Ignore:
Timestamp:
2017-02-02T00:08:08+01:00 (9 years ago)
Author:
Don-vip
Message:

see #14319 - update to latest version of svgSalamander (2017-01-07, patched)

File:
1 edited

Legend:

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

    r8084 r11525  
    44 * All rights reserved.
    55 *
    6  * Redistribution and use in source and binary forms, with or 
     6 * Redistribution and use in source and binary forms, with or
    77 * without modification, are permitted provided that the following
    88 * conditions are met:
    99 *
    10  *   - Redistributions of source code must retain the above 
     10 *   - Redistributions of source code must retain the above
    1111 *     copyright notice, this list of conditions and the following
    1212 *     disclaimer.
    1313 *   - Redistributions in binary form must reproduce the above
    1414 *     copyright notice, this list of conditions and the following
    15  *     disclaimer in the documentation and/or other materials 
     15 *     disclaimer in the documentation and/or other materials
    1616 *     provided with the distribution.
    1717 *
     
    2727 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    2828 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    29  * OF THE POSSIBILITY OF SUCH DAMAGE. 
    30  * 
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
    3131 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    3232 * projects can be found at http://www.kitfox.com
     
    3535 */
    3636package com.kitfox.svg;
     37
     38import java.awt.geom.AffineTransform;
     39import java.awt.geom.GeneralPath;
     40import java.io.Serializable;
     41import java.net.URI;
     42import java.util.ArrayList;
     43import java.util.Collections;
     44import java.util.HashMap;
     45import java.util.HashSet;
     46import java.util.Iterator;
     47import java.util.LinkedList;
     48import java.util.List;
     49import java.util.Set;
     50import java.util.regex.Matcher;
     51import java.util.regex.Pattern;
     52
     53import org.xml.sax.Attributes;
     54import org.xml.sax.SAXException;
    3755
    3856import com.kitfox.svg.pathcmd.Arc;
     
    5169import com.kitfox.svg.xml.StyleSheet;
    5270import com.kitfox.svg.xml.XMLParseUtil;
    53 import java.awt.geom.AffineTransform;
    54 import java.awt.geom.GeneralPath;
    55 import java.io.Serializable;
    56 import java.net.URI;
    57 import java.util.ArrayList;
    58 import java.util.Collections;
    59 import java.util.HashMap;
    60 import java.util.HashSet;
    61 import java.util.Iterator;
    62 import java.util.LinkedList;
    63 import java.util.List;
    64 import java.util.Set;
    65 import java.util.regex.Matcher;
    66 import java.util.regex.Pattern;
    67 import org.xml.sax.Attributes;
    68 import org.xml.sax.SAXException;
    69 
    7071
    7172/**
     
    7980    public static final String SVG_NS = "http://www.w3.org/2000/svg";
    8081    protected SVGElement parent = null;
    81     protected final ArrayList children = new ArrayList();
     82    protected final ArrayList<SVGElement> children = new ArrayList<>();
    8283    protected String id = null;
    8384    /**
     
    8889     * Styles defined for this elemnt via the <b>style</b> attribute.
    8990     */
    90     protected final HashMap inlineStyles = new HashMap();
     91    protected final HashMap<String, StyleAttribute> inlineStyles = new HashMap<>();
    9192    /**
    9293     * Presentation attributes set for this element. Ie, any attribute other
    9394     * than the <b>style</b> attribute.
    9495     */
    95     protected final HashMap presAttribs = new HashMap();
     96    protected final HashMap<String, StyleAttribute> presAttribs = new HashMap<>();
    9697    /**
    9798     * A list of presentation attributes to not include in the presentation
    9899     * attribute set.
    99100     */
    100     protected static final Set ignorePresAttrib;
     101    protected static final Set<String> ignorePresAttrib;
    101102
    102103    static
    103104    {
    104         HashSet set = new HashSet();
     105        HashSet<String> set = new HashSet<>();
    105106//        set.add("id");
    106107//        set.add("class");
     
    157158     * @return an ordered list of nodes from the root of the tree to this node
    158159     */
    159     public List getPath(List retVec)
     160    public List<SVGElement> getPath(List<SVGElement> retVec)
    160161    {
    161162        if (retVec == null)
    162163        {
    163             retVec = new ArrayList();
     164            retVec = new ArrayList<>();
    164165        }
    165166
     
    179180     * @return The list containing the children of this group
    180181     */
    181     public List getChildren(List retVec)
     182    public List<SVGElement> getChildren(List<SVGElement> retVec)
    182183    {
    183184        if (retVec == null)
    184185        {
    185             retVec = new ArrayList();
     186            retVec = new ArrayList<>();
    186187        }
    187188
     
    197198    public SVGElement getChild(String id)
    198199    {
    199         for (Iterator it = children.iterator(); it.hasNext();)
    200         {
    201             SVGElement ele = (SVGElement) it.next();
     200        for (SVGElement ele : children) {
    202201            String eleId = ele.getId();
    203202            if (eleId != null && eleId.equals(id))
     
    234233        }
    235234
    236         Object temp = children.get(i);
     235        SVGElement temp = children.get(i);
    237236        children.set(i, children.get(j));
    238237        children.set(j, temp);
     
    269268        if (style != null)
    270269        {
    271             HashMap map = XMLParseUtil.parseStyle(style, inlineStyles);
     270            HashMap<?, ?> map = XMLParseUtil.parseStyle(style, inlineStyles);
    272271        }
    273272
     
    302301     * @return a set of Strings that corespond to CSS attributes on this element
    303302     */
    304     public Set getInlineAttributes()
     303    public Set<String> getInlineAttributes()
    305304    {
    306305        return inlineStyles.keySet();
     
    310309     * @return a set of Strings that corespond to XML attributes on this element
    311310     */
    312     public Set getPresentationAttributes()
     311    public Set<String> getPresentationAttributes()
    313312    {
    314313        return presAttribs.keySet();
     
    330329        this.diagram = diagram;
    331330        diagram.setElement(id, this);
    332         for (Iterator it = children.iterator(); it.hasNext();)
    333         {
    334             SVGElement ele = (SVGElement) it.next();
     331        for (SVGElement ele : children) {
    335332            ele.setDiagram(diagram);
    336333        }
     
    400397        for (int i = 0; i < children.size(); ++i)
    401398        {
    402             SVGElement ele = (SVGElement) children.get(i);
     399            SVGElement ele = children.get(i);
    403400            ele.build();
    404401        }
     
    418415        return id;
    419416    }
    420     LinkedList contexts = new LinkedList();
     417    LinkedList<SVGElement> contexts = new LinkedList<>();
    421418
    422419    /**
     
    431428    protected SVGElement popParentContext()
    432429    {
    433         return (SVGElement) contexts.removeLast();
     430        return contexts.removeLast();
    434431    }
    435432
     
    474471
    475472        //Check for local inline styles
    476         StyleAttribute styAttr = (StyleAttribute)inlineStyles.get(styName);
     473        StyleAttribute styAttr = inlineStyles.get(styName);
    477474
    478475        attrib.setStringValue(styAttr == null ? "" : styAttr.getStringValue());
     
    486483
    487484        //Check for presentation attribute
    488         StyleAttribute presAttr = (StyleAttribute)presAttribs.get(styName);
     485        StyleAttribute presAttr = presAttribs.get(styName);
    489486
    490487        attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue());
     
    533530    {
    534531        //Check for local inline styles
    535         return (StyleAttribute) inlineStyles.get(styName);
     532        return inlineStyles.get(styName);
    536533    }
    537534
     
    546543
    547544        //Make sure we have a coresponding presentation attribute
    548         StyleAttribute presAttr = (StyleAttribute) presAttribs.get(presName);
     545        StyleAttribute presAttr = presAttribs.get(presName);
    549546
    550547        //Copy presentation value directly
     
    568565    {
    569566        //Check for local inline styles
    570         return (StyleAttribute) presAttribs.get(styName);
     567        return presAttribs.get(styName);
    571568    }
    572569
     
    601598        String function = matchWord.group().toLowerCase();
    602599
    603         LinkedList termList = new LinkedList();
     600        LinkedList<String> termList = new LinkedList<>();
    604601        while (matchWord.find())
    605602        {
     
    609606
    610607        double[] terms = new double[termList.size()];
    611         Iterator it = termList.iterator();
     608        Iterator<String> it = termList.iterator();
    612609        int count = 0;
    613610        while (it.hasNext())
    614611        {
    615             terms[count++] = XMLParseUtil.parseDouble((String) it.next());
     612            terms[count++] = XMLParseUtil.parseDouble(it.next());
    616613        }
    617614
     
    661658    }
    662659
    663     static protected float nextFloat(LinkedList l)
    664     {
    665         String s = (String) l.removeFirst();
     660    static protected float nextFloat(LinkedList<String> l)
     661    {
     662        String s = l.removeFirst();
    666663        return Float.parseFloat(s);
    667664    }
     
    672669
    673670        //Tokenize
    674         LinkedList tokens = new LinkedList();
     671        LinkedList<String> tokens = new LinkedList<>();
    675672        while (matchPathCmd.find())
    676673        {
     
    680677
    681678        boolean defaultRelative = false;
    682         LinkedList cmdList = new LinkedList();
     679        LinkedList<PathCommand> cmdList = new LinkedList<>();
    683680        char curCmd = 'Z';
    684681        while (tokens.size() != 0)
    685682        {
    686             String curToken = (String) tokens.removeFirst();
     683            String curToken = tokens.removeFirst();
    687684            char initChar = curToken.charAt(0);
    688685            if ((initChar >= 'A' && initChar <= 'Z') || (initChar >= 'a' && initChar <= 'z'))
     
    825822    public SVGElement getChild(int i)
    826823    {
    827         return (SVGElement) children.get(i);
     824        return children.get(i);
    828825    }
    829826
Note: See TracChangeset for help on using the changeset viewer.