Package org.apache.flex.swf.tags

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


        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());
       
View Full Code Here


            return null;
       
        if ((node.visible) && (!node.isPartofClipMask))
        {
      
            DefineShapeTag imageShape;
            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

            // 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;           
            }
           
            return po3;
           
        }
        else
        {
          DefineShapeTag shape = createDefineShapeTag(node, shapeRecords, fill, stroke, context.getTransform(), windings);
          PlaceObject3Tag po3 = PlaceObject3Tag(shape, context);
          return po3;
        }
      
    }
View Full Code Here

     * @throws MalformedTagException
     * @see SWFWriter#writeDefineShape
     */
    private DefineShapeTag readDefineShape() throws IOException, MalformedTagException
    {
        final DefineShapeTag tag = new DefineShapeTag();
        tag.setCharacterID(bitStream.readUI16());
        tag.setShapeBounds(readRect());
        final ShapeWithStyle shapeWithStyle = readShapeWithStyle(TagType.DefineShape);
        tag.setShapes(shapeWithStyle);
        return tag;
    }
View Full Code Here

    }

    private DefineSpriteTag buildSlicedSprite(DefineBitsTag image, int width, int height, Collection<ITag> tags, Collection<ICompilerProblem> problems)
    {
        DefineScalingGridTag scalingGrid = buildScalingGrid();
        DefineShapeTag shape = buildSlicedShape(image, scalingGrid.getSplitter(), width, height);
        return buildSprite(image, shape, scalingGrid, tags);
    }
View Full Code Here

        return buildSprite(image, shape, scalingGrid, tags);
    }

    private DefineSpriteTag buildSmoothingSprite(DefineBitsTag image, int width, int height, Collection<ITag> tags, Collection<ICompilerProblem> problems)
    {
        DefineShapeTag shape = buildSmoothingShape(image, width, height);
        return buildSprite(image, shape, null, tags);
    }
View Full Code Here

        return shape;
    }

    private DefineShapeTag buildSmoothingShape(DefineBitsTag image, int width, int height)
    {
        DefineShapeTag shape = new DefineShapeTag();

        Rect bounds = new Rect(0, width, 0, height);
        shape.setShapeBounds(bounds);

        final FillStyleArray fillStyles = new FillStyleArray();
        final LineStyleArray lineStyles = new LineStyleArray();
        Styles styles = new Styles(fillStyles, lineStyles);
        ShapeWithStyle shapeWithStyle = new ShapeWithStyle(styles);
        shape.setShapes(shapeWithStyle);

        // translate into source bitmap
        Matrix tsm = new Matrix();
        // unity in twips
        tsm.setScale(ISWFConstants.TWIPS_PER_PIXEL, ISWFConstants.TWIPS_PER_PIXEL);
View Full Code Here

TOP

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

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.