org.jgraph.graph.DefaultPort Java Examples
The following examples show how to use
org.jgraph.graph.DefaultPort.
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: RelationTool.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 6 votes |
@Override public void mouseReleased(MouseEvent e) { if (e != null && port != null && firstPort != null) { connect((Port) firstPort.getCell(), (Port) port.getCell()); e.consume(); } else { if (firstPort != null) { DefaultPort thePort = (DefaultPort) firstPort.getCell(); GraphCell theCell = (GraphCell) thePort.getParent(); if (theCell instanceof TableCell) { DefaultPopupMenu menu = createPopupMenu(graph.fromScreen(new Point2D.Double(e.getX(), e.getY())), (TableCell) theCell); menu.show(graph, e.getX(), e.getY()); } } } firstPort = null; port = null; start = null; current = null; super.mouseReleased(e); graph.repaint(); }
Example #2
Source File: RelationTool.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 6 votes |
public void connect(Port aSource, Port aTarget) { // Construct Edge with no label GraphCell theSourceCell = (GraphCell) ((DefaultPort) aSource).getParent(); GraphCell theTargetCell = (GraphCell) ((DefaultPort) aTarget).getParent(); if ((theSourceCell instanceof TableCell) && (theTargetCell instanceof TableCell)) { Table theTargetTable = (Table) ((TableCell) theTargetCell).getUserObject(); if (theTargetTable.hasPrimaryKey()) { graph.commandNewRelation((TableCell) theSourceCell, (TableCell) theTargetCell); graph.repaint(); } else { MessagesHelper.displayErrorMessage(graph, getResourceHelper().getText( ERDesignerBundle.EXPORTINGTABLENEEDSPRIMARYKEY)); } } }
Example #3
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 #4
Source File: CellViewFactory.java From MogwaiERDesignerNG with GNU General Public License v3.0 | 5 votes |
@Override protected PortView createPortView(Object cell) { if (cell instanceof DefaultPort) { return new DefaultPortView(cell); } return super.createPortView(cell); }
Example #5
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 #6
Source File: ViewDefinitionEdge.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the source port of this edge. * * @see DefaultEdge.getSource() * * @return */ @Override public DefaultPort getSource() { return _sourceObj.getPort(); }
Example #7
Source File: ViewDefinitionEdge.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the target port of this edge. * * @see DefaultEdge.getSource() * * @return */ @Override public DefaultPort getTarget() { return _targetObj.getPort(); }
Example #8
Source File: OverviewVertex.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * * * @return */ public DefaultPort getPort() { return _port; }
Example #9
Source File: View_Edge.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the source port of this edge. * * @see DefaultEdge#getSource() * * @return */ @Override public DefaultPort getSource() { return _sourceObj.getPort(); }
Example #10
Source File: View_Edge.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the target port of this edge. * * @see DefaultEdge#getSource() * * @return */ @Override public DefaultPort getTarget() { return _targetObj.getPort(); }
Example #11
Source File: SketchEdge.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the source port of this edge. * * @see DefaultEdge#getSource() * * @return */ @Override public DefaultPort getSource() { return _sourceObj.getPort(); }
Example #12
Source File: SketchEdge.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the target port of this edge. * * @see DefaultEdge#getSource() * * @return */ @Override public DefaultPort getTarget() { return _targetObj.getPort(); }
Example #13
Source File: ModelVertex.java From CQL with GNU Affero General Public License v3.0 | 2 votes |
/** * Returns the DefaultPort object that edges pointing to this vertex should be * attached to. * * @return */ public DefaultPort getPort() { return _port; }