org.jgraph.graph.DefaultGraphModel Java Examples
The following examples show how to use
org.jgraph.graph.DefaultGraphModel.
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: GraphView.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private JGraph setupGraph() { // Construct Model and Graph GraphModel model = new DefaultGraphModel(); JGraph graph = new JGraph(model); // Control-drag should clone selection graph.setCloneable(true); // Enable edit without final RETURN keystroke graph.setInvokesStopCellEditing(true); // When over a cell, jump to its default port (we only have one, anyway) graph.setJumpToDefaultPort(true); return graph; }
Example #2
Source File: Overview.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
/** * Refreshes the specified nodes/edges in the overview GUI. If called with no * arguments, all items are refreshed. * * @param cells */ public void refresh(GraphCell... cells) { setBackground(Easik.getInstance().getSettings().getColor("overview_canvas_background")); Object[] toRefresh = (cells.length > 0) ? cells : getRoots(); ((DefaultGraphModel) getModel()).cellsChanged(toRefresh); _appFrame.updateTitle(); if (cells.length == 0) { super.refresh(); } }
Example #3
Source File: EdgeRouter.java From CQL with GNU Affero General Public License v3.0 | 4 votes |
/** * Calculates intermediate points for multiple loops. This is the same algorithm * used by DefaultEdge.LoopRouting, but we scale the loop box for parallel * self-referencing edges. * * @param cache * @param edge * * @return */ @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public List routeLoop(final GraphLayoutCache cache, final EdgeView edge) { final CellView sourceNode = edge.getSource(); final List newPoints = new ArrayList(); newPoints.add(sourceNode); final CellView sourceParent = (sourceNode != null) ? sourceNode.getParentView() : edge.getSourceParentView(); if (sourceNode == null) { throw new RuntimeException("Internal EASIK error, please report"); } final Object[] edges = DefaultGraphModel.getEdgesBetween(cache.getModel(), sourceNode.getCell(), sourceNode.getCell(), true); int position = 0; if (edges != null) { for (int i = 0; i < edges.length; i++) { if (edges[i] == edge.getCell()) { position = i; break; } } } if (sourceParent != null) { final Point2D from = AbstractCellView.getCenterPoint(sourceParent); final Rectangle2D rect = sourceParent.getBounds(); final double posWidthFactor = 1.25 + 0.75 * position; final double posHeightFactor = 1.5 + position; final double width = rect.getWidth(); final double height2 = rect.getHeight() / 2; double loopWidth = Math.min(20, Math.max(10, width / 8)); double loopHeight = Math.min(30, Math.max(12, Math.max(loopWidth + 4, height2 / 2))); loopWidth *= posWidthFactor; loopHeight *= posHeightFactor; newPoints.add(edge.getAttributes().createPoint(from.getX() - loopWidth, from.getY() - height2 - loopHeight * 1.0)); final double midpointY = from.getY() - height2 - 1.5 * loopHeight; newPoints.add(edge.getAttributes().createPoint(from.getX(), midpointY)); newPoints.add(edge.getAttributes().createPoint(from.getX() + loopWidth, from.getY() - height2 - loopHeight * 1.0)); newPoints.add(edge.getTarget()); return newPoints; } return null; }