Package flash.swf.types

Examples of flash.swf.types.Rect


     * @param height The height of the rectangle in pixels.
     * @return A SWF Rect type representing the implied rectangle.
     */
    public static Rect rect(double width, double height)
    {
        Rect rect = new Rect();
        rect.xMax = (int)(width * SwfConstants.TWIPS_PER_PIXEL);
        rect.yMax = (int)(height * SwfConstants.TWIPS_PER_PIXEL);
        return rect;
    }
View Full Code Here


      
            DefineShape 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);
                PlaceObject po3 = placeObject(imageShape, context);
                return po3;
            }
            else
View Full Code Here

    protected DefineShape createDefineShape(AbstractShapeNode node, List<ShapeRecord> shapeRecords, FillNode fill,
            StrokeNode stroke, FXGMatrix transform, Winding... windings)
    {
        // Calculate the bounds of the shape outline (without strokes) - edgeBounds
        Rect edgeBounds = (node == null) ? ShapeHelper.getBounds(shapeRecords, null, (AbstractStrokeNode)stroke) : node.getBounds(shapeRecords, null);
       
        Rect shapeBounds;

        ShapeWithStyle sws = new ShapeWithStyle();
        sws.shapeRecords = shapeRecords;

        int lineStyleIndex = stroke == null ? 0 : 1;
View Full Code Here

             */
           
            BitmapFillNode fillNode = (BitmapFillNode) fill;

            // Calculate the bounds of the shape outline (without strokes)
            Rect edgeBounds = node.getBounds(shapeRecords, null);          
           
            String source = parseSource(fillNode.source);
            if (source == null)
            {
                // Exception: Missing source attribute in <BitmapGraphic> or <BitmapFill>.
                throw new FXGException(fill.getStartLine(), fill.getStartColumn(), "MissingSourceAttribute");
            }
            DefineBits imageTag = createDefineBits(fill, source);

            //process the filters later to avoid masking
            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);

View Full Code Here

            y1 = y1 - stroke;
            x2 = x2 + stroke;
            y2 = y2 + stroke;
        }
        return new Rect(x1, x2, y1, y2);
    }
View Full Code Here

    private Rect decodeRect() throws IOException
    {
        r.syncBits();

        Rect rect = new Rect();

        int nBits = r.readUBits(5);
        rect.xMin = r.readSBits(nBits);
        rect.xMax = r.readSBits(nBits);
        rect.yMin = r.readSBits(nBits);
View Full Code Here

    }

    private Rect parseRect(String s)
    {
        String[] parts = StringUtils.split(s, "x");
        return new Rect(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]));
    }
View Full Code Here

        builder.correctRoundingErrors();
        sws.shapeRecords = builder.build().shapeRecords;

        // Wrap up into a SWF DefineShape Tag
        DefineShape defineShape = new DefineShape(Tag.stagDefineShape3);
        defineShape.bounds = new Rect(width * SwfConstants.TWIPS_PER_PIXEL, height * SwfConstants.TWIPS_PER_PIXEL);
        defineShape.shapeWithStyle = sws;

        return defineShape;
    }
View Full Code Here

        if (y1 > Integer.MAX_VALUE)
            y1 = 0;
        if (y2 > Integer.MAX_VALUE)
            y2 = 0;

        tag.bounds = new Rect((int)x1, (int)x2, (int)y1, (int)y2);
    }
View Full Code Here

        if (y1 > Integer.MAX_VALUE)
            y1 = 0;
        if (y2 > Integer.MAX_VALUE)
            y2 = 0;

        tag.bounds = new Rect((int)x1, (int)x2, (int)y1, (int)y2);
    }
View Full Code Here

TOP

Related Classes of flash.swf.types.Rect

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.