Package com.mxgraph.io

Examples of com.mxgraph.io.mxCodec


      setGridVisible(true);
      setToolTips(true);
      getConnectionHandler().setCreateTarget(true);

      // Loads the defalt stylesheet from an external file
      mxCodec codec = new mxCodec();
      Document doc = mxUtils.loadDocument(GraphEditor.class.getResource(
          "/com/mxgraph/examples/swing/resources/default-style.xml")
          .toString());
      codec.decode(doc.getDocumentElement(), graph.getStylesheet());

      // Sets the background to white
      getViewport().setOpaque(true);
      getViewport().setBackground(Color.WHITE);
    }
View Full Code Here


      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        mxGraph graph = graphComponent.getGraph();
        mxCodec codec = new mxCodec();
        Document doc = mxUtils.loadDocument(EditorActions.class
            .getResource(stylesheet).toString());

        if (doc != null)
        {
          codec.decode(doc.getDocumentElement(),
              graph.getStylesheet());
          graph.refresh();
        }
      }
    }
View Full Code Here

      BufferedImage image = mxCellRenderer.createBufferedImage(graph,
          null, 1, bg, graphComponent.isAntiAlias(), null,
          graphComponent.getCanvas());

      // Creates the URL-encoded XML data
      mxCodec codec = new mxCodec();
      String xml = URLEncoder.encode(
          mxUtils.getXml(codec.encode(graph.getModel())), "UTF-8");
      mxPngEncodeParam param = mxPngEncodeParam
          .getDefaultEncodeParam(image);
      param.setCompressedText(new String[] { "mxGraphModel", xml });

      // Saves as a PNG file
View Full Code Here

                .getDocumentElement()), filename);
          }
          else if (ext.equalsIgnoreCase("mxe")
              || ext.equalsIgnoreCase("xml"))
          {
            mxCodec codec = new mxCodec();
            String xml = mxUtils.getXml(codec.encode(graph
                .getModel()));

            mxUtils.writeFile(xml, filename);

            editor.setModified(false);
View Full Code Here

        if (value != null)
        {
          Document document = mxUtils.parseXml(URLDecoder.decode(
              value, "UTF-8"));
          mxCodec codec = new mxCodec(document);
          codec.decode(document.getDocumentElement(), editor
              .getGraphComponent().getGraph().getModel());
          editor.setCurrentFile(file);
          resetEditor(editor);

          return;
View Full Code Here

                    openVdx(editor, fc.getSelectedFile(),
                        document);
                  }
                  else
                  {
                    mxCodec codec = new mxCodec(document);
                    codec.decode(
                        document.getDocumentElement(),
                        graph.getModel());
                    editor.setCurrentFile(fc
                        .getSelectedFile());
                  }
View Full Code Here

      setGridVisible(true);
      setToolTips(true);
      getConnectionHandler().setCreateTarget(true);

      // Loads the defalt stylesheet from an external file
      mxCodec codec = new mxCodec();
      Document doc = mxUtils.loadDocument(GraphEditor.class.getResource(
          "/com/mxgraph/examples/swing/resources/default-style.xml")
          .toString());
      codec.decode(doc.getDocumentElement(), graph.getStylesheet());

      // Sets the background to white
      getViewport().setOpaque(true);
      getViewport().setBackground(Color.WHITE);
    }
View Full Code Here

                .getDocumentElement()), filename);
          }
          else if (ext.equalsIgnoreCase("mxe")
              || ext.equalsIgnoreCase("xml"))
          {
            mxCodec codec = new mxCodec();
            String xml = mxXmlUtils.getXml(codec.encode(graph
                .getModel()));

            mxUtils.writeFile(xml, filename);

            editor.setModified(false);
View Full Code Here

      {
        // Handles the special case were no ids should be
        // resolved in the existing model. This change will
        // replace all registered ids and cells from the
        // model and insert a new cell hierarchy instead.
        mxCodec tmp = new mxCodec(node.getOwnerDocument());
        change = tmp.decode(node);
      }
      else
      {
        change = codec.decode(node);
      }
View Full Code Here

      if (e.getSource() instanceof mxGraphComponent)
      {
        mxGraphComponent graphComponent = (mxGraphComponent) e
            .getSource();
        mxGraph graph = graphComponent.getGraph();
        mxCodec codec = new mxCodec();
        Document doc = mxUtils.loadDocument(EditorActions.class
            .getResource(stylesheet).toString());

        if (doc != null)
        {
          codec.decode(doc.getDocumentElement(),
              graph.getStylesheet());
          graph.refresh();
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.mxgraph.io.mxCodec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.