Package org.apache.flex.swf.types

Examples of org.apache.flex.swf.types.Rect


     */
    public static Rect rect(double width, double height)
    {
        int xMax = (int)(width * ISWFConstants.TWIPS_PER_PIXEL);
        int yMax = (int)(height * ISWFConstants.TWIPS_PER_PIXEL);
        Rect rect = new Rect(0, xMax, 0, yMax);
        return rect;
    }
View Full Code Here


    private DefineShapeTag buildSlicedShape(DefineBitsTag image, Rect r, int width, int height)
    {
        DefineShape4Tag shape = new DefineShape4Tag();

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

        FillStyleArray fillStyles = new FillStyleArray();
        LineStyleArray lineStyles = new LineStyleArray();
View Full Code Here

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

        return result;
    }

    protected DefineScalingGridTag buildScalingGrid()
    {
        Rect rect = new Rect(scaleGridLeft, scaleGridRight, scaleGridTop, scaleGridBottom);
        DefineScalingGridTag scalingGrid = new DefineScalingGridTag();
        scalingGrid.setSplitter(rect);
        return scalingGrid;
    }
View Full Code Here

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

    protected DefineShapeTag createDefineShapeTag(AbstractShapeNode node, List<ShapeRecord> shapeRecords, IFillNode fill,
            IStrokeNode 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;

       
        int lineStyleIndex = stroke == null ? 0 : 1;
        int fillStyle0Index = fill == null ? 0 : 1;
        int fillStyle1Index = 0;
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)
            {
                // Missing source attribute in <BitmapGraphic> or <BitmapFill>.
                problems.add(new FXGMissingAttributeProblem(node.getDocumentPath(), node.getStartLine(),
                        node.getStartColumn(), FXGConstants.FXG_SOURCE_ATTRIBUTE, node.getNodeName()));
                return null;
            }
            DefineImage defImage = createDefineBitsTag(fill, source);
            if(defImage == null)
                return null;

            //process the filters later to avoid masking
            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;
View Full Code Here

    public static Rect getBounds(List<ShapeRecord> records, LineStyle ls, AbstractStrokeNode strokeNode)
    {
        if (records == null || records.size() == 0)
        {
            assert false: "null records";
            return new Rect(0,0);
        }
        int x1 = 0;
        int y1 = 0;
        int x2 = 0;
        int y2 = 0;
        int x = 0;
        int y = 0;
        boolean firstMove = true;

        Iterator<ShapeRecord> iterator = records.iterator();
        while (iterator.hasNext())
        {
            ShapeRecord r = iterator.next();

            if (r == null)
                continue;

            if (r instanceof StyleChangeRecord)
            {
                StyleChangeRecord scr = (StyleChangeRecord)r;
                x = scr.getMoveDeltaX();
                y = scr.getMoveDeltaY();
                scr.setMove(x, y);
               
                if (firstMove)
                {
                    x1 = x;
                    y1 = y;
                    x2 = x;
                    y2 = y;
                    firstMove = false;
                }
            }
            else if (r instanceof StraightEdgeRecord)
            {
                StraightEdgeRecord ser = (StraightEdgeRecord)r;
                x = x + ser.getDeltaX();
                y = y + ser.getDeltaY();
            }
            else if (r instanceof CurvedEdgeRecord)
            {
                CurvedEdgeRecord cer = (CurvedEdgeRecord)r;
               
                Rect currRect = new Rect(x1, x2, y1, y2);
                if (!curveControlPointInsideCurrentRect(x, y, cer, currRect))
                {               
                  Rect curvBounds = computeCurveBounds(x, y, cer);
               
                  if (curvBounds.xMin() < x1) x1 = curvBounds.xMin();
                  if (curvBounds.yMin() < y1) y1 = curvBounds.yMin();
                  if (curvBounds.xMax() > x2) x2 = curvBounds.xMax();
                  if (curvBounds.yMax() > y2) y2 = curvBounds.yMax();
                }
                               
                x = x + cer.getControlDeltaX() + cer.getAnchorDeltaX();
                y = y + cer.getControlDeltaY() + cer.getAnchorDeltaY();
            }

            //update x1, y1 to min values and x2, y2 to max values
            if (x < x1) x1 = x;
            if (y < y1) y1 = y;
            if (x > x2) x2 = x;
            if (y > y2) y2 = y;
        }
       
        Rect newRect = new Rect(x1, x2, y1, y2);

        if (ls == null)
        {
            return newRect;
        }
       
        // Inflate the bounding box from all sides with half of the stroke
        // weight - pathBBox.inflate(weight/2, weight/2).
        Rect strokeExtents = getStrokeExtents(strokeNode, ls);

        newRect = new Rect(newRect.xMin() - strokeExtents.xMax(), newRect.xMax() + strokeExtents.xMax(),
                newRect.yMin() - strokeExtents.yMax(), newRect.yMax() + strokeExtents.yMax());
       
       
        // If there are less than two segments, then or joint style is not
        //"miterLimit" finish - return pathBBox.
        if (ls instanceof LineStyle2)
        {
            if (records.size() < 2 || ls == null || ((LineStyle2)ls).getJoinStyle() != LineStyle2.JS_MITER_JOIN)
            {
              return newRect;
            }
        }
        // Use strokeExtents to get the transformed stroke weight.
        double halfWeight = (strokeExtents.xMax() - strokeExtents.xMin())/2.0;  
        newRect = addJoint2Bounds(records, ls, strokeNode, halfWeight, newRect);
        return newRect;
    }
View Full Code Here

        return newRect;
    }
   
    public static Rect addJoint2Bounds(List<ShapeRecord> records, LineStyle ls, AbstractStrokeNode stroke, double halfWeight, Rect pathBBox)
    {
        Rect newRect = pathBBox;
        int count = records.size();
      int start = 0;
      int end = 0;
      int lastMoveX = 0;
      int lastMoveY = 0;
View Full Code Here

        {
            // 180 degrees, nothing to contribute
            return pathBBox;
        }
  
        Rect newRect = pathBBox;
        // Is there miter limit at play?
        if (sinHalfAlpha == 0 || miterLimit < 1 / sinHalfAlpha)
        {
            // The miter limit is reached. Calculate two extra points that may
            // contribute to the bounds.
View Full Code Here

TOP

Related Classes of org.apache.flex.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.