Package com.kitfox.svg.xml

Examples of com.kitfox.svg.xml.StyleAttribute


   
    public void build() throws SVGException
    {
        super.build();
       
        StyleAttribute sty = new StyleAttribute();
       
        if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
       
        if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
       
        if (getStyle(sty.setName("font-family"))) fontFamily = sty.getStringValue();
        else fontFamily = "Sans Serif";
       
        if (getStyle(sty.setName("font-size"))) fontSize = sty.getFloatValueWithUnits();
        else fontSize = 12f;
       
        if (getStyle(sty.setName("font-style")))
        {
            String s = sty.getStringValue();
            if ("normal".equals(s))
            {
                fontStyle = TXST_NORMAL;
            }
            else if ("italic".equals(s))
            {
                fontStyle = TXST_ITALIC;
            }
            else if ("oblique".equals(s))
            {
                fontStyle = TXST_OBLIQUE;
            }
        }
        else fontStyle = TXST_NORMAL;
       
        if (getStyle(sty.setName("font-weight")))
        {
            String s = sty.getStringValue();
            if ("normal".equals(s))
            {
                fontWeight = TXWE_NORMAL;
            }
            else if ("bold".equals(s))
            {
                fontWeight = TXWE_BOLD;
            }
        }
        else fontWeight = TXWE_BOLD;
       
        if (getStyle(sty.setName("text-anchor")))
        {
            String s = sty.getStringValue();
            if (s.equals("middle")) textAnchor = TXAN_MIDDLE;
            else if (s.equals("end")) textAnchor = TXAN_END;
            else textAnchor = TXAN_START;
        }
        else textAnchor = TXAN_START;
View Full Code Here


    {
//        if (trackManager.getNumTracks() == 0) return false;
        boolean changeState = super.updateTime(curTime);
       
        //Get current values for parameters
        StyleAttribute sty = new StyleAttribute();
        boolean shapeChange = false;
       
        if (getPres(sty.setName("x")))
        {
            float newVal = sty.getFloatValueWithUnits();
            if (newVal != x)
            {
                x = newVal;
                shapeChange = true;
            }
        }
       
        if (getPres(sty.setName("y")))
        {
            float newVal = sty.getFloatValueWithUnits();
            if (newVal != y)
            {
                y = newVal;
                shapeChange = true;
            }
        }
       
        if (getPres(sty.setName("font-family")))
        {
            String newVal = sty.getStringValue();
            if (!newVal.equals(fontFamily))
            {
                fontFamily = newVal;
                shapeChange = true;
            }
        }
       
        if (getPres(sty.setName("font-size")))
        {
            float newVal = sty.getFloatValueWithUnits();
            if (newVal != fontSize)
            {
                fontSize = newVal;
                shapeChange = true;
            }
        }
       
       
        if (getStyle(sty.setName("font-style")))
        {
            String s = sty.getStringValue();
            int newVal = fontStyle;
            if ("normal".equals(s))
            {
                newVal = TXST_NORMAL;
            }
            else if ("italic".equals(s))
            {
                newVal = TXST_ITALIC;
            }
            else if ("oblique".equals(s))
            {
                newVal = TXST_OBLIQUE;
            }
            if (newVal != fontStyle)
            {
                fontStyle = newVal;
                shapeChange = true;
            }
        }
       
        if (getStyle(sty.setName("font-weight")))
        {
            String s = sty.getStringValue();
            int newVal = fontWeight;
            if ("normal".equals(s))
            {
                newVal = TXWE_NORMAL;
            }
View Full Code Here

   
    protected void build() throws SVGException
    {
        super.build();
       
        StyleAttribute sty = new StyleAttribute();
       
    //Load style string
        String href = null;
        if (getPres(sty.setName("xlink:href"))) href = sty.getStringValue();
        //String href = attrs.getValue("xlink:href");
        //If we have a link to another pattern, initialize ourselves with it's values
        if (href != null)
        {
//System.err.println("Gradient.loaderStartElement() href '" + href + "'");
            try {
                URI src = getXMLBase().resolve(href);
                PatternSVG patSrc = (PatternSVG)diagram.getUniverse().getElement(src);

                gradientUnits = patSrc.gradientUnits;
                x = patSrc.x;
                y = patSrc.y;
                width = patSrc.width;
                height = patSrc.height;
                viewBox = patSrc.viewBox;
                patternXform.setTransform(patSrc.patternXform);
                children.addAll(patSrc.children);
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }

        String gradientUnits = "";
        if (getPres(sty.setName("gradientUnits"))) gradientUnits = sty.getStringValue().toLowerCase();
        if (gradientUnits.equals("userspaceonuse")) this.gradientUnits = GU_USER_SPACE_ON_USE;
        else this.gradientUnits = GU_OBJECT_BOUNDING_BOX;

        String patternTransform = "";
        if (getPres(sty.setName("patternTransform"))) patternTransform = sty.getStringValue();
        patternXform = parseTransform(patternTransform);

       
        if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
       
        if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
       
        if (getPres(sty.setName("width"))) width = sty.getFloatValueWithUnits();
       
        if (getPres(sty.setName("height"))) height = sty.getFloatValueWithUnits();
       
        if (getPres(sty.setName("viewBox")))
        {
            float[] dim = sty.getFloatList();
            viewBox = new Rectangle2D.Float(dim[0], dim[1], dim[2], dim[3]);
        }
           
        preparePattern();
    }
View Full Code Here

    protected void build() throws SVGException
    {
        super.build();

        StyleAttribute sty = new StyleAttribute();

        if (getPres(sty.setName("refX"))) refX = sty.getFloatValueWithUnits();
        if (getPres(sty.setName("refY"))) refY = sty.getFloatValueWithUnits();
        if (getPres(sty.setName("markerWidth"))) markerWidth = sty.getFloatValueWithUnits();
        if (getPres(sty.setName("markerHeight"))) markerHeight = sty.getFloatValueWithUnits();

        if (getPres(sty.setName("orient")))
        {
            if ("auto".equals(sty.getStringValue()))
            {
                orient = Float.NaN;
            }
            else
            {
                orient = sty.getFloatValue();
            }
        }

        if (getPres(sty.setName("viewBox")))
        {
            float[] dim = sty.getFloatList();
            viewBox = new Rectangle2D.Float(dim[0], dim[1], dim[2], dim[3]);
        }

        if (viewBox == null)
        {
            viewBox = new Rectangle(0, 0, 1, 1);
        }

        if (getPres(sty.setName("markerUnits")))
        {
            String markerUnits = sty.getStringValue();
            if (markerUnits != null && markerUnits.equals("userSpaceOnUse"))
            {
                markerUnitsStrokeWidth = false;
            }
        }
View Full Code Here

   
    protected void build() throws SVGException
    {
        super.build();
       
        StyleAttribute sty = new StyleAttribute();
       
        if (getPres(sty.setName("horiz-origin-x"))) horizOriginX = sty.getIntValue();
       
        if (getPres(sty.setName("horiz-origin-y"))) horizOriginY = sty.getIntValue();
       
        if (getPres(sty.setName("horiz-adv-x"))) horizAdvX = sty.getIntValue();
       
        if (getPres(sty.setName("vert-origin-x"))) vertOriginX = sty.getIntValue();
       
        if (getPres(sty.setName("vert-origin-y"))) vertOriginY = sty.getIntValue();
       
        if (getPres(sty.setName("vert-adv-y"))) vertAdvY = sty.getIntValue();
    }
View Full Code Here

    protected void rebuild(AnimTimeParser animTimeParser) throws SVGException
    {
        super.rebuild(animTimeParser);

        StyleAttribute sty = new StyleAttribute();

        if (getPres(sty.setName("from")))
        {
            String strn = sty.getStringValue();
            if (XMLParseUtil.isDouble(strn))
            {
                fromValue = XMLParseUtil.parseDouble(strn);
            }
            else
            {
                fromColor = ColorTable.parseColor(strn);
                if (fromColor == null)
                {
                    //Try path
                    fromPath = this.buildPath(strn, GeneralPath.WIND_EVEN_ODD);
                    dataType = DT_PATH;
                }
                else dataType = DT_COLOR;
            }
        }

        if (getPres(sty.setName("to")))
        {
            String strn = sty.getStringValue();
            if (XMLParseUtil.isDouble(strn))
            {
                toValue = XMLParseUtil.parseDouble(strn);
            }
            else
            {
                toColor = ColorTable.parseColor(strn);
                if (toColor == null)
                {
                    //Try path
                    toPath = this.buildPath(strn, GeneralPath.WIND_EVEN_ODD);
                    dataType = DT_PATH;
                }
                else dataType = DT_COLOR;
            }
        }

        if (getPres(sty.setName("by")))
        {
            String strn = sty.getStringValue();
            if (strn != null) byValue = XMLParseUtil.parseDouble(strn);
        }

        if (getPres(sty.setName("values")))
        {
            String strn = sty.getStringValue();
            if (strn != null) valuesValue = XMLParseUtil.parseDoubleList(strn);
        }
    }
View Full Code Here

    public double getValue(double curTime)
    {
        double retVal = Double.NaN;
       
        StyleAttribute attr = null;
        switch (attribType)
        {
            case AnimationElement.AT_CSS:
                attr = parent.getStyleAbsolute(attribName);
                retVal = attr.getDoubleValue();
                break;
            case AnimationElement.AT_XML:
                attr = parent.getPresAbsolute(attribName);
                retVal = attr.getDoubleValue();
                break;
            case AnimationElement.AT_AUTO:
                attr = parent.getStyleAbsolute(attribName);
                if (attr == null) attr = parent.getPresAbsolute(attribName);
                retVal = attr.getDoubleValue();
                break;
        }
       
       
       
View Full Code Here

    protected void build() throws SVGException
    {
        super.build();

        StyleAttribute sty = new StyleAttribute();


        //Read glyph spacing info
        if (getPres(sty.setName("u1"))) u1 = sty.getStringValue();

        if (getPres(sty.setName("u2"))) u2 = sty.getStringValue();

        if (getPres(sty.setName("k"))) k = sty.getIntValue();
    }
View Full Code Here

    }
     */

    void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
    {
        StyleAttribute styleAttrib = new StyleAttribute();
//        if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
        if ((boundingBox ? getBoundingBox() : getShape()).contains(point))
        {
            retVec.add(getPath(null));
        }
View Full Code Here

        }
    }

    void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
    {
        StyleAttribute styleAttrib = new StyleAttribute();
//        if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
        if (ltw.createTransformedShape((boundingBox ? getBoundingBox() : getShape())).intersects(pickArea))
        {
            retVec.add(getPath(null));
        }
View Full Code Here

TOP

Related Classes of com.kitfox.svg.xml.StyleAttribute

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.