Package org.apache.flex.swf.types

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


        for (ShapeRecord shape : shapes.getShapeRecords())
        {
            indent();
            if (shape instanceof StyleChangeRecord)
            {
                StyleChangeRecord styleChange = (StyleChangeRecord)shape;
                out.print("<styleChange ");
                if (styleChange.isStateMoveTo())
                {
                    out.print("dx=\"" + styleChange.getMoveDeltaX() + "\" dy=\"" +
                              styleChange.getMoveDeltaY() + "\" ");
                }
                if (styleChange.isStateFillStyle0())
                {
                    out.print("fillStyle0=\"" +
                              (styles.getFillStyles().indexOf(styleChange.getFillstyle0()) + 1) + "\" ");
                }
                if (styleChange.isStateFillStyle1())
                {
                    out.print("fillStyle1=\"" +
                              (styles.getFillStyles().indexOf(styleChange.getFillstyle1()) + 1) + "\" ");
                }
                if (styleChange.isStateLineStyle())
                {
                    out.print("lineStyle=\"" +
                              (styles.getFillStyles().indexOf(styleChange.getLinestyle()) + 1) + "\" ");
                }
                if (styleChange.isStateNewStyles())
                {
                    out.println(">");
                    indent++;
                    printFillStyles(styleChange.getStyles().getFillStyles());
                    printLineStyles(styleChange.getStyles().getLineStyles());
                    indent--;
                    indent();
                    out.println("</styleChange>");
                    styles = styleChange.getStyles();
                }
                else
                {
                    out.println("/>");
                }
View Full Code Here


        for (ShapeRecord shape : shapes.getShapeRecords())
        {
            indent();
            if (shape instanceof StyleChangeRecord)
            {
                StyleChangeRecord styleChange = (StyleChangeRecord)shape;

                // No longer print out number of bits in MoveDeltaX and
                // MoveDeltaY. The StyleChangeRecord record does not preserve
                // this information.
                out.print("SCR\t");
                if (styleChange.isStateMoveTo())
                {
                    out.print(styleChange.getMoveDeltaX() + "\t" + styleChange.getMoveDeltaY());

                    if (startX == 0 && startY == 0)
                    {
                        startX = styleChange.getMoveDeltaX();
                        startY = styleChange.getMoveDeltaY();
                    }

                    x = styleChange.getMoveDeltaX();
                    y = styleChange.getMoveDeltaY();

                    out.print("\t\t");
                }
            }
            else
View Full Code Here

                    stateLineStyle ||
                    stateFillStyle1 ||
                    stateFillStyle0 ||
                    stateMoveTo)
                {
                    final StyleChangeRecord styleChange = readStyleChangeRecord(
                            stateNewStyles,
                            stateLineStyle,
                            stateFillStyle1,
                            stateFillStyle0,
                            stateMoveTo,
View Full Code Here

            CurrentStyles currentStyles) throws IOException, MalformedTagException
    {
        assert tagType != null;
        assert currentStyles != null;

        final StyleChangeRecord styleChange = new StyleChangeRecord();

        // move draw point
        if (stateMoveTo)
        {
            final int moveBits = bitStream.readUB(5);
            final int moveDeltaX = bitStream.readSB(moveBits);
            final int moveDeltaY = bitStream.readSB(moveBits);
            styleChange.setMove(moveDeltaX, moveDeltaY);
        }

        // there shouldn't be any styles on a shape for fonts, as the
        // tag is a Shape, not ShapeWithStyle, but the fillStyle0 can be 1 because
        // of the following from the SWF spec:
        // "The first STYLECHANGERECORD of each SHAPE in the GlyphShapeTable does not use
        // the LineStyle and LineStyles fields. In addition, the first STYLECHANGERECORD of each
        // shape must have both fields StateFillStyle0 and FillStyle0 set to 1."
        boolean ignoreStyle = tagType == TagType.DefineFont ||
                              tagType == TagType.DefineFont2 ||
                              tagType == TagType.DefineFont3;

        // select a style
        final int indexFillStyle0 = stateFillStyle0 ? bitStream.readUB(currentStyles.numFillBits) : 0;
        final int indexFillStyle1 = stateFillStyle1 ? bitStream.readUB(currentStyles.numFillBits) : 0;
        final int indexLineStyle = stateLineStyle ? bitStream.readUB(currentStyles.numLineBits) : 0;
        final IFillStyle fillStyle0;
        if (indexFillStyle0 > 0 && !ignoreStyle)
            fillStyle0 = currentStyles.styles.getFillStyles().get(indexFillStyle0 - 1);
        else
            fillStyle0 = null;

        final IFillStyle fillStyle1;
        if (indexFillStyle1 > 0 && !ignoreStyle)
            fillStyle1 = currentStyles.styles.getFillStyles().get(indexFillStyle1 - 1);
        else
            fillStyle1 = null;

        final ILineStyle lineStyle;
        if (indexLineStyle > 0 && !ignoreStyle)
            lineStyle = currentStyles.styles.getLineStyles().get(indexLineStyle - 1);
        else
            lineStyle = null;

        styleChange.setDefinedStyles(fillStyle0, fillStyle1, lineStyle,
                stateFillStyle0, stateFillStyle1, stateLineStyle, currentStyles.styles);

        // "StateNewStyles" field is only used by DefineShape 2, 3 and 4 tags.
        final boolean isDefineShape234 = tagType == TagType.DefineShape2 ||
                                         tagType == TagType.DefineShape3 ||
                                         tagType == TagType.DefineShape4;

        // replace styles
        if (stateNewStyles && isDefineShape234)
        {
            // read from SWF
            final FillStyleArray fillStyles = readFillStyleArray(tagType);
            final LineStyleArray lineStyles = readLineStyleArray(tagType);
            bitStream.byteAlign();
            final int numFillBits = bitStream.readUB(4);
            final int numLineBits = bitStream.readUB(4);

            // update StyleChangeRecord
            final Styles newStyles = new Styles(fillStyles, lineStyles);
            styleChange.setNumFillBits(numFillBits);
            styleChange.setNumLineBits(numLineBits);
            styleChange.setNewStyles(newStyles);

            // update style context variable
            currentStyles.styles = newStyles;
            currentStyles.numFillBits = numFillBits;
            currentStyles.numLineBits = numLineBits;
View Full Code Here

        int dya = stt;
        int dyb = sbt - stt;
        int dyc = (int)(bitmap.getHeight() * ISWFConstants.TWIPS_PER_PIXEL) - sbt;

        // border
        StyleChangeRecord scr = new StyleChangeRecord();
        scr.setMove(0, dya);
        scr.setDefinedStyles(-1, 1, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, -dya));
        shapeRecords.add(new StraightEdgeRecord(dxa, 0));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 2, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(dxb, 0));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 3, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(dxc, 0));
        shapeRecords.add(new StraightEdgeRecord(0, dya));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 6, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dyb));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 9, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dyc));
        shapeRecords.add(new StraightEdgeRecord(-dxc, 0));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 8, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(-dxb, 0));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 7, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(-dxa, 0));
        shapeRecords.add(new StraightEdgeRecord(0, -dyc));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(-1, 4, -1, styles);
        shapeRecords.add(scr);

        shapeRecords.add(new StraightEdgeRecord(0, -dyb));

        // down 1
       
        scr = new StyleChangeRecord();
        scr.setMove(dxa, 0);
        scr.setDefinedStyles(2, 1, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dya));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(5, 4, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dyb));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(8, 7, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dyc));

        // down 2
        scr = new StyleChangeRecord();
        scr.setMove(dxa + dxb, 0);
        scr.setDefinedStyles(3, 2, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dya));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(6, 5, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dyb));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(9, 8, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(0, dyc));

        // right 1
        scr = new StyleChangeRecord();
        scr.setMove(0, dya);
        scr.setDefinedStyles(1, 4, -1, styles);
        shapeRecords.add(scr);
       
        shapeRecords.add(new StraightEdgeRecord(dxa, 0));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(2, 5, -1, styles);
        shapeRecords.add(scr);

        shapeRecords.add(new StraightEdgeRecord(dxb, 0));
       
        scr = new StyleChangeRecord();
        scr.setDefinedStyles(3, 6, -1, styles);
        shapeRecords.add(scr);

        shapeRecords.add(new StraightEdgeRecord(dxc, 0));

        // right 2       
        scr = new StyleChangeRecord();
        scr.setMove(0, dya + dyb);
        scr.setDefinedStyles(4, 7, -1, styles);
        shapeRecords.add(scr);
        shapeRecords.add(new StraightEdgeRecord(dxa, 0));

        scr = new StyleChangeRecord();
        scr.setDefinedStyles(5, 8, -1, styles);
        shapeRecords.add(scr);

        shapeRecords.add(new StraightEdgeRecord(dxb, 0));

        scr = new StyleChangeRecord();
        scr.setDefinedStyles(6, 9, -1, styles);
        shapeRecords.add(scr);

        shapeRecords.add(new StraightEdgeRecord(dxc, 0));

        ShapeWithStyle sws = new ShapeWithStyle(styles);
View Full Code Here

     * @return list of ShapeRecords representing the rectangle.
     */
    public static List<ShapeRecord> implicitClosepath(double startX, double startY, double endX, double endY)
    {
        List<ShapeRecord> shapeRecords = new ArrayList<ShapeRecord>();
        StyleChangeRecord scr = move(startX, startY);
        scr.defaultStyles(false, false, true);
        shapeRecords.add(scr);
        shapeRecords.addAll(straightEdge(startX, startY, endX, endY));
        return shapeRecords;
    }
View Full Code Here

        if (shapeRecords != null && shapeRecords.size() > 0)
        {
            ShapeRecord firstRecord = shapeRecords.get(0);
            if (firstRecord instanceof StyleChangeRecord)
            {
                StyleChangeRecord scr = (StyleChangeRecord)firstRecord;
                scr.setDefinedStyles(fs0, fs1, ls, styles);
            }
        }
    }
View Full Code Here

            for (int i = 0; i < shapeRecords.size(); i++)
            {
                ShapeRecord record = shapeRecords.get(i);
                if (record instanceof StyleChangeRecord)
                {
                    StyleChangeRecord scr = (StyleChangeRecord)record;
                   
                    scr.setDefinedStyles(fs0, fs1, (!scr.isStateLineStyle() && ls > 0) ? ls : -1, styles);
                }
            }
        }
    }
View Full Code Here

            for (int i = 0; i < shapeRecords.size(); i++)
            {
                ShapeRecord record = shapeRecords.get(i);
                if (record instanceof StyleChangeRecord)
                {
                    StyleChangeRecord old_scr = (StyleChangeRecord) record;
                    StyleChangeRecord new_scr =  new StyleChangeRecord();
                    int old_scrLineStyleIndex = 0;
                   
                    if (old_scr.getLinestyle() != null)
                        old_scrLineStyleIndex = styleContext.getLineStyles().indexOf(old_scr.getLinestyle());
                   
                    new_scr.setDefinedStyles(fs0, fs1, ((!old_scr.isStateLineStyle() && (ls > 0)) ? ls: old_scrLineStyleIndex), styleContext);
                   
                    if (old_scr.isStateMoveTo())
                        new_scr.setMove(old_scr.getMoveDeltaX(), old_scr.getMoveDeltaY());
                   
                    shapeRecords.set(i, new_scr);
                   
                }
            }
View Full Code Here

        y *= TWIPS_PER_PIXEL;

        int moveX = (int)x;
        int moveY = (int)y;

        StyleChangeRecord scr = new StyleChangeRecord();
       
        scr.setMove(moveX, moveY);

        return scr;
    }
View Full Code Here

TOP

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

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.