Search in sources :

Example 11 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.

the class XYPlotTest method testRangeMarkerIndices.

@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);
    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) XYSeries(org.jfree.data.xy.XYSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYDataset(org.jfree.data.xy.XYDataset) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Example 12 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.

the class XYPlotTest method testEquals.

/**
 * Some checks for the equals() method.
 */
@Test
public void testEquals() {
    XYPlot plot1 = new XYPlot();
    XYPlot plot2 = new XYPlot();
    assertTrue(plot1.equals(plot2));
    // orientation...
    plot1.setOrientation(PlotOrientation.HORIZONTAL);
    assertFalse(plot1.equals(plot2));
    plot2.setOrientation(PlotOrientation.HORIZONTAL);
    assertTrue(plot1.equals(plot2));
    // axisOffset...
    plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
    assertFalse(plot1.equals(plot2));
    plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05));
    assertTrue(plot1.equals(plot2));
    // domainAxis...
    plot1.setDomainAxis(new NumberAxis("Domain Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxis(new NumberAxis("Domain Axis"));
    assertTrue(plot1.equals(plot2));
    // domainAxisLocation...
    plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // secondary DomainAxes...
    plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis"));
    assertTrue(plot1.equals(plot2));
    // secondary DomainAxisLocations...
    plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // rangeAxis...
    plot1.setRangeAxis(new NumberAxis("Range Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxis(new NumberAxis("Range Axis"));
    assertTrue(plot1.equals(plot2));
    // rangeAxisLocation...
    plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // secondary RangeAxes...
    plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis"));
    assertTrue(plot1.equals(plot2));
    // secondary RangeAxisLocations...
    plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT);
    assertTrue(plot1.equals(plot2));
    // secondary DatasetDomainAxisMap...
    plot1.mapDatasetToDomainAxis(11, 11);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToDomainAxis(11, 11);
    assertTrue(plot1.equals(plot2));
    // secondaryDatasetRangeAxisMap...
    plot1.mapDatasetToRangeAxis(11, 11);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToRangeAxis(11, 11);
    assertTrue(plot1.equals(plot2));
    // renderer
    plot1.setRenderer(new DefaultXYItemRenderer());
    assertFalse(plot1.equals(plot2));
    plot2.setRenderer(new DefaultXYItemRenderer());
    assertTrue(plot1.equals(plot2));
    // secondary renderers
    plot1.setRenderer(11, new DefaultXYItemRenderer());
    assertFalse(plot1.equals(plot2));
    plot2.setRenderer(11, new DefaultXYItemRenderer());
    assertTrue(plot1.equals(plot2));
    // domainGridlinesVisible
    plot1.setDomainGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    // domainGridlineStroke
    Stroke stroke = new BasicStroke(2.0f);
    plot1.setDomainGridlineStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlineStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // domainGridlinePaint
    plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeGridlinesVisible
    plot1.setRangeGridlinesVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeGridlinesVisible(false);
    assertTrue(plot1.equals(plot2));
    // rangeGridlineStroke
    plot1.setRangeGridlineStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeGridlineStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // rangeGridlinePaint
    plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeZeroBaselineVisible
    plot1.setRangeZeroBaselineVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeZeroBaselineVisible(true);
    assertTrue(plot1.equals(plot2));
    // rangeZeroBaselineStroke
    plot1.setRangeZeroBaselineStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeZeroBaselineStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // rangeZeroBaselinePaint
    plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairVisible
    plot1.setRangeCrosshairVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairVisible(true);
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairValue
    plot1.setRangeCrosshairValue(100.0);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairValue(100.0);
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairStroke
    plot1.setRangeCrosshairStroke(stroke);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairStroke(stroke);
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairPaint
    plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, 3.0f, 4.0f, Color.red));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, 3.0f, 4.0f, Color.red));
    assertTrue(plot1.equals(plot2));
    // rangeCrosshairLockedOnData
    plot1.setRangeCrosshairLockedOnData(false);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeCrosshairLockedOnData(false);
    assertTrue(plot1.equals(plot2));
    // range markers
    plot1.addRangeMarker(new ValueMarker(4.0));
    assertFalse(plot1.equals(plot2));
    plot2.addRangeMarker(new ValueMarker(4.0));
    assertTrue(plot1.equals(plot2));
    // secondary range markers
    plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
    assertFalse(plot1.equals(plot2));
    plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND);
    assertTrue(plot1.equals(plot2));
    plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
    assertFalse(plot1.equals(plot2));
    plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND);
    assertTrue(plot1.equals(plot2));
    // fixed legend items
    plot1.setFixedLegendItems(new LegendItemCollection());
    assertFalse(plot1.equals(plot2));
    plot2.setFixedLegendItems(new LegendItemCollection());
    assertTrue(plot1.equals(plot2));
    // weight
    plot1.setWeight(3);
    assertFalse(plot1.equals(plot2));
    plot2.setWeight(3);
    assertTrue(plot1.equals(plot2));
    // quadrant origin
    plot1.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantOrigin(new Point2D.Double(12.3, 45.6));
    assertTrue(plot1.equals(plot2));
    // quadrant paint
    plot1.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, 4.0f, 5.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, 4.0f, 5.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    plot1.setDomainTickBandPaint(Color.red);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainTickBandPaint(Color.red);
    assertTrue(plot1.equals(plot2));
    plot1.setRangeTickBandPaint(Color.blue);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeTickBandPaint(Color.blue);
    assertTrue(plot1.equals(plot2));
    plot1.setDomainMinorGridlinesVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainMinorGridlinesVisible(true);
    assertTrue(plot1.equals(plot2));
    plot1.setDomainMinorGridlinePaint(Color.red);
    assertFalse(plot1.equals(plot2));
    plot2.setDomainMinorGridlinePaint(Color.red);
    assertTrue(plot1.equals(plot2));
    plot1.setDomainGridlineStroke(new BasicStroke(1.1f));
    assertFalse(plot1.equals(plot2));
    plot2.setDomainGridlineStroke(new BasicStroke(1.1f));
    assertTrue(plot1.equals(plot2));
    plot1.setRangeMinorGridlinesVisible(true);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeMinorGridlinesVisible(true);
    assertTrue(plot1.equals(plot2));
    plot1.setRangeMinorGridlinePaint(Color.blue);
    assertFalse(plot1.equals(plot2));
    plot2.setRangeMinorGridlinePaint(Color.blue);
    assertTrue(plot1.equals(plot2));
    plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
    assertFalse(plot1.equals(plot2));
    plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f));
    assertTrue(plot1.equals(plot2));
    List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
    plot1.mapDatasetToDomainAxes(0, axisIndices);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToDomainAxes(0, axisIndices);
    assertTrue(plot1.equals(plot2));
    plot1.mapDatasetToRangeAxes(0, axisIndices);
    assertFalse(plot1.equals(plot2));
    plot2.mapDatasetToRangeAxes(0, axisIndices);
    assertTrue(plot1.equals(plot2));
    // shadowGenerator
    plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, 0.6f, 4, -Math.PI / 4));
    assertFalse(plot1.equals(plot2));
    plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, 0.6f, 4, -Math.PI / 4));
    assertTrue(plot1.equals(plot2));
    plot1.setShadowGenerator(null);
    assertFalse(plot1.equals(plot2));
    plot2.setShadowGenerator(null);
    assertTrue(plot1.equals(plot2));
    LegendItemCollection lic1 = new LegendItemCollection();
    lic1.add(new LegendItem("XYZ", Color.red));
    plot1.setFixedLegendItems(lic1);
    assertFalse(plot1.equals(plot2));
    LegendItemCollection lic2 = new LegendItemCollection();
    lic2.add(new LegendItem("XYZ", Color.red));
    plot2.setFixedLegendItems(lic2);
    assertTrue(plot1.equals(plot2));
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) NumberAxis(org.jfree.chart.axis.NumberAxis) LegendItemCollection(org.jfree.chart.LegendItemCollection) GradientPaint(java.awt.GradientPaint) DefaultShadowGenerator(org.jfree.chart.util.DefaultShadowGenerator) DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) Point2D(java.awt.geom.Point2D) LegendItem(org.jfree.chart.LegendItem) RectangleInsets(org.jfree.ui.RectangleInsets) List(java.util.List) Test(org.junit.Test)

Example 13 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.

the class XYPlotTest method testDatasetIndices.

/**
 * Datasets are now stored in a Map, and it should be possible to assign
 * them an arbitrary key (index).
 */
@Test
public void testDatasetIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(dataset, plot.getDataset(0));
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    // we should be able to give a dataset an arbitrary index
    plot.setDataset(99, dataset2);
    assertEquals(2, plot.getDatasetCount());
    assertEquals(dataset2, plot.getDataset(99));
    assertEquals(0, plot.indexOf(dataset));
    assertEquals(99, plot.indexOf(dataset2));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) XYSeries(org.jfree.data.xy.XYSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYDataset(org.jfree.data.xy.XYDataset) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Aggregations

DefaultXYItemRenderer (org.jfree.chart.renderer.xy.DefaultXYItemRenderer)13 NumberAxis (org.jfree.chart.axis.NumberAxis)12 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)12 Test (org.junit.Test)12 StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)11 DefaultXYDataset (org.jfree.data.xy.DefaultXYDataset)11 IntervalXYDataset (org.jfree.data.xy.IntervalXYDataset)11 XYDataset (org.jfree.data.xy.XYDataset)11 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)11 XYSeries (org.jfree.data.xy.XYSeries)6 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)4 List (java.util.List)3 BasicStroke (java.awt.BasicStroke)1 GradientPaint (java.awt.GradientPaint)1 Stroke (java.awt.Stroke)1 Point2D (java.awt.geom.Point2D)1 LegendItem (org.jfree.chart.LegendItem)1 LegendItemCollection (org.jfree.chart.LegendItemCollection)1 DefaultShadowGenerator (org.jfree.chart.util.DefaultShadowGenerator)1 RectangleInsets (org.jfree.ui.RectangleInsets)1