Search in sources :

Example 16 with StandardXYItemRenderer

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

the class CombinedRangeXYPlotTest method createPlot.

/**
 * Creates a sample plot.
 *
 * @return A sample plot.
 */
private CombinedRangeXYPlot createPlot() {
    // create subplot 1...
    XYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new StandardXYItemRenderer();
    NumberAxis xAxis1 = new NumberAxis("X1");
    XYPlot subplot1 = new XYPlot(data1, xAxis1, null, 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 xAxis2 = new NumberAxis("X2");
    xAxis2.setAutoRangeIncludesZero(false);
    XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2);
    subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    // parent plot...
    CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis("Range"));
    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 17 with StandardXYItemRenderer

use of org.jfree.chart.renderer.xy.StandardXYItemRenderer 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)

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