Changeset 7676 in josm for trunk/src/com/kitfox/svg/SVGRoot.java
- Timestamp:
- 2014-10-30T11:39:47+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/SVGRoot.java
r6002 r7676 44 44 import java.awt.Shape; 45 45 import java.awt.geom.AffineTransform; 46 import java.awt.geom.NoninvertibleTransformException; 47 import java.awt.geom.Point2D; 46 48 import java.awt.geom.Rectangle2D; 49 import java.util.List; 47 50 48 51 /** … … 239 242 clipRect.setRect(xx, yy, ww, hh); 240 243 244 // if (viewBox == null) 245 // { 246 // viewXform.setToIdentity(); 247 // } 248 // else 249 // { 250 // //If viewport window is set, we are drawing to entire viewport 251 // clipRect.setRect(deviceViewport); 252 // 253 // viewXform.setToIdentity(); 254 // viewXform.setToTranslation(deviceViewport.x, deviceViewport.y); 255 // viewXform.scale(deviceViewport.width, deviceViewport.height); 256 // viewXform.scale(1 / viewBox.width, 1 / viewBox.height); 257 // viewXform.translate(-viewBox.x, -viewBox.y); 258 // } 259 } 260 261 public void renderToViewport(Graphics2D g) throws SVGException 262 { 263 prepareViewport(); 264 241 265 if (viewBox == null) 242 266 { … … 245 269 else 246 270 { 247 viewXform.setToTranslation(clipRect.x, clipRect.y); 248 viewXform.scale(clipRect.width, clipRect.height); 271 Rectangle deviceViewport = g.getClipBounds(); 272 //If viewport window is set, we are drawing to entire viewport 273 clipRect.setRect(deviceViewport); 274 275 viewXform.setToIdentity(); 276 viewXform.setToTranslation(deviceViewport.x, deviceViewport.y); 277 viewXform.scale(deviceViewport.width, deviceViewport.height); 249 278 viewXform.scale(1 / viewBox.width, 1 / viewBox.height); 250 279 viewXform.translate(-viewBox.x, -viewBox.y); 251 280 } 252 }253 254 public void render(Graphics2D g) throws SVGException255 {256 prepareViewport();257 281 258 282 AffineTransform cachedXform = g.getTransform(); … … 262 286 263 287 g.setTransform(cachedXform); 288 } 289 290 public void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException 291 { 292 if (viewXform != null) 293 { 294 ltw = new AffineTransform(ltw); 295 ltw.concatenate(viewXform); 296 } 297 298 super.pick(pickArea, ltw, boundingBox, retVec); 299 } 300 301 public void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException 302 { 303 Point2D xPoint = new Point2D.Double(point.getX(), point.getY()); 304 if (viewXform != null) 305 { 306 try 307 { 308 viewXform.inverseTransform(point, xPoint); 309 } catch (NoninvertibleTransformException ex) 310 { 311 throw new SVGException(ex); 312 } 313 } 314 315 super.pick(xPoint, boundingBox, retVec); 264 316 } 265 317
Note:
See TracChangeset
for help on using the changeset viewer.