Search in sources :

Example 56 with CategoryItemRenderer

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

the class CategoryPlotTest method testMapDatasetToRangeAxis.

@Test
public void testMapDatasetToRangeAxis() {
    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);
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(22, yAxis2);
    // add a second dataset
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(1, "R1", "C1");
    plot.setDataset(99, dataset);
    assertEquals(yAxis, plot.getRangeAxisForDataset(99));
    // now map the dataset to the second xAxis
    plot.mapDatasetToRangeAxis(99, 22);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(99));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) DefaultCategoryItemRenderer(org.jfree.chart.renderer.category.DefaultCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Test(org.junit.Test)

Example 57 with CategoryItemRenderer

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

the class CategoryPlotTest method testAxisIndices.

@Test
public void testAxisIndices() {
    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);
    assertEquals(xAxis, plot.getDomainAxis(0));
    assertEquals(yAxis, plot.getRangeAxis(0));
    CategoryAxis xAxis2 = new CategoryAxis("X2");
    plot.setDomainAxis(99, xAxis2);
    assertEquals(xAxis2, plot.getDomainAxis(99));
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(99, yAxis2);
    assertEquals(yAxis2, plot.getRangeAxis(99));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) DefaultCategoryItemRenderer(org.jfree.chart.renderer.category.DefaultCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Test(org.junit.Test)

Example 58 with CategoryItemRenderer

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

the class CategoryPlotTest method testRendererIndices.

@Test
public void testRendererIndices() {
    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);
    assertEquals(renderer, plot.getRenderer(0));
    // we should be able to give a renderer an arbitrary index
    CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
    plot.setRenderer(20, renderer2);
    assertEquals(2, plot.getRendererCount());
    assertEquals(renderer2, plot.getRenderer(20));
    assertEquals(20, plot.getIndexOf(renderer2));
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) DefaultCategoryItemRenderer(org.jfree.chart.renderer.category.DefaultCategoryItemRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Test(org.junit.Test)

Example 59 with CategoryItemRenderer

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

the class DefaultPlotEditor method updatePlotProperties.

/**
 * Updates the plot properties to match the properties defined on the panel.
 *
 * @param plot  The plot.
 */
public void updatePlotProperties(Plot plot) {
    // set the plot properties...
    plot.setOutlinePaint(getOutlinePaint());
    plot.setOutlineStroke(getOutlineStroke());
    plot.setBackgroundPaint(getBackgroundPaint());
    plot.setInsets(getPlotInsets());
    // then the axis properties...
    if (this.domainAxisPropertyPanel != null) {
        Axis domainAxis = null;
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            domainAxis = p.getDomainAxis();
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            domainAxis = p.getDomainAxis();
        }
        if (domainAxis != null) {
            this.domainAxisPropertyPanel.setAxisProperties(domainAxis);
        }
    }
    if (this.rangeAxisPropertyPanel != null) {
        Axis rangeAxis = null;
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            rangeAxis = p.getRangeAxis();
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            rangeAxis = p.getRangeAxis();
        } else if (plot instanceof PolarPlot) {
            PolarPlot p = (PolarPlot) plot;
            rangeAxis = p.getAxis();
        }
        if (rangeAxis != null) {
            this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis);
        }
    }
    if (this.plotOrientation != null) {
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            p.setOrientation(this.plotOrientation);
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            p.setOrientation(this.plotOrientation);
        }
    }
    if (this.drawLines != null) {
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            CategoryItemRenderer r = p.getRenderer();
            if (r instanceof LineAndShapeRenderer) {
                ((LineAndShapeRenderer) r).setLinesVisible(this.drawLines.booleanValue());
            }
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            XYItemRenderer r = p.getRenderer();
            if (r instanceof StandardXYItemRenderer) {
                ((StandardXYItemRenderer) r).setPlotLines(this.drawLines.booleanValue());
            }
        }
    }
    if (this.drawShapes != null) {
        if (plot instanceof CategoryPlot) {
            CategoryPlot p = (CategoryPlot) plot;
            CategoryItemRenderer r = p.getRenderer();
            if (r instanceof LineAndShapeRenderer) {
                ((LineAndShapeRenderer) r).setShapesVisible(this.drawShapes.booleanValue());
            }
        } else if (plot instanceof XYPlot) {
            XYPlot p = (XYPlot) plot;
            XYItemRenderer r = p.getRenderer();
            if (r instanceof StandardXYItemRenderer) {
                ((StandardXYItemRenderer) r).setBaseShapesVisible(this.drawShapes.booleanValue());
            }
        }
    }
    // dmo: added this panel for colorbar control. (start dmo additions)
    if (this.colorBarAxisPropertyPanel != null) {
        ColorBar colorBar = null;
        if (plot instanceof ContourPlot) {
            ContourPlot p = (ContourPlot) plot;
            colorBar = p.getColorBar();
        }
        if (colorBar != null) {
            this.colorBarAxisPropertyPanel.setAxisProperties(colorBar);
        }
    }
// dmo: (end dmo additions)
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) ContourPlot(org.jfree.chart.plot.ContourPlot) XYPlot(org.jfree.chart.plot.XYPlot) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) PolarPlot(org.jfree.chart.plot.PolarPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) Axis(org.jfree.chart.axis.Axis) CategoryPlot(org.jfree.chart.plot.CategoryPlot) ColorBar(org.jfree.chart.axis.ColorBar)

Example 60 with CategoryItemRenderer

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

the class LineChart3DTest method testSetSeriesURLGenerator.

/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertSame(url2, url1);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryURLGenerator(org.jfree.chart.urls.CategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Test(org.junit.Test)

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