Examples of PlaceObject3Tag


Examples of org.apache.flex.swf.tags.PlaceObject3Tag

        DefineShapeTag clipShape = createDefineShapeTag(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
        PlaceObject3Tag(clipShape, new GraphicContext());
        spriteStack.pop();
       
        //place the clipping mask in the imageSprite
        PlaceObject3Tag po3clip = PlaceObject3Tag(clipSprite, context);
        po3clip.setClipDepth(po3clip.getDepth()+1);
        po3clip.setHasClipDepth(true);
        // Then, process the image
        DefineShapeTag imageShape = ImageHelper.createShapeForImage(defImage, node);
        PlaceObject3Tag(imageShape, context);       
        spriteStack.pop();
       
        PlaceObject3Tag po3 = PlaceObject3Tag(imageSprite, new GraphicContext());
       
        // If filters were not processed, place the topmost sprite in display list and apply filters
        // This is done to force processing of masks before filters
        if (filters != null)
        {
            DefineSpriteTag sprite = spriteStack.pop();
            GraphicContext gc = new GraphicContext();
            gc.filters = filters;
            PlaceObject3Tag poFilter = PlaceObject3Tag(sprite, gc);
            return poFilter;           
        }
        return po3;
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

            ScalingGrid scalingGrid = context.scalingGrid;
            if (scalingGrid != null)
            {
                Rect grid = TypeHelper.rect(scalingGrid.scaleGridLeft, scalingGrid.scaleGridTop, scalingGrid.scaleGridRight, scalingGrid.scaleGridBottom);
                imageShape = ImageHelper.create9SlicedShape(imageTag, grid, Double.NaN, Double.NaN);
                PlaceObject3Tag po3 = PlaceObject3Tag(imageShape, context);
                return po3;
            }
            else
            {
              if (ImageHelper.bitmapImageNeedsClipping(imageTag, node))
              {
                PlaceObject3Tag p03 = bitmapWithClip(imageTag, node);
                return p03;
              }
              else
              {
                imageShape = ImageHelper.createShapeForImage(imageTag, node);
                PlaceObject3Tag po3 = PlaceObject3Tag(imageShape, context);
                return po3;
              }
            }           
        }
        else
        {
          if (!ImageHelper.bitmapImageNeedsClipping(imageTag, node))
          {          
               double width = (Double.isNaN(node.width)) ? imageTag.getWidth() : node.width;
                 double height = (Double.isNaN(node.height)) ? imageTag.getHeight() : node.height;
             List<ShapeRecord>  shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);       
               DefineShapeTag shape = createDefineShapeTag(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
             PlaceObject3Tag po3 = PlaceObject3Tag(shape, context);
             return po3;
          }
          else
          {
                double width = ((imageTag.getWidth() < node.width) || Double.isNaN(node.width)) ? imageTag.getWidth() : node.width;
                double height = ((imageTag.getHeight() < node.height) || (Double.isNaN(node.height))) ? imageTag.getHeight() : node.height;
              List<ShapeRecord>  shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);       
                 DefineShapeTag shape = createDefineShapeTag(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
              PlaceObject3Tag po3 = PlaceObject3Tag(shape, context);
              return po3;
          }
        }
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

        }
    }

    protected PlaceObject3Tag graphicContentNode(GraphicContentNode node)
    {
        PlaceObject3Tag po3 = null;

      if (!node.visible)
        {
            ColorTransformNode ct = new ColorTransformNode();
            ct.alphaMultiplier = 0;
            ct.alphaOffset = 0;
            ct.blueMultiplier = 1;
            ct.blueOffset = 0;
            ct.greenMultiplier = 1;
            ct.greenOffset = 0;
            ct.redMultiplier = 1;
            ct.redOffset = 0;
            node.colorTransform = ct;
           
            if (node instanceof AbstractShapeNode)
            {
                AbstractShapeNode shapeNode = (AbstractShapeNode)node;
                shapeNode.fill = null;
                shapeNode.stroke = null;
            }
           
        }

        if (node instanceof GroupNode)
        {
            group((GroupNode)node);
        }
        else
        {
            if (node.blendMode == BlendMode.AUTO)
                node.blendMode = BlendMode.NORMAL;
           
            // For non-group nodes, we process mask to clip only this shape
            // node. Process the mask first to ensure the depth is correct.
            List<IFilterNode> filters = null;
            if (node.mask != null)
            {
                // Remove the filters from context and process them later to force Flash Player to process the masks first
                if (node.filters != null)
                {  
                    filters = node.filters;
                    node.filters = null;
                    DefineSpriteTag filterSprite = createDefineSpriteTag("MaskFilter");
                    spriteStack.push(filterSprite);
                }
                DefineSpriteTag parentSprite = spriteStack.peek();
                mask(node, parentSprite);
            }
           
            if (node instanceof EllipseNode)
                po3 = ellipse((EllipseNode)node);
            else if (node instanceof LineNode)
                po3 = line((LineNode)node);
            else if (node instanceof PathNode)
                po3 = path((PathNode)node);
            else if (node instanceof RectNode)
                po3 = rect((RectNode)node);
            else if (node instanceof PlaceObjectNode)
                po3 = PlaceObject3TagInstance((PlaceObjectNode)node);
            else if (node instanceof BitmapGraphicNode)
                po3 = bitmap((BitmapGraphicNode)node);
            else if (node instanceof TextGraphicNode)
                po3 = text((TextGraphicNode)node);
            else if (node instanceof RichTextNode)
                po3 = richtext((RichTextNode)node);
           
            // If filters were not processed, place the topmost sprite in display list and apply filters
            // This is done to force processing of masks before filters
            if (filters != null)
            {
                DefineSpriteTag sprite = spriteStack.pop();
                GraphicContext gc = new GraphicContext();
                gc.filters = filters;
                PlaceObject3Tag poFilter = PlaceObject3Tag(sprite, gc);
                return poFilter;           
            }
        }

        return po3;
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

            grid.setCharacter(groupSprite);
            extraTags.put(groupSprite,grid);
            //groupSprite.scalingGrid = grid;
        }

        PlaceObject3Tag po3 = PlaceObject3Tag(groupSprite, context);
        spriteStack.push(groupSprite);
       
        // First, process mask (if present)
        List <IFilterNode> filters = null;
        if (node.mask != null)
        {   
            // Remove the filters from context and process them later to force Flash Player to process the masks first
            filters = node.filters;
            if (filters == null)
            {
                List<GraphicContentNode> children = node.children;
                if (children != null)
                {
                    GraphicContentNode gcNode0 = (GraphicContentNode) children.get(0);
                    filters = gcNode0.filters;
                    if (filters != null)
                    {
                        //check if all the nodes share the same filter
                        for (int i = 1; ((i < children.size()) && filters!= null); i++)
                        {
                            GraphicContentNode gcNodeI = (GraphicContentNode) children.get(i);
                            if (gcNodeI.filters != filters)
                                filters = null;
                        }
                    }

                    if (filters != null)
                    {
                        for (int i = 0; (i < children.size()) ; i++)
                        {
                            GraphicContentNode gcNodeI = (GraphicContentNode) children.get(i);
                            gcNodeI.filters = null;
                        }                       
                    }
                   
                }
            }
            else
            {
                node.filters = null;
            }
            if (filters != null)      
            {   
                DefineSpriteTag filterSprite = createDefineSpriteTag("MaskFilter");
                spriteStack.push(filterSprite);
            }
            DefineSpriteTag sprite = spriteStack.peek();
            mask(node, sprite);
        }

        // Then process child nodes.
        if (node.children != null)
            graphicContentNodes(node.children);
       
        // If filters were not processed, place the topmost sprite in display list and apply filters
        // This is done to force processing of masks before filters
        if (filters != null)
        {
            DefineSpriteTag sprite = spriteStack.pop();
            GraphicContext gc = new GraphicContext();
            gc.filters = filters;
            PlaceObject3Tag poFilter = PlaceObject3Tag(sprite, gc);
            return poFilter;           
        }
        spriteStack.pop();
        return po3;
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

    protected PlaceObject3Tag line(LineNode node)
    {
        List<ShapeRecord> shapeRecords = ShapeHelper.line(node.xFrom, node.yFrom, node.xTo, node.yTo);
        GraphicContext context = node.createGraphicContext();
        PlaceObject3Tag po3 = placeDefineShapeTag(node, shapeRecords, node.fill, node.stroke, context);
        return po3;
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

        return po3;
    }

    protected PlaceObject3Tag mask(IMaskableNode node, DefineSpriteTag parentSprite)
    {
        PlaceObject3Tag po3 = null;

        IMaskingNode mask = node.getMask();
        if (mask instanceof GroupNode)
        {
            // According to FXG Spec.: The masking element inherits the target
            // group's coordinate space, as though it were a direct child
            // element. In the case when mask is inside a shape, it doesn't
            // automatically inherit the coordinates from the shape node
            // but inherits from its parent node which is also parent of
            // the shape node. To fix it, specifically concatenating the
            // shape node matrix to the masking node matrix.
            if (!(node instanceof GroupNode || node instanceof GraphicNode))
            {
                FXGMatrix nodeMatrix = null;
                MatrixNode matrixNodeShape = ((GraphicContentNode)node).matrix;
                if (matrixNodeShape == null)
                    // Convert shape node's discreet transform attributes to
                    // matrix.
                    nodeMatrix = FXGMatrix.convertToMatrix(((GraphicContentNode)node).scaleX, ((GraphicContentNode)node).scaleY, ((GraphicContentNode)node).rotation, ((GraphicContentNode)node).x, ((GraphicContentNode)node).y);
                else
                    nodeMatrix = new FXGMatrix(matrixNodeShape);
                // Get masking node matrix.
                MatrixNode matrixNodeMasking = ((GraphicContentNode)mask).matrix;
                // Create a new MatrixNode if the masking node doesn't have one.
                if (matrixNodeMasking == null)
                {
                    // Convert masking node's transform attributes to matrix
                    // so we can concatenate the shape node's matrix to it.
                    ((GraphicContentNode)mask).convertTransformAttrToMatrix(problems);
                    matrixNodeMasking = ((GraphicContentNode)mask).matrix;
                }
                FXGMatrix maskMatrix = new FXGMatrix(matrixNodeMasking);
                // Concatenate the shape node's matrix to the masking node's
                // matrix.
                maskMatrix.concat(nodeMatrix);
                // Set the masking node's matrix with the concatenated values.
                maskMatrix.setMatrixNodeValue(matrixNodeMasking);
            }
           
            markLeafNodesAsMask(node, (GroupNode) mask);
            po3 = group((GroupNode)mask);
        }
        else if (mask instanceof PlaceObjectNode)
        {
            po3 = PlaceObject3TagInstance((PlaceObjectNode)mask);
        }

        if (po3 != null)
        {
            int clipDepth = 1;
            // If we had a graphic or group, clip the depths for all children.
            if (node instanceof GroupNode)
            {
                GroupNode group = (GroupNode)node;
                if (group.children != null)
                    clipDepth = getSpriteDepth(parentSprite) + group.children.size();
            }
            else if (node instanceof GraphicNode)
            {
                GraphicNode graphic = (GraphicNode)node;
                if (graphic.children != null)
                    clipDepth = getSpriteDepth(parentSprite) + graphic.children.size();
            }
            // ... otherwise, just clip the shape itself.
            else
            {//TODO
                clipDepth = po3.getDepth() + 1;
            }

            po3.setClipDepth(clipDepth);
            po3.setHasClipDepth(true);
            if (node.getMaskType() == MaskType.ALPHA)
            {
                po3.setHasCacheAsBitmap(true);
            }
        }

        return po3;
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

    {
        List<ShapeRecord> shapeRecords = ShapeHelper.path(node, (node.fill != null), problems);
        GraphicContext context = node.createGraphicContext();
        Winding winding[] = new Winding[1];
        winding[0] = node.winding;
        PlaceObject3Tag po3 = placeDefineShapeTag(node, shapeRecords, node.fill, node.stroke, context, winding);
        return po3;
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

   
    protected PlaceObject3Tag PlaceObject3Tag(ICharacterTag symbol, GraphicContext context)
    {
        DefineSpriteTag sprite = spriteStack.peek();

        PlaceObject3Tag po3 = new PlaceObject3Tag();
        // po3.setName(name);
        po3.setCharacter(symbol);
        assert symbol != sprite;
        po3.setHasCharacter(true);
        Integer depthCount = getSpriteDepth(sprite) + 1;
       
        setSpriteDepth(sprite, depthCount);
       
        po3.setDepth(depthCount);
        if (context.blendMode != null)
        {
            if (!context.blendMode.needsPixelBenderSupport())
            {
                int blendMode = createBlendMode(context.blendMode);
                po3.setBlendMode(blendMode);
                po3.setHasBlendMode(true);
            }
            else
            {
                setPixelBenderBlendMode(po3, context.blendMode);
            }
        }
       
        if (context.filters != null)
        {
            List<Filter> filters = createFilters(context.filters);
            Filter filterArray[] = {};
            po3.setSurfaceFilterList(filters.toArray(filterArray));
            po3.setHasFilterList(true);
        }

        // FXG angles are always clockwise.
        Matrix matrix = context.getTransform().toSWFMatrix();
        po3.setMatrix(matrix);
        po3.setHasMatrix(true);
        if (context.colorTransform != null)
        {
            ColorTransformNode t = context.colorTransform;
            CXFormWithAlpha cx = TypeHelper.cxFormWithAlpha(t.alphaMultiplier, t.redMultiplier, t.greenMultiplier, t.blueMultiplier, t.alphaOffset, t.redOffset, t.greenOffset, t.blueOffset);
            po3.setColorTransform(cx);
            po3.setHasColorTransform(true);
        }

       
        if (context.maskType == MaskType.ALPHA)
        {
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

        return tag;
    }

    private PlaceObject3Tag readPlaceObject3() throws IOException, MalformedTagException
    {
        final PlaceObject3Tag tag = new PlaceObject3Tag();
        tag.setHasClipActions(bitStream.readBit());
        tag.setHasClipDepth(bitStream.readBit());
        tag.setHasName(bitStream.readBit());
        tag.setHasRatio(bitStream.readBit());
        tag.setHasColorTransform(bitStream.readBit());
        tag.setHasMatrix(bitStream.readBit());
        tag.setHasCharacter(bitStream.readBit());
        tag.setMove(bitStream.readBit());

        bitStream.readUB(3); // reserved;
        tag.setHasImage(bitStream.readBit());
        tag.setHasClassName(bitStream.readBit());
        tag.setHasCacheAsBitmap(bitStream.readBit());
        tag.setHasBlendMode(bitStream.readBit());
        tag.setHasFilterList(bitStream.readBit());

        tag.setDepth(bitStream.readUI16());
        if (tag.isHasClassName())
            tag.setClassName(bitStream.readString());
        if (tag.isHasCharacter())
            tag.setCharacter(getTagById(bitStream.readUI16(), tag.getTagType()));
        if (tag.isHasMatrix())
            tag.setMatrix(readMatrix());
        if (tag.isHasColorTransform())
            tag.setColorTransform(readColorTransformWithAlpha());
        if (tag.isHasRatio())
            tag.setRatio(bitStream.readUI16());
        if (tag.isHasName())
            tag.setName(bitStream.readString());
        if (tag.isHasClipDepth())
            tag.setClipDepth(bitStream.readUI16());
        if (tag.isHasFilterList())
        {
            final int count = bitStream.readUI8();
            final Filter[] filterList = new Filter[count];
            for (int i = 0; i < count; i++)
                filterList[i] = readFilter();
            tag.setSurfaceFilterList(filterList);
        }
        if (tag.isHasBlendMode())
            tag.setBlendMode(bitStream.readUI8());
        if (tag.isHasCacheAsBitmap())
            tag.setBitmapCache(bitStream.readUI8());

        ClipActions clipActions = new ClipActions();
        clipActions.data = bitStream.readToBoundary();
        tag.setClipActions(clipActions);
        return tag;
    }
View Full Code Here

Examples of org.apache.flex.swf.tags.PlaceObject3Tag

     */
    @Override
    protected PlaceObject3Tag mask(IMaskableNode node, DefineSpriteTag parentSprite)
    {
        IMaskingNode mask = node.getMask();
        PlaceObject3Tag po3 = super.mask(node, parentSprite);

        if (mask != null)
        {
            MaskType maskType = node.getMaskType();

            if (maskType != MaskType.CLIP)
            {
                // Record the display list position that the mask was placed.
                // The ActionScript display list is 0 based, but SWF the depth
                // counter starts at 1, so we subtract 1.
                int maskIndex = getSpriteDepth(parentSprite) - 1;
                mask.setMaskIndex(maskIndex);
            }

            if (maskType == MaskType.LUMINOSITY)
            {
                // Create a new SymbolClass to map to this mask's
                // DefineSpriteTag (see below) 
                String className = createUniqueName(graphicClass.getClassName() + "_Mask");
                FXGSymbolClass symbolClass = new FXGSymbolClass();
                symbolClass.setPackageName(packageName);
                symbolClass.setClassName(className);

                // Then record this SymbolClass with the top-level graphic
                // SymbolClass so that it will be associated with the FXG asset.
                graphicClass.addAdditionalSymbolClass(symbolClass);

                // Calculate luminosity mode
                int mode = 0;

                if (node.getLuminosityClip())
                    mode += 2;

                if (node.getLuminosityInvert())
                    mode += 1;
               
                //Add required dependencies
                addDependency(packageShaderFilter);
                addDependency(packageLuminosityMaskShader);

                StringBuilder buf = new StringBuilder(768);
                buf.append("package ").append(packageName).append("\n");
                buf.append("{\n\n");
                buf.append("import flash.display.Sprite;\n");
                buf.append("import ").append(packageShaderFilter).append(";\n");
                buf.append("import ").append(packageLuminosityMaskShader).append(";\n\n");
                buf.append("public class ").append(className).append(" extends Sprite\n");
                buf.append("{\n");
                buf.append("    public function ").append(className).append("()\n");
                buf.append("    {\n");
                buf.append("        super();\n");
                buf.append("        this.cacheAsBitmap = true;\n");
                buf.append("        var shader:LuminosityMaskShader = new LuminosityMaskShader();\n");
                buf.append("        shader.mode = ").append(mode).append(";\n");
                buf.append("        var filter:ShaderFilter = new ShaderFilter(shader);\n");
                buf.append("        this.filters = [filter.clone()];\n");
                buf.append("    }\n");
                buf.append("}\n"); // End class
                buf.append("}\n"); // End package

                symbolClass.setGeneratedSource(buf.toString());
                symbolClass.setSymbol(po3.getCharacter());
            }
        }

        return po3;
    }
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.