예제 #1
0
 /**
  * Convert discreet transform attributes to child matrix. This allows concatenation of another
  * matrix.
  */
 public void convertTransformAttrToMatrix() {
   try {
     MatrixNode matrixNode = MatrixNode.class.newInstance();
     // Convert discreet transform attributes to FXGMatrix.
     FXGMatrix matrix = FXGMatrix.convertToMatrix(scaleX, scaleY, rotation, x, y);
     // Set matrix attributes to FXGMatrix values.
     matrix.setMatrixNodeValue(matrixNode);
     // Reset all discreet transform attributes since matrix
     // and discreet transform attributes cannot coexist.
     resetTransformAttr();
     // Add child matrix to the node.
     this.addChild(matrixNode);
   } catch (Throwable t) {
     throw new FXGException(
         mask.getStartLine(), mask.getStartColumn(), "InvalidChildMatrixNode", t);
   }
 }
예제 #2
0
  /**
   * Creates the graphic context.
   *
   * @return the graphic context
   */
  public GraphicContext createGraphicContext() {
    GraphicContext graphicContext = new GraphicContext();

    if (parentGraphicContext != null) graphicContext.scalingGrid = parentGraphicContext.scalingGrid;

    FXGMatrix transform = graphicContext.getTransform();
    if (matrix != null) {
      FXGMatrix t = new FXGMatrix(matrix);
      transform.concat(t);
    } else {

      if (scaleSet) transform.scale(scaleX, scaleY);

      if (rotationSet) transform.rotate(rotation);

      if (translateSet) transform.translate(x, y);
    }

    if (colorTransform != null) {
      graphicContext.colorTransform = colorTransform;
    } else if (alphaSet) {
      if (graphicContext.colorTransform == null)
        graphicContext.colorTransform = new ColorTransformNode();

      graphicContext.colorTransform.alphaMultiplier = alpha;
    }

    graphicContext.blendMode = blendMode;

    if (filters != null) {
      graphicContext.addFilters(filters);
    }

    if (maskTypeSet) graphicContext.maskType = maskType;
    else if (parentGraphicContext != null) graphicContext.maskType = parentGraphicContext.maskType;

    return graphicContext;
  }