/** * 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); } } } }
/** * Hides the middle handle if the edge is not bendable. */ protected boolean isHandleVisible(int index) { return super.isHandleVisible(index) && (isSource(index) || isTarget(index) || isCellBendable()); }
/** * Hides the middle handle if the edge is not bendable. */ protected boolean isHandleVisible(int index) { return super.isHandleVisible(index) && (isSource(index) || isTarget(index) || isCellBendable()); }
/** * Refreshes the cell handler. */ public void refresh(mxCellState state) { this.state = state; handles = createHandles(); mxGraph graph = graphComponent.getGraph(); mxRectangle tmp = graph.getBoundingBox(state.getCell()); if (tmp != null) { bounds = tmp.getRectangle(); if (handles != null) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i)) { bounds.add(handles[i]); } } } } }
/** * Refreshes the cell handler. */ public void refresh(mxCellState state) { this.state = state; handles = createHandles(); mxGraph graph = graphComponent.getGraph(); mxRectangle tmp = graph.getBoundingBox(state.getCell()); if (tmp != null) { bounds = tmp.getRectangle(); if (handles != null) { for (int i = 0; i < handles.length; i++) { if (isHandleVisible(i)) { bounds.add(handles[i]); } } } } }