Search in sources :

Example 11 with PolarPlot

use of org.jfree.chart.plot.PolarPlot in project seng438-a3-R41Ryan by seng438-winter-2022.

the class PolarChartPanel method actionPerformed.

/**
 * Handles action events generated by the popup menu.
 *
 * @param event  the event.
 */
@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals(POLAR_ZOOM_IN_ACTION_COMMAND)) {
        PolarPlot plot = (PolarPlot) getChart().getPlot();
        plot.zoom(0.5);
    } else if (command.equals(POLAR_ZOOM_OUT_ACTION_COMMAND)) {
        PolarPlot plot = (PolarPlot) getChart().getPlot();
        plot.zoom(2.0);
    } else if (command.equals(POLAR_AUTO_RANGE_ACTION_COMMAND)) {
        PolarPlot plot = (PolarPlot) getChart().getPlot();
        plot.getAxis().setAutoRange(true);
    } else {
        super.actionPerformed(event);
    }
}
Also used : PolarPlot(org.jfree.chart.plot.PolarPlot)

Example 12 with PolarPlot

use of org.jfree.chart.plot.PolarPlot in project seng438-a3-R41Ryan by seng438-winter-2022.

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)

Example 13 with PolarPlot

use of org.jfree.chart.plot.PolarPlot in project graphcode2vec by graphcode2vec.

the class ChartFactory method createPolarChart.

/**
 * Creates a polar plot for the specified dataset (x-values interpreted as
 * angles in degrees).  The chart object returned by this method uses a
 * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for
 * the radial axis.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param legend  legend required?
 *
 * @return A chart.
 */
public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend) {
    PolarPlot plot = new PolarPlot();
    plot.setDataset(dataset);
    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setAxis(rangeAxis);
    plot.setRenderer(new DefaultPolarItemRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) PolarPlot(org.jfree.chart.plot.PolarPlot) DefaultPolarItemRenderer(org.jfree.chart.renderer.DefaultPolarItemRenderer) RectangleInsets(org.jfree.chart.util.RectangleInsets)

Example 14 with PolarPlot

use of org.jfree.chart.plot.PolarPlot in project SIMVA-SoS by SESoS.

the class ChartFactory method createPolarChart.

/**
 * Creates a polar plot for the specified dataset (x-values interpreted as
 * angles in degrees).  The chart object returned by this method uses a
 * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for
 * the radial axis.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param legend  legend required?
 * @param tooltips  tooltips required?
 * @param urls  URLs required?
 *
 * @return A chart.
 */
public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) {
    PolarPlot plot = new PolarPlot();
    plot.setDataset(dataset);
    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setAxis(rangeAxis);
    plot.setRenderer(new DefaultPolarItemRenderer());
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) PolarPlot(org.jfree.chart.plot.PolarPlot) DefaultPolarItemRenderer(org.jfree.chart.renderer.DefaultPolarItemRenderer) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 15 with PolarPlot

use of org.jfree.chart.plot.PolarPlot in project SIMVA-SoS by SESoS.

the class DefaultPolarPlotEditor method updatePlotProperties.

@Override
public void updatePlotProperties(Plot plot) {
    super.updatePlotProperties(plot);
    PolarPlot pp = (PolarPlot) plot;
    pp.setAngleTickUnit(new NumberTickUnit(this.manualTickUnitValue));
    pp.setAngleOffset(this.angleOffsetValue);
}
Also used : PolarPlot(org.jfree.chart.plot.PolarPlot) NumberTickUnit(org.jfree.chart.axis.NumberTickUnit)

Aggregations

PolarPlot (org.jfree.chart.plot.PolarPlot)26 Axis (org.jfree.chart.axis.Axis)6 CategoryPlot (org.jfree.chart.plot.CategoryPlot)6 XYPlot (org.jfree.chart.plot.XYPlot)6 Paint (java.awt.Paint)4 Shape (java.awt.Shape)4 Stroke (java.awt.Stroke)4 ColorBar (org.jfree.chart.axis.ColorBar)4 NumberAxis (org.jfree.chart.axis.NumberAxis)4 ContourPlot (org.jfree.chart.plot.ContourPlot)4 DrawingSupplier (org.jfree.chart.plot.DrawingSupplier)4 DefaultPolarItemRenderer (org.jfree.chart.renderer.DefaultPolarItemRenderer)4 XYDataset (org.jfree.data.xy.XYDataset)4 JTabbedPane (javax.swing.JTabbedPane)3 LegendItem (org.jfree.chart.LegendItem)3 NumberTickUnit (org.jfree.chart.axis.NumberTickUnit)3 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)3 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)3 StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)3 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)3