📄 abstractrenderer.java
字号:
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ---------------------
* AbstractRenderer.java
* ---------------------
* (C) Copyright 2002-2007, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Nicolas Brodu;
*
* Changes:
* --------
* 22-Aug-2002 : Version 1, draws code out of AbstractXYItemRenderer to share
* with AbstractCategoryItemRenderer (DG);
* 01-Oct-2002 : Fixed errors reported by Checkstyle (DG);
* 06-Nov-2002 : Moved to the com.jrefinery.chart.renderer package (DG);
* 21-Nov-2002 : Added a paint table for the renderer to use (DG);
* 17-Jan-2003 : Moved plot classes into a separate package (DG);
* 25-Mar-2003 : Implemented Serializable (DG);
* 29-Apr-2003 : Added valueLabelFont and valueLabelPaint attributes, based on
* code from Arnaud Lelievre (DG);
* 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG);
* 13-Aug-2003 : Implemented Cloneable (DG);
* 15-Sep-2003 : Fixed serialization (NB);
* 17-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG);
* 07-Oct-2003 : Moved PlotRenderingInfo into RendererState to allow for
* multiple threads using a single renderer (DG);
* 20-Oct-2003 : Added missing setOutlinePaint() method (DG);
* 23-Oct-2003 : Split item label attributes into 'positive' and 'negative'
* values (DG);
* 26-Nov-2003 : Added methods to get the positive and negative item label
* positions (DG);
* 01-Mar-2004 : Modified readObject() method to prevent null pointer exceptions
* after deserialization (DG);
* 19-Jul-2004 : Fixed bug in getItemLabelFont(int, int) method (DG);
* 04-Oct-2004 : Updated equals() method, eliminated use of NumberUtils,
* renamed BooleanUtils --> BooleanUtilities, ShapeUtils -->
* ShapeUtilities (DG);
* 15-Mar-2005 : Fixed serialization of baseFillPaint (DG);
* 16-May-2005 : Base outline stroke should never be null (DG);
* 01-Jun-2005 : Added hasListener() method for unit testing (DG);
* 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG);
* ------------- JFREECHART 1.0.x ---------------------------------------------
* 02-Feb-2007 : Minor API doc update (DG);
* 19-Feb-2007 : Fixes for clone() method (DG);
* 28-Feb-2007 : Use cached event to signal changes (DG);
* 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG);
* 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke,
* outlineStroke, shape, itemLabelsVisible, itemLabelFont,
* itemLabelPaint, positiveItemLabelPosition,
* negativeItemLabelPosition and createEntities override
* fields (DG);
* 13-Jun-2007 : Added new autoPopulate flags for core series attributes (DG);
* 23-Oct-2007 : Updated lookup methods to better handle overridden
* methods (DG);
*
*/
package org.jfree.chart.renderer;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.EventListener;
import java.util.List;
import javax.swing.event.EventListenerList;
import org.jfree.chart.event.RendererChangeEvent;
import org.jfree.chart.event.RendererChangeListener;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.plot.DrawingSupplier;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.io.SerialUtilities;
import org.jfree.ui.TextAnchor;
import org.jfree.util.BooleanList;
import org.jfree.util.BooleanUtilities;
import org.jfree.util.ObjectList;
import org.jfree.util.ObjectUtilities;
import org.jfree.util.PaintList;
import org.jfree.util.PaintUtilities;
import org.jfree.util.ShapeList;
import org.jfree.util.ShapeUtilities;
import org.jfree.util.StrokeList;
/**
* Base class providing common services for renderers. Most methods that update
* attributes of the renderer will fire a {@link RendererChangeEvent}, which
* normally means the plot that owns the renderer will receive notification that
* the renderer has been changed (the plot will, in turn, notify the chart).
*/
public abstract class AbstractRenderer implements Cloneable, Serializable {
/** For serialization. */
private static final long serialVersionUID = -828267569428206075L;
/** Zero represented as a <code>Double</code>. */
public static final Double ZERO = new Double(0.0);
/** The default paint. */
public static final Paint DEFAULT_PAINT = Color.blue;
/** The default outline paint. */
public static final Paint DEFAULT_OUTLINE_PAINT = Color.gray;
/** The default stroke. */
public static final Stroke DEFAULT_STROKE = new BasicStroke(1.0f);
/** The default outline stroke. */
public static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(1.0f);
/** The default shape. */
public static final Shape DEFAULT_SHAPE
= new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0);
/** The default value label font. */
public static final Font DEFAULT_VALUE_LABEL_FONT
= new Font("SansSerif", Font.PLAIN, 10);
/** The default value label paint. */
public static final Paint DEFAULT_VALUE_LABEL_PAINT = Color.black;
/**
* A flag that controls the visibility of ALL series.
*
* @deprecated This field is redundant, you can rely on seriesVisibleList
* and baseSeriesVisible. Deprecated from version 1.0.6 onwards.
*/
private Boolean seriesVisible;
/** A list of flags that controls whether or not each series is visible. */
private BooleanList seriesVisibleList;
/** The default visibility for each series. */
private boolean baseSeriesVisible;
/**
* A flag that controls the visibility of ALL series in the legend.
*
* @deprecated This field is redundant, you can rely on
* seriesVisibleInLegendList and baseSeriesVisibleInLegend.
* Deprecated from version 1.0.6 onwards.
*/
private Boolean seriesVisibleInLegend;
/**
* A list of flags that controls whether or not each series is visible in
* the legend.
*/
private BooleanList seriesVisibleInLegendList;
/** The default visibility for each series in the legend. */
private boolean baseSeriesVisibleInLegend;
/**
* The paint for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on paintList and
* basePaint. Deprecated from version 1.0.6 onwards.
*/
private transient Paint paint;
/** The paint list. */
private PaintList paintList;
/**
* A flag that controls whether or not the paintList is auto-populated
* in the {@link #lookupSeriesPaint(int)} method.
*
* @since 1.0.6
*/
private boolean autoPopulateSeriesPaint;
/** The base paint. */
private transient Paint basePaint;
/**
* The fill paint for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on fillPaintList and
* baseFillPaint. Deprecated from version 1.0.6 onwards.
*/
private transient Paint fillPaint;
/** The fill paint list. */
private PaintList fillPaintList;
/**
* A flag that controls whether or not the fillPaintList is auto-populated
* in the {@link #lookupSeriesFillPaint(int)} method.
*
* @since 1.0.6
*/
private boolean autoPopulateSeriesFillPaint;
/** The base fill paint. */
private transient Paint baseFillPaint;
/**
* The outline paint for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on outlinePaintList
* and baseOutlinePaint. Deprecated from version 1.0.6 onwards.
*/
private transient Paint outlinePaint;
/** The outline paint list. */
private PaintList outlinePaintList;
/**
* A flag that controls whether or not the outlinePaintList is
* auto-populated in the {@link #lookupSeriesOutlinePaint(int)} method.
*
* @since 1.0.6
*/
private boolean autoPopulateSeriesOutlinePaint;
/** The base outline paint. */
private transient Paint baseOutlinePaint;
/**
* The stroke for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on strokeList and
* baseStroke. Deprecated from version 1.0.6 onwards.
*/
private transient Stroke stroke;
/** The stroke list. */
private StrokeList strokeList;
/**
* A flag that controls whether or not the strokeList is auto-populated
* in the {@link #lookupSeriesStroke(int)} method.
*
* @since 1.0.6
*/
private boolean autoPopulateSeriesStroke;
/** The base stroke. */
private transient Stroke baseStroke;
/**
* The outline stroke for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on strokeList and
* baseStroke. Deprecated from version 1.0.6 onwards.
*/
private transient Stroke outlineStroke;
/** The outline stroke list. */
private StrokeList outlineStrokeList;
/** The base outline stroke. */
private transient Stroke baseOutlineStroke;
/**
* A flag that controls whether or not the outlineStrokeList is
* auto-populated in the {@link #lookupSeriesOutlineStroke(int)} method.
*
* @since 1.0.6
*/
private boolean autoPopulateSeriesOutlineStroke;
/**
* The shape for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on shapeList and
* baseShape. Deprecated from version 1.0.6 onwards.
*/
private transient Shape shape;
/** A shape list. */
private ShapeList shapeList;
/**
* A flag that controls whether or not the shapeList is auto-populated
* in the {@link #lookupSeriesShape(int)} method.
*
* @since 1.0.6
*/
private boolean autoPopulateSeriesShape;
/** The base shape. */
private transient Shape baseShape;
/**
* Visibility of the item labels for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on
* itemLabelsVisibleList and baseItemLabelsVisible. Deprecated from
* version 1.0.6 onwards.
*/
private Boolean itemLabelsVisible;
/** Visibility of the item labels PER series. */
private BooleanList itemLabelsVisibleList;
/** The base item labels visible. */
private Boolean baseItemLabelsVisible;
/**
* The item label font for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on itemLabelFontList
* and baseItemLabelFont. Deprecated from version 1.0.6 onwards.
*/
private Font itemLabelFont;
/** The item label font list (one font per series). */
private ObjectList itemLabelFontList;
/** The base item label font. */
private Font baseItemLabelFont;
/**
* The item label paint for ALL series.
*
* @deprecated This field is redundant, you can rely on itemLabelPaintList
* and baseItemLabelPaint. Deprecated from version 1.0.6 onwards.
*/
private transient Paint itemLabelPaint;
/** The item label paint list (one paint per series). */
private PaintList itemLabelPaintList;
/** The base item label paint. */
private transient Paint baseItemLabelPaint;
/**
* The positive item label position for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on the
* positiveItemLabelPositionList and basePositiveItemLabelPosition
* fields. Deprecated from version 1.0.6 onwards.
*/
private ItemLabelPosition positiveItemLabelPosition;
/** The positive item label position (per series). */
private ObjectList positiveItemLabelPositionList;
/** The fallback positive item label position. */
private ItemLabelPosition basePositiveItemLabelPosition;
/**
* The negative item label position for ALL series (optional).
*
* @deprecated This field is redundant, you can rely on the
* negativeItemLabelPositionList and baseNegativeItemLabelPosition
* fields. Deprecated from version 1.0.6 onwards.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -