SampledXYSeries implements FastXYSeries, OrderedXYSeries { public void setZoomFactor(double factor) { if(factor <= 1) { activeSeries = rawData; } else { int i = getZoomIndex(factor, getRatio()); if (i < zoomLevels.size()) { activeSeries = zoomLevels.get(i); } else { activeSeries = zoomLevels.get(zoomLevels.size() - 1); } } } SampledXYSeries(XYSeries rawData, XOrder xOrder, float ratio, int threshold);  SampledXYSeries(XYSeries rawData, float ratio, int threshold); void resample(); void setZoomFactor(double factor); double getMaxZoomFactor(); Sampler getAlgorithm(); void setAlgorithm(Sampler algorithm); @Override String getTitle(); @Override int size(); @Override Number getX(int index); @Override Number getY(int index); int getThreshold(); void setThreshold(int threshold); RectRegion getBounds(); void setBounds(RectRegion bounds); @Override RectRegion minMax(); @Override XOrder getXOrder(); float getRatio(); void setRatio(float ratio);  }
@Test public void testSetZoomFactor() throws Exception { XYSeries rawData = TestUtils.generateXYSeries("my series", 2000); SampledXYSeries sampledXYSeries = spy(new SampledXYSeries(rawData, 2, 100)); sampledXYSeries.setZoomFactor(2); assertEquals(1000, sampledXYSeries.size()); sampledXYSeries.setZoomFactor(4); assertEquals(500, sampledXYSeries.size()); sampledXYSeries.setZoomFactor(8); assertEquals(250, sampledXYSeries.size()); sampledXYSeries.setZoomFactor(16); assertEquals(125, sampledXYSeries.size()); }