Java Code Examples for org.eclipse.draw2d.PositionConstants#SOUTH

The following examples show how to use org.eclipse.draw2d.PositionConstants#SOUTH . 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: CustomRectilinearRouter.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Given the coordinates of the connection anchor point the shape's rectangle and the
 * orientation of the first rectilinear connection segment that comes out from the anchor
 * point the method detemines on which geographic side of the rectangle the anchor point
 * is located on.
 * 
 * @param anchorPoint coordinates of the anchor point
 * @param rectangle the shape's bounding rectangle
 * @param segmentOrientation orinetation of the segment coming out from the anchor point
 * @return geographic position of the anchor point relative to the rectangle
 */
private int getAnchorLocationBasedOnSegmentOrientation(Point anchorPoint, Rectangle rectangle, int segmentOrientation) {
    if (segmentOrientation == PositionConstants.VERTICAL) {
        if (Math.abs(anchorPoint.y - rectangle.y) < Math.abs(anchorPoint.y - rectangle.y - rectangle.height)) {
            return PositionConstants.NORTH;
        } else {
            return PositionConstants.SOUTH;
        }
    } else if (segmentOrientation == PositionConstants.HORIZONTAL) {
        if (Math.abs(anchorPoint.x - rectangle.x) < Math.abs(anchorPoint.x - rectangle.x - rectangle.width)) {
            return PositionConstants.WEST;
        } else {
            return PositionConstants.EAST;
        }
    }
    return PositionConstants.NONE;
}
 
Example 2
Source File: CellDragoicator.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructor
 * 
 * @param reference
 * @param location
 */
public CellDragoicator( IFigure reference, int location )
{
	setReferenceFigure( reference );
	switch ( location & PositionConstants.NORTH_SOUTH )
	{
		case PositionConstants.SOUTH :
			relativeY = 1.0;
			break;
		default :
			relativeY = 0;
	}

	switch ( location & PositionConstants.EAST_WEST )
	{
		case PositionConstants.EAST :
			relativeX = 1.0;
			break;
		default :
			relativeX = 0;
	}
}
 
Example 3
Source File: IntermediateErrorCatchEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateErrorCatchEventLabel2EditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 4
Source File: BotGefProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Point computeTargetLocation(final String pSourceElement, final int pOrientation) {
    final SWTBotGefEditPart gep = gmfEditor.getEditPart(pSourceElement);
    Assert.assertNotNull("Error: No Edit Part \'" + pSourceElement + "\' found.", gep);
    final SWTBotGefEditPart element = gep.parent();
    final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) element.part();
    switch (pOrientation) {
        case PositionConstants.NORTH:
            return graphicalEditPart.getFigure().getBounds().getTop().getCopy().translate(-30, -70);
        case PositionConstants.SOUTH:
            return graphicalEditPart.getFigure().getBounds().getBottom().getCopy().translate(-30, 70);
        case PositionConstants.WEST:
            return graphicalEditPart.getFigure().getBounds().getTopLeft().getCopy().translate(-140, 0);
        case PositionConstants.EAST:
            return graphicalEditPart.getFigure().getBounds().getTopRight().getCopy().translate(80, 0);
        case PositionConstants.NORTH_EAST:
            return graphicalEditPart.getFigure().getBounds().getTopRight().getCopy().translate(80, -70);
        case PositionConstants.NORTH_WEST:
            return graphicalEditPart.getFigure().getBounds().getTopLeft().getCopy().translate(-80, 70);
        case PositionConstants.SOUTH_EAST:
            return graphicalEditPart.getFigure().getBounds().getBottomRight().getCopy().translate(-80, 70);
        case PositionConstants.SOUTH_WEST:
            return graphicalEditPart.getFigure().getBounds().getBottomLeft().getCopy().translate(80, -70);
        default:
            throw new RuntimeException("Invalid position specified");
    }

}
 
Example 5
Source File: NonInterruptingBoundaryTimerEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof NonInterruptingBoundaryTimerEventNameEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 6
Source File: IntermediateCatchMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateCatchMessageEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 7
Source File: StartTimerEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof StartTimerEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 8
Source File: IntermediateCatchSignalEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateCatchSignalEventLabel2EditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 9
Source File: EndSignalEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof EndSignalEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 10
Source File: EndErrorEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof EndErrorEventLabel2EditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 11
Source File: IntermediateThrowMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateThrowMessageEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 12
Source File: CatchLinkEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof CatchLinkEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 13
Source File: StartSignalEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof StartSignalEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 14
Source File: IntermediateErrorCatchEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateErrorCatchEventLabelEditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 15
Source File: IntermediateThrowSignalEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
	if (borderItemEditPart instanceof IntermediateThrowSignalEventLabel2EditPart) {
		BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		locator.setBorderItemOffset(new Dimension(-20, -20));
		borderItemContainer.add(borderItemEditPart.getFigure(), locator);
	} else {
		super.addBorderItem(borderItemContainer, borderItemEditPart);
	}
}
 
Example 16
Source File: ReportRootEditPart.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns <code>true</code> if the given point is outside the
 * viewport or near its edge. Scrolls the viewport by a calculated (time
 * based) amount in the current direction.
 * 
 * todo: investigate if we should allow auto expose when the pointer is
 * outside the viewport
 * 
 * @see org.eclipse.gef.AutoexposeHelper#step(org.eclipse.draw2d.geometry.Point)
 */
public boolean step( Point where )
{
	Viewport port = findViewport( owner );

	Rectangle rect = Rectangle.SINGLETON;
	port.getClientArea( rect );
	port.translateToParent( rect );
	port.translateToAbsolute( rect );
	if ( !rect.contains( where )
			|| rect.crop( threshold ).contains( where ) )
		return false;

	// set scroll offset (speed factor)
	int scrollOffset = 0;

	// calculate time based scroll offset
	if ( lastStepTime == 0 )
		lastStepTime = System.currentTimeMillis( );

	DeferredGraphicalViewer.OriginStepData stepData = ( (DeferredGraphicalViewer) owner.getViewer( ) ).getOriginStepData( );
	long difference = System.currentTimeMillis( ) - lastStepTime;

	if ( difference > 0 )
	{
		scrollOffset = ( (int) difference / 3 );
		lastStepTime = System.currentTimeMillis( );
	}

	if ( scrollOffset == 0 )
		return true;

	rect.crop( threshold );

	int region = rect.getPosition( where );
	Point loc = port.getViewLocation( );

	if ( ( region & PositionConstants.SOUTH ) != 0 )
		loc.y += scrollOffset;
	else if ( ( region & PositionConstants.NORTH ) != 0 )
		loc.y -= scrollOffset;

	if ( ( region & PositionConstants.EAST ) != 0 )
		loc.x += scrollOffset;
	else if ( ( region & PositionConstants.WEST ) != 0 )
		loc.x -= scrollOffset;

	if ( stepData.minX > loc.x )
		loc.x = port.getHorizontalRangeModel( ).getValue( );
	if ( stepData.maxX - stepData.extendX < loc.x )
		loc.x = port.getHorizontalRangeModel( ).getValue( );
	if ( stepData.minY > loc.y )
		loc.y = port.getVerticalRangeModel( ).getValue( );
	if ( stepData.maxY - stepData.extendY < loc.y )
		loc.y = port.getVerticalRangeModel( ).getValue( );
	port.setViewLocation( loc );

	return true;
}
 
Example 17
Source File: ReportElementResizablePolicy.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#createSelectionHandles()
 */
protected List createSelectionHandles( )
{
	List list = new ArrayList( );

	if ( this.getResizeDirections( ) != -1 )
	{
		ReportResizableHandleKit.addMoveHandle( (GraphicalEditPart) getHost( ), list );
		if ( ( this.getResizeDirections( ) & PositionConstants.EAST ) != 0 )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.EAST );
		if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH_EAST ) == PositionConstants.SOUTH_EAST )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.SOUTH_EAST );
		if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH ) != 0 )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.SOUTH );
		if ( ( this.getResizeDirections( ) & PositionConstants.SOUTH_WEST ) == PositionConstants.SOUTH_WEST )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.SOUTH_WEST );
		if ( ( this.getResizeDirections( ) & PositionConstants.WEST ) != 0 )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.WEST );
		if ( ( this.getResizeDirections( ) & PositionConstants.NORTH_WEST ) == PositionConstants.NORTH_WEST )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.NORTH_WEST );
		if ( ( this.getResizeDirections( ) & PositionConstants.NORTH ) != 0 )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.NORTH );
		if ( ( this.getResizeDirections( ) & PositionConstants.NORTH_EAST ) == PositionConstants.NORTH_EAST )
			ReportResizableHandleKit.addHandle( (GraphicalEditPart) getHost( ),
					list,
					PositionConstants.NORTH_EAST );
	}
	else
		ReportResizableHandleKit.addHandles( (GraphicalEditPart) getHost( ), list );

	return list;
}
 
Example 18
Source File: TableFigure.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
 */
protected void paintFigure( Graphics graphics )
{
	if ( isOpaque( ) )
	{
		if ( getBorder( ) instanceof BaseBorder )
		{
			graphics.fillRectangle( getBounds( ).getCopy( )
					.crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) );
		}
		else
		{
			graphics.fillRectangle( getBounds( ) );
		}
	}

	Image image = getImage( );
	if ( image == null )
	{
		return;
	}

	int x, y;
	Rectangle area = getBounds( );

	// Calculates X
	if ( position != null && position.x != -1 )
	{
		x = area.x + position.x;
	}
	else
	{
		switch ( alignment & PositionConstants.EAST_WEST )
		{
			case PositionConstants.EAST :
				x = area.x + area.width - size.width;
				break;
			case PositionConstants.WEST :
				x = area.x;
				break;
			default :
				x = ( area.width - size.width ) / 2 + area.x;
				break;
		}
	}

	// Calculates Y
	if ( position != null && position.y != -1 )
	{
		y = area.y + position.y;
	}
	else
	{
		switch ( alignment & PositionConstants.NORTH_SOUTH )
		{
			case PositionConstants.NORTH :
				y = area.y;
				break;
			case PositionConstants.SOUTH :
				y = area.y + area.height - size.height;
				break;
			default :
				y = ( area.height - size.height ) / 2 + area.y;
				break;
		}
	}

	ArrayList xyList = createImageList( x, y );

	Iterator iter = xyList.iterator( );
	while ( iter.hasNext( ) )
	{
		Point point = (Point) iter.next( );
		graphics.drawImage( image, point );
	}
	xyList.clear( );
}
 
Example 19
Source File: ImageFigure.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.draw2d.Figure#paintFigure(Graphics)
 */
protected void paintFigure( Graphics graphics )
{
	if ( isOpaque( ) )
	{
		if ( getBorder( ) instanceof BaseBorder )
		{
			graphics.fillRectangle( getBounds( ).getCopy( )
					.crop( ( (BaseBorder) getBorder( ) ).getBorderInsets( ) ) );
		}
		else
		{
			graphics.fillRectangle( getBounds( ) );
		}
	}

	if ( getImage( ) == null || getImage( ).isDisposed( ) )
	{
		return;
	}

	if ( stretch )
	{
		paintStretched( graphics );

		return;
	}

	int x, y;
	Rectangle area = getClientArea( );
	switch ( alignment & PositionConstants.NORTH_SOUTH )
	{
		case PositionConstants.NORTH :
			y = area.y;
			break;
		case PositionConstants.SOUTH :
			y = area.y + area.height - size.height;
			break;
		default :
			y = ( area.height - size.height ) / 2 + area.y;
			break;
	}
	switch ( alignment & PositionConstants.EAST_WEST )
	{
		case PositionConstants.EAST :
			x = area.x + area.width - size.width;
			break;
		case PositionConstants.WEST :
			x = area.x;
			break;
		default :
			x = ( area.width - size.width ) / 2 + area.x;
			break;
	}
	graphics.drawImage( getImage( ), x, y );
}
 
Example 20
Source File: NodeElementSelectionEditPolicy.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List createSelectionHandles() {
    final List selectedEditParts = getHost().getViewer().getSelectedEditParts();
    if (selectedEditParts.size() == 1) {
        if (!(getHost().getModel() instanceof Category)) {
            final NodeElementEditPart editPart = (NodeElementEditPart) getHost();
            editPart.reorder();
        }
    }

    final List list = new ArrayList();

    final int directions = getResizeDirections();

    if (directions == 0) {
        // NonResizableHandleKit.addHandles((GraphicalEditPart) getHost(),
        // list);

    } else if (directions != -1) {
        // 0
        list.add(new ERDiagramMoveHandle((GraphicalEditPart) getHost()));

        // 1
        if ((directions & PositionConstants.EAST) != 0) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.EAST);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.EAST);
        }

        // 2
        if ((directions & PositionConstants.SOUTH_EAST) == PositionConstants.SOUTH_EAST) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_EAST);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_EAST);
        }

        // 3
        if ((directions & PositionConstants.SOUTH) != 0) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH);
        }

        // 4
        if ((directions & PositionConstants.SOUTH_WEST) == PositionConstants.SOUTH_WEST) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_WEST);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.SOUTH_WEST);
        }

        // 5
        if ((directions & PositionConstants.WEST) != 0) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.WEST);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.WEST);
        }

        // 6
        if ((directions & PositionConstants.NORTH_WEST) == PositionConstants.NORTH_WEST) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_WEST);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_WEST);
        }

        // 7
        if ((directions & PositionConstants.NORTH) != 0) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH);
        }

        // 8
        if ((directions & PositionConstants.NORTH_EAST) == PositionConstants.NORTH_EAST) {
            ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_EAST);
        } else {
            NonResizableHandleKit.addHandle((GraphicalEditPart) getHost(), list, PositionConstants.NORTH_EAST);
        }

    } else {
        addHandles((GraphicalEditPart) getHost(), list);
    }

    return list;
}