Changeset 11525 in josm for trunk/src/com/kitfox/svg/xml/XMLParseUtil.java
- Timestamp:
- 2017-02-02T00:08:08+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/xml/XMLParseUtil.java
r10866 r11525 4 4 * All rights reserved. 5 5 * 6 * Redistribution and use in source and binary forms, with or 6 * Redistribution and use in source and binary forms, with or 7 7 * without modification, are permitted provided that the following 8 8 * conditions are met: 9 9 * 10 * - Redistributions of source code must retain the above 10 * - Redistributions of source code must retain the above 11 11 * copyright notice, this list of conditions and the following 12 12 * disclaimer. 13 13 * - Redistributions in binary form must reproduce the above 14 14 * 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 16 16 * provided with the distribution. 17 17 * … … 27 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 28 * 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 * 31 31 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 32 32 * projects can be found at http://www.kitfox.com … … 37 37 package com.kitfox.svg.xml; 38 38 39 import com.kitfox.svg.SVGConst;40 import java. awt.*;41 import java.util. *;42 import java.util. regex.*;39 import java.awt.Toolkit; 40 import java.util.HashMap; 41 import java.util.Iterator; 42 import java.util.LinkedList; 43 43 import java.util.logging.Level; 44 44 import java.util.logging.Logger; 45 import java.util.regex.Matcher; 46 import java.util.regex.Pattern; 47 48 import com.kitfox.svg.SVGConst; 45 49 46 50 /** … … 63 67 matchWs.reset(list); 64 68 65 LinkedList matchList = new LinkedList();69 LinkedList<String> matchList = new LinkedList<>(); 66 70 while (matchWs.find()) 67 71 { … … 70 74 71 75 String[] retArr = new String[matchList.size()]; 72 return (String[])matchList.toArray(retArr);76 return matchList.toArray(retArr); 73 77 } 74 78 75 79 public static double parseDouble(String val) 76 80 { 77 /*78 if (val == null) return 0.0;79 80 double retVal = 0.0;81 try82 { retVal = Double.parseDouble(val); }83 catch (Exception e)84 {}85 return retVal;86 */87 81 return findDouble(val); 88 82 } … … 103 97 catch (StringIndexOutOfBoundsException e) 104 98 { 105 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 99 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 106 100 "XMLParseUtil: regex parse problem: '" + val + "'", e); 107 101 } … … 112 106 double retVal = 0; 113 107 try 114 { 115 retVal = Double.parseDouble(val); 116 108 { 109 retVal = Double.parseDouble(val); 110 117 111 float pixPerInch; 118 112 try { 119 pixPerInch = (float)Toolkit.getDefaultToolkit().getScreenResolution();113 pixPerInch = Toolkit.getDefaultToolkit().getScreenResolution(); 120 114 } 121 115 catch (NoClassDefFoundError err) … … 126 120 final float inchesPerCm = .3936f; 127 121 final String units = fpMatch.group(6); 128 122 129 123 if ("%".equals(units)) retVal /= 100; 130 124 else if ("in".equals(units)) … … 166 160 fpMatch.reset(list); 167 161 168 LinkedList doubList = new LinkedList();162 LinkedList<Double> doubList = new LinkedList<>(); 169 163 while (fpMatch.find()) 170 164 { … … 174 168 175 169 double[] retArr = new double[doubList.size()]; 176 Iterator it = doubList.iterator();170 Iterator<Double> it = doubList.iterator(); 177 171 int idx = 0; 178 172 while (it.hasNext()) 179 173 { 180 retArr[idx++] = ((Double)it.next()).doubleValue();174 retArr[idx++] = it.next().doubleValue(); 181 175 } 182 176 … … 216 210 fpMatch.reset(list); 217 211 218 LinkedList floatList = new LinkedList();212 LinkedList<Float> floatList = new LinkedList<>(); 219 213 while (fpMatch.find()) 220 214 { … … 224 218 225 219 float[] retArr = new float[floatList.size()]; 226 Iterator it = floatList.iterator();220 Iterator<Float> it = floatList.iterator(); 227 221 int idx = 0; 228 222 while (it.hasNext()) 229 223 { 230 retArr[idx++] = ((Float)it.next()).floatValue();224 retArr[idx++] = it.next().floatValue(); 231 225 } 232 226 … … 261 255 intMatch.reset(list); 262 256 263 LinkedList intList = new LinkedList();257 LinkedList<Integer> intList = new LinkedList<>(); 264 258 while (intMatch.find()) 265 259 { … … 269 263 270 264 int[] retArr = new int[intList.size()]; 271 Iterator it = intList.iterator();265 Iterator<Integer> it = intList.iterator(); 272 266 int idx = 0; 273 267 while (it.hasNext()) 274 268 { 275 retArr[idx++] = ((Integer)it.next()).intValue();269 retArr[idx++] = it.next().intValue(); 276 270 } 277 271 … … 307 301 * @param map - A map to which these styles will be added 308 302 */ 309 public static HashMap parseStyle(String styleString, HashMapmap) {303 public static HashMap<String, StyleAttribute> parseStyle(String styleString, HashMap<String, StyleAttribute> map) { 310 304 final Pattern patSemi = Pattern.compile(";"); 311 305
Note:
See TracChangeset
for help on using the changeset viewer.