Package plotter

Examples of plotter.DoubleData


  }


  private void appendPoints(StringBuffer b, PointData data) {
    b.append("[");
    DoubleData x = data.getX();
    DoubleData y = data.getY();
    int n = x.getLength();
    for(int i = 0; i < n; i++) {
      b.append("(");
      b.append(x.get(i));
      b.append(",");
      b.append(y.get(i));
      b.append(")");
      if(i < n - 1) {
        b.append(",");
      }
    }
View Full Code Here


    oldMaxY = maxY;
  }


  private void truncate() {
    DoubleData data = line.getIndependentDimension() == XYDimension.Y ? yData : xData;
    int length = data.getLength();
    // We assume here that not many points will be truncated, so a simple linear search is best.
    // If a large number of points may be truncated, a binary search may be better.
    int i = 0;
    while(i < length && data.get(i) < truncationPoint) {
      i++;
    }
    i -= truncationOffset;
    if(i > 0) {
      _removeFirst(i);
View Full Code Here

      input.getX().add(y, yoff, len);
    }
    PointData output = new PointData();
    compressor.compress(input, output, compressionOffset, compressionScale);

    DoubleData outx;
    DoubleData outy;
    if(independentDimension == XYDimension.X) {
      outx = output.getX();
      outy = output.getY();
    } else {
      outy = output.getX();
View Full Code Here

    PointData input = new PointData(x, y);
    PointData output = new PointData();
    compressor.compress(input, output, compressionOffset, compressionScale);

    DoubleData outx;
    DoubleData outy;
    XYDimension independentDimension = line.getIndependentDimension();
    if(independentDimension == XYDimension.X) {
      outx = output.getX();
      outy = output.getY();
    } else {
      outy = output.getX();
      outx = output.getY();
    }
    int length = outx.getLength();
    for(int i = 0; i < length; i++) {
      updateMinMax(outx.get(i), outy.get(i));
    }
    // TODO: Only add data that wouldn't be truncated
    line.prepend(outx, outy);

    postMod();
View Full Code Here

   * Recompresses the existing data.
   * This is useful if the compression scale has increased since data was added.
   * Data may lose fidelity if compressed multiple times.
   */
  public void recompress() {
    DoubleData newx =xData.clone();
    DoubleData newy =yData.clone();
    line.removeAllPoints();
    prepend(newx, newy);
  }
View Full Code Here

    double xscale = width / (xend - xstart);
    double yscale = height / (yend - ystart);
    int[] pointsx = new int[(n - i) * 2];
    int[] pointsy = new int[pointsx.length];

    DoubleData dependentData = independentDimension == XYDimension.Y ? xData : yData;
    // Loop through all the points to draw.
    outer: while(i < n - 1) {
      // Find the first non-NaN point.
      while(Double.isNaN(dependentData.get(i))) {
        i++;
        if(i == n) {
          break outer;
        }
      }
      int x = (int) ((xData.get(i) - xstart) * xscale + .5) - 1;
      int y = height - (int) ((yData.get(i) - ystart) * yscale + .5);
      int points = 0;
      if(missingPointMode == MissingPointMode.RIGHT || missingPointMode == MissingPointMode.BOTH) {
        if(i > 0 && i > index) {
          if(independentDimension == XYDimension.X) {
            pointsx[points] = (int) ((xData.get(i - 1) - xstart) * xscale + .5) - 1;
            pointsy[points] = y;
            points++;
          } else if(independentDimension == XYDimension.Y) {
            pointsy[points] = height - (int) ((yData.get(i - 1) - ystart) * yscale + .5);
            pointsx[points] = x;
            points++;
          }
        }
      }
      pointsx[points]=x;
      pointsy[points]=y;
      points++;
      i++;
      // Add points until we come to the end or a NaN point.
      while(i < n) {
        if(Double.isNaN(dependentData.get(i))) {
          if(missingPointMode == MissingPointMode.BOTH || missingPointMode == MissingPointMode.LEFT) {
            if(independentDimension == XYDimension.X) {
              double xd = xData.get(i);
              int x2 = (int) ((xd - xstart) * xscale + .5) - 1;
              pointsx[points] = x2;
View Full Code Here

    double[] newx = { 10, 11, 12, 13, 14 };
    double[] newy = { 10, 11, 12, 13, 14 };
    dataset.prepend(newx, 0, newy, 0, 5);

    assertEquals(10, dataset.getPointCount());
    DoubleData x = dataset.getXData();
    DoubleData y = dataset.getYData();
    assertEquals(10, x.getLength());
    assertEquals(10, y.getLength());
    assertEquals(10.0, x.get(0));
    assertEquals(10.0, y.get(0));
    assertEquals(4.0, x.get(9));
    assertEquals(4.0, y.get(9));
    assertEquals(0.0, dataset.getMinX());
    assertEquals(14.0, dataset.getMaxX());
    assertEquals(0.0, dataset.getMinY());
    assertEquals(14.0, dataset.getMaxY());
  }
View Full Code Here

    dataset.add(3, 3);
    assertEquals(5, dataset.getPointCount());

    dataset.add(5, 5);
    assertEquals(5, dataset.getPointCount());
    DoubleData x = dataset.getXData();
    DoubleData y = dataset.getYData();
    assertEquals(5, x.getLength());
    assertEquals(5, y.getLength());
    assertEquals(1.0, x.get(0));
    assertEquals(1.0, y.get(0));
    assertEquals(5.0, x.get(4));
    assertEquals(5.0, y.get(4));
    assertEquals(0.0, dataset.getMinX());
    assertEquals(5.0, dataset.getMaxX());
    assertEquals(0.0, dataset.getMinY());
    assertEquals(5.0, dataset.getMaxY());
  }
View Full Code Here

    dataset.add(4, 4);
    assertEquals(5, dataset.getPointCount());

    dataset.add(5, 5);
    assertEquals(5, dataset.getPointCount());
    DoubleData x = dataset.getXData();
    DoubleData y = dataset.getYData();
    assertEquals(5, x.getLength());
    assertEquals(5, y.getLength());
    assertEquals(1.0, x.get(0));
    assertEquals(1.0, y.get(0));
    assertEquals(5.0, x.get(4));
    assertEquals(5.0, y.get(4));
    assertEquals(1.0, dataset.getMinX());
    assertEquals(5.0, dataset.getMaxX());
    assertEquals(1.0, dataset.getMinY());
    assertEquals(5.0, dataset.getMaxY());
  }
View Full Code Here

    d.add(1, 2);
    assertEquals(1, d.getPointCount());
    assertEquals(1, points.size());
    assertEquals(new Point2D.Double(2, 1), points.get(0));

    DoubleData xData = new DoubleDataDouble();
    DoubleData yData = new DoubleDataDouble();
    xData.add(2);
    yData.add(3);
    xData.add(3);
    yData.add(4);
    d.prepend(xData, yData);
    assertEquals(3, d.getPointCount());
    assertEquals(3, points.size());
    assertEquals(new Point2D.Double(4, 3), points.get(0));
    assertEquals(new Point2D.Double(3, 2), points.get(1));
View Full Code Here

TOP

Related Classes of plotter.DoubleData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.