Changeset 6002 in josm for trunk/src/com


Ignore:
Timestamp:
2013-06-11T01:01:28+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #8742 - update svgsalamander to release 0.1.18+patch (fix bug SVGSALAMANDER-26) -> allow to open more SVG files

Location:
trunk/src/com/kitfox/svg
Files:
3 added
2 deleted
85 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/kitfox/svg/A.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 1:56 AM
     
    2938
    3039import com.kitfox.svg.xml.StyleAttribute;
    31 import java.awt.*;
    3240import java.net.URI;
    3341
     
    3644 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3745 */
    38 public class A extends Group {
     46public class A extends Group
     47{
     48    public static final String TAG_NAME = "a";
    3949
    4050    URI href;
     
    4252
    4353    /** Creates a new instance of Stop */
    44     public A() {
     54    public A()
     55    {
    4556    }
    46 /*
    47     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     57
     58    public String getTagName()
    4859    {
    49                 //Load style string
    50         super.loaderStartElement(helper, attrs, parent);
    51 
    52         String offset = attrs.getValue("offset");
    53         this.offset = (float)XMLParseUtil.parseRatio(offset);
    54 
    55         buildStop();
     60        return TAG_NAME;
    5661    }
    57     */
    5862   
    5963    protected void build() throws SVGException
  • trunk/src/com/kitfox/svg/Circle.java

    r4256 r6002  
    11/*
    2  * Rect.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 5:25 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3846 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3947 */
    40 public class Circle extends ShapeElement 
     48public class Circle extends ShapeElement
    4149{
    4250
     51    public static final String TAG_NAME = "circle";
    4352    float cx = 0f;
    4453    float cy = 0f;
    4554    float r = 0f;
    46 
    47 
    4855    Ellipse2D.Float circle = new Ellipse2D.Float();
    4956
    50     /** Creates a new instance of Rect */
    51     public Circle() {
     57    /**
     58     * Creates a new instance of Rect
     59     */
     60    public Circle()
     61    {
    5262    }
    53 /*
    54     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     63
     64    public String getTagName()
    5565    {
    56                 //Load style string
    57         super.loaderStartElement(helper, attrs, parent);
     66        return TAG_NAME;
     67    }
    5868
    59         String cx = attrs.getValue("cx");
    60         String cy = attrs.getValue("cy");
    61         String r = attrs.getValue("r");
    62 
    63         this.cx = XMLParseUtil.parseFloat(cx);
    64         this.cy = XMLParseUtil.parseFloat(cy);
    65         this.r = XMLParseUtil.parseFloat(r);
    66 
    67         build();
    68        
    69         //setBounds(this.cx - this.r, this.cy - this.r, this.r * 2.0, this.r * 2.0);
    70     }
    71 */
    72     /*
    73     public void loaderEndElement(SVGLoaderHelper helper)
    74     {
    75 //        super.loaderEndElement(helper);
    76 
    77 //        build();
    78     }
    79      */
    80    
    8169    protected void build() throws SVGException
    8270    {
    8371        super.build();
    84        
     72
    8573        StyleAttribute sty = new StyleAttribute();
    86        
    87         if (getPres(sty.setName("cx"))) cx = sty.getFloatValueWithUnits();
    88        
    89         if (getPres(sty.setName("cy"))) cy = sty.getFloatValueWithUnits();
    90        
    91         if (getPres(sty.setName("r"))) r = sty.getFloatValueWithUnits();
    92        
     74
     75        if (getPres(sty.setName("cx")))
     76        {
     77            cx = sty.getFloatValueWithUnits();
     78        }
     79
     80        if (getPres(sty.setName("cy")))
     81        {
     82            cy = sty.getFloatValueWithUnits();
     83        }
     84
     85        if (getPres(sty.setName("r")))
     86        {
     87            r = sty.getFloatValueWithUnits();
     88        }
     89
    9390        circle.setFrame(cx - r, cy - r, r * 2f, r * 2f);
    9491    }
     
    112109
    113110    /**
    114      * Updates all attributes in this diagram associated with a time event.
    115      * Ie, all attributes with track information.
     111     * Updates all attributes in this diagram associated with a time event. Ie,
     112     * all attributes with track information.
     113     *
    116114     * @return - true if this node has changed state as a result of the time
    117115     * update
     
    125123        StyleAttribute sty = new StyleAttribute();
    126124        boolean shapeChange = false;
    127        
     125
    128126        if (getPres(sty.setName("cx")))
    129127        {
     
    135133            }
    136134        }
    137        
     135
    138136        if (getPres(sty.setName("cy")))
    139137        {
     
    145143            }
    146144        }
    147        
     145
    148146        if (getPres(sty.setName("r")))
    149147        {
     
    155153            }
    156154        }
    157        
     155
    158156        if (shapeChange)
    159157        {
     
    162160//            return true;
    163161        }
    164        
     162
    165163        return changeState || shapeChange;
    166164    }
    167    
    168165}
    169 
    170 
    171 
  • trunk/src/com/kitfox/svg/ClipPath.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 1:56 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3745 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3846 */
    39 public class ClipPath extends SVGElement 
     47public class ClipPath extends SVGElement
    4048{
    4149
     50    public static final String TAG_NAME = "clippath";
    4251    public static final int CP_USER_SPACE_ON_USE = 0;
    4352    public static final int CP_OBJECT_BOUNDING_BOX = 1;
    44 
    4553    int clipPathUnits = CP_USER_SPACE_ON_USE;
    4654
    47     /** Creates a new instance of Stop */
    48     public ClipPath() {
     55    /**
     56     * Creates a new instance of Stop
     57     */
     58    public ClipPath()
     59    {
    4960    }
    50 /*
    51     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     61
     62    public String getTagName()
    5263    {
    53                 //Load style string
    54         super.loaderStartElement(helper, attrs, parent);
     64        return TAG_NAME;
     65    }
    5566
    56         String clipPathUnits = attrs.getValue("clipPathUnits");
    57 
    58         if (clipPathUnits.equals("objectBoundingBox")) this.clipPathUnits = CP_OBJECT_BOUNDING_BOX;
    59 
    60     }
    61 */
    6267    /**
    6368     * Called after the start element but before the end element to indicate
     
    6671    public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
    6772    {
    68                 super.loaderAddChild(helper, child);
    69 
    70 //        if (child instanceof ShapeElement) members.add(child);
     73        super.loaderAddChild(helper, child);
    7174    }
    7275
    73     /*
    74     public void loaderEndElement(SVGLoaderHelper helper)
    75     {
    76 //        super.loaderEndElement(helper);
    77 
    78 //        build();
    79     }
    80     */
    81    
    8276    protected void build() throws SVGException
    8377    {
    8478        super.build();
    85        
     79
    8680        StyleAttribute sty = new StyleAttribute();
    87        
     81
    8882        clipPathUnits = (getPres(sty.setName("clipPathUnits"))
    89             && sty.getStringValue().equals("objectBoundingBox")) 
    90             ? CP_OBJECT_BOUNDING_BOX 
     83            && sty.getStringValue().equals("objectBoundingBox"))
     84            ? CP_OBJECT_BOUNDING_BOX
    9185            : CP_USER_SPACE_ON_USE;
    9286    }
    93    
     87
    9488    public int getClipPathUnits()
    9589    {
     
    9993    public Shape getClipPathShape()
    10094    {
    101         if (children.size() == 0) return null;
    102         if (children.size() == 1) return ((ShapeElement)children.get(0)).getShape();
     95        if (children.isEmpty())
     96        {
     97            return null;
     98        }
     99        if (children.size() == 1)
     100        {
     101            return ((ShapeElement) children.get(0)).getShape();
     102        }
    103103
    104104        Area clipArea = null;
    105105        for (Iterator it = children.iterator(); it.hasNext();)
    106106        {
    107             ShapeElement se = (ShapeElement)it.next();
     107            ShapeElement se = (ShapeElement) it.next();
    108108
    109109            if (clipArea == null)
    110110            {
    111111                Shape shape = se.getShape();
    112                 if (shape != null) clipArea = new Area(se.getShape());
     112                if (shape != null)
     113                {
     114                    clipArea = new Area(se.getShape());
     115                }
    113116                continue;
    114117            }
    115118
    116119            Shape shape = se.getShape();
    117             if (shape != null) clipArea.intersect(new Area(shape));
     120            if (shape != null)
     121            {
     122                clipArea.intersect(new Area(shape));
     123            }
    118124        }
    119125
     
    122128
    123129    /**
    124      * Updates all attributes in this diagram associated with a time event.
    125      * Ie, all attributes with track information.
     130     * Updates all attributes in this diagram associated with a time event. Ie,
     131     * all attributes with track information.
     132     *
    126133     * @return - true if this node has changed state as a result of the time
    127134     * update
     
    129136    public boolean updateTime(double curTime) throws SVGException
    130137    {
    131 //        if (trackManager.getNumTracks() == 0) return false;
    132 
    133138        //Get current values for parameters
    134139        StyleAttribute sty = new StyleAttribute();
    135140        boolean shapeChange = false;
    136141
    137        
     142
    138143        if (getPres(sty.setName("clipPathUnits")))
    139144        {
    140145            String newUnitsStrn = sty.getStringValue();
    141146            int newUnits = newUnitsStrn.equals("objectBoundingBox")
    142                 ? CP_OBJECT_BOUNDING_BOX 
     147                ? CP_OBJECT_BOUNDING_BOX
    143148                : CP_USER_SPACE_ON_USE;
    144                
     149
    145150            if (newUnits != clipPathUnits)
    146151            {
  • trunk/src/com/kitfox/svg/Defs.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 1:56 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    30 import java.awt.*;
    31 import java.awt.geom.*;
    32 import java.util.*;
    33 
    34 import com.kitfox.svg.xml.*;
    35 import org.xml.sax.*;
     38import java.util.Iterator;
    3639
    3740/**
     
    4245{
    4346
    44     /** Creates a new instance of Stop */
    45     public Defs() {
     47    public static final String TAG_NAME = "defs";
     48
     49    /**
     50     * Creates a new instance of Stop
     51     */
     52    public Defs()
     53    {
     54    }
     55
     56    public String getTagName()
     57    {
     58        return TAG_NAME;
    4659    }
    4760
     
    5265    public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
    5366    {
    54                 super.loaderAddChild(helper, child);
     67        super.loaderAddChild(helper, child);
    5568
    5669//        members.add(child);
     
    6275        for (Iterator it = children.iterator(); it.hasNext();)
    6376        {
    64             SVGElement ele = (SVGElement)it.next();
     77            SVGElement ele = (SVGElement) it.next();
    6578            stateChange = stateChange || ele.updateTime(curTime);
    6679        }
    67        
     80
    6881        return super.updateTime(curTime) || stateChange;
    6982    }
  • trunk/src/com/kitfox/svg/Desc.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on September 19, 2004, 1:56 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3442 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3543 */
    36 public class Desc extends SVGElement {
     44public class Desc extends SVGElement
     45{
    3746
     47    public static final String TAG_NAME = "desc";
    3848    StringBuffer text = new StringBuffer();
    3949
    40     /** Creates a new instance of Stop */
    41     public Desc() {
     50    /**
     51     * Creates a new instance of Stop
     52     */
     53    public Desc()
     54    {
     55    }
     56
     57    public String getTagName()
     58    {
     59        return TAG_NAME;
    4260    }
    4361
     
    5068    }
    5169
    52     public String getText() { return text.toString(); }
    53    
     70    public String getText()
     71    {
     72        return text.toString();
     73    }
     74
    5475    public boolean updateTime(double curTime)
    5576    {
  • trunk/src/com/kitfox/svg/Ellipse.java

    r4256 r6002  
    11/*
    2  * Rect.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 5:25 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import com.kitfox.svg.xml.*;
    32 import org.xml.sax.*;
    33 
    34 import java.awt.*;
    35 import java.awt.geom.*;
     39import java.awt.Graphics2D;
     40import java.awt.Shape;
     41import java.awt.geom.Ellipse2D;
     42import java.awt.geom.Rectangle2D;
    3643
    3744/**
     
    3946 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4047 */
    41 public class Ellipse extends ShapeElement {
     48public class Ellipse extends ShapeElement
     49{
    4250
     51    public static final String TAG_NAME = "ellipse";
    4352    float cx = 0.0f;
    4453    float cy = 0.0f;
    4554    float rx = 0.0f;
    4655    float ry = 0.0f;
    47 
    4856    Ellipse2D.Float ellipse = new Ellipse2D.Float();
    4957
    50     /** Creates a new instance of Rect */
    51     public Ellipse() {
     58    /**
     59     * Creates a new instance of Rect
     60     */
     61    public Ellipse()
     62    {
    5263    }
    53 /*
    54     protected void init(String idIn, Style parentStyle, String cx, String cy, String rx, String ry) {
    55         super.init(idIn, parentStyle);
    5664
    57         this.cx = parseDouble(cx);
    58         this.cy = parseDouble(cy);
    59         this.rx = parseDouble(rx);
    60         this.ry = parseDouble(ry);
     65    public String getTagName()
     66    {
     67        return TAG_NAME;
     68    }
    6169
    62         setBounds(this.cx - this.rx, this.cy - this.ry, this.rx * 2.0, this.ry * 2.0);
    63     }
    64 */
    65     /*
    66     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    67     {
    68                 //Load style string
    69         super.loaderStartElement(helper, attrs, parent);
    70 
    71         String cx = attrs.getValue("cx");
    72         String cy = attrs.getValue("cy");
    73         String rx = attrs.getValue("rx");
    74         String ry = attrs.getValue("ry");
    75 
    76         this.cx = XMLParseUtil.parseDouble(cx);
    77         this.cy = XMLParseUtil.parseDouble(cy);
    78         this.rx = XMLParseUtil.parseDouble(rx);
    79         this.ry = XMLParseUtil.parseDouble(ry);
    80 
    81         build();
    82     }
    83     */
    84    
    85     /*
    86     public void loaderEndElement(SVGLoaderHelper helper)
    87     {
    88         super.loaderEndElement(helper);
    89 
    90         build();
    91     }
    92      */
    93    
    9470    protected void build() throws SVGException
    9571    {
    9672        super.build();
    97        
     73
    9874        StyleAttribute sty = new StyleAttribute();
    99        
    100         if (getPres(sty.setName("cx"))) cx = sty.getFloatValueWithUnits();
    101        
    102         if (getPres(sty.setName("cy"))) cy = sty.getFloatValueWithUnits();
    103        
    104         if (getPres(sty.setName("rx"))) rx = sty.getFloatValueWithUnits();
    105        
    106         if (getPres(sty.setName("ry"))) ry = sty.getFloatValueWithUnits();
    107        
     75
     76        if (getPres(sty.setName("cx")))
     77        {
     78            cx = sty.getFloatValueWithUnits();
     79        }
     80
     81        if (getPres(sty.setName("cy")))
     82        {
     83            cy = sty.getFloatValueWithUnits();
     84        }
     85
     86        if (getPres(sty.setName("rx")))
     87        {
     88            rx = sty.getFloatValueWithUnits();
     89        }
     90
     91        if (getPres(sty.setName("ry")))
     92        {
     93            ry = sty.getFloatValueWithUnits();
     94        }
     95
    10896        ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f);
    10997    }
     
    125113        return boundsToParent(includeStrokeInBounds(ellipse.getBounds2D()));
    126114    }
    127    
     115
    128116    /**
    129      * Updates all attributes in this diagram associated with a time event.
    130      * Ie, all attributes with track information.
     117     * Updates all attributes in this diagram associated with a time event. Ie,
     118     * all attributes with track information.
     119     *
    131120     * @return - true if this node has changed state as a result of the time
    132121     * update
     
    140129        StyleAttribute sty = new StyleAttribute();
    141130        boolean shapeChange = false;
    142        
     131
    143132        if (getPres(sty.setName("cx")))
    144133        {
     
    150139            }
    151140        }
    152        
     141
    153142        if (getPres(sty.setName("cy")))
    154143        {
     
    160149            }
    161150        }
    162        
     151
    163152        if (getPres(sty.setName("rx")))
    164153        {
     
    170159            }
    171160        }
    172        
     161
    173162        if (getPres(sty.setName("ry")))
    174163        {
     
    180169            }
    181170        }
    182        
     171
    183172        if (shapeChange)
    184173        {
     
    187176//            return true;
    188177        }
    189        
     178
    190179        return changeState || shapeChange;
    191180    }
  • trunk/src/com/kitfox/svg/FeDistantLight.java

    r4256 r6002  
    11/*
    2  * FillElement.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import java.awt.*;
    32 import java.awt.geom.*;
    33 import java.net.*;
    34 import java.util.*;
    35 
    36 import com.kitfox.svg.xml.*;
    37 import org.xml.sax.*;
    3839
    3940/**
     
    4142 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4243 */
    43 public class FeDistantLight extends FeLight 
     44public class FeDistantLight extends FeLight
    4445{
     46
     47    public static final String TAG_NAME = "fedistantlight";
    4548    float azimuth = 0f;
    4649    float elevation = 0f;
    47    
    4850
    49     /** Creates a new instance of FillElement */
    50     public FeDistantLight() {
     51    /**
     52     * Creates a new instance of FillElement
     53     */
     54    public FeDistantLight()
     55    {
    5156    }
    5257
    53    
     58    public String getTagName()
     59    {
     60        return TAG_NAME;
     61    }
     62
    5463    protected void build() throws SVGException
    5564    {
    5665        super.build();
    57        
     66
    5867        StyleAttribute sty = new StyleAttribute();
    5968        String strn;
    60        
    61         if (getPres(sty.setName("azimuth"))) azimuth = sty.getFloatValueWithUnits();
    62        
    63         if (getPres(sty.setName("elevation"))) elevation = sty.getFloatValueWithUnits();
     69
     70        if (getPres(sty.setName("azimuth")))
     71        {
     72            azimuth = sty.getFloatValueWithUnits();
     73        }
     74
     75        if (getPres(sty.setName("elevation")))
     76        {
     77            elevation = sty.getFloatValueWithUnits();
     78        }
    6479    }
    6580
    66     public float getAzimuth() { return azimuth; }
    67     public float getElevation() { return elevation; }
    68    
     81    public float getAzimuth()
     82    {
     83        return azimuth;
     84    }
     85
     86    public float getElevation()
     87    {
     88        return elevation;
     89    }
     90
    6991    public boolean updateTime(double curTime) throws SVGException
    7092    {
     
    7496        StyleAttribute sty = new StyleAttribute();
    7597        boolean stateChange = false;
    76        
     98
    7799        if (getPres(sty.setName("azimuth")))
    78100        {
     
    84106            }
    85107        }
    86        
     108
    87109        if (getPres(sty.setName("elevation")))
    88110        {
     
    94116            }
    95117        }
    96        
     118
    97119        return stateChange;
    98120    }
    99121}
    100 
  • trunk/src/com/kitfox/svg/FeLight.java

    r4256 r6002  
    11/*
    2  * FillElement.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    29 
    30 import java.awt.*;
    31 import java.awt.geom.*;
    32 import java.net.*;
    33 import java.util.*;
    34 
    35 import com.kitfox.svg.xml.*;
    36 import org.xml.sax.*;
    3737
    3838/**
     
    4040 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4141 */
    42 abstract public class FeLight extends FilterEffects 
     42abstract public class FeLight extends FilterEffects
    4343{
    4444
    45     /** Creates a new instance of FillElement */
    46     public FeLight() {
     45    public static final String TAG_NAME = "feLight";
     46
     47    /**
     48     * Creates a new instance of FillElement
     49     */
     50    public FeLight()
     51    {
    4752    }
    4853
     54    public String getTagName()
     55    {
     56        return TAG_NAME;
     57    }
    4958}
    50 
  • trunk/src/com/kitfox/svg/FePointLight.java

    r4256 r6002  
    11/*
    2  * FillElement.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import java.awt.*;
    32 import java.awt.geom.*;
    33 import java.net.*;
    34 import java.util.*;
    35 
    36 import com.kitfox.svg.xml.*;
    37 import org.xml.sax.*;
    3839
    3940/**
     
    4142 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4243 */
    43 public class FePointLight extends FeLight 
     44public class FePointLight extends FeLight
    4445{
     46
     47    public static final String TAG_NAME = "fepointlight";
    4548    float x = 0f;
    4649    float y = 0f;
    4750    float z = 0f;
    48    
    4951
    50     /** Creates a new instance of FillElement */
    51     public FePointLight() {
     52    /**
     53     * Creates a new instance of FillElement
     54     */
     55    public FePointLight()
     56    {
    5257    }
    5358
    54    
     59    public String getTagName()
     60    {
     61        return TAG_NAME;
     62    }
     63
    5564    protected void build() throws SVGException
    5665    {
    5766        super.build();
    58        
     67
    5968        StyleAttribute sty = new StyleAttribute();
    6069        String strn;
    61        
    62         if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
    63        
    64         if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
    65        
    66         if (getPres(sty.setName("z"))) z = sty.getFloatValueWithUnits();
     70
     71        if (getPres(sty.setName("x")))
     72        {
     73            x = sty.getFloatValueWithUnits();
     74        }
     75
     76        if (getPres(sty.setName("y")))
     77        {
     78            y = sty.getFloatValueWithUnits();
     79        }
     80
     81        if (getPres(sty.setName("z")))
     82        {
     83            z = sty.getFloatValueWithUnits();
     84        }
    6785    }
    6886
    69     public float getX() { return x; }
    70     public float getY() { return y; }
    71     public float getZ() { return z; }
    72    
     87    public float getX()
     88    {
     89        return x;
     90    }
     91
     92    public float getY()
     93    {
     94        return y;
     95    }
     96
     97    public float getZ()
     98    {
     99        return z;
     100    }
     101
    73102    public boolean updateTime(double curTime) throws SVGException
    74103    {
     
    78107        StyleAttribute sty = new StyleAttribute();
    79108        boolean stateChange = false;
    80        
     109
    81110        if (getPres(sty.setName("x")))
    82111        {
     
    88117            }
    89118        }
    90        
     119
    91120        if (getPres(sty.setName("y")))
    92121        {
     
    98127            }
    99128        }
    100        
     129
    101130        if (getPres(sty.setName("z")))
    102131        {
     
    108137            }
    109138        }
    110        
     139
    111140        return stateChange;
    112141    }
    113142}
    114 
  • trunk/src/com/kitfox/svg/FeSpotLight.java

    r4256 r6002  
    11/*
    2  * FillElement.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import java.awt.*;
    32 import java.awt.geom.*;
    33 import java.net.*;
    34 import java.util.*;
    35 
    36 import com.kitfox.svg.xml.*;
    37 import org.xml.sax.*;
    3839
    3940/**
     
    4142 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4243 */
    43 public class FeSpotLight extends FeLight 
     44public class FeSpotLight extends FeLight
    4445{
     46
     47    public static final String TAG_NAME = "fespotlight";
    4548    float x = 0f;
    4649    float y = 0f;
     
    5154    float specularComponent = 0f;
    5255    float limitingConeAngle = 0f;
    53    
    54 
    55     /** Creates a new instance of FillElement */
    56     public FeSpotLight() {
    57     }
    58 
    59    
     56
     57    /**
     58     * Creates a new instance of FillElement
     59     */
     60    public FeSpotLight()
     61    {
     62    }
     63
     64    public String getTagName()
     65    {
     66        return TAG_NAME;
     67    }
     68
    6069    protected void build() throws SVGException
    6170    {
    6271        super.build();
    63        
     72
    6473        StyleAttribute sty = new StyleAttribute();
    6574        String strn;
    66        
    67         if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
    68         if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
    69         if (getPres(sty.setName("z"))) z = sty.getFloatValueWithUnits();
    70         if (getPres(sty.setName("pointsAtX"))) pointsAtX = sty.getFloatValueWithUnits();
    71         if (getPres(sty.setName("pointsAtY"))) pointsAtY = sty.getFloatValueWithUnits();
    72         if (getPres(sty.setName("pointsAtZ"))) pointsAtZ = sty.getFloatValueWithUnits();
    73         if (getPres(sty.setName("specularComponent"))) specularComponent = sty.getFloatValueWithUnits();
    74         if (getPres(sty.setName("limitingConeAngle"))) limitingConeAngle = sty.getFloatValueWithUnits();
    75     }
    76 
    77     public float getX() { return x; }
    78     public float getY() { return y; }
    79     public float getZ() { return z; }
    80     public float getPointsAtX() { return pointsAtX; }
    81     public float getPointsAtY() { return pointsAtY; }
    82     public float getPointsAtZ() { return pointsAtZ; }
    83     public float getSpecularComponent() { return specularComponent; }
    84     public float getLimitingConeAngle() { return limitingConeAngle; }
    85    
     75
     76        if (getPres(sty.setName("x")))
     77        {
     78            x = sty.getFloatValueWithUnits();
     79        }
     80        if (getPres(sty.setName("y")))
     81        {
     82            y = sty.getFloatValueWithUnits();
     83        }
     84        if (getPres(sty.setName("z")))
     85        {
     86            z = sty.getFloatValueWithUnits();
     87        }
     88        if (getPres(sty.setName("pointsAtX")))
     89        {
     90            pointsAtX = sty.getFloatValueWithUnits();
     91        }
     92        if (getPres(sty.setName("pointsAtY")))
     93        {
     94            pointsAtY = sty.getFloatValueWithUnits();
     95        }
     96        if (getPres(sty.setName("pointsAtZ")))
     97        {
     98            pointsAtZ = sty.getFloatValueWithUnits();
     99        }
     100        if (getPres(sty.setName("specularComponent")))
     101        {
     102            specularComponent = sty.getFloatValueWithUnits();
     103        }
     104        if (getPres(sty.setName("limitingConeAngle")))
     105        {
     106            limitingConeAngle = sty.getFloatValueWithUnits();
     107        }
     108    }
     109
     110    public float getX()
     111    {
     112        return x;
     113    }
     114
     115    public float getY()
     116    {
     117        return y;
     118    }
     119
     120    public float getZ()
     121    {
     122        return z;
     123    }
     124
     125    public float getPointsAtX()
     126    {
     127        return pointsAtX;
     128    }
     129
     130    public float getPointsAtY()
     131    {
     132        return pointsAtY;
     133    }
     134
     135    public float getPointsAtZ()
     136    {
     137        return pointsAtZ;
     138    }
     139
     140    public float getSpecularComponent()
     141    {
     142        return specularComponent;
     143    }
     144
     145    public float getLimitingConeAngle()
     146    {
     147        return limitingConeAngle;
     148    }
     149
    86150    public boolean updateTime(double curTime) throws SVGException
    87151    {
     
    91155        StyleAttribute sty = new StyleAttribute();
    92156        boolean stateChange = false;
    93        
     157
    94158        if (getPres(sty.setName("x")))
    95159        {
     
    101165            }
    102166        }
    103        
     167
    104168        if (getPres(sty.setName("y")))
    105169        {
     
    111175            }
    112176        }
    113        
     177
    114178        if (getPres(sty.setName("z")))
    115179        {
     
    121185            }
    122186        }
    123        
     187
    124188        if (getPres(sty.setName("pointsAtX")))
    125189        {
     
    131195            }
    132196        }
    133        
     197
    134198        if (getPres(sty.setName("pointsAtY")))
    135199        {
     
    141205            }
    142206        }
    143        
     207
    144208        if (getPres(sty.setName("pointsAtZ")))
    145209        {
     
    151215            }
    152216        }
    153        
     217
    154218        if (getPres(sty.setName("specularComponent")))
    155219        {
     
    161225            }
    162226        }
    163        
     227
    164228        if (getPres(sty.setName("limitingConeAngle")))
    165229        {
     
    171235            }
    172236        }
    173        
     237
    174238        return stateChange;
    175239    }
    176240}
    177 
  • trunk/src/com/kitfox/svg/FillElement.java

    r4256 r6002  
    11/*
    2  * FillElement.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3543 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3644 */
    37 abstract public class FillElement extends SVGElement {
    38 
    39     /** Creates a new instance of FillElement */
    40     public FillElement() {
     45abstract public class FillElement extends SVGElement
     46{
     47    /**
     48     * Creates a new instance of FillElement
     49     */
     50    public FillElement()
     51    {
    4152    }
    4253
    4354    /**
    44      * Requests the paint defined by this element.  Passes in information
    45      * to allow paint to be customized
     55     * Requests the paint defined by this element. Passes in information to
     56     * allow paint to be customized
     57     *
    4658     * @param bounds - bounding box of shape being rendered
    47      * @param xform - The current transformation that the shape is being rendered
    48      * under.
     59     * @param xform - The current transformation that the shape is being
     60     * rendered under.
    4961     */
    5062    abstract public Paint getPaint(Rectangle2D bounds, AffineTransform xform);
  • trunk/src/com/kitfox/svg/Filter.java

    r4256 r6002  
    11/*
    2  * FillElement.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    30 import java.awt.geom.*;
    31 import java.net.*;
    32 import java.util.*;
    33 
    34 import com.kitfox.svg.xml.*;
     38import com.kitfox.svg.xml.StyleAttribute;
     39import java.awt.geom.Point2D;
     40import java.net.URI;
     41import java.net.URL;
     42import java.util.ArrayList;
    3543
    3644/**
     
    3846 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3947 */
    40 public class Filter extends SVGElement 
     48public class Filter extends SVGElement
    4149{
     50
     51    public static final String TAG_NAME = "filter";
    4252    public static final int FU_OBJECT_BOUNDING_BOX = 0;
    4353    public static final int FU_USER_SPACE_ON_USE = 1;
    44 
    4554    protected int filterUnits = FU_OBJECT_BOUNDING_BOX;
    46    
    4755    public static final int PU_OBJECT_BOUNDING_BOX = 0;
    4856    public static final int PU_USER_SPACE_ON_USE = 1;
    49 
    5057    protected int primitiveUnits = PU_OBJECT_BOUNDING_BOX;
    51    
    5258    float x = 0f;
    5359    float y = 0f;
    5460    float width = 1f;
    5561    float height = 1f;
    56    
    5762    Point2D filterRes = new Point2D.Double();
    58    
    5963    URL href = null;
    60 
    6164    final ArrayList filterEffects = new ArrayList();
    6265
    63     /** Creates a new instance of FillElement */
    64     public Filter() {
     66    /**
     67     * Creates a new instance of FillElement
     68     */
     69    public Filter()
     70    {
     71    }
     72
     73    public String getTagName()
     74    {
     75        return TAG_NAME;
    6576    }
    6677
     
    7889        }
    7990    }
    80    
     91
    8192    protected void build() throws SVGException
    8293    {
    8394        super.build();
    84        
     95
    8596        StyleAttribute sty = new StyleAttribute();
    8697        String strn;
    87        
     98
    8899        if (getPres(sty.setName("filterUnits")))
    89100        {
    90101            strn = sty.getStringValue().toLowerCase();
    91             if (strn.equals("userspaceonuse")) filterUnits = FU_USER_SPACE_ON_USE;
    92             else filterUnits = FU_OBJECT_BOUNDING_BOX;
     102            if (strn.equals("userspaceonuse"))
     103            {
     104                filterUnits = FU_USER_SPACE_ON_USE;
     105            } else
     106            {
     107                filterUnits = FU_OBJECT_BOUNDING_BOX;
     108            }
    93109        }
    94110
     
    96112        {
    97113            strn = sty.getStringValue().toLowerCase();
    98             if (strn.equals("userspaceonuse")) primitiveUnits = PU_USER_SPACE_ON_USE;
    99             else primitiveUnits = PU_OBJECT_BOUNDING_BOX;
    100         }
    101 
    102         if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
    103 
    104         if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
    105 
    106         if (getPres(sty.setName("width"))) width = sty.getFloatValueWithUnits();
    107 
    108         if (getPres(sty.setName("height"))) height = sty.getFloatValueWithUnits();
    109 
    110         try {
     114            if (strn.equals("userspaceonuse"))
     115            {
     116                primitiveUnits = PU_USER_SPACE_ON_USE;
     117            } else
     118            {
     119                primitiveUnits = PU_OBJECT_BOUNDING_BOX;
     120            }
     121        }
     122
     123        if (getPres(sty.setName("x")))
     124        {
     125            x = sty.getFloatValueWithUnits();
     126        }
     127
     128        if (getPres(sty.setName("y")))
     129        {
     130            y = sty.getFloatValueWithUnits();
     131        }
     132
     133        if (getPres(sty.setName("width")))
     134        {
     135            width = sty.getFloatValueWithUnits();
     136        }
     137
     138        if (getPres(sty.setName("height")))
     139        {
     140            height = sty.getFloatValueWithUnits();
     141        }
     142
     143        try
     144        {
    111145            if (getPres(sty.setName("xlink:href")))
    112146            {
     
    114148                href = src.toURL();
    115149            }
    116         }
    117         catch (Exception e)
     150        } catch (Exception e)
    118151        {
    119152            throw new SVGException(e);
     
    122155    }
    123156
    124     public float getX() { return x; }
    125     public float getY() { return y; }
    126     public float getWidth() { return width; }
    127     public float getHeight() { return height; }
    128    
     157    public float getX()
     158    {
     159        return x;
     160    }
     161
     162    public float getY()
     163    {
     164        return y;
     165    }
     166
     167    public float getWidth()
     168    {
     169        return width;
     170    }
     171
     172    public float getHeight()
     173    {
     174        return height;
     175    }
     176
    129177    public boolean updateTime(double curTime) throws SVGException
    130178    {
     
    134182        StyleAttribute sty = new StyleAttribute();
    135183        boolean stateChange = false;
    136        
     184
    137185        if (getPres(sty.setName("x")))
    138186        {
     
    144192            }
    145193        }
    146        
     194
    147195        if (getPres(sty.setName("y")))
    148196        {
     
    154202            }
    155203        }
    156        
     204
    157205        if (getPres(sty.setName("width")))
    158206        {
     
    164212            }
    165213        }
    166        
     214
    167215        if (getPres(sty.setName("height")))
    168216        {
     
    174222            }
    175223        }
    176        
    177         try {
     224
     225        try
     226        {
    178227            if (getPres(sty.setName("xlink:href")))
    179228            {
    180229                URI src = sty.getURIValue(getXMLBase());
    181230                URL newVal = src.toURL();
    182                
     231
    183232                if (!newVal.equals(href))
    184233                {
     
    187236                }
    188237            }
    189         }
    190         catch (Exception e)
     238        } catch (Exception e)
    191239        {
    192240            throw new SVGException(e);
     
    197245            int newVal;
    198246            String strn = sty.getStringValue().toLowerCase();
    199             if (strn.equals("userspaceonuse")) newVal = FU_USER_SPACE_ON_USE;
    200             else newVal = FU_OBJECT_BOUNDING_BOX;
     247            if (strn.equals("userspaceonuse"))
     248            {
     249                newVal = FU_USER_SPACE_ON_USE;
     250            } else
     251            {
     252                newVal = FU_OBJECT_BOUNDING_BOX;
     253            }
    201254            if (newVal != filterUnits)
    202255            {
     
    210263            int newVal;
    211264            String strn = sty.getStringValue().toLowerCase();
    212             if (strn.equals("userspaceonuse")) newVal = PU_USER_SPACE_ON_USE;
    213             else newVal = PU_OBJECT_BOUNDING_BOX;
     265            if (strn.equals("userspaceonuse"))
     266            {
     267                newVal = PU_USER_SPACE_ON_USE;
     268            } else
     269            {
     270                newVal = PU_OBJECT_BOUNDING_BOX;
     271            }
    214272            if (newVal != filterUnits)
    215273            {
     
    219277        }
    220278
    221        
    222        
     279
     280
    223281        return stateChange;
    224282    }
    225283}
    226 
  • trunk/src/com/kitfox/svg/FilterEffects.java

    r4256 r6002  
    11/*
    2  * FillElement.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on March 18, 2004, 6:52 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import java.awt.*;
    32 import java.awt.geom.*;
    33 import java.net.*;
    34 import java.util.*;
    35 
    36 import com.kitfox.svg.xml.*;
    37 import org.xml.sax.*;
     39import java.net.URI;
     40import java.net.URL;
    3841
    3942/**
     
    4144 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4245 */
    43 public class FilterEffects extends SVGElement 
     46public class FilterEffects extends SVGElement
    4447{
     48    public static final String TAG_NAME = "filtereffects";
     49   
    4550    public static final int FP_SOURCE_GRAPHIC = 0;
    4651    public static final int FP_SOURCE_ALPHA = 1;
     
    5055    public static final int FP_STROKE_PAINT = 5;
    5156    public static final int FP_CUSTOM = 5;
    52 
    5357    private int filterPrimitiveTypeIn;
    5458    private String filterPrimitiveRefIn;
    55    
    56    
    5759    float x = 0f;
    5860    float y = 0f;
    5961    float width = 1f;
    6062    float height = 1f;
    61    
    6263    String result = "defaultFilterName";
    63    
    64    
    65    
    6664    URL href = null;
    6765
    68 
    69     /** Creates a new instance of FillElement */
    70     public FilterEffects() {
     66    /**
     67     * Creates a new instance of FillElement
     68     */
     69    public FilterEffects()
     70    {
     71    }
     72
     73    public String getTagName()
     74    {
     75        return TAG_NAME;
    7176    }
    7277
     
    8489        }
    8590    }
    86    
     91
    8792    protected void build() throws SVGException
    8893    {
    8994        super.build();
    90        
     95
    9196        StyleAttribute sty = new StyleAttribute();
    9297        String strn;
    9398        /*
    94         if (getPres(sty.setName("filterUnits")))
    95         {
    96             strn = sty.getStringValue().toLowerCase();
    97             if (strn.equals("userspaceonuse")) filterUnits = FU_USER_SPACE_ON_USE;
    98             else filterUnits = FU_OBJECT_BOUNDING_BOX;
    99         }
    100 
    101         if (getPres(sty.setName("primitiveUnits")))
    102         {
    103             strn = sty.getStringValue().toLowerCase();
    104             if (strn.equals("userspaceonuse")) primitiveUnits = PU_USER_SPACE_ON_USE;
    105             else primitiveUnits = PU_OBJECT_BOUNDING_BOX;
    106         }
    107 
    108         if (getPres(sty.setName("x"))) x = sty.getFloatValue();
    109 
    110         if (getPres(sty.setName("y"))) y = sty.getFloatValue();
    111 
    112         if (getPres(sty.setName("width"))) width = sty.getFloatValue();
    113 
    114         if (getPres(sty.setName("height"))) height = sty.getFloatValue();
    115 
    116         try {
    117             if (getPres(sty.setName("xlink:href")))
    118             {
    119                 URI src = sty.getURIValue(getXMLBase());
    120                 href = src.toURL();
    121             }
    122         }
    123         catch (Exception e)
    124         {
    125             throw new SVGException(e);
    126         }
    127 */
    128     }
    129 
    130     public float getX() { return x; }
    131     public float getY() { return y; }
    132     public float getWidth() { return width; }
    133     public float getHeight() { return height; }
    134    
     99         if (getPres(sty.setName("filterUnits")))
     100         {
     101         strn = sty.getStringValue().toLowerCase();
     102         if (strn.equals("userspaceonuse")) filterUnits = FU_USER_SPACE_ON_USE;
     103         else filterUnits = FU_OBJECT_BOUNDING_BOX;
     104         }
     105
     106         if (getPres(sty.setName("primitiveUnits")))
     107         {
     108         strn = sty.getStringValue().toLowerCase();
     109         if (strn.equals("userspaceonuse")) primitiveUnits = PU_USER_SPACE_ON_USE;
     110         else primitiveUnits = PU_OBJECT_BOUNDING_BOX;
     111         }
     112
     113         if (getPres(sty.setName("x"))) x = sty.getFloatValue();
     114
     115         if (getPres(sty.setName("y"))) y = sty.getFloatValue();
     116
     117         if (getPres(sty.setName("width"))) width = sty.getFloatValue();
     118
     119         if (getPres(sty.setName("height"))) height = sty.getFloatValue();
     120
     121         try {
     122         if (getPres(sty.setName("xlink:href")))
     123         {
     124         URI src = sty.getURIValue(getXMLBase());
     125         href = src.toURL();
     126         }
     127         }
     128         catch (Exception e)
     129         {
     130         throw new SVGException(e);
     131         }
     132         */
     133    }
     134
     135    public float getX()
     136    {
     137        return x;
     138    }
     139
     140    public float getY()
     141    {
     142        return y;
     143    }
     144
     145    public float getWidth()
     146    {
     147        return width;
     148    }
     149
     150    public float getHeight()
     151    {
     152        return height;
     153    }
     154
    135155    public boolean updateTime(double curTime) throws SVGException
    136156    {
     
    140160        StyleAttribute sty = new StyleAttribute();
    141161        boolean stateChange = false;
    142        
     162
    143163        if (getPres(sty.setName("x")))
    144164        {
     
    150170            }
    151171        }
    152        
     172
    153173        if (getPres(sty.setName("y")))
    154174        {
     
    160180            }
    161181        }
    162        
     182
    163183        if (getPres(sty.setName("width")))
    164184        {
     
    170190            }
    171191        }
    172        
     192
    173193        if (getPres(sty.setName("height")))
    174194        {
     
    180200            }
    181201        }
    182        
    183         try {
     202
     203        try
     204        {
    184205            if (getPres(sty.setName("xlink:href")))
    185206            {
    186207                URI src = sty.getURIValue(getXMLBase());
    187208                URL newVal = src.toURL();
    188                
     209
    189210                if (!newVal.equals(href))
    190211                {
     
    193214                }
    194215            }
    195         }
    196         catch (Exception e)
     216        } catch (Exception e)
    197217        {
    198218            throw new SVGException(e);
     
    200220
    201221        /*
    202         if (getPres(sty.setName("filterUnits")))
    203         {
    204             int newVal;
    205             String strn = sty.getStringValue().toLowerCase();
    206             if (strn.equals("userspaceonuse")) newVal = FU_USER_SPACE_ON_USE;
    207             else newVal = FU_OBJECT_BOUNDING_BOX;
    208             if (newVal != filterUnits)
    209             {
    210                 filterUnits = newVal;
    211                 stateChange = true;
    212             }
    213         }
    214 
    215         if (getPres(sty.setName("primitiveUnits")))
    216         {
    217             int newVal;
    218             String strn = sty.getStringValue().toLowerCase();
    219             if (strn.equals("userspaceonuse")) newVal = PU_USER_SPACE_ON_USE;
    220             else newVal = PU_OBJECT_BOUNDING_BOX;
    221             if (newVal != filterUnits)
    222             {
    223                 primitiveUnits = newVal;
    224                 stateChange = true;
    225             }
    226         }
    227 
    228         */
    229        
     222         if (getPres(sty.setName("filterUnits")))
     223         {
     224         int newVal;
     225         String strn = sty.getStringValue().toLowerCase();
     226         if (strn.equals("userspaceonuse")) newVal = FU_USER_SPACE_ON_USE;
     227         else newVal = FU_OBJECT_BOUNDING_BOX;
     228         if (newVal != filterUnits)
     229         {
     230         filterUnits = newVal;
     231         stateChange = true;
     232         }
     233         }
     234
     235         if (getPres(sty.setName("primitiveUnits")))
     236         {
     237         int newVal;
     238         String strn = sty.getStringValue().toLowerCase();
     239         if (strn.equals("userspaceonuse")) newVal = PU_USER_SPACE_ON_USE;
     240         else newVal = PU_OBJECT_BOUNDING_BOX;
     241         if (newVal != filterUnits)
     242         {
     243         primitiveUnits = newVal;
     244         stateChange = true;
     245         }
     246         }
     247
     248         */
     249
    230250        return stateChange;
    231251    }
    232252}
    233 
  • trunk/src/com/kitfox/svg/Font.java

    r4256 r6002  
    11/*
    2  * Font.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import com.kitfox.svg.xml.*;
    32 import org.xml.sax.*;
    33 
    34 import java.util.*;
     39import java.util.HashMap;
    3540
    3641/**
     
    4449public class Font extends SVGElement
    4550{
     51
     52    public static final String TAG_NAME = "font";
    4653    int horizOriginX = 0;
    4754    int horizOriginY = 0;
     
    5057    int vertOriginY = -1;  //Defaults to font's ascent
    5158    int vertAdvY = -1;  //Defaults to one 'em'.  See font-face
    52 
    5359    FontFace fontFace = null;
    5460    MissingGlyph missingGlyph = null;
    5561    final HashMap glyphs = new HashMap();
    5662
    57     /** Creates a new instance of Font */
     63    /**
     64     * Creates a new instance of Font
     65     */
    5866    public Font()
    5967    {
    6068    }
    61 /*
    62     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    63     {
    64                 //Load style string
    65         super.loaderStartElement(helper, attrs, parent);
    66 
    67         String horizOriginX = attrs.getValue("horiz-origin-x");
    68         String horizOriginY = attrs.getValue("horiz-origin-y");
    69         String horizAdvX = attrs.getValue("horiz-adv-x");
    70         String vertOriginX = attrs.getValue("vert-origin-x");
    71         String vertOriginY = attrs.getValue("vert-origin-y");
    72         String vertAdvY = attrs.getValue("vert-adv-y");
    73 
    74         if (horizOriginX != null) this.horizOriginX = XMLParseUtil.parseInt(horizOriginX);
    75         if (horizOriginY != null) this.horizOriginY = XMLParseUtil.parseInt(horizOriginY);
    76         if (horizAdvX != null) this.horizAdvX = XMLParseUtil.parseInt(horizAdvX);
    77         if (vertOriginX != null) this.vertOriginX = XMLParseUtil.parseInt(vertOriginX);
    78         if (vertOriginY != null) this.vertOriginY = XMLParseUtil.parseInt(vertOriginY);
    79         if (vertAdvY != null) this.vertAdvY = XMLParseUtil.parseInt(vertAdvY);
    80 
    81     }
    82 */
     69
     70    public String getTagName()
     71    {
     72        return TAG_NAME;
     73    }
     74
    8375    /**
    8476     * Called after the start element but before the end element to indicate
     
    8779    public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
    8880    {
    89                 super.loaderAddChild(helper, child);
     81        super.loaderAddChild(helper, child);
    9082
    9183        if (child instanceof Glyph)
    9284        {
    93             glyphs.put(((Glyph)child).getUnicode(), child);
    94         }
    95         else if (child instanceof MissingGlyph)
    96         {
    97             missingGlyph = (MissingGlyph)child;
    98         }
    99         else if (child instanceof FontFace)
    100         {
    101             fontFace = (FontFace)child;
     85            glyphs.put(((Glyph) child).getUnicode(), child);
     86        } else if (child instanceof MissingGlyph)
     87        {
     88            missingGlyph = (MissingGlyph) child;
     89        } else if (child instanceof FontFace)
     90        {
     91            fontFace = (FontFace) child;
    10292        }
    10393    }
     
    10898
    10999        //build();
    110        
     100
    111101        helper.universe.registerFont(this);
    112102    }
    113    
     103
    114104    protected void build() throws SVGException
    115105    {
    116106        super.build();
    117        
     107
    118108        StyleAttribute sty = new StyleAttribute();
    119        
    120         if (getPres(sty.setName("horiz-origin-x"))) horizOriginX = sty.getIntValue();
    121        
    122         if (getPres(sty.setName("horiz-origin-y"))) horizOriginY = sty.getIntValue();
    123        
    124         if (getPres(sty.setName("horiz-adv-x"))) horizAdvX = sty.getIntValue();
    125        
    126         if (getPres(sty.setName("vert-origin-x"))) vertOriginX = sty.getIntValue();
    127        
    128         if (getPres(sty.setName("vert-origin-y"))) vertOriginY = sty.getIntValue();
    129        
    130         if (getPres(sty.setName("vert-adv-y"))) vertAdvY = sty.getIntValue();
    131     }
    132    
    133     public FontFace getFontFace() { return fontFace; }
     109
     110        if (getPres(sty.setName("horiz-origin-x")))
     111        {
     112            horizOriginX = sty.getIntValue();
     113        }
     114
     115        if (getPres(sty.setName("horiz-origin-y")))
     116        {
     117            horizOriginY = sty.getIntValue();
     118        }
     119
     120        if (getPres(sty.setName("horiz-adv-x")))
     121        {
     122            horizAdvX = sty.getIntValue();
     123        }
     124
     125        if (getPres(sty.setName("vert-origin-x")))
     126        {
     127            vertOriginX = sty.getIntValue();
     128        }
     129
     130        if (getPres(sty.setName("vert-origin-y")))
     131        {
     132            vertOriginY = sty.getIntValue();
     133        }
     134
     135        if (getPres(sty.setName("vert-adv-y")))
     136        {
     137            vertAdvY = sty.getIntValue();
     138        }
     139    }
     140
     141    public FontFace getFontFace()
     142    {
     143        return fontFace;
     144    }
    134145
    135146    public MissingGlyph getGlyph(String unicode)
    136147    {
    137         Glyph retVal = (Glyph)glyphs.get(unicode);
    138         if (retVal == null) return missingGlyph;
     148        Glyph retVal = (Glyph) glyphs.get(unicode);
     149        if (retVal == null)
     150        {
     151            return missingGlyph;
     152        }
    139153        return retVal;
    140154    }
    141155
    142     public int getHorizOriginX() { return horizOriginX; }
    143     public int getHorizOriginY() { return horizOriginY; }
    144     public int getHorizAdvX() { return horizAdvX; }
     156    public int getHorizOriginX()
     157    {
     158        return horizOriginX;
     159    }
     160
     161    public int getHorizOriginY()
     162    {
     163        return horizOriginY;
     164    }
     165
     166    public int getHorizAdvX()
     167    {
     168        return horizAdvX;
     169    }
    145170
    146171    public int getVertOriginX()
    147172    {
    148         if (vertOriginX != -1) return vertOriginX;
     173        if (vertOriginX != -1)
     174        {
     175            return vertOriginX;
     176        }
    149177        vertOriginX = getHorizAdvX() / 2;
    150178        return vertOriginX;
     
    153181    public int getVertOriginY()
    154182    {
    155         if (vertOriginY != -1) return vertOriginY;
     183        if (vertOriginY != -1)
     184        {
     185            return vertOriginY;
     186        }
    156187        vertOriginY = fontFace.getAscent();
    157188        return vertOriginY;
     
    160191    public int getVertAdvY()
    161192    {
    162         if (vertAdvY != -1) return vertAdvY;
     193        if (vertAdvY != -1)
     194        {
     195            return vertAdvY;
     196        }
    163197        vertAdvY = fontFace.getUnitsPerEm();
    164198        return vertAdvY;
    165199    }
    166    
     200
    167201    /**
    168      * Updates all attributes in this diagram associated with a time event.
    169      * Ie, all attributes with track information.
     202     * Updates all attributes in this diagram associated with a time event. Ie,
     203     * all attributes with track information.
     204     *
    170205     * @return - true if this node has changed state as a result of the time
    171206     * update
     
    176211        return false;
    177212        /*
    178         if (trackManager.getNumTracks() == 0) return false;
    179        
    180         //Get current values for parameters
    181         StyleAttribute sty = new StyleAttribute();
    182         boolean stateChange = false;
    183        
    184         if (getPres(sty.setName("horiz-origin-x")))
    185         {
    186             int newVal = sty.getIntValue();
    187             if (newVal != horizOriginX)
    188             {
    189                 horizOriginX = newVal;
    190                 stateChange = true;
    191             }
    192         }
    193        
    194         if (getPres(sty.setName("horiz-origin-y")))
    195         {
    196             int newVal = sty.getIntValue();
    197             if (newVal != horizOriginY)
    198             {
    199                 horizOriginY = newVal;
    200                 stateChange = true;
    201             }
    202         }
    203        
    204         if (getPres(sty.setName("horiz-adv-x")))
    205         {
    206             int newVal = sty.getIntValue();
    207             if (newVal != horizAdvX)
    208             {
    209                 horizAdvX = newVal;
    210                 stateChange = true;
    211             }
    212         }
    213        
    214         if (getPres(sty.setName("vert-origin-x")))
    215         {
    216             int newVal = sty.getIntValue();
    217             if (newVal != vertOriginX)
    218             {
    219                 vertOriginX = newVal;
    220                 stateChange = true;
    221             }
    222         }
    223        
    224         if (getPres(sty.setName("vert-origin-y")))
    225         {
    226             int newVal = sty.getIntValue();
    227             if (newVal != vertOriginY)
    228             {
    229                 vertOriginY = newVal;
    230                 stateChange = true;
    231             }
    232         }
    233        
    234         if (getPres(sty.setName("vert-adv-y")))
    235         {
    236             int newVal = sty.getIntValue();
    237             if (newVal != vertAdvY)
    238             {
    239                 vertAdvY = newVal;
    240                 stateChange = true;
    241             }
    242         }
    243        
    244         return shapeChange;
    245         */
     213         if (trackManager.getNumTracks() == 0) return false;
     214       
     215         //Get current values for parameters
     216         StyleAttribute sty = new StyleAttribute();
     217         boolean stateChange = false;
     218       
     219         if (getPres(sty.setName("horiz-origin-x")))
     220         {
     221         int newVal = sty.getIntValue();
     222         if (newVal != horizOriginX)
     223         {
     224         horizOriginX = newVal;
     225         stateChange = true;
     226         }
     227         }
     228       
     229         if (getPres(sty.setName("horiz-origin-y")))
     230         {
     231         int newVal = sty.getIntValue();
     232         if (newVal != horizOriginY)
     233         {
     234         horizOriginY = newVal;
     235         stateChange = true;
     236         }
     237         }
     238       
     239         if (getPres(sty.setName("horiz-adv-x")))
     240         {
     241         int newVal = sty.getIntValue();
     242         if (newVal != horizAdvX)
     243         {
     244         horizAdvX = newVal;
     245         stateChange = true;
     246         }
     247         }
     248       
     249         if (getPres(sty.setName("vert-origin-x")))
     250         {
     251         int newVal = sty.getIntValue();
     252         if (newVal != vertOriginX)
     253         {
     254         vertOriginX = newVal;
     255         stateChange = true;
     256         }
     257         }
     258       
     259         if (getPres(sty.setName("vert-origin-y")))
     260         {
     261         int newVal = sty.getIntValue();
     262         if (newVal != vertOriginY)
     263         {
     264         vertOriginY = newVal;
     265         stateChange = true;
     266         }
     267         }
     268       
     269         if (getPres(sty.setName("vert-adv-y")))
     270         {
     271         int newVal = sty.getIntValue();
     272         if (newVal != vertAdvY)
     273         {
     274         vertAdvY = newVal;
     275         stateChange = true;
     276         }
     277         }
     278       
     279         return shapeChange;
     280         */
    246281    }
    247282}
  • trunk/src/com/kitfox/svg/FontFace.java

    r4256 r6002  
    11/*
    2  * Font.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import com.kitfox.svg.xml.*;
    32 import org.xml.sax.*;
    33 
    34 import java.awt.geom.*;
    35 import java.awt.*;
    36 
    3739
    3840/**
     
    4648public class FontFace extends SVGElement
    4749{
     50
     51    public static final String TAG_NAME = "fontface";
    4852    String fontFamily;
    49 
    50     /** Em size of coordinate system font is defined in */
     53    /**
     54     * Em size of coordinate system font is defined in
     55     */
    5156    int unitsPerEm = 1000;
    52 
    5357    int ascent = -1;
    5458    int descent = -1;
    5559    int accentHeight = -1;
    56 
    5760    int underlinePosition = -1;
    5861    int underlineThickness = -1;
     
    6265    int overlineThickness = -1;
    6366
    64     /** Creates a new instance of Font */
     67    /**
     68     * Creates a new instance of Font
     69     */
    6570    public FontFace()
    6671    {
    6772    }
    68 /*
    69     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    70     {
    71                 //Load style string
    72         super.loaderStartElement(helper, attrs, parent);
    73 
    74         fontFamily = attrs.getValue("font-family");
    75 
    76         String unitsPerEm = attrs.getValue("units-per-em");
    77         String ascent = attrs.getValue("ascent");
    78         String descent = attrs.getValue("descent");
    79         String accentHeight = attrs.getValue("accent-height");
    80 
    81         String underlinePosition = attrs.getValue("underline-position");
    82         String underlineThickness = attrs.getValue("underline-thickness");
    83         String strikethroughPosition = attrs.getValue("strikethrough-position");
    84         String strikethroughThickness = attrs.getValue("strikethrough-thickness");
    85         String overlinePosition = attrs.getValue("overline-position");
    86         String overlineThickness = attrs.getValue("overline-thickness");
    87 
    88 
    89         if (unitsPerEm != null) this.unitsPerEm = XMLParseUtil.parseInt(unitsPerEm);
    90         if (ascent != null) this.ascent = XMLParseUtil.parseInt(ascent);
    91         if (descent != null) this.descent = XMLParseUtil.parseInt(descent);
    92         if (accentHeight != null) this.accentHeight = XMLParseUtil.parseInt(accentHeight);
    93 
    94         if (underlinePosition != null) this.underlinePosition = XMLParseUtil.parseInt(underlinePosition);
    95         if (underlineThickness != null) this.underlineThickness = XMLParseUtil.parseInt(underlineThickness);
    96         if (strikethroughPosition != null) this.strikethroughPosition = XMLParseUtil.parseInt(strikethroughPosition);
    97         if (strikethroughThickness != null) this.strikethroughThickness = XMLParseUtil.parseInt(strikethroughThickness);
    98         if (overlinePosition != null) this.overlinePosition = XMLParseUtil.parseInt(overlinePosition);
    99         if (overlineThickness != null) this.overlineThickness = XMLParseUtil.parseInt(overlineThickness);
    100 
    101 //        unitFontXform.setToScale(1.0 / (double)unitsPerEm, 1.0 / (double)unitsPerEm);
    102     }
    103   */ 
    104     /*
    105     public void loaderEndElement(SVGLoaderHelper helper)
    106     {
    107         super.loaderEndElement(helper);
    108 
    109         build();
    110        
    111 //        unitFontXform.setToScale(1.0 / (double)unitsPerEm, 1.0 / (double)unitsPerEm);
    112     }
    113      */
    114    
     73
     74    public String getTagName()
     75    {
     76        return TAG_NAME;
     77    }
     78
    11579    protected void build() throws SVGException
    11680    {
    11781        super.build();
    118        
     82
    11983        StyleAttribute sty = new StyleAttribute();
    120        
    121         if (getPres(sty.setName("font-family"))) fontFamily = sty.getStringValue();
    122        
    123         if (getPres(sty.setName("units-per-em"))) unitsPerEm = sty.getIntValue();
    124         if (getPres(sty.setName("ascent"))) ascent = sty.getIntValue();
    125         if (getPres(sty.setName("descent"))) descent = sty.getIntValue();
    126         if (getPres(sty.setName("accent-height"))) accentHeight = sty.getIntValue();
    127 
    128         if (getPres(sty.setName("underline-position"))) underlinePosition = sty.getIntValue();
    129         if (getPres(sty.setName("underline-thickness"))) underlineThickness = sty.getIntValue();
    130         if (getPres(sty.setName("strikethrough-position"))) strikethroughPosition = sty.getIntValue();
    131         if (getPres(sty.setName("strikethrough-thickenss"))) strikethroughThickness = sty.getIntValue();
    132         if (getPres(sty.setName("overline-position"))) overlinePosition = sty.getIntValue();
    133         if (getPres(sty.setName("overline-thickness"))) overlineThickness = sty.getIntValue();
    134     }
    135 
    136 
    137     public String getFontFamily() { return fontFamily; }
    138 
    139     public int getUnitsPerEm() { return unitsPerEm; }
     84
     85        if (getPres(sty.setName("font-family")))
     86        {
     87            fontFamily = sty.getStringValue();
     88        }
     89
     90        if (getPres(sty.setName("units-per-em")))
     91        {
     92            unitsPerEm = sty.getIntValue();
     93        }
     94        if (getPres(sty.setName("ascent")))
     95        {
     96            ascent = sty.getIntValue();
     97        }
     98        if (getPres(sty.setName("descent")))
     99        {
     100            descent = sty.getIntValue();
     101        }
     102        if (getPres(sty.setName("accent-height")))
     103        {
     104            accentHeight = sty.getIntValue();
     105        }
     106
     107        if (getPres(sty.setName("underline-position")))
     108        {
     109            underlinePosition = sty.getIntValue();
     110        }
     111        if (getPres(sty.setName("underline-thickness")))
     112        {
     113            underlineThickness = sty.getIntValue();
     114        }
     115        if (getPres(sty.setName("strikethrough-position")))
     116        {
     117            strikethroughPosition = sty.getIntValue();
     118        }
     119        if (getPres(sty.setName("strikethrough-thickenss")))
     120        {
     121            strikethroughThickness = sty.getIntValue();
     122        }
     123        if (getPres(sty.setName("overline-position")))
     124        {
     125            overlinePosition = sty.getIntValue();
     126        }
     127        if (getPres(sty.setName("overline-thickness")))
     128        {
     129            overlineThickness = sty.getIntValue();
     130        }
     131    }
     132
     133    public String getFontFamily()
     134    {
     135        return fontFamily;
     136    }
     137
     138    public int getUnitsPerEm()
     139    {
     140        return unitsPerEm;
     141    }
    140142
    141143    public int getAscent()
    142144    {
    143145        if (ascent == -1)
    144             ascent = unitsPerEm - ((Font)parent).getVertOriginY();
     146        {
     147            ascent = unitsPerEm - ((Font) parent).getVertOriginY();
     148        }
    145149        return ascent;
    146150    }
     
    149153    {
    150154        if (descent == -1)
    151             descent = ((Font)parent).getVertOriginY();
     155        {
     156            descent = ((Font) parent).getVertOriginY();
     157        }
    152158        return descent;
    153159    }
     
    156162    {
    157163        if (accentHeight == -1)
     164        {
    158165            accentHeight = getAscent();
     166        }
    159167        return accentHeight;
    160168    }
     
    163171    {
    164172        if (underlinePosition == -1)
     173        {
    165174            underlinePosition = unitsPerEm * 5 / 6;
     175        }
    166176        return underlinePosition;
    167177    }
     
    170180    {
    171181        if (underlineThickness == -1)
     182        {
    172183            underlineThickness = unitsPerEm / 20;
     184        }
    173185        return underlineThickness;
    174186    }
     
    177189    {
    178190        if (strikethroughPosition == -1)
     191        {
    179192            strikethroughPosition = unitsPerEm * 3 / 6;
     193        }
    180194        return strikethroughPosition;
    181195    }
     
    184198    {
    185199        if (strikethroughThickness == -1)
     200        {
    186201            strikethroughThickness = unitsPerEm / 20;
     202        }
    187203        return strikethroughThickness;
    188204    }
     
    191207    {
    192208        if (overlinePosition == -1)
     209        {
    193210            overlinePosition = unitsPerEm * 5 / 6;
     211        }
    194212        return overlinePosition;
    195213    }
     
    198216    {
    199217        if (overlineThickness == -1)
     218        {
    200219            overlineThickness = unitsPerEm / 20;
     220        }
    201221        return overlineThickness;
    202222    }
    203    
     223
    204224    /**
    205      * Updates all attributes in this diagram associated with a time event.
    206      * Ie, all attributes with track information.
     225     * Updates all attributes in this diagram associated with a time event. Ie,
     226     * all attributes with track information.
     227     *
    207228     * @return - true if this node has changed state as a result of the time
    208229     * update
  • trunk/src/com/kitfox/svg/Glyph.java

    r4256 r6002  
    11/*
    2  * Font.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import com.kitfox.svg.xml.*;
    32 import org.xml.sax.*;
    33 
    34 import java.awt.*;
    35 import java.awt.geom.*;
    36 import java.util.*;
    37 
    38 import com.kitfox.svg.pathcmd.*;
    39 //import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
    4039
    4140/**
     
    4948public class Glyph extends MissingGlyph
    5049{
     50
     51    public static final String TAG_NAME = "missingglyph";
    5152    /**
    52      * One or more characters indicating the unicode sequence that denotes
    53      * this glyph.
     53     * One or more characters indicating the unicode sequence that denotes this
     54     * glyph.
    5455     */
    5556    String unicode;
    5657
    57     /** Creates a new instance of Font */
     58    /**
     59     * Creates a new instance of Font
     60     */
    5861    public Glyph()
    5962    {
    6063    }
    61 /*
    62     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     64
     65    public String getTagName()
    6366    {
    64                 //Load style string
    65         super.loaderStartElement(helper, attrs, parent);
     67        return TAG_NAME;
     68    }
    6669
    67         //Get unicode sequence that maps to this glyph
    68         unicode = attrs.getValue("unicode");
    69     }
    70 */
    71     /*
    72     public void loaderEndElement(SVGLoaderHelper helper)
    73     {
    74         super.loaderEndElement(helper);
    75 
    76         build();
    77     }
    78      */
    79    
    8070    protected void build() throws SVGException
    8171    {
    8272        super.build();
    83        
     73
    8474        StyleAttribute sty = new StyleAttribute();
    85        
    86         if (getPres(sty.setName("unicode"))) unicode = sty.getStringValue();
     75
     76        if (getPres(sty.setName("unicode")))
     77        {
     78            unicode = sty.getStringValue();
     79        }
    8780    }
    88    
    89     public String getUnicode() { return unicode; }
    90    
     81
     82    public String getUnicode()
     83    {
     84        return unicode;
     85    }
     86
    9187    /**
    92      * Updates all attributes in this diagram associated with a time event.
    93      * Ie, all attributes with track information.
     88     * Updates all attributes in this diagram associated with a time event. Ie,
     89     * all attributes with track information.
     90     *
    9491     * @return - true if this node has changed state as a result of the time
    9592     * update
  • trunk/src/com/kitfox/svg/Gradient.java

    r4256 r6002  
    11/*
    2  * Gradient.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 3:25 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    30 import java.net.*;
    31 import java.util.*;
    32 import java.awt.geom.*;
    33 import java.awt.*;
    34 
    35 import com.kitfox.svg.xml.*;
     38import com.kitfox.svg.xml.StyleAttribute;
     39import java.awt.Color;
     40import java.awt.geom.AffineTransform;
     41import java.net.URI;
     42import java.util.ArrayList;
     43import java.util.Iterator;
     44import java.util.logging.Level;
     45import java.util.logging.Logger;
    3646
    3747/**
     
    4151abstract public class Gradient extends FillElement
    4252{
    43 
     53    public static final String TAG_NAME = "gradient";
     54   
    4455    public static final int SM_PAD = 0;
    4556    public static final int SM_REPEAT = 1;
    4657    public static final int SM_REFLECT = 2;
    47 
    4858    int spreadMethod = SM_PAD;
    49 
    5059    public static final int GU_OBJECT_BOUNDING_BOX = 0;
    5160    public static final int GU_USER_SPACE_ON_USE = 1;
    52 
    5361    protected int gradientUnits = GU_OBJECT_BOUNDING_BOX;
    54 
    5562    //Either this gradient contains a list of stops, or it will take it's
    5663    // stops from the referenced gradient
    5764    ArrayList stops = new ArrayList();
    5865    URI stopRef = null;
    59 //    Gradient stopRef = null;
    60 
    6166    protected AffineTransform gradientTransform = null;
    62 
     67   
    6368    //Cache arrays of stop values here
    6469    float[] stopFractions;
    6570    Color[] stopColors;
    6671
    67     /** Creates a new instance of Gradient */
    68     public Gradient() {
    69     }
    70    
     72    /**
     73     * Creates a new instance of Gradient
     74     */
     75    public Gradient()
     76    {
     77    }
     78
     79    public String getTagName()
     80    {
     81        return TAG_NAME;
     82    }
     83
    7184    /**
    7285     * Called after the start element but before the end element to indicate
     
    7790        super.loaderAddChild(helper, child);
    7891
    79         if (!(child instanceof Stop)) return;
    80         appendStop((Stop)child);
     92        if (!(child instanceof Stop))
     93        {
     94            return;
     95        }
     96        appendStop((Stop) child);
    8197    }
    8298
     
    84100    {
    85101        super.build();
    86        
     102
    87103        StyleAttribute sty = new StyleAttribute();
    88104        String strn;
    89        
     105
    90106        if (getPres(sty.setName("spreadMethod")))
    91107        {
    92108            strn = sty.getStringValue().toLowerCase();
    93             if (strn.equals("repeat")) spreadMethod = SM_REPEAT;
    94             else if (strn.equals("reflect")) spreadMethod = SM_REFLECT;
    95             else spreadMethod = SM_PAD;
     109            if (strn.equals("repeat"))
     110            {
     111                spreadMethod = SM_REPEAT;
     112            } else if (strn.equals("reflect"))
     113            {
     114                spreadMethod = SM_REFLECT;
     115            } else
     116            {
     117                spreadMethod = SM_PAD;
     118            }
    96119        }
    97120
     
    99122        {
    100123            strn = sty.getStringValue().toLowerCase();
    101             if (strn.equals("userspaceonuse")) gradientUnits = GU_USER_SPACE_ON_USE;
    102             else gradientUnits = GU_OBJECT_BOUNDING_BOX;
    103         }
    104 
    105         if (getPres(sty.setName("gradientTransform"))) gradientTransform = parseTransform(sty.getStringValue());
     124            if (strn.equals("userspaceonuse"))
     125            {
     126                gradientUnits = GU_USER_SPACE_ON_USE;
     127            } else
     128            {
     129                gradientUnits = GU_OBJECT_BOUNDING_BOX;
     130            }
     131        }
     132
     133        if (getPres(sty.setName("gradientTransform")))
     134        {
     135            gradientTransform = parseTransform(sty.getStringValue());
     136        }
    106137        //If we still don't have one, set it to identity
    107         if (gradientTransform == null) gradientTransform = new AffineTransform();
    108 
    109        
     138        if (gradientTransform == null)
     139        {
     140            gradientTransform = new AffineTransform();
     141        }
     142
     143
    110144        //Check to see if we're using our own stops or referencing someone else's
    111145        if (getPres(sty.setName("xlink:href")))
    112146        {
    113             try {
     147            try
     148            {
    114149                stopRef = sty.getURIValue(getXMLBase());
    115150//System.err.println("Gradient: " + sty.getStringValue() + ", " + getXMLBase() + ", " + src);
    116151//                URI src = getXMLBase().resolve(href);
    117152//                stopRef = (Gradient)diagram.getUniverse().getElement(src);
    118             }
    119             catch (Exception e)
     153            } catch (Exception e)
    120154            {
    121155                throw new SVGException("Could not resolve relative URL in Gradient: " + sty.getStringValue() + ", " + getXMLBase(), e);
     
    123157        }
    124158    }
    125    
     159
    126160    public float[] getStopFractions()
    127161    {
    128162        if (stopRef != null)
    129163        {
    130             Gradient grad = (Gradient)diagram.getUniverse().getElement(stopRef);
     164            Gradient grad = (Gradient) diagram.getUniverse().getElement(stopRef);
    131165            return grad.getStopFractions();
    132166        }
    133167
    134         if (stopFractions != null) return stopFractions;
     168        if (stopFractions != null)
     169        {
     170            return stopFractions;
     171        }
    135172
    136173        stopFractions = new float[stops.size()];
     
    138175        for (Iterator it = stops.iterator(); it.hasNext();)
    139176        {
    140             Stop stop = (Stop)it.next();
     177            Stop stop = (Stop) it.next();
    141178            float val = stop.offset;
    142             if (idx != 0 && val < stopFractions[idx - 1]) val = stopFractions[idx - 1];
     179            if (idx != 0 && val < stopFractions[idx - 1])
     180            {
     181                val = stopFractions[idx - 1];
     182            }
    143183            stopFractions[idx++] = val;
    144184        }
     
    151191        if (stopRef != null)
    152192        {
    153             Gradient grad = (Gradient)diagram.getUniverse().getElement(stopRef);
     193            Gradient grad = (Gradient) diagram.getUniverse().getElement(stopRef);
    154194            return grad.getStopColors();
    155195        }
    156196
    157         if (stopColors != null) return stopColors;
     197        if (stopColors != null)
     198        {
     199            return stopColors;
     200        }
    158201
    159202        stopColors = new Color[stops.size()];
     
    161204        for (Iterator it = stops.iterator(); it.hasNext();)
    162205        {
    163             Stop stop = (Stop)it.next();
     206            Stop stop = (Stop) it.next();
    164207            int stopColorVal = stop.color.getRGB();
    165             Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int)(stop.opacity * 255), 0, 255));
     208            Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int) (stop.opacity * 255), 0, 255));
    166209            stopColors[idx++] = stopColor;
    167210        }
     
    169212        return stopColors;
    170213    }
    171    
     214
    172215    public void setStops(Color[] colors, float[] fractions)
    173216    {
     
    176219            throw new IllegalArgumentException();
    177220        }
    178        
     221
    179222        this.stopColors = colors;
    180223        this.stopFractions = fractions;
    181224        stopRef = null;
    182225    }
    183    
     226
    184227    private int clamp(int val, int min, int max)
    185228    {
    186         if (val < min) return min;
    187         if (val > max) return max;
     229        if (val < min)
     230        {
     231            return min;
     232        }
     233        if (val > max)
     234        {
     235            return max;
     236        }
    188237        return val;
    189238    }
    190    
     239
    191240    public void setStopRef(URI grad)
    192241    {
     
    200249
    201250    /**
    202      * Updates all attributes in this diagram associated with a time event.
    203      * Ie, all attributes with track information.
     251     * Updates all attributes in this diagram associated with a time event. Ie,
     252     * all attributes with track information.
     253     *
    204254     * @return - true if this node has changed state as a result of the time
    205255     * update
     
    214264        boolean shapeChange = false;
    215265        String strn;
    216        
     266
    217267
    218268        if (getPres(sty.setName("spreadMethod")))
     
    220270            int newVal;
    221271            strn = sty.getStringValue().toLowerCase();
    222             if (strn.equals("repeat")) newVal = SM_REPEAT;
    223             else if (strn.equals("reflect")) newVal = SM_REFLECT;
    224             else newVal = SM_PAD;
     272            if (strn.equals("repeat"))
     273            {
     274                newVal = SM_REPEAT;
     275            } else if (strn.equals("reflect"))
     276            {
     277                newVal = SM_REFLECT;
     278            } else
     279            {
     280                newVal = SM_PAD;
     281            }
    225282            if (spreadMethod != newVal)
    226283            {
     
    229286            }
    230287        }
    231        
     288
    232289        if (getPres(sty.setName("gradientUnits")))
    233290        {
    234291            int newVal;
    235292            strn = sty.getStringValue().toLowerCase();
    236             if (strn.equals("userspaceonuse")) newVal = GU_USER_SPACE_ON_USE;
    237             else newVal = GU_OBJECT_BOUNDING_BOX;
     293            if (strn.equals("userspaceonuse"))
     294            {
     295                newVal = GU_USER_SPACE_ON_USE;
     296            } else
     297            {
     298                newVal = GU_OBJECT_BOUNDING_BOX;
     299            }
    238300            if (newVal != gradientUnits)
    239301            {
     
    253315        }
    254316
    255        
     317
    256318        //Check to see if we're using our own stops or referencing someone else's
    257319        if (getPres(sty.setName("xlink:href")))
    258320        {
    259             try {
     321            try
     322            {
    260323                URI newVal = sty.getURIValue(getXMLBase());
    261324                if ((newVal == null && stopRef != null) || !newVal.equals(stopRef))
     
    264327                    stateChange = true;
    265328                }
    266             }
    267             catch (Exception e)
    268             {
    269                 e.printStackTrace();
    270             }
    271         }
    272        
     329            } catch (Exception e)
     330            {
     331                Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
     332                    "Could not parse xlink:href", e);
     333            }
     334        }
     335
    273336        //Check stops, if any
    274337        for (Iterator it = stops.iterator(); it.hasNext();)
    275338        {
    276             Stop stop = (Stop)it.next();
     339            Stop stop = (Stop) it.next();
    277340            if (stop.updateTime(curTime))
    278341            {
     
    282345            }
    283346        }
    284        
     347
    285348        return stateChange;
    286349    }
    287 
    288350}
  • trunk/src/com/kitfox/svg/Group.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 1:56 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    3139import java.awt.Graphics2D;
    32 import java.awt.Rectangle;
    3340import java.awt.Shape;
    3441import java.awt.geom.AffineTransform;
     
    4047import java.util.List;
    4148
    42 
    4349/**
    4450 * @author Mark McKay
     
    4753public class Group extends ShapeElement
    4854{
    49 
     55    public static final String TAG_NAME = "group";
     56   
    5057    //Cache bounding box for faster clip testing
    5158    Rectangle2D boundingBox;
    5259    Shape cachedShape;
    5360
    54     //Cache clip bounds
    55     final Rectangle clipBounds = new Rectangle();
    56 
    57     /** Creates a new instance of Stop */
    58     public Group() {
    59     }
    60 
    61     /*
    62     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    63     {
    64         //Load style string
    65         super.loaderStartElement(helper, attrs, parent);
    66 
    67         //String transform = attrs.getValue("transform");
    68     }
    69      */
     61    /**
     62     * Creates a new instance of Stop
     63     */
     64    public Group()
     65    {
     66    }
     67
     68    public String getTagName()
     69    {
     70        return TAG_NAME;
     71    }
    7072
    7173    /**
     
    7678    {
    7779        super.loaderAddChild(helper, child);
    78 
    79 //        members.add(child);
    8080    }
    8181
    8282    protected boolean outsideClip(Graphics2D g) throws SVGException
    8383    {
    84         g.getClipBounds(clipBounds);
     84        Shape clip = g.getClip();
     85        if (clip == null)
     86        {
     87            return false;
     88        }
     89        //g.getClipBounds(clipBounds);
    8590        Rectangle2D rect = getBoundingBox();
    8691
    87 //if (rect == null)
    88 //{
    89 //    rect = getBoundingBox();
    90 //}
    91 
    92 //        if (rect.intersects(clipBounds))
    93         if (rect.intersects(clipBounds))
     92        if (clip.intersects(rect))
    9493        {
    9594            return false;
     
    107106            {
    108107                xform.inverseTransform(point, xPoint);
    109             }
    110             catch (NoninvertibleTransformException ex)
     108            } catch (NoninvertibleTransformException ex)
    111109            {
    112110                throw new SVGException(ex);
    113111            }
    114112        }
    115        
    116        
     113
     114
    117115        for (Iterator it = children.iterator(); it.hasNext();)
    118116        {
    119             SVGElement ele = (SVGElement)it.next();
    120             if (ele instanceof RenderableElement)
    121             {
    122                 RenderableElement rendEle = (RenderableElement)ele;
    123                
     117            SVGElement ele = (SVGElement) it.next();
     118            if (ele instanceof RenderableElement)
     119            {
     120                RenderableElement rendEle = (RenderableElement) ele;
     121
    124122                rendEle.pick(xPoint, boundingBox, retVec);
    125123            }
     
    134132            ltw.concatenate(xform);
    135133        }
    136        
    137        
     134
     135
    138136        for (Iterator it = children.iterator(); it.hasNext();)
    139137        {
    140             SVGElement ele = (SVGElement)it.next();
    141             if (ele instanceof RenderableElement)
    142             {
    143                 RenderableElement rendEle = (RenderableElement)ele;
    144                
     138            SVGElement ele = (SVGElement) it.next();
     139            if (ele instanceof RenderableElement)
     140            {
     141                RenderableElement rendEle = (RenderableElement) ele;
     142
    145143                rendEle.pick(pickArea, ltw, boundingBox, retVec);
    146144            }
     
    154152        if (getStyle(styleAttrib.setName("visibility")))
    155153        {
    156             if (!styleAttrib.getStringValue().equals("visible")) return;
    157         }
    158        
     154            if (!styleAttrib.getStringValue().equals("visible"))
     155            {
     156                return;
     157            }
     158        }
     159
    159160        //Do not process offscreen groups
    160161        boolean ignoreClip = diagram.ignoringClipHeuristic();
    161         if (!ignoreClip && outsideClip(g)) return;
     162        if (!ignoreClip && outsideClip(g))
     163        {
     164            return;
     165        }
    162166
    163167        beginLayer(g);
     
    165169        Iterator it = children.iterator();
    166170
    167         try
    168         {
    169             g.getClipBounds(clipBounds);
    170         }
    171         catch (Exception e)
    172         {
    173             //For some reason, getClipBounds can throw a null pointer exception for
    174             // some types of Graphics2D
    175             ignoreClip = true;
    176         }
    177 
     171//        try
     172//        {
     173//            g.getClipBounds(clipBounds);
     174//        }
     175//        catch (Exception e)
     176//        {
     177//            //For some reason, getClipBounds can throw a null pointer exception for
     178//            // some types of Graphics2D
     179//            ignoreClip = true;
     180//        }
     181
     182        Shape clip = g.getClip();
    178183        while (it.hasNext())
    179184        {
    180             SVGElement ele = (SVGElement)it.next();
    181             if (ele instanceof RenderableElement)
    182             {
    183                 RenderableElement rendEle = (RenderableElement)ele;
     185            SVGElement ele = (SVGElement) it.next();
     186            if (ele instanceof RenderableElement)
     187            {
     188                RenderableElement rendEle = (RenderableElement) ele;
    184189
    185190//                if (shapeEle == null) continue;
     
    188193                {
    189194                    //Skip if clipping area is outside our bounds
    190                     if (!ignoreClip && !rendEle.getBoundingBox().intersects(clipBounds))
     195                    if (!ignoreClip && clip != null
     196                        && !clip.intersects(rendEle.getBoundingBox()))
    191197                    {
    192198                        continue;
     
    201207    }
    202208
    203 
    204209    /**
    205210     * Retrieves the cached bounding box of this group
     
    207212    public Shape getShape()
    208213    {
    209         if (cachedShape == null) calcShape();
     214        if (cachedShape == null)
     215        {
     216            calcShape();
     217        }
    210218        return cachedShape;
    211219    }
     
    217225        for (Iterator it = children.iterator(); it.hasNext();)
    218226        {
    219             SVGElement ele = (SVGElement)it.next();
     227            SVGElement ele = (SVGElement) it.next();
    220228
    221229            if (ele instanceof ShapeElement)
    222230            {
    223                 ShapeElement shpEle = (ShapeElement)ele;
     231                ShapeElement shpEle = (ShapeElement) ele;
    224232                Shape shape = shpEle.getShape();
    225233                if (shape != null)
     
    238246    public Rectangle2D getBoundingBox() throws SVGException
    239247    {
    240         if (boundingBox == null) calcBoundingBox();
     248        if (boundingBox == null)
     249        {
     250            calcBoundingBox();
     251        }
    241252//        calcBoundingBox();
    242253        return boundingBox;
     
    245256    /**
    246257     * Recalculates the bounding box by taking the union of the bounding boxes
    247      * of all children.  Caches the result.
     258     * of all children. Caches the result.
    248259     */
    249260    public void calcBoundingBox() throws SVGException
     
    254265        for (Iterator it = children.iterator(); it.hasNext();)
    255266        {
    256             SVGElement ele = (SVGElement)it.next();
    257 
    258             if (ele instanceof RenderableElement)
    259             {
    260                 RenderableElement rendEle = (RenderableElement)ele;
     267            SVGElement ele = (SVGElement) it.next();
     268
     269            if (ele instanceof RenderableElement)
     270            {
     271                RenderableElement rendEle = (RenderableElement) ele;
    261272                Rectangle2D bounds = rendEle.getBoundingBox();
    262273                if (bounds != null)
    263274                {
    264                     if (retRect == null) retRect = bounds;
    265                     else retRect = retRect.createUnion(bounds);
     275                    if (retRect == null)
     276                    {
     277                        retRect = bounds;
     278                    } else
     279                    {
     280                        retRect = retRect.createUnion(bounds);
     281                    }
    266282                }
    267283            }
     
    274290
    275291        //If no contents, use degenerate rectangle
    276         if (retRect == null) retRect = new Rectangle2D.Float();
     292        if (retRect == null)
     293        {
     294            retRect = new Rectangle2D.Float();
     295        }
    277296
    278297        boundingBox = boundsToParent(retRect);
     
    287306        while (it.hasNext())
    288307        {
    289             SVGElement ele = (SVGElement)it.next();
     308            SVGElement ele = (SVGElement) it.next();
    290309            boolean updateVal = ele.updateTime(curTime);
    291310
     
    293312
    294313            //Update our shape if shape aware children change
    295             if (ele instanceof ShapeElement) cachedShape = null;
    296             if (ele instanceof RenderableElement) boundingBox = null;
     314            if (ele instanceof ShapeElement)
     315            {
     316                cachedShape = null;
     317            }
     318            if (ele instanceof RenderableElement)
     319            {
     320                boundingBox = null;
     321            }
    297322        }
    298323
  • trunk/src/com/kitfox/svg/Hkern.java

    r4256 r6002  
    11/*
    2  * Font.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3644public class Hkern extends SVGElement
    3745{
     46
     47    public static final String TAG_NAME = "hkern";
    3848    String u1;
    3949    String u2;
    4050    int k;
    4151
     52    public String getTagName()
     53    {
     54        return TAG_NAME;
     55    }
    4256
    4357    protected void build() throws SVGException
     
    4963
    5064        //Read glyph spacing info
    51         if (getPres(sty.setName("u1"))) u1 = sty.getStringValue();
     65        if (getPres(sty.setName("u1")))
     66        {
     67            u1 = sty.getStringValue();
     68        }
    5269
    53         if (getPres(sty.setName("u2"))) u2 = sty.getStringValue();
     70        if (getPres(sty.setName("u2")))
     71        {
     72            u2 = sty.getStringValue();
     73        }
    5474
    55         if (getPres(sty.setName("k"))) k = sty.getIntValue();
     75        if (getPres(sty.setName("k")))
     76        {
     77            k = sty.getIntValue();
     78        }
    5679    }
    5780
     
    6184        return false;
    6285    }
    63    
    64    
    6586}
  • trunk/src/com/kitfox/svg/ImageSVG.java

    r4256 r6002  
    11/*
    2  * Font.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.app.data.Handler;
    31 import com.kitfox.svg.xml.*;
    32 
    33 import java.awt.*;
    34 import java.awt.geom.*;
    35 import java.awt.image.*;
    36 import java.net.*;
     39import com.kitfox.svg.xml.StyleAttribute;
     40import java.awt.AlphaComposite;
     41import java.awt.Composite;
     42import java.awt.Graphics2D;
     43import java.awt.geom.AffineTransform;
     44import java.awt.geom.Point2D;
     45import java.awt.geom.Rectangle2D;
     46import java.awt.image.BufferedImage;
     47import java.net.URI;
     48import java.net.URL;
    3749import java.util.List;
     50import java.util.logging.Level;
     51import java.util.logging.Logger;
    3852
    3953/**
    40  * Implements an embedded font.
    41  *
    42  * SVG specification: http://www.w3.org/TR/SVG/fonts.html
     54 * Implements an image.
    4355 *
    4456 * @author Mark McKay
     
    4759public class ImageSVG extends RenderableElement
    4860{
     61    public static final String TAG_NAME = "image";
     62   
    4963    float x = 0f;
    5064    float y = 0f;
    5165    float width = 0f;
    5266    float height = 0f;
    53 
    5467//    BufferedImage href = null;
    5568    URL imageSrc = null;
    56 
    5769    AffineTransform xform;
    5870    Rectangle2D bounds;
    5971
    60     /** Creates a new instance of Font */
     72    /**
     73     * Creates a new instance of Font
     74     */
    6175    public ImageSVG()
    6276    {
    6377    }
    64    
     78
     79    public String getTagName()
     80    {
     81        return TAG_NAME;
     82    }
     83
    6584    protected void build() throws SVGException
    6685    {
    6786        super.build();
    68        
     87
    6988        StyleAttribute sty = new StyleAttribute();
    70        
    71         if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
    72 
    73         if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
    74 
    75         if (getPres(sty.setName("width"))) width = sty.getFloatValueWithUnits();
    76 
    77         if (getPres(sty.setName("height"))) height = sty.getFloatValueWithUnits();
    78 
    79         try {
     89
     90        if (getPres(sty.setName("x")))
     91        {
     92            x = sty.getFloatValueWithUnits();
     93        }
     94
     95        if (getPres(sty.setName("y")))
     96        {
     97            y = sty.getFloatValueWithUnits();
     98        }
     99
     100        if (getPres(sty.setName("width")))
     101        {
     102            width = sty.getFloatValueWithUnits();
     103        }
     104
     105        if (getPres(sty.setName("height")))
     106        {
     107            height = sty.getFloatValueWithUnits();
     108        }
     109
     110        try
     111        {
    80112            if (getPres(sty.setName("xlink:href")))
    81113            {
     
    84116                {
    85117                    imageSrc = new URL(null, src.toASCIIString(), new Handler());
    86                 }
    87                 else
    88                 {
    89                     try {
     118                } else
     119                {
     120                    try
     121                    {
    90122                        imageSrc = src.toURL();
    91                     }
    92                     catch (Exception e)
     123                    } catch (Exception e)
    93124                    {
    94                         e.printStackTrace();
     125                        Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
     126                            "Could not parse xlink:href", e);
     127//                        e.printStackTrace();
    95128                        imageSrc = null;
    96129                    }
    97130                }
    98131            }
    99         }
    100         catch (Exception e)
     132        } catch (Exception e)
    101133        {
    102134            throw new SVGException(e);
     
    104136
    105137        diagram.getUniverse().registerImage(imageSrc);
    106        
     138
    107139        //Set widths if not set
    108140        BufferedImage img = diagram.getUniverse().getImage(imageSrc);
     
    113145            return;
    114146        }
    115        
    116         if (width == 0) width = img.getWidth();
    117         if (height == 0) height = img.getHeight();
    118        
     147
     148        if (width == 0)
     149        {
     150            width = img.getWidth();
     151        }
     152        if (height == 0)
     153        {
     154            height = img.getHeight();
     155        }
     156
    119157        //Determine image xform
    120158        xform = new AffineTransform();
     
    123161        xform.translate(this.x, this.y);
    124162        xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
    125        
     163
    126164        bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
    127165    }
    128    
    129    
    130    
    131     public float getX() { return x; }
    132     public float getY() { return y; }
    133     public float getWidth() { return width; }
    134     public float getHeight() { return height; }
     166
     167    public float getX()
     168    {
     169        return x;
     170    }
     171
     172    public float getY()
     173    {
     174        return y;
     175    }
     176
     177    public float getWidth()
     178    {
     179        return width;
     180    }
     181
     182    public float getHeight()
     183    {
     184        return height;
     185    }
    135186
    136187    void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
     
    155206        if (getStyle(styleAttrib.setName("visibility")))
    156207        {
    157             if (!styleAttrib.getStringValue().equals("visible")) return;
    158         }
    159        
     208            if (!styleAttrib.getStringValue().equals("visible"))
     209            {
     210                return;
     211            }
     212        }
     213
    160214        beginLayer(g);
    161        
     215
    162216        float opacity = 1f;
    163217        if (getStyle(styleAttrib.setName("opacity")))
     
    165219            opacity = styleAttrib.getRatioValue();
    166220        }
    167        
    168         if (opacity <= 0) return;
     221
     222        if (opacity <= 0)
     223        {
     224            return;
     225        }
    169226
    170227        Composite oldComp = null;
    171        
     228
    172229        if (opacity < 1)
    173230        {
     
    176233            g.setComposite(comp);
    177234        }
    178        
     235
    179236        BufferedImage img = diagram.getUniverse().getImage(imageSrc);
    180         if (img == null) return;
    181        
     237        if (img == null)
     238        {
     239            return;
     240        }
     241
    182242        AffineTransform curXform = g.getTransform();
    183243        g.transform(xform);
    184        
     244
    185245        g.drawImage(img, 0, 0, null);
    186        
     246
    187247        g.setTransform(curXform);
    188         if (oldComp != null) g.setComposite(oldComp);
    189        
     248        if (oldComp != null)
     249        {
     250            g.setComposite(oldComp);
     251        }
     252
    190253        finishLayer(g);
    191254    }
    192    
     255
    193256    public Rectangle2D getBoundingBox()
    194257    {
     
    197260
    198261    /**
    199      * Updates all attributes in this diagram associated with a time event.
    200      * Ie, all attributes with track information.
     262     * Updates all attributes in this diagram associated with a time event. Ie,
     263     * all attributes with track information.
     264     *
    201265     * @return - true if this node has changed state as a result of the time
    202266     * update
     
    210274        StyleAttribute sty = new StyleAttribute();
    211275        boolean shapeChange = false;
    212        
     276
    213277        if (getPres(sty.setName("x")))
    214278        {
     
    220284            }
    221285        }
    222        
     286
    223287        if (getPres(sty.setName("y")))
    224288        {
     
    230294            }
    231295        }
    232        
     296
    233297        if (getPres(sty.setName("width")))
    234298        {
     
    240304            }
    241305        }
    242        
     306
    243307        if (getPres(sty.setName("height")))
    244308        {
     
    250314            }
    251315        }
    252        
    253         try {
     316
     317        try
     318        {
    254319            if (getPres(sty.setName("xlink:href")))
    255320            {
    256321                URI src = sty.getURIValue(getXMLBase());
    257                 URL newVal = src.toURL();
    258                
     322
     323                URL newVal;
     324                if ("data".equals(src.getScheme()))
     325                {
     326                    newVal = new URL(null, src.toASCIIString(), new Handler());
     327                } else
     328                {
     329                    newVal = src.toURL();
     330                }
     331
    259332                if (!newVal.equals(imageSrc))
    260333                {
     
    263336                }
    264337            }
    265         }
    266         catch (IllegalArgumentException ie)
    267         {
    268             new Exception("Image provided with illegal value for href: \"" + sty.getStringValue() + '"', ie).printStackTrace();
    269         }
    270         catch (Exception e)
    271         {
    272             e.printStackTrace();
    273         }
    274 
    275        
     338        } catch (IllegalArgumentException ie)
     339        {
     340            Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
     341                "Image provided with illegal value for href: \""
     342                + sty.getStringValue() + '"', ie);
     343        } catch (Exception e)
     344        {
     345            Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
     346                "Could not parse xlink:href", e);
     347        }
     348
     349
    276350        if (shapeChange)
    277351        {
     
    303377//            return true;
    304378        }
    305        
     379
    306380        return changeState || shapeChange;
    307381    }
  • trunk/src/com/kitfox/svg/Line.java

    r4256 r6002  
    11/*
    2  * Rect.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 5:25 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3846 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3947 */
    40 public class Line extends ShapeElement {
    41 
     48public class Line extends ShapeElement
     49{
     50    public static final String TAG_NAME = "line";
     51   
    4252    float x1 = 0f;
    4353    float y1 = 0f;
    4454    float x2 = 0f;
    4555    float y2 = 0f;
     56    Line2D.Float line;
    4657
    47     Line2D.Float line;
    48 //    RectangularShape rect;
    49 
    50     /** Creates a new instance of Rect */
    51     public Line() {
     58    /**
     59     * Creates a new instance of Rect
     60     */
     61    public Line()
     62    {
    5263    }
    5364
    54     /*
    55     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     65    public String getTagName()
    5666    {
    57                 //Load style string
    58         super.loaderStartElement(helper, attrs, parent);
     67        return TAG_NAME;
     68    }
    5969
    60         String x1 = attrs.getValue("x1");
    61         String y1 = attrs.getValue("y1");
    62         String x2 = attrs.getValue("x2");
    63         String y2 = attrs.getValue("y2");
    64 
    65         this.x1 = XMLParseUtil.parseFloat(x1);
    66         this.y1 = XMLParseUtil.parseFloat(y1);
    67         this.x2 = XMLParseUtil.parseFloat(x2);
    68         this.y2 = XMLParseUtil.parseFloat(y2);
    69 
    70         build();
    71     }
    72 */
    7370    protected void build() throws SVGException
    7471    {
    7572        super.build();
    76        
     73
    7774        StyleAttribute sty = new StyleAttribute();
    78        
    79         if (getPres(sty.setName("x1"))) x1 = sty.getFloatValueWithUnits();
    8075
    81         if (getPres(sty.setName("y1"))) y1 = sty.getFloatValueWithUnits();
     76        if (getPres(sty.setName("x1")))
     77        {
     78            x1 = sty.getFloatValueWithUnits();
     79        }
    8280
    83         if (getPres(sty.setName("x2"))) x2 = sty.getFloatValueWithUnits();
     81        if (getPres(sty.setName("y1")))
     82        {
     83            y1 = sty.getFloatValueWithUnits();
     84        }
    8485
    85         if (getPres(sty.setName("y2"))) y2 = sty.getFloatValueWithUnits();
     86        if (getPres(sty.setName("x2")))
     87        {
     88            x2 = sty.getFloatValueWithUnits();
     89        }
     90
     91        if (getPres(sty.setName("y2")))
     92        {
     93            y2 = sty.getFloatValueWithUnits();
     94        }
    8695
    8796        line = new Line2D.Float(x1, y1, x2, y2);
    8897    }
    89    
    9098
    9199    public void render(Graphics2D g) throws SVGException
     
    107115
    108116    /**
    109      * Updates all attributes in this diagram associated with a time event.
    110      * Ie, all attributes with track information.
     117     * Updates all attributes in this diagram associated with a time event. Ie,
     118     * all attributes with track information.
     119     *
    111120     * @return - true if this node has changed state as a result of the time
    112121     * update
     
    120129        StyleAttribute sty = new StyleAttribute();
    121130        boolean shapeChange = false;
    122        
     131
    123132        if (getPres(sty.setName("x1")))
    124133        {
     
    164173        {
    165174            build();
    166 //            line = new Line2D.Float(x1, y1, x2, y2);
    167 //            return true;
    168175        }
    169        
     176
    170177        return changeState || shapeChange;
    171178    }
  • trunk/src/com/kitfox/svg/LinearGradient.java

    r4256 r6002  
    11/*
    2  * LinearGradient.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on January 26, 2004, 1:54 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 import java.awt.geom.*;
    32 import java.awt.*;
    33 
    34 import com.kitfox.svg.xml.*;
    35 import org.xml.sax.*;
    36 
    37 //import org.apache.batik.ext.awt.*;
    38 import com.kitfox.svg.batik.*;
    39 
     39import java.awt.Color;
     40import java.awt.Paint;
     41import java.awt.geom.AffineTransform;
     42import java.awt.geom.Point2D;
     43import java.awt.geom.Rectangle2D;
    4044
    4145/**
     
    4347 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4448 */
    45 public class LinearGradient extends Gradient {
    46 
     49public class LinearGradient extends Gradient
     50{
     51    public static final String TAG_NAME = "lineargradient";
     52   
    4753    float x1 = 0f;
    4854    float y1 = 0f;
     
    5056    float y2 = 0f;
    5157
    52     /** Creates a new instance of LinearGradient */
    53     public LinearGradient() {
    54     }
    55 /*
    56     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    57     {
    58                 //Load style string
    59         super.loaderStartElement(helper, attrs, parent);
    60 
    61         String x1 = attrs.getValue("x1");
    62         String x2 = attrs.getValue("x2");
    63         String y1 = attrs.getValue("y1");
    64         String y2 = attrs.getValue("y2");
    65 
    66         if (x1 != null) this.x1 = (float)XMLParseUtil.parseRatio(x1);
    67         if (y1 != null) this.y1 = (float)XMLParseUtil.parseRatio(y1);
    68         if (x2 != null) this.x2 = (float)XMLParseUtil.parseRatio(x2);
    69         if (y2 != null) this.y2 = (float)XMLParseUtil.parseRatio(y2);
    70     }
    71 */
    72     /*
    73     public void loaderEndElement(SVGLoaderHelper helper)
    74     {
    75         super.loaderEndElement(helper);
    76        
    77         build();
    78     }
    79     */
    80    
     58    /**
     59     * Creates a new instance of LinearGradient
     60     */
     61    public LinearGradient()
     62    {
     63    }
     64
     65    public String getTagName()
     66    {
     67        return TAG_NAME;
     68    }
     69
    8170    protected void build() throws SVGException
    8271    {
    8372        super.build();
    84        
     73
    8574        StyleAttribute sty = new StyleAttribute();
    86        
    87         if (getPres(sty.setName("x1"))) x1 = sty.getFloatValueWithUnits();
    88        
    89         if (getPres(sty.setName("y1"))) y1 = sty.getFloatValueWithUnits();
    90        
    91         if (getPres(sty.setName("x2"))) x2 = sty.getFloatValueWithUnits();
    92        
    93         if (getPres(sty.setName("y2"))) y2 = sty.getFloatValueWithUnits();
    94     }
    95    
     75
     76        if (getPres(sty.setName("x1")))
     77        {
     78            x1 = sty.getFloatValueWithUnits();
     79        }
     80
     81        if (getPres(sty.setName("y1")))
     82        {
     83            y1 = sty.getFloatValueWithUnits();
     84        }
     85
     86        if (getPres(sty.setName("x2")))
     87        {
     88            x2 = sty.getFloatValueWithUnits();
     89        }
     90
     91        if (getPres(sty.setName("y2")))
     92        {
     93            y2 = sty.getFloatValueWithUnits();
     94        }
     95    }
     96
    9697    public Paint getPaint(Rectangle2D bounds, AffineTransform xform)
    9798    {
     
    111112        }
    112113
    113         com.kitfox.svg.batik.LinearGradientPaint paint;
    114         if (gradientUnits == GU_USER_SPACE_ON_USE)
    115         {
    116 //            paint = new LinearGradientPaint(x1, y1, x2, y2, getStopFractions(), getStopColors(), method);
     114        Paint paint;
     115        Point2D.Float pt1 = new Point2D.Float(x1, y1);
     116        Point2D.Float pt2 = new Point2D.Float(x2, y2);
     117        if (pt1.equals(pt2))
     118        {
     119            Color[] colors = getStopColors();
     120            paint = colors.length > 0 ? colors[0] : Color.black;
     121        } else if (gradientUnits == GU_USER_SPACE_ON_USE)
     122        {
    117123            paint = new com.kitfox.svg.batik.LinearGradientPaint(
    118                 new Point2D.Float(x1, y1),
    119                 new Point2D.Float(x2, y2),
     124                pt1,
     125                pt2,
    120126                getStopFractions(),
    121127                getStopColors(),
    122128                method,
    123129                com.kitfox.svg.batik.MultipleGradientPaint.SRGB,
    124                 gradientTransform);
    125         }
    126         else
     130                gradientTransform == null
     131                ? new AffineTransform()
     132                : gradientTransform);
     133        } else
    127134        {
    128135            AffineTransform viewXform = new AffineTransform();
    129136            viewXform.translate(bounds.getX(), bounds.getY());
    130            
     137
    131138            //This is a hack to get around shapes that have a width or height of 0.  Should be close enough to the true answer.
    132             double width = bounds.getWidth();
    133             double height = bounds.getHeight();
    134             if (width == 0) width = 1;
    135             if (height == 0) height = 1;
     139            double width = Math.max(1, bounds.getWidth());
     140            double height = Math.max(1, bounds.getHeight());
    136141            viewXform.scale(width, height);
    137142
    138             viewXform.concatenate(gradientTransform);
     143            if (gradientTransform != null)
     144            {
     145                viewXform.concatenate(gradientTransform);
     146            }
    139147
    140148            paint = new com.kitfox.svg.batik.LinearGradientPaint(
    141                 new Point2D.Float(x1, y1),
    142                 new Point2D.Float(x2, y2),
     149                pt1,
     150                pt2,
    143151                getStopFractions(),
    144152                getStopColors(),
     
    150158        return paint;
    151159    }
    152    
     160
    153161    /**
    154      * Updates all attributes in this diagram associated with a time event.
    155      * Ie, all attributes with track information.
     162     * Updates all attributes in this diagram associated with a time event. Ie,
     163     * all attributes with track information.
     164     *
    156165     * @return - true if this node has changed state as a result of the time
    157166     * update
     
    165174        StyleAttribute sty = new StyleAttribute();
    166175        boolean shapeChange = false;
    167        
     176
    168177        if (getPres(sty.setName("x1")))
    169178        {
  • trunk/src/com/kitfox/svg/Marker.java

    r4256 r6002  
    11/*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    433 */
    5 
    634package com.kitfox.svg;
    735
     
    2149public class Marker extends Group
    2250{
     51    public static final String TAG_NAME = "marker";
     52   
    2353    AffineTransform viewXform;
    2454    AffineTransform markerXform;
    2555    Rectangle2D viewBox;
    26 
    2756    float refX;
    2857    float refY;
     
    3059    float markerHeight = 3;
    3160    float orient = Float.NaN;
     61    boolean markerUnitsStrokeWidth = true; //if set to false 'userSpaceOnUse' is assumed
     62
     63    public String getTagName()
     64    {
     65        return TAG_NAME;
     66    }
    3267
    3368    protected void build() throws SVGException
     
    3772        StyleAttribute sty = new StyleAttribute();
    3873
    39         if (getPres(sty.setName("refX"))) refX = sty.getFloatValueWithUnits();
    40         if (getPres(sty.setName("refY"))) refY = sty.getFloatValueWithUnits();
    41         if (getPres(sty.setName("markerWidth"))) markerWidth = sty.getFloatValueWithUnits();
    42         if (getPres(sty.setName("markerHeight"))) markerHeight = sty.getFloatValueWithUnits();
     74        if (getPres(sty.setName("refX")))
     75        {
     76            refX = sty.getFloatValueWithUnits();
     77        }
     78        if (getPres(sty.setName("refY")))
     79        {
     80            refY = sty.getFloatValueWithUnits();
     81        }
     82        if (getPres(sty.setName("markerWidth")))
     83        {
     84            markerWidth = sty.getFloatValueWithUnits();
     85        }
     86        if (getPres(sty.setName("markerHeight")))
     87        {
     88            markerHeight = sty.getFloatValueWithUnits();
     89        }
    4390
    4491        if (getPres(sty.setName("orient")))
     
    4794            {
    4895                orient = Float.NaN;
    49             }
    50             else
     96            } else
    5197            {
    5298                orient = sty.getFloatValue();
     
    63109        {
    64110            viewBox = new Rectangle(0, 0, 1, 1);
     111        }
     112
     113        if (getPres(sty.setName("markerUnits")))
     114        {
     115            String markerUnits = sty.getStringValue();
     116            if (markerUnits != null && markerUnits.equals("userSpaceOnUse"))
     117            {
     118                markerUnitsStrokeWidth = false;
     119            }
    65120        }
    66121
     
    78133    protected boolean outsideClip(Graphics2D g) throws SVGException
    79134    {
    80         g.getClipBounds(clipBounds);
     135        Shape clip = g.getClip();
    81136        Rectangle2D rect = super.getBoundingBox();
    82         if (rect.intersects(clipBounds))
     137        if (clip == null || clip.intersects(rect))
    83138        {
    84139            return false;
     
    104159
    105160        g.translate(pos.x, pos.y);
    106         g.scale(strokeWidth, strokeWidth);
     161        if (markerUnitsStrokeWidth)
     162        {
     163            g.scale(strokeWidth, strokeWidth);
     164        }
     165
    107166        g.rotate(Math.atan2(pos.dy, pos.dx));
    108167
     
    127186
    128187    /**
    129      * Updates all attributes in this diagram associated with a time event.
    130      * Ie, all attributes with track information.
     188     * Updates all attributes in this diagram associated with a time event. Ie,
     189     * all attributes with track information.
     190     *
    131191     * @return - true if this node has changed state as a result of the time
    132192     * update
     
    139199        return changeState;
    140200    }
    141 
     201   
    142202    //--------------------------------
    143203    public static final int MARKER_START = 0;
     
    147207    public static class MarkerPos
    148208    {
     209
    149210        int type;
    150211        double x;
     
    165226    public static class MarkerLayout
    166227    {
     228
    167229        private ArrayList markerList = new ArrayList();
    168230        boolean started = false;
     
    174236            double[] coords = new double[6];
    175237            for (PathIterator it = shape.getPathIterator(null);
    176                     !it.isDone(); it.next())
     238                !it.isDone(); it.next())
    177239            {
    178240                switch (it.currentSegment(coords))
     
    202264                        double x = coords[2];
    203265                        double y = coords[3];
     266
     267
     268                        //Best in tangent
     269                        if (px != k0x || py != k0y)
     270                        {
     271                            markerIn(px, py, k0x - px, k0y - py);
     272                        } else
     273                        {
     274                            markerIn(px, py, x - px, y - py);
     275                        }
     276
     277                        //Best out tangent
     278                        if (x != k0x || y != k0y)
     279                        {
     280                            markerOut(x, y, x - k0x, y - k0y);
     281                        } else
     282                        {
     283                            markerOut(x, y, x - px, y - py);
     284                        }
     285
    204286                        markerIn(px, py, k0x - px, k0y - py);
    205287                        markerOut(x, y, x - k0x, y - k0y);
     
    216298                        double x = coords[4];
    217299                        double y = coords[5];
    218                         markerIn(px, py, k0x - px, k0y - py);
    219                         markerOut(x, y, x - k1x, y - k1y);
     300
     301                        //Best in tangent
     302                        if (px != k0x || py != k0y)
     303                        {
     304                            markerIn(px, py, k0x - px, k0y - py);
     305                        } else if (px != k1x || py != k1y)
     306                        {
     307                            markerIn(px, py, k1x - px, k1y - py);
     308                        } else
     309                        {
     310                            markerIn(px, py, x - px, y - py);
     311                        }
     312
     313                        //Best out tangent
     314                        if (x != k1x || y != k1y)
     315                        {
     316                            markerOut(x, y, x - k1x, y - k1y);
     317                        } else if (x != k0x || y != k0y)
     318                        {
     319                            markerOut(x, y, x - k0x, y - k0y);
     320                        } else
     321                        {
     322                            markerOut(x, y, x - px, y - py);
     323                        }
    220324                        px = x;
    221325                        py = y;
     
    227331            for (int i = 1; i < markerList.size(); ++i)
    228332            {
    229                 MarkerPos prev = (MarkerPos)markerList.get(i - 1);
    230                 MarkerPos cur = (MarkerPos)markerList.get(i);
     333                MarkerPos prev = (MarkerPos) markerList.get(i - 1);
     334                MarkerPos cur = (MarkerPos) markerList.get(i);
    231335
    232336                if (cur.type == MARKER_START)
     
    235339                }
    236340            }
    237             MarkerPos last = (MarkerPos)markerList.get(markerList.size() - 1);
     341            MarkerPos last = (MarkerPos) markerList.get(markerList.size() - 1);
    238342            last.type = MARKER_END;
    239343        }
  • trunk/src/com/kitfox/svg/Metadata.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
    717 *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on September 19, 2004, 1:56 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038/**
    31  * Does not hold any information.  Included to allow metadata tag to be parsed.
     39 * Does not hold any information. Included to allow metadata tag to be parsed.
    3240 *
    3341 * @author Mark McKay
    3442 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3543 */
    36 public class Metadata extends SVGElement 
     44public class Metadata extends SVGElement
    3745{
    38     /** Creates a new instance of Stop */
    39     public Metadata() {
     46    public static final String TAG_NAME = "metadata";
     47
     48    /**
     49     * Creates a new instance of Stop
     50     */
     51    public Metadata()
     52    {
     53    }
     54
     55    public String getTagName()
     56    {
     57        return TAG_NAME;
    4058    }
    4159
  • trunk/src/com/kitfox/svg/MissingGlyph.java

    r4256 r6002  
    11/*
    2  * Font.java
    3  *
    4  *
    5  *  The Salamander Project - 2D and 3D graphics libraries in Java
    6  *  Copyright (C) 2004 Mark McKay
    7  *
    8  *  This library is free software; you can redistribute it and/or
    9  *  modify it under the terms of the GNU Lesser General Public
    10  *  License as published by the Free Software Foundation; either
    11  *  version 2.1 of the License, or (at your option) any later version.
    12  *
    13  *  This library is distributed in the hope that it will be useful,
    14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    16  *  Lesser General Public License for more details.
    17  *
    18  *  You should have received a copy of the GNU Lesser General Public
    19  *  License along with this library; if not, write to the Free Software
    20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    21  *
    22  *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    23  *  projects can be found at http://www.kitfox.com
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     5 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
     9 *
     10 *   - Redistributions of source code must retain the above
     11 *     copyright notice, this list of conditions and the following
     12 *     disclaimer.
     13 *   - Redistributions in binary form must reproduce the above
     14 *     copyright notice, this list of conditions and the following
     15 *     disclaimer in the documentation and/or other materials
     16 *     provided with the distribution.
     17 *
     18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
     31 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
     32 * projects can be found at http://www.kitfox.com
    2433 *
    2534 * Created on February 20, 2004, 10:00 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    30 import com.kitfox.svg.xml.*;
    31 
    32 import java.awt.*;
    33 import java.awt.geom.*;
    34 import java.util.*;
    35 
    36 import com.kitfox.svg.pathcmd.*;
    37 //import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
     38import com.kitfox.svg.pathcmd.BuildHistory;
     39import com.kitfox.svg.pathcmd.PathCommand;
     40import com.kitfox.svg.xml.StyleAttribute;
     41import java.awt.Graphics2D;
     42import java.awt.Shape;
     43import java.awt.geom.AffineTransform;
     44import java.awt.geom.GeneralPath;
     45import java.awt.geom.Rectangle2D;
     46import java.util.Iterator;
    3847
    3948/**
     
    4756public class MissingGlyph extends ShapeElement
    4857{
     58    public static final String TAG_NAME = "missingglyph";
     59   
    4960    //We may define a path
    50 //    ExtendedGeneralPath path = null;
    5161    Shape path = null;
    52 
    5362    //Alternately, we may have child graphical elements
    54 
    5563    int horizAdvX = -1;  //Inherits font's value if not set
    5664    int vertOriginX = -1;  //Inherits font's value if not set
     
    5866    int vertAdvY = -1;  //Inherits font's value if not set
    5967
    60     /** Creates a new instance of Font */
     68    /**
     69     * Creates a new instance of Font
     70     */
    6171    public MissingGlyph()
    6272    {
    6373    }
    64 /*
    65     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    66     {
    67                 //Load style string
    68         super.loaderStartElement(helper, attrs, parent);
     74
     75    public String getTagName()
     76    {
     77        return TAG_NAME;
     78    }
     79
     80    /**
     81     * Called after the start element but before the end element to indicate
     82     * each child tag that has been processed
     83     */
     84    public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
     85    {
     86        super.loaderAddChild(helper, child);
     87    }
     88
     89    protected void build() throws SVGException
     90    {
     91        super.build();
     92
     93        StyleAttribute sty = new StyleAttribute();
     94
     95        String commandList = "";
     96        if (getPres(sty.setName("d")))
     97        {
     98            commandList = sty.getStringValue();
     99        }
     100
    69101
    70102        //If glyph path was specified, calculate it
    71         String commandList = attrs.getValue("d");
    72103        if (commandList != null)
    73104        {
    74             StyleAttribute atyleAttrib = getStyle("fill-rule");
    75             String fillRule = (atyleAttrib == null) ? "nonzero" : atyleAttrib.getStringValue();
     105            String fillRule = getStyle(sty.setName("fill-rule")) ? sty.getStringValue() : "nonzero";
    76106
    77107            PathCommand[] commands = parsePathList(commandList);
    78108
    79 //            ExtendedGeneralPath buildPath = new ExtendedGeneralPath(
    80109            GeneralPath buildPath = new GeneralPath(
    81110                fillRule.equals("evenodd") ? GeneralPath.WIND_EVEN_ODD : GeneralPath.WIND_NON_ZERO,
     
    98127
    99128        //Read glyph spacing info
    100         String horizAdvX = attrs.getValue("horiz-adv-x");
    101         String vertOriginX = attrs.getValue("vert-origin-x");
    102         String vertOriginY = attrs.getValue("vert-origin-y");
    103         String vertAdvY = attrs.getValue("vert-adv-y");
    104 
    105         if (horizAdvX != null) this.horizAdvX = XMLParseUtil.parseInt(horizAdvX);
    106         if (vertOriginX != null) this.vertOriginX = XMLParseUtil.parseInt(vertOriginX);
    107         if (vertOriginY != null) this.vertOriginY = XMLParseUtil.parseInt(vertOriginY);
    108         if (vertAdvY != null) this.vertAdvY = XMLParseUtil.parseInt(vertAdvY);
    109 
    110     }
    111 */
    112     /**
    113      * Called after the start element but before the end element to indicate
    114      * each child tag that has been processed
    115      */
    116     public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
    117     {
    118         super.loaderAddChild(helper, child);
    119     }
    120 
    121    
    122     protected void build() throws SVGException
    123     {
    124         super.build();
    125        
    126         StyleAttribute sty = new StyleAttribute();
    127        
    128         String commandList = "";
    129         if (getPres(sty.setName("d"))) commandList = sty.getStringValue();
    130 
    131