Examples of PathSprite


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

    if (series instanceof ScatterSeries) {
      boolean markers = true;
      // Line series - display as short line with optional marker in the middle
      if (series instanceof LineSeries) {
        LineSeries<M> lineSeries = (LineSeries<M>) series;
        line = new PathSprite();
        add(line);
        chart.addSprite(line);
        line.addCommand(new MoveTo(-5.5, 0.5));
        line.addCommand(new LineTo(17.5, 0.5));
        line.setStrokeWidth(lineSeries.getStrokeWidth());
        line.setStrokeLineJoin(LineJoin.ROUND);
        line.setStroke(lineSeries.getStroke());
        markers = lineSeries.isShowMarkers();
      } else if (series instanceof RadarSeries) {
        RadarSeries<M> radar = (RadarSeries<M>) series;
        line = new PathSprite();
        add(line);
        chart.addSprite(line);
        line.addCommand(new MoveTo(0.5, 0.5));
        line.addCommand(new LineTo(16.5, 0.5));
        line.setStrokeWidth(radar.getStrokeWidth());
View Full Code Here

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

   * @param commands the target path commands
   * @return the animator
   */
  public static Animator createCommandsAnimator(final PathSprite origin, List<PathCommand> commands) {
    List<PathSprite> sourceDelta = PathSprite.findDelta(origin, commands);
    final PathSprite source = sourceDelta.get(0);
    final PathSprite delta = sourceDelta.get(1);
    return new Animator() {
      @Override
      protected void onUpdate(double progress) {
        PathSprite start = new PathSprite(source);
        for (int i = 0; i < start.size(); i++) {
          if (start.getCommand(i) instanceof MoveTo) {
            MoveTo move1 = (MoveTo) start.getCommand(i);
            MoveTo move2 = (MoveTo) delta.getCommand(i);
            move1.setX(move1.getX() + (move2.getX() * progress));
            move1.setY(move1.getY() + (move2.getY() * progress));
          } else if (start.getCommand(i) instanceof CurveTo) {
            CurveTo curve1 = (CurveTo) start.getCommand(i);
            CurveTo curve2 = (CurveTo) delta.getCommand(i);
            curve1.setX(curve1.getX() + (curve2.getX() * progress));
            curve1.setY(curve1.getY() + (curve2.getY() * progress));
            curve1.setX1(curve1.getX1() + (curve2.getX1() * progress));
            curve1.setY1(curve1.getY1() + (curve2.getY1() * progress));
            curve1.setX2(curve1.getX2() + (curve2.getX2() * progress));
            curve1.setY2(curve1.getY2() + (curve2.getY2() * progress));
          }
        }
        origin.setCommands(start.getCommands());
        origin.redraw();
      }
    };
  }
View Full Code Here

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

  /**
   * Creates a bar {@link Series}.
   */
  public BarSeries() {
    // setup shadow attributes
    Sprite config = new PathSprite();
    config.setStrokeWidth(6);
    config.setStrokeOpacity(0.05);
    config.setStroke(new RGB(200, 200, 200));
    config.setTranslation(1.2, 1.2);
    shadowAttributes.add(config);
    config = new PathSprite();
    config.setStrokeWidth(4);
    config.setStrokeOpacity(0.1);
    config.setStroke(new RGB(150, 150, 150));
    config.setTranslation(0.9, 0.9);
    shadowAttributes.add(config);
    config = new PathSprite();
    config.setStrokeWidth(2);
    config.setStrokeOpacity(0.15);
    config.setStroke(new RGB(100, 100, 100));
    config.setTranslation(0.6, 0.6);
    shadowAttributes.add(config);

    // initialize shadow groups
    if (shadowGroups.size() == 0) {
      for (int i = 0; i < shadowAttributes.size(); i++) {
View Full Code Here

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

      }
    }

    createLabels();

    final PathSprite axis;
    if (lines.size() == 0) {
      axis = axisConfig.copy();
      lines.add(axis);
      chart.addSprite(axis);
    } else {
      axis = lines.get(0);
    }
    axis.setCommands(commands);
    axis.redraw();

    // drawGrid
    if (!init && displayGrid) {
      drawGrid();
    }
    axisBBox = axis.getBBox();
    drawLabels();
  }
View Full Code Here

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

          long height = Math.round((rect.getY() + rect.getHeight()) * zoom);
          vml = path.append("m").append(x).append(",").append(y).append(" l").append(width).append(",").append(y).append(
              " l").append(width).append(",").append(height).append(" l").append(x).append(",").append(height).append(
              " x e").toString();
        } else {
          vml = path2vml(new PathSprite(rect));
        }
      }
    } else if (sprite instanceof PathSprite) {
      PathSprite pathSprite = (PathSprite) sprite;
      vml = path2vml(pathSprite);

    } else if (sprite instanceof TextSprite) {
      // Handle text (special handling required)
      setTextAttributes((TextSprite) sprite, element);
View Full Code Here

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

        // VML does NOT support a gradient stroke :(
        stroke.setPropertyString("color", strokeColor.getColor());
      }

      if (sprite instanceof PathSprite) {
        PathSprite path = (PathSprite) sprite;
        if (path.getStrokeLineCap() != null) {
          stroke.setPropertyString("endcap", path.getStrokeLineCap().getValue());
        }
        if (path.getStrokeLineJoin() != null) {
          stroke.setPropertyString("joinstyle", path.getStrokeLineJoin().getValue());
        }
        if (!Double.isNaN(path.getMiterLimit())) {
          stroke.setPropertyDouble("miterlimit", path.getMiterLimit());
        }
      }

      double width = sprite.getStrokeWidth();
      double opacity = sprite.getStrokeOpacity();
View Full Code Here

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

   * Creates a line {@link Series}.
   */
  public LineSeries() {
    // setup shadow attributes
    shadowAttributes = new ArrayList<Sprite>();
    Sprite config = new PathSprite();
    config.setStrokeWidth(6);
    config.setStrokeOpacity(0.05);
    config.setStroke(RGB.BLACK);
    config.setTranslation(1, 1);
    shadowAttributes.add(config);
    config = new PathSprite();
    config.setStrokeWidth(4);
    config.setStrokeOpacity(0.1);
    config.setStroke(RGB.BLACK);
    config.setTranslation(1, 1);
    shadowAttributes.add(config);
    config = new PathSprite();
    config.setStrokeWidth(2);
    config.setStrokeOpacity(0.15);
    config.setStroke(RGB.BLACK);
    config.setTranslation(1, 1);
    shadowAttributes.add(config);

    // initialize shadow groups
    if (shadowGroups.size() == 0) {
      for (int i = 0; i < shadowAttributes.size(); i++) {
View Full Code Here

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

    }

    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 {
      line.setCommands(renderCommands);
      line.redraw();
    }

    if (lineRenderer != null) {
      lineRenderer.spriteRenderer(line, 0, chart.getStore());
    }

    if (fill != Color.NONE && fill != null) {
      fillCommands.addAll(renderCommands);
      fillCommands.add(new LineTo(x, bbox.getY() + bbox.getHeight()));
      fillCommands.add(new LineTo(bbox.getX(), bbox.getY() + bbox.getHeight()));
      fillCommands.add(new LineTo(bbox.getX(), firstY));

      if (fillSprite == null) {
        fillSprite = new PathSprite();
        fillSprite.setOpacity(0.3);
        fillSprite.setFill(fill);
        fillSprite.setCommands(dummyCommands);
        chart.addSprite(fillSprite);
      }
      if (chart.isAnimated() && fillSprite.size() > 0) {
        DrawFx.createCommandsAnimator(fillSprite, fillCommands).run(chart.getAnimationDuration(),
            chart.getAnimationEasing());
      } else {
        fillSprite.setCommands(fillCommands);
        fillSprite.redraw();
      }
      if (fillRenderer != null) {
        fillRenderer.spriteRenderer(fillSprite, 0, chart.getStore());
      }
    }

    if (chart.hasShadows()) {
      for (int i = 0; i < lineShadows.size(); i++) {
        PathSprite shadow = lineShadows.get(i);
        if (!hidden) {
          shadow.setHidden(false);
        }
        if (chart.isAnimated()) {
          DrawFx.createCommandsAnimator(shadow, renderCommands).run(chart.getAnimationDuration(),
              chart.getAnimationEasing());
        } else {
          shadow.setCommands(renderCommands);
          shadow.redraw();
        }
        if (shadowRenderer != null) {
          shadowRenderer.spriteRenderer(shadow, i, chart.getCurrentStore());
        }
      }
View Full Code Here

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

   * @param cy the center x-coordinate of the primitive
   * @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));
    arrow.addCommand(new LineTo(-radius * 0.6, 0, true));
    arrow.addCommand(new ClosePath());
    return arrow;
  }
View Full Code Here

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

   * @param cy the center x-coordinate of the primitive
   * @param radius the size of the primitive
   * @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));
    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));
    cross.addCommand(new LineTo(-radius, -radius, true));
    cross.addCommand(new ClosePath());
    return cross;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.