Package org.apache.flex.swf.types

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


     * @throws MalformedTagException
     * @throws RuntimeException if the FillStyle is invalid.
     */
    private FillStyle readStandardFillStyle(TagType tagType) throws MalformedTagException
    {
        final FillStyle s = new FillStyle();
        final int type = bitStream.readUI8();
        s.setFillStyleType(type);

        switch (type)
        {
            case FillStyle.SOLID_FILL:
                switch (tagType)
                {
                    case DefineShape3:
                    case DefineShape4:
                        s.setColor(readRGBA());
                        break;
                    case DefineShape2:
                    case DefineShape:
                        s.setColor(readRGB());
                        break;
                    default:
                        throw new IllegalArgumentException("Invalid tag: " + tagType);
                }
                break;
            case FillStyle.LINEAR_GRADIENT_FILL:
            case FillStyle.RADIAL_GRADIENT_FILL:
                s.setGradientMatrix(readMatrix());
                s.setGradient(readGradient(tagType));
                break;
            case FillStyle.FOCAL_RADIAL_GRADIENT_FILL:
                s.setGradientMatrix(readMatrix());
                s.setGradient(readFocalGradient(tagType));
                break;
            case FillStyle.REPEATING_BITMAP_FILL: // 0x40 tiled bitmap fill
            case FillStyle.CLIPPED_BITMAP_FILL: // 0x41 clipped bitmap fill
            case FillStyle.NON_SMOOTHED_REPEATING_BITMAP: // 0x42 tiled non-smoothed fill
            case FillStyle.NON_SMOOTHED_CLIPPED_BITMAP: // 0x43 clipped non-smoothed fill
                final int idref = bitStream.readUI16();
                s.setBitmapCharacter(getTagById(idref, tagType));
                s.setBitmapMatrix(readMatrix());
                break;
            default:
                problems.add(new SWFUnknownFillStyleProblem(type, false, swfPath, bitStream.getOffset()));
                throw new MalformedTagException();
        }
View Full Code Here


        // Create Fill Style
        Matrix matrix = new Matrix();
        double twx = (ISWFConstants.TWIPS_PER_PIXEL);
        matrix.setScale(twx, twx);
       
        FillStyle fs = null;
        if (fileVersion.equalTo(FXGVersion.v1_0))
        {
          if (repeat)
            fs = new FillStyle(FillStyle.REPEATING_BITMAP_FILL, matrix, image.getTag());
          else
            fs = new FillStyle(FillStyle.CLIPPED_BITMAP_FILL, matrix, image.getTag());
        }
        else
        {
          if (fillMode.equals(FillMode.REPEAT))
          {
            fs = new FillStyle(FillStyle.REPEATING_BITMAP_FILL, matrix, image.getTag());
          }
          else if (fillMode.equals(FillMode.CLIP))
          {
            fs = new FillStyle(FillStyle.CLIPPED_BITMAP_FILL, matrix, image.getTag());
          }
          else if (fillMode.equals(FillMode.SCALE))
          {
            //override the scale for matrix
              double fwidth = (width*ISWFConstants.TWIPS_PER_PIXEL)/(double)image.getWidth();
              double fheight = (height*ISWFConstants.TWIPS_PER_PIXEL)/(double)image.getHeight();
               
              //For consistency with the 4.5.1 snapshot of the flex compiler.
              fwidth = ((double)StrictMath.rint(0x10000 * fwidth))/((double)0x10000);
              fheight = ((double)StrictMath.rint(0x10000 * fheight))/((double)0x10000);
             
              matrix.setScale(fwidth, fheight);
           
            //fill style does not matter much since the entire area is filled with bitmap
            fs = new FillStyle(FillStyle.CLIPPED_BITMAP_FILL, matrix, image.getTag());
          }
        }

        // Apply Fill Styles
        FillStyleArray styleArray = new FillStyleArray();
View Full Code Here

        matrix.setScale(twx, twx);
       
        // Create 9 identical fillstyles as a work around
        for (int i = 0; i < 9; i++)
        {
            FillStyle fs = new FillStyle(FillStyle.NON_SMOOTHED_REPEATING_BITMAP, matrix, bitmap.getTag());
            fillStyleArray.add(fs);
        }
        Styles styles = new Styles(fillStyleArray, lineStyleArray);
       
        int dxa = slt;
View Full Code Here

        // 9 identical fillstyles to fool things
        // not sure why this is needed, and why we're indexing into
        // the into, as the values are identical.  Was ported over from hero.
        for (int i = 0; i < 9; ++i)
        {
            FillStyle fs = new FillStyle();
            fs.setBitmapCharacter(image);
            fs.setBitmapMatrix(tsm);
            fs.setFillStyleType(FillStyle.NON_SMOOTHED_REPEATING_BITMAP);
            fillStyles.add(fs);
        }

        int slt = r.xMin();
        int srt = r.xMax();
View Full Code Here

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

        FillStyle fs = new FillStyle();
        fs.setBitmapCharacter(image);
        fs.setBitmapMatrix(tsm);
        fs.setFillStyleType(FillStyle.CLIPPED_BITMAP_FILL);
        fillStyles.add(fs);

        StyleChangeRecord startStyle = new StyleChangeRecord();
        // We use fillstyle1, because it matches what FlashAuthoring generates.
        startStyle.setDefinedStyles(null, fs, null, styles);
View Full Code Here

       
        FillStyleArray fillStyles = new FillStyleArray(1);
        LineStyleArray lineStyles = new LineStyleArray();
        if (fill != null)
        {
            FillStyle fillStyle = createFillStyle(fill, edgeBounds);
            if(fillStyle != null)
                fillStyles.add(fillStyle);
        }

        if (stroke != null)
View Full Code Here

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

            return null;
    }

    protected FillStyle createFillStyle(SolidColorFillNode fill)
    {
        FillStyle fs = new FillStyle();
        fs.setColor(TypeHelper.splitColor(TypeHelper.colorARGB(fill.color, fill.alpha)));
        fs.setFillStyleType(FillStyle.SOLID_FILL);
        return fs;
    }
View Full Code Here

        return fs;
    }

    protected FillStyle createFillStyle(BitmapFillNode fill, Rect bounds)
    {
        FillStyle fs = new FillStyle();
       
        if (ImageHelper.bitmapFillModeIsRepeat(fill))
            fs.setFillStyleType(FillStyle.REPEATING_BITMAP_FILL);
        else
            fs.setFillStyleType(FillStyle.CLIPPED_BITMAP_FILL);

        String sourceFormatted = parseSource(fill.source);
       
        if (sourceFormatted == null)
        {
            // Source is required after FXG 1.0
            // Missing source attribute in <BitmapGraphic> or <BitmapFill>.
            problems.add(new FXGMissingAttributeProblem(fill.getDocumentPath(), fill.getStartLine(),
                    fill.getStartColumn(), FXGConstants.FXG_SOURCE_ATTRIBUTE, fill.getNodeName()));
            return null;
        }

        DefineImage img = createDefineBitsTag(fill, sourceFormatted);
        if(img != null)
        {
            fs.setBitmapCharacter(img.getTag());
       
            fs.setBitmapMatrix(TypeHelper.bitmapFillMatrix(fill, img, bounds).toSWFMatrix());
        }
        return fs;
    }
View Full Code Here

        return fs;
    }

    protected FillStyle createFillStyle(LinearGradientFillNode node, Rect bounds)
    {
        FillStyle fs = new FillStyle();
        fs.setFillStyleType(FillStyle.LINEAR_GRADIENT_FILL);
        fs.setGradientMatrix(TypeHelper.linearGradientMatrix(node, bounds));
        Gradient gradient = new Gradient();
        populateGradient(gradient, node.entries, node.interpolationMethod, node.spreadMethod);
        fs.setGradient(gradient);

        return fs;
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.swf.types.FillStyle

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.