/** * Returns the index of the handle at the given location. * * @param x X-coordinate of the location. * @param y Y-coordinate of the location. * @return Returns the handle index for the given location. */ public int getIndexAt(int x, int y) { if (handles != null && isHandlesVisible()) { int tol = graphComponent.getTolerance(); Rectangle rect = new Rectangle(x - tol / 2, y - tol / 2, tol, tol); for (int i = handles.length - 1; i >= 0; i--) { if (isHandleVisible(i) && handles[i].intersects(rect)) { return i; } } } return -1; }
/** * Returns the index of the handle at the given location. * * @param x X-coordinate of the location. * @param y Y-coordinate of the location. * @return Returns the handle index for the given location. */ public int getIndexAt(int x, int y) { if (handles != null && isHandlesVisible()) { int tol = graphComponent.getTolerance(); Rectangle rect = new Rectangle(x - tol / 2, y - tol / 2, tol, tol); for (int i = handles.length - 1; i >= 0; i--) { if (isHandleVisible(i) && handles[i].intersects(rect)) { return i; } } } return -1; }
/** * Paints the visible handles of this handler. */ public void paint(Graphics g) { if (handles != null && isHandlesVisible()) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i) && g.hitClip(handles[i].x, handles[i].y, handles[i].width, handles[i].height)) { g.setColor(getHandleFillColor(i)); g.fillRect(handles[i].x, handles[i].y, handles[i].width, handles[i].height); g.setColor(getHandleBorderColor(i)); g.drawRect(handles[i].x, handles[i].y, handles[i].width - 1, handles[i].height - 1); } } } }
/** * Paints the visible handles of this handler. */ public void paint(Graphics g) { if (handles != null && isHandlesVisible()) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i) && g.hitClip(handles[i].x, handles[i].y, handles[i].width, handles[i].height)) { g.setColor(getHandleFillColor(i)); g.fillRect(handles[i].x, handles[i].y, handles[i].width, handles[i].height); g.setColor(getHandleBorderColor(i)); g.drawRect(handles[i].x, handles[i].y, handles[i].width - 1, handles[i].height - 1); } } } }