Package flash.swf.tags

Examples of flash.swf.tags.DefineSprite


     * {@inheritDoc}
     */
    public Object transcode(FXGNode fxgNode)
    {
        GraphicNode node = (GraphicNode)fxgNode;
        DefineSprite sprite = createDefineSprite("Graphic");
        spriteStack.push(sprite);

        // Process mask (if present)
        if (node.mask != null)
            mask(node, sprite);
View Full Code Here


        List<FilterNode> filters = null;
        if (context.filters != null)      
        {  
            filters = context.filters;
            context.filters = null;
            DefineSprite filterSprite = createDefineSprite("MaskFilter");
            spriteStack.push(filterSprite);
        }
       
        DefineSprite imageSprite = createDefineSprite("BitmapGraphic");
        spriteStack.push(imageSprite);

        // First, generate the clipping mask
        DefineSprite clipSprite = createDefineSprite("BitmapGraphic_Clip");
        spriteStack.push(clipSprite);
        double width = (imageTag.width < node.width) ? imageTag.width : node.width;
        double height = (imageTag.height < node.height) ? imageTag.height : node.height;
        List<ShapeRecord> shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);
        DefineShape clipShape = createDefineShape(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
        placeObject(clipShape, new GraphicContext());
        spriteStack.pop();
       
        //place the clipping mask in the imageSprite
        PlaceObject po3clip = placeObject(clipSprite, context);
        po3clip.setClipDepth(po3clip.depth+1);
       
        // Then, process the image
        DefineShape imageShape = ImageHelper.createShapeForImage(imageTag, node);
        placeObject(imageShape, context);       
        spriteStack.pop();
       
        PlaceObject po3 = placeObject(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)
        {
            DefineSprite sprite = spriteStack.pop();   
            GraphicContext gc = new GraphicContext();
            gc.filters = filters;
            PlaceObject poFilter = placeObject(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;
                    DefineSprite filterSprite = createDefineSprite("MaskFilter");
                    spriteStack.push(filterSprite);
                }
                DefineSprite 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 = placeObjectInstance((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)
            {
                DefineSprite sprite = spriteStack.pop();   
                GraphicContext gc = new GraphicContext();
                gc.filters = filters;
                PlaceObject poFilter = placeObject(sprite, gc);
                return poFilter;           
            }
View Full Code Here

          }
         
         
        }
       
        DefineSprite groupSprite = createDefineSprite("Group");
        GraphicContext context = node.createGraphicContext();
       
        // Handle 'scale 9' grid definition
        if (node.definesScaleGrid())
        {
            DefineScalingGrid grid = createDefineScalingGrid(context.scalingGrid);
            grid.scalingTarget = groupSprite;
            groupSprite.scalingGrid = grid;
        }

        PlaceObject po3 = placeObject(groupSprite, context);
        spriteStack.push(groupSprite);

        // First, process mask (if present)
        List <FilterNode> 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)      
            {   
                DefineSprite filterSprite = createDefineSprite("MaskFilter");
                spriteStack.push(filterSprite);
            }
            DefineSprite 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)
        {
            DefineSprite sprite = spriteStack.pop();   
            GraphicContext gc = new GraphicContext();
            gc.filters = filters;
            PlaceObject poFilter = placeObject(sprite, gc);
            return poFilter;           
        }
View Full Code Here

      
    }
   
    protected PlaceObject placeObject(DefineTag symbol, GraphicContext context)
    {
        DefineSprite sprite = spriteStack.peek();

        PlaceObject po3 = new PlaceObject(Tag.stagPlaceObject3);
        // po3.setName(name);
        po3.setRef(symbol);
        po3.depth = ++sprite.depthCounter;
View Full Code Here

        String definitionName = node.getNodeName();

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

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

        return scalingGrid;
    }

    protected DefineSprite createDefineSprite(String name)
    {
        DefineSprite sprite = new DefineSprite();
        sprite.tagList = new TagList();
        sprite.framecount = 1;
        if (name == null) name = "";
        sprite.name = name + random.nextInt();
        return sprite;
View Full Code Here

            List<FilterNode> filters = null;
            if (context.filters != null)      
            {  
                filters = context.filters;
                context.filters = null;
                DefineSprite filterSprite = createDefineSprite("MaskFilter");
                spriteStack.push(filterSprite);
            }

            DefineSprite imageSprite = createDefineSprite("BitmapFill");
            spriteStack.push(imageSprite);

            // First, generate the clipping mask
            DefineSprite clipSprite = createDefineSprite("BitmapFill_Clip");
            spriteStack.push(clipSprite);
            List<ShapeRecord> clipRectRecords = ShapeHelper.rectangle(0.0, 0.0, imageTag.width, imageTag.height);
            DefineShape clipShape = createDefineShape(null, clipRectRecords, new SolidColorFillNode(), null, context.getTransform());
            FXGMatrix bitmapMatrix = TypeHelper.bitmapFillMatrix(fillNode, imageTag, edgeBounds);
            FXGMatrix clipMatrix = new FXGMatrix(bitmapMatrix.a, bitmapMatrix.b, bitmapMatrix.c, bitmapMatrix.d, 0, 0);
            clipMatrix.scale(1.0/SwfConstants.TWIPS_PER_PIXEL, 1.0/SwfConstants.TWIPS_PER_PIXEL);
            clipMatrix.translate(bitmapMatrix.tx, bitmapMatrix.ty);
            GraphicContext clipContext = new GraphicContext();
            clipContext.setTransform(clipMatrix);
            placeObject(clipShape, clipContext);
            spriteStack.pop();
           
            // Set the depth of the mask to that of the bitmap image fill
            clipContext.setTransform(context.getTransform());
            PlaceObject po3clip = placeObject(clipSprite, clipContext);
            po3clip.setClipDepth(po3clip.depth+1);
           
            // Then, process the bitmap image fill
            ShapeWithStyle sws = new ShapeWithStyle();
            sws.shapeRecords = shapeRecords;
            int lineStyleIndex = 0;
            int fillStyle0Index = 1;
            int fillStyle1Index = 0;
            if (windings.length > 0)
                ShapeHelper.setPathStyles(shapeRecords, lineStyleIndex, fillStyle0Index, fillStyle1Index);
            else
                ShapeHelper.setStyles(shapeRecords, lineStyleIndex, fillStyle0Index, fillStyle1Index);

            FillStyle fillStyle = createFillStyle(fill, edgeBounds);
            sws.fillstyles = new ArrayList<FillStyle>(1);
            sws.fillstyles.add(fillStyle);
           
            DefineShape imageShape = new DefineShape(Tag.stagDefineShape4);
            imageShape.shapeWithStyle = sws;
            imageShape.bounds = edgeBounds;
            imageShape.edgeBounds = edgeBounds;
            if ((fill != null) &&( windings.length > 0))
            {
                Winding windingValue = windings[0];
                imageShape.usesFillWindingRule = (windingValue == Winding.NON_ZERO);
            }
            PlaceObject po3 = placeObject(imageShape, context);       
            
            if (stroke != null)
            {
                //make a copy of ShapeRecord for strokes
                ArrayList<ShapeRecord> shapeRecords2 = new ArrayList<ShapeRecord>(shapeRecords);
                Collections.copy(shapeRecords2, shapeRecords);

                //generate the define sprite for the stroke object with no clipping
                ShapeWithStyle swsStroke = new ShapeWithStyle();
                swsStroke.shapeRecords = shapeRecords2;
   
                lineStyleIndex = 1;
                fillStyle0Index = 0;
                fillStyle1Index = 0;
                ShapeHelper.replaceStyles(shapeRecords2, lineStyleIndex, fillStyle0Index, fillStyle1Index);

                // 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.linestyles = new ArrayList<LineStyle>(1);
                swsStroke.linestyles.add(lineStyle);

                DefineShape strokeShape = new DefineShape(Tag.stagDefineShape4);
                strokeShape.shapeWithStyle = swsStroke;
                strokeShape.bounds = shapeBounds;
                strokeShape.edgeBounds = edgeBounds;
                po3 = placeObject(strokeShape, context);   
            }            
            spriteStack.pop();

            po3 = placeObject(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)
            {
                DefineSprite sprite = spriteStack.pop();   
                GraphicContext gc = new GraphicContext();
                gc.filters = filters;
                PlaceObject poFilter = placeObject(sprite, gc);
                return poFilter;           
            }
View Full Code Here

        tagHandler.defineShape3(tag);
    }

    public void DefineSprite(Attributes attributes) throws SAXParseException
    {
        DefineSprite sprite = new DefineSprite();
        int id = parseInt(getAttribute(attributes, "id"));
        createCharacter(id, sprite);
        stack.push(sprite);
        this.sprite = sprite;
    }
View Full Code Here

        this.sprite = sprite;
    }

    public void DefineSprite()
    {
        DefineSprite sprite = (DefineSprite)stack.pop();
        this.sprite = null;
        tagHandler.defineSprite(sprite);
    }
View Full Code Here

TOP

Related Classes of flash.swf.tags.DefineSprite

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.