org.eclipse.gef.tools.ResizeTracker Java Examples

The following examples show how to use org.eclipse.gef.tools.ResizeTracker. 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: BarResizeEditPolicy.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ResizeTracker getResizeTracker(int direction) {

	return new ResizeTracker((GraphicalEditPart) getHost(), direction) {
		@Override
		protected void enforceConstraintsForResize(ChangeBoundsRequest request) {
			Rectangle locationAndSize = getOriginalBounds();
			
			final Rectangle origRequestedBounds = request.getTransformedRectangle(locationAndSize);
			final Rectangle modified = origRequestedBounds.getCopy();
			checkAndPrepareConstraint(request, modified);
			Dimension newDelta = new Dimension(modified.width - locationAndSize.width,
					modified.height - locationAndSize.height);
			request.setSizeDelta(newDelta);
			final Point moveDelta = request.getMoveDelta();
			request.setMoveDelta(new Point(moveDelta.x - origRequestedBounds.x + modified.x,
					moveDelta.y - origRequestedBounds.y + modified.y));
		}
	};
}
 
Example #2
Source File: LiveFeedbackResizableEditPolicy.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected ResizeTracker getResizeTracker(int direction) {
	LiveFeedbackResizeTracker liveFeedbackResizeTracker = new LiveFeedbackResizeTracker(
			(GraphicalEditPart) getHost(), direction);
	liveFeedbackResizeTracker.setOriginalBounds(getOriginalBounds());
	return liveFeedbackResizeTracker;
}
 
Example #3
Source File: CrosstavCellDragHandle.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected DragTracker createDragTracker( )
{
	CrosstabHandleAdapter adapter = ((CrosstabTableEditPart)getOwner( ).getParent( )).getCrosstabHandleAdapter( );
	if (cursorDirection == PositionConstants.EAST && 
			(adapter.getColumnOprationCell( start )!=null||adapter.getColumnOprationCell( end )!=null))
	{
		return new CrosstabColumnDragTracker(getOwner( ), start, end);
	}
	if (cursorDirection == PositionConstants.SOUTH && adapter.getRowOprationCell( start ) != null)
	{
		return new CrosstabRowDragTracker(getOwner( ), start, end);
	}
	//return null;
	return new ResizeTracker( getOwner( ), cursorDirection )
	{
		protected void showTargetFeedback() 
		{
			
		}
		protected void eraseTargetFeedback() 
		{
		
		}
		
		protected void showSourceFeedback( )
		{
		}
		
		protected void eraseSourceFeedback( )
		{
		}
		
		protected Command getCommand( )
		{
			return UnexecutableCommand.INSTANCE;
		}
	};
}
 
Example #4
Source File: TableCellDragHandle.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected DragTracker createDragTracker( )
{
	
	if (cursorDirection == PositionConstants.EAST )
	{
		return new ColumnDragTracker(getOwner( ).getParent( ), start, end);
	}
	if (cursorDirection == PositionConstants.SOUTH)
	{
		return new RowDragTracker(getOwner( ).getParent( ), start, end);
	}
	//return null;
	return new ResizeTracker( getOwner( ), cursorDirection )
	{
		protected void showTargetFeedback() 
		{
			
		}
		protected void eraseTargetFeedback() 
		{
		
		}
		
		protected void showSourceFeedback( )
		{
		}
		
		protected void eraseSourceFeedback( )
		{
		}
		
		protected Command getCommand( )
		{
			return UnexecutableCommand.INSTANCE;
		}
	};
}
 
Example #5
Source File: CustomPoolResizeHandle.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected DragTracker createDragTracker() {
	if (getOwner() instanceof CustomPoolEditPart){
		GraphicalEditPart target = getOwner();
	    CustomPoolEditPart pool = (CustomPoolEditPart)getOwner();
		for (Object o:pool.getChildren()){
			if (o instanceof CustomPoolCompartmentEditPart){
				for (Object o2:((CustomPoolCompartmentEditPart)o).getChildren()){
					if (o2 instanceof CustomLaneEditPart){
					    target = (CustomLaneEditPart)o2;
					}
				}
			}
		}
		
		return new ResizeTracker(target, cursorDirection){
			@Override
			protected GraphicalEditPart getTargetEditPart() {
				return getOwner();
			}
			
			@Override
			protected List getOperationSet() {
				List operationSet = new ArrayList();
				operationSet.add(getOwner());
				return operationSet;
			}
		};
	}
	return new ResizeTracker(getOwner(),cursorDirection);


}
 
Example #6
Source File: CustomResizeHandle.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected DragTracker createDragTracker() {
	return new ResizeTracker(getOwner(), cursorDirection){
		@Override
		protected void updateSourceRequest() {
			ChangeBoundsRequest request = (ChangeBoundsRequest) getSourceRequest();
			Dimension d = getDragMoveDelta();

			Point location = new Point(getLocation());
			Point moveDelta = new Point(0, 0);
			Dimension resizeDelta = new Dimension(0, 0);

			if (getOwner() != null) {

				if(isContrained){
					request.setConstrainedResize(true);
					int origHeight = getOwner().getFigure().getBounds().height;
					int origWidth = getOwner().getFigure().getBounds().width;
					float ratio = 1;

					if (origWidth != 0 && origHeight != 0)
						ratio = ((float) origHeight / (float) origWidth);

					if (getResizeDirection() == PositionConstants.SOUTH_EAST) {
						if (d.height > (d.width * ratio))
							d.width = (int) (d.height / ratio);
						else
							d.height = (int) (d.width * ratio);
					} else if (getResizeDirection() == PositionConstants.NORTH_WEST) {
						if (d.height < (d.width * ratio))
							d.width = (int) (d.height / ratio);
						else
							d.height = (int) (d.width * ratio);
					} else if (getResizeDirection() == PositionConstants.NORTH_EAST) {
						if (-(d.height) > (d.width * ratio))
							d.width = -(int) (d.height / ratio);
						else
							d.height = -(int) (d.width * ratio);
					} else if (getResizeDirection() == PositionConstants.SOUTH_WEST) {
						if (-(d.height) < (d.width * ratio))
							d.width = -(int) (d.height / ratio);
						else
							d.height = -(int) (d.width * ratio);
					}
				}
			}else{
				request.setConstrainedResize(false);
			}

			request.setCenteredResize(getCurrentInput().isModKeyDown(SWT.MOD1));

			if ((getResizeDirection() & PositionConstants.NORTH) != 0) {
				if (getCurrentInput().isControlKeyDown()) {
					resizeDelta.height -= d.height;
				}
				moveDelta.y += d.height;
				resizeDelta.height -= d.height;
			}
			if ((getResizeDirection() & PositionConstants.SOUTH) != 0) {
				if (getCurrentInput().isControlKeyDown()) {
					moveDelta.y -= d.height;
					resizeDelta.height += d.height;
				}
				resizeDelta.height += d.height;
			}
			if ((getResizeDirection() & PositionConstants.WEST) != 0) {
				if (getCurrentInput().isControlKeyDown()) {
					resizeDelta.width -= d.width;
				}
				moveDelta.x += d.width;
				resizeDelta.width -= d.width;
			}
			if ((getResizeDirection() & PositionConstants.EAST) != 0) {
				if (getCurrentInput().isControlKeyDown()) {
					moveDelta.x -= d.width;
					resizeDelta.width += d.width;
				}
				resizeDelta.width += d.width;
			}

			request.setMoveDelta(moveDelta);
			request.setSizeDelta(resizeDelta);
			request.setLocation(location);
			request.setEditParts(getOperationSet());

			request.getExtendedData().clear();
		}

		@Override
		protected List<IGraphicalEditPart> createOperationSet() {
			ArrayList<IGraphicalEditPart> res = new ArrayList<IGraphicalEditPart>();
			for (Object selection : getCurrentViewer().getSelectedEditParts()) {
				if (isResizable((IGraphicalEditPart)selection)) {
					res.add((IGraphicalEditPart)selection);
				}
			}
			return res;
		}
	};
}