Package com.sencha.gxt.core.client.util

Examples of com.sencha.gxt.core.client.util.PrecisePoint


          "v",
          new StringBuilder().append("m").append(Math.round(sprite.getX() * zoom)).append(",").append(
              Math.round((sprite.getY() + (height / 2.0)) * zoom)).append(" l").append(
              Math.round(sprite.getX() * zoom) + 1).append(",").append(
              Math.round((sprite.getY() + (height / 2.0)) * zoom)).toString());
      textRenderedPoints.put(sprite, new PrecisePoint(sprite.getX(), sprite.getY()));
      textRenderedBaseline.put(sprite, sprite.getTextBaseline());
    }
  }
View Full Code Here


  }

  public void calculateBounds() {
    PreciseRectangle chartBBox = chart.getBBox();
    ListStore<M> store = chart.getCurrentStore();
    min = new PrecisePoint(Double.NaN, Double.NaN);
    max = new PrecisePoint(Double.NaN, Double.NaN);
    scale = new PrecisePoint();

    bbox.setX(chartBBox.getX() + chart.getMaxGutter()[0]);
    bbox.setY(chartBBox.getY() + chart.getMaxGutter()[1]);
    bbox.setWidth(chartBBox.getWidth() - (chart.getMaxGutter()[0] * 2));
    bbox.setHeight(chartBBox.getHeight() - (chart.getMaxGutter()[1] * 2));

    Axis<M, ?> axis = chart.getAxis(yAxisPosition);
    if (axis != null) {
      if (axis.getPosition() == Position.TOP || axis.getPosition() == Position.BOTTOM) {
        min.setX(axis.getFrom());
        max.setX(axis.getTo());
      } else {
        min.setY(axis.getFrom());
        max.setY(axis.getTo());
      }
    } else if (yField != null) {
      NumericAxis<M> numAxis = new NumericAxis<M>();
      numAxis.setChart(chart);
      numAxis.addField(yField);
      numAxis.calcEnds();
      min.setY(numAxis.getFrom());
      max.setY(numAxis.getTo());
    }
    axis = chart.getAxis(xAxisPosition);
    if (axis != null) {
      if (axis.getPosition() == Position.TOP || axis.getPosition() == Position.BOTTOM) {
        min.setX(axis.getFrom());
        max.setX(axis.getTo());
      } else {
        min.setY(axis.getFrom());
        max.setY(axis.getTo());
      }
    } else if (xField != null) {
      NumericAxis<M> numAxis = new NumericAxis<M>();
      numAxis.setChart(chart);
      numAxis.addField(xField);
      numAxis.calcEnds();
      min.setX(numAxis.getFrom());
      max.setX(numAxis.getTo());
    }

    if (Double.isNaN(min.getX())) {
      min.setX(0);
      scale.setX(bbox.getWidth() / (store.size() - 1));
    } else {
      scale.setX(bbox.getWidth() / (max.getX() - min.getX()));
    }
    if (Double.isNaN(min.getY())) {
      min.setY(0);
      scale.setY(bbox.getHeight() / (store.size() - 1));
    } else {
      scale.setY(bbox.getHeight() / (max.getY() - min.getY()));
    }

    coordinates.clear();
    for (int i = 0; i < store.size(); i++) {
      M model = store.get(i);
      final double xValue;
      final double yValue;
      // Ensure a value
      if (xField == null) {
        xValue = i;
      } else if (xField.getValue(model) != null) {
        xValue = xField.getValue(model).doubleValue();
      } else {
        xValue = Double.NaN;
      }

      if (yField == null) {
        yValue = i;
      } else if (yField.getValue(model) != null) {
        yValue = yField.getValue(model).doubleValue();
      } else {
        yValue = Double.NaN;
      }

      double x = bbox.getX() + (xValue - min.getX()) * scale.getX();
      double y = bbox.getY() + bbox.getHeight() - (yValue - min.getY()) * scale.getY();
      if (!Double.isNaN(x) && !Double.isNaN(y)) {
        coordinates.put(i, new PrecisePoint(x, y));
      }
    }

    if (coordinates.size() > bbox.getWidth()) {
      coordinates = shrink(bbox.getWidth());
View Full Code Here

          } else {
            setLabelContrast(sprite, labelConfig, back);
          }
        }
        PreciseRectangle textBox = sprite.getBBox();
        PrecisePoint point = coordinates.get(i);
        if (point != null) {
          double x = coordinates.get(i).getX();
          double y = coordinates.get(i).getY();

          y -= textBox.getHeight() / 2.0;
View Full Code Here

        sprite.setTranslation((bbox.getX() + bbox.getWidth()) / 2, (bbox.getY() + bbox.getHeight()) / 2);
      }
      if (chart.hasShadows()) {
        drawShadows(i);
      }
      PrecisePoint point = coordinates.get(i);
      if (point != null) {
        double x = point.getX();
        double y = point.getY();
        if (chart.isAnimated()) {
          DrawFx.createTranslationAnimator(sprite, x, y).run(chart.getAnimationDuration(), chart.getAnimationEasing());
        } else {
          sprite.setTranslation(x, y);
          sprite.redraw();
View Full Code Here

        chart.addSprite(shadowSprite);
      }
      if (chart.isResizing()) {
        shadowSprite.setTranslation((bbox.getX() + bbox.getWidth()) / 2, (bbox.getY() + bbox.getHeight()) / 2);
      }
      PrecisePoint point = coordinates.get(i);
      if (point != null) {
        if (chart.isAnimated()) {
          DrawFx.createTranslationAnimator(shadowSprite, point.getX(), point.getY()).run(chart.getAnimationDuration(),
              chart.getAnimationEasing());
        } else {
          shadowSprite.setTranslation(point.getX(), point.getY());
          shadowSprite.redraw();
        }
      } else {
        shadowSprite.setHidden(true);
        shadowSprite.redraw();
View Full Code Here

  @Override
  protected int getIndex(PrecisePoint point) {
    for (int i = 0; i < sprites.size(); i++) {
      Translation trans = sprites.get(i).getTranslation();
      if (point.equalsNoPrecision(new PrecisePoint(trans.getX(), trans.getY()), selectionTolerance)) {
        return i;
      }
    }
    return -1;
  }
View Full Code Here

    double xSum = 0;
    double ySum = 0;
    final double ratio = Math.ceil(coordinates.size() / width);

    for (int i = 1; i < coordinates.size(); i++) {
      PrecisePoint point = coordinates.get(i);
      if (point != null) {
        xSum += point.getX();
        ySum += point.getY();
      }
      if (i % ratio == 0) {
        result.put(result.size(), new PrecisePoint(xSum / ratio, ySum / ratio));
        xSum = 0;
        ySum = 0;
      }
    }
    return result;
View Full Code Here

TOP

Related Classes of com.sencha.gxt.core.client.util.PrecisePoint

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.