Esempio n. 1
0
  private void loadURL(URL url) {
    boolean verbose = cmCheck_verbose.isSelected();

    universe = new SVGUniverse();
    universe.setVerbose(verbose);
    SVGDiagram diagram = null;

    if (!CheckBoxMenuItem_anonInputStream.isSelected()) {
      // Load from a disk with a valid URL
      URI uri = universe.loadSVG(url);

      if (verbose) System.err.println(uri.toString());

      diagram = universe.getDiagram(uri);
    } else {
      // Load from a stream with no particular valid URL
      try {
        InputStream is = url.openStream();
        URI uri = universe.loadSVG(is, "defaultName");

        if (verbose) System.err.println(uri.toString());

        diagram = universe.getDiagram(uri);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    svgDisplayPanel.setDiagram(diagram);
    repaint();
  }
Esempio n. 2
0
  private void loadURL(URL url) {
    boolean verbose = cmCheck_verbose.isSelected();

    //                SVGUniverse universe = new SVGUniverse();
    SVGUniverse universe = SVGCache.getSVGUniverse();
    SVGDiagram diagram = null;
    URI uri;

    if (!CheckBoxMenuItem_anonInputStream.isSelected()) {
      // Load from a disk with a valid URL
      uri = universe.loadSVG(url);

      if (verbose) System.err.println("Loading document " + uri.toString());

      diagram = universe.getDiagram(uri);
    } else {
      // Load from a stream with no particular valid URL
      try {
        InputStream is = url.openStream();
        uri = universe.loadSVG(is, "defaultName");

        if (verbose) System.err.println("Loading document " + uri.toString());
      } catch (Exception e) {
        e.printStackTrace();
        return;
      }
    }
    /*
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    ObjectOutputStream os = new ObjectOutputStream(bs);
    os.writeObject(universe);
    os.close();

    ByteArrayInputStream bin = new ByteArrayInputStream(bs.toByteArray());
    ObjectInputStream is = new ObjectInputStream(bin);
    universe = (SVGUniverse)is.readObject();
    is.close();
    */

    diagram = universe.getDiagram(uri);

    svgDisplayPanel.setDiagram(diagram);
    repaint();
  }