Changeset 11525 in josm
- Timestamp:
- 2017-02-02T00:08:08+01:00 (8 years ago)
- Location:
- trunk/src/com/kitfox/svg
- Files:
-
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/A.java
r8084 r11525 56 56 } 57 57 58 @Override 58 59 public String getTagName() 59 60 { … … 61 62 } 62 63 64 @Override 63 65 protected void build() throws SVGException 64 66 { … … 84 86 * update 85 87 */ 88 @Override 86 89 public boolean updateTime(double curTime) throws SVGException 87 90 { -
trunk/src/com/kitfox/svg/Circle.java
r8084 r11525 62 62 } 63 63 64 @Override 64 65 public String getTagName() 65 66 { … … 67 68 } 68 69 70 @Override 69 71 protected void build() throws SVGException 70 72 { … … 91 93 } 92 94 95 @Override 93 96 public void render(Graphics2D g) throws SVGException 94 97 { … … 98 101 } 99 102 103 @Override 100 104 public Shape getShape() 101 105 { … … 103 107 } 104 108 109 @Override 105 110 public Rectangle2D getBoundingBox() throws SVGException 106 111 { … … 115 120 * update 116 121 */ 122 @Override 117 123 public boolean updateTime(double curTime) throws SVGException 118 124 { -
trunk/src/com/kitfox/svg/ClipPath.java
r8084 r11525 39 39 import java.awt.Shape; 40 40 import java.awt.geom.Area; 41 import java.util.Iterator;42 41 43 42 /** … … 60 59 } 61 60 61 @Override 62 62 public String getTagName() 63 63 { … … 69 69 * each child tag that has been processed 70 70 */ 71 @Override 71 72 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 72 73 { … … 74 75 } 75 76 77 @Override 76 78 protected void build() throws SVGException 77 79 { … … 103 105 104 106 Area clipArea = null; 105 for (Iterator it = children.iterator(); it.hasNext();) 106 { 107 ShapeElement se = (ShapeElement) it.next(); 107 for (SVGElement svgElement : children) { 108 ShapeElement se = (ShapeElement) svgElement; 108 109 109 110 if (clipArea == null) … … 136 137 * @throws com.kitfox.svg.SVGException 137 138 */ 139 @Override 138 140 public boolean updateTime(double curTime) throws SVGException 139 141 { -
trunk/src/com/kitfox/svg/Defs.java
r8084 r11525 36 36 package com.kitfox.svg; 37 37 38 import java.util.Iterator;39 40 38 /** 41 39 * @author Mark McKay … … 54 52 } 55 53 54 @Override 56 55 public String getTagName() 57 56 { … … 63 62 * each child tag that has been processed 64 63 */ 64 @Override 65 65 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 66 66 { … … 70 70 } 71 71 72 @Override 72 73 public boolean updateTime(double curTime) throws SVGException 73 74 { 74 75 boolean stateChange = false; 75 for (Iterator it = children.iterator(); it.hasNext();) 76 { 77 SVGElement ele = (SVGElement) it.next(); 76 for (SVGElement ele : children) { 78 77 stateChange = stateChange || ele.updateTime(curTime); 79 78 } -
trunk/src/com/kitfox/svg/Desc.java
r8084 r11525 55 55 } 56 56 57 @Override 57 58 public String getTagName() 58 59 { … … 63 64 * Called during load process to add text scanned within a tag 64 65 */ 66 @Override 65 67 public void loaderAddText(SVGLoaderHelper helper, String text) 66 68 { … … 73 75 } 74 76 77 @Override 75 78 public boolean updateTime(double curTime) 76 79 { -
trunk/src/com/kitfox/svg/Ellipse.java
r8084 r11525 63 63 } 64 64 65 @Override 65 66 public String getTagName() 66 67 { … … 68 69 } 69 70 71 @Override 70 72 protected void build() throws SVGException 71 73 { … … 97 99 } 98 100 101 @Override 99 102 public void render(Graphics2D g) throws SVGException 100 103 { … … 104 107 } 105 108 109 @Override 106 110 public Shape getShape() 107 111 { … … 109 113 } 110 114 115 @Override 111 116 public Rectangle2D getBoundingBox() throws SVGException 112 117 { … … 121 126 * update 122 127 */ 128 @Override 123 129 public boolean updateTime(double curTime) throws SVGException 124 130 { -
trunk/src/com/kitfox/svg/Filter.java
r10865 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 … … 36 36 package com.kitfox.svg; 37 37 38 import com.kitfox.svg.xml.StyleAttribute;39 38 import java.awt.geom.Point2D; 40 39 import java.net.URI; 41 40 import java.net.URL; 42 41 import java.util.ArrayList; 42 43 import com.kitfox.svg.xml.StyleAttribute; 43 44 44 45 /** … … 62 63 Point2D filterRes = new Point2D.Double(); 63 64 URL href = null; 64 final ArrayList filterEffects = new ArrayList();65 final ArrayList<SVGElement> filterEffects = new ArrayList<>(); 65 66 66 67 /** … … 71 72 } 72 73 74 @Override 73 75 public String getTagName() 74 76 { … … 76 78 } 77 79 80 @Override 78 81 protected void build() throws SVGException 79 82 { … … 161 164 } 162 165 166 @Override 163 167 public boolean updateTime(double curTime) throws SVGException 164 168 { -
trunk/src/com/kitfox/svg/Font.java
r8084 r11525 59 59 FontFace fontFace = null; 60 60 MissingGlyph missingGlyph = null; 61 final HashMap glyphs = new HashMap();61 final HashMap<String, SVGElement> glyphs = new HashMap<>(); 62 62 63 63 /** … … 68 68 } 69 69 70 @Override 70 71 public String getTagName() 71 72 { … … 77 78 * each child tag that has been processed 78 79 */ 80 @Override 79 81 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 80 82 { … … 93 95 } 94 96 97 @Override 95 98 public void loaderEndElement(SVGLoaderHelper helper) throws SVGParseException 96 99 { … … 102 105 } 103 106 107 @Override 104 108 protected void build() throws SVGException 105 109 { … … 211 215 * update 212 216 */ 217 @Override 213 218 public boolean updateTime(double curTime) throws SVGException 214 219 { -
trunk/src/com/kitfox/svg/FontFace.java
r8084 r11525 72 72 } 73 73 74 @Override 74 75 public String getTagName() 75 76 { … … 77 78 } 78 79 80 @Override 79 81 protected void build() throws SVGException 80 82 { … … 229 231 * update 230 232 */ 233 @Override 231 234 public boolean updateTime(double curTime) 232 235 { -
trunk/src/com/kitfox/svg/Glyph.java
r8084 r11525 63 63 } 64 64 65 @Override 65 66 public String getTagName() 66 67 { … … 68 69 } 69 70 71 @Override 70 72 protected void build() throws SVGException 71 73 { … … 92 94 * update 93 95 */ 96 @Override 94 97 public boolean updateTime(double curTime) throws SVGException 95 98 { -
trunk/src/com/kitfox/svg/Gradient.java
r8084 r11525 41 41 import java.net.URI; 42 42 import java.util.ArrayList; 43 import java.util.Iterator;44 43 import java.util.logging.Level; 45 44 import java.util.logging.Logger; … … 62 61 //Either this gradient contains a list of stops, or it will take it's 63 62 // stops from the referenced gradient 64 ArrayList stops = new ArrayList();63 ArrayList<Stop> stops = new ArrayList<>(); 65 64 URI stopRef = null; 66 65 protected AffineTransform gradientTransform = null; … … 77 76 } 78 77 78 @Override 79 79 public String getTagName() 80 80 { … … 86 86 * each child tag that has been processed 87 87 */ 88 @Override 88 89 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 89 90 { … … 97 98 } 98 99 100 @Override 99 101 protected void build() throws SVGException 100 102 { … … 173 175 stopFractions = new float[stops.size()]; 174 176 int idx = 0; 175 for (Iterator it = stops.iterator(); it.hasNext();) 176 { 177 Stop stop = (Stop) it.next(); 177 for (Stop stop : stops) { 178 178 float val = stop.offset; 179 179 if (idx != 0 && val < stopFractions[idx - 1]) … … 202 202 stopColors = new Color[stops.size()]; 203 203 int idx = 0; 204 for (Iterator it = stops.iterator(); it.hasNext();) 205 { 206 Stop stop = (Stop) it.next(); 204 for (Stop stop : stops) { 207 205 int stopColorVal = stop.color.getRGB(); 208 206 Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int) (stop.opacity * 255), 0, 255)); … … 255 253 * update 256 254 */ 255 @Override 257 256 public boolean updateTime(double curTime) throws SVGException 258 257 { … … 262 261 //Get current values for parameters 263 262 StyleAttribute sty = new StyleAttribute(); 264 boolean shapeChange = false;265 263 String strn; 266 264 … … 335 333 336 334 //Check stops, if any 337 for (Iterator it = stops.iterator(); it.hasNext();) 338 { 339 Stop stop = (Stop) it.next(); 335 for (Stop stop : stops) { 340 336 if (stop.updateTime(curTime)) 341 337 { -
trunk/src/com/kitfox/svg/Group.java
r8084 r11525 66 66 } 67 67 68 @Override 68 69 public String getTagName() 69 70 { … … 75 76 * each child tag that has been processed 76 77 */ 78 @Override 77 79 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 78 80 { … … 98 100 } 99 101 100 void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException 102 @Override 103 void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 101 104 { 102 105 Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); … … 113 116 114 117 115 for (Iterator it = children.iterator(); it.hasNext();) 116 { 117 SVGElement ele = (SVGElement) it.next(); 118 for (SVGElement ele : children) { 118 119 if (ele instanceof RenderableElement) 119 120 { … … 125 126 } 126 127 127 void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException 128 @Override 129 void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 128 130 { 129 131 if (xform != null) … … 134 136 135 137 136 for (Iterator it = children.iterator(); it.hasNext();) 137 { 138 SVGElement ele = (SVGElement) it.next(); 138 for (SVGElement ele : children) { 139 139 if (ele instanceof RenderableElement) 140 140 { … … 146 146 } 147 147 148 @Override 148 149 public void render(Graphics2D g) throws SVGException 149 150 { … … 169 170 beginLayer(g); 170 171 171 Iterator it = children.iterator();172 Iterator<SVGElement> it = children.iterator(); 172 173 173 174 // try … … 185 186 while (it.hasNext()) 186 187 { 187 SVGElement ele = (SVGElement)it.next();188 SVGElement ele = it.next(); 188 189 if (ele instanceof RenderableElement) 189 190 { … … 212 213 * Retrieves the cached bounding box of this group 213 214 */ 215 @Override 214 216 public Shape getShape() 215 217 { … … 225 227 Area retShape = new Area(); 226 228 227 for (Iterator it = children.iterator(); it.hasNext();) 228 { 229 SVGElement ele = (SVGElement) it.next(); 230 229 for (SVGElement ele : children) { 231 230 if (ele instanceof ShapeElement) 232 231 { … … 246 245 * Retrieves the cached bounding box of this group 247 246 */ 247 @Override 248 248 public Rectangle2D getBoundingBox() throws SVGException 249 249 { … … 262 262 public void calcBoundingBox() throws SVGException 263 263 { 264 // Rectangle2D retRect = new Rectangle2D.Float();265 264 Rectangle2D retRect = null; 266 265 267 for (Iterator it = children.iterator(); it.hasNext();) 268 { 269 SVGElement ele = (SVGElement) it.next(); 270 266 for (SVGElement ele : children) { 271 267 if (ele instanceof RenderableElement) 272 268 { … … 304 300 } 305 301 302 @Override 306 303 public boolean updateTime(double curTime) throws SVGException 307 304 { 308 305 boolean changeState = super.updateTime(curTime); 309 Iterator it = children.iterator();306 Iterator<SVGElement> it = children.iterator(); 310 307 311 308 //Distribute message to all members of this group 312 309 while (it.hasNext()) 313 310 { 314 SVGElement ele = (SVGElement)it.next();311 SVGElement ele = it.next(); 315 312 boolean updateVal = ele.updateTime(curTime); 316 313 -
trunk/src/com/kitfox/svg/Hkern.java
r8084 r11525 50 50 int k; 51 51 52 @Override 52 53 public String getTagName() 53 54 { … … 55 56 } 56 57 58 @Override 57 59 protected void build() throws SVGException 58 60 { … … 79 81 } 80 82 83 @Override 81 84 public boolean updateTime(double curTime) throws SVGException 82 85 { -
trunk/src/com/kitfox/svg/ImageSVG.java
r8084 r11525 77 77 } 78 78 79 @Override 79 80 public String getTagName() 80 81 { … … 82 83 } 83 84 85 @Override 84 86 protected void build() throws SVGException 85 87 { … … 185 187 } 186 188 187 void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException 189 @Override 190 void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 188 191 { 189 192 if (getBoundingBox().contains(point)) … … 193 196 } 194 197 195 void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException 198 @Override 199 void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 196 200 { 197 201 if (ltw.createTransformedShape(getBoundingBox()).intersects(pickArea)) … … 201 205 } 202 206 207 @Override 203 208 public void render(Graphics2D g) throws SVGException 204 209 { … … 262 267 } 263 268 269 @Override 264 270 public Rectangle2D getBoundingBox() 265 271 { … … 274 280 * update 275 281 */ 282 @Override 276 283 public boolean updateTime(double curTime) throws SVGException 277 284 { -
trunk/src/com/kitfox/svg/Line.java
r8084 r11525 63 63 } 64 64 65 @Override 65 66 public String getTagName() 66 67 { … … 68 69 } 69 70 71 @Override 70 72 protected void build() throws SVGException 71 73 { … … 97 99 } 98 100 101 @Override 99 102 public void render(Graphics2D g) throws SVGException 100 103 { … … 104 107 } 105 108 109 @Override 106 110 public Shape getShape() 107 111 { … … 109 113 } 110 114 115 @Override 111 116 public Rectangle2D getBoundingBox() throws SVGException 112 117 { … … 121 126 * update 122 127 */ 128 @Override 123 129 public boolean updateTime(double curTime) throws SVGException 124 130 { -
trunk/src/com/kitfox/svg/LinearGradient.java
r10787 r11525 65 65 } 66 66 67 @Override 67 68 public String getTagName() 68 69 { … … 70 71 } 71 72 73 @Override 72 74 protected void build() throws SVGException 73 75 { … … 97 99 } 98 100 101 @Override 99 102 public Paint getPaint(Rectangle2D bounds, AffineTransform xform) 100 103 { … … 168 171 * update 169 172 */ 173 @Override 170 174 public boolean updateTime(double curTime) throws SVGException 171 175 { -
trunk/src/com/kitfox/svg/Marker.java
r8084 r11525 61 61 boolean markerUnitsStrokeWidth = true; //if set to false 'userSpaceOnUse' is assumed 62 62 63 @Override 63 64 public String getTagName() 64 65 { … … 66 67 } 67 68 69 @Override 68 70 protected void build() throws SVGException 69 71 { … … 131 133 } 132 134 135 @Override 133 136 protected boolean outsideClip(Graphics2D g) throws SVGException 134 137 { … … 144 147 } 145 148 149 @Override 146 150 public void render(Graphics2D g) throws SVGException 147 151 { … … 173 177 } 174 178 179 @Override 175 180 public Shape getShape() 176 181 { … … 179 184 } 180 185 186 @Override 181 187 public Rectangle2D getBoundingBox() throws SVGException 182 188 { … … 192 198 * update 193 199 */ 200 @Override 194 201 public boolean updateTime(double curTime) throws SVGException 195 202 { … … 229 236 { 230 237 231 private ArrayList markerList = new ArrayList();238 private ArrayList<MarkerPos> markerList = new ArrayList<MarkerPos>(); 232 239 boolean started = false; 233 240 … … 362 369 * @return the markerList 363 370 */ 364 public ArrayList getMarkerList()371 public ArrayList<MarkerPos> getMarkerList() 365 372 { 366 373 return markerList; -
trunk/src/com/kitfox/svg/Metadata.java
r8084 r11525 53 53 } 54 54 55 @Override 55 56 public String getTagName() 56 57 { … … 58 59 } 59 60 61 @Override 60 62 public boolean updateTime(double curTime) 61 63 { -
trunk/src/com/kitfox/svg/MissingGlyph.java
r8084 r11525 73 73 } 74 74 75 @Override 75 76 public String getTagName() 76 77 { … … 82 83 * each child tag that has been processed 83 84 */ 85 @Override 84 86 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 85 87 { … … 87 89 } 88 90 91 @Override 89 92 protected void build() throws SVGException 90 93 { … … 153 156 } 154 157 158 @Override 155 159 public void render(Graphics2D g) throws SVGException 156 160 { … … 162 166 } 163 167 164 Iterator it = children.iterator();168 Iterator<SVGElement> it = children.iterator(); 165 169 while (it.hasNext()) 166 170 { 167 SVGElement ele = (SVGElement)it.next();171 SVGElement ele = it.next(); 168 172 if (ele instanceof RenderableElement) 169 173 { … … 212 216 } 213 217 218 @Override 214 219 public Shape getShape() 215 220 { … … 221 226 } 222 227 228 @Override 223 229 public Rectangle2D getBoundingBox() throws SVGException 224 230 { … … 237 243 * update 238 244 */ 245 @Override 239 246 public boolean updateTime(double curTime) throws SVGException 240 247 { -
trunk/src/com/kitfox/svg/Path.java
r10787 r11525 63 63 } 64 64 65 @Override 65 66 public String getTagName() 66 67 { … … 68 69 } 69 70 71 @Override 70 72 protected void build() throws SVGException 71 73 { … … 86 88 } 87 89 90 @Override 88 91 public void render(Graphics2D g) throws SVGException 89 92 { … … 93 96 } 94 97 98 @Override 95 99 public Shape getShape() 96 100 { … … 98 102 } 99 103 104 @Override 100 105 public Rectangle2D getBoundingBox() throws SVGException 101 106 { … … 110 115 * update 111 116 */ 117 @Override 112 118 public boolean updateTime(double curTime) throws SVGException 113 119 { -
trunk/src/com/kitfox/svg/PatternSVG.java
r8084 r11525 47 47 import java.awt.image.BufferedImage; 48 48 import java.net.URI; 49 import java.util.Iterator;50 49 import java.util.logging.Level; 51 50 import java.util.logging.Logger; … … 77 76 } 78 77 78 @Override 79 79 public String getTagName() 80 80 { … … 86 86 * each child tag that has been processed 87 87 */ 88 @Override 88 89 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 89 90 { … … 91 92 } 92 93 94 @Override 93 95 protected void build() throws SVGException 94 96 { … … 227 229 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 228 230 229 for (Iterator it = children.iterator(); it.hasNext();) 230 { 231 SVGElement ele = (SVGElement) it.next(); 231 for (SVGElement ele : children) { 232 232 if (ele instanceof RenderableElement) 233 233 { … … 264 264 } 265 265 266 @Override 266 267 public Paint getPaint(Rectangle2D bounds, AffineTransform xform) 267 268 { … … 276 277 * update 277 278 */ 279 @Override 278 280 public boolean updateTime(double curTime) throws SVGException 279 281 { -
trunk/src/com/kitfox/svg/Polygon.java
r8084 r11525 62 62 } 63 63 64 @Override 64 65 public String getTagName() 65 66 { … … 67 68 } 68 69 70 @Override 69 71 protected void build() throws SVGException 70 72 { … … 97 99 } 98 100 101 @Override 99 102 public void render(Graphics2D g) throws SVGException 100 103 { … … 104 107 } 105 108 109 @Override 106 110 public Shape getShape() 107 111 { … … 109 113 } 110 114 115 @Override 111 116 public Rectangle2D getBoundingBox() throws SVGException 112 117 { … … 121 126 * update 122 127 */ 128 @Override 123 129 public boolean updateTime(double curTime) throws SVGException 124 130 { -
trunk/src/com/kitfox/svg/Polyline.java
r8084 r11525 62 62 } 63 63 64 @Override 64 65 public String getTagName() 65 66 { … … 67 68 } 68 69 70 @Override 69 71 public void build() throws SVGException 70 72 { … … 96 98 } 97 99 100 @Override 98 101 public void render(Graphics2D g) throws SVGException 99 102 { … … 103 106 } 104 107 108 @Override 105 109 public Shape getShape() 106 110 { … … 108 112 } 109 113 114 @Override 110 115 public Rectangle2D getBoundingBox() throws SVGException 111 116 { … … 120 125 * update 121 126 */ 127 @Override 122 128 public boolean updateTime(double curTime) throws SVGException 123 129 { -
trunk/src/com/kitfox/svg/RadialGradient.java
r10787 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 … … 36 36 package com.kitfox.svg; 37 37 38 import com.kitfox.svg.xml.StyleAttribute; 38 39 import java.awt.MultipleGradientPaint; 39 40 import java.awt.Paint; … … 42 43 import java.awt.geom.Point2D; 43 44 import java.awt.geom.Rectangle2D; 44 import java.util.Arrays;45 46 import com.kitfox.svg.xml.StyleAttribute;47 45 48 46 /** -
trunk/src/com/kitfox/svg/Rect.java
r8084 r11525 69 69 } 70 70 71 @Override 71 72 public String getTagName() 72 73 { … … 132 133 } 133 134 */ 135 @Override 134 136 protected void build() throws SVGException 135 137 { … … 200 202 } 201 203 204 @Override 202 205 public void render(Graphics2D g) throws SVGException 203 206 { … … 207 210 } 208 211 212 @Override 209 213 public Shape getShape() 210 214 { … … 212 216 } 213 217 218 @Override 214 219 public Rectangle2D getBoundingBox() throws SVGException 215 220 { … … 224 229 * update 225 230 */ 231 @Override 226 232 public boolean updateTime(double curTime) throws SVGException 227 233 { -
trunk/src/com/kitfox/svg/RenderableElement.java
r8084 r11525 73 73 } 74 74 75 @Override 75 76 protected void build() throws SVGException 76 77 { … … 96 97 abstract public void render(Graphics2D g) throws SVGException; 97 98 98 abstract void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException;99 abstract void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException; 99 100 100 abstract void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException;101 abstract void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException; 101 102 102 103 abstract public Rectangle2D getBoundingBox() throws SVGException; -
trunk/src/com/kitfox/svg/SVGDiagram.java
r8084 r11525 62 62 63 63 //Indexes elements within this SVG diagram 64 final HashMap idMap = new HashMap();64 final HashMap<String, SVGElement> idMap = new HashMap<>(); 65 65 66 66 SVGRoot root; … … 116 116 * @return the passed in list 117 117 */ 118 public List pick(Point2D point, ListretVec) throws SVGException118 public List<List<SVGElement>> pick(Point2D point, List<List<SVGElement>> retVec) throws SVGException 119 119 { 120 120 return pick(point, false, retVec); 121 121 } 122 122 123 public List pick(Point2D point, boolean boundingBox, ListretVec) throws SVGException123 public List<List<SVGElement>> pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 124 124 { 125 125 if (retVec == null) 126 126 { 127 retVec = new ArrayList ();127 retVec = new ArrayList<>(); 128 128 } 129 129 … … 133 133 } 134 134 135 public List pick(Rectangle2D pickArea, ListretVec) throws SVGException135 public List<List<SVGElement>> pick(Rectangle2D pickArea, List<List<SVGElement>> retVec) throws SVGException 136 136 { 137 137 return pick(pickArea, false, retVec); 138 138 } 139 139 140 public List pick(Rectangle2D pickArea, boolean boundingBox, ListretVec) throws SVGException140 public List<List<SVGElement>> pick(Rectangle2D pickArea, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 141 141 { 142 142 if (retVec == null) 143 143 { 144 retVec = new ArrayList ();144 retVec = new ArrayList<>(); 145 145 } 146 146 -
trunk/src/com/kitfox/svg/SVGElement.java
r8084 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 … … 35 35 */ 36 36 package com.kitfox.svg; 37 38 import java.awt.geom.AffineTransform; 39 import java.awt.geom.GeneralPath; 40 import java.io.Serializable; 41 import java.net.URI; 42 import java.util.ArrayList; 43 import java.util.Collections; 44 import java.util.HashMap; 45 import java.util.HashSet; 46 import java.util.Iterator; 47 import java.util.LinkedList; 48 import java.util.List; 49 import java.util.Set; 50 import java.util.regex.Matcher; 51 import java.util.regex.Pattern; 52 53 import org.xml.sax.Attributes; 54 import org.xml.sax.SAXException; 37 55 38 56 import com.kitfox.svg.pathcmd.Arc; … … 51 69 import com.kitfox.svg.xml.StyleSheet; 52 70 import 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 70 71 71 72 /** … … 79 80 public static final String SVG_NS = "http://www.w3.org/2000/svg"; 80 81 protected SVGElement parent = null; 81 protected final ArrayList children = new ArrayList();82 protected final ArrayList<SVGElement> children = new ArrayList<>(); 82 83 protected String id = null; 83 84 /** … … 88 89 * Styles defined for this elemnt via the <b>style</b> attribute. 89 90 */ 90 protected final HashMap inlineStyles = new HashMap();91 protected final HashMap<String, StyleAttribute> inlineStyles = new HashMap<>(); 91 92 /** 92 93 * Presentation attributes set for this element. Ie, any attribute other 93 94 * than the <b>style</b> attribute. 94 95 */ 95 protected final HashMap presAttribs = new HashMap();96 protected final HashMap<String, StyleAttribute> presAttribs = new HashMap<>(); 96 97 /** 97 98 * A list of presentation attributes to not include in the presentation 98 99 * attribute set. 99 100 */ 100 protected static final Set ignorePresAttrib;101 protected static final Set<String> ignorePresAttrib; 101 102 102 103 static 103 104 { 104 HashSet set = new HashSet();105 HashSet<String> set = new HashSet<>(); 105 106 // set.add("id"); 106 107 // set.add("class"); … … 157 158 * @return an ordered list of nodes from the root of the tree to this node 158 159 */ 159 public List getPath(ListretVec)160 public List<SVGElement> getPath(List<SVGElement> retVec) 160 161 { 161 162 if (retVec == null) 162 163 { 163 retVec = new ArrayList ();164 retVec = new ArrayList<>(); 164 165 } 165 166 … … 179 180 * @return The list containing the children of this group 180 181 */ 181 public List getChildren(ListretVec)182 public List<SVGElement> getChildren(List<SVGElement> retVec) 182 183 { 183 184 if (retVec == null) 184 185 { 185 retVec = new ArrayList ();186 retVec = new ArrayList<>(); 186 187 } 187 188 … … 197 198 public SVGElement getChild(String id) 198 199 { 199 for (Iterator it = children.iterator(); it.hasNext();) 200 { 201 SVGElement ele = (SVGElement) it.next(); 200 for (SVGElement ele : children) { 202 201 String eleId = ele.getId(); 203 202 if (eleId != null && eleId.equals(id)) … … 234 233 } 235 234 236 Object temp = children.get(i);235 SVGElement temp = children.get(i); 237 236 children.set(i, children.get(j)); 238 237 children.set(j, temp); … … 269 268 if (style != null) 270 269 { 271 HashMap map = XMLParseUtil.parseStyle(style, inlineStyles);270 HashMap<?, ?> map = XMLParseUtil.parseStyle(style, inlineStyles); 272 271 } 273 272 … … 302 301 * @return a set of Strings that corespond to CSS attributes on this element 303 302 */ 304 public Set getInlineAttributes()303 public Set<String> getInlineAttributes() 305 304 { 306 305 return inlineStyles.keySet(); … … 310 309 * @return a set of Strings that corespond to XML attributes on this element 311 310 */ 312 public Set getPresentationAttributes()311 public Set<String> getPresentationAttributes() 313 312 { 314 313 return presAttribs.keySet(); … … 330 329 this.diagram = diagram; 331 330 diagram.setElement(id, this); 332 for (Iterator it = children.iterator(); it.hasNext();) 333 { 334 SVGElement ele = (SVGElement) it.next(); 331 for (SVGElement ele : children) { 335 332 ele.setDiagram(diagram); 336 333 } … … 400 397 for (int i = 0; i < children.size(); ++i) 401 398 { 402 SVGElement ele = (SVGElement)children.get(i);399 SVGElement ele = children.get(i); 403 400 ele.build(); 404 401 } … … 418 415 return id; 419 416 } 420 LinkedList contexts = new LinkedList();417 LinkedList<SVGElement> contexts = new LinkedList<>(); 421 418 422 419 /** … … 431 428 protected SVGElement popParentContext() 432 429 { 433 return (SVGElement)contexts.removeLast();430 return contexts.removeLast(); 434 431 } 435 432 … … 474 471 475 472 //Check for local inline styles 476 StyleAttribute styAttr = (StyleAttribute)inlineStyles.get(styName);473 StyleAttribute styAttr = inlineStyles.get(styName); 477 474 478 475 attrib.setStringValue(styAttr == null ? "" : styAttr.getStringValue()); … … 486 483 487 484 //Check for presentation attribute 488 StyleAttribute presAttr = (StyleAttribute)presAttribs.get(styName);485 StyleAttribute presAttr = presAttribs.get(styName); 489 486 490 487 attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue()); … … 533 530 { 534 531 //Check for local inline styles 535 return (StyleAttribute)inlineStyles.get(styName);532 return inlineStyles.get(styName); 536 533 } 537 534 … … 546 543 547 544 //Make sure we have a coresponding presentation attribute 548 StyleAttribute presAttr = (StyleAttribute)presAttribs.get(presName);545 StyleAttribute presAttr = presAttribs.get(presName); 549 546 550 547 //Copy presentation value directly … … 568 565 { 569 566 //Check for local inline styles 570 return (StyleAttribute)presAttribs.get(styName);567 return presAttribs.get(styName); 571 568 } 572 569 … … 601 598 String function = matchWord.group().toLowerCase(); 602 599 603 LinkedList termList = new LinkedList();600 LinkedList<String> termList = new LinkedList<>(); 604 601 while (matchWord.find()) 605 602 { … … 609 606 610 607 double[] terms = new double[termList.size()]; 611 Iterator it = termList.iterator();608 Iterator<String> it = termList.iterator(); 612 609 int count = 0; 613 610 while (it.hasNext()) 614 611 { 615 terms[count++] = XMLParseUtil.parseDouble( (String)it.next());612 terms[count++] = XMLParseUtil.parseDouble(it.next()); 616 613 } 617 614 … … 661 658 } 662 659 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(); 666 663 return Float.parseFloat(s); 667 664 } … … 672 669 673 670 //Tokenize 674 LinkedList tokens = new LinkedList();671 LinkedList<String> tokens = new LinkedList<>(); 675 672 while (matchPathCmd.find()) 676 673 { … … 680 677 681 678 boolean defaultRelative = false; 682 LinkedList cmdList = new LinkedList();679 LinkedList<PathCommand> cmdList = new LinkedList<>(); 683 680 char curCmd = 'Z'; 684 681 while (tokens.size() != 0) 685 682 { 686 String curToken = (String)tokens.removeFirst();683 String curToken = tokens.removeFirst(); 687 684 char initChar = curToken.charAt(0); 688 685 if ((initChar >= 'A' && initChar <= 'Z') || (initChar >= 'a' && initChar <= 'z')) … … 825 822 public SVGElement getChild(int i) 826 823 { 827 return (SVGElement)children.get(i);824 return children.get(i); 828 825 } 829 826 -
trunk/src/com/kitfox/svg/SVGLoader.java
r8084 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 … … 38 38 39 39 40 import java.util.*; 41 import java.net.*; 42 import org.xml.sax.*; 43 import org.xml.sax.helpers.DefaultHandler; 44 40 import java.net.URI; 41 import java.util.HashMap; 42 import java.util.HashSet; 43 import java.util.LinkedList; 45 44 import java.util.logging.Level; 46 45 import java.util.logging.Logger; 46 47 import org.xml.sax.Attributes; 48 import org.xml.sax.SAXException; 49 import org.xml.sax.helpers.DefaultHandler; 47 50 48 51 /** … … 52 55 public class SVGLoader extends DefaultHandler 53 56 { 54 final HashMap nodeClasses = new HashMap();57 final HashMap<String, Class<?>> nodeClasses = new HashMap<>(); 55 58 //final HashMap attribClasses = new HashMap(); 56 final LinkedList buildStack = new LinkedList();57 58 final HashSet ignoreClasses = new HashSet();59 final LinkedList<SVGElement> buildStack = new LinkedList<>(); 60 61 final HashSet<String> ignoreClasses = new HashSet<>(); 59 62 60 63 final SVGLoaderHelper helper; … … 73 76 74 77 final boolean verbose; 75 78 76 79 /** Creates a new instance of SVGLoader */ 77 80 public SVGLoader(URI xmlBase, SVGUniverse universe) … … 79 82 this(xmlBase, universe, false); 80 83 } 81 84 82 85 public SVGLoader(URI xmlBase, SVGUniverse universe, boolean verbose) 83 86 { 84 87 this.verbose = verbose; 85 88 86 89 diagram = new SVGDiagram(xmlBase, universe); 87 90 … … 138 141 return sb.toString(); 139 142 } 140 143 144 @Override 141 145 public void startDocument() throws SAXException 142 146 { … … 146 150 } 147 151 152 @Override 148 153 public void endDocument() throws SAXException 149 154 { … … 151 156 } 152 157 158 @Override 153 159 public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException 154 160 { … … 158 164 } 159 165 indent++; 160 166 161 167 if (skipNonSVGTagDepth != 0 || (!namespaceURI.equals("") && !namespaceURI.equals(SVGElement.SVG_NS))) 162 168 { … … 164 170 return; 165 171 } 166 172 167 173 sName = sName.toLowerCase(); 168 174 … … 187 193 188 194 try { 189 Class cls = (Class)obj;195 Class<?> cls = (Class<?>)obj; 190 196 SVGElement svgEle = (SVGElement)cls.newInstance(); 191 197 192 198 SVGElement parent = null; 193 if (buildStack.size() != 0) parent = (SVGElement)buildStack.getLast();199 if (buildStack.size() != 0) parent = buildStack.getLast(); 194 200 svgEle.loaderStartElement(helper, attrs, parent); 195 201 … … 198 204 catch (Exception e) 199 205 { 200 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 206 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 201 207 "Could not load", e); 202 208 throw new SAXException(e); … … 205 211 } 206 212 213 @Override 207 214 public void endElement(String namespaceURI, String sName, String qName) 208 215 throws SAXException … … 213 220 System.err.println(printIndent(indent, " ") + "Ending parse of tag " + sName+ ": " + namespaceURI); 214 221 } 215 222 216 223 if (skipNonSVGTagDepth != 0) 217 224 { … … 219 226 return; 220 227 } 221 228 222 229 sName = sName.toLowerCase(); 223 230 … … 230 237 231 238 try { 232 SVGElement svgEle = (SVGElement)buildStack.removeLast();239 SVGElement svgEle = buildStack.removeLast(); 233 240 234 241 svgEle.loaderEndElement(helper); … … 237 244 if (buildStack.size() != 0) 238 245 { 239 parent = (SVGElement)buildStack.getLast();246 parent = buildStack.getLast(); 240 247 } 241 248 //else loadRoot = (SVGElement)svgEle; … … 253 260 catch (Exception e) 254 261 { 255 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 262 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 256 263 "Could not parse", e); 257 264 throw new SAXException(e); … … 259 266 } 260 267 268 @Override 261 269 public void characters(char buf[], int offset, int len) 262 270 throws SAXException … … 269 277 if (buildStack.size() != 0) 270 278 { 271 SVGElement parent = (SVGElement)buildStack.getLast();279 SVGElement parent = buildStack.getLast(); 272 280 String s = new String(buf, offset, len); 273 281 parent.loaderAddText(helper, s); … … 275 283 } 276 284 285 @Override 277 286 public void processingInstruction(String target, String data) 278 287 throws SAXException … … 280 289 //Check for external style sheet 281 290 } 282 291 283 292 // public SVGElement getLoadRoot() { return loadRoot; } 284 293 public SVGDiagram getLoadedDiagram() { return diagram; } -
trunk/src/com/kitfox/svg/SVGLoaderHelper.java
r8084 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; 38 38 39 import java.net. *;39 import java.net.URI; 40 40 41 41 /** … … 56 56 57 57 public final URI xmlBase; 58 58 59 59 /** Creates a new instance of SVGLoaderHelper */ 60 60 public SVGLoaderHelper(URI xmlBase, SVGUniverse universe, SVGDiagram diagram) -
trunk/src/com/kitfox/svg/SVGRoot.java
r10787 r11525 93 93 } 94 94 95 @Override 95 96 public String getTagName() 96 97 { … … 98 99 } 99 100 101 @Override 100 102 public void build() throws SVGException 101 103 { … … 163 165 } 164 166 167 @Override 165 168 public SVGRoot getRoot() 166 169 { … … 262 265 { 263 266 prepareViewport(); 264 267 265 268 Rectangle targetViewport = g.getClipBounds(); 266 269 // 270 // if (targetViewport == null) 271 // { 272 // Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); 273 // targetViewport = new Rectangle(0, 0, size.width, size.height); 274 // } 275 // clipRect.setRect(targetViewport); 276 277 267 278 Rectangle deviceViewport = diagram.getDeviceViewport(); 268 279 if (width != null && height != null) … … 294 305 else 295 306 { 307 // Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); 308 // targetViewport = new Rectangle(0, 0, size.width, size.height); 296 309 targetViewport = new Rectangle(deviceViewport); 297 310 } … … 319 332 } 320 333 321 public void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException 334 @Override 335 public void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 322 336 { 323 337 if (viewXform != null) … … 330 344 } 331 345 332 public void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException 346 @Override 347 public void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 333 348 { 334 349 Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); … … 347 362 } 348 363 364 @Override 349 365 public Shape getShape() 350 366 { … … 353 369 } 354 370 371 @Override 355 372 public Rectangle2D getBoundingBox() throws SVGException 356 373 { … … 381 398 * update 382 399 */ 400 @Override 383 401 public boolean updateTime(double curTime) throws SVGException 384 402 { -
trunk/src/com/kitfox/svg/SVGUniverse.java
r10865 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 … … 36 36 package com.kitfox.svg; 37 37 38 import com.kitfox.svg.app.beans.SVGIcon;39 38 import java.awt.Graphics2D; 40 39 import java.awt.image.BufferedImage; … … 58 57 import java.util.Base64; 59 58 import java.util.HashMap; 60 import java.util.Iterator;61 59 import java.util.logging.Level; 62 60 import java.util.logging.Logger; 63 61 import java.util.zip.GZIPInputStream; 62 64 63 import javax.imageio.ImageIO; 65 64 import javax.xml.parsers.ParserConfigurationException; 66 65 import javax.xml.parsers.SAXParserFactory; 66 67 67 import org.xml.sax.EntityResolver; 68 68 import org.xml.sax.InputSource; … … 70 70 import org.xml.sax.SAXParseException; 71 71 import org.xml.sax.XMLReader; 72 73 import com.kitfox.svg.app.beans.SVGIcon; 72 74 73 75 /** … … 89 91 * initiated from streams will have the scheme <i>svgSalamander</i>. 90 92 */ 91 final HashMap loadedDocs = new HashMap();92 final HashMap loadedFonts = new HashMap();93 final HashMap loadedImages = new HashMap();93 final HashMap<URI, SVGDiagram> loadedDocs = new HashMap<>(); 94 final HashMap<String, Font> loadedFonts = new HashMap<>(); 95 final HashMap<URL, SoftReference<BufferedImage>> loadedImages = new HashMap<>(); 94 96 public static final String INPUTSTREAM_SCHEME = "svgSalamander"; 95 97 /** … … 141 143 public Font getDefaultFont() 142 144 { 143 for (Iterator it = loadedFonts.values().iterator(); it.hasNext();) 144 { 145 return (Font) it.next(); 145 for (Font font : loadedFonts.values()) { 146 return font; 146 147 } 147 148 return null; … … 150 151 public Font getFont(String fontName) 151 152 { 152 return (Font)loadedFonts.get(fontName);153 return loadedFonts.get(fontName); 153 154 } 154 155 … … 183 184 } 184 185 185 SoftReference ref = new SoftReference(img);186 SoftReference<BufferedImage> ref = new SoftReference<>(img); 186 187 loadedImages.put(url, ref); 187 188 … … 218 219 } 219 220 220 SoftReference ref;221 SoftReference<BufferedImage> ref; 221 222 try 222 223 { … … 231 232 icon.paintIcon(null, g, 0, 0); 232 233 g.dispose(); 233 ref = new SoftReference (img);234 ref = new SoftReference<>(img); 234 235 } else 235 236 { 236 237 BufferedImage img = ImageIO.read(imageURL); 237 ref = new SoftReference (img);238 ref = new SoftReference<>(img); 238 239 } 239 240 loadedImages.put(imageURL, ref); … … 247 248 BufferedImage getImage(URL imageURL) 248 249 { 249 SoftReference ref = (SoftReference)loadedImages.get(imageURL);250 SoftReference<BufferedImage> ref = loadedImages.get(imageURL); 250 251 if (ref == null) 251 252 { … … 253 254 } 254 255 255 BufferedImage img = (BufferedImage)ref.get();256 BufferedImage img = ref.get(); 256 257 //If image was cleared from memory, reload it 257 258 if (img == null) … … 265 266 "Could not load image", e); 266 267 } 267 ref = new SoftReference (img);268 ref = new SoftReference<>(img); 268 269 loadedImages.put(imageURL, ref); 269 270 } … … 308 309 URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null); 309 310 310 SVGDiagram dia = (SVGDiagram)loadedDocs.get(xmlBase);311 SVGDiagram dia = loadedDocs.get(xmlBase); 311 312 if (dia == null && loadIfAbsent) 312 313 { … … 316 317 317 318 loadSVG(url, false); 318 dia = (SVGDiagram)loadedDocs.get(xmlBase);319 dia = loadedDocs.get(xmlBase); 319 320 if (dia == null) 320 321 { … … 349 350 } 350 351 351 SVGDiagram dia = (SVGDiagram)loadedDocs.get(xmlBase);352 SVGDiagram dia = loadedDocs.get(xmlBase); 352 353 if (dia != null || !loadIfAbsent) 353 354 { … … 372 373 373 374 loadSVG(url, false); 374 dia = (SVGDiagram)loadedDocs.get(xmlBase);375 dia = loadedDocs.get(xmlBase); 375 376 return dia; 376 377 } catch (Exception e) … … 604 605 /** 605 606 * Get list of uris of all loaded documents and subdocuments. 606 * @return 607 */ 608 public ArrayList getLoadedDocumentURIs()609 { 610 return new ArrayList (loadedDocs.keySet());611 } 612 607 * @return 608 */ 609 public ArrayList<URI> getLoadedDocumentURIs() 610 { 611 return new ArrayList<>(loadedDocs.keySet()); 612 } 613 613 614 /** 614 615 * Remove loaded document from cache. 615 * @param uri 616 * @param uri 616 617 */ 617 618 public void removeDocument(URI uri) … … 619 620 loadedDocs.remove(uri); 620 621 } 621 622 622 623 public boolean isVerbose() 623 624 { -
trunk/src/com/kitfox/svg/ShapeElement.java
r10787 r11525 87 87 88 88 @Override 89 void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException89 void pick(Point2D point, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 90 90 { 91 91 // StyleAttribute styleAttrib = new StyleAttribute(); … … 98 98 99 99 @Override 100 void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException101 { 102 StyleAttribute styleAttrib = new StyleAttribute();100 void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List<List<SVGElement>> retVec) throws SVGException 101 { 102 // StyleAttribute styleAttrib = new StyleAttribute(); 103 103 // if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point)) 104 104 if (ltw.createTransformedShape((boundingBox ? getBoundingBox() : getShape())).intersects(pickArea)) … … 397 397 layout.layout(shape); 398 398 399 ArrayList list = layout.getMarkerList();399 ArrayList<MarkerPos> list = layout.getMarkerList(); 400 400 for (int i = 0; i < list.size(); ++i) 401 401 { 402 MarkerPos pos = (MarkerPos)list.get(i);402 MarkerPos pos = list.get(i); 403 403 404 404 switch (pos.type) -
trunk/src/com/kitfox/svg/Stop.java
r8084 r11525 58 58 } 59 59 60 @Override 60 61 public String getTagName() 61 62 { … … 63 64 } 64 65 66 @Override 65 67 protected void build() throws SVGException 66 68 { … … 105 107 * update 106 108 */ 109 @Override 107 110 public boolean updateTime(double curTime) throws SVGException 108 111 { -
trunk/src/com/kitfox/svg/Style.java
r8084 r11525 62 62 } 63 63 64 @Override 64 65 public String getTagName() 65 66 { … … 70 71 * Called during load process to add text scanned within a tag 71 72 */ 73 @Override 72 74 public void loaderAddText(SVGLoaderHelper helper, String text) 73 75 { … … 78 80 } 79 81 82 @Override 80 83 protected void build() throws SVGException 81 84 { … … 90 93 } 91 94 95 @Override 92 96 public boolean updateTime(double curTime) throws SVGException 93 97 { -
trunk/src/com/kitfox/svg/Symbol.java
r8084 r11525 61 61 } 62 62 63 @Override 63 64 public String getTagName() 64 65 { … … 66 67 } 67 68 69 @Override 68 70 protected void build() throws SVGException 69 71 { … … 94 96 } 95 97 98 @Override 96 99 protected boolean outsideClip(Graphics2D g) throws SVGException 97 100 { … … 108 111 } 109 112 113 @Override 110 114 public void render(Graphics2D g) throws SVGException 111 115 { … … 118 122 } 119 123 124 @Override 120 125 public Shape getShape() 121 126 { … … 124 129 } 125 130 131 @Override 126 132 public Rectangle2D getBoundingBox() throws SVGException 127 133 { … … 137 143 * update 138 144 */ 145 @Override 139 146 public boolean updateTime(double curTime) throws SVGException 140 147 { -
trunk/src/com/kitfox/svg/Text.java
r10787 r11525 44 44 import java.awt.geom.Point2D; 45 45 import java.awt.geom.Rectangle2D; 46 import java. util.Iterator;46 import java.io.Serializable; 47 47 import java.util.LinkedList; 48 import java.util.List; 48 49 import java.util.regex.Matcher; 49 50 import java.util.regex.Pattern; … … 63 64 float fontSize; 64 65 //List of strings and tspans containing the content of this node 65 LinkedList content = new LinkedList();66 LinkedList<Serializable> content = new LinkedList<>(); 66 67 Shape textShape; 67 68 public static final int TXAN_START = 0; … … 98 99 } 99 100 101 @Override 100 102 public String getTagName() 101 103 { … … 122 124 } 123 125 124 public java.util.ListgetContent()126 public List<Serializable> getContent() 125 127 { 126 128 return content; … … 131 133 * each child tag that has been processed 132 134 */ 135 @Override 133 136 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 134 137 { … … 141 144 * Called during load process to add text scanned within a tag 142 145 */ 146 @Override 143 147 public void loaderAddText(SVGLoaderHelper helper, String text) 144 148 { … … 150 154 } 151 155 156 @Override 152 157 public void build() throws SVGException 153 158 { … … 273 278 } 274 279 } 275 280 276 281 if (font == null) 277 282 { … … 286 291 AffineTransform xform = new AffineTransform(); 287 292 288 for (Iterator it = content.iterator(); it.hasNext();) 289 { 290 Object obj = it.next(); 291 293 for (Serializable obj : content) { 292 294 if (obj instanceof String) 293 295 { … … 451 453 // } 452 454 455 @Override 453 456 public void render(Graphics2D g) throws SVGException 454 457 { … … 458 461 } 459 462 463 @Override 460 464 public Shape getShape() 461 465 { … … 463 467 } 464 468 469 @Override 465 470 public Rectangle2D getBoundingBox() throws SVGException 466 471 { … … 475 480 * update 476 481 */ 482 @Override 477 483 public boolean updateTime(double curTime) throws SVGException 478 484 { -
trunk/src/com/kitfox/svg/Title.java
r8084 r11525 55 55 } 56 56 57 @Override 57 58 public String getTagName() 58 59 { … … 63 64 * Called during load process to add text scanned within a tag 64 65 */ 66 @Override 65 67 public void loaderAddText(SVGLoaderHelper helper, String text) 66 68 { … … 80 82 * update 81 83 */ 84 @Override 82 85 public boolean updateTime(double curTime) throws SVGException 83 86 { -
trunk/src/com/kitfox/svg/TransformableElement.java
r8084 r11525 87 87 */ 88 88 89 @Override 89 90 protected void build() throws SVGException 90 91 { … … 124 125 * update 125 126 */ 127 @Override 126 128 public boolean updateTime(double curTime) throws SVGException 127 129 { -
trunk/src/com/kitfox/svg/Tspan.java
r10787 r11525 41 41 import java.awt.Shape; 42 42 import java.awt.font.FontRenderContext; 43 import java.awt.font.GlyphMetrics;44 import java.awt.font.GlyphVector;45 43 import java.awt.geom.AffineTransform; 46 44 import java.awt.geom.GeneralPath; … … 73 71 } 74 72 73 @Override 75 74 public String getTagName() 76 75 { … … 125 124 * Called during load process to add text scanned within a tag 126 125 */ 126 @Override 127 127 public void loaderAddText(SVGLoaderHelper helper, String text) 128 128 { … … 130 130 } 131 131 132 @Override 132 133 protected void build() throws SVGException 133 134 { … … 340 341 // } 341 342 343 @Override 342 344 public void render(Graphics2D g) throws SVGException 343 345 { … … 433 435 float cursorY = 0; 434 436 435 int posPtr = 1;436 437 FontRenderContext frc = g.getFontRenderContext(); 437 438 … … 442 443 } 443 444 445 @Override 444 446 public Shape getShape() 445 447 { … … 448 450 } 449 451 452 @Override 450 453 public Rectangle2D getBoundingBox() 451 454 { … … 461 464 * update 462 465 */ 466 @Override 463 467 public boolean updateTime(double curTime) throws SVGException 464 468 { -
trunk/src/com/kitfox/svg/Use.java
r8084 r11525 66 66 } 67 67 68 @Override 68 69 public String getTagName() 69 70 { … … 71 72 } 72 73 74 @Override 73 75 protected void build() throws SVGException 74 76 { … … 109 111 } 110 112 113 @Override 111 114 public void render(Graphics2D g) throws SVGException 112 115 { … … 134 137 } 135 138 139 @Override 136 140 public Shape getShape() 137 141 { … … 148 152 } 149 153 154 @Override 150 155 public Rectangle2D getBoundingBox() throws SVGException 151 156 { … … 174 179 * update 175 180 */ 181 @Override 176 182 public boolean updateTime(double curTime) throws SVGException 177 183 { -
trunk/src/com/kitfox/svg/app/beans/SVGIcon.java
r10787 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.app.beans; 38 38 39 import com.kitfox.svg.SVGCache;40 import com.kitfox.svg.SVGDiagram;41 import com.kitfox.svg.SVGException;42 import com.kitfox.svg.SVGUniverse;43 39 import java.awt.Component; 44 40 import java.awt.Dimension; … … 54 50 import java.beans.PropertyChangeSupport; 55 51 import java.net.URI; 52 56 53 import javax.swing.ImageIcon; 57 54 55 import com.kitfox.svg.SVGCache; 56 import com.kitfox.svg.SVGDiagram; 57 import com.kitfox.svg.SVGException; 58 import com.kitfox.svg.SVGUniverse; 58 59 59 60 /** … … 66 67 67 68 public static final String PROP_AUTOSIZE = "PROP_AUTOSIZE"; 68 69 69 70 private final PropertyChangeSupport changes = new PropertyChangeSupport(this); 70 71 71 72 SVGUniverse svgUniverse = SVGCache.getSVGUniverse(); 72 73 public static final int INTERP_NEAREST_NEIGHBOR = 0; 73 74 public static final int INTERP_BILINEAR = 1; 74 75 public static final int INTERP_BICUBIC = 2; 75 76 76 77 private boolean antiAlias; 77 78 private int interpolation = INTERP_NEAREST_NEIGHBOR; 78 79 private boolean clipToViewbox; 79 80 80 81 URI svgURI; 81 82 82 83 // private boolean scaleToFit; 83 84 AffineTransform scaleXform = new AffineTransform(); … … 89 90 public static final int AUTOSIZE_STRETCH = 4; 90 91 private int autosize = AUTOSIZE_NONE; 91 92 92 93 Dimension preferredSize; 93 94 94 95 /** Creates a new instance of SVGIcon */ 95 96 public SVGIcon() 96 97 { 97 98 } 98 99 99 100 public void addPropertyChangeListener(PropertyChangeListener p) 100 101 { 101 102 changes.addPropertyChangeListener(p); 102 103 } 103 104 104 105 public void removePropertyChangeListener(PropertyChangeListener p) 105 106 { 106 107 changes.removePropertyChangeListener(p); 107 108 } 108 109 110 @Override 109 111 public Image getImage() 110 112 { … … 117 119 * @return height of this icon 118 120 */ 119 public int getIconHeight ()121 public int getIconHeightIgnoreAutosize() 120 122 { 121 123 if (preferredSize != null && 122 (autosize == AUTOSIZE_VERT || autosize == AUTOSIZE_STRETCH 124 (autosize == AUTOSIZE_VERT || autosize == AUTOSIZE_STRETCH 123 125 || autosize == AUTOSIZE_BESTFIT)) 124 126 { 125 127 return preferredSize.height; 126 128 } 127 129 128 130 SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 129 131 if (diagram == null) … … 133 135 return (int)diagram.getHeight(); 134 136 } 135 137 136 138 /** 137 139 * @return width of this icon 138 140 */ 139 public int getIconWidth ()141 public int getIconWidthIgnoreAutosize() 140 142 { 141 143 if (preferredSize != null && 142 (autosize == AUTOSIZE_HORIZ || autosize == AUTOSIZE_STRETCH 144 (autosize == AUTOSIZE_HORIZ || autosize == AUTOSIZE_STRETCH 143 145 || autosize == AUTOSIZE_BESTFIT)) 144 146 { 145 147 return preferredSize.width; 146 148 } 147 149 148 150 SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 149 151 if (diagram == null) … … 153 155 return (int)diagram.getWidth(); 154 156 } 155 157 158 private boolean isAutoSizeBestFitUseFixedHeight(final int iconWidthIgnoreAutosize, final int iconHeightIgnoreAutosize, 159 final SVGDiagram diagram) 160 { 161 return iconHeightIgnoreAutosize/diagram.getHeight() < iconWidthIgnoreAutosize/diagram.getWidth(); 162 } 163 164 @Override 165 public int getIconWidth() 166 { 167 final int iconWidthIgnoreAutosize = getIconWidthIgnoreAutosize(); 168 final int iconHeightIgnoreAutosize = getIconHeightIgnoreAutosize(); 169 final SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 170 if (preferredSize != null && (autosize == AUTOSIZE_VERT || 171 (autosize == AUTOSIZE_BESTFIT && isAutoSizeBestFitUseFixedHeight(iconWidthIgnoreAutosize, iconHeightIgnoreAutosize, diagram)))) 172 { 173 final double aspectRatio = diagram.getHeight()/diagram.getWidth(); 174 return (int)(iconHeightIgnoreAutosize / aspectRatio); 175 } 176 else 177 { 178 return iconWidthIgnoreAutosize; 179 } 180 } 181 182 @Override 183 public int getIconHeight() 184 { 185 final int iconWidthIgnoreAutosize = getIconWidthIgnoreAutosize(); 186 final int iconHeightIgnoreAutosize = getIconHeightIgnoreAutosize(); 187 final SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 188 if (preferredSize != null && (autosize == AUTOSIZE_HORIZ || 189 (autosize == AUTOSIZE_BESTFIT && !isAutoSizeBestFitUseFixedHeight(iconWidthIgnoreAutosize, iconHeightIgnoreAutosize, diagram)))) 190 { 191 final double aspectRatio = diagram.getHeight()/diagram.getWidth(); 192 return (int)(iconWidthIgnoreAutosize * aspectRatio); 193 } 194 else 195 { 196 return iconHeightIgnoreAutosize; 197 } 198 } 199 156 200 /** 157 201 * Draws the icon to the specified component. … … 161 205 * @param y - Y coordinate to draw icon 162 206 */ 207 @Override 163 208 public void paintIcon(Component comp, Graphics gg, int x, int y) 164 209 { 165 //Copy graphics object so that 210 //Copy graphics object so that 166 211 Graphics2D g = (Graphics2D)gg.create(); 167 212 paintIcon(comp, g, x, y); 168 213 g.dispose(); 169 214 } 170 215 171 216 private void paintIcon(Component comp, Graphics2D g, int x, int y) 172 217 { 173 218 Object oldAliasHint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); 174 219 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); 175 220 176 221 Object oldInterpolationHint = g.getRenderingHint(RenderingHints.KEY_INTERPOLATION); 177 222 switch (interpolation) … … 187 232 break; 188 233 } 189 190 234 235 191 236 SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 192 237 if (diagram == null) … … 194 239 return; 195 240 } 196 241 197 242 g.translate(x, y); 198 243 diagram.setIgnoringClipHeuristic(!clipToViewbox); … … 201 246 g.setClip(new Rectangle2D.Float(0, 0, diagram.getWidth(), diagram.getHeight())); 202 247 } 203 204 248 249 205 250 if (autosize == AUTOSIZE_NONE) 206 251 { … … 217 262 return; 218 263 } 219 220 final int width = getIconWidth ();221 final int height = getIconHeight ();264 265 final int width = getIconWidthIgnoreAutosize(); 266 final int height = getIconHeightIgnoreAutosize(); 222 267 // int width = getWidth(); 223 268 // int height = getHeight(); 224 269 225 270 if (width == 0 || height == 0) 226 271 { 227 272 return; 228 273 } 229 274 230 275 // if (width == 0 || height == 0) 231 276 // { … … 236 281 // return; 237 282 // } 238 283 239 284 // g.setClip(0, 0, width, height); 240 241 285 286 242 287 // final Rectangle2D.Double rect = new Rectangle2D.Double(); 243 288 // diagram.getViewRect(rect); 244 // 289 // 245 290 // scaleXform.setToScale(width / rect.width, height / rect.height); 246 291 double diaWidth = diagram.getWidth(); 247 292 double diaHeight = diagram.getHeight(); 248 293 249 294 double scaleW = 1; 250 295 double scaleH = 1; 251 296 if (autosize == AUTOSIZE_BESTFIT) 252 297 { 253 scaleW = scaleH = (height / diaHeight < width / diaWidth) 298 scaleW = scaleH = (height / diaHeight < width / diaWidth) 254 299 ? height / diaHeight : width / diaWidth; 255 300 } … … 268 313 } 269 314 scaleXform.setToScale(scaleW, scaleH); 270 315 271 316 AffineTransform oldXform = g.getTransform(); 272 317 g.transform(scaleXform); 273 318 274 319 try 275 320 { … … 280 325 throw new RuntimeException(e); 281 326 } 282 327 283 328 g.setTransform(oldXform); 284 285 329 330 286 331 g.translate(-x, -y); 287 332 288 333 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAliasHint); 289 334 if (oldInterpolationHint != null) … … 292 337 } 293 338 } 294 339 295 340 /** 296 341 * @return the universe this icon draws it's SVGDiagrams from … … 300 345 return svgUniverse; 301 346 } 302 347 303 348 public void setSvgUniverse(SVGUniverse svgUniverse) 304 349 { … … 307 352 changes.firePropertyChange("svgUniverse", old, svgUniverse); 308 353 } 309 354 310 355 /** 311 356 * @return the uni of the document being displayed by this icon … … 315 360 return svgURI; 316 361 } 317 362 318 363 /** 319 364 * Loads an SVG document from a URI. … … 324 369 URI old = this.svgURI; 325 370 this.svgURI = svgURI; 326 371 327 372 SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 328 373 if (diagram != null) … … 335 380 diagram.setDeviceViewport(new Rectangle(0, 0, size.width, size.height)); 336 381 } 337 382 338 383 changes.firePropertyChange("svgURI", old, svgURI); 339 384 } 340 385 341 386 /** 342 387 * Loads an SVG document from the classpath. This function is equivilant to … … 347 392 { 348 393 URI old = this.svgURI; 349 394 350 395 try 351 396 { 352 397 svgURI = new URI(getClass().getResource(resourcePath).toString()); 353 398 changes.firePropertyChange("svgURI", old, svgURI); 354 399 355 400 SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 356 401 if (diagram != null) … … 358 403 diagram.setDeviceViewport(new Rectangle(0, 0, preferredSize.width, preferredSize.height)); 359 404 } 360 405 361 406 } 362 407 catch (Exception e) … … 365 410 } 366 411 } 367 368 /** 369 * If this SVG document has a viewbox, if scaleToFit is set, will scale the viewbox to match the 370 * preferred size of this icon 371 * @deprecated 372 * @return 373 */ 374 public boolean isScaleToFit() 375 { 376 return autosize == AUTOSIZE_STRETCH; 377 } 378 379 /** 380 * @deprecated 381 * @return 382 */ 383 public void setScaleToFit(boolean scaleToFit) 384 { 385 setAutosize(AUTOSIZE_STRETCH); 386 // boolean old = this.scaleToFit; 387 // this.scaleToFit = scaleToFit; 388 // firePropertyChange("scaleToFit", old, scaleToFit); 389 } 390 412 391 413 public Dimension getPreferredSize() 392 414 { … … 400 422 } 401 423 } 402 424 403 425 return new Dimension(preferredSize); 404 426 } 405 427 406 428 public void setPreferredSize(Dimension preferredSize) 407 429 { 408 430 Dimension old = this.preferredSize; 409 431 this.preferredSize = preferredSize; 410 432 411 433 SVGDiagram diagram = svgUniverse.getDiagram(svgURI); 412 434 if (diagram != null) … … 414 436 diagram.setDeviceViewport(new Rectangle(0, 0, preferredSize.width, preferredSize.height)); 415 437 } 416 438 417 439 changes.firePropertyChange("preferredSize", old, preferredSize); 418 440 } 419 420 441 421 442 /** 422 443 * @return true if antiAliasing is turned on. 423 * @deprecated424 */425 public boolean getUseAntiAlias()426 {427 return getAntiAlias();428 }429 430 /**431 * @param antiAlias true to use antiAliasing.432 * @deprecated433 */434 public void setUseAntiAlias(boolean antiAlias)435 {436 setAntiAlias(antiAlias);437 }438 439 /**440 * @return true if antiAliasing is turned on.441 444 */ 442 445 public boolean getAntiAlias() … … 444 447 return antiAlias; 445 448 } 446 449 447 450 /** 448 451 * @param antiAlias true to use antiAliasing. … … 454 457 changes.firePropertyChange("antiAlias", old, antiAlias); 455 458 } 456 459 457 460 /** 458 461 * @return interpolation used in rescaling images … … 462 465 return interpolation; 463 466 } 464 467 465 468 /** 466 469 * @param interpolation Interpolation value used in rescaling images. … … 476 479 changes.firePropertyChange("interpolation", old, interpolation); 477 480 } 478 481 479 482 /** 480 483 * clipToViewbox will set a clip box equivilant to the SVG's viewbox before … … 485 488 return clipToViewbox; 486 489 } 487 490 488 491 public void setClipToViewbox(boolean clipToViewbox) 489 492 { … … 508 511 changes.firePropertyChange(PROP_AUTOSIZE, oldAutosize, autosize); 509 512 } 510 513 511 514 } -
trunk/src/com/kitfox/svg/app/data/Handler.java
r10746 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 … … 35 35 package com.kitfox.svg.app.data; 36 36 37 import com.kitfox.svg.SVGConst;38 37 import java.io.ByteArrayInputStream; 39 38 import java.io.IOException; … … 45 44 import java.util.logging.Level; 46 45 import java.util.logging.Logger; 46 47 import com.kitfox.svg.SVGConst; 47 48 48 49 /** … … 78 79 } 79 80 } 80 81 82 @Override 81 83 public void connect() throws IOException 82 84 { 83 85 } 84 86 87 @Override 85 88 public String getHeaderField(String name) 86 89 { … … 93 96 } 94 97 98 @Override 95 99 public InputStream getInputStream() throws IOException 96 100 { … … 104 108 } 105 109 110 @Override 106 111 protected URLConnection openConnection(URL u) throws IOException 107 112 { -
trunk/src/com/kitfox/svg/pathcmd/Arc.java
r8084 r11525 77 77 78 78 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 79 @Override 79 80 public void appendPath(GeneralPath path, BuildHistory hist) 80 81 { … … 91 92 } 92 93 94 @Override 93 95 public int getNumKnotsAdded() 94 96 { … … 257 259 } 258 260 261 @Override 259 262 public String toString() 260 263 { -
trunk/src/com/kitfox/svg/pathcmd/Cubic.java
r8084 r11525 57 57 } 58 58 59 @Override 59 60 public String toString() 60 61 { … … 75 76 76 77 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 78 @Override 77 79 public void appendPath(GeneralPath path, BuildHistory hist) 78 80 { … … 88 90 } 89 91 92 @Override 90 93 public int getNumKnotsAdded() 91 94 { -
trunk/src/com/kitfox/svg/pathcmd/CubicSmooth.java
r8084 r11525 64 64 65 65 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 66 @Override 66 67 public void appendPath(GeneralPath path, BuildHistory hist) 67 68 { … … 82 83 } 83 84 85 @Override 84 86 public int getNumKnotsAdded() 85 87 { … … 87 89 } 88 90 91 @Override 89 92 public String toString() 90 93 { -
trunk/src/com/kitfox/svg/pathcmd/Horizontal.java
r8084 r11525 52 52 } 53 53 54 @Override 54 55 public String toString() 55 56 { … … 64 65 65 66 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 67 @Override 66 68 public void appendPath(GeneralPath path, BuildHistory hist) 67 69 { … … 74 76 } 75 77 78 @Override 76 79 public int getNumKnotsAdded() 77 80 { -
trunk/src/com/kitfox/svg/pathcmd/LineTo.java
r8084 r11525 61 61 62 62 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 63 @Override 63 64 public void appendPath(GeneralPath path, BuildHistory hist) 64 65 { … … 71 72 } 72 73 74 @Override 73 75 public int getNumKnotsAdded() 74 76 { … … 76 78 } 77 79 80 @Override 78 81 public String toString() 79 82 { -
trunk/src/com/kitfox/svg/pathcmd/MoveTo.java
r8084 r11525 60 60 61 61 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 62 @Override 62 63 public void appendPath(GeneralPath path, BuildHistory hist) 63 64 { … … 71 72 } 72 73 74 @Override 73 75 public int getNumKnotsAdded() 74 76 { … … 76 78 } 77 79 80 @Override 78 81 public String toString() 79 82 { -
trunk/src/com/kitfox/svg/pathcmd/Quadratic.java
r8084 r11525 55 55 } 56 56 57 @Override 57 58 public String toString() 58 59 { … … 70 71 71 72 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 73 @Override 72 74 public void appendPath(GeneralPath path, BuildHistory hist) 73 75 { … … 80 82 } 81 83 84 @Override 82 85 public int getNumKnotsAdded() 83 86 { -
trunk/src/com/kitfox/svg/pathcmd/QuadraticSmooth.java
r8084 r11525 53 53 } 54 54 55 @Override 55 56 public String toString() 56 57 { … … 65 66 66 67 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 68 @Override 67 69 public void appendPath(GeneralPath path, BuildHistory hist) 68 70 { … … 83 85 } 84 86 87 @Override 85 88 public int getNumKnotsAdded() 86 89 { -
trunk/src/com/kitfox/svg/pathcmd/Terminal.java
r8084 r11525 52 52 } 53 53 54 @Override 54 55 public String toString() 55 56 { … … 59 60 60 61 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 62 @Override 61 63 public void appendPath(GeneralPath path, BuildHistory hist) 62 64 { … … 66 68 } 67 69 70 @Override 68 71 public int getNumKnotsAdded() 69 72 { -
trunk/src/com/kitfox/svg/pathcmd/Vertical.java
r8084 r11525 52 52 } 53 53 54 @Override 54 55 public String toString() 55 56 { … … 63 64 64 65 // public void appendPath(ExtendedGeneralPath path, BuildHistory hist) 66 @Override 65 67 public void appendPath(GeneralPath path, BuildHistory hist) 66 68 { … … 73 75 } 74 76 77 @Override 75 78 public int getNumKnotsAdded() 76 79 { -
trunk/src/com/kitfox/svg/util/FontSystem.java
r10787 r11525 56 56 FontMetrics fm; 57 57 58 HashMap glyphCache = new HashMap();58 HashMap<String, Glyph> glyphCache = new HashMap<String, Glyph>(); 59 59 60 60 public FontSystem(String fontFamily, int fontStyle, int fontWeight, int fontSize) … … 94 94 } 95 95 96 @Override 96 97 public MissingGlyph getGlyph(String unicode) 97 98 { -
trunk/src/com/kitfox/svg/xml/ColorTable.java
r8084 r11525 49 49 { 50 50 51 static final Map colorTable;51 static final Map<String, Color> colorTable; 52 52 static { 53 HashMap table = new HashMap();53 HashMap<String, Color> table = new HashMap<>(); 54 54 55 55 //We really should be interpreting the currentColor keyword as -
trunk/src/com/kitfox/svg/xml/NumberWithUnits.java
r8084 r11525 123 123 } 124 124 125 @Override 125 126 public String toString() 126 127 { … … 128 129 } 129 130 131 @Override 130 132 public boolean equals(Object obj) 131 133 { … … 146 148 } 147 149 150 @Override 148 151 public int hashCode() 149 152 { -
trunk/src/com/kitfox/svg/xml/ReadableXMLElement.java
r8084 r11525 39 39 import org.w3c.dom.*; 40 40 import java.net.*; 41 import java.util.*;42 import java.lang.reflect.*;43 41 44 42 /** -
trunk/src/com/kitfox/svg/xml/StyleSheet.java
r8084 r11525 16 16 public class StyleSheet 17 17 { 18 HashMap ruleMap = new HashMap();18 HashMap<StyleSheetRule, String> ruleMap = new HashMap<>(); 19 19 20 20 public static StyleSheet parseSheet(String src) -
trunk/src/com/kitfox/svg/xml/StyleSheetRule.java
r8084 r11525 22 22 } 23 23 24 @Override 24 25 public int hashCode() 25 26 { … … 31 32 } 32 33 34 @Override 33 35 public boolean equals(Object obj) 34 36 { -
trunk/src/com/kitfox/svg/xml/WritableXMLElement.java
r8084 r11525 37 37 package com.kitfox.svg.xml; 38 38 39 import org.w3c.dom.*;40 import java.net.*;41 import java.util.*;42 import java.lang.reflect.*;43 44 39 /** 45 40 * @author Mark McKay -
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.