Search in sources :

Example 21 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.

the class CategoryPlot method setRenderer.

/**
 * Sets the renderer to use for the dataset with the specified index and,
 * if requested, sends a change event to all registered listeners.  Note
 * that each dataset should have its own renderer, you should not use one
 * renderer for multiple datasets.
 *
 * @param index  the index.
 * @param renderer  the renderer (<code>null</code> permitted).
 * @param notify  notify listeners?
 *
 * @see #getRenderer(int)
 */
public void setRenderer(int index, CategoryItemRenderer renderer, boolean notify) {
    CategoryItemRenderer existing = this.renderers.get(index);
    if (existing != null) {
        existing.removeChangeListener(this);
    }
    this.renderers.put(index, renderer);
    if (renderer != null) {
        renderer.setPlot(this);
        renderer.addChangeListener(this);
    }
    configureDomainAxes();
    configureRangeAxes();
    if (notify) {
        fireChangeEvent();
    }
}
Also used : AbstractCategoryItemRenderer(org.jfree.chart.renderer.category.AbstractCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer)

Example 22 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.

the class CategoryPlot method drawRangeMarkers.

/**
 * Draws the range 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 #drawDomainMarkers(Graphics2D, Rectangle2D, int, Layer)
 */
protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) {
    CategoryItemRenderer r = getRenderer(index);
    if (r == null) {
        return;
    }
    Collection markers = getRangeMarkers(index, layer);
    ValueAxis axis = getRangeAxisForDataset(index);
    if (markers != null && axis != null) {
        Iterator iterator = markers.iterator();
        while (iterator.hasNext()) {
            Marker marker = (Marker) iterator.next();
            r.drawRangeMarker(g2, this, axis, marker, dataArea);
        }
    }
}
Also used : AbstractCategoryItemRenderer(org.jfree.chart.renderer.category.AbstractCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) LegendItemCollection(org.jfree.chart.LegendItemCollection) Collection(java.util.Collection) AxisCollection(org.jfree.chart.axis.AxisCollection)

Example 23 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.

the class CategoryPlot method getLegendItems.

/**
 * Returns the legend items for the plot.  By default, this method creates
 * a legend item for each series in each of the datasets.  You can change
 * this behaviour by overriding this method.
 *
 * @return The legend items.
 */
@Override
public LegendItemCollection getLegendItems() {
    if (this.fixedLegendItems != null) {
        return this.fixedLegendItems;
    }
    LegendItemCollection result = new LegendItemCollection();
    // get the legend items for the datasets...
    for (CategoryDataset dataset : this.datasets.values()) {
        if (dataset != null) {
            int datasetIndex = indexOf(dataset);
            CategoryItemRenderer renderer = getRenderer(datasetIndex);
            if (renderer != null) {
                result.addAll(renderer.getLegendItems());
            }
        }
    }
    return result;
}
Also used : AbstractCategoryItemRenderer(org.jfree.chart.renderer.category.AbstractCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) LegendItemCollection(org.jfree.chart.LegendItemCollection) CategoryDataset(org.jfree.data.category.CategoryDataset) Paint(java.awt.Paint)

Example 24 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.

the class CategoryPlot method readObject.

/**
 * Provides serialization support.
 *
 * @param stream  the input stream.
 *
 * @throws IOException  if there is an I/O error.
 * @throws ClassNotFoundException  if there is a classpath problem.
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    this.domainGridlineStroke = SerialUtilities.readStroke(stream);
    this.domainGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeGridlineStroke = SerialUtilities.readStroke(stream);
    this.rangeGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeCrosshairStroke = SerialUtilities.readStroke(stream);
    this.rangeCrosshairPaint = SerialUtilities.readPaint(stream);
    this.domainCrosshairStroke = SerialUtilities.readStroke(stream);
    this.domainCrosshairPaint = SerialUtilities.readPaint(stream);
    this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream);
    this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream);
    this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream);
    this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream);
    for (CategoryAxis xAxis : this.domainAxes.values()) {
        if (xAxis != null) {
            xAxis.setPlot(this);
            xAxis.addChangeListener(this);
        }
    }
    for (ValueAxis yAxis : this.rangeAxes.values()) {
        if (yAxis != null) {
            yAxis.setPlot(this);
            yAxis.addChangeListener(this);
        }
    }
    for (CategoryDataset dataset : this.datasets.values()) {
        if (dataset != null) {
            dataset.addChangeListener(this);
        }
    }
    for (CategoryItemRenderer renderer : this.renderers.values()) {
        if (renderer != null) {
            renderer.addChangeListener(this);
        }
    }
}
Also used : AbstractCategoryItemRenderer(org.jfree.chart.renderer.category.AbstractCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ValueAxis(org.jfree.chart.axis.ValueAxis) CategoryDataset(org.jfree.data.category.CategoryDataset)

Example 25 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.

the class CategoryPlot method drawZeroRangeBaseline.

/**
 * Draws a base line across the chart at value zero on the range axis.
 *
 * @param g2  the graphics device.
 * @param area  the data area.
 *
 * @see #setRangeZeroBaselineVisible(boolean)
 *
 * @since 1.0.13
 */
protected void drawZeroRangeBaseline(Graphics2D g2, Rectangle2D area) {
    if (!isRangeZeroBaselineVisible()) {
        return;
    }
    CategoryItemRenderer r = getRenderer();
    if (r instanceof AbstractCategoryItemRenderer) {
        AbstractCategoryItemRenderer aci = (AbstractCategoryItemRenderer) r;
        aci.drawRangeLine(g2, this, getRangeAxis(), area, 0.0, this.rangeZeroBaselinePaint, this.rangeZeroBaselineStroke);
    } else {
        r.drawRangeGridline(g2, this, getRangeAxis(), area, 0.0);
    }
}
Also used : AbstractCategoryItemRenderer(org.jfree.chart.renderer.category.AbstractCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) AbstractCategoryItemRenderer(org.jfree.chart.renderer.category.AbstractCategoryItemRenderer)

Aggregations

CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)70 CategoryPlot (org.jfree.chart.plot.CategoryPlot)36 Test (org.junit.Test)32 CategoryAxis (org.jfree.chart.axis.CategoryAxis)23 CategoryDataset (org.jfree.data.category.CategoryDataset)20 AbstractCategoryItemRenderer (org.jfree.chart.renderer.category.AbstractCategoryItemRenderer)14 Paint (java.awt.Paint)13 NumberAxis (org.jfree.chart.axis.NumberAxis)13 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)13 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)12 DefaultCategoryItemRenderer (org.jfree.chart.renderer.category.DefaultCategoryItemRenderer)12 StandardCategoryURLGenerator (org.jfree.chart.urls.StandardCategoryURLGenerator)12 StandardCategoryToolTipGenerator (org.jfree.chart.labels.StandardCategoryToolTipGenerator)11 ValueAxis (org.jfree.chart.axis.ValueAxis)10 CategoryToolTipGenerator (org.jfree.chart.labels.CategoryToolTipGenerator)10 CategoryURLGenerator (org.jfree.chart.urls.CategoryURLGenerator)10 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)9 JFreeChart (org.jfree.chart.JFreeChart)6 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)5 Rectangle2D (java.awt.geom.Rectangle2D)4