예제 #1
0
  /**
   * Adds an FXG child node to this node.
   *
   * <p>Graphic content nodes support child property nodes &lt;filter&gt;, &lt;mask&gt;,
   * &lt;matrix&gt;, or &lt;colorTransform&gt;.
   *
   * @param child - a child FXG node to be added to this node.
   * @throws FXGException if the child is not supported by this node.
   */
  @Override
  public void addChild(FXGNode child) {
    if (child instanceof FilterNode) {
      if (filters == null) filters = new ArrayList<FilterNode>();

      filters.add((FilterNode) child);
    } else if (child instanceof MaskPropertyNode) {
      mask = ((MaskPropertyNode) child).mask;
      if (mask instanceof GraphicContentNode) {
        ((GraphicContentNode) mask).setParentGraphicContext(createGraphicContext());
      }
    } else if (child instanceof MatrixNode) {
      if (translateSet || scaleSet || rotationSet)
        // Exception:Cannot supply a matrix child if transformation attributes were provided
        throw new FXGException(
            child.getStartLine(), child.getStartColumn(), "InvalidChildMatrixNode");

      matrix = (MatrixNode) child;
    } else if (child instanceof ColorTransformNode) {
      if (alphaSet)
        // Exception:Cannot supply a colorTransform child if alpha attribute was provided.
        throw new FXGException(
            child.getStartLine(), child.getStartColumn(), "InvalidChildColorTransformNode");

      colorTransform = (ColorTransformNode) child;
    } else {
      super.addChild(child);
    }
  }
예제 #2
0
 /**
  * Sets an FXG attribute on this FXG node. Delegates to the parent class to process attributes
  * that are not in the list below.
  *
  * <p>Graphic content nodes support the following attributes:
  *
  * <ul>
  *   <li><b>rotation</b> (ASDegrees): Defaults to 0.
  *   <li><b>scaleX</b> (Number): Defaults to 1.
  *   <li><b>scaleY</b> (Number): Defaults to 1.
  *   <li><b>x</b> (Number): The horizontal placement of the left edge of the text box, relative to
  *       the parent grouping element. Defaults to 0.
  *   <li><b>y</b> (Number): The vertical placement of the top edge of the text box, relative to
  *       the parent grouping element. Defaults to 0.
  *   <li><b>blendMode</b> (String): [normal, add, alpha, darken, difference, erase, hardlight,
  *       invert, layer, lighten, multiply, normal, subtract, screen, overlay, auto, colordodge,
  *       colorburn, exclusion, softlight, hue, saturation, color, luminosity] Defaults to auto.
  *   <li><b>alpha</b> (ASAlpha): Defaults to 1.
  *   <li><b>maskType</b> (String):[clip, alpha]: Defaults to clip.
  *   <li><b>visible</b> (Boolean): Whether or not the text box is visible. Defaults to true.
  * </ul>
  *
  * <p>Graphic content nodes also support an id attribute.
  *
  * @param name - the unqualified attribute name
  * @param value - the attribute value
  * @throws FXGException if a value is out of the valid range.
  * @see com.adobe.internal.fxg.dom.AbstractFXGNode#setAttribute(java.lang.String,
  *     java.lang.String)
  */
 @Override
 public void setAttribute(String name, String value) {
   if (FXG_X_ATTRIBUTE.equals(name)) {
     x = DOMParserHelper.parseDouble(this, value, name);
     translateSet = true;
   } else if (FXG_Y_ATTRIBUTE.equals(name)) {
     y = DOMParserHelper.parseDouble(this, value, name);
     translateSet = true;
   } else if (FXG_ROTATION_ATTRIBUTE.equals(name)) {
     rotation = DOMParserHelper.parseDouble(this, value, name);
     rotationSet = true;
   } else if (FXG_SCALEX_ATTRIBUTE.equals(name)) {
     scaleX = DOMParserHelper.parseDouble(this, value, name);
     scaleSet = true;
   } else if (FXG_SCALEY_ATTRIBUTE.equals(name)) {
     scaleY = DOMParserHelper.parseDouble(this, value, name);
     scaleSet = true;
   } else if (FXG_ALPHA_ATTRIBUTE.equals(name)) {
     alpha =
         DOMParserHelper.parseDouble(
             this, value, name, ALPHA_MIN_INCLUSIVE, ALPHA_MAX_INCLUSIVE, alpha);
     alphaSet = true;
   } else if (FXG_BLENDMODE_ATTRIBUTE.equals(name)) {
     blendMode = parseBlendMode(this, value, blendMode);
   } else if (FXG_VISIBLE_ATTRIBUTE.equals(name)) {
     visible = DOMParserHelper.parseBoolean(this, value, name);
   } else if (FXG_ID_ATTRIBUTE.equals(name)) {
     id = value;
   } else if (FXG_MASKTYPE_ATTRIBUTE.equals(name)) {
     maskType = DOMParserHelper.parseMaskType(this, value, name, maskType);
     // Luminosity mask is not supported by Flex on Mobile in
     // FXG 2.0.
     if (isForMobile() && (maskType == MaskType.LUMINOSITY)) {
       FXGLog.getLogger()
           .log(
               FXGLogger.WARN,
               "MobileUnsupportedLuminosityMask",
               null,
               ((AbstractFXGNode) this).getDocumentName(),
               startLine,
               startColumn);
       maskTypeSet = false;
     } else {
       maskTypeSet = true;
     }
   } else if (getFileVersion().equalTo(FXGVersion.v1_0)) {
     // Rest of the attributes are not supported by FXG 1.0
     // Exception:Attribute {0} not supported by node {1}.
     throw new FXGException(
         getStartLine(), getStartColumn(), "InvalidNodeAttribute", name, getNodeName());
   } else if (FXG_LUMINOSITYCLIP_ATTRIBUTE.equals(name)) {
     luminosityClip = DOMParserHelper.parseBoolean(this, value, name);
   } else if (FXG_LUMINOSITYINVERT_ATTRIBUTE.equals(name)) {
     luminosityInvert = DOMParserHelper.parseBoolean(this, value, name);
   } else {
     super.setAttribute(name, value);
   }
 }