use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlot method drawDomainMarkers.
/**
* Draws the domain markers (if any) for an axis and layer. This method is
* typically called from within the draw() method.
*
* @param g2 the graphics device.
* @param dataArea the data area.
* @param index the renderer index.
* @param layer the layer (foreground or background).
*
* @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer)
*/
protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) {
CategoryItemRenderer r = getRenderer(index);
if (r == null) {
return;
}
Collection markers = getDomainMarkers(index, layer);
CategoryAxis axis = getDomainAxisForDataset(index);
if (markers != null && axis != null) {
Iterator iterator = markers.iterator();
while (iterator.hasNext()) {
CategoryMarker marker = (CategoryMarker) iterator.next();
r.drawDomainMarker(g2, this, axis, marker, dataArea);
}
}
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlot method getDataRange.
/**
* Returns the range of data values that will be plotted against the range
* axis. If the dataset is <code>null</code>, this method returns
* <code>null</code>.
*
* @param axis the axis.
*
* @return The data range.
*/
@Override
public Range getDataRange(ValueAxis axis) {
Range result = null;
List<CategoryDataset> mappedDatasets = new ArrayList<CategoryDataset>();
int rangeIndex = findRangeAxisIndex(axis);
if (rangeIndex >= 0) {
mappedDatasets.addAll(datasetsMappedToRangeAxis(rangeIndex));
} else if (axis == getRangeAxis()) {
mappedDatasets.addAll(datasetsMappedToRangeAxis(0));
}
// of the ranges.
for (CategoryDataset d : mappedDatasets) {
CategoryItemRenderer r = getRendererForDataset(d);
if (r != null) {
result = Range.combine(result, r.findRangeBounds(d));
}
}
return result;
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlot method getRendererForDataset.
/**
* Returns the renderer for the specified dataset. If the dataset doesn't
* belong to the plot, this method will return <code>null</code>.
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return The renderer (possibly <code>null</code>).
*/
public CategoryItemRenderer getRendererForDataset(CategoryDataset dataset) {
int datasetIndex = indexOf(dataset);
if (datasetIndex < 0) {
return null;
}
CategoryItemRenderer renderer = this.renderers.get(datasetIndex);
if (renderer == null) {
return getRenderer();
}
return renderer;
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testMapDatasetToDomainAxis.
@Test
public void testMapDatasetToDomainAxis() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
CategoryAxis xAxis2 = new CategoryAxis("X2");
plot.setDomainAxis(11, xAxis2);
// add a second dataset
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
assertEquals(xAxis, plot.getDomainAxisForDataset(99));
// now map the dataset to the second xAxis
plot.mapDatasetToDomainAxis(99, 11);
assertEquals(xAxis2, plot.getDomainAxisForDataset(99));
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testSetRenderer.
/**
* A test for a bug where setting the renderer doesn't register the plot
* as a RendererChangeListener.
*/
@Test
public void testSetRenderer() {
CategoryPlot plot = new CategoryPlot();
CategoryItemRenderer renderer = new LineAndShapeRenderer();
plot.setRenderer(renderer);
// now make a change to the renderer and see if it triggers a plot
// change event...
MyPlotChangeListener listener = new MyPlotChangeListener();
plot.addChangeListener(listener);
renderer.setSeriesPaint(0, Color.black);
assertTrue(listener.getEvent() != null);
}
Aggregations