/** * Implements the getConnectionPoint method in Connector interface. * * @param wayPoint the way point to be connected * @return the target connection point * @throws IllegalArgumentException if given wayPoint is null */ public Point getConnectionPoint(Point wayPoint) { Util.checkNotNull(wayPoint, "wayPoint"); // Get the top rectangle Point position = parent.getLocation(); position.x += parent.getSelectionBound().x; position.y += parent.getSelectionBound().y; Dimension size = new Dimension(); Dimension compartmentSize = null; if (parent.getStereotypeCompartment().isVisible()) { compartmentSize = parent.getStereotypeCompartment().getPreferredSize(); Util.combineSize(size, compartmentSize, true); } compartmentSize = parent.getNameCompartment().getSize(); if (parent.getNamespaceCompartment().isVisible()) { Util.combineSize(size, compartmentSize, true); compartmentSize = parent.getNamespaceCompartment().getSize(); Util.combineSize(size, compartmentSize, false); } else { Util.combineSize(size, compartmentSize, false); } if (wayPoint.x < position.x + size.width && wayPoint.y < position.y + size.height) { // Connect to the top rectangle Rectangle bound = new Rectangle(position, size); return new RectangleConnector(bound).getConnectionPoint(wayPoint); } // Connect to the bottom rectangle position.y += size.height; size.width = parent.getSelectionBound().width; size.height = parent.getSelectionBound().height - size.height; Rectangle bound = new Rectangle(position, size); return new RectangleConnector(bound).getConnectionPoint(wayPoint); }