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

The following examples show how to use org.eclipse.draw2d.geometry.Rectangle#getRight() . 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: RailroadView.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public void reveal(IFigure figure) {
	Viewport viewport = canvas.getViewport();
	Rectangle viewportBounds = viewport.getBounds().getCopy();
	viewportBounds.translate(viewport.getViewLocation());
	Rectangle figureBounds = figure.getBounds().getCopy();
	figure.translateToAbsolute(figureBounds);
	figureBounds.translate(viewport.getViewLocation());
	if (!viewportBounds.contains(figureBounds)) {
		int newX = viewportBounds.x;
		int newY = viewportBounds.y;
		if(viewportBounds.x > figureBounds.x) {
			newX = figureBounds.x; 
		} else if(viewportBounds.x + viewportBounds.getRight().x < figureBounds.getRight().x) {
			newX = figureBounds.getRight().x - viewportBounds.width;
		}
		if(viewportBounds.y > figureBounds.y) {
			newY = figureBounds.y; 
		} else if(viewportBounds.getBottom().y < figureBounds.getBottom().y) {
			newY = figureBounds.getBottom().y - viewportBounds.height;
		}
		canvas.scrollSmoothTo(newX, newY);
	}
}
 
Example 2
Source File: LinkAnchor.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public Point getLocation(Point reference) {
	int hTrans = 0;
	if (!node.isMinimized()) {
		hTrans = ProcessFigure.MARGIN_WIDTH + 1;
		if (forInput) {
			hTrans *= -1;
		}
	}
	Rectangle r = getOwner().getBounds().getCopy();
	r.translate(hTrans, 0);
	getOwner().translateToAbsolute(r);
	Point location = null;
	if (forInput) {
		location = r.getLeft();
	} else {
		location = r.getRight();
	}
	return location;
}
 
Example 3
Source File: Connection.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Point getLocation(Point reference) {
	IFigure owner = getOwner();
	Rectangle bounds = owner.getBounds().getCopy();
	owner.translateToAbsolute(bounds);
	if (reference.x < bounds.getLeft().x) {
		return bounds.getLeft();
	} else {
		return bounds.getRight();
	}
}
 
Example 4
Source File: ReportCreationTool.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Performs the creation. Runs the creation via simulating the mouse move
 * event.
 * 
 * @param editPart
 *            the current EditPart
 */
public void performCreation( EditPart editPart )
{
	if ( editPart == null )
		return;
	setTargetEditPart( editPart );
	boolean validateCurr = handleValidatePalette( getFactory( ).getObjectType( ),
			getTargetEditPart( ) );
	if ( !validateCurr )
	{
		// Validates the parent part
		setTargetEditPart( editPart.getParent( ) );
	}
	if ( validateCurr
			|| handleValidatePalette( getFactory( ).getObjectType( ),
					getTargetEditPart( ) ) )
	{
		// Sets the insertion point
		IFigure figure = ( (GraphicalEditPart) editPart ).getFigure( );
		Rectangle rect = figure.getBounds( ).getCopy( );
		figure.translateToAbsolute( rect );
		Point point = rect.getRight( );
		point.performTranslate( 1, 1 );
		getCreateRequest( ).setLocation( point );

		setCurrentCommand( getCommand( ) );
		performCreation( MOUSE_BUTTON1 );
	}
	eraseTargetFeedback( );
}