/** * For backwards compatibility. */ public Point2D getLocation(EdgeView edge) { return getLocation(edge, null); }
/** * Constructs a PortView view for the specified object. * * @deprecated replaced by {@link #createPortView(Object)}since * JGraph no longer exposes dependecies on GraphCell subclasses * (Port, Edge) */ protected PortView createPortView(Port cell) { return new PortView(cell); } }
/** * Convenience method to return the port at the specified location. */ public Object getPortForLocation(double x, double y) { PortView view = getPortViewAt(x, y, tolerance); if (view != null) return view.getCell(); return null; }
/** * Returns the bounds for the port view. */ public Rectangle2D getBounds() { Point2D loc = getLocation(); double x = 0; double y = 0; if (loc != null) { x = loc.getX(); y = loc.getY(); } Rectangle2D bounds = new Rectangle2D.Double(x, y, 0, 0); bounds.setFrame(bounds.getX() - getPortSize() / 2, bounds.getY() - getPortSize() / 2, getPortSize(), getPortSize()); return bounds; }
CellView vertex = getParentView(); Point2D pos = null; if (vertex != null) { pos = getCenterPoint(vertex); y = y * (r.getHeight() - 1) / GraphConstants.PERMILLE; pos = (anchor != null) ? anchor.getLocation(edge, nearest) : new Point2D.Double(r.getX(), r.getY()); pos = new Point2D.Double(pos.getX() + x, pos.getY() + y); return getCenterPoint(vertex); if (shouldInvokePortMagic(edge)) { if (nearest != null) { Rectangle2D r = vertex.getBounds();
/** * Description of the Method * *@param g Description of Parameter */ protected void paintPort(Graphics g) { // If Current Port is Valid if (port != null) { // If Not Floating Port... boolean o = (GraphConstants.getOffset(port.getAttributes()) != null); // ...Then use Parent's Bounds Rectangle r = (o) ? port.getBounds().getBounds() : port.getParentView().getBounds().getBounds(); // Scale from Model to Screen r = getGraph().toScreen(new Rectangle(r)).getBounds(); // Add Space For the Highlight Border r.setBounds(r.x - 3, r.y - 3, r.width + 6, r.height + 6); // Paint Port in Preview (=Highlight) Mode //getGraph().getUI().paintCell(g, port, r, true); } }
/** * 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; }
/** * Paint the renderer. Overrides superclass paint to add specific painting. * Note: The preview flag is interpreted as "highlight" in this context. * (This is used to highlight the port if the mouse is over it.) */ public void paint(Graphics g) { Dimension d = getSize(); if (xorEnabled) { g.setColor(graphBackground); g.setXORMode(graphBackground); } super.paint(g); if (preview) { g.fill3DRect(0, 0, d.width, d.height, true); } else { g.fillRect(0, 0, d.width, d.height); } boolean offset = (GraphConstants.getOffset(view.getAllAttributes()) != null); g.setColor(getForeground()); if (!offset) g.fillRect(1, 1, d.width - 2, d.height - 2); else if (!preview) g.drawRect(1, 1, d.width - 3, d.height - 3); }
/** * Shortcut method to getLocation(null, null) */ public Point2D getLocation() { return getLocation(null, null); }
/** * Constructs a PortView view for the specified object. */ protected PortView createPortView(Object cell) { if (cell instanceof Port) return createPortView((Port) cell); else return new PortView(cell); }
public void run(){ String className=graph.getClass().getName(); String diagramType=className.substring(className.lastIndexOf(".")+1, className.indexOf("ModelJGraph")); // Then Establish Connection RelationshipManager.connect((Port) firstPortBackup.getCell(), (Port) portBackup.getCell(), graph, ids.getDiagramFilter().getCurrentAllowedRelationships().get(diagramType)); } };
/** * Returns a list where all instances of PortView are replaced by their * correspnding Point instance. */ public List clonePoints(Object[] points, boolean convertPortViews) { // TODO: Change the list in-place? ArrayList newList = new ArrayList(points.length); for (int i = 0; i < points.length; i++) { // Clone Point Object point = points[i]; if (point instanceof PortView && convertPortViews) point = createPoint(((PortView) point).getLocation()); else if (point instanceof Point2D) point = createPoint((Point2D) point); newList.add(point); } return newList; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
public Point2D getPoint(int index) { Object obj = points.get(index); if (obj instanceof PortView) { return ((PortView) obj).getLocation(this, getPointLocation((index == 0) ? 1 : points .size() - 2)); } else if (obj instanceof VirtualNode) { return ((VirtualNode) obj).getPosition(); } else if (obj instanceof CellView) { System.err.println("CellView!"); Rectangle2D r = ((CellView) obj).getBounds(); return getAttributes().createPoint(r.getX(), r.getY()); } else if (obj instanceof Point2D) // Regular Point return (Point2D) obj; return null; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
/** * Returns the cached points for this edge. */ public Point2D getPoint(int index) { Object obj = points.get(index); if (index == 0 && sourceParentView != null) { return sourceParentView.getPerimeterPoint(this, getCenterPoint(sourceParentView), getNearestPoint(index == 0)); } else if (index == getPointCount() - 1 && targetParentView != null) { return targetParentView.getPerimeterPoint(this, getCenterPoint(targetParentView), getNearestPoint(index == 0)); } else if (obj instanceof PortView) // Port Location Seen From This Edge return ((PortView) obj).getLocation(this, getNearestPoint(index == 0)); else if (obj instanceof CellView) { // Should not happen Rectangle2D r = ((CellView) obj).getBounds(); return new Point2D.Double(r.getX(), r.getY()); } else if (obj instanceof Point2D) // Regular Point return (Point2D) obj; return null; }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
/** * Returns the nearest point wrt to the source or target. This method * returns the next or previous point or port in the points list, eg. if * source is true it returns the location of the point or port at index 1 * without calling the getLocation method on any ports.<br> * Likewise, the method returns the location at index getPointCount()-2 if * source is false. */ protected Point2D getNearestPoint(boolean source) { if (getPointCount() == 2) { if (source && target instanceof PortView && GraphConstants.getOffset(target.getAllAttributes()) != null) { return ((PortView) target).getLocation(this); } if (!source && this.source instanceof PortView && GraphConstants.getOffset(this.source.getAllAttributes()) != null) { return ((PortView) this.source).getLocation(this); } if (source && targetParentView != null && targetParentView.isLeaf()) return getCenterPoint(targetParentView); else if (!source && sourceParentView != null && sourceParentView.isLeaf()) return getCenterPoint(sourceParentView); } return getPointLocation((source) ? 1 : getPointCount() - 2); }
public org.jgraph.graph.CellView createView(GraphModel model, Object cell) { org.jgraph.graph.CellView view = null; if (model.isPort(cell)) view = new PortView(cell); else if (model.isEdge(cell)) view = createEdgeView(cell); else view = createVertexView(cell); return view; }
if (edge.getSource() instanceof PortView) { newPoints.set(0, edge.getSource()); from = ((PortView) edge.getSource()).getLocation(); } else if (edge.getSource() != null) { Rectangle2D b = edge.getSource().getBounds(); CellView target = edge.getTarget(); if (target instanceof PortView) to = ((PortView) target).getLocation(); else if (target != null) { Rectangle2D b = target.getBounds();