List of usage examples for org.jfree.data Range getUpperBound
public double getUpperBound()
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private void updateMaxRange() { ValueAxis x = chart.getXYPlot().getDomainAxis(); if (maxRange == 0) { x.setAutoRange(true);/*from w w w . j a v a2s .c o m*/ } else { Range dr = chart.getXYPlot().getDataRange(x); x.setRange(Math.max(dr.getLowerBound(), dr.getUpperBound() - maxRange * 60 * 1000), dr.getUpperBound()); } }
From source file:org.rdv.viz.dial.DialPanel.java
/** * Updates the dial range./*from w w w. j a v a2s . com*/ * * @param range the dial range */ private void updateRange() { Range range = model.getRange(); lowerBoundTextField.setText(engineeringFormat.format(model.getRange().getLowerBound())); upperBoundTextField.setText(engineeringFormat.format(model.getRange().getUpperBound())); dialScale.setLowerBound(range.getLowerBound()); dialScale.setUpperBound(range.getUpperBound()); double tickIncrement = range.getLength() / 10; dialScale.setMajorTickIncrement(tickIncrement); plot.addScale(0, dialScale); updateThresholdRanges(); }
From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java
/** * This method implements the graph zoom out functionality. *///from ww w . j a v a2 s .c om private void zoomOut() { Range r = timeAxis.getRange(); double low = r.getLowerBound(); double high = low + (r.getUpperBound() - low) * ZOOM_FACTOR; setTimeRange(low, high); }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Adjusts the axis range to match the data range that the axis is * required to display./*w ww.ja v a 2s . com*/ */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } double upper = r.getUpperBound(); double lower = r.getLowerBound(); double range = upper - lower; // if fixed auto range, then derive lower bound... double fixedAutoRange = getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = Math.max(upper - fixedAutoRange, this.smallestValue); } else { // ensure the autorange is at least <minRange> in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { double expand = (minRange - range) / 2; upper = upper + expand; lower = lower - expand; } // apply the margins - these should apply to the exponent range // upper = upper + getUpperMargin() * range; // lower = lower - getLowerMargin() * range; } setRange(new Range(lower, upper), false, false); } }
From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java
/** * This method implements the graph zoom in functionality. *///from ww w .j av a 2s . c o m private void zoomIn() { Range range = timeAxis.getRange(); double lowl = range.getLowerBound(); double high = lowl + (range.getUpperBound() - lowl) / ZOOM_FACTOR; setTimeRange(lowl, high); }
From source file:org.tsho.dmc2.core.chart.DmcLyapunovPlot.java
public void initializeVsParameter(VariableDoubles parameters, VariableDoubles initialValues, String parLabel, Range parameterRange, int iterations) { this.parameters.putAll(parameters); this.initialPoint.putAll(initialValues); this.firstParLabel = parLabel; this.lower = parameterRange.getLowerBound(); this.upper = parameterRange.getUpperBound(); this.iterations = iterations; this.type = VSPAR; }
From source file:de.bund.bfr.knime.nls.chart.ChartCreator.java
public JFreeChart createChart() throws ParseException { if (varX == null || varY == null) { return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, new XYPlot(), showLegend); }/*ww w . j a va 2 s . com*/ List<String> idsToPaint; if (selectAll) { idsToPaint = new ArrayList<>(plotables.keySet()); } else { idsToPaint = selectedIds; } NumberAxis xAxis = new NumberAxis(transformX.getName(varX)); NumberAxis yAxis = new NumberAxis(transformY.getName(varY)); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); double usedMinX = Double.POSITIVE_INFINITY; double usedMaxX = Double.NEGATIVE_INFINITY; int index = 0; List<Color> defaultColors = ChartUtils.createColorList(idsToPaint.size()); List<NamedShape> defaultShapes = ChartUtils.createShapeList(idsToPaint.size()); for (String id : idsToPaint) { Plotable plotable = plotables.get(id); if (plotable == null) { continue; } if (plotable.isDataType()) { double[][] points = plotable.getDataPoints(varX, varY, transformX, transformY); if (points != null) { for (int i = 0; i < points[0].length; i++) { usedMinX = Math.min(usedMinX, points[0][i]); usedMaxX = Math.max(usedMaxX, points[0][i]); } } } if (plotable.isParamType()) { double minArg = transformX.to(MathUtils.nullToNan(plotable.getMinValues().get(varX))); double maxArg = transformX.to(MathUtils.nullToNan(plotable.getMaxValues().get(varX))); if (Double.isFinite(minArg)) { usedMinX = Math.min(usedMinX, minArg); } if (Double.isFinite(maxArg)) { usedMaxX = Math.max(usedMaxX, maxArg); } } } if (!Double.isFinite(usedMinX)) { usedMinX = 0.0; } if (!Double.isFinite(usedMaxX)) { usedMaxX = 100.0; } xAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeIncludesZero(false); if (usedMinX == usedMaxX) { usedMinX -= 1.0; usedMaxX += 1.0; } if (useManualRange && minX < maxX && minY < maxY) { usedMinX = minX; usedMaxX = maxX; xAxis.setRange(new Range(minX, maxX)); yAxis.setRange(new Range(minY, maxY)); } for (String id : idsToPaint) { Plotable plotable = plotables.get(id); if (plotable == null) { continue; } plotable.setFunctionSteps(resolution); plotable.setInterpolator(interpolator); switch (plotable.getType()) { case DATA: plotData(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index)); break; case FUNCTION: plotFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DATA_FUNCTION: plotDataFunction(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DIFF: plotDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; case DATA_DIFF: plotDataDiff(plot, plotable, id, defaultColors.get(index), defaultShapes.get(index), usedMinX, usedMaxX); break; default: throw new RuntimeException("Unknown type of plotable: " + plotable.getType()); } index++; } if (minToZero && !useManualRange) { Range xRange = xAxis.getRange(); Range yRange = yAxis.getRange(); if (xRange.getUpperBound() <= 0.0 || yRange.getUpperBound() <= 0.0) { return null; } xAxis.setRange(new Range(0.0, xRange.getUpperBound())); yAxis.setRange(new Range(0.0, yRange.getUpperBound())); } return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); }
From source file:edu.wisc.ssec.mcidasv.control.McIDASVHistogramWrapper.java
/** * Assumes that {@code data} has been validated and is okay to actually try * loading.//from ww w. j a v a2 s .c o m * * @param data Data to use in histogram. Cannot be {@code null} or all NaNs. * * @throws VisADException * @throws RemoteException */ private void reallyLoadData(FlatField data) throws VisADException, RemoteException { createChart(); List dataChoiceWrappers = getDataChoiceWrappers(); try { clearHistogram(); Hashtable props = new Hashtable(); ErrorEstimate[] errOut = new ErrorEstimate[1]; for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx++) { DataChoiceWrapper wrapper = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx); DataChoice dataChoice = wrapper.getDataChoice(); props = dataChoice.getProperties(); Unit defaultUnit = ucar.visad.Util.getDefaultRangeUnits((FlatField) data)[0]; Unit unit = ((DisplayControlImpl) imageControl).getDisplayUnit(); double[][] samples = data.getValues(false); double[] actualValues = filterData(samples[0], getTimeValues(samples, data))[0]; if ((defaultUnit != null) && !defaultUnit.equals(unit)) { actualValues = Unit.transformUnits(unit, errOut, defaultUnit, null, actualValues); } final NumberAxis domainAxis = new NumberAxis(wrapper.getLabel(unit)); domainAxis.setAutoRangeIncludesZero(false); XYItemRenderer renderer; if (getStacked()) { renderer = new StackedXYBarRenderer(); } else { renderer = new XYBarRenderer(); } if ((plot == null) && (chartPanel != null)) { plot = chartPanel.getChart().getXYPlot(); } plot.setRenderer(paramIdx, renderer); Color c = wrapper.getColor(paramIdx); domainAxis.setLabelPaint(c); renderer.setSeriesPaint(0, c); MyHistogramDataset dataset = new MyHistogramDataset(); dataset.setType(HistogramType.FREQUENCY); dataset.addSeries(dataChoice.getName() + " [" + unit + ']', actualValues, getBins()); samples = null; actualValues = null; plot.setDomainAxis(paramIdx, domainAxis, false); plot.mapDatasetToDomainAxis(paramIdx, paramIdx); plot.setDataset(paramIdx, dataset); domainAxis.addChangeListener(new AxisChangeListener() { public void axisChanged(AxisChangeEvent ae) { if (!imageControl.isInitDone()) { return; } Range range = domainAxis.getRange(); double newLow = Math.floor(range.getLowerBound() + 0.5); double newHigh = Math.floor(range.getUpperBound() + 0.5); double prevLow = getLow(); double prevHigh = getHigh(); try { ucar.unidata.util.Range newRange; if (prevLow > prevHigh) { newRange = new ucar.unidata.util.Range(newHigh, newLow); } else { newRange = new ucar.unidata.util.Range(newLow, newHigh); } ((DisplayControlImpl) imageControl).setRange(newRange); } catch (Exception e) { logger.error("Cannot change range", e); } } }); Range range = domainAxis.getRange(); low = range.getLowerBound(); high = range.getUpperBound(); } } catch (Exception exc) { System.out.println("Exception exc=" + exc); LogUtil.logException("Error creating data set", exc); } }
From source file:net.sf.maltcms.chromaui.charts.format.ScaledNumberFormatter.java
/** * * @param cce//from ww w . java 2s.com */ @Override public void chartChanged(ChartChangeEvent cce) { ChartChangeEventType ccet = cce.getType(); if (ccet == ChartChangeEventType.DATASET_UPDATED || ccet == ChartChangeEventType.NEW_DATASET) { if (cce.getSource() != (this)) { Plot p = cce.getChart().getPlot(); if (p instanceof XYPlot) { XYPlot xyp = (XYPlot) p; Range axisRange = xyp.getRangeAxis().getRange(); ; if (relativeMode) { int cnt = xyp.getDatasetCount(); Range r = new Range(0, 1); for (int i = 0; i < cnt; i++) { Dataset d = xyp.getDataset(i); if (d != null && d instanceof XYDataset) { XYDataset xyd = (XYDataset) d; Range dr = DatasetUtilities.findRangeBounds(xyd); if (dr != null) { r = new Range(Math.min(r.getLowerBound(), dr.getLowerBound()), Math.max(r.getUpperBound(), dr.getUpperBound())); } } else { throw new NotImplementedException( "No support yet for dataset of type: " + d.getClass()); } } this.dataMin = Math.min(0, r.getLowerBound()); this.dataMax = r.getUpperBound(); cce.getChart().fireChartChanged(); } else { this.min = axisRange.getLowerBound(); this.max = axisRange.getUpperBound(); cce.getChart().fireChartChanged(); } } } } }
From source file:edu.dlnu.liuwenpeng.Time.TimeSeriesCollection.java
/** * Returns the maximum x-value in the dataset. * // www. j a v a2s . co m * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }