org.jfree.chart.plot.Plot Java Examples
The following examples show how to use
org.jfree.chart.plot.Plot.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardChartTheme.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Applies this theme to the supplied chart. * * @param chart the chart (<code>null</code> not permitted). */ @Override public void apply(JFreeChart chart) { ParamChecks.nullNotPermitted(chart, "chart"); TextTitle title = chart.getTitle(); if (title != null) { title.setFont(this.extraLargeFont); title.setPaint(this.titlePaint); } int subtitleCount = chart.getSubtitleCount(); for (int i = 0; i < subtitleCount; i++) { applyToTitle(chart.getSubtitle(i)); } chart.setBackgroundPaint(this.chartBackgroundPaint); // now process the plot if there is one Plot plot = chart.getPlot(); if (plot != null) { applyToPlot(plot); } }
Example #2
Source File: ChartPanel.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Restores the auto-range calculation on the domain axis. */ public void restoreAutoDomainBounds() { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); // we need to guard against this.zoomPoint being null Point2D zp = (this.zoomPoint != null ? this.zoomPoint : new Point()); z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp); plot.setNotify(savedNotify); } }
Example #3
Source File: MouseWheelHandler.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Handles a mouse wheel event from the underlying chart panel. * * @param e the event. */ @Override public void mouseWheelMoved(MouseWheelEvent e) { JFreeChart chart = this.chartPanel.getChart(); if (chart == null) { return; } Plot plot = chart.getPlot(); if (plot instanceof Zoomable) { Zoomable zoomable = (Zoomable) plot; handleZoomable(zoomable, e); } else if (plot instanceof PiePlot) { PiePlot pp = (PiePlot) plot; pp.handleMouseWheelRotation(e.getWheelRotation()); } }
Example #4
Source File: ScrollHandlerFX.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Handle the case where a plot implements the {@link Zoomable} interface. * * @param zoomable the zoomable plot. * @param e the mouse wheel event. */ private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, ScrollEvent e) { // don't zoom unless the mouse pointer is in the plot's data area ChartRenderingInfo info = canvas.getRenderingInfo(); PlotRenderingInfo pinfo = info.getPlotInfo(); Point2D p = new Point2D.Double(e.getX(), e.getY()); if (pinfo.getDataArea().contains(p)) { Plot plot = (Plot) zoomable; // do not notify while zooming each axis boolean notifyState = plot.isNotify(); plot.setNotify(false); int clicks = (int) e.getDeltaY(); double zf = 1.0 + this.zoomFactor; if (clicks < 0) { zf = 1.0 / zf; } if (true) { //this.chartPanel.isDomainZoomable()) { zoomable.zoomDomainAxes(zf, pinfo, p, true); } if (true) { //this.chartPanel.isRangeZoomable()) { zoomable.zoomRangeAxes(zf, pinfo, p, true); } plot.setNotify(notifyState); // this generates the change event too } }
Example #5
Source File: StandardChartTheme.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Applies this theme to the supplied chart. * * @param chart the chart (<code>null</code> not permitted). */ @Override public void apply(JFreeChart chart) { ParamChecks.nullNotPermitted(chart, "chart"); TextTitle title = chart.getTitle(); if (title != null) { title.setFont(this.extraLargeFont); title.setPaint(this.titlePaint); } int subtitleCount = chart.getSubtitleCount(); for (int i = 0; i < subtitleCount; i++) { applyToTitle(chart.getSubtitle(i)); } chart.setBackgroundPaint(this.chartBackgroundPaint); // now process the plot if there is one Plot plot = chart.getPlot(); if (plot != null) { applyToPlot(plot); } }
Example #6
Source File: ChartComposite.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Increases the length the range axis, centered about the given * coordinate on the screen. The length of the range axis is increased * by the value of {@link #getZoomOutFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomOutRange(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }
Example #7
Source File: MouseWheelHandler.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Handle the case where a plot implements the {@link Zoomable} interface. * * @param zoomable the zoomable plot. * @param e the mouse wheel event. */ private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) { // don't zoom unless the mouse pointer is in the plot's data area ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); PlotRenderingInfo pinfo = info.getPlotInfo(); Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint()); if (!pinfo.getDataArea().contains(p)) { return; } Plot plot = (Plot) zoomable; // do not notify while zooming each axis boolean notifyState = plot.isNotify(); plot.setNotify(false); int clicks = e.getWheelRotation(); double zf = 1.0 + this.zoomFactor; if (clicks < 0) { zf = 1.0 / zf; } if (chartPanel.isDomainZoomable()) { zoomable.zoomDomainAxes(zf, pinfo, p, true); } if (chartPanel.isRangeZoomable()) { zoomable.zoomRangeAxes(zf, pinfo, p, true); } plot.setNotify(notifyState); // this generates the change event too }
Example #8
Source File: JFreeChart.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Clones the object, and takes care of listeners. * Note: caller shall register its own listeners on cloned graph. * * @return A clone. * * @throws CloneNotSupportedException if the chart is not cloneable. */ @Override public Object clone() throws CloneNotSupportedException { JFreeChart chart = (JFreeChart) super.clone(); chart.renderingHints = (RenderingHints) this.renderingHints.clone(); // private boolean borderVisible; // private transient Stroke borderStroke; // private transient Paint borderPaint; if (this.title != null) { chart.title = (TextTitle) this.title.clone(); chart.title.addChangeListener(chart); } chart.subtitles = new ArrayList(); for (int i = 0; i < getSubtitleCount(); i++) { Title subtitle = (Title) getSubtitle(i).clone(); chart.subtitles.add(subtitle); subtitle.addChangeListener(chart); } if (this.plot != null) { chart.plot = (Plot) this.plot.clone(); chart.plot.addChangeListener(chart); } chart.progressListeners = new EventListenerList(); chart.changeListeners = new EventListenerList(); return chart; }
Example #9
Source File: ChartComposite.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * A flag that controls mouse-based zooming on the vertical axis. * * @param flag <code>true</code> enables zooming. */ public void setRangeZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.rangeZoomable = flag && (z.isRangeZoomable()); } } else { this.rangeZoomable = false; } }
Example #10
Source File: PolarChartPanel.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * 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"); } }
Example #11
Source File: JFreeChart.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Clones the object, and takes care of listeners. * Note: caller shall register its own listeners on cloned graph. * * @return A clone. * * @throws CloneNotSupportedException if the chart is not cloneable. */ public Object clone() throws CloneNotSupportedException { JFreeChart chart = (JFreeChart) super.clone(); chart.renderingHints = (RenderingHints) this.renderingHints.clone(); // private boolean borderVisible; // private transient Stroke borderStroke; // private transient Paint borderPaint; if (this.title != null) { chart.title = (TextTitle) this.title.clone(); chart.title.addChangeListener(chart); } chart.subtitles = new ArrayList(); for (int i = 0; i < getSubtitleCount(); i++) { Title subtitle = (Title) getSubtitle(i).clone(); chart.subtitles.add(subtitle); subtitle.addChangeListener(chart); } if (this.plot != null) { chart.plot = (Plot) this.plot.clone(); chart.plot.addChangeListener(chart); } chart.progressListeners = new EventListenerList(); chart.changeListeners = new EventListenerList(); return chart; }
Example #12
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public Collection<String> resolveXAxis(int axisIndex) { Plot p = chart.getPlot(); Collection<String> names = new LinkedList<>(); if (p instanceof XYPlot) { XYPlot plot = (XYPlot) p; for (int i = 0; i < plot.getDomainAxisCount(); i++) { ValueAxis domain = plot.getDomainAxis(i); names.add(domain.getLabel()); } } return names; }
Example #13
Source File: ChartPanel.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Restores the auto-range calculation on both axes. */ public void restoreAutoBounds() { Plot plot = this.chart.getPlot(); if (plot == null) { return; } // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); restoreAutoDomainBounds(); restoreAutoRangeBounds(); plot.setNotify(savedNotify); }
Example #14
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public Collection<String> resolveYAxis(int axisIndex) { Plot p = chart.getPlot(); Collection<String> names = new LinkedList<>(); if (p instanceof XYPlot) { XYPlot plot = (XYPlot) p; for (int i = 0; i < plot.getRangeAxisCount(); i++) { ValueAxis domain = plot.getRangeAxis(i); names.add(domain.getLabel()); } } return names; }
Example #15
Source File: ChartComposite.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A flag that controls mouse-based zooming on the vertical axis. * * @param flag <code>true</code> enables zooming. */ public void setRangeZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.rangeZoomable = flag && (z.isRangeZoomable()); } } else { this.rangeZoomable = false; } }
Example #16
Source File: StepCustomizer.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void customize(JFreeChart jfc, JRChart jrc) { Plot plot = jfc.getPlot(); if (plot instanceof XYPlot) { ((XYPlot)plot).setRenderer(new XYStepRenderer()); } }
Example #17
Source File: ChartPanel.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Sets the flag that controls whether or not zooming is enabled for the * domain axis. A check is made to ensure that the current plot supports * zooming for the domain values. * * @param flag <code>true</code> enables zooming if possible. */ public void setDomainZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = flag && (z.isDomainZoomable()); } } else { this.domainZoomable = false; } }
Example #18
Source File: ChartPanel.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Sets the flag that controls whether or not zooming is enabled for the * domain axis. A check is made to ensure that the current plot supports * zooming for the domain values. * * @param flag <code>true</code> enables zooming if possible. */ public void setDomainZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = flag && (z.isDomainZoomable()); } } else { this.domainZoomable = false; } }
Example #19
Source File: ColorBar.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Reserves the space required to draw the color bar. * * @param g2 the graphics device. * @param plot the plot that the axis belongs to. * @param plotArea the area within which the plot should be drawn. * @param dataArea the data area. * @param edge the axis location. * @param space the space already reserved. * * @return The space required to draw the axis in the specified plot area. */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisSpace space) { AxisSpace result = this.axis.reserveSpace( g2, plot, plotArea, edge, space ); double thickness = calculateBarThickness(dataArea, edge); result.add(thickness + 2 * this.outerGap, edge); return result; }
Example #20
Source File: ChartComposite.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Restores the auto-range calculation on the domain axis. */ public void restoreAutoDomainBounds() { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; // we need to guard against this.zoomPoint being null org.eclipse.swt.graphics.Point zp = (this.zoomPoint != null ? this.zoomPoint : new org.eclipse.swt.graphics.Point(0, 0)); z.zoomDomainAxes(0.0, this.info.getPlotInfo(), SWTUtils.toAwtPoint(zp)); } }
Example #21
Source File: ChartPanel.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Sets the chart that is displayed in the panel. * * @param chart the chart (<code>null</code> permitted). */ public void setChart(JFreeChart chart) { // stop listening for changes to the existing chart if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } // add the new chart this.chart = chart; if (chart != null) { this.chart.addChangeListener(this); this.chart.addProgressListener(this); Plot plot = chart.getPlot(); this.domainZoomable = false; this.rangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = z.isDomainZoomable(); this.rangeZoomable = z.isRangeZoomable(); this.orientation = z.getOrientation(); } } else { this.domainZoomable = false; this.rangeZoomable = false; } if (this.useBuffer) { this.refreshBuffer = true; } repaint(); }
Example #22
Source File: ChartPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Decreases the length of the range axis, centered about the given * coordinate on the screen. The length of the range axis is reduced by * the value of {@link #getZoomInFactor()}. * * @param x the x-coordinate (in screen coordinates). * @param y the y coordinate (in screen coordinates). */ public void zoomInRange(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }
Example #23
Source File: ChartPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * A flag that controls mouse-based zooming on the vertical axis. * * @param flag <code>true</code> enables zooming. */ public void setRangeZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.rangeZoomable = flag && (z.isRangeZoomable()); } } else { this.rangeZoomable = false; } }
Example #24
Source File: ChartComposite.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Decreases the length of the range axis, centered about the given * coordinate on the screen. The length of the range axis is reduced by * the value of {@link #getZoomInFactor()}. * * @param x the x-coordinate (in screen coordinates). * @param y the y coordinate (in screen coordinates). */ public void zoomInRange(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } }
Example #25
Source File: BaseChartBuilderTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { Plot plot = new CategoryPlot(); _jFreeChart = new JFreeChart(plot); when(_chartingDefinition.getChartTitle()).thenReturn(CHART_TITLE); when(_chartingDefinition.getChartSubtitle()).thenReturn(CHART_SUB_TITLE); when(_chartingDefinition.getXAxisTitle()).thenReturn(X_TITLE); when(_chartingDefinition.getYAxisTitle()).thenReturn(Y_TITLE); when(_chartingDefinition.getSeriesDefinitions()).thenReturn(_seriesDefinitions ); }
Example #26
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * Receives notification of changes to the chart, and redraws the chart. * * @param event * details of the chart change event. */ @Override public void chartChanged(ChartChangeEvent event) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.orientation = z.getOrientation(); } repaint(); }
Example #27
Source File: DefaultPolarPlotEditor.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a tabbed pane for editing the plot attributes. * * @param plot the plot. * * @return A tabbed pane. */ @Override protected JTabbedPane createPlotTabs(Plot plot) { JTabbedPane tabs = super.createPlotTabs(plot); // TODO find a better localization key tabs.insertTab(localizationResources.getString("General1"), null, createPlotPanel(), null, 0); tabs.setSelectedIndex(0); return tabs; }
Example #28
Source File: ColorBar.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Reserves the space required to draw the color bar. * * @param g2 the graphics device. * @param plot the plot that the axis belongs to. * @param plotArea the area within which the plot should be drawn. * @param dataArea the data area. * @param edge the axis location. * @param space the space already reserved. * * @return The space required to draw the axis in the specified plot area. */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisSpace space) { AxisSpace result = this.axis.reserveSpace(g2, plot, plotArea, edge, space); double thickness = calculateBarThickness(dataArea, edge); result.add(thickness + 2 * this.outerGap, edge); return result; }
Example #29
Source File: TaScrollHandlerFX.java From TAcharting with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void handleScroll(TaChartCanvas canvas, ScrollEvent e) { JFreeChart chart = canvas.getChart(); Plot plot = chart.getPlot(); if (plot instanceof Zoomable) { Zoomable zoomable = (Zoomable) plot; handleZoomable(canvas, zoomable, e); } else if (plot instanceof PiePlot) { PiePlot pp = (PiePlot) plot; pp.handleMouseWheelRotation((int) e.getDeltaY()); } }
Example #30
Source File: ChartPanel.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Sets the chart that is displayed in the panel. * * @param chart the chart (<code>null</code> permitted). */ public void setChart(JFreeChart chart) { // stop listening for changes to the existing chart if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } // add the new chart this.chart = chart; if (chart != null) { this.chart.addChangeListener(this); this.chart.addProgressListener(this); Plot plot = chart.getPlot(); this.domainZoomable = false; this.rangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = z.isDomainZoomable(); this.rangeZoomable = z.isRangeZoomable(); this.orientation = z.getOrientation(); } } else { this.domainZoomable = false; this.rangeZoomable = false; } if (this.useBuffer) { this.refreshBuffer = true; } repaint(); }