/** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ @Override public double getRangeUpperBound(boolean includeInterval) { double result = Double.NaN; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double hiY = series.getMaxY(); if (Double.isNaN(result)) { result = hiY; } else { if (!Double.isNaN(hiY)) { result = Math.max(result, hiY); } } } return result; }
/** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ public double getRangeUpperBound(boolean includeInterval) { double result = Double.NaN; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double hiY = series.getMaxY(); if (Double.isNaN(result)) { result = hiY; } else { if (!Double.isNaN(hiY)) { result = Math.max(result, hiY); } } } return result; }
lower = Math.min(lower, minY); double maxY = series.getMaxY(); if (!Double.isNaN(maxY)) { upper = Math.max(upper, maxY);
/** * Returns the range of the values in this dataset's range. * * @param includeInterval ignored. * * @return The range (or <code>null</code> if the dataset contains no * values). */ public Range getRangeBounds(boolean includeInterval) { double lower = Double.POSITIVE_INFINITY; double upper = Double.NEGATIVE_INFINITY; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double minY = series.getMinY(); if (!Double.isNaN(minY)) { lower = Math.min(lower, minY); } double maxY = series.getMaxY(); if (!Double.isNaN(maxY)) { upper = Math.max(upper, maxY); } } if (lower > upper) { return null; } else { return new Range(lower, upper); } }
public static void scaleChart(JFreeChart chart, XYSeries dSeries, boolean normalized) { XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(1.0); domainAxis.setUpperMargin(1.0); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (normalized) { domainAxis.setRange(-0.05, 1.05); } else { domainAxis.setRange(dSeries.getMinX() - 1, dSeries.getMaxX() + 1); } NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(-0.1 * Math.sqrt(dSeries.getMaxY()), dSeries.getMaxY() + 0.1 * Math.sqrt(dSeries.getMaxY())); }
private void startGui() { XYSeries series = new XYSeries("Rate", false); XYPlot plot = createChartFrame(series); ValueAxis xAxis = plot.getDomainAxis(); ValueAxis yAxis = plot.getRangeAxis(); xAxis.setRange(0, TIME_RANGE); yAxis.setRange(Y_RANGE_MIN, Y_RANGE_UPPER_INITIAL); long initialTimestamp = System.currentTimeMillis(); hzMap.addEntryListener((EntryAddedListener<Long, Double>) event -> { long x = event.getKey() - initialTimestamp; double y = event.getValue() / SCALE_Y; EventQueue.invokeLater(() -> { series.add(x, y); xAxis.setRange(max(0, x - TIME_RANGE), max(TIME_RANGE, x)); yAxis.setRange(Y_RANGE_MIN, max(series.getMaxY(), Y_RANGE_UPPER_INITIAL)); }); hzMap.remove(event.getKey()); }, true); }
System.out.println(seriesX.getMaxX() + "; " + seriesX.getMaxY());