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.

用于显示两个坐标轴分别是CategoryAxis, AbstractValueAxis的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
          缺省控制十字线是否自动锁定数据点.
static boolean DEFAULT_CATEGORY_CROSSHAIR_VISIBLE
          缺省控制category轴方向的十字线是否可见.
 
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()
          缺省的构造器.
CategoryPlot(CategoryAxis categoryAxis, AbstractValueAxis valueAxis, AbstractCategoryRender render)
          构造一个新的对象.
 
Method Summary
 java.lang.Object clone()
          克隆本对象.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, ChartShapeCollection chartShapes)
          绘制图表的plot区域,子类需要实现此方法.
protected  java.awt.geom.Rectangle2D drawAxes(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, PlotShapeCollection shapeCollection)
          绘制所有的坐标轴.
 boolean equals(java.lang.Object obj)
          测试两个对象是否相等.
 CategoryAxis getCategoryAxis()
          返回第0个CategoryAxis对象.
 CategoryAxis getCategoryAxis(int index)
          根据索引返回CategoryAxis对象.
 CategoryAxis getCategoryAxisByRenderIndex(int renderIndex)
          根据索引返回category坐标轴对象.
 int getCategoryAxisCount()
          返回category坐标轴的个数.
 RectangleEdge getCategoryAxisEdge()
          计算第0个category坐标轴的边界位置.
 int getCategoryAxisIndex(CategoryAxis axis)
          返回指定category坐标轴的索引.
 AxisLocation getCategoryAxisLocation()
          返回索引值为0的category坐标轴的位置.
 AxisLocation getCategoryAxisLocation(int index)
          返回指定索引的category坐标轴的位置.
protected  CategoryAxis getNotNullCategoryAxis(int index)
          根据索引寻找不为null的Category坐标轴,寻找方法为从当前索引值开始先往前找,如果找不到则再往后寻找.
protected  AbstractValueAxis getNotNullValueAxis(int index)
          根据索引寻找不为null的Value坐标轴,寻找方法为从当前索引值开始先往前找,如果找不到则再往后寻找.
protected  RectangleEdge getNotNullValueAxisEdge(int index)
          根据索引寻找不为null的value坐标轴的边界,寻找方法为从当前索引值开始先往前找, 如果找不到则再往后寻找.
 PlotType getPlotType()
          返回描述此plot的字符串.
 AbstractCategoryRender getRender()
          返回第0个render.
 AbstractCategoryRender getRender(int index)
          根据索引值获取render.
 int getRenderIndex(AbstractCategoryRender render)
          返回指定render的索引,没有找到则返回-1.
 java.util.Collection getRenders()
          返回render集合,此集合不可修改.
 int hashCode()
          计算hashcode.
 boolean isDomainZoomable()
          返回domain坐标轴是否可缩放.
 void setCategoryAxes(CategoryAxis[] axes)
          设置plot的category坐标轴,已经存在的对象会被覆盖,并向所有监听器发送PlotChangeEvent事件.
 void setCategoryAxes(CategoryAxis[] axes, int startIndex)
          设置plot的category坐标轴,并向所有监听器发送PlotChangeEvent事件.
 void setCategoryAxis(CategoryAxis axis)
          设置plot的category坐标轴,并向所有监听器发送PlotChangeEvent事件.
 void setCategoryAxis(int index, CategoryAxis axis)
          设置category坐标轴,并向所有监听器发送PlotChangeEvent事件.
 void setCategoryAxis(int index, CategoryAxis axis, boolean notify)
          设置category坐标轴,并向所有监听器发送PlotChangeEvent事件.
 void setCategoryAxisLocation(AxisLocation location)
          设置category坐标轴的位置.
 void setCategoryAxisLocation(int index, AxisLocation location)
          设置索引为index的category坐标轴的位置.
 void setRender(AbstractCategoryRender render)
          设置第0个render.
 void setRender(AbstractCategoryRender render, boolean notify)
          设置第0个render,如果需要会向所有监听器发送PlotChangeEvent事件.
 void setRender(int index, AbstractCategoryRender render)
          设定指定索引值的render,并向所有监听器发送PlotChangeEvent事件.
 void setRender(int index, AbstractCategoryRender render, boolean notify)
          设定指定索引值的render,并向所有监听器发送PlotChangeEvent事件.
 java.lang.String toString()
          覆盖toString()方法.
 
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
缺省控制category轴方向的十字线是否可见.

See Also:
Constant Field Values

DEFAULT_CATEGORY_CROSSHAIR_LOCKED_ON_DATA

public static final boolean DEFAULT_CATEGORY_CROSSHAIR_LOCKED_ON_DATA
缺省控制十字线是否自动锁定数据点.

See Also:
Constant Field Values
Constructor Detail

CategoryPlot

public CategoryPlot()
缺省的构造器.


CategoryPlot

public CategoryPlot(CategoryAxis categoryAxis,
                    AbstractValueAxis valueAxis,
                    AbstractCategoryRender render)
构造一个新的对象.

Parameters:
categoryAxis - CategoryAxis category坐标轴 (可为null).
valueAxis - AbstractValueAxis value坐标轴 (可为null).
render - AbstractCategoryRender 绘制数据区的类 (可为null).
Method Detail

getCategoryAxisCount

public int getCategoryAxisCount()
返回category坐标轴的个数.

Returns:
坐标轴的个数.

getCategoryAxis

public CategoryAxis getCategoryAxis()
返回第0个CategoryAxis对象.

Returns:
第0个CategoryAxis对象 (可能为null).

getCategoryAxis

public CategoryAxis getCategoryAxis(int index)
根据索引返回CategoryAxis对象.

Parameters:
index - 索引值.
Returns:
CategoryAxis对象 (可能为null).

setCategoryAxis

public void setCategoryAxis(CategoryAxis axis)
设置plot的category坐标轴,并向所有监听器发送PlotChangeEvent事件.

Parameters:
axis - CategoryAxis category坐标轴对象 (不可为null).

getCategoryAxisByRenderIndex

public CategoryAxis getCategoryAxisByRenderIndex(int renderIndex)
根据索引返回category坐标轴对象.

Parameters:
renderIndex - render的索引值.
Returns:
category坐标轴对象 (可能为null).

setCategoryAxis

public void setCategoryAxis(int index,
                            CategoryAxis axis)
设置category坐标轴,并向所有监听器发送PlotChangeEvent事件.

Parameters:
index - int 索引值,必须大于等于0.
axis - CategoryAxis category坐标轴 (不可为null).

setCategoryAxis

public void setCategoryAxis(int index,
                            CategoryAxis axis,
                            boolean notify)
设置category坐标轴,并向所有监听器发送PlotChangeEvent事件.

Parameters:
index - int 索引值,必须大于等于0.
axis - CategoryAxis category坐标轴 (不可为null).
notify - boolean 是否通知监听器.

setCategoryAxes

public void setCategoryAxes(CategoryAxis[] axes)
设置plot的category坐标轴,已经存在的对象会被覆盖,并向所有监听器发送PlotChangeEvent事件.

Parameters:
axes - CategoryAxis[] category坐标轴数组 (不可为null).

setCategoryAxes

public void setCategoryAxes(CategoryAxis[] axes,
                            int startIndex)
设置plot的category坐标轴,并向所有监听器发送PlotChangeEvent事件.

Parameters:
axes - CategoryAxis[] category坐标轴数组 (不可为null).
startIndex - int 索引的开始值,startIndex之前的对象不会被覆盖,必须大于等于0.

getCategoryAxisIndex

public int getCategoryAxisIndex(CategoryAxis axis)
返回指定category坐标轴的索引.

Parameters:
axis - category坐标轴对象 (不可为null).
Returns:
索引值,没有找到则返回-1.

getRender

public AbstractCategoryRender getRender()
返回第0个render.

Returns:
AbstractCategoryRender 第0个render

getRender

public AbstractCategoryRender getRender(int index)
根据索引值获取render.

Parameters:
index - 索引值,必须大于等于0.
Returns:
AbstractCategoryRender render(可能为null).

getRenders

public java.util.Collection getRenders()
返回render集合,此集合不可修改.

Specified by:
getRenders in class AbstractPlot
Returns:
Collection render集合.

setRender

public void setRender(AbstractCategoryRender render)
设置第0个render.

Parameters:
render - AbstractCategoryRender render (不可为null).

setRender

public void setRender(AbstractCategoryRender render,
                      boolean notify)
设置第0个render,如果需要会向所有监听器发送PlotChangeEvent事件.

Parameters:
render - AbstractCategoryRender render (不可为null).
notify - boolean 是否通知监听器.

setRender

public void setRender(int index,
                      AbstractCategoryRender render)
设定指定索引值的render,并向所有监听器发送PlotChangeEvent事件.

Parameters:
index - int 索引值,必须大于等于0.
render - AbstractCategoryRender render (不可为null).

setRender

public void setRender(int index,
                      AbstractCategoryRender render,
                      boolean notify)
设定指定索引值的render,并向所有监听器发送PlotChangeEvent事件.

Parameters:
index - int 索引值,必须大于等于0.
render - AbstractCategoryRender render (不可为null).
notify - boolean 是否通知监听器.

setRenders

public void setRenders(AbstractCategoryRender[] renders,
                       int startIndex)
设置坐标轴的render,并向所有监听器发送PlotChangeEvent事件.

Parameters:
renders - AbstractCategoryRender[] render数组 (不可为null).
startIndex - int 索引的开始值,startIndex之前的对象不会被覆盖,必须大于等于0.

getRenderIndex

public int getRenderIndex(AbstractCategoryRender render)
返回指定render的索引,没有找到则返回-1.

Parameters:
render - AbstractCategoryRender render (不可为null).
Returns:
int 索引值.

getCategoryAxisLocation

public AxisLocation getCategoryAxisLocation()
返回索引值为0的category坐标轴的位置.

Returns:
位置 (不为null).

getCategoryAxisLocation

public AxisLocation getCategoryAxisLocation(int index)
返回指定索引的category坐标轴的位置.

Parameters:
index - 索引值,必须大于等于0.
Returns:
位置.

setCategoryAxisLocation

public void setCategoryAxisLocation(AxisLocation location)
设置category坐标轴的位置.

Parameters:
location - 坐标轴的位置 (不可为null).

setCategoryAxisLocation

public void setCategoryAxisLocation(int index,
                                    AxisLocation location)
设置索引为index的category坐标轴的位置.

Parameters:
index - 索引,必须大于等于0.
location - 坐标轴位置 (不可为null).

getCategoryAxisEdge

public RectangleEdge getCategoryAxisEdge()
计算第0个category坐标轴的边界位置.

Returns:
边界位置.

getCategoryAxisEdge

public RectangleEdge getCategoryAxisEdge(int index)
返回指定索引的category坐标轴的边界值.

Parameters:
index - 坐标轴的索引值,必须大于等于0.
Returns:
索引值.

isDomainZoomable

public boolean isDomainZoomable()
返回domain坐标轴是否可缩放.

Specified by:
isDomainZoomable in interface IZoomable
Overrides:
isDomainZoomable in class AbstractPlot
Returns:
boolean 布尔值.

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 ChartShapeCollection chartShapes)
绘制图表的plot区域,子类需要实现此方法.

Specified by:
draw in class AbstractPlot
Parameters:
g2 - Graphics2D 图形设备(打印机或屏幕) (不可为null).
plotArea - Rectangle2D plot绘制区域 (不可为null).
chartShapes - ChartShapeCollection chart区域图形集合 (不可为null).

drawAxes

protected java.awt.geom.Rectangle2D drawAxes(java.awt.Graphics2D g2,
                                             java.awt.geom.Rectangle2D plotArea,
                                             PlotShapeCollection shapeCollection)
绘制所有的坐标轴.

Parameters:
g2 - 图形设备(打印机或屏幕) (不可为null).
plotArea - plot绘制区域 (不可为null).
shapeCollection - PlotShapeCollection plot区域图形集合 (不可为null).
Returns:
Rectangle2D 数据区.

getNotNullCategoryAxis

protected CategoryAxis getNotNullCategoryAxis(int index)
根据索引寻找不为null的Category坐标轴,寻找方法为从当前索引值开始先往前找,如果找不到则再往后寻找.

Parameters:
index - int 索引值.
Returns:
CategoryAxis Category坐标轴.

getNotNullValueAxis

protected AbstractValueAxis getNotNullValueAxis(int index)
根据索引寻找不为null的Value坐标轴,寻找方法为从当前索引值开始先往前找,如果找不到则再往后寻找.

Parameters:
index - int 索引值.
Returns:
AbstractValueAxis value坐标轴.

getNotNullValueAxisEdge

protected RectangleEdge getNotNullValueAxisEdge(int index)
根据索引寻找不为null的value坐标轴的边界,寻找方法为从当前索引值开始先往前找, 如果找不到则再往后寻找.

Parameters:
index - int 索引值.
Returns:
RectangleEdge value坐标轴边界.

getPlotType

public PlotType getPlotType()
返回描述此plot的字符串.

Specified by:
getPlotType in class AbstractPlot
Returns:
plot的类型.

equals

public boolean equals(java.lang.Object obj)
测试两个对象是否相等.

Overrides:
equals in class AbstractAxisPlot
Parameters:
obj - 要比较的对象 (可为null).
Returns:
A boolean.

hashCode

public int hashCode()
计算hashcode.

Overrides:
hashCode in class AbstractAxisPlot
Returns:
hashcode.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
克隆本对象.

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

toString

public java.lang.String toString()
覆盖toString()方法.

Overrides:
toString in class AbstractAxisPlot
Returns:
String