final GraphNode node = (GraphNode) event.getData(); final GraphExecuter.events eventType = event.getEventType(); switch(eventType) { case ADD_EVENT:
@Override protected Graph doInBackground() throws Exception { final Graph graphFromFile = GPFProcessor.readGraph(new InputStreamReader(fileStream), null); setGraph(graphFromFile, addUI); notifyGraphEvent(new GraphEvent(events.REFRESH_EVENT, null)); return graphFromFile; } }
public void setGraph(final Graph graphFromFile, final boolean addUI) throws GraphException { if (graphFromFile != null) { graph = graphFromFile; graphNodeList.clear(); final XppDom presentationXML = graph.getApplicationData("Presentation"); if (presentationXML != null) { // get graph description final XppDom descXML = presentationXML.getChild("Description"); if (descXML != null && descXML.getValue() != null) { graphDescription = descXML.getValue(); } } final Node[] nodes = graph.getNodes(); for (Node n : nodes) { final GraphNode newGraphNode = new GraphNode(n); if (presentationXML != null) newGraphNode.setDisplayParameters(presentationXML); graphNodeList.add(newGraphNode); if (addUI) { OperatorUI ui = OperatorUIRegistry.CreateOperatorUI(newGraphNode.getOperatorName()); if (ui == null) { throw new GraphException("Unable to load " + newGraphNode.getOperatorName()); } newGraphNode.setOperatorUI(ui); } notifyGraphEvent(new GraphEvent(events.ADD_EVENT, newGraphNode)); } } }
/** * Implements the functionality of Observer participant of Observer Design Pattern to define a one-to-many * dependency between a Subject object and any number of Observer objects so that when the * Subject object changes state, all its Observer objects are notified and updated automatically. * <p> * Defines an updating interface for objects that should be notified of changes in a subject. * * @param subject The Observerable subject * @param data optional data */ public void update(java.util.Observable subject, Object data) { GraphExecuter.GraphEvent event = (GraphExecuter.GraphEvent) data; GraphNode node = (GraphNode) event.getData(); String opID = node.getNode().getId(); if (event.getEventType() == GraphExecuter.events.ADD_EVENT) { updateValue = "Add"; } else if (event.getEventType() == GraphExecuter.events.REMOVE_EVENT) { updateValue = "Remove"; } else if (event.getEventType() == GraphExecuter.events.SELECT_EVENT) { updateValue = "Selected"; } } }
public void setSelectedNode(GraphNode node) { if (node == null) return; notifyGraphEvent(new GraphEvent(events.SELECT_EVENT, node)); }
public void notifyConnection() { if(graphNodeList.getGraphNodes().length > 0) { notifyGraphEvent(new GraphEvent(events.CONNECT_EVENT, graphNodeList.getGraphNodes()[0])); } }
public void removeOperator(final GraphNode node) { notifyGraphEvent(new GraphEvent(events.REMOVE_EVENT, node)); removeNode(node); }
public GraphNode addOperator(final String opName) { String id = opName; int cnt = 1; while (graphNodeList.findGraphNode(id) != null) { ++cnt; id = opName + '(' + cnt + ')'; } final GraphNode newGraphNode = createNewGraphNode(graph, opName, id); notifyGraphEvent(new GraphEvent(events.ADD_EVENT, newGraphNode)); return newGraphNode; }