List of usage examples for org.jfree.data Range getLowerBound
public double getLowerBound()
From source file:net.sf.mzmine.chartbasics.HistogramChartFactory.java
/** * //from w w w .j a va 2 s . c o m * @param data * @param yAxisLabel * @param width automatic width if parameter is <=0 * @return */ public static JFreeChart createHistogram(double[] data, String yAxisLabel, double width) { Range range = getBounds(data); return createHistogram(data, yAxisLabel, width, range.getLowerBound(), range.getUpperBound()); }
From source file:org.jfree.data.Range.java
/** * Returns a new range that spans both <code>range1</code> and * <code>range2</code>. This method has a special handling to ignore * Double.NaN values.//from w ww . j av a 2s .c o m * * @param range1 the first range (<code>null</code> permitted). * @param range2 the second range (<code>null</code> permitted). * * @return A new range (possibly <code>null</code>). * * @since 1.0.15 */ public static Range combineIgnoringNaN(Range range1, Range range2) { if (range1 == null) { if (range2 != null && range2.isNaNRange()) { return null; } return range2; } if (range2 == null) { if (range1.isNaNRange()) { return null; } return range1; } double l = min(range1.getLowerBound(), range2.getLowerBound()); double u = max(range1.getUpperBound(), range2.getUpperBound()); if (Double.isNaN(l) && Double.isNaN(u)) { return null; } return new Range(l, u); }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static double translateChartY(double chartY, Rectangle2D imageArea, JFreeChart chart) { XYPlot plot = chart.getXYPlot();//ww w . ja v a2 s. co m boolean isRangeInverted = plot.getRangeAxis().isInverted(); Range rangeSection = plot.getRangeAxis().getRange(); if (!isRangeInverted) { return imageArea.getMinY() + (rangeSection.getUpperBound() - chartY) / rangeSection.getLength() * imageArea.getHeight(); } else { return imageArea.getMinY() + (chartY - rangeSection.getLowerBound()) / rangeSection.getLength() * imageArea.getHeight(); } }
From source file:playground.thibautd.utils.charts.ChartsAxisUnifier.java
public void addChart(final JFreeChart chart) { charts.add(chart);/*from ww w . ja v a2s . co m*/ if (unifyX) { Plot plot = chart.getPlot(); if (plot instanceof XYPlot) { ValueAxis axis = chart.getXYPlot().getDomainAxis(); Range range = axis.getRange(); lowerX = Math.min(lowerX, range.getLowerBound()); upperX = Math.max(upperX, range.getUpperBound()); } } if (unifyY) { Plot plot = chart.getPlot(); ValueAxis axis; if (plot instanceof XYPlot) { axis = chart.getXYPlot().getRangeAxis(); } else if (plot instanceof CategoryPlot) { axis = chart.getCategoryPlot().getRangeAxis(); } else { return; } Range range = axis.getRange(); lowerY = Math.min(lowerY, range.getLowerBound()); upperY = Math.max(upperY, range.getUpperBound()); } }
From source file:peakml.util.jfreechart.LognAxis.java
@Override public double java2DToValue(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = log(range.getLowerBound()); double axisMax = log(range.getUpperBound()); double min = 0.0, max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getX();//w w w .j a va 2 s. co m max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } if (isInverted()) return pow(axisMax - ((java2DValue - min) / (max - min)) * (axisMax - axisMin)); else return pow(axisMin + ((java2DValue - min) / (max - min)) * (axisMax - axisMin)); }
From source file:peakml.util.jfreechart.LognAxis.java
@Override public double valueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = log(range.getLowerBound()); double axisMax = log(range.getUpperBound()); double min = 0.0, max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getMinX();//w ww . j a va 2 s . c o m max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } value = log(value); if (isInverted()) return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min)); else return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min)); }
From source file:org.jfree.data.xy.DefaultOHLCDatasetTest.java
/** * A small test for the data range calculated on this dataset. *//* ww w . j a v a2s . c om*/ @Test public void testDataRange() { OHLCDataItem[] data = new OHLCDataItem[3]; data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data); Range r = DatasetUtilities.findRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON); }
From source file:gda.plots.DataMagnifierWindow.java
/** * The SimplePlot will call this method when the Rectangle to be magnified has changed. * /*from w w w .j av a 2 s .c o m*/ * @param magnifyRectangle * the Rectangle to be magnified */ @Override public void update(Rectangle2D magnifyRectangle) { // The magnifyRectangle will be in Java coordinates, need to calculate // the axis limits required. This mechanism was copied from the zooming // methods within JFreeChart. double hLower = 0.0; double hUpper = 0.0; double vLower = 0.0; double vUpper = 0.0; double a; double b; Rectangle2D scaledDataArea; if (magnifyRectangle != null) { scaledDataArea = simplePlot.getScreenDataArea(); hLower = (magnifyRectangle.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); hUpper = (magnifyRectangle.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); vLower = (scaledDataArea.getMaxY() - magnifyRectangle.getMaxY()) / scaledDataArea.getHeight(); vUpper = (scaledDataArea.getMaxY() - magnifyRectangle.getMinY()) / scaledDataArea.getHeight(); Range r = simplePlot.getChart().getXYPlot().getDomainAxis().getRange(); a = r.getLowerBound() + hLower * r.getLength(); b = r.getLowerBound() + hUpper * r.getLength(); Range newR = new Range(Math.min(a, b), Math.max(a, b)); magnifiedPlot.getDomainAxis().setRange(newR); r = simplePlot.getChart().getXYPlot().getRangeAxis().getRange(); a = r.getLowerBound() + vLower * r.getLength(); b = r.getLowerBound() + vUpper * r.getLength(); newR = new Range(Math.min(a, b), Math.max(a, b)); magnifiedPlot.getRangeAxis().setRange(newR); repaint(); } }
From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java
/** * A small test for the data range calculated on this dataset. *///ww w. j a v a 2 s .c o m public void testDataRange() { OHLCDataItem[] data = new OHLCDataItem[3]; data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data); Range r = DatasetUtilities.findRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.ScalingLogarithmicAxis.java
public void autoAdjustRange() { super.autoAdjustRange(); if (getPlot() instanceof ValueAxisPlot) { final Range range = this.getRange(); setRange(new Range(range.getLowerBound() * 10.0, range.getUpperBound() * 10.0), false, false); setupSmallLogFlag();//from ww w . j a va2 s .c o m } }