Example #1
19
  /**
   * Looks up a href within our universe. If the href refers to a document that is not loaded, it
   * will be loaded. The URL #target will then be checked against the SVG diagram's index and the
   * coresponding element returned. If there is no coresponding index, null is returned.
   */
  public SVGElement getElement(URI path, boolean loadIfAbsent) {
    try {
      // Strip fragment from URI
      URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null);

      SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase);
      if (dia == null && loadIfAbsent) {
        // System.err.println("SVGUnivserse: " + xmlBase.toString());
        // javax.swing.JOptionPane.showMessageDialog(null, xmlBase.toString());
        URL url = xmlBase.toURL();

        loadSVG(url, false);
        dia = (SVGDiagram) loadedDocs.get(xmlBase);
        if (dia == null) {
          return null;
        }
      }

      String fragment = path.getFragment();
      return fragment == null ? dia.getRoot() : dia.getElement(fragment);
    } catch (Exception e) {
      Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse path " + path, e);
      return null;
    }
  }
Example #2
0
 /**
  * Updates all time influenced style and presentation attributes in all SVG documents in this
  * universe.
  */
 public void updateTime() throws SVGException {
   for (Iterator it = loadedDocs.values().iterator(); it.hasNext(); ) {
     SVGDiagram dia = (SVGDiagram) it.next();
     dia.updateTime(curTime);
   }
 }