org.jgraph.graph.DefaultEdge Java Examples
The following examples show how to use
org.jgraph.graph.DefaultEdge.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractRMLProcessor.java From GeoTriples with Apache License 2.0 | 6 votes |
private static void manage(DefaultEdge incomingedge, TriplesMap from, DefaultDirectedGraph<TriplesMap, DefaultEdge> xx) { TriplesMap incomingFromVertex = xx.getEdgeSource(incomingedge); TriplesMap incomingTargetVertex = xx.getEdgeTarget(incomingedge); if (sorted(incomingFromVertex, from)) { // put it here xx.removeEdge(incomingedge); xx.addEdge(incomingFromVertex, from); xx.addEdge(from, incomingTargetVertex); } else { Set<DefaultEdge> incoming = xx.incomingEdgesOf(incomingFromVertex); DefaultEdge incedge = null; for (DefaultEdge e : incoming) { incedge = e; break; } if (incedge == null) { xx.addEdge(from, incomingFromVertex); } else { manage(incedge, from, xx); } } // Set<DefaultEdge> incoming = xx.incomingEdgesOf(xx // .getEdgeSource(incomingedge)); // it should be only one incoming }
Example #2
Source File: AbstractRMLProcessor.java From GeoTriples with Apache License 2.0 | 6 votes |
private static boolean addCondition(TriplesMap from, TriplesMap target, DefaultDirectedGraph<TriplesMap, DefaultEdge> xx) { if (xx.containsEdge(from, target)) { return false; } xx.addVertex(from); xx.addVertex(target); Set<DefaultEdge> incoming = xx.incomingEdgesOf(target); DefaultEdge incedge = null; for (DefaultEdge e : incoming) { incedge = e; break; } if (incedge == null) { xx.addEdge(from, target); } else { manage(incedge, from, xx); } return true; }
Example #3
Source File: GraphVisitor.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override protected Object unhandled_node(SimpleNode node) throws Exception { DefaultGraphCell cell = null; String caption = node.toString(); parentAddPort(); cell = createVertex(caption, indent, depth, nodeColor, false); DefaultEdge edge = createConnection(cell); cells.add(cell); cells.add(edge); incrementPosition(cell); return null; }
Example #4
Source File: MicroarrayGraph.java From chipster with MIT License | 6 votes |
public void removeLink(DataBean source, DataBean target, Link type) { GraphVertex sourceVertex = vertexMap.get(source); GraphVertex targetVertex = vertexMap.get(target); if (type.equals(Link.GROUPING)) { sourceVertex.getGroup().removeChildVertex(sourceVertex); } else { for (DefaultEdge edge : getAllEdgesOfVertex(sourceVertex, this)) { // Get link type, source vertex and target vertex Link edgeType = (Link) edge.getUserObject(); GraphVertex edgeSource = (GraphVertex) ((DefaultPort) edge.getSource()).getParent(); GraphVertex edgeTarget = (GraphVertex) ((DefaultPort) edge.getTarget()).getParent(); logger.debug("Edge type: " + edgeType + ", edgeSource: " + edgeSource + ", edgeTarget: " + edgeTarget); if (edgeSource.equals(sourceVertex) && edgeTarget.equals(targetVertex) && edgeType.equals(type)) { // Remove the edge if target, source and link type matched graphLayoutCache.remove(new Object[] { edge }); } } } }
Example #5
Source File: GraphVisitor.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private DefaultEdge createConnection(DefaultGraphCell cell) { DefaultEdge edge = new DefaultEdge(); edge.setSource(stack.peek().getChildAt(0)); edge.setTarget(cell); // Set Arrow Style for edge int arrow = GraphConstants.ARROW_TECHNICAL; GraphConstants.setLineEnd(edge.getAttributes(), arrow); GraphConstants.setEndFill(edge.getAttributes(), true); return edge; }
Example #6
Source File: MicroarrayGraph.java From chipster with MIT License | 5 votes |
private static void setModificationEdgeStyle(DefaultEdge edge) { setEdgeStyle(edge); GraphConstants.setLineBegin(edge.getAttributes(), GraphConstants.ARROW_TECHNICAL); GraphConstants.setBeginFill(edge.getAttributes(), true); GraphConstants.setBeginSize(edge.getAttributes(), 5); GraphConstants.setForeground(edge.getAttributes(), Color.LIGHT_GRAY); GraphConstants.setDashPattern(edge.getAttributes(), new float[] { 1f, 2f }); }
Example #7
Source File: MicroarrayGraph.java From chipster with MIT License | 5 votes |
private static void setDerivationEdgeStyle(DefaultEdge edge) { setEdgeStyle(edge); GraphConstants.setLineBegin(edge.getAttributes(), GraphConstants.ARROW_TECHNICAL); GraphConstants.setBeginFill(edge.getAttributes(), true); GraphConstants.setBeginSize(edge.getAttributes(), 5); GraphConstants.setLineWidth(edge.getAttributes(), 1); }
Example #8
Source File: MicroarrayGraph.java From chipster with MIT License | 4 votes |
/** * Removes the given dataset from this graph. * * @param data * Dataset to be removed. * @return True if remove succeeded, false if it failed (that is, corresponding vertex was not found in the graph). */ public void removeData(DataBean data) { // fetch vertex GraphVertex vertex = vertexMap.get(data); if (vertex == null) { throw new IllegalArgumentException(data.getName() + " was not present in graph"); } // mark vertex to be removed Vector<Object> removedCells = new Vector<Object>(); removedCells.add(vertex); // process children and their nested objects to be removed (edges and ports) List children = vertex.getChildren(); for (Object child : children) { if (child instanceof DefaultPort) { DefaultPort port = (DefaultPort) child; Set edges = port.getEdges(); for (Object edgeObject : edges) { if (edgeObject instanceof DefaultEdge) { DefaultEdge edge = (DefaultEdge) edgeObject; Object source = edge.getSource(); if (source instanceof DefaultPort) { DefaultPort sourcePort = (DefaultPort) source; removedCells.add(sourcePort); } removedCells.add(edge); } } removedCells.add(port); } } // removes the group vertex if there is no group members left in the group if (vertex.getGroup() != null) { GroupVertex group = vertex.getGroup(); // if there are no other vertexes in the group remove it if ((group.getChildCount() - 2) < 1) { removedCells.add(group); } } // remove from graph and graph model this.getGraphLayoutCache().remove(removedCells.toArray()); // removed from visible graph (?) this.model.remove(removedCells.toArray()); // removes from graph model // remove from vertex map vertexMap.remove(data); // remove from other structures for (Object o : removedCells) { if (groups.contains(o)) { // Data is a group groups.remove(o); // remove from groups list } else if (o instanceof AbstractGraphVertex) { // Data is not a root and not a group => remove the data from parent's list of children Object parent = ((AbstractGraphVertex) o).getParent(); if (parent != null) { if (parent instanceof GraphVertex) { ((GraphVertex) parent).removeChildVertex((GraphVertex) o); } else { // GroupVertex does not store information about it's // children. This information is stored only by JGraph // and it is removed when cell is removed from // graphLayoutCache. So we do nothing } } } } graphPanel.autoZoom(); this.repaint(); }
Example #9
Source File: MicroarrayGraph.java From chipster with MIT License | 4 votes |
private static void setEdgeStyle(DefaultEdge edge) { GraphConstants.setSelectable(edge.getAttributes(), false); }
Example #10
Source File: MicroarrayGraph.java From chipster with MIT License | 4 votes |
private static void setAnnotationEdgeStyle(DefaultEdge edge) { setEdgeStyle(edge); GraphConstants.setForeground(edge.getAttributes(), Color.LIGHT_GRAY); GraphConstants.setDashPattern(edge.getAttributes(), new float[] { 2f, 2f }); }
Example #11
Source File: MicroarrayGraph.java From chipster with MIT License | 4 votes |
private void insertLink(GraphVertex sourceVertex, GraphVertex targetVertex, Link type, DataBean sourceDataBean) { if (type.equals(DataBean.Link.GROUPING)) { if (sourceVertex.getGroup() != null && targetVertex.getGroup() != null) { // both are grouped if (sourceVertex.getGroup() == targetVertex.getGroup()) { // already in the same group, ignore return; } else { throw new IllegalArgumentException("beans already have different groups"); } } if (sourceVertex.getGroup() == null && targetVertex.getGroup() == null) { createGroup(sourceVertex.getData()); // create group for the source and add target next } // other is grouped, other not => group the ungrouped one if (sourceVertex.getGroup() != null) { sourceVertex.getGroup().addChildVertex(targetVertex); } else { targetVertex.getGroup().addChildVertex(sourceVertex); } } else if (type.equals(DataBean.Link.ANNOTATION) || type.equals(DataBean.Link.DERIVATION) || type.equals(DataBean.Link.MODIFICATION)) { DefaultEdge linkEdge = new NoLabelEdge(type); linkEdge.setSource(sourceVertex.getChildAt(0)); linkEdge.setTarget(targetVertex.getChildAt(0)); switch (type) { case ANNOTATION: setAnnotationEdgeStyle(linkEdge); break; case DERIVATION: setDerivationEdgeStyle(linkEdge); break; case MODIFICATION: setModificationEdgeStyle(linkEdge); break; } this.getGraphLayoutCache().insert(linkEdge); if (type.equals(DataBean.Link.DERIVATION) || type.equals(DataBean.Link.MODIFICATION)) { layoutManager.updateLayout(sourceVertex, sourceDataBean); // update position if this was made child of other bean graphPanel.autoZoom(); scrollCellToVisibleAnimated(sourceVertex); repaint(); } else if (type.equals(DataBean.Link.ANNOTATION)) { moveCloseToAnnotated(sourceVertex.getData()); } } else { throw new IllegalArgumentException("unsupported link type: " + type); } }