/** * Sets a renderer and, if requested, sends a {@link PlotChangeEvent} to * all registered listeners. * * @param index the index. * @param renderer the renderer. * @param notify notify listeners? * * @see #getRenderer(int) * * @since 1.0.14 */ public void setRenderer(int index, PolarItemRenderer renderer, boolean notify) { PolarItemRenderer existing = getRenderer(index); if (existing != null) { existing.removeChangeListener(this); } this.renderers.set(index, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } if (notify) { fireChangeEvent(); } }
/** * Returns the legend items for the plot. Each legend item is generated by * the plot's m_Renderer, since the m_Renderer is responsible for the visual * representation of the data. * * @return The legend items. */ @Override public LegendItemCollection getLegendItems() { if (this.fixedLegendItems != null) { return this.fixedLegendItems; } LegendItemCollection result = new LegendItemCollection(); int count = this.datasets.size(); for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { XYDataset dataset = getDataset(datasetIndex); PolarItemRenderer renderer = getRenderer(datasetIndex); if (dataset != null && renderer != null) { int seriesCount = dataset.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { LegendItem item = renderer.getLegendItem(i); result.add(item); } } } return result; }
/** * Returns the legend items for the plot. Each legend item is generated by * the plot's m_Renderer, since the m_Renderer is responsible for the visual * representation of the data. * * @return The legend items. */ public LegendItemCollection getLegendItems() { if (this.fixedLegendItems != null) { return this.fixedLegendItems; } LegendItemCollection result = new LegendItemCollection(); int count = this.datasets.size(); for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { XYDataset dataset = getDataset(datasetIndex); PolarItemRenderer renderer = getRenderer(datasetIndex); if (dataset != null && renderer != null) { int seriesCount = dataset.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { LegendItem item = renderer.getLegendItem(i); result.add(item); } } } return result; }
/** * Sets the item renderer, and notifies all listeners of a change to the plot. * <P> * If the renderer is set to <code>null</code>, no chart will be drawn. * * @param renderer the new renderer (<code>null</code> permitted). */ public void setRenderer(PolarItemRenderer renderer) { if (this.renderer != null) { this.renderer.removeChangeListener(this); } this.renderer = renderer; if (this.renderer != null) { this.renderer.setPlot(this); } notifyListeners(new PlotChangeEvent(this)); }
/** * Sets the item renderer, and notifies all listeners of a change to the * plot. * <P> * If the renderer is set to <code>null</code>, no chart will be drawn. * * @param renderer the new renderer (<code>null</code> permitted). * * @see #getRenderer() */ public void setRenderer(PolarItemRenderer renderer) { if (this.renderer != null) { this.renderer.removeChangeListener(this); } this.renderer = renderer; if (this.renderer != null) { this.renderer.setPlot(this); } notifyListeners(new PlotChangeEvent(this)); }
/** * Draws a representation of the data within the dataArea region, using the * current m_Renderer. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension * information (<code>null</code> permitted). */ protected void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) { // now get the data and plot it (the visual representation will depend // on the m_Renderer that has been set)... boolean hasData = false; int datasetCount = this.datasets.size(); for (int i = datasetCount - 1; i >= 0; i--) { XYDataset dataset = getDataset(i); if (dataset == null) { continue; } PolarItemRenderer renderer = getRenderer(i); if (renderer == null) { continue; } if (!DatasetUtilities.isEmptyOrNull(dataset)) { hasData = true; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { renderer.drawSeries(g2, dataArea, info, this, dataset, series); } } } if (!hasData) { drawNoDataMessage(g2, dataArea); } }
/** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.angleGridlineStroke = SerialUtilities.readStroke(stream); this.angleGridlinePaint = SerialUtilities.readPaint(stream); this.radiusGridlineStroke = SerialUtilities.readStroke(stream); this.radiusGridlinePaint = SerialUtilities.readPaint(stream); this.angleLabelPaint = SerialUtilities.readPaint(stream); int rangeAxisCount = this.axes.size(); for (int i = 0; i < rangeAxisCount; i++) { Axis axis = (Axis) this.axes.get(i); if (axis != null) { axis.setPlot(this); axis.addChangeListener(this); } } int datasetCount = this.datasets.size(); for (int i = 0; i < datasetCount; i++) { Dataset dataset = (Dataset) this.datasets.get(i); if (dataset != null) { dataset.addChangeListener(this); } } int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { PolarItemRenderer renderer = (PolarItemRenderer) this.renderers.get(i); if (renderer != null) { renderer.addChangeListener(this); } } }
/** * Draws a representation of the data within the dataArea region, using the * current m_Renderer. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension * information ({@code null} permitted). */ protected void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) { // now get the data and plot it (the visual representation will depend // on the m_Renderer that has been set)... boolean hasData = false; int datasetCount = this.datasets.size(); for (int i = datasetCount - 1; i >= 0; i--) { XYDataset dataset = getDataset(i); if (dataset == null) { continue; } PolarItemRenderer renderer = getRenderer(i); if (renderer == null) { continue; } if (!DatasetUtils.isEmptyOrNull(dataset)) { hasData = true; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { renderer.drawSeries(g2, dataArea, info, this, dataset, series); } } } if (!hasData) { drawNoDataMessage(g2, dataArea); } }
/** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.angleGridlineStroke = SerialUtils.readStroke(stream); this.angleGridlinePaint = SerialUtils.readPaint(stream); this.radiusGridlineStroke = SerialUtils.readStroke(stream); this.radiusGridlinePaint = SerialUtils.readPaint(stream); this.angleLabelPaint = SerialUtils.readPaint(stream); int rangeAxisCount = this.axes.size(); for (int i = 0; i < rangeAxisCount; i++) { Axis axis = (Axis) this.axes.get(i); if (axis != null) { axis.setPlot(this); axis.addChangeListener(this); } } int datasetCount = this.datasets.size(); for (int i = 0; i < datasetCount; i++) { Dataset dataset = (Dataset) this.datasets.get(i); if (dataset != null) { dataset.addChangeListener(this); } } int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { PolarItemRenderer renderer = (PolarItemRenderer) this.renderers.get(i); if (renderer != null) { renderer.addChangeListener(this); } } }
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). * @param radiusAxis the radius axis (<code>null</code> permitted). * @param renderer the renderer (<code>null</code> permitted). */ public PolarPlot(XYDataset dataset, ValueAxis radiusAxis, PolarItemRenderer renderer) { super(); this.dataset = dataset; if (this.dataset != null) { this.dataset.addChangeListener(this); } this.angleTickUnit = new NumberTickUnit(DEFAULT_ANGLE_TICK_UNIT_SIZE); this.axis = radiusAxis; if (this.axis != null) { this.axis.setPlot(this); this.axis.addChangeListener(this); } this.renderer = renderer; if (this.renderer != null) { this.renderer.setPlot(this); this.renderer.addChangeListener(this); } this.angleGridlinesVisible = true; this.angleGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.angleGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.radiusGridlinesVisible = true; this.radiusGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.radiusGridlinePaint = DEFAULT_GRIDLINE_PAINT; }
/** * Sets the item renderer, and notifies all listeners of a change to the * plot. * <P> * If the renderer is set to <code>null</code>, no chart will be drawn. * * @param renderer the new renderer (<code>null</code> permitted). * * @see #getRenderer() */ public void setRenderer(PolarItemRenderer renderer) { if (this.renderer != null) { this.renderer.removeChangeListener(this); } this.renderer = renderer; if (this.renderer != null) { this.renderer.setPlot(this); } fireChangeEvent(); }