public void figureMoved(IFigure figure) { Rectangle bounds = figure.getBounds(); if (relativeToParent) { bounds = Rectangle.SINGLETON.setBounds(bounds); // copy Rectangle parentBounds = figure.getParent().getBounds(); bounds.translate(-parentBounds.x, -parentBounds.y); } Point loc = element.getLocation(); if (loc == null || loc.x != bounds.x || loc.y != bounds.y) { Point newLocation = new Point(bounds.x, bounds.y); if (element instanceof FormElementGroup) { FormElementGroupPropertySource formElementGroupPropertySource = new FormElementGroupPropertySource((FormElementGroup) element, form); formElementGroupPropertySource.setLocation(newLocation); } else { element.setLocation(newLocation); } } Dimension dim = element.getSize(); if (dim == null || dim.width != bounds.width || dim.height != bounds.height) { Dimension newSize = new Dimension(bounds.width, bounds.height); if (element instanceof FormElementGroup) { FormElementGroupPropertySource formElementGroupPropertySource = new FormElementGroupPropertySource((FormElementGroup) element, null); formElementGroupPropertySource.setSize(newSize); } else { element.setSize(newSize); } } }
/** Shows a nice guideline to show the move */ protected void showSourceFeedback() { if (_container == null) { return; } if (guideline.getParent() == null) { addFeedback(guideline); } Rectangle bounds = Rectangle.SINGLETON.getCopy(); bounds.y = getCurrentPositionZoomed(); Rectangle containerBounds = _container.getFigure().getBounds().getCopy(); _container.getFigure().translateToAbsolute(containerBounds); ((DiagramEditPart) getCurrentViewer().getContents()) .getFigure() .translateToRelative(containerBounds); bounds.x = containerBounds.x; bounds.height = 1; bounds.width = containerBounds.width; ZoomManager zoomManager = ((DiagramRootEditPart) getCurrentViewer().getRootEditPart()).getZoomManager(); bounds.performScale(zoomManager.getZoom()); guideline.setBounds(bounds); guideline.setVisible(getState() == STATE_DRAG_IN_PROGRESS); ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE); request.setMoveDelta(((ChangeBoundsRequest) getSourceRequest()).getMoveDelta()); request.setSizeDelta(new Dimension(0, 0)); request.setEditParts(_movingShapes); for (IGraphicalEditPart part : _movingShapes) { part.showSourceFeedback(request); } ChangeBoundsRequest spRequest = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE); Point moveDelta = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy(); Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y); spRequest.setSizeDelta(spSizeDelta); spRequest.setMoveDelta(new Point(0, 0)); spRequest.setEditParts(_subProcesses); for (IGraphicalEditPart sp : _subProcesses) { sp.showSourceFeedback(spRequest); } ((DiagramEditPart) getCurrentViewer().getContents()).getRoot().refresh(); }
/** * Returns <code>true</code> if the point (x,y) is contained within this handle. * * @param x The x coordinate. * @param y The y coordinate. * @return <code>true</code> if the point (x,y) is contained within this handle. */ public boolean containsPoint(int x, int y) { if (!super.containsPoint(x, y)) return false; return !Rectangle.SINGLETON.setBounds(getBounds()).shrink(INNER_PAD, INNER_PAD).contains(x, y); }