SeriesUtils { public static RectRegion minMax(List<XYSeries> seriesList) { return minMax(null, seriesList); }  static RectRegion minMax(List<XYSeries> seriesList); static RectRegion minMax(XYSeries... seriesList); static Region minMaxX(XYSeries... seriesList); static Region minMaxY(XYSeries... seriesList); static RectRegion minMax(XYConstraints constraints, List<XYSeries> seriesList); static RectRegion minMax(XYConstraints constraints, XYSeries... seriesArray); static Region minMax(Region bounds, List<Number>... lists); static Region iBounds(XYSeries series, RectRegion visibleBounds); static Region minMax(List<Number>... lists); static OrderedXYSeries.XOrder getXYOrder(XYSeries series);  }
@Test public void minMax_onSimpleXYSeries_calculatesExpectedRegion() { SimpleXYSeries series = new SimpleXYSeries(LINEAR, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); RectRegion minMax = SeriesUtils.minMax(series); assertEquals(0, minMax.getMinX().doubleValue(), 0); assertEquals(7, minMax.getMaxX().doubleValue(), 0); assertEquals(1, minMax.getMinY().doubleValue(), 0); assertEquals(8, minMax.getMaxY().doubleValue(), 0); series = new SimpleXYSeries(LINEAR_INVERSE, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); minMax = SeriesUtils.minMax(series); assertEquals(0, minMax.getMinX().doubleValue(), 0); assertEquals(7, minMax.getMaxX().doubleValue(), 0); assertEquals(1, minMax.getMinY().doubleValue(), 0); assertEquals(8, minMax.getMaxY().doubleValue(), 0); series = new SimpleXYSeries(ZIG_ZAG, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); minMax = SeriesUtils.minMax(series); assertEquals(0, minMax.getMinX().doubleValue(), 0); assertEquals(7, minMax.getMaxX().doubleValue(), 0); assertEquals(1, minMax.getMinY().doubleValue(), 0); assertEquals(10, minMax.getMaxY().doubleValue(), 0); series = new SimpleXYSeries(NULLS, NULLS, null); minMax = SeriesUtils.minMax(series); assertEquals(-1, minMax.getMinX().doubleValue(), 0); assertEquals(4, minMax.getMaxX().doubleValue(), 0); assertEquals(-1, minMax.getMinY().doubleValue(), 0); assertEquals(4, minMax.getMaxY().doubleValue(), 0); series = new SimpleXYSeries(SINGLE_VALUE, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); minMax = SeriesUtils.minMax(series); assertEquals(0, minMax.getMinX().doubleValue(), 0); assertEquals(0, minMax.getMaxX().doubleValue(), 0); assertEquals(3, minMax.getMinY().doubleValue(), 0); assertEquals(3, minMax.getMaxY().doubleValue(), 0); series = new SimpleXYSeries(SINGLE_VALUE_NULL, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); minMax = SeriesUtils.minMax(series); assertEquals(0, minMax.getMinX().doubleValue(), 0); assertEquals(0, minMax.getMaxX().doubleValue(), 0); assertEquals(null, minMax.getMinY()); assertEquals(null, minMax.getMaxY()); series = new SimpleXYSeries(EMPTY, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, null); minMax = SeriesUtils.minMax(series); assertEquals(null, minMax.getMinX()); assertEquals(null, minMax.getMaxX()); assertEquals(null, minMax.getMinY()); assertEquals(null, minMax.getMaxY()); }
@Test public void minMax_onFastXYSeries_usesSeriesMinMax() { FastXYSeries series = mock(FastXYSeries.class); SeriesUtils.minMax(series); verify(series).minMax(); }
@Test public void minMax_calculatesExpectedRegion_onFastXYSeriesWithLayoutConstraints() { FastXYSeries series = new FastXYSeries() { final ArrayList<Integer> times = new ArrayList<>(); final ArrayList<Integer> values = new ArrayList<>(); { for (int i = 0; i < 10; i++) { times.add(i); values.add(i); } } @Override public int size() { return times.size(); } @Override public Number getX(int index) { return times.get(index); } @Override public Number getY(int index) { return values.get(index); } @Override public String getTitle() { return "Isaac's crazy thing"; } @Override public RectRegion minMax() { return new RectRegion(0, 10, 0, 10); } }; final XYConstraints constraints = new XYConstraints(); constraints.setDomainLowerBoundaryMode(BoundaryMode.FIXED); constraints.setDomainUpperBoundaryMode(BoundaryMode.FIXED); constraints.setMinX(5); constraints.setMaxX(9); final RectRegion result = SeriesUtils.minMax(constraints, series); assertEquals(5d, result.getMinX().doubleValue()); assertEquals(9d, result.getMaxX().doubleValue()); assertEquals(5d, result.getMinY().doubleValue()); assertEquals(9d, result.getMaxY().doubleValue()); }
@Test public void minMax_onSeriesList_producesAggregateResult() { Region minMax = SeriesUtils.minMax(LINEAR); assertEquals(1, minMax.getMin().doubleValue(), 0); assertEquals(8, minMax.getMax().doubleValue(), 0); minMax = SeriesUtils.minMax(LINEAR_INVERSE); assertEquals(1, minMax.getMin().doubleValue(), 0); assertEquals(8, minMax.getMax().doubleValue(), 0); minMax = SeriesUtils.minMax(ZIG_ZAG); assertEquals(1, minMax.getMin().doubleValue(), 0); assertEquals(10, minMax.getMax().doubleValue(), 0); minMax = SeriesUtils.minMax(NULLS); assertEquals(-1, minMax.getMin().doubleValue(), 0); assertEquals(4, minMax.getMax().doubleValue(), 0); minMax = SeriesUtils.minMax(SINGLE_VALUE); assertEquals(3, minMax.getMin().doubleValue(), 0); assertEquals(3, minMax.getMax().doubleValue(), 0); minMax = SeriesUtils.minMax(SINGLE_VALUE_NULL); assertEquals(null, minMax.getMin()); assertEquals(null, minMax.getMax()); minMax = SeriesUtils.minMax(EMPTY); assertEquals(null, minMax.getMin()); assertEquals(null, minMax.getMax()); }