pieplot.java

来自「JfreeChart 常用图表例子」· Java 代码 · 共 1,886 行 · 第 1/5 页

JAVA
1,886
字号
     *      * @return The paint (never <code>null</code>).     */    public Paint getLabelLinkPaint() {        return this.labelLinkPaint;       }        /**     * Sets the paint used for the lines that connect pie sections to their      * corresponding labels, and sends a {@link PlotChangeEvent} to all      * registered listeners.     *      * @param paint  the paint (<code>null</code> not permitted).     */    public void setLabelLinkPaint(Paint paint) {        if (paint == null) {            throw new IllegalArgumentException("Null 'paint' argument.");        }        this.labelLinkPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the stroke used for the label linking lines.     *      * @return The stroke.     */    public Stroke getLabelLinkStroke() {        return this.labelLinkStroke;       }        /**     * Sets the link stroke and sends a {@link PlotChangeEvent} to all      * registered listeners.     *      * @param stroke  the stroke.     */    public void setLabelLinkStroke(Stroke stroke) {        if (stroke == null) {            throw new IllegalArgumentException("Null 'stroke' argument.");        }        this.labelLinkStroke = stroke;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the section label font.     *     * @return The font (never <code>null</code>).     */    public Font getLabelFont() {        return this.labelFont;    }    /**     * Sets the section label font and sends a {@link PlotChangeEvent} to all      * registered listeners.     *     * @param font  the font (<code>null</code> not permitted).     */    public void setLabelFont(Font font) {        if (font == null) {            throw new IllegalArgumentException("Null 'font' argument.");        }        this.labelFont = font;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the section label paint.     *     * @return The paint (never <code>null</code>).     */    public Paint getLabelPaint() {        return this.labelPaint;    }    /**     * Sets the section label paint and sends a {@link PlotChangeEvent} to all      * registered listeners.     *     * @param paint  the paint (<code>null</code> not permitted).     */    public void setLabelPaint(Paint paint) {        if (paint == null) {            throw new IllegalArgumentException("Null 'paint' argument.");        }        this.labelPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the section label background paint.     *     * @return The paint (possibly <code>null</code>).     */    public Paint getLabelBackgroundPaint() {        return this.labelBackgroundPaint;    }    /**     * Sets the section label background paint and sends a      * {@link PlotChangeEvent} to all registered listeners.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setLabelBackgroundPaint(Paint paint) {        this.labelBackgroundPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the section label outline paint.     *     * @return The paint (possibly <code>null</code>).     */    public Paint getLabelOutlinePaint() {        return this.labelOutlinePaint;    }    /**     * Sets the section label outline paint and sends a      * {@link PlotChangeEvent} to all registered listeners.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setLabelOutlinePaint(Paint paint) {        this.labelOutlinePaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the section label outline stroke.     *     * @return The stroke (possibly <code>null</code>).     */    public Stroke getLabelOutlineStroke() {        return this.labelOutlineStroke;    }    /**     * Sets the section label outline stroke and sends a      * {@link PlotChangeEvent} to all registered listeners.     *     * @param stroke  the stroke (<code>null</code> permitted).     */    public void setLabelOutlineStroke(Stroke stroke) {        this.labelOutlineStroke = stroke;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the section label shadow paint.     *     * @return The paint (possibly <code>null</code>).     */    public Paint getLabelShadowPaint() {        return this.labelShadowPaint;    }    /**     * Sets the section label shadow paint and sends a {@link PlotChangeEvent}     * to all registered listeners.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setLabelShadowPaint(Paint paint) {        this.labelShadowPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the tool tip generator, an object that is responsible for      * generating the text items used for tool tips by the plot.  If the      * generator is <code>null</code>, no tool tips will be created.     *     * @return The generator (possibly <code>null</code>).     */    public PieToolTipGenerator getToolTipGenerator() {        return this.toolTipGenerator;    }    /**     * Sets the tool tip generator and sends a {@link PlotChangeEvent} to all      * registered listeners.  Set the generator to <code>null</code> if you      * don't want any tool tips.     *     * @param generator  the generator (<code>null</code> permitted).     */    public void setToolTipGenerator(PieToolTipGenerator generator) {        this.toolTipGenerator = generator;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the URL generator.     *     * @return The generator (possibly <code>null</code>).     */    public PieURLGenerator getURLGenerator() {        return this.urlGenerator;    }    /**     * Sets the URL generator and sends a {@link PlotChangeEvent} to all      * registered listeners.     *     * @param generator  the generator (<code>null</code> permitted).     */    public void setURLGenerator(PieURLGenerator generator) {        this.urlGenerator = generator;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the minimum arc angle that will be drawn.  Pie sections for an      * angle smaller than this are not drawn, to avoid a JDK bug.     *     * @return The minimum angle.     */    public double getMinimumArcAngleToDraw() {        return this.minimumArcAngleToDraw;    }    /**     * Sets the minimum arc angle that will be drawn.  Pie sections for an      * angle smaller than this are not drawn, to avoid a JDK bug.  See this      * link for details:     * <br><br>     * <a href="http://www.jfree.org/phpBB2/viewtopic.php?t=2707">     * http://www.jfree.org/phpBB2/viewtopic.php?t=2707</a>     * <br><br>     * ...and this bug report in the Java Bug Parade:     * <br><br>     * <a href=     * "http://developer.java.sun.com/developer/bugParade/bugs/4836495.html">     * http://developer.java.sun.com/developer/bugParade/bugs/4836495.html</a>     *     * @param angle  the minimum angle.     */    public void setMinimumArcAngleToDraw(double angle) {        this.minimumArcAngleToDraw = angle;    }        /**     * Returns the shape used for legend items.     *      * @return The shape.     */    public Shape getLegendItemShape() {        return this.legendItemShape;    }    /**     * Sets the shape used for legend items.     *      * @param shape  the shape (<code>null</code> not permitted).     */    public void setLegendItemShape(Shape shape) {        if (shape == null) {            throw new IllegalArgumentException("Null 'shape' argument.");        }        this.legendItemShape = shape;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the legend label tool tip generator.     *      * @return The legend label tool tip generator (possibly <code>null</code>).     */    public PieSectionLabelGenerator getLegendLabelToolTipGenerator() {        return this.legendLabelToolTipGenerator;    }        /**     * Sets the legend label tool tip generator and sends a      * {@link PlotChangeEvent} to all registered listeners.     *      * @param generator  the generator (<code>null</code> permitted).     */    public void setLegendLabelToolTipGenerator(            PieSectionLabelGenerator generator) {        this.legendLabelToolTipGenerator = generator;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the legend label generator.     *      * @return The legend label generator (never <code>null</code>).     */    public PieSectionLabelGenerator getLegendLabelGenerator() {        return this.legendLabelGenerator;    }        /**     * Sets the legend label generator and sends a {@link PlotChangeEvent} to      * all registered listeners.     *      * @param generator  the generator (<code>null</code> not permitted).     */    public void setLegendLabelGenerator(PieSectionLabelGenerator generator) {        if (generator == null) {            throw new IllegalArgumentException("Null 'generator' argument.");        }        this.legendLabelGenerator = generator;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Initialises the drawing procedure.  This method will be called before      * the first item is rendered, giving the plot an opportunity to initialise     * any state information it wants to maintain.     *     * @param g2  the graphics device.     * @param plotArea  the plot area (<code>null</code> not permitted).     * @param plot  the plot.     * @param index  the secondary index (<code>null</code> for primary      *               renderer).     * @param info  collects chart rendering information for return to caller.     *      * @return A state object (maintains state information relevant to one      *         chart drawing).     */    public PiePlotState initialise(Graphics2D g2,                                   Rectangle2D plotArea,                                   PiePlot plot,                                   Integer index,                                   PlotRenderingInfo info) {             PiePlotState state = new PiePlotState(info);        state.setPassesRequired(2);        state.setTotal(            DatasetUtilities.calculatePieDatasetTotal(plot.getDataset())        );        state.setLatestAngle(plot.getStartAngle());        return state;            }        /**     * Draws the plot on a Java 2D graphics device (such as the screen or a      * printer).     *     * @param g2  the graphics device.     * @param area  the area within which the plot should be drawn.     * @param anchor  the anchor point (<code>null</code> permitted).     * @param parentState  the state from the parent plot, if there is one.     * @param info  collects info about the drawing      *              (<code>null</code> permitted).     */    public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,                     PlotState parentState,                     PlotRenderingInfo info) {        // adjust for insets...        RectangleInsets insets = getInsets();        insets.trim(area);        if (info != null) {            info.setPlotArea(area);            info.setDataArea(area);        }        drawBackground(g2, area);        drawOutline(g2, area);        Shape savedClip = g2.getClip();        g2.clip(area);        Composite originalComposite = g2.getComposite();        g2.setComposite(            AlphaComposite.getInstance(                AlphaComposite.SRC_OVER, getForegroundAlpha()            )        );

⌨️ 快捷键说明

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