Package org.apache.flex.swf.tags

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


        graphicClass = new FXGSymbolClass();
        graphicClass.setPackageName(packageName);
        graphicClass.setClassName(className);
       
        GraphicNode node = (GraphicNode)fxgNode;
        DefineSpriteTag sprite = createDefineSpriteTag("Graphic");
        spriteStack.push(sprite);
       
        // Process mask (if present)
        if (node.mask != null)
            mask(node, sprite);
View Full Code Here


        List<IFilterNode> filters = null;
        if (context.filters != null)      
        {  
            filters = context.filters;
            context.filters = null;
            DefineSpriteTag filterSprite = createDefineSpriteTag("MaskFilter");
            spriteStack.push(filterSprite);
        }
       
        DefineSpriteTag imageSprite = createDefineSpriteTag("BitmapGraphic");
        spriteStack.push(imageSprite);
       
        // First, generate the clipping mask
        DefineSpriteTag clipSprite = createDefineSpriteTag("BitmapGraphic_Clip");
        spriteStack.push(clipSprite);
       
        double width = (defImage.getWidth() < node.width) ? defImage.getWidth() : node.width;
        double height = (defImage.getHeight() < node.height) ? defImage.getHeight() : node.height;
        List<ShapeRecord> shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);
        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;           
        }
View Full Code Here

                // 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;           
            }
View Full Code Here

            node.blendMode = BlendMode.NORMAL;
          else
            node.blendMode = BlendMode.LAYER;
        }
       
        DefineSpriteTag groupSprite = createDefineSpriteTag("Group");
        GraphicContext context = node.createGraphicContext();
       
        // Handle 'scale 9' grid definition
        if (node.definesScaleGrid())
        {
            DefineScalingGridTag grid = createDefineScalingGridTag(context.scalingGrid);
            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;           
        }
View Full Code Here

      
    }
   
    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)
        {
            setAlphaMask(po3);
        }
        else if (context.maskType == MaskType.LUMINOSITY)
        {
            setLuminosityMask(po3);
        }
        sprite.getControlTags().add(po3);
        return po3;
    }
View Full Code Here

        String definitionName = node.getNodeName();

        if (definitions == null)
            definitions = new HashMap<String, DefineSpriteTag>();

        DefineSpriteTag definitionSprite = definitions.get(definitionName);
        if (definitionSprite == null)
        {
            definitionSprite = createDefineSpriteTag("Definition");
            FXG2SWFTranscoder graphics = newInstance();
            graphics.setResourceResolver(resourceResolver);
View Full Code Here

        return scalingGrid;
    }

    protected DefineSpriteTag createDefineSpriteTag(String name)
    {
        DefineSpriteTag sprite = new DefineSpriteTag(0, new ArrayList<ITag>());
        if (name == null)
            name = "";
        return sprite;
    }
View Full Code Here

            List<IFilterNode> filters = null;
            if (context.filters != null)      
            {  
                filters = context.filters;
                context.filters = null;
                DefineSpriteTag filterSprite = createDefineSpriteTag("MaskFilter");
                spriteStack.push(filterSprite);
            }

            DefineSpriteTag imageSprite = createDefineSpriteTag("BitmapFill");
            spriteStack.push(imageSprite);
           
            // First, generate the clipping mask
            DefineSpriteTag clipSprite = createDefineSpriteTag("BitmapFill_Clip");
            spriteStack.push(clipSprite);
           
            List<ShapeRecord> clipRectRecords = ShapeHelper.rectangle(0.0, 0.0, defImage.getWidth(), defImage.getHeight());
            DefineShapeTag clipShape = createDefineShapeTag(null, clipRectRecords, new SolidColorFillNode(), null, context.getTransform());
            FXGMatrix bitmapMatrix = TypeHelper.bitmapFillMatrix(fillNode, defImage, edgeBounds);
            FXGMatrix clipMatrix = new FXGMatrix(bitmapMatrix.a, bitmapMatrix.b, bitmapMatrix.c, bitmapMatrix.d, 0, 0);
            clipMatrix.scale(1.0/ISWFConstants.TWIPS_PER_PIXEL, 1.0/ISWFConstants.TWIPS_PER_PIXEL);
            clipMatrix.translate(bitmapMatrix.tx, bitmapMatrix.ty);
            GraphicContext clipContext = new GraphicContext();
            clipContext.setTransform(clipMatrix);
            PlaceObject3Tag(clipShape, clipContext);
            spriteStack.pop();
           
            // Set the depth of the mask to that of the bitmap image fill
            clipContext.setTransform(context.getTransform());
            PlaceObject3Tag po3clip = PlaceObject3Tag(clipSprite, clipContext);
            po3clip.setClipDepth(po3clip.getDepth() + 1);
            po3clip.setHasClipDepth(true);
           
            Styles styles = new Styles(new FillStyleArray(), new LineStyleArray());
            // Then, process the bitmap image fill
            ShapeWithStyle sws = new ShapeWithStyle(styles);
           
            int lineStyleIndex = 0;
            int fillStyle0Index = 1;
            int fillStyle1Index = 0;

            FillStyle fillStyle = createFillStyle(fill, edgeBounds);
            if(fillStyle != null)
                sws.getFillStyles().add(fillStyle);

            if (windings.length > 0)
                ShapeHelper.setPathStyles(shapeRecords, lineStyleIndex, fillStyle0Index, fillStyle1Index, styles);
            else
                ShapeHelper.setStyles(shapeRecords, lineStyleIndex, fillStyle0Index, fillStyle1Index, styles);
           
            sws.addShapeRecords(shapeRecords);
           
            DefineShape4Tag imageShape = new DefineShape4Tag();
            imageShape.setShapes(sws);
            imageShape.setShapeBounds(edgeBounds);
            imageShape.setEdgeBounds(edgeBounds);
            if ((fill != null) &&( windings.length > 0))
            {
                Winding windingValue = windings[0];
                imageShape.setUsesFillWindingRule(windingValue == Winding.NON_ZERO);
            }
            PlaceObject3Tag po3 = PlaceObject3Tag(imageShape, context);       
            
            if (stroke != null)
            {
                //make a copy of ShapeRecord for strokes
                ArrayList<ShapeRecord> shapeRecords2 = new ArrayList<ShapeRecord>(shapeRecords);
                Collections.copy(shapeRecords2, shapeRecords);

                Styles strokeStyles = new Styles(new FillStyleArray(), new LineStyleArray());

                //generate the define sprite for the stroke object with no clipping
                ShapeWithStyle swsStroke = new ShapeWithStyle(strokeStyles);

                // Consider linestyle stroke widths with bounds calculation              
                AbstractStrokeNode strokeNode = (AbstractStrokeNode) stroke;
                LineStyle ls = createGenericLineStyle(strokeNode);
                Rect shapeBounds =  node.getBounds(shapeRecords2, ls);    
               
                LineStyle lineStyle = createLineStyle(stroke, shapeBounds);
                swsStroke.getLineStyles().add(lineStyle);
               
                lineStyleIndex = 1;
                fillStyle0Index = 0;
                fillStyle1Index = 0;
                ShapeHelper.replaceStyles(shapeRecords2, lineStyleIndex, fillStyle0Index, fillStyle1Index, strokeStyles);
        
                swsStroke.addShapeRecords(shapeRecords2);

                DefineShape4Tag strokeShape = new DefineShape4Tag();
                strokeShape.setShapes(swsStroke);
                strokeShape.setShapeBounds(shapeBounds);
                strokeShape.setEdgeBounds(edgeBounds);
                po3 = PlaceObject3Tag(strokeShape, context);   
            }            
            spriteStack.pop();
           
            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;           
View Full Code Here

    private boolean modifyTagsForEmbedding(ICharacterTag tag)
    {
        boolean tagsModified = false;
        if (tag instanceof DefineSpriteTag)
        {
            DefineSpriteTag spriteTag = (DefineSpriteTag)tag;
            for (ITag controlTag : spriteTag.getControlTags())
            {
                if (controlTag instanceof PlaceObject2Tag)
                {
                    PlaceObject2Tag placeObject = (PlaceObject2Tag)controlTag;
                    if (placeObject.isHasClipActions())
View Full Code Here

                spriteTags.add(spriteTag);
        }
        while (spriteTag == null || spriteTag.getTagType() != TagType.End);

        bitStream.setReadBoundary(boundary);
        DefineSpriteTag sprite = new DefineSpriteTag(frameCount, spriteTags);
        sprite.setCharacterID(spriteId);
        return sprite;
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.swf.tags.DefineSpriteTag

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.