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

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


  @Override
  public void highlight(int yFieldIndex) {
    if (highlightLine != null) {
      if (lineBottom == null) {
        lineBottom = new PrecisePoint(lineTop.getX(), bbox.getY() + bbox.getHeight());
      }
      highlightLine.clearCommands();
      highlightLine.addCommand(new MoveTo(lineTop.getX(), lineTop.getY()));
      highlightLine.addCommand(new LineTo(lineBottom.getX(), lineBottom.getY()));
      highlightLine.setHidden(false);
View Full Code Here


      }
      double dist = Double.POSITIVE_INFINITY;
      ArrayList<PrecisePoint> pointsUp = this.pointsUp.get(i);
      ArrayList<PrecisePoint> pointsDown = this.pointsDown.get(i);
      for (int p = 0; p < pointsUp.size(); p++) {
        PrecisePoint pointTop = pointsUp.get(p);
        boolean distChanged = false;
        boolean last = p == pointsUp.size() - 1;
        if (dist > Math.abs(point.getX() - pointTop.getX())) {
          dist = Math.abs(point.getX() - pointTop.getX());
          distChanged = true;
          if (last) {
            ++p;
          }
        }
        if (!distChanged || (distChanged && last)) {
          pointTop = pointsUp.get(p - 1);
          if (point.getY() >= pointTop.getY()) {
            if (pointsDown.size() == 0) {
              lineTop = pointTop;
              lineBottom = null;
              storeIndex = p - 1;
              return i;
            }
            PrecisePoint pointBottom = pointsDown.get(p - 1);
            if (point.getY() <= pointBottom.getY()) {
              lineTop = pointTop;
              lineBottom = pointBottom;
              storeIndex = p - 1;
              return i;
            }
View Full Code Here

  /**
   * Calculates the bounds of the series.
   */
  private void calculateBounds() {
    ListStore<M> store = chart.getCurrentStore();
    min = new PrecisePoint(Double.NaN, Double.NaN);
    max = new PrecisePoint(Double.NaN, Double.NaN);
    // get bounding box dimensions
    calculateBBox(false);
    xValues = new ArrayList<Double>();
    yValues = new ArrayList<double[]>();

View Full Code Here

        } else {
          commands = areasCommands.get(j);
          commands.add(new LineTo(x, y));
        }
        componentCommands.add(new LineTo(x, y));
        pointsUp.get(j).add(new PrecisePoint(x, y));
      }
    }

    int prevAreaIndex = 0;
    // Close the paths
    for (int i = 0; i < yFields.size(); i++) {

      if (exclude.contains(i)) {
        continue;
      }

      pointsDown.put(i, new ArrayList<PrecisePoint>());
      commands = areasCommands.get(i);
      // Close bottom path to the axis
      if (first) {
        first = false;
        commands.add(new LineTo(x, bbox.getY() + bbox.getHeight()));
        commands.add(new LineTo(bbox.getX(), bbox.getY() + bbox.getHeight()));
      }
      // Close other paths to the one before them
      else {
        componentCommands = areasComponentCommands.get(prevAreaIndex);
        // reverse the componentCommands
        for (int j = 0; j < componentCommands.size() / 2; j++) {
          command = componentCommands.remove(j);
          componentCommands.add(componentCommands.size() - j, command);
          command = componentCommands.remove(componentCommands.size() - j - 2);
          componentCommands.add(j, command);
        }
        command = componentCommands.get(0);
        if (command instanceof MoveTo) {
          commands.add(new LineTo(x, ((MoveTo) command).getY()));
        } else if (command instanceof LineTo) {
          commands.add(new LineTo(x, ((LineTo) command).getY()));
        }

        for (int j = 0; j < ln; j++) {
          command = componentCommands.get(j);
          if (command instanceof MoveTo) {
            commands.add(new MoveTo((MoveTo) command));
          } else if (command instanceof LineTo) {
            commands.add(new LineTo((LineTo) command));
          }
          EndPointCommand point = (EndPointCommand) command;
          pointsDown.get(i).add(0, new PrecisePoint(point.getX(), point.getY()));
        }
        command = commands.get(0);
        if (command instanceof MoveTo) {
          commands.add(new LineTo(bbox.getX(), ((MoveTo) command).getY()));
        } else if (command instanceof LineTo) {
View Full Code Here

            chart.addSprite(sprite);
          }
          setLabelText(sprite, i);
          sprite.redraw();
          double offsetY = sprite.getBBox().getHeight() / 2.0;
          PrecisePoint point = getPointFromCommand(areasCommands.get(top).get(i));
          if (chart.isAnimated() && sprite.getTranslation() != null) {
            DrawFx.createTranslationAnimator(sprite, point.getX(), point.getY() - offsetY).run(
                chart.getAnimationDuration(), chart.getAnimationEasing());
          } else {
            sprite.setTranslation(point.getX(), point.getY() - offsetY);
            sprite.redraw();
          }
        }
      } else if (labelPosition == LabelPosition.END || labelPosition == LabelPosition.START) {
        for (int i = 0; i < yValues.size(); i++) {
          double[] values = yValues.get(i);
          for (int j = 0; j < values.length; j++) {
            final Sprite sprite;
            if (labels.get(i * values.length + j) != null) {
              sprite = labels.get(i * values.length + j);
            } else {
              sprite = labelConfig.getSpriteConfig().copy();
              labels.put(i * values.length + j, sprite);
              chart.addSprite(sprite);
            }
            if (sprite instanceof TextSprite) {
              TextSprite text = (TextSprite) sprite;
              if (labelConfig.getLabelProvider() != null) {
                text.setText(labelConfig.getLabelProvider().getLabel(chart.getCurrentStore().get(j),
                    getValueProvider(j)));
              }
              text.redraw();
            }
            double offsetY = sprite.getBBox().getHeight() / 2.0;
            PrecisePoint point = getPointFromCommand(areasCommands.get(j).get(i));
            if (chart.isAnimated() && sprite.getTranslation() != null) {
              DrawFx.createTranslationAnimator(sprite, point.getX(), point.getY() - offsetY).run(
                  chart.getAnimationDuration(), chart.getAnimationEasing());
            } else {
              sprite.setTranslation(point.getX(), point.getY() - offsetY);
              sprite.redraw();
            }
          }
        }
      }
View Full Code Here

      if (i == 0) {
        commands.add(new MoveTo(x + centerX, y + centerY));
      } else {
        commands.add(new LineTo(x + centerX, y + centerY));
      }
      coordinates.put(i, new PrecisePoint(x + centerX, y + centerY));
    }
    commands.add(new ClosePath());

    // create path sprite
    if (radar == null) {
View Full Code Here

  @Override
  protected int getIndex(PrecisePoint point) {
    for (int i = 0; i < radar.size() - 1; i++) {
      PathCommand command = radar.getCommand(i);
      PrecisePoint bound = getPointFromCommand(command);
      if (point.equalsNoPrecision(bound, selectionTolerance)) {
        return i;
      }
    }
    return -1;
View Full Code Here

   *
   * @param point the point to multiply
   * @return the result of the multiplication
   */
  public PrecisePoint pointMultiply(PrecisePoint point) {
    return new PrecisePoint(point.getX() * matrix[0][0] + point.getY() * matrix[0][1] + matrix[0][2], point.getX()
        * matrix[1][0] + point.getY() * matrix[1][1] + matrix[1][2]);
  }
View Full Code Here

  public static List<PathSprite> findDelta(PathSprite origin, List<PathCommand> commands) {
    PathSprite me = origin.copy().toAbsolute();
    PathSprite sprite = new PathSprite();
    sprite.setCommands(commands);
    sprite = sprite.copy().toAbsolute();
    PrecisePoint myCurrentPoint = new PrecisePoint();
    PrecisePoint myMovePoint = new PrecisePoint();
    PrecisePoint myCurvePoint = new PrecisePoint();
    PrecisePoint myQuadraticPoint = new PrecisePoint();
    PrecisePoint spriteCurrentPoint = new PrecisePoint();
    PrecisePoint spriteMovePoint = new PrecisePoint();
    PrecisePoint spriteCurvePoint = new PrecisePoint();
    PrecisePoint spriteQuadraticPoint = new PrecisePoint();

    while (me.size() < sprite.size()) {
      me.addCommand(sprite.getCommand(me.size()));
    }
    while (me.size() > sprite.size()) {
View Full Code Here

      return new PreciseRectangle();
    }
    PathSprite curve = this.copy().toCurve();
    double x = 0;
    double y = 0;
    PrecisePoint min = new PrecisePoint(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
    PrecisePoint max = new PrecisePoint(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);

    for (PathCommand command : curve.getCommands()) {
      if (command instanceof MoveTo) {
        MoveTo moveto = (MoveTo) command;
        x = moveto.getX();
        y = moveto.getY();
        min.setX(Math.min(min.getX(), x));
        min.setY(Math.min(min.getY(), y));
        max.setX(Math.max(max.getX(), x));
        max.setY(Math.max(max.getY(), y));
      } else {
        CurveTo curveto = (CurveTo) command;
        PreciseRectangle bbox = this.curveDimensions(new PrecisePoint(x, y), curveto);
        min.setX(Math.min(min.getX(), bbox.getX()));
        min.setY(Math.min(min.getY(), bbox.getY()));
        max.setX(Math.max(max.getX(), bbox.getX() + bbox.getWidth()));
        max.setY(Math.max(max.getY(), bbox.getY() + bbox.getHeight()));
        x = curveto.getX();
        y = curveto.getY();
      }
    }

    return new PreciseRectangle(min.getX(), min.getY(), max.getX() - min.getX(), max.getY() - min.getY());
  }
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.