Java Code Examples for org.eclipse.draw2d.FigureCanvas#scrollToX()

The following examples show how to use org.eclipse.draw2d.FigureCanvas#scrollToX() . 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: TableCellKeyDelegate.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
void scrollViewer( KeyEvent event )
{
	if ( !( getViewer( ).getControl( ) instanceof FigureCanvas ) )
		return;
	FigureCanvas figCanvas = (FigureCanvas) getViewer( ).getControl( );
	Point loc = figCanvas.getViewport( ).getViewLocation( );
	Rectangle area = figCanvas.getViewport( )
			.getClientArea( Rectangle.SINGLETON )
			.scale( .1 );
	switch ( event.keyCode )
	{
		case SWT.ARROW_DOWN :
			figCanvas.scrollToY( loc.y + area.height );
			break;
		case SWT.ARROW_UP :
			figCanvas.scrollToY( loc.y - area.height );
			break;
		case SWT.ARROW_LEFT :
			figCanvas.scrollToX( loc.x - area.width );
			break;
		case SWT.ARROW_RIGHT :
			figCanvas.scrollToX( loc.x + area.width );
	}
}
 
Example 2
Source File: ReportViewerKeyHandler.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private boolean scrollIncrement( GraphicalEditPart part, KeyEvent event )
{
	if ( ( event.stateMask & SWT.CONTROL ) == 0 )
	{
		return false;
	}
	if ( !( part.getViewer( ) instanceof DeferredGraphicalViewer ) )
	{
		return false;
	}
	DeferredGraphicalViewer viewer = (DeferredGraphicalViewer) part.getViewer( );
	FigureCanvas canvas = viewer.getFigureCanvas( );
	int code = event.keyCode;
	int increment = 0;
	if ( code == SWT.ARROW_RIGHT )
	{
		increment = canvas.getHorizontalBar( ).getSelection( )
				+ canvas.getHorizontalBar( ).getIncrement( );
	}
	else if ( code == SWT.ARROW_LEFT )
	{
		increment = canvas.getHorizontalBar( ).getSelection( )
				- canvas.getHorizontalBar( ).getIncrement( );
	}
	else if ( code == SWT.ARROW_DOWN )
	{
		increment = canvas.getVerticalBar( ).getSelection( )
				+ canvas.getVerticalBar( ).getIncrement( );
	}
	else if ( code == SWT.ARROW_UP )
	{
		increment = canvas.getVerticalBar( ).getSelection( )
				- canvas.getVerticalBar( ).getIncrement( );
	}

	if ( code == SWT.ARROW_RIGHT || code == SWT.ARROW_LEFT )
	{
		canvas.scrollToX( increment );
	}
	if ( code == SWT.ARROW_UP || code == SWT.ARROW_DOWN )
	{
		canvas.scrollToY( increment );
	}
	return true;

}