/** * 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); return chart; }
/** * Creates a polar plot for the specified dataset (x-values interpreted as angles in degrees). * <P> * 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 Insets(0, 0, 0, 0)); plot.setRadialAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * 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; }
/** * 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} permitted). * @param dataset the dataset ({@code null} 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; }
private JFreeChart createXYPolarChart(String title, XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createPolarChart( title, dataset, true, false, false); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... PolarPlot plot = (PolarPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRenderer(new SOCRPolarItemRenderer()); //PolarItemRenderer renderer = plot.getRenderer(); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
public LegendItem getLegendItem(int series) { LegendItem result = null; PolarPlot polarPlot = getPlot(); if (polarPlot != null) { XYDataset dataset; dataset = polarPlot.getDataset(); s = new Summary(dataset); if (dataset != null) { //String label = dataset.getSeriesKey(series).toString(); String label = s.getYSummary(series)+"\n"; String description = label; Shape shape = lookupSeriesShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); result = new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint); result.setDataset(dataset); } } return result; }
/** * Return the legend for the given series. * * @param series the series index. * * @return The legend item. */ public LegendItem getLegendItem(int series) { LegendItem result = null; PolarPlot polarPlot = getPlot(); if (polarPlot != null) { XYDataset dataset = polarPlot.getDataset(); if (dataset != null) { String label = dataset.getSeriesKey(series).toString(); String description = label; Shape shape = lookupSeriesShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); result = new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint); result.setDataset(dataset); } } return result; }
/** * Return the legend for the given series. * * @param series the series index. * * @return The legend item. */ public LegendItem getLegendItem(int series) { LegendItem result = null; PolarPlot polarPlot = getPlot(); if (polarPlot != null) { XYDataset dataset; dataset = polarPlot.getDataset(); if (dataset != null) { String label = dataset.getSeriesKey(series).toString(); String description = label; Shape shape = getSeriesShape(series); Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); Stroke outlineStroke = getSeriesOutlineStroke(series); result = new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint); } } return result; }
/** * 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; }
private JFreeChart createPolarChart(final XYDataset dataset,String chartName) { if(chartName == null) chartName=FunctionToPlot; final JFreeChart chRt = ChartFactory.createPolarChart( chartName, dataset, true, true, false ); final PolarPlot plot = (PolarPlot) chRt.getPlot(); final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer(); renderer.setShapesVisible(false); //renderer.setShapesFilled(false); // renderer.setSeriesFilled(0, false); return chRt; }
/** * Returns the drawing supplier from the plot. * * @return The drawing supplier. */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; PolarPlot p = getPlot(); if (p != null) { result = p.getDrawingSupplier(); } return result; }
/** * Plots the data for a given series. * * @param g2 the drawing surface. * @param dataArea the data area. * @param info collects plot rendering info. * @param plot the plot. * @param dataset the dataset. * @param seriesIndex the series index. */ public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { Polygon poly = new Polygon(); int numPoints = dataset.getItemCount(seriesIndex); for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); double radius = dataset.getYValue(seriesIndex, i); Point p = plot.translateValueThetaRadiusToJava2D(theta, radius, dataArea); poly.addPoint(p.x, p.y); } g2.setPaint(getSeriesPaint(seriesIndex)); g2.setStroke(getSeriesStroke(seriesIndex)); if (isSeriesFilled(seriesIndex)) { Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); g2.fill(poly); g2.setComposite(savedComposite); } else { g2.draw(poly); } }
/** * Draw the radial gridlines - the rings. * * @param g2 the drawing surface. * @param plot the plot. * @param radialAxis the radial axis. * @param ticks the ticks. * @param dataArea the data area. */ public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea) { g2.setFont(radialAxis.getTickLabelFont()); g2.setPaint(plot.getRadiusGridlinePaint()); g2.setStroke(plot.getRadiusGridlineStroke()); Point center = plot.translateValueThetaRadiusToJava2D(0.0, 0.0, dataArea); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { NumberTick tick = (NumberTick) iterator.next(); Point p = plot.translateValueThetaRadiusToJava2D( 90.0, tick.getNumber().doubleValue(), dataArea ); int r = p.x - center.x; int upperLeftX = center.x - r; int upperLeftY = center.y - r; int d = 2 * r; Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d); g2.setPaint(plot.getRadiusGridlinePaint()); g2.draw(ring); } }
/** * Test that the chart is using an xy plot with time as the domain axis. * * @param chart the chart. */ private void checkChart(JFreeChart chart) { Plot plot = chart.getPlot(); if (!(plot instanceof PolarPlot)) { throw new IllegalArgumentException("plot is not a PolarPlot"); } }
/** * Plots the data for a given series. * * @param g2 the drawing surface. * @param dataArea the data area. * @param info collects plot rendering info. * @param plot the plot. * @param dataset the dataset. * @param seriesIndex the series index. */ public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { Polygon poly = new Polygon(); int numPoints = dataset.getItemCount(seriesIndex); for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); double radius = dataset.getYValue(seriesIndex, i); Point p = plot.translateValueThetaRadiusToJava2D(theta, radius, dataArea); poly.addPoint(p.x, p.y); } g2.setPaint(getSeriesPaint(seriesIndex)); g2.setStroke(getSeriesStroke(seriesIndex)); if (isSeriesFilled(seriesIndex)) { Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f)); g2.fill(poly); g2.setComposite(savedComposite); } else { g2.draw(poly); } }
/** * Draw the radial gridlines - the rings. * * @param g2 the drawing surface. * @param plot the plot. * @param radialAxis the radial axis. * @param ticks the ticks. * @param dataArea the data area. */ public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea) { g2.setFont(radialAxis.getTickLabelFont()); g2.setPaint(plot.getRadiusGridlinePaint()); g2.setStroke(plot.getRadiusGridlineStroke()); double axisMin = radialAxis.getLowerBound(); Point center = plot.translateValueThetaRadiusToJava2D(axisMin, axisMin, dataArea); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { NumberTick tick = (NumberTick) iterator.next(); Point p = plot.translateValueThetaRadiusToJava2D(90.0, tick.getNumber().doubleValue(), dataArea); int r = p.x - center.x; int upperLeftX = center.x - r; int upperLeftY = center.y - r; int d = 2 * r; Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d); g2.setPaint(plot.getRadiusGridlinePaint()); g2.draw(ring); } }
/** * Returns the drawing supplier from the plot. * * @return The drawing supplier. */ @Override public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; PolarPlot p = getPlot(); if (p != null) { result = p.getDrawingSupplier(); } return result; }
/** * Draw the radial gridlines - the rings. * * @param g2 the drawing surface (<code>null</code> not permitted). * @param plot the plot (<code>null</code> not permitted). * @param radialAxis the radial axis (<code>null</code> not permitted). * @param ticks the ticks (<code>null</code> not permitted). * @param dataArea the data area. */ @Override public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea) { ParamChecks.nullNotPermitted(radialAxis, "radialAxis"); g2.setFont(radialAxis.getTickLabelFont()); g2.setPaint(plot.getRadiusGridlinePaint()); g2.setStroke(plot.getRadiusGridlineStroke()); double centerValue; if (radialAxis.isInverted()) { centerValue = radialAxis.getUpperBound(); } else { centerValue = radialAxis.getLowerBound(); } Point center = plot.translateToJava2D(0, centerValue, radialAxis, dataArea); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { NumberTick tick = (NumberTick) iterator.next(); double angleDegrees = plot.isCounterClockwise() ? plot.getAngleOffset() : -plot.getAngleOffset(); Point p = plot.translateToJava2D(angleDegrees, tick.getNumber().doubleValue(), radialAxis, dataArea); int r = p.x - center.x; int upperLeftX = center.x - r; int upperLeftY = center.y - r; int d = 2 * r; Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d); g2.setPaint(plot.getRadiusGridlinePaint()); g2.draw(ring); } }
/** * Applies the attributes of this theme to a {@link PolarPlot}. This * method is called from the {@link #applyToPlot(Plot)} method. * * @param plot the plot (<code>null</code> not permitted). */ protected void applyToPolarPlot(PolarPlot plot) { plot.setAngleLabelFont(this.regularFont); plot.setAngleLabelPaint(this.tickLabelPaint); plot.setAngleGridlinePaint(this.domainGridlinePaint); plot.setRadiusGridlinePaint(this.rangeGridlinePaint); ValueAxis axis = plot.getAxis(); if (axis != null) { applyToValueAxis(axis); } }
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot. * * @param plot the plot, which should be changed. */ public DefaultPolarPlotEditor(PolarPlot plot) { super(plot); this.angleOffsetValue = plot.getAngleOffset(); this.angleOffset.setText(Double.toString(this.angleOffsetValue)); this.manualTickUnitValue = plot.getAngleTickUnit().getSize(); this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); }
@Override public void updatePlotProperties(Plot plot) { super.updatePlotProperties(plot); PolarPlot pp = (PolarPlot) plot; pp.setAngleTickUnit(new NumberTickUnit(this.manualTickUnitValue)); pp.setAngleOffset(this.angleOffsetValue); }