schmitzm.jfree.chart.renderer
Class PointSelectionCategoryRenderer

java.lang.Object
  extended by LineAndShapeRenderer
      extended by schmitzm.jfree.chart.renderer.PointSelectionCategoryRenderer
All Implemented Interfaces:
SelectionRenderer<CategoryDatasetSelectionModel>, DatasetSelectionModelProvider<CategoryDatasetSelectionModel>

public class PointSelectionCategoryRenderer
extends LineAndShapeRenderer
implements SelectionRenderer<CategoryDatasetSelectionModel>

Extends the LineAndShapeRenderer with the SelectionRenderer functionality. Additionally redefines the drawItem(Graphics2D, CategoryItemRendererState, Rectangle2D, CategoryPlot, CategoryAxis, ValueAxis, CategoryDataset, int, int, int) method to realize the highlight rendering of the selected items. Only the selected data points are rendered. No lines ore areas!
Note:
An adequate SeriesDatasetSelectionModel is automatically created when a new Plot is set. Manually calling #setSelectionModel(SeriesDatasetSelectionModel) is usually not necessary. Overwrite createAndSetSelectionModel() to avoid this behavior.
If no selection model is set, the behavior of this renderer is exactly like the super class.

Author:
Martin Schmitz

Field Summary
protected  Logger LOGGER
          Used for log and debug messages.
protected  CategoryDatasetSelectionModel selectionModel
          Holds the selection model, the renderer uses to determine whether a data item is selected or not.
protected  Paint selectionPaint
          Holds the selection color for each series.
 
Constructor Summary
PointSelectionCategoryRenderer()
          Creates a new renderer.
 
Method Summary
 void createAndSetSelectionModel()
          Creates and sets an adequate SeriesDatasetSelectionModel according to the Dataset of the current Plot.
 CategoryDatasetSelectionModel createSelectionModel(Dataset dataset)
          Creates an adequate SeriesDatasetSelectionModel according to the given Dataset.
 void drawItem(Graphics2D g, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass)
          Sets the rendering color (temporary for the rendering process) to the highlight color, if the item is defined as selected (by the selection model).
 CategoryDatasetSelectionModel getSelectionModel()
          Returns the selection model the renderer uses to determine whether a data item is selected or not.
 Paint getSelectionPaint()
          Returns the color, the selected data of the primary series is rendered with.
protected  void init()
          Called by every constructor to initialize the extensions of this renderer.
 boolean isSeriesVisibleInLegend(int series)
          Returns always false, so that no series of the selection renderer is visible in the legend.
 void setPlot(CategoryPlot plot)
          Creates and sets a new SeriesDatasetSelectionModel, if no selection model is set yet, or the selection model's dataset differs from the dataset of the new plot.
 void setSelectionModel(CategoryDatasetSelectionModel model)
          Sets the selection model the renderer uses to determine whether a data item is selected or not.
 void setSelectionPaint(Paint paint)
          Sets the color, the selected data is rendered with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface schmitzm.jfree.chart.selection.DatasetSelectionModelProvider
setSelectionModel
 

Field Detail

LOGGER

protected Logger LOGGER
Used for log and debug messages.


selectionModel

protected CategoryDatasetSelectionModel selectionModel
Holds the selection model, the renderer uses to determine whether a data item is selected or not.


selectionPaint

protected Paint selectionPaint
Holds the selection color for each series.

Constructor Detail

PointSelectionCategoryRenderer

public PointSelectionCategoryRenderer()
Creates a new renderer.

Method Detail

init

protected void init()
Called by every constructor to initialize the extensions of this renderer.


isSeriesVisibleInLegend

public boolean isSeriesVisibleInLegend(int series)
Returns always false, so that no series of the selection renderer is visible in the legend.


setSelectionModel

public void setSelectionModel(CategoryDatasetSelectionModel model)
Sets the selection model the renderer uses to determine whether a data item is selected or not.

Parameters:
model - the selection model

getSelectionModel

public CategoryDatasetSelectionModel getSelectionModel()
Returns the selection model the renderer uses to determine whether a data item is selected or not.

Specified by:
getSelectionModel in interface DatasetSelectionModelProvider<CategoryDatasetSelectionModel>

createAndSetSelectionModel

public void createAndSetSelectionModel()
Creates and sets an adequate SeriesDatasetSelectionModel according to the Dataset of the current Plot. Automatically called by #setPlot(XYPlot).
Sets the selection model to null if the renderer is not connected to a plot or the plot contains no dataset.

See Also:
#createSelectionModel(XYDataset)

createSelectionModel

public CategoryDatasetSelectionModel createSelectionModel(Dataset dataset)
Creates an adequate SeriesDatasetSelectionModel according to the given Dataset. Subclasses can overwrite this method to create an alternative SeriesDatasetSelectionModel.

Specified by:
createSelectionModel in interface DatasetSelectionModelProvider<CategoryDatasetSelectionModel>
Parameters:
dataset - must be a XYDataset
Throws:
IllegalArgumentException - if dataset is no XYDataset

getSelectionPaint

public Paint getSelectionPaint()
Returns the color, the selected data of the primary series is rendered with.

Specified by:
getSelectionPaint in interface SelectionRenderer<CategoryDatasetSelectionModel>
Returns:
null if no selection color is defined for the series

setSelectionPaint

public void setSelectionPaint(Paint paint)
Sets the color, the selected data is rendered with.

Specified by:
setSelectionPaint in interface SelectionRenderer<CategoryDatasetSelectionModel>
Parameters:
paint - color for the selected data

setPlot

public void setPlot(CategoryPlot plot)
Creates and sets a new SeriesDatasetSelectionModel, if no selection model is set yet, or the selection model's dataset differs from the dataset of the new plot.

Parameters:
plot - the plot rendered by this renderer

drawItem

public void drawItem(Graphics2D g,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset dataset,
                     int row,
                     int column,
                     int pass)
Sets the rendering color (temporary for the rendering process) to the highlight color, if the item is defined as selected (by the selection model).