
org.yaoqiang.graph.io.graphml.GraphMLCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yaoqiang-bpmn-editor Show documentation
Show all versions of yaoqiang-bpmn-editor Show documentation
an Open Source BPMN 2.0 Modeler
package org.yaoqiang.graph.io.graphml;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.yaoqiang.graph.swing.GraphComponent;
import org.yaoqiang.graph.view.Graph;
/**
* GraphMLCodec
*
* @author Shi Yaoqiang([email protected])
*/
public class GraphMLCodec {
protected GraphComponent graphComponent;
protected Graph graph;
protected Document document;
public GraphMLCodec(GraphComponent graphComponent, Document document) {
this.graphComponent = graphComponent;
this.graph = graphComponent.getGraph();
this.document = document;
}
public void decode() {
graph.clearBpmnModel();
graph.getModel().clear();
graphComponent.zoomTo(0.85, true);
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
NodeList graphs = document.getElementsByTagName(GraphMLConstants.GRAPH);
if (graphs.getLength() > 0) {
Element graphElement = (Element) graphs.item(0);
GraphMLGraph gmlGraph = new GraphMLGraph(graphElement);
gmlGraph.addGraph(graph, parent);
}
graph.getModel().endUpdate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy