Java Code Examples for org.eclipse.gef.RequestConstants#REQ_RESIZE
The following examples show how to use
org.eclipse.gef.RequestConstants#REQ_RESIZE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetPreferredSizeRequest.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public SetPreferredSizeRequest(IGraphicalEditPart host) { super(RequestConstants.REQ_RESIZE); setEditParts(host); double zoom = ((DiagramRootEditPart) host.getRoot()).getZoomManager().getZoom(); IFigure figure = host.getFigure(); Dimension prefSize = figure.getLayoutManager().getPreferredSize(figure, -1, -1).getCopy().scale(zoom); prefSize.expand(8,8); Dimension currentSize = figure.getSize().scale(zoom); Dimension newDimension = new Dimension(prefSize.width - currentSize.width, prefSize.height - currentSize.height); setSizeDelta(newDimension); }
Example 2
Source File: DiagramElementsModifier.java From txtUML with Eclipse Public License 1.0 | 5 votes |
/** * Resizes a GraphicalEditPart * * @param graphEP * - The GraphicalEditPart that is to be resized * @param new_width * - The new width of the EditPart * @param new_height * - The new height of the EditPart */ public static void resizeGraphicalEditPart(GraphicalEditPart graphEP, int new_width, int new_height) { Dimension figuredim = graphEP.getFigure().getSize(); ChangeBoundsRequest resize_req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE); resize_req.setSizeDelta(new Dimension(new_width - figuredim.width(), new_height - figuredim.height())); resize_req.setEditParts(graphEP); Command cmd = graphEP.getCommand(resize_req); if (cmd != null) cmd.execute(); }
Example 3
Source File: MultipleShapesHorizontalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Erases the guide and the feedback shown by the container * of the elements. */ protected void eraseSourceFeedback() { if (guideline.getParent() != null) { guideline.getParent().remove(guideline); } if (_container != null) { _container.eraseSourceFeedback(getSourceRequest()); } ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE); request.setEditParts(Collections.emptyList()); request.setSizeDelta(new Dimension(0, 0)); request.setMoveDelta(new Point(0, 0)); for (IGraphicalEditPart part : _movingShapes) { part.eraseSourceFeedback(request); } ChangeBoundsRequest spRequest = new ChangeBoundsRequest( RequestConstants.REQ_RESIZE); spRequest.setEditParts(Collections.emptyList()); spRequest.setSizeDelta(new Dimension(0, 0)); spRequest.setMoveDelta(new Point(0, 0)); for (IGraphicalEditPart sp : _subProcesses) { sp.eraseSourceFeedback(spRequest); } }
Example 4
Source File: MultipleShapesVerticalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * Erases the guide and the feedback shown by the container * of the elements. */ protected void eraseSourceFeedback() { if (guideline.getParent() != null) { guideline.getParent().remove(guideline); } if (_container != null) { _container.eraseSourceFeedback(getSourceRequest()); } ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE); request.setEditParts(Collections.emptyList()); request.setSizeDelta(new Dimension(0, 0)); request.setMoveDelta(new Point(0, 0)); for (IGraphicalEditPart part : _movingShapes) { part.eraseSourceFeedback(request); } ChangeBoundsRequest spRequest = new ChangeBoundsRequest( RequestConstants.REQ_RESIZE); spRequest.setEditParts(Collections.emptyList()); spRequest.setSizeDelta(new Dimension(0, 0)); spRequest.setMoveDelta(new Point(0, 0)); for (IGraphicalEditPart sp : _subProcesses) { sp.eraseSourceFeedback(spRequest); } }
Example 5
Source File: FiguresHelper.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static void resizeActivitiesFigure(final IGraphicalEditPart parentEp, final String text) { final int lineNumber = text.length() / LINE_LENGTH; final ChangeBoundsRequest req = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE); final int currentWidth = parentEp.getFigure().getSize().width; final int defaultWidth = parentEp.getFigure().getPreferredSize().width; final int withDeltaFromDefault = currentWidth - defaultWidth; final int currentHeight = parentEp.getFigure().getSize().height; final int defaultHeight = parentEp.getFigure().getPreferredSize().height; final int heightDeltaFromDefault = currentHeight - defaultHeight; req.setSizeDelta(new Dimension(20 * lineNumber - withDeltaFromDefault, 10 * lineNumber - heightDeltaFromDefault)); req.setConstrainedResize(true); req.setCenteredResize(true); req.setResizeDirection(PositionConstants.CENTER); req.setEditParts(parentEp); // avoid to perform request on element creation (figure have no size) if (currentWidth > 0 && currentHeight > 0 && req.getSizeDelta().width > 0 && req.getSizeDelta().height > 0) { final Command cmd = parentEp.getCommand(req); if (cmd != null) { parentEp.getDiagramEditDomain().getDiagramCommandStack().execute(cmd); } } }
Example 6
Source File: MultipleShapesHorizontalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * Shows a nice guideline to show the move to * the right or the left. */ protected void showSourceFeedback() { if (_container == null) { return; } if (guideline.getParent() == null) { addFeedback(guideline); } Rectangle bounds = Rectangle.SINGLETON.getCopy(); bounds.x = getCurrentPositionZoomed(); Rectangle containerBounds = _container.getFigure().getBounds().getCopy(); _container.getFigure().translateToAbsolute(containerBounds); ((DiagramEditPart) getCurrentViewer().getContents()) .getFigure().translateToRelative(containerBounds); bounds.y = containerBounds.y; bounds.width = 1; bounds.height = containerBounds.height; 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(); }
Example 7
Source File: MultipleShapesVerticalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * 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(); }