/** * For backwards compatibility. */ public Point2D getLocation(EdgeView edge) { return getLocation(edge, null); }
/** * Shortcut method to getLocation(null, null) */ public Point2D getLocation() { return getLocation(null, null); }
/** * 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 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; }
/** * 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; }
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);
/** * 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; }
/** * 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); }
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();
start = convert(getGraph().toScreen(port.getLocation(null)));
if (port!=null) { PortView portView = (PortView) mapper.getMapping(port, false); edgeLength = portView.getLocation().getX() - node.position.getX();
/** * Description of the Method * *@param e Description of Parameter */ public void mouseDragged(MouseEvent e) { // If remembered Start Point is Valid if (start != null && !e.isConsumed()) { // Fetch getGraph()ics from Graph Graphics g = getGraph().getGraphics(); // Xor-Paint the old Connector (Hide old Connector) paintConnector(Color.black, getGraph().getBackground(), g); // Reset Remembered Port port = getTargetPortAt(e.getPoint()); // If Port was found then Point to Port Location if (port != null) { current = convert(getGraph().toScreen(port.getLocation(null))); } // Else If no Port was found then Point to Mouse Location else { current = convert(getGraph().snap(e.getPoint())); } // Xor-Paint the new Connector paintConnector(getGraph().getBackground(), Color.black, g); // Consume Event e.consume(); } // Call Superclass super.mouseDragged(e); }