Search in sources :

Example 1 with StandardXYItemRenderer

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

the class JPanelAnalysisTimeDist method CreateChart.

private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) {
    JFreeChart chart = ChartFactory.createXYAreaChart("", // "Distance"
    bundle.getString("JPanelAnalysisTimeDist.labelX"), // "Elevation"
    bundle.getString("JPanelAnalysisTimeDist.labelY1"), // data
    dataset1, // include legend
    PlotOrientation.VERTICAL, // include legend
    false, // tooltips
    true, // urls
    false);
    // -- Background color
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);
    XYPlot plot = (XYPlot) chart.getPlot();
    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);
    // "Time"
    NumberAxis rangeAxis2 = new NumberAxis(bundle.getString("JPanelAnalysisTimeDist.labelY2"));
    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 2 with StandardXYItemRenderer

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

the class ChartsUtils method setScatterPlotLinearRegressionEnabled.

/**
 * Modify a scatter plot to show linear regression or not.
 * @param scatterPlot Scatter plot to modify
 * @param enabled Indicates if linear regression has to be shown
 */
public static void setScatterPlotLinearRegressionEnabled(final JFreeChart scatterPlot, final boolean enabled) {
    XYPlot plot = (XYPlot) scatterPlot.getPlot();
    if (enabled) {
        StandardXYItemRenderer regressionRenderer = new StandardXYItemRenderer();
        regressionRenderer.setBaseSeriesVisibleInLegend(false);
        plot.setDataset(1, regress((XYSeriesCollection) plot.getDataset(0)));
        plot.setRenderer(1, regressionRenderer);
    } else {
        // Remove linear regression
        plot.setDataset(1, null);
    }
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 3 with StandardXYItemRenderer

use of org.jfree.chart.renderer.xy.StandardXYItemRenderer in project j6dof-flight-sim by chris-ali.

the class SimulationPlot method createPlots.

/**
 * Populates the {@link plotLists} List with {@link XYPlot} objects created from the logsOut ArrayList
 * argument. It first creates {@link XYSeries} objects with data from logsOut, adds those to
 * {@link XYSeriesCollection}, adds those series collections to {@link XYPlot} objects, and finally
 * puts the XYPlot objects into {@link plotList}. The types of {@link XYPlot} objects generated
 * comes from settings in {@link SubPlotBundle}
 *
 * @param logsOut
 * @param bundle
 */
private void createPlots(List<Map<SimOuts, Double>> logsOut, SubPlotBundle bundle) {
    for (SubPlotOptions option : bundle.getSubPlots()) {
        XYSeriesCollection collection = new XYSeriesCollection();
        for (SimOuts simout : option.getyData()) {
            XYSeries series = new XYSeries(simout.toString());
            xySeriesData.put(simout, series);
            collection.addSeries(series);
        }
        domainAxis = new NumberAxis(option.getxAxisName());
        rangeAxes.put(option.getTitle(), new NumberAxis(option.getyAxisName()));
        xyCollections.put(option.getTitle(), collection);
    }
    combinedDomPlot = new CombinedDomainXYPlot(domainAxis);
    updateXYSeriesData(logsOut, bundle);
    for (Map.Entry<String, XYSeriesCollection> entry : xyCollections.entrySet()) {
        logger.debug("Creating a subplot called: " + entry.getKey() + "...");
        XYPlot subPlot = new XYPlot(entry.getValue(), domainAxis, rangeAxes.get(entry.getKey()), new StandardXYItemRenderer());
        plotList.add(subPlot);
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) SimOuts(com.chrisali.javaflightsim.simulation.integration.SimOuts) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) CombinedDomainXYPlot(org.jfree.chart.plot.CombinedDomainXYPlot) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SubPlotOptions(com.chrisali.javaflightsim.swing.plotting.PlotConfiguration.SubPlotOptions)

Example 4 with StandardXYItemRenderer

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

the class CashFlowToChart method addCashFlowAxis.

/**
 * Adds the cash flow axis to the plot.
 * @param plot the plot
 * @param dataset the cash flow dataset
 */
private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) {
    final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio");
    cashAxis.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, cashAxis);
    plot.setDataset(1, dataset);
    plot.mapDatasetToRangeAxis(1, 1);
    final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer();
    cashFlowRenderer.setSeriesPaint(0, Color.blue);
    plot.setRenderer(1, cashFlowRenderer);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer)

Example 5 with StandardXYItemRenderer

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

the class DefaultPlotEditor method createPlotPanel.

protected JPanel createPlotPanel(Plot plot) {
    this.plotInsets = plot.getInsets();
    this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint());
    this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke());
    this.outlinePaintSample = new PaintSample(plot.getOutlinePaint());
    if (plot instanceof CategoryPlot) {
        this.plotOrientation = ((CategoryPlot) plot).getOrientation();
    } else if (plot instanceof XYPlot) {
        this.plotOrientation = ((XYPlot) plot).getOrientation();
    }
    if (plot instanceof CategoryPlot) {
        CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer();
        if (renderer instanceof LineAndShapeRenderer) {
            LineAndShapeRenderer r = (LineAndShapeRenderer) renderer;
            this.drawLines = BooleanUtilities.valueOf(r.getBaseLinesVisible());
            this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible());
        }
    } else if (plot instanceof XYPlot) {
        XYItemRenderer renderer = ((XYPlot) plot).getRenderer();
        if (renderer instanceof StandardXYItemRenderer) {
            StandardXYItemRenderer r = (StandardXYItemRenderer) renderer;
            this.drawLines = BooleanUtilities.valueOf(r.getPlotLines());
            this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible());
        }
    }
    setLayout(new BorderLayout());
    this.availableStrokeSamples = new StrokeSample[4];
    this.availableStrokeSamples[0] = new StrokeSample(null);
    this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(1.0f));
    this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(2.0f));
    this.availableStrokeSamples[3] = new StrokeSample(new BasicStroke(3.0f));
    // create a panel for the settings...
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":")));
    JPanel general = new JPanel(new BorderLayout());
    general.setBorder(BorderFactory.createTitledBorder(localizationResources.getString("General")));
    JPanel interior = new JPanel(new LCBLayout(7));
    interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    // interior.add(new JLabel(localizationResources.getString("Insets")));
    // JButton button = new JButton(
    // localizationResources.getString("Edit...")
    // );
    // button.setActionCommand("Insets");
    // button.addActionListener(this);
    // 
    // this.insetsTextField = new InsetsTextField(this.plotInsets);
    // this.insetsTextField.setEnabled(false);
    // interior.add(this.insetsTextField);
    // interior.add(button);
    interior.add(new JLabel(localizationResources.getString("Outline_stroke")));
    JButton button = new JButton(localizationResources.getString("Select..."));
    button.setActionCommand("OutlineStroke");
    button.addActionListener(this);
    interior.add(this.outlineStrokeSample);
    interior.add(button);
    interior.add(new JLabel(localizationResources.getString("Outline_Paint")));
    button = new JButton(localizationResources.getString("Select..."));
    button.setActionCommand("OutlinePaint");
    button.addActionListener(this);
    interior.add(this.outlinePaintSample);
    interior.add(button);
    interior.add(new JLabel(localizationResources.getString("Background_paint")));
    button = new JButton(localizationResources.getString("Select..."));
    button.setActionCommand("BackgroundPaint");
    button.addActionListener(this);
    interior.add(this.backgroundPaintSample);
    interior.add(button);
    if (this.plotOrientation != null) {
        boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL);
        int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL;
        interior.add(new JLabel(localizationResources.getString("Orientation")));
        this.orientationCombo = new JComboBox(orientationNames);
        this.orientationCombo.setSelectedIndex(index);
        this.orientationCombo.setActionCommand("Orientation");
        this.orientationCombo.addActionListener(this);
        interior.add(new JPanel());
        interior.add(this.orientationCombo);
    }
    if (this.drawLines != null) {
        interior.add(new JLabel(localizationResources.getString("Draw_lines")));
        this.drawLinesCheckBox = new JCheckBox();
        this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue());
        this.drawLinesCheckBox.setActionCommand("DrawLines");
        this.drawLinesCheckBox.addActionListener(this);
        interior.add(new JPanel());
        interior.add(this.drawLinesCheckBox);
    }
    if (this.drawShapes != null) {
        interior.add(new JLabel(localizationResources.getString("Draw_shapes")));
        this.drawShapesCheckBox = new JCheckBox();
        this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue());
        this.drawShapesCheckBox.setActionCommand("DrawShapes");
        this.drawShapesCheckBox.addActionListener(this);
        interior.add(new JPanel());
        interior.add(this.drawShapesCheckBox);
    }
    general.add(interior, BorderLayout.NORTH);
    JPanel appearance = new JPanel(new BorderLayout());
    appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    appearance.add(general, BorderLayout.NORTH);
    JTabbedPane tabs = createPlotTabs(plot);
    tabs.add(localizationResources.getString("Appearance"), appearance);
    panel.add(tabs);
    return panel;
}
Also used : BasicStroke(java.awt.BasicStroke) LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) JPanel(javax.swing.JPanel) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) JComboBox(javax.swing.JComboBox) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Paint(java.awt.Paint) LCBLayout(org.jfree.layout.LCBLayout) JCheckBox(javax.swing.JCheckBox) XYPlot(org.jfree.chart.plot.XYPlot) BorderLayout(java.awt.BorderLayout) PaintSample(org.jfree.ui.PaintSample) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) StrokeSample(org.jfree.ui.StrokeSample) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer)

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