Class LevelRenderer
- java.lang.Object
-
- org.jfree.chart.renderer.AbstractRenderer
-
- org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
-
- org.jfree.chart.renderer.category.LevelRenderer
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,LegendItemSource
,CategoryItemRenderer
,PublicCloneable
public class LevelRenderer extends AbstractCategoryItemRenderer implements java.lang.Cloneable, PublicCloneable, java.io.Serializable
ACategoryItemRenderer
that draws individual data items as horizontal lines, spaced in the same way as bars in a bar chart. The example shown here is generated by theOverlaidBarChartDemo2.java
program included in the JFreeChart Demo Collection:
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_ITEM_MARGIN
The default item margin percentage.private double
itemMargin
The margin between items within a category.private double
maxItemWidth
The maximum item width as a percentage of the available space.private static long
serialVersionUID
For serialization.-
Fields inherited from class org.jfree.chart.renderer.AbstractRenderer
DEFAULT_ITEM_LABEL_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, DEFAULT_PAINT, DEFAULT_SHAPE, DEFAULT_STROKE, DEFAULT_VALUE_LABEL_FONT, DEFAULT_VALUE_LABEL_PAINT, ZERO
-
-
Constructor Summary
Constructors Constructor Description LevelRenderer()
Creates a new renderer with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
calculateBarW0(CategoryPlot plot, PlotOrientation orientation, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column)
Calculates the coordinate of the first "side" of a bar.protected void
calculateItemWidth(CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state)
Calculates the bar width and stores it in the renderer state.protected double
calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series)
Calculates the available space for each series.void
drawItem(java.awt.Graphics2D g2, CategoryItemRendererState state, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)
Draws the bar for a single (series, category) data item.boolean
equals(java.lang.Object obj)
Tests an object for equality with this instance.double
getItemMargin()
Returns the item margin.double
getItemMiddle(java.lang.Comparable rowKey, java.lang.Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, java.awt.geom.Rectangle2D area, RectangleEdge edge)
Returns the Java2D coordinate for the middle of the specified data item.double
getMaximumItemWidth()
Returns the maximum width, as a percentage of the available drawing space.int
hashCode()
Returns a hash code for this instance.CategoryItemRendererState
initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
Initialises the renderer and returns a state object that will be passed to subsequent calls to the drawItem method.void
setItemMargin(double percent)
Sets the item margin and sends aRendererChangeEvent
to all registered listeners.void
setMaximumItemWidth(double percent)
Sets the maximum item width, which is specified as a percentage of the available space for all items, and sends aRendererChangeEvent
to all registered listeners.-
Methods inherited from class org.jfree.chart.renderer.category.AbstractCategoryItemRenderer
addEntity, addItemEntity, beginElementGroup, calculateDomainMarkerTextAnchorPoint, calculateRangeMarkerTextAnchorPoint, clone, createState, drawBackground, drawDomainGridline, drawDomainMarker, drawItemLabel, drawOutline, drawRangeLine, drawRangeMarker, findRangeBounds, findRangeBounds, getColumnCount, getDefaultItemLabelGenerator, getDefaultItemURLGenerator, getDefaultToolTipGenerator, getDomainAxis, getDrawingSupplier, getItemLabelGenerator, getItemURLGenerator, getLegendItem, getLegendItemLabelGenerator, getLegendItems, getLegendItemToolTipGenerator, getLegendItemURLGenerator, getPassCount, getPlot, getRangeAxis, getRowCount, getSeriesItemLabelGenerator, getSeriesItemURLGenerator, getSeriesToolTipGenerator, getToolTipGenerator, setDefaultItemLabelGenerator, setDefaultItemLabelGenerator, setDefaultItemURLGenerator, setDefaultItemURLGenerator, setDefaultToolTipGenerator, setDefaultToolTipGenerator, setLegendItemLabelGenerator, setLegendItemToolTipGenerator, setLegendItemURLGenerator, setPlot, setSeriesItemLabelGenerator, setSeriesItemLabelGenerator, setSeriesItemURLGenerator, setSeriesItemURLGenerator, setSeriesToolTipGenerator, setSeriesToolTipGenerator, updateCrosshairValues
-
Methods inherited from class org.jfree.chart.renderer.AbstractRenderer
addChangeListener, beginElementGroup, calculateLabelAnchorPoint, clearSeriesPaints, clearSeriesStrokes, endElementGroup, fireChangeEvent, getAutoPopulateSeriesFillPaint, getAutoPopulateSeriesOutlinePaint, getAutoPopulateSeriesOutlineStroke, getAutoPopulateSeriesPaint, getAutoPopulateSeriesShape, getAutoPopulateSeriesStroke, getDataBoundsIncludesVisibleSeriesOnly, getDefaultCreateEntities, getDefaultEntityRadius, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultLegendShape, getDefaultLegendTextFont, getDefaultLegendTextPaint, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getItemCreateEntity, getItemFillPaint, getItemLabelAnchorOffset, getItemLabelFont, getItemLabelInsets, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getLegendShape, getLegendTextFont, getLegendTextPaint, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisibleInLegend, getTreatLegendShapeAsLine, hasListener, isComputeItemLabelContrastColor, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, lookupLegendShape, lookupLegendTextFont, lookupLegendTextPaint, lookupSeriesFillPaint, lookupSeriesOutlinePaint, lookupSeriesOutlineStroke, lookupSeriesPaint, lookupSeriesShape, lookupSeriesStroke, notifyListeners, removeChangeListener, setAutoPopulateSeriesFillPaint, setAutoPopulateSeriesOutlinePaint, setAutoPopulateSeriesOutlineStroke, setAutoPopulateSeriesPaint, setAutoPopulateSeriesShape, setAutoPopulateSeriesStroke, setComputeItemLabelContrastColor, setDataBoundsIncludesVisibleSeriesOnly, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultEntityRadius, setDefaultFillPaint, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelFont, setDefaultItemLabelPaint, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultLegendShape, setDefaultLegendTextFont, setDefaultLegendTextPaint, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setItemLabelAnchorOffset, setItemLabelInsets, setLegendShape, setLegendTextFont, setLegendTextPaint, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend, setTreatLegendShapeAsLine
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.chart.renderer.category.CategoryItemRenderer
addChangeListener, getDefaultCreateEntities, getDefaultFillPaint, getDefaultItemLabelFont, getDefaultItemLabelPaint, getDefaultItemLabelsVisible, getDefaultNegativeItemLabelPosition, getDefaultOutlinePaint, getDefaultOutlineStroke, getDefaultPaint, getDefaultPositiveItemLabelPosition, getDefaultSeriesVisible, getDefaultSeriesVisibleInLegend, getDefaultShape, getDefaultStroke, getItemCreateEntity, getItemFillPaint, getItemLabelFont, getItemLabelPaint, getItemOutlinePaint, getItemOutlineStroke, getItemPaint, getItemShape, getItemStroke, getItemVisible, getNegativeItemLabelPosition, getPositiveItemLabelPosition, getSeriesCreateEntities, getSeriesFillPaint, getSeriesItemLabelFont, getSeriesItemLabelPaint, getSeriesNegativeItemLabelPosition, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesPositiveItemLabelPosition, getSeriesShape, getSeriesStroke, getSeriesVisible, getSeriesVisibleInLegend, isItemLabelVisible, isSeriesItemLabelsVisible, isSeriesVisible, isSeriesVisibleInLegend, removeChangeListener, setDefaultCreateEntities, setDefaultCreateEntities, setDefaultFillPaint, setDefaultItemLabelFont, setDefaultItemLabelFont, setDefaultItemLabelPaint, setDefaultItemLabelPaint, setDefaultItemLabelsVisible, setDefaultItemLabelsVisible, setDefaultNegativeItemLabelPosition, setDefaultNegativeItemLabelPosition, setDefaultOutlinePaint, setDefaultOutlinePaint, setDefaultOutlineStroke, setDefaultOutlineStroke, setDefaultPaint, setDefaultPaint, setDefaultPositiveItemLabelPosition, setDefaultPositiveItemLabelPosition, setDefaultSeriesVisible, setDefaultSeriesVisible, setDefaultSeriesVisibleInLegend, setDefaultSeriesVisibleInLegend, setDefaultShape, setDefaultShape, setDefaultStroke, setDefaultStroke, setSeriesCreateEntities, setSeriesCreateEntities, setSeriesFillPaint, setSeriesItemLabelFont, setSeriesItemLabelFont, setSeriesItemLabelPaint, setSeriesItemLabelPaint, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesItemLabelsVisible, setSeriesNegativeItemLabelPosition, setSeriesNegativeItemLabelPosition, setSeriesOutlinePaint, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesPositiveItemLabelPosition, setSeriesPositiveItemLabelPosition, setSeriesShape, setSeriesShape, setSeriesStroke, setSeriesStroke, setSeriesVisible, setSeriesVisible, setSeriesVisibleInLegend, setSeriesVisibleInLegend
-
Methods inherited from interface org.jfree.chart.util.PublicCloneable
clone
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
DEFAULT_ITEM_MARGIN
public static final double DEFAULT_ITEM_MARGIN
The default item margin percentage.- See Also:
- Constant Field Values
-
itemMargin
private double itemMargin
The margin between items within a category.
-
maxItemWidth
private double maxItemWidth
The maximum item width as a percentage of the available space.
-
-
Method Detail
-
getItemMargin
public double getItemMargin()
Returns the item margin.- Returns:
- The margin.
- See Also:
setItemMargin(double)
-
setItemMargin
public void setItemMargin(double percent)
Sets the item margin and sends aRendererChangeEvent
to all registered listeners. The value is expressed as a percentage of the available width for plotting all the bars, with the resulting amount to be distributed between all the bars evenly.- Parameters:
percent
- the new margin.- See Also:
getItemMargin()
-
getMaximumItemWidth
public double getMaximumItemWidth()
Returns the maximum width, as a percentage of the available drawing space.- Returns:
- The maximum width.
- See Also:
setMaximumItemWidth(double)
-
setMaximumItemWidth
public void setMaximumItemWidth(double percent)
Sets the maximum item width, which is specified as a percentage of the available space for all items, and sends aRendererChangeEvent
to all registered listeners.- Parameters:
percent
- the percent.- See Also:
getMaximumItemWidth()
-
initialise
public CategoryItemRendererState initialise(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info)
Initialises the renderer and returns a state object that will be passed to subsequent calls to the drawItem method.This method gets called once at the start of the process of drawing a chart.
- Specified by:
initialise
in interfaceCategoryItemRenderer
- Overrides:
initialise
in classAbstractCategoryItemRenderer
- Parameters:
g2
- the graphics device.dataArea
- the area in which the data is to be plotted.plot
- the plot.rendererIndex
- the renderer index.info
- collects chart rendering information for return to caller.- Returns:
- The renderer state.
-
calculateItemWidth
protected void calculateItemWidth(CategoryPlot plot, java.awt.geom.Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state)
Calculates the bar width and stores it in the renderer state.- Parameters:
plot
- the plot.dataArea
- the data area.rendererIndex
- the renderer index.state
- the renderer state.
-
calculateBarW0
protected double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, java.awt.geom.Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column)
Calculates the coordinate of the first "side" of a bar. This will be the minimum x-coordinate for a vertical bar, and the minimum y-coordinate for a horizontal bar.- Parameters:
plot
- the plot.orientation
- the plot orientation.dataArea
- the data area.domainAxis
- the domain axis.state
- the renderer state (has the bar width precalculated).row
- the row index.column
- the column index.- Returns:
- The coordinate.
-
drawItem
public void drawItem(java.awt.Graphics2D g2, CategoryItemRendererState state, java.awt.geom.Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)
Draws the bar for a single (series, category) data item.- Specified by:
drawItem
in interfaceCategoryItemRenderer
- Parameters:
g2
- the graphics device.state
- the renderer state.dataArea
- the data area.plot
- the plot.domainAxis
- the domain axis.rangeAxis
- the range axis.dataset
- the dataset.row
- the row index (zero-based).column
- the column index (zero-based).pass
- the pass index.
-
calculateSeriesWidth
protected double calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series)
Calculates the available space for each series.- Parameters:
space
- the space along the entire axis (in Java2D units).axis
- the category axis.categories
- the number of categories.series
- the number of series.- Returns:
- The width of one series.
-
getItemMiddle
public double getItemMiddle(java.lang.Comparable rowKey, java.lang.Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, java.awt.geom.Rectangle2D area, RectangleEdge edge)
Returns the Java2D coordinate for the middle of the specified data item.- Specified by:
getItemMiddle
in interfaceCategoryItemRenderer
- Overrides:
getItemMiddle
in classAbstractCategoryItemRenderer
- Parameters:
rowKey
- the row key.columnKey
- the column key.dataset
- the dataset.axis
- the axis.area
- the drawing area.edge
- the edge along which the axis lies.- Returns:
- The Java2D coordinate.
-
equals
public boolean equals(java.lang.Object obj)
Tests an object for equality with this instance.- Overrides:
equals
in classAbstractCategoryItemRenderer
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code for this instance.- Overrides:
hashCode
in classAbstractCategoryItemRenderer
- Returns:
- A hash code.
-
-