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

The following examples show how to use org.eclipse.draw2d.PositionConstants#EAST_WEST . 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: 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 2
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 3
Source File: ReportElementFigure.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( );

	graphics.getClip( PRIVATE_RECT );
	//graphics.setClip( area );

	// 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( );
	Dimension imageSize = new Rectangle( image.getBounds( ) ).getSize( );
	while ( iter.hasNext( ) )
	{
		Point point = (Point) iter.next( );
		graphics.drawImage( image, 0, 0, imageSize.width, imageSize.height,  point.x, point.y, size.width, size.height);
	}
	xyList.clear( );

	graphics.setClip( PRIVATE_RECT );
}
 
Example 4
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 );
}