Package com.sencha.gxt.chart.client.draw.path

Examples of com.sencha.gxt.chart.client.draw.path.MoveTo


      return;
    }

    if (position == Position.LEFT || position == Position.RIGHT) {
      currentX = Math.floor(this.x) + 0.5;
      commands.add(new MoveTo(currentX, y));
      commands.add(new LineTo(0, -length, true));
      trueLength = length - (gutterY * 2);
    } else {
      currentY = Math.floor(this.y) + 0.5;
      commands.add(new MoveTo(x, currentY));
      commands.add(new LineTo(length, 0, true));
      trueLength = length - (gutterX * 2);
    }

    delta = trueLength / steps;
    dashesX = Math.max(minorTickSteps + 1, 0);
    dashesY = Math.max(minorTickSteps + 1, 0);

    if (position == Position.LEFT || position == Position.RIGHT) {
      currentY = y - gutterY;
      if (position == Position.LEFT) {
        currentX = x - dashSize * 2;
      } else {
        currentX = x;
      }
      while (currentY >= y - gutterY - trueLength) {
        commands.add(new MoveTo(currentX, Math.floor(currentY) + 0.5));
        commands.add(new LineTo(dashSize * 2 + 1, 0, true));
        if (currentY != y - gutterY) {
          for (int i = 1; i < dashesY; i++) {
            commands.add(new MoveTo(currentX + dashSize, Math.floor(currentY + delta * i / dashesY) + 0.5));
            commands.add(new LineTo(dashSize + 1, 0, true));
          }
        }
        ticks.add(new PrecisePoint(Math.floor(x), Math.floor(currentY)));
        currentY -= delta;
        if (delta == 0) {
          break;
        }
      }
      if (Math.round(currentY + delta - (y - gutterY - trueLength)) != 0) {
        commands.add(new MoveTo(currentX, Math.floor(y - length + gutterY) + 0.5));
        commands.add(new LineTo(dashSize * 2 + 1, 0, true));
        for (int i = 1; i < dashesY; i++) {
          commands.add(new MoveTo(currentX + dashSize, Math.floor(currentY + delta * i / dashesY) + 0.5));
          commands.add(new LineTo(dashSize + 1, 0, true));
        }
        ticks.add(new PrecisePoint(Math.floor(x), Math.floor(currentY)));
      }
    } else {
      currentX = x + gutterX;
      if (position == Position.BOTTOM) {
        currentY = y - dashSize * 2;
      } else {
        currentY = y - dashSize * 4;
      }
      while (currentX <= x + gutterX + trueLength) {
        commands.add(new MoveTo(Math.floor(currentX) + 0.5, currentY + 6));
        commands.add(new LineTo(0, dashSize * 2 + 1, true));
        if (currentX != x + gutterX) {
          for (int i = 1; i < dashesX; i++) {
            commands.add(new MoveTo(Math.floor(currentX - delta * i / dashesX) + 0.5, currentY + 6));
            commands.add(new LineTo(0, dashSize + 1, true));
          }
        }
        ticks.add(new PrecisePoint(Math.floor(currentX), Math.floor(y)));
        currentX += delta;
        if (delta == 0) {
          break;
        }
      }
      if (Math.round(currentX - delta - (x + gutterX + trueLength)) != 0) {
        commands.add(new MoveTo(Math.floor(x + length - gutterX) + 0.5, currentY + 6));
        commands.add(new LineTo(0, dashSize * 2 + 1, true));
        for (int i = 1; i < dashesX; i++) {
          commands.add(new MoveTo(Math.floor(x + length - gutterX - delta * i / dashesX) + 0.5, currentY + 6));
          commands.add(new LineTo(0, dashSize + 1, true));
        }
        ticks.add(new PrecisePoint(Math.floor(currentX), Math.floor(y)));
      }
    }
View Full Code Here


        } else {
          lineWidth = 0;
        }
        commands = (i % 2 == 0 ? evenCommands : oddCommands);
        if (position == Position.LEFT) {
          commands.add(new MoveTo(prevPoint.getX() + 1 + lineWidth, prevPoint.getY() + 0.5 - lineWidth));
          commands.add(new LineTo(prevPoint.getX() + 1 + width - lineWidth, prevPoint.getY() + 0.5 - lineWidth));
          commands.add(new LineTo(point.getX() + 1 + width - lineWidth, point.getY() + 0.5 + lineWidth));
          commands.add(new LineTo(point.getX() + 1 + lineWidth, point.getY() + 0.5 + lineWidth));
          commands.add(new ClosePath());

        } else if (position == Position.RIGHT) {
          commands.add(new MoveTo(prevPoint.getX() - lineWidth, prevPoint.getY() + 0.5 - lineWidth));
          commands.add(new LineTo(prevPoint.getX() - width + lineWidth, prevPoint.getY() + 0.5 - lineWidth));
          commands.add(new LineTo(point.getX() - width + lineWidth, point.getY() + 0.5 + lineWidth));
          commands.add(new LineTo(point.getX() - lineWidth, point.getY() + 0.5 + lineWidth));
          commands.add(new ClosePath());
        } else if (position == Position.TOP) {
          commands.add(new MoveTo(prevPoint.getX() + 0.5 + lineWidth, prevPoint.getY() + 0.5 - lineWidth));
          commands.add(new LineTo(prevPoint.getX() + 0.5 + lineWidth, prevPoint.getY() + 1 + width - lineWidth));
          commands.add(new LineTo(point.getX() + 0.5 - lineWidth, point.getY() + 1 + width - lineWidth));
          commands.add(new LineTo(point.getX() + 0.5 - lineWidth, point.getY() + 1 + lineWidth));
          commands.add(new ClosePath());
        } else {
          commands.add(new MoveTo(prevPoint.getX() + 0.5 + lineWidth, prevPoint.getY() + 1 + lineWidth));
          commands.add(new LineTo(prevPoint.getX() + 0.5 + lineWidth, prevPoint.getY() - width + lineWidth));
          commands.add(new LineTo(point.getX() + 0.5 - lineWidth, point.getY() - width + lineWidth));
          commands.add(new LineTo(point.getX() + 0.5 - lineWidth, point.getY() - lineWidth));
          commands.add(new ClosePath());
        }
      } else if (defaultGridConfig != null) {
        if (position == Position.LEFT) {
          commands.add(new MoveTo(point.getX() + 0.5, point.getY() + 0.5));
          commands.add(new LineTo(width, 0, true));
        } else if (position == Position.RIGHT) {
          commands.add(new MoveTo(point.getX() + 0.5, point.getY() + 0.5));
          commands.add(new LineTo(-width, 0, true));
        } else if (position == Position.TOP) {
          commands.add(new MoveTo(point.getX() + 0.5, point.getY() + 0.5));
          commands.add(new LineTo(0, width, true));
        } else {
          commands.add(new MoveTo(point.getX() + 0.5, point.getY() - 0.5));
          commands.add(new LineTo(0, -width, true));
        }
      }
    }
    // odd path
View Full Code Here

        path.append("c").append(Math.round(curveto.getX1() * zoom)).append(",").append(
            Math.round(curveto.getY1() * zoom)).append(",").append(Math.round(curveto.getX2() * zoom)).append(",").append(
            Math.round(curveto.getY2() * zoom)).append(",").append(Math.round(curveto.getX() * zoom)).append(",").append(
            Math.round(curveto.getY() * zoom)).append(" ");
      } else if (command instanceof MoveTo) {
        MoveTo moveto = (MoveTo) command;
        path.append("m").append(Math.round(moveto.getX() * zoom)).append(",").append(Math.round(moveto.getY() * zoom)).append(
            " ");
      } else if (command instanceof LineTo) {
        LineTo lineto = (LineTo) command;
        path.append("l").append(Math.round(lineto.getX() * zoom)).append(",").append(Math.round(lineto.getY() * zoom)).append(
            " ");
View Full Code Here

          onbreak = false;
        }
        if (lineCommands.size() > 0 && !gap) {
          lineCommands.add(new LineTo(x, y));
        } else {
          lineCommands.add(new MoveTo(x, y));
          gap = false;
        }
        gapPosition.put(String.valueOf(lineCommands.size() - 1), i);
      } else if (!gapless) {
        gap = true;
      }

      if (Double.isNaN(firstY) && !Double.isNaN(y)) {
        firstY = y;
      }
    }

    List<PathCommand> renderCommands;

    if (smooth && lineCommands.size() > 0) {
      PathSprite smooth = new PathSprite();
      smooth.setCommands(lineCommands);
      renderCommands = smooth.copy().toSmooth(segments).getCommands();
    } else {
      renderCommands = PathSprite.copyCommands(lineCommands);
    }

    // Correct path if we're animating timeAxis intervals
    if (markerIndex > 0 && previousCommands != null && previousCommands.size() > 1) {
      previousCommands.remove(1);
      line.setCommands(previousCommands);
      if (chart.hasShadows()) {
        for (int i = 0; i < lineShadows.size(); i++) {
          PathSprite shadow = lineShadows.get(i);
          shadow.setCommands(previousCommands);
        }
      }
    }

    List<PathCommand> dummyCommands = new ArrayList<PathCommand>();
    dummyCommands.add(new MoveTo(bbox.getX(), bbox.getY() + bbox.getHeight() / 2.0));
    for (int k = 1; k < lineCommands.size(); k++) {
      dummyCommands.add(new LineTo(bbox.getX() + bbox.getWidth() / k, bbox.getY() + bbox.getHeight() / 2.0));
    }

    // Only create a line if one doesn't exist.
    if (line == null) {
      line = new PathSprite();
      line.setStroke(stroke);
      chart.addSprite(line);
      line.setCommands(dummyCommands);

      if (chart.hasShadows()) {
        // create shadows
        for (int i = 0; i < shadowGroups.size(); i++) {
          PathSprite shadow = new PathSprite();
          Sprite shadowAttr = shadowAttributes.get(i);
          shadow.setStrokeWidth(shadowAttr.getStrokeWidth());
          shadow.setStrokeOpacity(shadowAttr.getStrokeOpacity());
          shadow.setStroke(shadowAttr.getStroke());
          shadow.setTranslation(new Translation(shadowAttr.getTranslation()));
          shadow.setFill(Color.NONE);
          shadow.setCommands(line.getCommands());
          chart.addSprite(shadow);
          lineShadows.add(shadow);
        }
      }
    }
    if (stroke != null) {
      line.setStroke(stroke);
    }
    if (!Double.isNaN(strokeWidth)) {
      line.setStrokeWidth(strokeWidth);
    }
    line.setFill(Color.NONE);

    if (chart.isAnimated() && line.size() > 0) {
      if (markerIndex > 0) {
        if (smooth) {
          renderCommands.remove(1);
        } else {
          MoveTo move = (MoveTo) renderCommands.get(0);
          renderCommands.add(1, new LineTo(move.getX(), move.getY()));
        }
        previousCommands = renderCommands;
      }
      DrawFx.createCommandsAnimator(line, renderCommands).run(500);
    } else {
View Full Code Here

   * @param radius the size of the primitive
   * @return the generated primitive
   */
  public static PathSprite arrow(double cx, double cy, double radius) {
    PathSprite arrow = new PathSprite();
    arrow.addCommand(new MoveTo(cx - radius * 0.7, cy - radius * 0.4));
    arrow.addCommand(new LineTo(radius * 0.6, 0, true));
    arrow.addCommand(new LineTo(0, -radius * 0.4, true));
    arrow.addCommand(new LineTo(radius, radius * 0.8, true));
    arrow.addCommand(new LineTo(-radius, radius * 0.8, true));
    arrow.addCommand(new LineTo(0, -radius * 0.4, true));
View Full Code Here

   * @return the generated primitive
   */
  public static PathSprite cross(double cx, double cy, double radius) {
    PathSprite cross = new PathSprite();
    radius /= 2.5;
    cross.addCommand(new MoveTo(cx - radius, cy));
    cross.addCommand(new LineTo(-radius, -radius, true));
    cross.addCommand(new LineTo(radius, -radius, true));
    cross.addCommand(new LineTo(radius, radius, true));
    cross.addCommand(new LineTo(radius, -radius, true));
    cross.addCommand(new LineTo(radius, radius, true));
View Full Code Here

   * @param radius the size of the primitive
   * @return the generated primitive
   */
  public static PathSprite diamond(double cx, double cy, double radius) {
    PathSprite diamond = new PathSprite();
    diamond.addCommand(new MoveTo(cx, cy - radius));
    diamond.addCommand(new LineTo(radius, radius, true));
    diamond.addCommand(new LineTo(-radius, radius, true));
    diamond.addCommand(new LineTo(-radius, -radius, true));
    diamond.addCommand(new LineTo(radius, -radius, true));
    diamond.addCommand(new ClosePath());
View Full Code Here

   * @return the generated primitive
   */
  public static PathSprite plus(double cx, double cy, double radius) {
    PathSprite plus = new PathSprite();
    radius /= 2;
    plus.addCommand(new MoveTo(cx - radius / 2, cy - radius / 2));
    plus.addCommand(new LineTo(0, -radius, true));
    plus.addCommand(new LineTo(radius, 0, true));
    plus.addCommand(new LineTo(0, radius, true));
    plus.addCommand(new LineTo(radius, 0, true));
    plus.addCommand(new LineTo(0, radius, true));
View Full Code Here

   * @return the generated primitive
   */
  public static PathSprite triangle(double cx, double cy, double radius) {
    PathSprite triangle = new PathSprite();
    radius *= 1.75;
    triangle.addCommand(new MoveTo(cx, cy));
    triangle.addCommand(new MoveTo(0, -radius * 0.58, true));
    triangle.addCommand(new LineTo(radius * 0.5, radius * 0.87, true));
    triangle.addCommand(new LineTo(-radius, 0, true));
    triangle.addCommand(new ClosePath());
    return triangle;
  }
View Full Code Here

TOP

Related Classes of com.sencha.gxt.chart.client.draw.path.MoveTo

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.