org.eclipse.gef.handles.HandleBounds Java Examples

The following examples show how to use org.eclipse.gef.handles.HandleBounds. 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: CustomResizeHandle.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public CustomResizeHandle(GraphicalEditPart owner, int direction) {
	setOwner(owner);

	RelativeHandleLocator locator = new RelativeHandleLocator(owner.getFigure(), direction){
		protected Rectangle getReferenceBox() {
			IFigure f = getReferenceFigure();
			if (f instanceof HandleBounds){
				Rectangle r = ((HandleBounds) f).getHandleBounds() ;
				return r;
			}
			return super.getReferenceBox();
		}
	};

	setLocator(locator);
	setCursor(Cursors.getDirectionalCursor(direction, owner.getFigure()
			.isMirrored()));
	cursorDirection = direction;
}
 
Example #2
Source File: AdjustIdentityAnchorCommand.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private PrecisionPoint computeNewAnchor(PrecisionPoint currentAnchorPoint, EditPart editPart) {

		double scale = getScale(editPart);
		IFigure figure = ((IGraphicalEditPart) editPart).getFigure();
		Rectangle bounds = figure.getBounds();
		if (figure instanceof HandleBounds) {
			bounds = ((HandleBounds) figure).getHandleBounds();
		}

		Point currentRelativePoint = getAnchorRelativePoint(currentAnchorPoint, bounds);

		if (futureSize != null && delta != null) {
			// In case of border node, the real location is computed earlier
			// (according to BorderItemLocator). The corresponding futureSize
			// and delta are used instead of the request data.
			return new PrecisionPoint(((double) (currentRelativePoint.x - delta.x)) / futureSize.width,
					((double) (currentRelativePoint.y - delta.y)) / futureSize.height);
		} else {

			double logicalWidthDelta = request.getSizeDelta().width / scale;
			double logicalHeightDelta = request.getSizeDelta().height / scale;

			int direction = request.getResizeDirection();

			double newRelativeX = computeNewXRelativeLocation(direction, currentRelativePoint, logicalWidthDelta);
			double newRelativeY = computeNewYRelativeLocation(direction, currentRelativePoint, logicalHeightDelta);

			return new PrecisionPoint(newRelativeX / (bounds.width() + logicalWidthDelta),
					newRelativeY / (bounds.height() + logicalHeightDelta));
		}
	}
 
Example #3
Source File: PreferredSizeHandlerEditPolicy.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public PreferredSizeSquareHandle(GraphicalEditPart editpart) {
	super(editpart, new RelativeLocator(getHostFigure(), 0.75, 1) {
		protected Rectangle getReferenceBox() {
			IFigure f = getReferenceFigure();
			if (f instanceof HandleBounds)
				return ((HandleBounds) f).getHandleBounds();
			return super.getReferenceBox();
		}
	});
}