예제 #1
0
    @Override
    public void save(String file, XcosDiagram from) throws Exception {
      final XcosCodec codec = new XcosCodec();
      final TransformerFactory tranFactory = ScilabTransformerFactory.newInstance();
      final Transformer aTransformer = tranFactory.newTransformer();

      LOG.entering("XcosCodec", "encode");
      final Node doc = codec.encode(from);
      LOG.exiting("XcosCodec", "encode");

      final DOMSource src = new DOMSource(doc);
      final StreamResult result = new StreamResult(file);

      LOG.entering("Transformer", "transform");
      aTransformer.transform(src, result);
      LOG.exiting("Transformer", "transform");
    }
예제 #2
0
    @Override
    public void save(String file, XcosDiagram from) throws Exception {
      LOG.entering("XcosFileType.ZCOS", "save");

      XcosPackage p = new XcosPackage(new File(file));
      p.setContent(from);
      p.store();

      LOG.exiting("XcosFileType.ZCOS", "save");
    }
예제 #3
0
    @Override
    public void load(String file, XcosDiagram into)
        throws TransformerException, IOException, SAXException, ParserConfigurationException {
      LOG.entering("XcosFileType.ZCOS", "load");

      XcosPackage p = new XcosPackage(new File(file));
      p.setContent(into);
      p.load();

      LOG.exiting("XcosFileType.ZCOS", "load");
    }
예제 #4
0
    @Override
    public void load(String file, XcosDiagram into) throws TransformerException {
      final XcosCodec codec = new XcosCodec();
      final TransformerFactory tranFactory = ScilabTransformerFactory.newInstance();
      final Transformer aTransformer = tranFactory.newTransformer();

      StreamSource src;
      try {
        src = new StreamSource(new File(file).toURI().toURL().toString());
        final DOMResult result = new DOMResult(codec.getDocument());

        LOG.entering("Transformer", "transform");
        aTransformer.transform(src, result);
        LOG.exiting("Transformer", "transform");

        LOG.entering("XcosCodec", "decode");
        codec.setElementIdAttributes();
        codec.decode(result.getNode().getFirstChild(), into);
        LOG.exiting("XcosCodec", "decode");
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }
    }