Search in sources :

Example 11 with StandardXYItemRenderer

use of org.jfree.chart.renderer.xy.StandardXYItemRenderer in project Course_Generator by patrovite.

the class JPanelAnalysisSpeed method CreateChart.

private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) {
    JFreeChart chart = ChartFactory.createXYAreaChart("", // "Distance",
    bundle.getString("JPanelAnalysisSpeed.labelX"), // "Speed"
    bundle.getString("JPanelAnalysisSpeed.labelY"), // data
    dataset1, // include legend
    PlotOrientation.VERTICAL, // include legend
    false, // tooltips
    true, // urls
    false);
    // Panel background color
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00));
    renderer.setOutline(true);
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    plot.setRenderer(0, renderer);
    NumberAxis rangeAxis2 = new NumberAxis();
    plot.setRangeAxis(1, rangeAxis2);
    plot.setDataset(1, dataset2);
    plot.setRangeAxis(1, rangeAxis2);
    plot.mapDatasetToRangeAxis(1, 1);
    StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);
    // -- Select the display order
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) Color(java.awt.Color) JFreeChart(org.jfree.chart.JFreeChart)

Example 12 with StandardXYItemRenderer

use of org.jfree.chart.renderer.xy.StandardXYItemRenderer in project Course_Generator by patrovite.

the class JPanelAnalysisSpeedSlope method CreateChart.

private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) {
    JFreeChart chart = ChartFactory.createScatterPlot("", // "Slope",
    bundle.getString("JPanelAnalysisSpeedSlope.labelX"), // "Speed",
    bundle.getString("JPanelAnalysisSpeedSlope.labelY"), // include legend
    dataset1, // include legend
    PlotOrientation.VERTICAL, // include legend
    false, // tooltips
    true, // urls
    false);
    // Panel background color
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    XYDotRenderer renderer = new XYDotRenderer();
    renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00));
    renderer.setDotWidth(4);
    renderer.setDotHeight(4);
    // renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);
    // renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    plot.setRenderer(renderer);
    NumberAxis rangeAxis2 = new NumberAxis();
    plot.setRangeAxis(1, rangeAxis2);
    plot.setDataset(1, dataset2);
    plot.setRangeAxis(1, rangeAxis2);
    plot.mapDatasetToRangeAxis(1, 1);
    StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);
    // -- Select the display order
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) Color(java.awt.Color) XYDotRenderer(org.jfree.chart.renderer.xy.XYDotRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 13 with StandardXYItemRenderer

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

the class XYPlotTest method testSerialization1.

/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization1() {
    XYDataset data = new XYSeriesCollection();
    NumberAxis domainAxis = new NumberAxis("Domain");
    NumberAxis rangeAxis = new NumberAxis("Range");
    StandardXYItemRenderer renderer = new StandardXYItemRenderer();
    XYPlot p1 = new XYPlot(data, domainAxis, rangeAxis, renderer);
    XYPlot p2 = (XYPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYDataset(org.jfree.data.xy.XYDataset) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Example 14 with StandardXYItemRenderer

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

the class XYPlotTest method testCloneIndependence.

/**
 * Tests the independence of the clones.
 */
@Test
public void testCloneIndependence() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setDomainAxis(1, new NumberAxis("Domain Axis 2"));
    p1.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1.equals(p2));
    p1.getDomainAxis().setLabel("Label");
    assertFalse(p1.equals(p2));
    p2.getDomainAxis().setLabel("Label");
    assertTrue(p1.equals(p2));
    p1.getDomainAxis(1).setLabel("S1");
    assertFalse(p1.equals(p2));
    p2.getDomainAxis(1).setLabel("S1");
    assertTrue(p1.equals(p2));
    p1.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT);
    assertFalse(p1.equals(p2));
    p2.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT);
    assertTrue(p1.equals(p2));
    p1.mapDatasetToDomainAxis(2, 1);
    assertFalse(p1.equals(p2));
    p2.mapDatasetToDomainAxis(2, 1);
    assertTrue(p1.equals(p2));
    p1.getRangeAxis().setLabel("Label");
    assertFalse(p1.equals(p2));
    p2.getRangeAxis().setLabel("Label");
    assertTrue(p1.equals(p2));
    p1.getRangeAxis(1).setLabel("S1");
    assertFalse(p1.equals(p2));
    p2.getRangeAxis(1).setLabel("S1");
    assertTrue(p1.equals(p2));
    p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT);
    assertFalse(p1.equals(p2));
    p2.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT);
    assertTrue(p1.equals(p2));
    p1.mapDatasetToRangeAxis(2, 1);
    assertFalse(p1.equals(p2));
    p2.mapDatasetToRangeAxis(2, 1);
    assertTrue(p1.equals(p2));
    p1.getRenderer().setOutlinePaint(Color.cyan);
    assertFalse(p1.equals(p2));
    p2.getRenderer().setOutlinePaint(Color.cyan);
    assertTrue(p1.equals(p2));
    p1.getRenderer(1).setOutlinePaint(Color.red);
    assertFalse(p1.equals(p2));
    p2.getRenderer(1).setOutlinePaint(Color.red);
    assertTrue(p1.equals(p2));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) Test(org.junit.Test)

Example 15 with StandardXYItemRenderer

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

the class XYPlotTest method testSerialization5.

/**
 * Tests a bug where the plot is no longer registered as a listener
 * with the dataset(s) and axes after deserialization.  See patch 1209475
 * at SourceForge.
 */
@Test
public void testSerialization5() {
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    NumberAxis domainAxis1 = new NumberAxis("Domain 1");
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    StandardXYItemRenderer renderer1 = new StandardXYItemRenderer();
    XYPlot p1 = new XYPlot(dataset1, domainAxis1, rangeAxis1, renderer1);
    NumberAxis domainAxis2 = new NumberAxis("Domain 2");
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    p1.setDataset(1, dataset2);
    p1.setDomainAxis(1, domainAxis2);
    p1.setRangeAxis(1, rangeAxis2);
    p1.setRenderer(1, renderer2);
    XYPlot p2 = (XYPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);
    // now check that all datasets, renderers and axes are being listened
    // too...
    NumberAxis domainAxisA = (NumberAxis) p2.getDomainAxis(0);
    NumberAxis rangeAxisA = (NumberAxis) p2.getRangeAxis(0);
    XYSeriesCollection datasetA = (XYSeriesCollection) p2.getDataset(0);
    StandardXYItemRenderer rendererA = (StandardXYItemRenderer) p2.getRenderer(0);
    NumberAxis domainAxisB = (NumberAxis) p2.getDomainAxis(1);
    NumberAxis rangeAxisB = (NumberAxis) p2.getRangeAxis(1);
    XYSeriesCollection datasetB = (XYSeriesCollection) p2.getDataset(1);
    StandardXYItemRenderer rendererB = (StandardXYItemRenderer) p2.getRenderer(1);
    assertTrue(datasetA.hasListener(p2));
    assertTrue(domainAxisA.hasListener(p2));
    assertTrue(rangeAxisA.hasListener(p2));
    assertTrue(rendererA.hasListener(p2));
    assertTrue(datasetB.hasListener(p2));
    assertTrue(domainAxisB.hasListener(p2));
    assertTrue(rangeAxisB.hasListener(p2));
    assertTrue(rendererB.hasListener(p2));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Aggregations

StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)17 NumberAxis (org.jfree.chart.axis.NumberAxis)13 XYPlot (org.jfree.chart.plot.XYPlot)9 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)5 Test (org.junit.Test)5 JFreeChart (org.jfree.chart.JFreeChart)4 XYDataset (org.jfree.data.xy.XYDataset)4 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)4 BasicStroke (java.awt.BasicStroke)3 Color (java.awt.Color)3 Font (java.awt.Font)2 XYTextAnnotation (org.jfree.chart.annotations.XYTextAnnotation)2 CategoryPlot (org.jfree.chart.plot.CategoryPlot)2 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)2 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)2 XYAreaRenderer (org.jfree.chart.renderer.xy.XYAreaRenderer)2 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)2 SimOuts (com.chrisali.javaflightsim.simulation.integration.SimOuts)1 SubPlotOptions (com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotOptions)1 BorderLayout (java.awt.BorderLayout)1