protected void invalidate() { // Retrieve current bounds and set local vars Rectangle2D tmp = graph.getCellBounds(vertex.getCell()); if (tmp != null) { tmp = (Rectangle2D) tmp.clone(); graph.toScreen(tmp); int handlesize = graph.getHandleSize(); int s2 = 2 * handlesize; double left = tmp.getX() - handlesize; double top = tmp.getY() - handlesize; double w2 = tmp.getX() + (tmp.getWidth() / 2) - handlesize; double h2 = tmp.getY() + (tmp.getHeight() / 2) - handlesize; double right = tmp.getX() + tmp.getWidth() - handlesize; double bottom = tmp.getY() + tmp.getHeight() - handlesize; // Update control point positions r[0].setFrame(left, top, s2, s2); r[1].setFrame(w2, top, s2, s2); r[2].setFrame(right, top, s2, s2); r[3].setFrame(left, h2, s2, s2); r[4].setFrame(right, h2, s2, s2); r[5].setFrame(left, bottom, s2, s2); r[6].setFrame(w2, bottom, s2, s2); r[7].setFrame(right, bottom, s2, s2); } }
public SizeHandle(VertexView vertexview, GraphContext ctx) { graph = ctx.getGraph(); vertex = vertexview; editing = graph.getEditingCell() == vertex.getCell(); int sizeableAxis = GraphConstants.getSizeableAxis(vertex.getAllAttributes()); if (sizeableAxis == GraphConstants.X_AXIS) cursors = xCursors; else if (sizeableAxis == GraphConstants.Y_AXIS) cursors = yCursors; else cursors = defaultCursors; // PortView Preview portViews = ctx.createTemporaryPortViews(); initialBounds = (Rectangle2D) vertex.getBounds().clone(); context = ctx; for (int i = 0; i < r.length; i++) r[i] = new Rectangle2D.Double(); invalidate(); }
/** Process mouse pressed event. */ public void mousePressed(MouseEvent event) { if (!graph.isSizeable()) return; for (int i = 0; i < r.length; i++) { if (r[i].contains(event.getPoint()) && cursors[i] != 0) { Set set = new HashSet(); set.add(vertex.getCell()); contextViews = context.createTemporaryContextViews(set); Object[] all = AbstractCellView.getDescendantViews(new CellView[] {vertex}); if (all.length >= org.jgraph.plaf.basic.BasicGraphUI.MAXHANDLES) cachedBounds = (Rectangle2D) initialBounds.clone(); event.consume(); index = i; return; } } }