Java Code Examples for org.jfree.chart.axis.ValueAxis#setRange()
The following examples show how to use
org.jfree.chart.axis.ValueAxis#setRange() .
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: ChartFactory.java From openstock with GNU General Public License v3.0 | 7 votes |
/** * Creates a wind plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the x-axis (<code>null</code> permitted). * @param yAxisLabel a label for the y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag that controls whether or not a legend is created. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A wind plot. * */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example 2
Source File: ChartFactory.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a wind plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the x-axis (<code>null</code> permitted). * @param yAxisLabel a label for the y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag that controls whether or not a legend is created. * * @return A wind plot. */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example 3
Source File: CategoryPlot.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Pans the range axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panRangeAxes(double percent, PlotRenderingInfo info, Point2D source) { if (!isRangePannable()) { return; } int rangeAxisCount = getRangeAxisCount(); for (int i = 0; i < rangeAxisCount; i++) { ValueAxis axis = getRangeAxis(i); if (axis == null) { continue; } double length = axis.getRange().getLength(); double adj = percent * length; if (axis.isInverted()) { adj = -adj; } axis.setRange(axis.getLowerBound() + adj, axis.getUpperBound() + adj); } }
Example 4
Source File: AbstractAxisCustomizer.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected void configValueAxis( ValueAxis valueAxis, String minProp, String maxProp ) { if (valueAxis != null) { Double rangeMin = getDoubleProperty(minProp); Double rangeMax = getDoubleProperty(maxProp); if ( rangeMin != null || rangeMax != null ) { valueAxis.setRange( rangeMin == null ? valueAxis.getRange().getLowerBound() : rangeMin, rangeMax == null ? valueAxis.getRange().getUpperBound() : rangeMax ); } } }
Example 5
Source File: ChartFactory.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates a wind plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the x-axis (<code>null</code> permitted). * @param yAxisLabel a label for the y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag that controls whether or not a legend is created. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A wind plot. * */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example 6
Source File: DefaultValueAxisEditor.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ @Override public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); ValueAxis valueAxis = (ValueAxis) axis; valueAxis.setAutoRange(this.autoRange); if (!this.autoRange) { valueAxis.setRange(this.minimumValue, this.maximumValue); } valueAxis.setAutoTickUnitSelection(this.autoTickUnitSelection); }
Example 7
Source File: GraphPanel.java From swift-k with Apache License 2.0 | 5 votes |
private void updateMaxRange() { ValueAxis x = chart.getXYPlot().getDomainAxis(); if (maxRange == 0) { x.setAutoRange(true); } else { Range dr = chart.getXYPlot().getDataRange(x); x.setRange(Math.max(dr.getLowerBound(), dr.getUpperBound() - maxRange * 60 * 1000), dr.getUpperBound()); } }
Example 8
Source File: DefaultValueAxisEditor.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ @Override public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); ValueAxis valueAxis = (ValueAxis) axis; valueAxis.setAutoRange(this.autoRange); if (!this.autoRange) { valueAxis.setRange(this.minimumValue, this.maximumValue); } valueAxis.setAutoTickUnitSelection(this.autoTickUnitSelection); }
Example 9
Source File: ScatterPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void finishScalingUpdate(AxisRangeControl axisRangeControl, ValueAxis newAxis, ValueAxis oldAxis) { if (axisRangeControl.isAutoMinMax()) { newAxis.setAutoRange(false); acceptableDeviationDataset.removeAllSeries(); regressionDataset.removeAllSeries(); getPlot().removeAnnotation(r2Annotation); newAxis.setAutoRange(true); axisRangeControl.adjustComponents(newAxis, 3); newAxis.setAutoRange(false); computeRegressionAndAcceptableDeviationData(); } else { newAxis.setAutoRange(false); newAxis.setRange(oldAxis.getRange()); } }
Example 10
Source File: DefaultValueAxisEditor.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ @Override public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); ValueAxis valueAxis = (ValueAxis) axis; valueAxis.setAutoRange(this.autoRange); if (!this.autoRange) { valueAxis.setRange(this.minimumValue, this.maximumValue); } valueAxis.setAutoTickUnitSelection(this.autoTickUnitSelection); }
Example 11
Source File: DefaultValueAxisEditor.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ @Override public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); ValueAxis valueAxis = (ValueAxis) axis; valueAxis.setAutoRange(this.autoRange); if (!this.autoRange) { valueAxis.setRange(this.minimumValue, this.maximumValue); } valueAxis.setAutoTickUnitSelection(this.autoTickUnitSelection); }
Example 12
Source File: PolarPlotTest.java From openstock with GNU General Public License v3.0 | 4 votes |
@Test public void testTranslateToJava2D_NumberAxisAndMargin() { Rectangle2D dataArea = new Rectangle2D.Double(10.0, 10.0, 80.0, 80.0); ValueAxis axis = new NumberAxis(); axis.setRange(-2.0, 2.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(110.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(128.0, point.getX(), 0.5); assertEquals(128.0, point.getY(), 0.5); point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); assertEquals(-28.0, point.getX(), 0.5); assertEquals(128.0, point.getY(), 0.5); point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); assertEquals(-10.0, point.getX(), 0.5); assertEquals(-10.0, point.getY(), 0.5); point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); assertEquals(110.0, point.getX(), 0.5); assertEquals(-10.0, point.getY(), 0.5); point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); assertEquals(113.0, point.getX(), 0.5); assertEquals(74.0, point.getY(), 0.5); point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); assertEquals(7.0, point.getX(), 0.5); assertEquals(64.0, point.getY(), 0.5); }
Example 13
Source File: PolarPlotTest.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
@Test public void testTranslateToJava2D_NumberAxisAndMargin() { Rectangle2D dataArea = new Rectangle2D.Double(10.0, 10.0, 80.0, 80.0); ValueAxis axis = new NumberAxis(); axis.setRange(-2.0, 2.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(110.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(128.0, point.getX(), 0.5); assertEquals(128.0, point.getY(), 0.5); point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); assertEquals(-28.0, point.getX(), 0.5); assertEquals(128.0, point.getY(), 0.5); point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); assertEquals(-10.0, point.getX(), 0.5); assertEquals(-10.0, point.getY(), 0.5); point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); assertEquals(110.0, point.getX(), 0.5); assertEquals(-10.0, point.getY(), 0.5); point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); assertEquals(113.0, point.getX(), 0.5); assertEquals(74.0, point.getY(), 0.5); point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); assertEquals(7.0, point.getX(), 0.5); assertEquals(64.0, point.getY(), 0.5); }
Example 14
Source File: PolarPlotTest.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
@Test public void testTranslateToJava2D_NumberAxis() { Rectangle2D dataArea = new Rectangle2D.Double(0.0, 0.0, 100.0, 100.0); ValueAxis axis = new NumberAxis(); axis.setRange(0.0, 20.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setMargin(0); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(75.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(62.5, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(85.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); assertEquals(15.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); assertEquals(23.0, point.getX(), 0.5); assertEquals(23.0, point.getY(), 0.5); point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); assertEquals(77.0, point.getX(), 0.5); assertEquals(23.0, point.getY(), 0.5); point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); assertEquals(77.0, point.getX(), 0.5); assertEquals(60.0, point.getY(), 0.5); point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); assertEquals(33.0, point.getX(), 0.5); assertEquals(55.0, point.getY(), 0.5); }
Example 15
Source File: PolarPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
@Test public void testTranslateToJava2D_NumberAxis() { Rectangle2D dataArea = new Rectangle2D.Double(0.0, 0.0, 100.0, 100.0); ValueAxis axis = new NumberAxis(); axis.setRange(0.0, 20.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setMargin(0); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(75.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(62.5, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(85.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); assertEquals(15.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); assertEquals(23.0, point.getX(), 0.5); assertEquals(23.0, point.getY(), 0.5); point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); assertEquals(77.0, point.getX(), 0.5); assertEquals(23.0, point.getY(), 0.5); point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); assertEquals(77.0, point.getX(), 0.5); assertEquals(60.0, point.getY(), 0.5); point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); assertEquals(33.0, point.getX(), 0.5); assertEquals(55.0, point.getY(), 0.5); }
Example 16
Source File: AxisRangeControl.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
public void adjustAxis(ValueAxis axis, int numDecimalPlaces) { final double lowerRange = MathUtils.round((Double) getBindingContext().getBinding("min").getPropertyValue(), roundFactor(numDecimalPlaces)); final double upperRange = MathUtils.round((Double) getBindingContext().getBinding("max").getPropertyValue(), roundFactor(numDecimalPlaces)); axis.setRange(lowerRange, upperRange); }
Example 17
Source File: ChartLogics.java From old-mzmine3 with GNU General Public License v2.0 | 2 votes |
/** * Zoom into a chart panel * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void setZoomAxis(ValueAxis axis, Range zoom) { axis.setRange(zoom); }
Example 18
Source File: ChartLogicsFX.java From old-mzmine3 with GNU General Public License v2.0 | 2 votes |
/** * Zoom into a chart panel * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void setZoomAxis(ValueAxis axis, Range zoom) { axis.setRange(zoom); }
Example 19
Source File: ChartLogics.java From mzmine3 with GNU General Public License v2.0 | 2 votes |
/** * Zoom into a chart panel * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void setZoomAxis(ValueAxis axis, Range zoom) { axis.setRange(zoom); }
Example 20
Source File: ChartLogicsFX.java From mzmine2 with GNU General Public License v2.0 | 2 votes |
/** * Zoom into a chart panel * * @param myChart * @param zoom * @param autoRangeY if true the range (Y) axis auto bounds will be restored */ public static void setZoomAxis(ValueAxis axis, Range zoom) { axis.setRange(zoom); }