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

Examples of com.sencha.gxt.chart.client.draw.Matrix


  public Matrix transformMatrix() {
    if (rotation == null && scaling == null && translation == null) {
      return null;
    }
    if (isTransformDirty()) {
      matrix = new Matrix();
      if (rotation != null) {
        matrix.rotate(rotation.getDegrees(), rotation.getX(), rotation.getY());
      }
      if (scaling != null) {
        matrix.scale(scaling.getX(), scaling.getY(), scaling.getCenterX(), scaling.getCenterY());
View Full Code Here


   * {@link Translation}.
   *
   * @param sprite the sprite to have its transformations applied
   */
  private void transform(Sprite sprite) {
    Matrix matrix = sprite.transformMatrix();
    getElement(sprite).setAttribute(
        "transform",
        new StringBuilder().append("matrix( ").append(matrix.get(0, 0)).append(", ").append(matrix.get(1, 0)).append(
            ", ").append(matrix.get(0, 1)).append(", ").append(matrix.get(1, 1)).append(", ").append(matrix.get(0, 2)).append(
            ", ").append(matrix.get(1, 2)).append(")").toString());
  }
View Full Code Here

   */
  private void transform(Sprite sprite) {
    double deltaDegrees = 0;
    double deltaScaleX = 1;
    double deltaScaleY = 1;
    Matrix matrix = new Matrix();
    Rotation rotation = sprite.getRotation();
    Scaling scaling = sprite.getScaling();
    Translation translation = sprite.getTranslation();
    XElement element = getElement(sprite);
    Style style = element.getStyle();
    Element skew = element.getPropertyJSO("skew").cast();

    if (rotation != null) {
      matrix.rotate(rotation.getDegrees(), rotation.getX(), rotation.getY());
      deltaDegrees += rotation.getDegrees();
    }
    if (scaling != null) {
      matrix.scale(scaling.getX(), scaling.getY(), scaling.getCenterX(), scaling.getCenterY());
      deltaScaleX *= scaling.getX();
      deltaScaleY *= scaling.getY();
    }
    if (translation != null) {
      matrix.translate(translation.getX(), translation.getY());
    }
    if (viewBoxShift != null) {
      matrix.scale(viewBoxShift.getX(), viewBoxShift.getY(), -1, -1);
      matrix.add(1, 0, 0, 1, viewBoxShift.getCenterX(), viewBoxShift.getCenterY());
    }

    if (!(sprite instanceof ImageSprite) && skew != null) {
      // matrix transform via VML skew
      skew.setPropertyString(
          "matrix",
          new StringBuilder().append(toFixed(matrix.get(0, 0), 4)).append(", ").append(toFixed(matrix.get(0, 1), 4)).append(
              ", ").append(toFixed(matrix.get(1, 0), 4)).append(", ").append(toFixed(matrix.get(1, 1), 4)).append(
              ", 0, 0").toString());
      skew.setPropertyString(
          "offset",
          new StringBuilder().append(toFixed(matrix.get(0, 2), 4)).append(", ").append(toFixed(matrix.get(1, 2), 4)).toString());
    } else {
      double deltaX = matrix.get(0, 2);
      double deltaY = matrix.get(1, 2);
      // Scale via coordsize property
      double zoomScaleX = zoom / deltaScaleX;
      double zoomScaleY = zoom / deltaScaleY;

      element.setPropertyString("coordsize", Math.abs(zoomScaleX) + " " + Math.abs(zoomScaleY));

      // Rotate via rotation property
      double newAngle = deltaDegrees * (deltaScaleX * ((deltaScaleY < 0) ? -1 : 1));
      if ((style.getProperty("rotation") == null && newAngle != 0)) {
        style.setProperty("rotation", String.valueOf(newAngle));
      } else if (style.getProperty("rotation") != null && newAngle != Double.valueOf(style.getProperty("rotation"))) {
        style.setProperty("rotation", String.valueOf(newAngle));
      }
      if (deltaDegrees != 0) {
        // Compensate x/y position due to rotation
        Matrix compMatrix = new Matrix();
        compMatrix.rotate(-deltaDegrees, deltaX, deltaY);
        deltaX = deltaX * compMatrix.get(0, 0) + deltaY * compMatrix.get(0, 1) + compMatrix.get(0, 2);
        deltaY = deltaX * compMatrix.get(1, 0) + deltaY * compMatrix.get(1, 1) + compMatrix.get(1, 2);
      }

      String flip = "";
      // Handle negative scaling via flipping
      if (deltaScaleX < 0) {
View Full Code Here

TOP

Related Classes of com.sencha.gxt.chart.client.draw.Matrix

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.