/** * Refresh the geometry. Check that the sites that the handles are attached to are the same as the * sites at the ends of the connector, and if not, fix them. This is needed because some clients * might unnecessarily over-write the sites that a connector is already snapped to. If the * grab-handles aren't re-attached accordingly, grabbing and moving them will cause unpredictable * results. */ public void refresh() { Connector c = (Connector) getChild(); // Check sites if (c != null) { if (_headHandle.getSite() != c.getHeadSite()) { _headHandle.setSite(c.getHeadSite()); } if (_tailHandle.getSite() != c.getTailSite()) { _tailHandle.setSite(c.getTailSite()); } } }
/** * Clear the current grab handles and create one for each of the head and tail sites. Subclasses * may override this to create additional grab handles. * * @param connector The connector. */ protected void _createGrabHandles(Connector connector) { clearGrabHandles(); // Create the grab handles and set them up GrabHandleFactory factory = getGrabHandleFactory(); _headHandle = factory.createGrabHandle(connector.getHeadSite()); _tailHandle = factory.createGrabHandle(connector.getTailSite()); _headHandle.setParent(this); _tailHandle.setParent(this); _headHandle.setInteractor(getHandleInteractor()); _tailHandle.setInteractor(getHandleInteractor()); addGrabHandle(_headHandle); addGrabHandle(_tailHandle); }