List of usage examples for org.jfree.data Range getUpperBound
public double getUpperBound()
From source file:net.sf.mzmine.chartbasics.HistogramChartFactory.java
/** * /*from w w w . ja 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.//w w w .jav a 2 s . co 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:net.sourceforge.processdash.ui.lib.chart.DiscLegendAxis.java
@Override protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { // the font used to display tick marks requires labels to be placed // at least this far apart. double tickLabelHeight = estimateMaximumTickLabelHeight(g2); // our tick marks get closer together as the values get larger. So // if we have a collision, it would be at the very top end of the // axis. We want to calculate a tick unit that will avoid that // collision. So first, we will find the pixel position of a // hypothetical tick mark drawn for the largest domain value. Range r = getRange(); double maxValue = r.getUpperBound(); double maxY = valueToJava2D(maxValue, dataArea, edge); // So far, we've identified a hypothetical tick mark placed at the // highest known domain value. If we drew another tick mark just // underneath it (one tick label height away), what domain value would // that hypothetical second-to-largest tick mark represent? double nextY = maxY + tickLabelHeight; double nextValue = java2DToValue(nextY, dataArea, edge); // calculate the numerical difference between these two domain values. // Then pick the tick unit that is larger, to avoid collisions. double amountBetweenTicks = maxValue - nextValue; NumberTickUnit unit = (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(amountBetweenTicks); setTickUnit(unit, false, false);//from w w w .j a v a2s . com }
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();//from ww w.j av a2 s . c om 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();/*from ww w .ja v a2s.com*/ 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:playground.thibautd.utils.charts.ChartsAxisUnifier.java
public void addChart(final JFreeChart chart) { charts.add(chart);//from ww w .j a va2 s . com 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:com.hmsinc.epicenter.webapp.chart.SNColumnArrangement.java
/** * Calculates and sets the bounds of all the items in the specified * container, subject to the given constraint. The <code>Graphics2D</code> * can be used by some items (particularly items containing text) to * calculate sizing parameters./*from ww w .j a va 2 s .co m*/ * * @param container * the container whose items are being arranged. * @param g2 * the graphics device. * @param constraint * the size constraint. * * @return The size of the container after arrangement of the contents. */ @SuppressWarnings("unchecked") public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { List<Block> blocks = container.getBlocks(); // calculate max width of entries double maxWidth = 0.0; double maxHeight = 0.0; for (Block block : blocks) { Size2D size = block.arrange(g2, RectangleConstraint.NONE); maxWidth = Math.max(maxWidth, size.width + this.horizontalGap); maxHeight = Math.max(maxHeight, size.height + this.verticalGap); } // calculate number of columns double width = 0.0; if (constraint.getWidthConstraintType() == LengthConstraintType.FIXED) { width = constraint.getWidth(); } else if (constraint.getWidthConstraintType() == LengthConstraintType.RANGE) { Range range = constraint.getWidthRange(); width = range.getUpperBound(); } else { throw new RuntimeException("Not implemented."); } int columns = (int) (Math.floor(width / maxWidth)); if (columns > 0) { columns--; } // for all columns int colx = -1; int coly = 0; for (Block block : blocks) { Size2D size = block.arrange(g2, RectangleConstraint.NONE); if (colx < columns) { colx++; } else { colx = 0; coly++; } double x = colx * maxWidth; double y = coly * maxHeight; block.setBounds(new Rectangle2D.Double(x, y, size.width, size.height)); } // calculate size of bounding double bWidth = (coly == 0) ? (colx + 1) * maxWidth : (columns + 1) * maxWidth; double bHeight = (coly + 1) * maxHeight; return new Size2D(bWidth, bHeight); }
From source file:org.jfree.data.xy.DefaultOHLCDatasetTest.java
/** * A small test for the data range calculated on this dataset. *//*from w w w .j a v a 2 s. co m*/ @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:ec.ui.view.res.ResidualsView.java
private double calcTick(Range rng) { double tick = 0; double avg = (rng.getUpperBound() - rng.getLowerBound()) / 6; for (int i = 0; i < 10 && tick == 0; i++) { double power = Math.pow(10, i); if (avg > (0.01 * power) && avg <= (0.02 * power)) { tick = (0.02 * power);//from www . j ava 2 s .c om } else if (avg > (0.02 * power) && avg <= (0.05 * power)) { tick = (0.05 * power); } else if (avg > (0.05 * power) && avg <= (0.1 * power)) { tick = (0.1 * power); } } return tick; }
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 . ja va2 s . c o m*/ } }