Eclipse Draw2d
2.1

org.eclipse.draw2d
Class FigureCanvas

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.Composite
                          |
                          +--org.eclipse.swt.widgets.Canvas
                                |
                                +--org.eclipse.draw2d.FigureCanvas
All Implemented Interfaces:
Drawable
Direct Known Subclasses:
MultiLineLabel

public class FigureCanvas
extends Canvas

A Canvas that contains Figures. TODO: Scrollbar visibility variables should be changed to constants.


Field Summary
static int ALWAYS
          Always show scrollbar
static int AUTOMATIC
          Automatically show scrollbar when needed
static int NEVER
          Never show scrollbar
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
FigureCanvas(Composite parent)
          Creates a new FigureCanvas with the given parent.
FigureCanvas(Composite parent, LightweightSystem lws)
          Constructs a new FigureCanvas with the given parent and LightweightSystem.
 
Method Summary
 Point computeSize(int wHint, int hHint, boolean changed)
           
 IFigure getContents()
           
 int getHorizontalScrollBarVisibility()
           
 LightweightSystem getLightweightSystem()
           
 int getVerticalScrollBarVisibility()
           
 Viewport getViewport()
          Returns the Viewport.
 void scrollSmoothTo(int x, int y)
          Scrolls in an animated way to the new x and y location.
 void scrollTo(int x, int y)
          Scrolls the contents to the new x and y location.
 void scrollToX(int hOffset)
          Scrolls the contents horizontally so that they are offset by hOffset.
 void scrollToY(int vOffset)
          Scrolls the contents vertically so that they are offset by vOffset.
 void setContents(IFigure figure)
          Sets the contents of the Viewport.
 void setHorizontalScrollBarVisibility(int v)
          Sets the horizontal scrollbar visibility.
 void setScrollBarVisibility(int both)
          Sets both the horizontal and vertical scrollbar visibility to the given value.
 void setVerticalScrollBarVisibility(int v)
          Sets the vertical scrollbar visibility.
 void setViewport(Viewport vp)
          Sets the Viewport.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getDisplay, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isDisposed, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getStyle, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NEVER

public static int NEVER
Never show scrollbar


AUTOMATIC

public static int AUTOMATIC
Automatically show scrollbar when needed


ALWAYS

public static int ALWAYS
Always show scrollbar

Constructor Detail

FigureCanvas

public FigureCanvas(Composite parent)
Creates a new FigureCanvas with the given parent.

Parameters:
parent - the parent

FigureCanvas

public FigureCanvas(Composite parent,
                    LightweightSystem lws)
Constructs a new FigureCanvas with the given parent and LightweightSystem.

Parameters:
parent - the parent
lws - the LightweightSystem
Method Detail

computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Overrides:
computeSize in class Composite
See Also:
Composite.computeSize(int, int, boolean)

getContents

public IFigure getContents()
Returns:
the contents of the Viewport.

getHorizontalScrollBarVisibility

public int getHorizontalScrollBarVisibility()
Returns:
the horizontal scrollbar visibility.

getLightweightSystem

public LightweightSystem getLightweightSystem()
Returns:
the LightweightSystem

getVerticalScrollBarVisibility

public int getVerticalScrollBarVisibility()
Returns:
the vertical scrollbar visibility.

getViewport

public Viewport getViewport()
Returns the Viewport. If it's null, a new one is created.

Returns:
the viewport

scrollSmoothTo

public void scrollSmoothTo(int x,
                           int y)
Scrolls in an animated way to the new x and y location.

Parameters:
x - the x coordinate to scroll to
y - the y coordinate to scroll to

scrollTo

public void scrollTo(int x,
                     int y)
Scrolls the contents to the new x and y location. If this scroll operation only consists of a vertical or horizontal scroll, a call will be made to scrollToY(int) or scrollToX(int), respectively, to increase performance.

Parameters:
x - the x coordinate to scroll to
y - the y coordinate to scroll to

scrollToX

public void scrollToX(int hOffset)
Scrolls the contents horizontally so that they are offset by hOffset.

Parameters:
hOffset - the new horizontal offset

scrollToY

public void scrollToY(int vOffset)
Scrolls the contents vertically so that they are offset by vOffset.

Parameters:
vOffset - the new vertical offset

setContents

public void setContents(IFigure figure)
Sets the contents of the Viewport.

Parameters:
figure - the new contents

setHorizontalScrollBarVisibility

public void setHorizontalScrollBarVisibility(int v)
Sets the horizontal scrollbar visibility. Possible values are AUTOMATIC, ALWAYS, and NEVER.

Parameters:
v - the new visibility

setScrollBarVisibility

public void setScrollBarVisibility(int both)
Sets both the horizontal and vertical scrollbar visibility to the given value. Possible values are AUTOMATIC, ALWAYS, and NEVER.

Parameters:
both - the new visibility

setVerticalScrollBarVisibility

public void setVerticalScrollBarVisibility(int v)
Sets the vertical scrollbar visibility. Possible values are AUTOMATIC, ALWAYS, and NEVER.

Parameters:
v - the new visibility

setViewport

public void setViewport(Viewport vp)
Sets the Viewport. The given Viewport must use "fake" scrolling. That is, it must be constructed using new Viewport(true).

Parameters:
vp - the new viewport

Eclipse Draw2d
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.