NormedXYSeries implements XYSeries { @Override public Number getY(int index) { final Number yVal = rawData.getY(index); if(yVal != null && transformY != null) { return minMaxY.transform(yVal.doubleValue(), transformY); } return yVal; } NormedXYSeries(XYSeries rawData);  NormedXYSeries(XYSeries rawData, Norm x, Norm y); @Override String getTitle(); @Override int size(); Number denormalizeXVal(Number xVal); Number denormalizeYVal(Number yVal); @Override Number getX(int index); @Override Number getY(int index);  }
@Test public void testConstructor_withNoOffset() { XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); NormedXYSeries normedData = new NormedXYSeries(rawData, new NormedXYSeries.Norm(null), new NormedXYSeries.Norm(null)); assertEquals(0d, normedData.getY(0).doubleValue(), DELTA); assertEquals(0.2d, normedData.getY(1).doubleValue(), DELTA); assertEquals(0.4d, normedData.getY(2).doubleValue(), DELTA); assertEquals(0.6d, normedData.getY(3).doubleValue(), DELTA); assertEquals(0.8d, normedData.getY(4).doubleValue(), DELTA); assertEquals(1.0d, normedData.getY(5).doubleValue(), DELTA); }
@Test public void testConstructor_withNullYVals() { XYSeries rawData = new SimpleXYSeries( SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, null, 4, null, 8, 10); NormedXYSeries normedData = new NormedXYSeries(rawData, new NormedXYSeries.Norm(null), new NormedXYSeries.Norm(null)); assertEquals(0d, normedData.getY(0).doubleValue(), DELTA); assertEquals(0.4d, normedData.getY(2).doubleValue(), DELTA); assertEquals(0.8d, normedData.getY(4).doubleValue(), DELTA); assertEquals(1.0d, normedData.getY(5).doubleValue(), DELTA); }
@Test public void testConstructor_withPositiveOffsetAndOffsetCompression() { XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); NormedXYSeries normedData = new NormedXYSeries(rawData, new NormedXYSeries.Norm(null, 0.5, true), new NormedXYSeries.Norm(null, 0.5, true)); assertEquals(0.5d, normedData.getY(0).doubleValue(), DELTA); assertEquals(0.6d, normedData.getY(1).doubleValue(), DELTA); assertEquals(1.0d, normedData.getY(5).doubleValue(), DELTA); }
@Test public void testConstructor_withNegativeOffsetAndOffsetCompression() { XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); NormedXYSeries normedData = new NormedXYSeries(rawData, new NormedXYSeries.Norm(null, -0.5, true), new NormedXYSeries.Norm(null, -0.5, true)); assertEquals(0d, normedData.getY(0).doubleValue(), DELTA); assertEquals(0.1d, normedData.getY(1).doubleValue(), DELTA); assertEquals(0.2d, normedData.getY(2).doubleValue(), DELTA); assertEquals(0.5d, normedData.getY(5).doubleValue(), DELTA); }
@Test public void testConstructor_withOffsetAndNoOffsetCompression() { XYSeries rawData = new SimpleXYSeries(SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "s1", 0, 2, 4, 6, 8, 10); NormedXYSeries normedData = new NormedXYSeries(rawData, new NormedXYSeries.Norm(null, 0.5, false), new NormedXYSeries.Norm(null, 0.5, false)); assertEquals(0.5d, normedData.getY(0).doubleValue(), DELTA); assertEquals(0.7d, normedData.getY(1).doubleValue(), DELTA); assertEquals(1.5d, normedData.getY(5).doubleValue(), DELTA); }