Java Code Examples for org.eclipse.draw2d.geometry.Rectangle#performScale()

The following examples show how to use org.eclipse.draw2d.geometry.Rectangle#performScale() . 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: BonitaUnspecifiedTypeCreationTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setViewer(EditPartViewer viewer) {
	super.setViewer(viewer);
	if(viewer != null && figure != null){
		double zoom = ((DiagramRootEditPart)((DiagramGraphicalViewer)getCurrentViewer()).getRootEditPart()).getZoomManager().getZoom() ;
		if(zoom != oldZoom){
			Rectangle r = figure.getBounds().getCopy() ;
			r.performScale(zoom);
			figure.setBounds(r) ;
			oldZoom = zoom ;
		}
	}
}
 
Example 2
Source File: DraggableElementCreationTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return
 */
private IFigure createImage() {
    final CreateUnspecifiedTypeRequest createUnspecifiedTypeRequest = (CreateUnspecifiedTypeRequest) tool.createCreateRequest();
    final EClass eClass = ((IElementType) createUnspecifiedTypeRequest.getElementTypes().get(0)).getEClass();
    final IFigure svgFigure = FiguresHelper.getSelectedFigure(eClass, -1, -1, null, null);
    final Rectangle r = svgFigure.getBounds().getCopy();
    r.performScale(zoomManager.getZoom());
    svgFigure.setBounds(r);
    return svgFigure;
}
 
Example 3
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* 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 4
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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();
}