SampledXYSeries implements FastXYSeries, OrderedXYSeries { protected static int getZoomIndex(double zoomFactor, double ratio) { final double lhs = Math.log(zoomFactor); final double rhs = Math.log(ratio); final double log = lhs / rhs; final int index = (int) Math.round(log); return index > 0 ? index - 1 : 0; } 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 testGetZoomIndex() throws Exception { assertEquals(0, SampledXYSeries.getZoomIndex(2, 2)); assertEquals(1, SampledXYSeries.getZoomIndex(3, 2)); assertEquals(1, SampledXYSeries.getZoomIndex(4, 2)); assertEquals(2, SampledXYSeries.getZoomIndex(8, 2)); assertEquals(2, SampledXYSeries.getZoomIndex(9, 2)); assertEquals(2, SampledXYSeries.getZoomIndex(10, 2)); assertEquals(3, SampledXYSeries.getZoomIndex(15, 2)); assertEquals(3, SampledXYSeries.getZoomIndex(16, 2)); assertEquals(3, SampledXYSeries.getZoomIndex(17, 2)); assertEquals(4, SampledXYSeries.getZoomIndex(31, 2)); assertEquals(4, SampledXYSeries.getZoomIndex(32, 2)); assertEquals(0, SampledXYSeries.getZoomIndex(1, 4)); assertEquals(0, SampledXYSeries.getZoomIndex(4, 4)); assertEquals(1, SampledXYSeries.getZoomIndex(15, 4)); assertEquals(1, SampledXYSeries.getZoomIndex(16, 4)); assertEquals(1, SampledXYSeries.getZoomIndex(17, 4)); assertEquals(2, SampledXYSeries.getZoomIndex(63, 4)); assertEquals(2, SampledXYSeries.getZoomIndex(64, 4)); assertEquals(2, SampledXYSeries.getZoomIndex(65, 4)); }