test_class.file: androidplot-core/src/test/java/com/androidplot/xy/SampledXYSeriesTest.java
test_class.identifier: SampledXYSeriesTest
test_class.superclass: extends AndroidplotTest
test_case.body: @Test
      public void testResample() {
          XYSeries rawData = TestUtils.generateXYSeries("my series", 10000);
          SampledXYSeries sampledXYSeries = new SampledXYSeries(rawData, 2, 200);
          assertEquals(5, sampledXYSeries.getZoomLevels().size());
      }
test_case.class_method_signature: SampledXYSeriesTest.testResample()
test_case.full_signature: @Test public void testResample()
test_case.identifier: testResample
test_case.invocations: generateXYSeries assertEquals size getZoomLevels
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testResample()
focal_class.declarator: threshold
focal_class.modifier: private
focal_class.original_string: private int threshold;
focal_class.type: int
focal_class.var_name: threshold
focal_class.declarator: algorithm = new LTTBSampler()
focal_class.modifier: private
focal_class.original_string: private Sampler algorithm = new LTTBSampler();
focal_class.type: Sampler
focal_class.var_name: algorithm
focal_class.declarator: rawData
focal_class.modifier: private
focal_class.original_string: private XYSeries rawData;
focal_class.type: XYSeries
focal_class.var_name: rawData
focal_class.declarator: zoomLevels
focal_class.modifier: private
focal_class.original_string: private List<EditableXYSeries> zoomLevels;
focal_class.type: List<EditableXYSeries>
focal_class.var_name: zoomLevels
focal_class.declarator: activeSeries
focal_class.modifier: private
focal_class.original_string: private XYSeries activeSeries;
focal_class.type: XYSeries
focal_class.var_name: activeSeries
focal_class.declarator: bounds
focal_class.modifier: private
focal_class.original_string: private RectRegion bounds;
focal_class.type: RectRegion
focal_class.var_name: bounds
focal_class.declarator: lastResamplingException
focal_class.modifier: private
focal_class.original_string: private Exception lastResamplingException;
focal_class.type: Exception
focal_class.var_name: lastResamplingException
focal_class.declarator: xOrder
focal_class.modifier: private final
focal_class.original_string: private final XOrder xOrder;
focal_class.type: XOrder
focal_class.var_name: xOrder
focal_class.declarator: ratio
focal_class.modifier: private
focal_class.original_string: private float ratio;
focal_class.type: float
focal_class.var_name: ratio
focal_class.file: androidplot-core/src/main/java/com/androidplot/xy/SampledXYSeries.java
focal_class.identifier: SampledXYSeries
focal_class.interfaces: implements FastXYSeries, OrderedXYSeries
focal_class.class_method_signature: SampledXYSeries.SampledXYSeries(XYSeries rawData, XOrder xOrder, float ratio, int threshold)
focal_class.full_signature: public  SampledXYSeries(XYSeries rawData, XOrder xOrder, float ratio, int threshold)
focal_class.identifier: SampledXYSeries
focal_class.modifiers: public
focal_class.parameters: (XYSeries rawData, XOrder xOrder, float ratio, int threshold)
focal_class.signature:  SampledXYSeries(XYSeries rawData, XOrder xOrder, float ratio, int threshold)
focal_class.class_method_signature: SampledXYSeries.SampledXYSeries(XYSeries rawData, float ratio, int threshold)
focal_class.full_signature: public  SampledXYSeries(XYSeries rawData, float ratio, int threshold)
focal_class.identifier: SampledXYSeries
focal_class.modifiers: public
focal_class.parameters: (XYSeries rawData, float ratio, int threshold)
focal_class.signature:  SampledXYSeries(XYSeries rawData, float ratio, int threshold)
focal_class.class_method_signature: SampledXYSeries.resample()
focal_class.full_signature: public void resample()
focal_class.identifier: resample
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void resample()
focal_class.class_method_signature: SampledXYSeries.getZoomLevels()
focal_class.full_signature: protected List<EditableXYSeries> getZoomLevels()
focal_class.identifier: getZoomLevels
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: List<EditableXYSeries>
focal_class.signature: List<EditableXYSeries> getZoomLevels()
focal_class.class_method_signature: SampledXYSeries.setZoomFactor(double factor)
focal_class.full_signature: public void setZoomFactor(double factor)
focal_class.identifier: setZoomFactor
focal_class.modifiers: public
focal_class.parameters: (double factor)
focal_class.return: void
focal_class.signature: void setZoomFactor(double factor)
focal_class.class_method_signature: SampledXYSeries.getZoomIndex(double zoomFactor, double ratio)
focal_class.full_signature: protected static int getZoomIndex(double zoomFactor, double ratio)
focal_class.identifier: getZoomIndex
focal_class.modifiers: protected static
focal_class.parameters: (double zoomFactor, double ratio)
focal_class.return: int
focal_class.signature: int getZoomIndex(double zoomFactor, double ratio)
focal_class.class_method_signature: SampledXYSeries.getMaxZoomFactor()
focal_class.full_signature: public double getMaxZoomFactor()
focal_class.identifier: getMaxZoomFactor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getMaxZoomFactor()
focal_class.class_method_signature: SampledXYSeries.getAlgorithm()
focal_class.full_signature: public Sampler getAlgorithm()
focal_class.identifier: getAlgorithm
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Sampler
focal_class.signature: Sampler getAlgorithm()
focal_class.class_method_signature: SampledXYSeries.setAlgorithm(Sampler algorithm)
focal_class.full_signature: public void setAlgorithm(Sampler algorithm)
focal_class.identifier: setAlgorithm
focal_class.modifiers: public
focal_class.parameters: (Sampler algorithm)
focal_class.return: void
focal_class.signature: void setAlgorithm(Sampler algorithm)
focal_class.class_method_signature: SampledXYSeries.getTitle()
focal_class.full_signature: @Override public String getTitle()
focal_class.identifier: getTitle
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getTitle()
focal_class.class_method_signature: SampledXYSeries.size()
focal_class.full_signature: @Override public int size()
focal_class.identifier: size
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_class.class_method_signature: SampledXYSeries.getX(int index)
focal_class.full_signature: @Override public Number getX(int index)
focal_class.identifier: getX
focal_class.modifiers: @Override public
focal_class.parameters: (int index)
focal_class.return: Number
focal_class.signature: Number getX(int index)
focal_class.class_method_signature: SampledXYSeries.getY(int index)
focal_class.full_signature: @Override public Number getY(int index)
focal_class.identifier: getY
focal_class.modifiers: @Override public
focal_class.parameters: (int index)
focal_class.return: Number
focal_class.signature: Number getY(int index)
focal_class.class_method_signature: SampledXYSeries.getThreshold()
focal_class.full_signature: public int getThreshold()
focal_class.identifier: getThreshold
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getThreshold()
focal_class.class_method_signature: SampledXYSeries.setThreshold(int threshold)
focal_class.full_signature: public void setThreshold(int threshold)
focal_class.identifier: setThreshold
focal_class.modifiers: public
focal_class.parameters: (int threshold)
focal_class.return: void
focal_class.signature: void setThreshold(int threshold)
focal_class.class_method_signature: SampledXYSeries.getBounds()
focal_class.full_signature: public RectRegion getBounds()
focal_class.identifier: getBounds
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: RectRegion
focal_class.signature: RectRegion getBounds()
focal_class.class_method_signature: SampledXYSeries.setBounds(RectRegion bounds)
focal_class.full_signature: public void setBounds(RectRegion bounds)
focal_class.identifier: setBounds
focal_class.modifiers: public
focal_class.parameters: (RectRegion bounds)
focal_class.return: void
focal_class.signature: void setBounds(RectRegion bounds)
focal_class.class_method_signature: SampledXYSeries.minMax()
focal_class.full_signature: @Override public RectRegion minMax()
focal_class.identifier: minMax
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: RectRegion
focal_class.signature: RectRegion minMax()
focal_class.class_method_signature: SampledXYSeries.getXOrder()
focal_class.full_signature: @Override public XOrder getXOrder()
focal_class.identifier: getXOrder
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: XOrder
focal_class.signature: XOrder getXOrder()
focal_class.class_method_signature: SampledXYSeries.getRatio()
focal_class.full_signature: public float getRatio()
focal_class.identifier: getRatio
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: float
focal_class.signature: float getRatio()
focal_class.class_method_signature: SampledXYSeries.setRatio(float ratio)
focal_class.full_signature: public void setRatio(float ratio)
focal_class.identifier: setRatio
focal_class.modifiers: public
focal_class.parameters: (float ratio)
focal_class.return: void
focal_class.signature: void setRatio(float ratio)
focal_method.body: public void resample() {
          bounds = null;
          zoomLevels = new ArrayList<>();
          int t = (int) Math.ceil(rawData.size() / getRatio());
          List<Thread> threads = new ArrayList<>(zoomLevels.size());
          while (t > threshold) {
              final int thisThreshold = t;
              final EditableXYSeries thisSeries = new FixedSizeEditableXYSeries(getTitle(), thisThreshold);
              Thread thread = new Thread(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          // TODO: make bounds a param to prevent calculating on each setZoomFactor level:
                          RectRegion b = getAlgorithm()
                                  .run(rawData, thisSeries);
                          if (bounds == null) {
                              bounds = b;
                          }
                      } catch(Exception ex) {
                          lastResamplingException = ex;
                      }
                  }
              }, "Androidplot XY Series Sampler");
              getZoomLevels().add(thisSeries);
              threads.add(thread);
              thread.start();
  
              t = (int) Math.ceil(t / getRatio());
          }
          for(Thread thread : threads) {
              try {
                  thread.join();
              } catch (InterruptedException e) {
                  throw new RuntimeException(e);
              }
          }
          if(lastResamplingException != null) {
              throw new RuntimeException("Exception encountered during resampling", lastResamplingException);
          }
  
      }
focal_method.class_method_signature: SampledXYSeries.resample()
focal_method.full_signature: public void resample()
focal_method.identifier: resample
focal_method.invocations: ceil size getRatio size getTitle run getAlgorithm add getZoomLevels add start ceil getRatio join
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void resample()