Search in sources :

Example 6 with StandardXYItemRenderer

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

the class CombinedDomainXYPlotTest method createPlot.

/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedDomainXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis rangeAxis1 = new NumberAxis("Range 1");
    XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
    subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    annotation.setRotationAngle(Math.PI / 4.0);
    subplot1.addAnnotation(annotation);
    // create subplot 2...
    XYDataset data2 = createDataset2();
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    NumberAxis rangeAxis2 = new NumberAxis("Range 2");
    rangeAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    // parent plot...
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
    plot.setGap(10.0);
    // add the subplots...
    plot.add(subplot1, 1);
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}
Also used : XYTextAnnotation(org.jfree.chart.annotations.XYTextAnnotation) NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYDataset(org.jfree.data.xy.XYDataset) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) Font(java.awt.Font)

Example 7 with StandardXYItemRenderer

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

the class XYPlotTest method testCloning3.

/**
 * Tests cloning for a plot where the fixed legend items have been
 * specified.
 */
@Test
public void testCloning3() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    LegendItemCollection c1 = new LegendItemCollection();
    p1.setFixedLegendItems(c1);
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
    // verify independence of fixed legend item collection
    c1.add(new LegendItem("X"));
    assertFalse(p1.equals(p2));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) LegendItem(org.jfree.chart.LegendItem) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) LegendItemCollection(org.jfree.chart.LegendItemCollection) Test(org.junit.Test)

Example 8 with StandardXYItemRenderer

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

the class XYPlotTest method testCloning2.

/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) List(java.util.List) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) Test(org.junit.Test)

Example 9 with StandardXYItemRenderer

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

the class SWTMultipleAxisDemo1 method createChart.

/**
 * Creates the demo chart.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {
    XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200);
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false);
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setBorderPaint(Color.BLACK);
    TextTitle subtitle = new TextTitle("Four datasets and four range axes.");
    chart.addSubtitle(subtitle);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);
    // AXIS 2
    NumberAxis axis2 = new NumberAxis("Range Axis 2");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);
    XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);
    // AXIS 3
    NumberAxis axis3 = new NumberAxis("Range Axis 3");
    axis3.setLabelPaint(Color.blue);
    axis3.setTickLabelPaint(Color.blue);
    // axis3.setPositiveArrowVisible(true);
    plot.setRangeAxis(2, axis3);
    XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170);
    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 2);
    XYItemRenderer renderer3 = new StandardXYItemRenderer();
    renderer3.setSeriesPaint(0, Color.blue);
    plot.setRenderer(2, renderer3);
    // AXIS 4
    NumberAxis axis4 = new NumberAxis("Range Axis 4");
    axis4.setLabelPaint(Color.green);
    axis4.setTickLabelPaint(Color.green);
    plot.setRangeAxis(3, axis4);
    XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200);
    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 3);
    XYItemRenderer renderer4 = new StandardXYItemRenderer();
    renderer4.setSeriesPaint(0, Color.green);
    plot.setRenderer(3, renderer4);
    return chart;
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) NumberAxis(org.jfree.chart.axis.NumberAxis) Minute(org.jfree.data.time.Minute) XYPlot(org.jfree.chart.plot.XYPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) RectangleInsets(org.jfree.ui.RectangleInsets) XYDataset(org.jfree.data.xy.XYDataset) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 10 with StandardXYItemRenderer

use of org.jfree.chart.renderer.xy.StandardXYItemRenderer in project processdash by dtuma.

the class XYChart method addTrendLine.

private void addTrendLine(JFreeChart chart, XYDataset dataset) {
    XYPlot plot = chart.getXYPlot();
    plot.setDataset(1, dataset);
    plot.setRenderer(1, new StandardXYItemRenderer(StandardXYItemRenderer.LINES));
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer)

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