Java Code Examples for org.eclipse.gef.requests.ChangeBoundsRequest#setResizeDirection()

The following examples show how to use org.eclipse.gef.requests.ChangeBoundsRequest#setResizeDirection() . 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: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void decreaseHeight() {
	ChangeBoundsRequest setRequest1 = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE) ; 
	List<EditPart> epToMove = new ArrayList<EditPart>();
	epToMove.add(gep);
	setRequest1.setEditParts(epToMove);
	setRequest1.setResizeDirection(PositionConstants.NORTH);
	setRequest1.setSizeDelta(new Dimension(0,-150));
	gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
	for(Object o : gep.getChildren()){
		if(o instanceof CustomPoolCompartmentEditPart){
			for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
				lane.refresh();
			}
		}
		
	}
	
}
 
Example 2
Source File: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void increaseHeight() {
	ChangeBoundsRequest setRequest1 = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE) ; 
	List<EditPart> epToMove = new ArrayList<EditPart>();
	epToMove.add(gep);
	setRequest1.setEditParts(epToMove);
	setRequest1.setResizeDirection(PositionConstants.SOUTH);
	setRequest1.setSizeDelta(new Dimension(0,150));
	gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
	for(Object o : gep.getChildren()){
		if(o instanceof CustomPoolCompartmentEditPart){
			for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
				lane.refresh();
			}
		}
		
	}
}
 
Example 3
Source File: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void increaseWidth() {
	ChangeBoundsRequest setRequest1 = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE) ; 
	List<EditPart> epToMove = new ArrayList<EditPart>();
	epToMove.add(gep);
	for(Object o : gep.getChildren()){
		if(o instanceof CustomPoolCompartmentEditPart){
			for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
				epToMove.add(lane);
			}
		}
		
	}
	setRequest1.setEditParts(epToMove);
	setRequest1.setResizeDirection(PositionConstants.EAST);
	setRequest1.setSizeDelta(new Dimension(150,0));
	gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
}
 
Example 4
Source File: FiguresHelper.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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);
            }
        }

    }