/** * Returns the label position of the specified view in the given graph. */ public Point2D getExtraLabelPosition(EdgeView view, int index) { setView(view); Point2D[] pts = GraphConstants.getExtraLabelPositions(view .getAllAttributes()); if (pts != null && index < pts.length) return getLabelPosition(pts[index]); return null; }
/** * Subclassers can override this to decide whether or not "port magic" * should appear on a given edge. (Port magic means the port tries to make * the edge horizontal or vertical if the closest control point lies within * the bounds of the parent vertex.) */ protected boolean shouldInvokePortMagic(EdgeView edge) { return allowPortMagic && !(getParentView() instanceof EdgeView) && edge.getPointCount() > 2 && GraphConstants.getLineStyle(edge.getAllAttributes()) == GraphConstants.STYLE_ORTHOGONAL; }
private DefaultGraphCell getExtreme(org.jgraph.graph.Edge edge){ if (!(((DefaultGraphCell)((DefaultPort)edge.getTarget()).getParent()).getUserObject() instanceof ingenias.editor.entities.NAryEdgeEntity)) return (DefaultGraphCell)((DefaultPort)edge.getSource()).getParent(); else return (DefaultGraphCell)((DefaultPort)edge.getTarget()).getParent(); }
/** * Overrides the parent method to udpate the cached points. */ public void update(GraphLayoutCache cache) { super.update(cache); bounds = GraphConstants.getBounds(allAttributes); if (bounds == null) { bounds = allAttributes.createRect(defaultBounds); GraphConstants.setBounds(allAttributes, bounds); } groupBounds = null; }
/** * Inserts the specified connection into the model. */ protected void handleConnection(ConnectionSet.Connection c, boolean establish) { Object edge = c.getEdge(); Object port = (establish) ? c.getPort() : (c.isSource()) ? getSource(edge) : getTarget(edge); connect(edge, port, c.isSource(), establish); }
/** * Changes the <code>attributes</code> of the cell. * * @deprecated Use getAttributes().applyMap */ public Map changeAttributes(Map change) { return getAttributes().applyMap(change); }
/** * Helper methods that connects the source of <code>edge</code> to * <code>port</code> in <code>model</model>. */ public static void setTargetPort(GraphModel model, Object edge, Object port) { model.edit(null, new ConnectionSet(edge, port, false), null, null); }
public void refresh(CellView view, boolean create) { if (view != null) { view.refresh(this, this, create); CellView[] children = view.getChildViews(); for (int i = 0; i < children.length; i++) refresh(children[i], create); } }
private static DefaultGraphCell[] getEdgeExtremes(DefaultEdge edge, GraphModel m) { DefaultEdge de = edge; DefaultGraphCell target = (DefaultGraphCell) ( (DefaultPort) m.getTarget(de)). getParent(); DefaultGraphCell source = (DefaultGraphCell) ( (DefaultPort) m.getSource(de)). getParent(); return new DefaultGraphCell[]{target,source}; }
public RoleEntity(String id) { super(id); attributes=new org.jgraph.graph.AttributeMap(); GraphConstants.setDisconnectable(attributes,false); }
public void update(CellView view) { if (view != null) { view.update(this); CellView[] children = view.getChildViews(); for (int i = 0; i < children.length; i++) update(children[i]); } }
/** * Hook for subclassers to avoid cloning the cell's attributes. Return * model.getAttributes(cell) to avoid cloning. */ protected AttributeMap getCellAttributes(GraphModel model) { return (AttributeMap) model.getAttributes(cell).clone(); }
/** * Returns true if the edge is a loop. */ public boolean isLoop() { return (getSource() != null && getSource() == getTarget()) || (sourceParentView != null && sourceParentView == targetParentView) || (sourceParentView != null && getTarget() != null && getTarget() .getParentView() == sourceParentView) || (targetParentView != null && getSource() != null && getSource() .getParentView() == targetParentView); }
protected CellView getVisibleParent(GraphModel model, CellMapper mapper, Object port) { CellView view = null; do { view = mapper.getMapping(port, false); port = model.getParent(port); } while (view == null && port != null); return view; }
/** * Brings <code>cells</code> to front. */ public void toFront(Object[] cells) { GraphModelLayerEdit edit = createLayerEdit(cells, GraphModelLayerEdit.FRONT); if (edit != null) { edit.execute(); postEdit(edit); } }
/** * Returns the label position of the specified view in the given graph. */ public Point2D getLabelPosition(EdgeView view) { setView(view); return getLabelPosition(view.getLabelPosition()); }
/** * Returns the absolute position of the main label * @return the absolute position of the main label */ protected Point2D getAbsoluteLabelPosition() { Point2D result = getAbsoluteLabelPositionFromRelative(GraphConstants.getLabelPosition(getAllAttributes())); return result; }
/** * A shortcut method to create a connection set that represents the * connections in this model. Useful for encoding to avoid writing redundant * connection data stored in the cells. */ public ConnectionSet getConnectionSet() { return ConnectionSet .create(this, DefaultGraphModel.getAll(this), false); }
/** * Returns the shape of the view according to the last rendering state */ public Shape getShape() { if (sharedPath != null) return sharedPath; else { return sharedPath = (GeneralPath) getEdgeRenderer().createShape(); } }
public int getPreferredLineStyle(EdgeView edge) { if (edge.isLoop()) { return getLoopStyle(); } return getEdgeStyle(); }