⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jfreechart.java

📁 JfreeChart 常用图表例子
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        return this.borderVisible;    }    /**     * Sets a flag that controls whether or not a border is drawn around the      * outside of the chart.     *     * @param visible  the flag.     */    public void setBorderVisible(boolean visible) {        this.borderVisible = visible;        fireChartChanged();    }    /**     * Returns the stroke used to draw the chart border (if visible).     *     * @return The border stroke.     */    public Stroke getBorderStroke() {        return this.borderStroke;    }    /**     * Sets the stroke used to draw the chart border (if visible).     *     * @param stroke  the stroke.     */    public void setBorderStroke(Stroke stroke) {        this.borderStroke = stroke;        fireChartChanged();    }    /**     * Returns the paint used to draw the chart border (if visible).     *     * @return The border paint.     */    public Paint getBorderPaint() {        return this.borderPaint;    }    /**     * Sets the paint used to draw the chart border (if visible).     *     * @param paint  the paint.     */    public void setBorderPaint(Paint paint) {        this.borderPaint = paint;        fireChartChanged();    }    /**     * Returns the main chart title.  Very often a chart will have just one     * title, so we make this case simple by providing accessor methods for     * the main title.  However, multiple titles are supported - see the     * {@link #addSubtitle(Title)} method.     *     * @return The chart title (possibly <code>null</code>).     */    public TextTitle getTitle() {        return this.title;    }    /**     * Sets the main title for the chart and sends a {@link ChartChangeEvent}      * to all registered listeners.  If you do not want a title for the      * chart, set it to <code>null</code>.  If you want more than one title on     * a chart, use the {@link #addSubtitle(Title)} method.     *     * @param title  the title (<code>null</code> permitted).     */    public void setTitle(TextTitle title) {        this.title = title;        fireChartChanged();    }    /**     * Sets the chart title and sends a {@link ChartChangeEvent} to all      * registered listeners.  This is a convenience method that ends up calling      * the {@link #setTitle(TextTitle)} method.  If there is an existing title,     * its text is updated, otherwise a new title using the default font is      * added to the chart.  If <code>text</code> is <code>null</code> the chart     * title is set to <code>null</code>.     *     * @param text  the title text (<code>null</code> permitted).     */    public void setTitle(String text) {        if (text != null) {            if (this.title == null) {                setTitle(new TextTitle(text, JFreeChart.DEFAULT_TITLE_FONT));            }            else {                this.title.setText(text);            }        }        else {            setTitle((TextTitle) null);        }    }    /**     * Returns the legend for the chart, if there is one.  Note that a chart     * can have more than one legend - this method returns the first.     *      * @return The legend (possibly <code>null</code>).     */    public LegendTitle getLegend() {        return getLegend(0);    }        /**     * Returns the nth legend for a chart, or <code>null</code>.     *      * @param index  the legend index (zero-based).     *      * @return The legend (possibly <code>null</code>).     */    public LegendTitle getLegend(int index) {        int seen = 0;        Iterator iterator = this.subtitles.iterator();        while (iterator.hasNext()) {            Title subtitle = (Title) iterator.next();            if (subtitle instanceof LegendTitle) {                if (seen == index) {                    return (LegendTitle) subtitle;                }                else {                    seen++;                   }            }        }        return null;            }        /**     * Removes the first legend in the chart and sends a      * {@link ChartChangeEvent} to all registered listeners.     */    public void removeLegend() {        removeSubtitle(getLegend());    }        /**     * Returns the list of subtitles for the chart.     *     * @return The subtitle list (possibly empty, but never <code>null</code>).     */    public List getSubtitles() {        return this.subtitles;    }    /**     * Sets the title list for the chart (completely replaces any existing      * titles).     *     * @param subtitles  the new list of subtitles (<code>null</code> not      *                   permitted).     */    public void setSubtitles(List subtitles) {        if (subtitles == null) {            throw new NullPointerException("Null 'subtitles' argument.");        }        this.subtitles = subtitles;        fireChartChanged();    }    /**     * Returns the number of titles for the chart.     *     * @return The number of titles for the chart.     */    public int getSubtitleCount() {        return this.subtitles.size();    }    /**     * Returns a chart subtitle.     *     * @param index  the index of the chart subtitle (zero based).     *     * @return A chart subtitle.     */    public Title getSubtitle(int index) {        if ((index < 0) || (index == getSubtitleCount())) {            throw new IllegalArgumentException("Index out of range.");        }        return (Title) this.subtitles.get(index);    }    /**     * Adds a chart subtitle, and notifies registered listeners that the chart      * has been modified.     *     * @param subtitle  the subtitle (<code>null</code> not permitted).     */    public void addSubtitle(Title subtitle) {        if (subtitle == null) {            throw new IllegalArgumentException("Null 'subtitle' argument.");        }        this.subtitles.add(subtitle);        subtitle.addChangeListener(this);        fireChartChanged();    }        /**     * Clears all subtitles from the chart and sends a {@link ChartChangeEvent}     * to all registered listeners.     */    public void clearSubtitles() {        Iterator iterator = this.subtitles.iterator();        while (iterator.hasNext()) {            Title t = (Title) iterator.next();            t.removeChangeListener(this);        }        this.subtitles.clear();        fireChartChanged();    }    /**     * Removes the specified subtitle and sends a {@link ChartChangeEvent} to     * all registered listeners.     *      * @param title  the title.     */    public void removeSubtitle(Title title) {        this.subtitles.remove(title);        fireChartChanged();    }        /**     * Returns the chart legend.     *     * @return The chart legend (possibly <code>null</code>).     */    public OldLegend getOldLegend() {        return this.oldLegend;    }    /**     * Sets the chart legend.  Registered listeners are notified that the chart     * has been modified. The legends chart reference is updated.     *     * @param legend  the new chart legend (<code>null</code> permitted).     */    public void setOldLegend(OldLegend legend) {        // if there is an existing legend, remove the chart from the list of        // change listeners...        OldLegend existing = this.oldLegend;        if (existing != null) {            existing.removeChangeListener(this);            existing.registerChart(null);        }        // set the new legend, and register the chart as a change listener...        this.oldLegend = legend;        if (legend != null) {            legend.registerChart(this);            legend.addChangeListener(this);        }        // notify chart change listeners...        fireChartChanged();    }    /**     * Returns the plot for the chart.  The plot is a class responsible for     * coordinating the visual representation of the data, including the axes     * (if any).     *     * @return The plot.     */    public Plot getPlot() {        return this.plot;    }    /**     * Returns the plot cast as a {@link CategoryPlot}.     * <p>     * NOTE: if the plot is not an instance of {@link CategoryPlot}, then a     * <code>ClassCastException</code> is thrown.     *     * @return The plot.     */    public CategoryPlot getCategoryPlot() {        return (CategoryPlot) this.plot;    }    /**     * Returns the plot cast as an {@link XYPlot}.     * <p>     * NOTE: if the plot is not an instance of {@link XYPlot}, then a     * <code>ClassCastException</code> is thrown.     *     * @return The plot.     */    public XYPlot getXYPlot() {        return (XYPlot) this.plot;    }    /**     * Returns a flag that indicates whether or not anti-aliasing is used when     * the chart is drawn.     *     * @return The flag.     */    public boolean getAntiAlias() {        Object o = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);        if (o == null) {            return false;        }        return (o.equals(RenderingHints.VALUE_ANTIALIAS_ON));    }    /**     * Sets a flag that indicates whether or not anti-aliasing is used when the     * chart is drawn.     * <P>     * Anti-aliasing usually improves the appearance of charts, but is slower.     *     * @param flag  the new value of the flag.     */    public void setAntiAlias(boolean flag) {        Object o = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);        if (o == null) {            o = RenderingHints.VALUE_ANTIALIAS_DEFAULT;        }        if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(o)             || flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(o)) {            // no change, do nothing            return;        }        if (flag) {            this.renderingHints.put(RenderingHints.KEY_ANTIALIASING,                                     RenderingHints.VALUE_ANTIALIAS_ON);        }        else {            this.renderingHints.put(RenderingHints.KEY_ANTIALIASING,                                     RenderingHints.VALUE_ANTIALIAS_OFF);        }        fireChartChanged();    }    /**     * Returns the paint used for the chart background.     *     * @return The paint (possibly <code>null</code>).     */    public Paint getBackgroundPaint() {        return this.backgroundPaint;    }    /**     * Sets the paint used to fill the chart background and sends a      * {@link ChartChangeEvent} to all registered listeners.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setBackgroundPaint(Paint paint) {        if (this.backgroundPaint != null) {            if (!this.backgroundPaint.equals(paint)) {                this.backgroundPaint = paint;                fireChartChanged();            }        }        else {            if (paint != null) {                this.backgroundPaint = paint;                fireChartChanged();            }        }    }    /**     * Returns the background image for the chart, or <code>null</code> if      * there is no image.     *     * @return The image (possibly <code>null</code>).     */    public Image getBackgroundImage() {        return this.backgroundImage;    }    /**     * Sets the background image for the chart and sends a      * {@link ChartChangeEvent} to all registered listeners.     *     * @param image  the image (<code>null</code> permitted).     */    public void setBackgroundImage(Image image) {        if (this.backgroundImage != null) {            if (!this.backgroundImage.equals(image)) {                this.backgroundImage = image;                fireChartChanged();            }        }        else {            if (image != null) {                this.backgroundImage = image;                fireChartChanged();            }        }    }    /**     * Returns the background image alignment. Alignment constants are defined      * in the <code>org.jfree.ui.Align</code> class in the JCommon class      * library.     *     * @return The alignment.     */    public int getBackgroundImageAlignment() {        return this.backgroundImageAlignment;    }    /**     * Sets the background alignment.  Alignment options are defined by the      * {@link org.jfree.ui.Align} class.     *     * @param alignment  the alignment.     */    public void setBackgroundImageAlignment(int alignment) {        if (this.backgroundImageAlignment != alignment) {            this.backgroundImageAlignment = alignment;            fireChartChanged();        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -