Package org.eclipse.draw2d
Class FigureCanvas
- All Implemented Interfaces:
- Drawable
- Direct Known Subclasses:
- MultiLineLabel
A scrolling Canvas that contains 
Figures viewed through a
 Viewport. Call setContents(IFigure) to specify the root of
 the tree of Figures to be viewed through the Viewport.
 Normal procedure for using a FigureCanvas:
- Create a FigureCanvas.
- Create a Draw2d Figure and call setContents(IFigure). This Figure will be the top-level Figure of the Draw2d application.
- Required Styles (when using certain constructors):
- V_SCROLL, H_SCROLL, NO_REDRAW_RESIZE
- Optional Styles:
- DOUBLE_BUFFERED, RIGHT_TO_LEFT, LEFT_TO_RIGHT, NO_BACKGROUND, BORDER
Note: Only one of the styles RIGHT_TO_LEFT, LEFT_TO_RIGHT may be specified.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic intAlways show scrollbarstatic intAutomatically show scrollbar when neededstatic intNever show scrollbar
- 
Constructor SummaryConstructorsConstructorDescriptionFigureCanvas(int style, Composite parent) Constructor which uses the given styles verbatim.FigureCanvas(int style, Composite parent, LightweightSystem lws) Constructor taking a lightweight system and SWT style, which is used verbatim.FigureCanvas(Composite parent) Creates a new FigureCanvas with the given parent and theDEFAULT_STYLES.FigureCanvas(Composite parent, int style) Constructor which applies the default styles plus any optional styles indicated.FigureCanvas(Composite parent, int style, LightweightSystem lws) ConstructorFigureCanvas(Composite parent, LightweightSystem lws) Constructs a new FigureCanvas with the given parent and LightweightSystem, using theDEFAULT_STYLES.
- 
Method SummaryModifier and TypeMethodDescriptioncomputeSize(int wHint, int hHint, boolean changed) getFont()intintReturns the Viewport.voidscrollSmoothTo(int x, int y) Scrolls in an animated way to the new x and y location.voidscrollTo(int x, int y) Scrolls the contents to the new x and y location.voidscrollToX(int hOffset) Scrolls the contents horizontally so that they are offset byhOffset.voidscrollToY(int vOffset) Scrolls the contents vertically so that they are offset byvOffset.voidSets the given border on the LightweightSystem's root figure.voidsetContents(IFigure figure) Sets the contents of theViewport.voidvoidSets the horizontal scrollbar visibility.voidsetScrollBarVisibility(int both) Sets both the horizontal and vertical scrollbar visibility to the given value.voidSets the vertical scrollbar visibility.voidsetViewport(Viewport vp) Sets the Viewport.Methods inherited from class org.eclipse.swt.widgets.CanvasdrawBackground, getCaret, getIME, scroll, setCaret, setIMEMethods inherited from class org.eclipse.swt.widgets.Compositechanged, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, redraw, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class org.eclipse.swt.widgets.ScrollablecomputeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsModeMethods inherited from class org.eclipse.swt.widgets.ControladdControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateMethods inherited from class org.eclipse.swt.widgets.WidgetaddDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setDataMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.swt.graphics.DrawableisAutoScalable
- 
Field Details- 
NEVERpublic static int NEVERNever show scrollbar
- 
AUTOMATICpublic static int AUTOMATICAutomatically show scrollbar when needed
- 
ALWAYSpublic static int ALWAYSAlways show scrollbar
 
- 
- 
Constructor Details- 
FigureCanvasCreates a new FigureCanvas with the given parent and theDEFAULT_STYLES.- Parameters:
- parent- the parent
 
- 
FigureCanvasConstructor which applies the default styles plus any optional styles indicated.- Parameters:
- parent- the parent composite
- style- see the class javadoc for optional styles
- Since:
- 3.1
 
- 
FigureCanvasConstructor which uses the given styles verbatim. Certain styles must be used with this class. Refer to the class javadoc for more details.- Parameters:
- style- see the class javadoc for required and optional styles
- parent- the parent composite
- Since:
- 3.4
 
- 
FigureCanvasConstructs a new FigureCanvas with the given parent and LightweightSystem, using theDEFAULT_STYLES.- Parameters:
- parent- the parent
- lws- the LightweightSystem
 
- 
FigureCanvasConstructor taking a lightweight system and SWT style, which is used verbatim. Certain styles must be used with this class. Refer to the class javadoc for more details.- Parameters:
- style- see the class javadoc for required and optional styles
- parent- the parent composite
- lws- the LightweightSystem
- Since:
- 3.4
 
- 
FigureCanvasConstructor- Parameters:
- parent- the parent composite
- style- look at class javadoc for valid styles
- lws- the lightweight system
- Since:
- 3.1
 
 
- 
- 
Method Details- 
computeSize- Overrides:
- computeSizein class- Composite
- See Also:
 
- 
getContents- Returns:
- the contents of the Viewport.
 
- 
getFont
- 
getHorizontalScrollBarVisibilitypublic int getHorizontalScrollBarVisibility()- Returns:
- the horizontal scrollbar visibility.
 
- 
getLightweightSystem- Returns:
- the LightweightSystem
 
- 
getVerticalScrollBarVisibilitypublic int getVerticalScrollBarVisibility()- Returns:
- the vertical scrollbar visibility.
 
- 
getViewportReturns the Viewport. If it'snull, a new one is created.- Returns:
- the viewport
 
- 
scrollSmoothTopublic 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
 
- 
scrollTopublic 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 toscrollToY(int)orscrollToX(int), respectively, to increase performance.- Parameters:
- x- the x coordinate to scroll to
- y- the y coordinate to scroll to
 
- 
scrollToXpublic void scrollToX(int hOffset) Scrolls the contents horizontally so that they are offset byhOffset.- Parameters:
- hOffset- the new horizontal offset
 
- 
scrollToYpublic void scrollToY(int vOffset) Scrolls the contents vertically so that they are offset byvOffset.- Parameters:
- vOffset- the new vertical offset
 
- 
setBorderSets the given border on the LightweightSystem's root figure.- Parameters:
- border- The new border
 
- 
setContentsSets the contents of theViewport.- Parameters:
- figure- the new contents
 
- 
setFont
- 
setHorizontalScrollBarVisibilitypublic void setHorizontalScrollBarVisibility(int v) - Parameters:
- v- the new visibility
 
- 
setScrollBarVisibilitypublic void setScrollBarVisibility(int both) Sets both the horizontal and vertical scrollbar visibility to the given value. Possible values areAUTOMATIC,ALWAYS, andNEVER.- Parameters:
- both- the new visibility
 
- 
setVerticalScrollBarVisibilitypublic void setVerticalScrollBarVisibility(int v) - Parameters:
- v- the new visibility
 
- 
setViewportSets the Viewport. The given Viewport must use "fake" scrolling. That is, it must be constructed usingnew Viewport(true).- Parameters:
- vp- the new viewport
 
 
-