Changeset 6002 in josm for trunk/src/com/kitfox/svg/SVGUniverse.java
- Timestamp:
- 2013-06-11T01:01:28+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/SVGUniverse.java
r4256 r6002 1 1 /* 2 * SVGUniverse.java 2 * SVG Salamander 3 * Copyright (c) 2004, Mark McKay 4 * All rights reserved. 3 5 * 6 * Redistribution and use in source and binary forms, with or 7 * without modification, are permitted provided that the following 8 * conditions are met: 4 9 * 5 * The Salamander Project - 2D and 3D graphics libraries in Java 6 * Copyright (C) 2004 Mark McKay 10 * - Redistributions of source code must retain the above 11 * copyright notice, this list of conditions and the following 12 * disclaimer. 13 * - Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 16 * provided with the distribution. 7 17 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 23 * projects can be found at http://www.kitfox.com 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 32 * projects can be found at http://www.kitfox.com 24 33 * 25 34 * Created on February 18, 2004, 11:43 PM 26 35 */ 27 28 36 package com.kitfox.svg; 29 37 … … 36 44 import java.io.ByteArrayInputStream; 37 45 import java.io.ByteArrayOutputStream; 38 import java.io.File;39 46 import java.io.IOException; 40 47 import java.io.InputStream; … … 46 53 import java.net.MalformedURLException; 47 54 import java.net.URI; 55 import java.net.URISyntaxException; 48 56 import java.net.URL; 49 57 import java.net.URLConnection; … … 51 59 import java.util.HashMap; 52 60 import java.util.Iterator; 61 import java.util.logging.Level; 62 import java.util.logging.Logger; 53 63 import java.util.zip.GZIPInputStream; 54 64 import javax.imageio.ImageIO; … … 61 71 62 72 /** 63 * Many SVG files can be loaded at one time. These files will quite likely64 * need to reference one another. The SVG universe provides a container for65 * all thesefiles and the means for them to relate to each other.73 * Many SVG files can be loaded at one time. These files will quite likely need 74 * to reference one another. The SVG universe provides a container for all these 75 * files and the means for them to relate to each other. 66 76 * 67 77 * @author Mark McKay … … 70 80 public class SVGUniverse implements Serializable 71 81 { 82 72 83 public static final long serialVersionUID = 0; 73 74 84 transient private PropertyChangeSupport changes = new PropertyChangeSupport(this); 75 76 /** 77 * Maps document URIs to their loaded SVG diagrams. Note that URIs for 85 /** 86 * Maps document URIs to their loaded SVG diagrams. Note that URIs for 78 87 * documents loaded from URLs will reflect their URLs and URIs for documents 79 88 * initiated from streams will have the scheme <i>svgSalamander</i>. 80 89 */ 81 90 final HashMap loadedDocs = new HashMap(); 82 83 91 final HashMap loadedFonts = new HashMap(); 84 85 92 final HashMap loadedImages = new HashMap(); 86 87 93 public static final String INPUTSTREAM_SCHEME = "svgSalamander"; 88 89 /** 90 * Current time in this universe. Used for resolving attributes that 91 * are influenced by track information. Time is in milliseconds. Time 92 * 0 coresponds to the time of 0 in each member diagram. 94 /** 95 * Current time in this universe. Used for resolving attributes that are 96 * influenced by track information. Time is in milliseconds. Time 0 97 * coresponds to the time of 0 in each member diagram. 93 98 */ 94 99 protected double curTime = 0.0; 95 96 100 private boolean verbose = false; 97 98 101 //Cache reader for efficiency 99 102 XMLReader cachedReader; 100 101 /** Creates a new instance of SVGUniverse */ 103 104 /** 105 * Creates a new instance of SVGUniverse 106 */ 102 107 public SVGUniverse() 103 108 { 104 109 } 105 110 106 111 public void addPropertyChangeListener(PropertyChangeListener l) 107 112 { 108 113 changes.addPropertyChangeListener(l); 109 114 } 110 115 111 116 public void removePropertyChangeListener(PropertyChangeListener l) 112 117 { 113 118 changes.removePropertyChangeListener(l); 114 119 } 115 120 116 121 /** 117 122 * Release all loaded SVG document from memory … … 123 128 loadedImages.clear(); 124 129 } 125 130 126 131 /** 127 132 * Returns the current animation time in milliseconds. 128 133 */ 129 134 public double getCurTime() 130 { 131 return curTime; 132 } 133 135 { 136 return curTime; 137 } 138 134 139 public void setCurTime(double curTime) 135 140 { 136 141 double oldTime = this.curTime; 137 this.curTime = curTime; 142 this.curTime = curTime; 138 143 changes.firePropertyChange("curTime", new Double(oldTime), new Double(curTime)); 139 144 } 140 145 141 146 /** 142 147 * Updates all time influenced style and presentation attributes in all SVG … … 147 152 for (Iterator it = loadedDocs.values().iterator(); it.hasNext();) 148 153 { 149 SVGDiagram dia = (SVGDiagram) it.next();154 SVGDiagram dia = (SVGDiagram) it.next(); 150 155 dia.updateTime(curTime); 151 156 } 152 157 } 153 158 154 159 /** 155 160 * Called by the Font element to let the universe know that a font has been … … 160 165 loadedFonts.put(font.getFontFace().getFontFamily(), font); 161 166 } 162 167 163 168 public Font getDefaultFont() 164 169 { 165 170 for (Iterator it = loadedFonts.values().iterator(); it.hasNext();) 166 171 { 167 return (Font) it.next();172 return (Font) it.next(); 168 173 } 169 174 return null; 170 175 } 171 176 172 177 public Font getFont(String fontName) 173 178 { 174 return (Font) loadedFonts.get(fontName);179 return (Font) loadedFonts.get(fontName); 175 180 } 176 181 … … 188 193 { 189 194 content = content.substring(6); 190 try { 195 try 196 { 191 197 byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(content); 192 198 ByteArrayInputStream bais = new ByteArrayInputStream(buf); … … 209 215 210 216 return url; 211 } catch (IOException ex) { 212 ex.printStackTrace(); 217 } catch (IOException ex) 218 { 219 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 220 "Could not decode inline image", ex); 213 221 } 214 222 } 215 223 return null; 216 } 217 else218 {219 try{224 } else 225 { 226 try 227 { 220 228 URL url = imageURI.toURL(); 221 229 registerImage(url); 222 230 return url; 223 } catch (MalformedURLException ex) { 224 ex.printStackTrace(); 231 } catch (MalformedURLException ex) 232 { 233 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 234 "Bad url", ex); 225 235 } 226 236 return null; … … 230 240 void registerImage(URL imageURL) 231 241 { 232 if (loadedImages.containsKey(imageURL)) return; 233 242 if (loadedImages.containsKey(imageURL)) 243 { 244 return; 245 } 246 234 247 SoftReference ref; 235 248 try … … 240 253 SVGIcon icon = new SVGIcon(); 241 254 icon.setSvgURI(imageURL.toURI()); 242 255 243 256 BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); 244 257 Graphics2D g = img.createGraphics(); … … 246 259 g.dispose(); 247 260 ref = new SoftReference(img); 248 } 249 else 261 } else 250 262 { 251 263 BufferedImage img = ImageIO.read(imageURL); … … 253 265 } 254 266 loadedImages.put(imageURL, ref); 255 } 256 catch (Exception e) 257 { 258 System.err.println("Could not load image: " + imageURL); 259 e.printStackTrace(); 260 } 261 } 262 267 } catch (Exception e) 268 { 269 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 270 "Could not load image: " + imageURL, e); 271 } 272 } 273 263 274 BufferedImage getImage(URL imageURL) 264 275 { 265 SoftReference ref = (SoftReference)loadedImages.get(imageURL); 266 if (ref == null) return null; 267 268 BufferedImage img = (BufferedImage)ref.get(); 276 SoftReference ref = (SoftReference) loadedImages.get(imageURL); 277 if (ref == null) 278 { 279 return null; 280 } 281 282 BufferedImage img = (BufferedImage) ref.get(); 269 283 //If image was cleared from memory, reload it 270 284 if (img == null) … … 273 287 { 274 288 img = ImageIO.read(imageURL); 275 } 276 catch (Exception e) 277 { e.printStackTrace(); } 289 } catch (Exception e) 290 { 291 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 292 "Could not load image", e); 293 } 278 294 ref = new SoftReference(img); 279 295 loadedImages.put(imageURL, ref); 280 296 } 281 297 282 298 return img; 283 299 } 284 285 /** 286 * Returns the element of the document at the given URI. If the document287 * isnot already loaded, it will be.300 301 /** 302 * Returns the element of the document at the given URI. If the document is 303 * not already loaded, it will be. 288 304 */ 289 305 public SVGElement getElement(URI path) … … 291 307 return getElement(path, true); 292 308 } 293 309 294 310 public SVGElement getElement(URL path) 295 311 { … … 298 314 URI uri = new URI(path.toString()); 299 315 return getElement(uri, true); 300 } 301 catch (Exception e)302 {303 e.printStackTrace();316 } catch (Exception e) 317 { 318 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 319 "Could not parse url " + path, e); 304 320 } 305 321 return null; 306 322 } 307 308 /** 309 * Looks up a href within our universe. If the href refers to a document that310 * is not loaded, it will be loaded. The URL #target will then be checked311 * against the SVG diagram's index and the coresponding element returned.312 * If there is no coresponding index, null is returned.323 324 /** 325 * Looks up a href within our universe. If the href refers to a document 326 * that is not loaded, it will be loaded. The URL #target will then be 327 * checked against the SVG diagram's index and the coresponding element 328 * returned. If there is no coresponding index, null is returned. 313 329 */ 314 330 public SVGElement getElement(URI path, boolean loadIfAbsent) … … 318 334 //Strip fragment from URI 319 335 URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null); 320 321 SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase);336 337 SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase); 322 338 if (dia == null && loadIfAbsent) 323 339 { … … 325 341 //javax.swing.JOptionPane.showMessageDialog(null, xmlBase.toString()); 326 342 URL url = xmlBase.toURL(); 327 343 328 344 loadSVG(url, false); 329 dia = (SVGDiagram)loadedDocs.get(xmlBase); 330 if (dia == null) return null; 331 } 332 345 dia = (SVGDiagram) loadedDocs.get(xmlBase); 346 if (dia == null) 347 { 348 return null; 349 } 350 } 351 333 352 String fragment = path.getFragment(); 334 353 return fragment == null ? dia.getRoot() : dia.getElement(fragment); 335 } 336 catch (Exception e)337 {338 e.printStackTrace();339 return null; 340 } 341 } 342 354 } catch (Exception e) 355 { 356 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 357 "Could not parse path " + path, e); 358 return null; 359 } 360 } 361 343 362 public SVGDiagram getDiagram(URI xmlBase) 344 363 { 345 364 return getDiagram(xmlBase, true); 346 365 } 347 348 /** 349 * Returns the diagram that has been loaded from this root. 366 367 /** 368 * Returns the diagram that has been loaded from this root. If diagram is 350 369 * not already loaded, returns null. 351 370 */ 352 371 public SVGDiagram getDiagram(URI xmlBase, boolean loadIfAbsent) 353 372 { 354 if (xmlBase == null) return null; 355 356 SVGDiagram dia = (SVGDiagram)loadedDocs.get(xmlBase); 357 if (dia != null || !loadIfAbsent) return dia; 358 373 if (xmlBase == null) 374 { 375 return null; 376 } 377 378 SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase); 379 if (dia != null || !loadIfAbsent) 380 { 381 return dia; 382 } 383 359 384 //Load missing diagram 360 385 try … … 372 397 } 373 398 374 399 375 400 loadSVG(url, false); 376 dia = (SVGDiagram) loadedDocs.get(xmlBase);401 dia = (SVGDiagram) loadedDocs.get(xmlBase); 377 402 return dia; 378 } 379 catch (Exception e)380 {381 e.printStackTrace();382 } 383 403 } catch (Exception e) 404 { 405 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 406 "Could not parse", e); 407 } 408 384 409 return null; 385 410 } 386 387 /** 388 * Wraps input stream in a BufferedInputStream. 411 412 /** 413 * Wraps input stream in a BufferedInputStream. If it is detected that this 389 414 * input stream is GZIPped, also wraps in a GZIPInputStream for inflation. 390 * 415 * 391 416 * @param is Raw input stream 392 417 * @return Uncompressed stream of SVG data … … 406 431 GZIPInputStream iis = new GZIPInputStream(bin); 407 432 return iis; 408 } 409 else 433 } else 410 434 { 411 435 //Plain text … … 413 437 } 414 438 } 415 439 416 440 public URI loadSVG(URL docRoot) 417 441 { 418 442 return loadSVG(docRoot, false); 419 443 } 420 444 421 445 /** 422 446 * Loads an SVG file and all the files it references from the URL provided. 423 447 * If a referenced file already exists in the SVG universe, it is not 424 448 * reloaded. 449 * 425 450 * @param docRoot - URL to the location where this SVG file can be found. 426 451 * @param forceLoad - if true, ignore cached diagram and reload … … 432 457 { 433 458 URI uri = new URI(docRoot.toString()); 434 if (loadedDocs.containsKey(uri) && !forceLoad) return uri; 435 459 if (loadedDocs.containsKey(uri) && !forceLoad) 460 { 461 return uri; 462 } 463 436 464 InputStream is = docRoot.openStream(); 437 465 return loadSVG(uri, new InputSource(createDocumentInputStream(is))); 438 } 439 catch (Throwable t) 440 { 441 t.printStackTrace(); 442 } 443 466 } catch (URISyntaxException ex) 467 { 468 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 469 "Could not parse", ex); 470 } catch (IOException e) 471 { 472 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 473 "Could not parse", e); 474 } 475 444 476 return null; 445 477 } 446 447 478 448 479 public URI loadSVG(InputStream is, String name) throws IOException 449 480 { 450 481 return loadSVG(is, name, false); 451 482 } 452 483 453 484 public URI loadSVG(InputStream is, String name, boolean forceLoad) throws IOException 454 485 { 455 486 URI uri = getStreamBuiltURI(name); 456 if (uri == null) return null; 457 if (loadedDocs.containsKey(uri) && !forceLoad) return uri; 458 487 if (uri == null) 488 { 489 return null; 490 } 491 if (loadedDocs.containsKey(uri) && !forceLoad) 492 { 493 return uri; 494 } 495 459 496 return loadSVG(uri, new InputSource(createDocumentInputStream(is))); 460 497 } 461 498 462 499 public URI loadSVG(Reader reader, String name) 463 500 { 464 501 return loadSVG(reader, name, false); 465 502 } 466 503 467 504 /** 468 505 * This routine allows you to create SVG documents from data streams that 469 * may not necessarily have a URL to load from. 470 * must be identified by a unique URL, Salamander provides a method to 471 * fake this for streams by defining it's own protocol - svgSalamander -472 * for SVGdocuments without a formal URL.506 * may not necessarily have a URL to load from. Since every SVG document 507 * must be identified by a unique URL, Salamander provides a method to fake 508 * this for streams by defining it's own protocol - svgSalamander - for SVG 509 * documents without a formal URL. 473 510 * 474 511 * @param reader - A stream containing a valid SVG document 475 * @param name - <p>A unique name for this document. 512 * @param name - <p>A unique name for this document. It will be used to 476 513 * construct a unique URI to refer to this document and perform resolution 477 * with relative URIs within this document.</p> 478 * <p>For example, a name of "/myScene" will produce the URI 479 * svgSalamander:/myScene. "/maps/canada/toronto" will produce 480 * svgSalamander:/maps/canada/toronto. If this second document then 481 * contained the href "../uk/london", it would resolve by default to 482 * svgSalamander:/maps/uk/london. That is, SVG Salamander defines the 483 * URI scheme svgSalamander for it's own internal use and uses it 484 * for uniquely identfying documents loaded by stream.</p> 485 * <p>If you need to link to documents outside of this scheme, you can 486 * either supply full hrefs (eg, href="url(http://www.kitfox.com/index.html)") 487 * or put the xml:base attribute in a tag to change the defaultbase 488 * URIs are resolved against</p> 489 * <p>If a name does not start with the character '/', it will be automatically 490 * prefixed to it.</p> 514 * with relative URIs within this document.</p> <p>For example, a name of 515 * "/myScene" will produce the URI svgSalamander:/myScene. 516 * "/maps/canada/toronto" will produce svgSalamander:/maps/canada/toronto. 517 * If this second document then contained the href "../uk/london", it would 518 * resolve by default to svgSalamander:/maps/uk/london. That is, SVG 519 * Salamander defines the URI scheme svgSalamander for it's own internal use 520 * and uses it for uniquely identfying documents loaded by stream.</p> <p>If 521 * you need to link to documents outside of this scheme, you can either 522 * supply full hrefs (eg, href="url(http://www.kitfox.com/index.html)") or 523 * put the xml:base attribute in a tag to change the defaultbase URIs are 524 * resolved against</p> <p>If a name does not start with the character '/', 525 * it will be automatically prefixed to it.</p> 491 526 * @param forceLoad - if true, ignore cached diagram and reload 492 527 * … … 498 533 //Synthesize URI for this stream 499 534 URI uri = getStreamBuiltURI(name); 500 if (uri == null) return null; 501 if (loadedDocs.containsKey(uri) && !forceLoad) return uri; 502 535 if (uri == null) 536 { 537 return null; 538 } 539 if (loadedDocs.containsKey(uri) && !forceLoad) 540 { 541 return uri; 542 } 543 503 544 return loadSVG(uri, new InputSource(reader)); 504 545 } 505 546 506 547 /** 507 548 * Synthesize a URI for an SVGDiagram constructed from a stream. 549 * 508 550 * @param name - Name given the document constructed from a stream. 509 551 */ 510 552 public URI getStreamBuiltURI(String name) 511 553 { 512 if (name == null || name.length() == 0) return null; 513 514 if (name.charAt(0) != '/') name = '/' + name; 515 554 if (name == null || name.length() == 0) 555 { 556 return null; 557 } 558 559 if (name.charAt(0) != '/') 560 { 561 name = '/' + name; 562 } 563 516 564 try 517 565 { 518 566 //Dummy URL for SVG documents built from image streams 519 567 return new URI(INPUTSTREAM_SCHEME, name, null); 520 } 521 catch (Exception e)522 {523 e.printStackTrace();524 return null; 525 } 526 } 527 568 } catch (Exception e) 569 { 570 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 571 "Could not parse", e); 572 return null; 573 } 574 } 575 528 576 private XMLReader getXMLReaderCached() throws SAXException 529 577 { … … 534 582 return cachedReader; 535 583 } 536 537 // protected URI loadSVG(URI xmlBase, InputStream is) 584 538 585 protected URI loadSVG(URI xmlBase, InputSource is) 539 586 { 540 587 // Use an instance of ourselves as the SAX event handler 541 588 SVGLoader handler = new SVGLoader(xmlBase, this, verbose); 542 589 543 590 //Place this docment in the universe before it is completely loaded 544 591 // so that the load process can refer to references within it's current 545 592 // document 546 //System.err.println("SVGUniverse: loading dia " + xmlBase);547 593 loadedDocs.put(xmlBase, handler.getLoadedDiagram()); 548 549 // Use the default (non-validating) parser 550 // SAXParserFactory factory = SAXParserFactory.newInstance(); 551 // factory.setValidating(false); 552 // factory.setNamespaceAware(true); 553 594 554 595 try 555 596 { … … 564 605 return new InputSource(new ByteArrayInputStream(new byte[0])); 565 606 } 566 } 567 ); 607 }); 568 608 reader.setContentHandler(handler); 569 609 reader.parse(is); 570 571 // SAXParser saxParser = factory.newSAXParser(); 572 // saxParser.parse(new InputSource(new BufferedReader(is)), handler); 610 611 handler.getLoadedDiagram().updateTime(curTime); 573 612 return xmlBase; 574 } 575 catch (SAXParseException sex) 613 } catch (SAXParseException sex) 576 614 { 577 615 System.err.println("Error processing " + xmlBase); 578 616 System.err.println(sex.getMessage()); 579 617 580 618 loadedDocs.remove(xmlBase); 581 619 return null; 582 } 583 catch (Throwable t)584 {585 t.printStackTrace();586 } 587 620 } catch (Throwable e) 621 { 622 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 623 "Could not load SVG " + xmlBase, e); 624 } 625 588 626 return null; 589 627 } 590 591 public static void main(String argv[])592 {593 try594 {595 URL url = new URL("svgSalamander", "localhost", -1, "abc.svg",596 new URLStreamHandler()597 {598 protected URLConnection openConnection(URL u)599 {600 return null;601 }602 }603 );604 // URL url2 = new URL("svgSalamander", "localhost", -1, "abc.svg");605 606 //Investigate URI resolution607 URI uriA, uriB, uriC, uriD, uriE;608 609 uriA = new URI("svgSalamander", "/names/mySpecialName", null);610 // uriA = new URI("http://www.kitfox.com/salamander");611 // uriA = new URI("svgSalamander://mySpecialName/grape");612 System.err.println(uriA.toString());613 System.err.println(uriA.getScheme());614 615 uriB = uriA.resolve("#begin");616 System.err.println(uriB.toString());617 618 uriC = uriA.resolve("tree#boing");619 System.err.println(uriC.toString());620 621 uriC = uriA.resolve("../tree#boing");622 System.err.println(uriC.toString());623 }624 catch (Exception e)625 {626 e.printStackTrace(); 627 } 628 }629 628 629 // public static void main(String argv[]) 630 // { 631 // try 632 // { 633 // URL url = new URL("svgSalamander", "localhost", -1, "abc.svg", 634 // new URLStreamHandler() 635 // { 636 // protected URLConnection openConnection(URL u) 637 // { 638 // return null; 639 // } 640 // } 641 // ); 642 //// URL url2 = new URL("svgSalamander", "localhost", -1, "abc.svg"); 643 // 644 // //Investigate URI resolution 645 // URI uriA, uriB, uriC, uriD, uriE; 646 // 647 // uriA = new URI("svgSalamander", "/names/mySpecialName", null); 648 //// uriA = new URI("http://www.kitfox.com/salamander"); 649 //// uriA = new URI("svgSalamander://mySpecialName/grape"); 650 // System.err.println(uriA.toString()); 651 // System.err.println(uriA.getScheme()); 652 // 653 // uriB = uriA.resolve("#begin"); 654 // System.err.println(uriB.toString()); 655 // 656 // uriC = uriA.resolve("tree#boing"); 657 // System.err.println(uriC.toString()); 658 // 659 // uriC = uriA.resolve("../tree#boing"); 660 // System.err.println(uriC.toString()); 661 // } 662 // catch (Exception e) 663 // { 664 // Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 665 // "Could not parse", e); 666 // } 667 // } 630 668 public boolean isVerbose() 631 669 { … … 637 675 this.verbose = verbose; 638 676 } 639 677 640 678 /** 641 679 * Uses serialization to duplicate this universe. … … 650 688 ByteArrayInputStream bin = new ByteArrayInputStream(bs.toByteArray()); 651 689 ObjectInputStream is = new ObjectInputStream(bin); 652 SVGUniverse universe = (SVGUniverse) is.readObject();690 SVGUniverse universe = (SVGUniverse) is.readObject(); 653 691 is.close(); 654 692
Note:
See TracChangeset
for help on using the changeset viewer.