List of usage examples for org.jfree.data Range getLowerBound
public double getLowerBound()
From source file:org.jfree.data.time.TimePeriodValuesCollectionTest.java
/** * Some more checks for the getDomainBounds() method. * // www. j a va 2s . c om * @see #testGetDomainBoundsWithoutInterval() */ @Test public void testGetDomainBoundsWithInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Range r = dataset.getDomainBounds(true); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(2000.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(3000.0, r.getUpperBound(), EPSILON); // add a third time period s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(7000.0, r.getUpperBound(), EPSILON); // add a fourth time period s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(7000.0, r.getUpperBound(), EPSILON); }
From source file:org.jfree.data.contour.DefaultContourDataset.java
/** * Returns the maximum z-value within visible region of plot. * * @param x the x range./*w w w .ja va 2s.c o m*/ * @param y the y range. * * @return The z range. */ @Override public Range getZValueRange(Range x, Range y) { double minX = x.getLowerBound(); double minY = y.getLowerBound(); double maxX = x.getUpperBound(); double maxY = y.getUpperBound(); double zMin = 1.e20; double zMax = -1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.xValues[k].doubleValue() >= minX && this.xValues[k].doubleValue() <= maxX && this.yValues[k].doubleValue() >= minY && this.yValues[k].doubleValue() <= maxY) { if (this.zValues[k] != null) { zMin = Math.min(zMin, this.zValues[k].doubleValue()); zMax = Math.max(zMax, this.zValues[k].doubleValue()); } } } return new Range(zMin, zMax); }
From source file:org.tsho.dmc2.core.chart.CowebRenderer.java
private void animateCowebPlot(Graphics2D g2, Rectangle2D dataArea) { Graphics2D g2bisec = (Graphics2D) g2.create(); g2bisec.setColor(Color.blue); Stroke stroke = new BasicStroke(3f); Stroke origStroke = g2.getStroke(); Color color = Color.BLACK; g2blink = (Graphics2D) g2.create(); g2blink.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2blink.setXORMode(color);//from w w w.j ava 2s. co m g2blink.setStroke(stroke); if (plot.isAlpha()) { g2bisec.setComposite(AlphaComposite.SrcOver); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getForegroundAlpha())); } /* transients */ stepper.setInitialValue(initialValue); stepper.initialize(); state = STATE_TRANSIENTS; for (int index = 0; index < transients; index++) { stepper.step(); if (stopped) { state = STATE_STOPPED; return; } } state = STATE_RUNNING; Range xDataRange = plot.getDataRange(domainAxis); int transX, transY, transX1, transY1; transX = (int) this.domainAxis.valueToJava2D(xDataRange.getLowerBound(), dataArea, RectangleEdge.BOTTOM); transY = (int) this.rangeAxis.valueToJava2D(xDataRange.getLowerBound(), dataArea, RectangleEdge.LEFT); transX1 = (int) this.domainAxis.valueToJava2D(xDataRange.getUpperBound(), dataArea, RectangleEdge.BOTTOM); transY1 = (int) this.rangeAxis.valueToJava2D(xDataRange.getUpperBound(), dataArea, RectangleEdge.LEFT); g2bisec.drawLine(transX, transY, transX1, transY1); //renderer.reset(); recurseCoweb(g2, dataArea); }
From source file:org.jfree.data.xy.XYSeriesCollectionTest.java
/** * A test to cover bug 3445507. The issue does not affect * XYSeriesCollection.//from ww w . j a v a 2 s . c om */ @Test public void testBug3445507() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, null); s1.add(2.0, null); XYSeries s2 = new XYSeries("S2"); s1.add(1.0, 5.0); s1.add(2.0, 6.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); Range r = dataset.getRangeBounds(false); assertEquals(5.0, r.getLowerBound(), EPSILON); assertEquals(6.0, r.getUpperBound(), EPSILON); }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Converts a value on the axis scale to a Java2D coordinate relative to * the given <code>area</code>, based on the axis running along the * specified <code>edge</code>. * /*from w w w. ja v a 2 s . c o m*/ * @param value the data value. * @param area the area. * @param edge the edge. * * @return The Java2D coordinate corresponding to <code>value</code>. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); value = calculateLog(value); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMaxY(); } if (isInverted()) { return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); } else { return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); } }
From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java
/** * Returns the range of values the renderer requires to display all the * items from the specified dataset./* ww w .ja v a 2 s .c o m*/ * * @param dataset the dataset (<code>null</code> permitted). * * @return The range (<code>null</code> if the dataset is <code>null</code> * or empty). * * @see #findDomainBounds(XYDataset) */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtilities.findRangeBounds(dataset, false); if (r == null) { return null; } else { return new Range(r.getLowerBound() + this.yOffset, r.getUpperBound() + this.blockHeight + this.yOffset); } } else { return null; } }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Converts a Java2D coordinate to an axis value, assuming that the * axis covers the specified <code>edge</code> of the <code>area</code>. * /* w ww . ja va 2s. com*/ * @param java2DValue the Java2D coordinate. * @param area the area. * @param edge the edge that the axis belongs to. * * @return A value along the axis scale. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } double log = 0.0; if (isInverted()) { log = axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin); } else { log = axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin); } return calculateValue(log); }
From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java
/** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset.//ww w.ja v a2 s. co m * * @param dataset the dataset (<code>null</code> permitted). * * @return The range (<code>null</code> if the dataset is <code>null</code> * or empty). * * @see #findRangeBounds(XYDataset) */ @Override public Range findDomainBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtilities.findDomainBounds(dataset, false); if (r == null) { return null; } else { return new Range(r.getLowerBound() + this.xOffset, r.getUpperBound() + this.blockWidth + this.xOffset); } } else { return null; } }
From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java
public void initializeVsTime(VariableDoubles parameters, VariableDoubles initialValues, Range timeRange) { this.parameters.putAll(parameters); this.initialPoint.putAll(initialValues); this.lower = (int) timeRange.getLowerBound(); this.upper = (int) timeRange.getUpperBound(); this.type = VSTIME; }
From source file:org.jfree.data.time.TimeSeriesCollectionTest.java
/** * A test to cover bug 3445507./* ww w . j a v a2 s. c om*/ */ @Test public void testBug3445507() { TimeSeries s1 = new TimeSeries("S1"); s1.add(new Year(2011), null); s1.add(new Year(2012), null); TimeSeries s2 = new TimeSeries("S2"); s2.add(new Year(2011), 5.0); s2.add(new Year(2012), 6.0); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); List keys = new ArrayList(); keys.add("S1"); keys.add("S2"); Range r = dataset.getRangeBounds(keys, new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), false); assertEquals(5.0, r.getLowerBound(), EPSILON); assertEquals(6.0, r.getUpperBound(), EPSILON); }