com.ijchart.xychart.plot
Class CategoryPlot

java.lang.Object
  extended by com.ijchart.xychart.plot.AbstractPlot
      extended by com.ijchart.xychart.plot.AbstractAxisPlot
          extended by com.ijchart.xychart.plot.CategoryPlot
All Implemented Interfaces:
IAxisChangeListener, IDatasetChangeListener, IRenderChangeListener, IZoomable, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
AbstractCombineCategoryPlot, Category3DPlot

public class CategoryPlot
extends AbstractAxisPlot
implements java.lang.Cloneable, java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

Used to display the two coordinate axis are (@Link com.ijchart.xychart.axis.category.CategoryAxis), (@Link com.ijchart.xychart.axis.value.AbstractValueAxis) of the plot.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Field Summary
static boolean DEFAULT_CATEGORY_CROSSHAIR_LOCKED_ON_DATA
           A default flag that controls whether or not the crosshair locks onto actual data points.
static boolean DEFAULT_CATEGORY_CROSSHAIR_VISIBLE
           A default flag that controls whether or not a category crosshair is drawn.
 
Fields inherited from class com.ijchart.xychart.plot.AbstractAxisPlot
DEFAULT_CHART_ORIENTATION, DEFAULT_CROSSHAIR_PAINT, DEFAULT_CROSSHAIR_STROKE, DEFAULT_DOMAIN_CROSSHAIR_LOCKED_ON_DATA, DEFAULT_DOMAIN_CROSSHAIR_VISIBLE, DEFAULT_DOMAIN_GRIDLINE_VISIBLE, DEFAULT_DOMAIN_ZERO_BASELINE_VISIBLE, DEFAULT_GRIDLINE_PAINT, DEFAULT_GRIDLINE_STROKE, DEFAULT_VALUE_CROSSHAIR_LOCKED_ON_DATA, DEFAULT_VALUE_CROSSHAIR_VISIBLE, DEFAULT_VALUE_GRIDLINE_VISIBLE, domainAxes, renderToDomainAxis, renderToValueAxis, valueAxes
 
Fields inherited from class com.ijchart.xychart.plot.AbstractPlot
dataArea, DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_IMAGE_ALIGNMENT, DEFAULT_BACKGROUND_PAINT, DEFAULT_BORDER_PAINT, DEFAULT_BORDER_STROKE, DEFAULT_BORDER_VISIBLE, DEFAULT_DRAW_NO_DATA_MESSAGE, DEFAULT_DRAWINT_SUPPLIER, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_MINIMUM_HEIGHT_TO_DRAW, DEFAULT_MINIMUM_WIDTH_TO_DRAW, DEFAULT_NO_DATA_MESSAGE, DEFAULT_NO_DATA_MESSAGE_FONT, DEFAULT_NO_DATA_MESSAGE_PAINT, DEFAULT_RENDER_CALL_ORDER, drawNoDataMessage, plotShapes, renderingOrder, renderShapesList
 
Constructor Summary
CategoryPlot()
           Default constructor.
CategoryPlot(CategoryAxis categoryAxis, AbstractValueAxis valueAxis, AbstractCategoryRender render)
           Creates a new plot.
 
Method Summary
 java.lang.Object clone()
           Returns a clone of the plot.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, ChartShapeCollection chartShapes)
           Draws the plot within the specified area.Subclasses need to provide an implementation of this method, obviously.
protected  java.awt.geom.Rectangle2D drawAxes(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PlotShapeCollection shapeCollection)
           A utility method for drawing the plot's axes.
 boolean equals(java.lang.Object obj)
           Tests the plot for equality with an arbitrary object.
 CategoryAxis getCategoryAxis()
           Returns the category axis for the plot.
 CategoryAxis getCategoryAxis(int index)
           Returns a category axis.
 CategoryAxis getCategoryAxisByRenderIndex(int renderIndex)
           Returns a category axis.
 int getCategoryAxisCount()
           Returns the number of category axes.
 RectangleEdge getCategoryAxisEdge()
           Returns the category axis edge.
 RectangleEdge getCategoryAxisEdge(int index)
           Returns the edge for a category axis.
 int getCategoryAxisIndex(CategoryAxis axis)
           Returns the index of the specified axis, or -1 if the axis is not assigned to the plot.
 AxisLocation getCategoryAxisLocation()
           Returns the category axis location for the primary category axis.
 AxisLocation getCategoryAxisLocation(int index)
           Returns the location for a category axis.
protected  CategoryAxis getNotNullCategoryAxis(int index)
           Search the category axis at the specified position,first search previous,if not found search next.
protected  AbstractValueAxis getNotNullValueAxis(int index)
           Search the value axis at the specified position,first search previous,if not found search next.
protected  RectangleEdge getNotNullValueAxisEdge(int index)
           Search the value axis edge at the specified position,first search previous,if not found search next.
 PlotType getPlotType()
           Returns a short string describing the plot type.
 AbstractCategoryRender getRender()
           Returns a reference to the render for the plot.
 AbstractCategoryRender getRender(int index)
           Returns the render at the given index.
 int getRenderIndex(AbstractCategoryRender render)
           Returns the index of the specified render, or -1 if the render is not assigned to this plot.
 java.util.Collection getRenders()
           Returns the collection of renders,and this collection is unmodifiable.
 int hashCode()
           Returns a hash code for this object.
 boolean isDomainZoomable()
           Returns true if the plot's domain axis is zoomable, and false otherwise.
 void setCategoryAxes(CategoryAxis[] axes)
           Sets the category axes for this plot and sends a PlotChangeEvent to all registered listeners.
 void setCategoryAxes(CategoryAxis[] axes, int startIndex)
           Sets the category axes for this plot and sends a PlotChangeEvent to all registered listeners.
 void setCategoryAxis(CategoryAxis axis)
           Sets the category axis for the plot and sends a PlotChangeEvent to all registered listeners.
 void setCategoryAxis(int index, CategoryAxis axis)
           Sets a category axis and sends a PlotChangeEvent to all registered listeners.
 void setCategoryAxis(int index, CategoryAxis axis, boolean notify)
           Sets a category axis and sends a PlotChangeEvent to all registered listeners.
 void setCategoryAxisLocation(AxisLocation location)
           Sets the location of the category axis and, if requested, sends a PlotChangeEvent to all registered listeners.
 void setCategoryAxisLocation(int index, AxisLocation location)
           Sets the location for a category axis and sends a PlotChangeEvent to all registered listeners.
 void setRender(AbstractCategoryRender render)
           Sets the render at index 0 (sometimes referred to as the "primary" render) and sends a PlotChangeEvent to all registered listeners.
 void setRender(AbstractCategoryRender render, boolean notify)
           Sets the render at index 0 (sometimes referred to as the "primary" render) and, if requested, sends a PlotChangeEvent to all registered listeners.
 void setRender(int index, AbstractCategoryRender render)
           Sets the render at the specified index and sends a PlotChangeEvent to all registered listeners.
 void setRender(int index, AbstractCategoryRender render, boolean notify)
           Sets a render.
 void setRenders(AbstractCategoryRender[] renders, int startIndex)
           Sets the renders for this plot and sends a PlotChangeEvent to all registered listeners.
 java.lang.String toString()
           Override toString method.
 
Methods inherited from class com.ijchart.xychart.plot.AbstractAxisPlot
allocateRenderShapesList, clearDomainAxes, clearValueAxes, drawCrosshair, drawValueGridlines, getAxisOffset, getCrosshairPoint, getDomainCrosshairPaint, getDomainCrosshairStroke, getDomainGridlinePaint, getDomainGridlineStroke, getOrientation, getRenderIndexForValueAxis, getRenderShapeCollection, getValueAxis, getValueAxis, getValueAxisByRenderIndex, getValueAxisCount, getValueAxisEdge, getValueAxisEdge, getValueAxisIndex, getValueAxisLocation, getValueAxisLocation, getValueCrosshairPaint, getValueCrosshairStroke, getValueGridlinePaint, getValueGridlineStroke, isDomainCrosshairLockedOnData, isDomainCrosshairVisible, isDomainGridlineVisible, isValueCrosshairLockedOnData, isValueCrosshairVisible, isValueGridlineVisible, mapRenderToDomainAxis, mapRenderToValueAxis, mapValueAxisToRender, setAxisOffset, setDomainCrosshairLockedOnData, setDomainCrosshairPaint, setDomainCrosshairStroke, setDomainCrosshairVisible, setDomainGridlinePaint, setDomainGridlineStroke, setDomainGridlineVisible, setOrientation, setValueAxes, setValueAxes, setValueAxis, setValueAxis, setValueAxis, setValueAxisLocation, setValueAxisLocation, setValueAxisLocation, setValueAxisLocation, setValueCrosshairLockedOnData, setValueCrosshairPaint, setValueCrosshairStroke, setValueCrosshairVisible, setValueGridlinePaint, setValueGridlineStroke, setValueGridlineVisible, translateMarkerShapes, zoomValueAxes
 
Methods inherited from class com.ijchart.xychart.plot.AbstractPlot
addChangeListener, axisChanged, datasetChanged, drawBackground, drawBackgroundImage, drawBorder, drawNoDataMessage, firePlotChanged, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getBorderPaint, getBorderStroke, getDataArea, getDrawingSupplier, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getRenderDrawOrder, getRenderShapesList, getSubPlots, handleClick, isBorderVisible, isDrawNoDataMessage, isValueZoomable, notifyListeners, removeChangeListener, renderChanged, resolveDomainAxisLocation, resolveValueAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setBorderPaint, setBorderStroke, setBorderVisible, setDrawingSupplier, setDrawNoDataMessage, setForegroundAlpha, setInsets, setListObject, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setRenderDrawOrder, zoomDomainAxes
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ijchart.xychart.listener.IRenderChangeListener
renderChanged
 

Field Detail

DEFAULT_CATEGORY_CROSSHAIR_VISIBLE

public static final boolean DEFAULT_CATEGORY_CROSSHAIR_VISIBLE
A default flag that controls whether or not a category crosshair is drawn.

See Also:
Constant Field Values

DEFAULT_CATEGORY_CROSSHAIR_LOCKED_ON_DATA

public static final boolean DEFAULT_CATEGORY_CROSSHAIR_LOCKED_ON_DATA
A default flag that controls whether or not the crosshair locks onto actual data points.

See Also:
Constant Field Values
Constructor Detail

CategoryPlot

public CategoryPlot()
Default constructor.


CategoryPlot

public CategoryPlot(CategoryAxis categoryAxis,
                    AbstractValueAxis valueAxis,
                    AbstractCategoryRender render)
Creates a new plot.

Parameters:
categoryAxis - CategoryAxis The category axis (null permitted).
valueAxis - AbstractValueAxis The value axis (null permitted).
render - AbstractCategoryRender The item render (null permitted).
Method Detail

getCategoryAxisCount

public int getCategoryAxisCount()
Returns the number of category axes.

Returns:
The axis count.

getCategoryAxis

public CategoryAxis getCategoryAxis()
Returns the category axis for the plot.

Returns:
The category axis (null permitted).

getCategoryAxis

public CategoryAxis getCategoryAxis(int index)
Returns a category axis.

Parameters:
index - The axis index.
Returns:
The axis (null possible).

setCategoryAxis

public void setCategoryAxis(CategoryAxis axis)
Sets the category axis for the plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
axis - CategoryAxis The axis (null not permitted).

getCategoryAxisByRenderIndex

public CategoryAxis getCategoryAxisByRenderIndex(int renderIndex)
Returns a category axis.

Parameters:
renderIndex - The index of render.
Returns:
The category axis (null possible).

setCategoryAxis

public void setCategoryAxis(int index,
                            CategoryAxis axis)
Sets a category axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - int The axis index,must be greater than or equal to 0.
axis - CategoryAxis The axis (null not permitted).

setCategoryAxis

public void setCategoryAxis(int index,
                            CategoryAxis axis,
                            boolean notify)
Sets a category axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - int The axis index,must be greater than or equal to 0.
axis - CategoryAxis The axis (null not permitted).
notify - boolean Whether or not notify listener.

setCategoryAxes

public void setCategoryAxes(CategoryAxis[] axes)
Sets the category axes for this plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
axes - CategoryAxis[] The axes (null not permitted).

setCategoryAxes

public void setCategoryAxes(CategoryAxis[] axes,
                            int startIndex)
Sets the category axes for this plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
axes - CategoryAxis[] The axes (null not permitted).
startIndex - int The beginning of the index value, startIndex before the target will not be covered. must be greater than or equal to 0.

getCategoryAxisIndex

public int getCategoryAxisIndex(CategoryAxis axis)
Returns the index of the specified axis, or -1 if the axis is not assigned to the plot.

Parameters:
axis - The axis (null not permitted).
Returns:
The axis index.

getRender

public AbstractCategoryRender getRender()
Returns a reference to the render for the plot.

Returns:
AbstractCategoryRender The render.

getRender

public AbstractCategoryRender getRender(int index)
Returns the render at the given index.

Parameters:
index - The render index (zero-based).
Returns:
AbstractCategoryRender The render (possibly null).

getRenders

public java.util.Collection getRenders()
Returns the collection of renders,and this collection is unmodifiable.

Specified by:
getRenders in class AbstractPlot
Returns:
Collection The collection of renders.

setRender

public void setRender(AbstractCategoryRender render)
Sets the render at index 0 (sometimes referred to as the "primary" render) and sends a PlotChangeEvent to all registered listeners.

Parameters:
render - AbstractCategoryRender The render (null not permitted.

setRender

public void setRender(AbstractCategoryRender render,
                      boolean notify)
Sets the render at index 0 (sometimes referred to as the "primary" render) and, if requested, sends a PlotChangeEvent to all registered listeners.

Parameters:
render - AbstractCategoryRender The render (null not permitted).
notify - boolean Whether or not notify listeners.

setRender

public void setRender(int index,
                      AbstractCategoryRender render)
Sets the render at the specified index and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - int The index (zero-based).
render - AbstractCategoryRender The render (null not permitted).

setRender

public void setRender(int index,
                      AbstractCategoryRender render,
                      boolean notify)
Sets a render. A PlotChangeEvent is sent to all registered listeners.

Parameters:
index - int The dataset index (zero-based).
render - AbstractCategoryRender The render (null not permitted).
notify - boolean Whether or not notify listeners.

setRenders

public void setRenders(AbstractCategoryRender[] renders,
                       int startIndex)
Sets the renders for this plot and sends a PlotChangeEvent to all registered listeners.

Parameters:
renders - AbstractCategoryRender[] The renders (null not permitted).
startIndex - int The beginning of the index value, startIndex before the target will not be covered. must be greater than or equal to 0.

getRenderIndex

public int getRenderIndex(AbstractCategoryRender render)
Returns the index of the specified render, or -1 if the render is not assigned to this plot.

Parameters:
render - AbstractCategoryRender The render (null permitted).
Returns:
int The render index.

getCategoryAxisLocation

public AxisLocation getCategoryAxisLocation()
Returns the category axis location for the primary category axis.

Returns:
The location (never null).

getCategoryAxisLocation

public AxisLocation getCategoryAxisLocation(int index)
Returns the location for a category axis.

Parameters:
index - The axis index,must be greater than or equal to 0.
Returns:
The location.

setCategoryAxisLocation

public void setCategoryAxisLocation(AxisLocation location)
Sets the location of the category axis and, if requested, sends a PlotChangeEvent to all registered listeners.

Parameters:
location - The axis location (null not permitted).

setCategoryAxisLocation

public void setCategoryAxisLocation(int index,
                                    AxisLocation location)
Sets the location for a category axis and sends a PlotChangeEvent to all registered listeners.

Parameters:
index - The axis index,must be greater than or equal to 0.
location - The location (null not permitted).

getCategoryAxisEdge

public RectangleEdge getCategoryAxisEdge()
Returns the category axis edge. This is derived from the axis location and the chart orientation.

Returns:
The edge (never null).

getCategoryAxisEdge

public RectangleEdge getCategoryAxisEdge(int index)
Returns the edge for a category axis.

Parameters:
index - The axis index,must be greater than or equal to 0.
Returns:
The edge (never null).

isDomainZoomable

public boolean isDomainZoomable()
Returns true if the plot's domain axis is zoomable, and false otherwise.

Specified by:
isDomainZoomable in interface IZoomable
Overrides:
isDomainZoomable in class AbstractPlot
Returns:
boolean A boolean.

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 ChartShapeCollection chartShapes)
Draws the plot within the specified area.Subclasses need to provide an implementation of this method, obviously.

Specified by:
draw in class AbstractPlot
Parameters:
g2 - Graphics2D The graphics device (null not permitted).
plotArea - Rectangle2D The plot draw area (null not permitted).
chartShapes - ChartShapeCollection Collects information about the chart (null not permitted).

drawAxes

protected java.awt.geom.Rectangle2D drawAxes(java.awt.Graphics2D g2,
                                             java.awt.geom.Rectangle2D plotArea,
                                             PlotShapeCollection shapeCollection)
A utility method for drawing the plot's axes.

Parameters:
g2 - The graphics device (null not permitted).
plotArea - The plot draw area (null not permitted).
shapeCollection - PlotShapeCollection Collects information about the plot (null not permitted).
Returns:
Rectangle2D The data area.

getNotNullCategoryAxis

protected CategoryAxis getNotNullCategoryAxis(int index)
Search the category axis at the specified position,first search previous,if not found search next.

Parameters:
index - int The index.
Returns:
CategoryAxis The category axis.

getNotNullValueAxis

protected AbstractValueAxis getNotNullValueAxis(int index)
Search the value axis at the specified position,first search previous,if not found search next.

Parameters:
index - int The index.
Returns:
AbstractValueAxis The value axis.

getNotNullValueAxisEdge

protected RectangleEdge getNotNullValueAxisEdge(int index)
Search the value axis edge at the specified position,first search previous,if not found search next.

Parameters:
index - int The index.
Returns:
RectangleEdge The edge of value axis.

getPlotType

public PlotType getPlotType()
Returns a short string describing the plot type.

Specified by:
getPlotType in class AbstractPlot
Returns:
The plot type.

equals

public boolean equals(java.lang.Object obj)
Tests the plot for equality with an arbitrary object.

Overrides:
equals in class AbstractAxisPlot
Parameters:
obj - The object to test against (null permitted).
Returns:
A boolean.

hashCode

public int hashCode()
Returns a hash code for this object.

Overrides:
hashCode in class AbstractAxisPlot
Returns:
A hash code.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the plot.

Overrides:
clone in class AbstractAxisPlot
Returns:
A clone.
Throws:
java.lang.CloneNotSupportedException - if the cloning is not supported.

toString

public java.lang.String toString()
Override toString method.

Overrides:
toString in class AbstractAxisPlot
Returns:
String