Class ScrollView
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.tracecompass.tmf.ui.views.uml2sd.ScrollView
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
- Direct Known Subclasses:
SDWidget,TimeCompressionBar
public class ScrollView
extends org.eclipse.swt.widgets.Composite
ScrollView widget provides a scrolling area with on-demand scroll bars.
Overview scrollable panel can be used (@see setOverviewEnabled()).
- Version:
- 1.0
- Author:
- Eric Miravete
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intScroll bar mode ALWAYS_OFFstatic final intScroll bar mode ALWAYS_ONstatic final intScroll bar mode AUTOstatic final intBit mask for visible horizontal scroll barstatic final intBit mask for visible vertical scroll barFields inherited from class org.eclipse.swt.widgets.Control
handleFields inherited from class org.eclipse.swt.widgets.Widget
nativeZoom -
Constructor Summary
ConstructorsConstructorDescriptionScrollView(org.eclipse.swt.widgets.Composite c, int style) Create a ScrollView, child of composite c.ScrollView(org.eclipse.swt.widgets.Composite c, int style, boolean mouseWheel) Create a ScrollView, child of composite c. -
Method Summary
Modifier and TypeMethodDescriptionintcomputeBarVisibility(int forWidth, int forHeight, boolean currHorVis, boolean currVertvis) Compute visibility of vertical/horizontal bar using given width/height and current visibility (i.e.org.eclipse.swt.graphics.RectanglecomputeTrim(int x, int y, int w, int h) final org.eclipse.swt.graphics.PointcontentsToView(int x, int y) Transform (x,y) point from contents coordinates, to widget coordinates.intcontentsToViewX(int x) Transform X axis coordinates from contents to widgets.intcontentsToViewY(int y) Transform Y axis coordinates from contents to widgets.voidensureVisible(int px, int py) Scroll to ensure point(in contents coordinates) is visible.voidensureVisible(int xValue, int yValue, int width, int height, int align) Make rectangle (x,y,w,h, in contents coordinates) visible.org.eclipse.swt.graphics.RectangleintAccess method for the contentsHeight property.intAccess method for the contentsWidth property.intAccess method for the contentsX property.intAccess method for the contentsY property.intReturn auto scroll period.org.eclipse.swt.widgets.ScrollBarintReturns horizontal bar height even if bar isn't visible.intReturn horizontal scroll bar increment, default:1intAccess method for the hScrollBarMode property.intReturns the overview size at ratio 1:1.org.eclipse.swt.widgets.ScrollBarintReturns vertical bar width, even if bar isn't visible.org.eclipse.swt.widgets.ControlReturns control used to display view (might not be this object).intReturn the visible height of scroll view, might be > contentsHeightorg.eclipse.swt.graphics.RectanglegetVisiblePart(int xValue, int yValue, int width, int height) Returns visible part of rectangle, or null if rectangle is not visible.final org.eclipse.swt.graphics.RectanglegetVisiblePart(org.eclipse.swt.graphics.Rectangle rect) Returns the visible part for given rectangle.intReturn int the visible width of scroll view, might be > contentsWidth().intReturn vertical scroll bar increment, default:1intAccess method for the vScrollBarMode property.booleanDetermines if the dragAutoScroll property is true.booleanReturns whether the overview is enabled or not.booleanisVisible(int px, int py) Returns true if point is visible (expressed in contents coordinates).booleanisVisible(int xValue, int yValue, int width, int height) Returns true if rectangle if partially visible.voidredraw()voidreplaceControlListener(org.eclipse.swt.events.ControlListener nlistener) Remove the local Listener and add the new listener.voidreplaceKeyListener(org.eclipse.swt.events.KeyListener nlistener) Remove the local Listener and add the new listener.voidreplaceMouseListener(org.eclipse.swt.events.MouseListener nlistener) Remove the local Listener and add the new listener.voidreplaceMouseMoveListener(org.eclipse.swt.events.MouseMoveListener nlistener) Remove the local Listener and add the new listener.voidreplacePaintListener(org.eclipse.swt.events.PaintListener nlistener) Remove the local Listener and add the new listener.voidresizeContents(int width, int height) Change the size of the contents area.voidscrollBy(int delataX, int deltaY) voidsetBackground(org.eclipse.swt.graphics.Color c) booleansetContentsPos(int xValue, int yValue) Change top left position of visible area.voidsetCornerControl(org.eclipse.swt.widgets.Control control) Change the control used in the bottom right corner (between two scrollbar), if control is null reset previous corner control.voidsetCursor(org.eclipse.swt.graphics.Cursor cursor) voidsetDragAutoScroll(boolean aDragAutoScroll) Sets the value of the dragAutoScroll property.voidsetDragAutoScrollPeriod(int period) Change delay (in millisec) used for auto scroll feature.booleansetFocus()voidsetHScrollBarIncrement(int inc) Change horizontal scroll bar increment, minimum:1.voidsetHScrollBarMode(int aHScrollBarMode) Sets the value of the hScrollBarMode property.voidsetOverviewEnabled(boolean value) Enable or disable overview feature.voidsetOverviewSize(int size) Change overview size (at ratio 1:1), default is 100voidsetToolTipText(String text) voidsetVScrollBarIncrement(int inc) Change vertical scroll bar increment, minimum:1.voidsetVScrollBarMode(int aVScrollBarMode) Sets the value of the vScrollBarMode property.final org.eclipse.swt.graphics.PointviewToContents(int x, int y) Transform (x,y) point in widget coordinates to contents coordinates.intviewToContentsX(int x) Transform x in widget coordinates to contents coordinatesintviewToContentsY(int y) Transform y in widget coordinates to contents coordinatesMethods inherited from class org.eclipse.swt.widgets.Composite
changed, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
getScrollbarsMode, setScrollbarsModeMethods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, 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, setBackgroundImage, setBounds, setBounds, setCapture, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateMethods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, reskin, setData, setDataMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.swt.graphics.Drawable
isAutoScalable
-
Field Details
-
AUTO
public static final int AUTOScroll bar mode AUTO- See Also:
-
ALWAYS_ON
public static final int ALWAYS_ONScroll bar mode ALWAYS_ON- See Also:
-
ALWAYS_OFF
public static final int ALWAYS_OFFScroll bar mode ALWAYS_OFF- See Also:
-
VBAR
public static final int VBARBit mask for visible vertical scroll bar- See Also:
-
HBAR
public static final int HBARBit mask for visible horizontal scroll bar- See Also:
-
-
Constructor Details
-
ScrollView
public ScrollView(org.eclipse.swt.widgets.Composite c, int style) Create a ScrollView, child of composite c. Both scroll bar have the mode AUTO. Auto scroll feature is enabled using a delay of 250ms. Overview feature is not enabled by default (use setOverviewEnabled()).- Parameters:
c- The parent compositestyle- The SWT style bits @see SWT
-
ScrollView
public ScrollView(org.eclipse.swt.widgets.Composite c, int style, boolean mouseWheel) Create a ScrollView, child of composite c. Both scroll bar have the mode AUTO. Auto scroll feature is enabled using a delay of 250ms. Overview feature is not enabled by default (use setOverviewEnabled()).- Parameters:
c- The parent composite.style- The SWT style bits @see SWTmouseWheel- Flag to force scrollView to handles mouse wheel
-
-
Method Details
-
setFocus
public boolean setFocus()- Overrides:
setFocusin classorg.eclipse.swt.widgets.Composite
-
setCursor
public void setCursor(org.eclipse.swt.graphics.Cursor cursor) - Overrides:
setCursorin classorg.eclipse.swt.widgets.Control
-
getClientArea
public org.eclipse.swt.graphics.Rectangle getClientArea()- Overrides:
getClientAreain classorg.eclipse.swt.widgets.Scrollable
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color c) - Overrides:
setBackgroundin classorg.eclipse.swt.widgets.Control
-
setToolTipText
- Overrides:
setToolTipTextin classorg.eclipse.swt.widgets.Control
-
replaceControlListener
public void replaceControlListener(org.eclipse.swt.events.ControlListener nlistener) Remove the local Listener and add the new listener.- Parameters:
nlistener- the new listener
-
replaceKeyListener
public void replaceKeyListener(org.eclipse.swt.events.KeyListener nlistener) Remove the local Listener and add the new listener.- Parameters:
nlistener- the new listener
-
replaceMouseListener
public void replaceMouseListener(org.eclipse.swt.events.MouseListener nlistener) Remove the local Listener and add the new listener.- Parameters:
nlistener- the new listener
-
replaceMouseMoveListener
public void replaceMouseMoveListener(org.eclipse.swt.events.MouseMoveListener nlistener) Remove the local Listener and add the new listener.- Parameters:
nlistener- the new listener
-
replacePaintListener
public void replacePaintListener(org.eclipse.swt.events.PaintListener nlistener) Remove the local Listener and add the new listener.- Parameters:
nlistener- the new listener
-
getContentsHeight
public int getContentsHeight()Access method for the contentsHeight property.- Returns:
- the current value of the contentsHeight property
-
getContentsWidth
public int getContentsWidth()Access method for the contentsWidth property.- Returns:
- the current value of the contentsWidth property
-
getContentsX
public int getContentsX()Access method for the contentsX property.- Returns:
- the current value of the contentsX property
-
getContentsY
public int getContentsY()Access method for the contentsY property.- Returns:
- the current value of the contentsY property
-
isDragAutoScroll
public boolean isDragAutoScroll()Determines if the dragAutoScroll property is true.- Returns:
trueif the dragAutoScroll property is true
-
setDragAutoScroll
public void setDragAutoScroll(boolean aDragAutoScroll) Sets the value of the dragAutoScroll property.- Parameters:
aDragAutoScroll- the new value of the dragAutoScroll property
-
setDragAutoScrollPeriod
public void setDragAutoScrollPeriod(int period) Change delay (in millisec) used for auto scroll feature.- Parameters:
period- new period between to auto scroll
-
getDragAutoScrollPeriod
public int getDragAutoScrollPeriod()Return auto scroll period.- Returns:
- The period
-
getHScrollBarMode
public int getHScrollBarMode()Access method for the hScrollBarMode property.- Returns:
- the current value of the hScrollBarMode property
-
setHScrollBarMode
public void setHScrollBarMode(int aHScrollBarMode) Sets the value of the hScrollBarMode property.- Parameters:
aHScrollBarMode- the new value of the hScrollBarMode property
-
getVScrollBarMode
public int getVScrollBarMode()Access method for the vScrollBarMode property.- Returns:
- the current value of the vScrollBarMode property
-
setVScrollBarMode
public void setVScrollBarMode(int aVScrollBarMode) Sets the value of the vScrollBarMode property.- Parameters:
aVScrollBarMode- the new value of the vScrollBarMode property
-
getHScrollBarIncrement
public int getHScrollBarIncrement()Return horizontal scroll bar increment, default:1- Returns:
- The increment
-
getVScrollBarIncrement
public int getVScrollBarIncrement()Return vertical scroll bar increment, default:1- Returns:
- The increment
-
setHScrollBarIncrement
public void setHScrollBarIncrement(int inc) Change horizontal scroll bar increment, minimum:1. Page increment is always set to visible width.- Parameters:
inc- Increment value to set
-
setVScrollBarIncrement
public void setVScrollBarIncrement(int inc) Change vertical scroll bar increment, minimum:1. Page increment is always set to visible height.- Parameters:
inc- Increment value to set
-
setOverviewEnabled
public void setOverviewEnabled(boolean value) Enable or disable overview feature. Enabling overview, dispose and replace existing corner control by a button. Clicking in it open overview, move mouse cursor holding button to move scroll view and release button to hide overview. Tip: hold control and/or shift key while moving mouse when overview is open made fine scroll.- Parameters:
value- true to engage overview feature
-
setOverviewSize
public void setOverviewSize(int size) Change overview size (at ratio 1:1), default is 100- Parameters:
size- The new size
-
isOverviewEnabled
public boolean isOverviewEnabled()Returns whether the overview is enabled or not.- Returns:
- true is overview feature is enabled
-
getOverviewSize
public int getOverviewSize()Returns the overview size at ratio 1:1.- Returns:
- current overview size at ratio 1:1
-
getViewControl
public org.eclipse.swt.widgets.Control getViewControl()Returns control used to display view (might not be this object). Use this control to add/remove listener on the draw area.- Returns:
- control used to display view (might not be this object).
-
resizeContents
public void resizeContents(int width, int height) Change the size of the contents area.- Parameters:
width- new width of the area.height- new height of the area.
-
redraw
public void redraw()- Overrides:
redrawin classorg.eclipse.swt.widgets.Control
-
scrollBy
public void scrollBy(int delataX, int deltaY) - Parameters:
delataX- The delta in XdeltaY- the delta in Y
-
ensureVisible
public void ensureVisible(int px, int py) Scroll to ensure point(in contents coordinates) is visible.- Parameters:
px- Point's x positionpy- Point's y position
-
ensureVisible
public void ensureVisible(int xValue, int yValue, int width, int height, int align) Make rectangle (x,y,w,h, in contents coordinates) visible. if rectangle cannot be completely visible, use align flags.- Parameters:
xValue- x contents coordinates of rectangle.yValue- y contents coordinates of rectangle.width- width of rectangle.height- height of rectangle.align- bit or'ed SWT flag like SWT.LEFT,RIGHT,CENTER,TOP,BOTTOM,VERTICAL used only for bigger rectangle than visible area. By default CENTER/VERTICAL
-
isVisible
public boolean isVisible(int px, int py) Returns true if point is visible (expressed in contents coordinates).- Parameters:
px- Point's x positionpy- Point's y position- Returns:
- true if point is visible (expressed in contents coordinates)
-
isVisible
public boolean isVisible(int xValue, int yValue, int width, int height) Returns true if rectangle if partially visible.- Parameters:
xValue- x contents coordinates of rectangle.yValue- y contents coordinates of rectangle.width- width of rectangle.height- height of rectangle.- Returns:
- true if rectangle if partially visible.
-
getVisiblePart
public org.eclipse.swt.graphics.Rectangle getVisiblePart(int xValue, int yValue, int width, int height) Returns visible part of rectangle, or null if rectangle is not visible. Rectangle is expressed in contents coordinates.- Parameters:
xValue- x contents coordinates of rectangle.yValue- y contents coordinates of rectangle.width- width of rectangle.height- height of rectangle.- Returns:
- visible part of rectangle, or null if rectangle is not visible.
-
getVisiblePart
public final org.eclipse.swt.graphics.Rectangle getVisiblePart(org.eclipse.swt.graphics.Rectangle rect) Returns the visible part for given rectangle.- Parameters:
rect- A rectangle- Returns:
- gets visible part of rectangle (or
null)
-
setContentsPos
public boolean setContentsPos(int xValue, int yValue) Change top left position of visible area. Check if the given point is inside contents area.- Parameters:
xValue- x contents coordinates of visible area.yValue- y contents coordinates of visible area.- Returns:
- true if view really moves
-
getVerticalBar
public org.eclipse.swt.widgets.ScrollBar getVerticalBar()- Overrides:
getVerticalBarin classorg.eclipse.swt.widgets.Scrollable
-
getHorizontalBar
public org.eclipse.swt.widgets.ScrollBar getHorizontalBar()- Overrides:
getHorizontalBarin classorg.eclipse.swt.widgets.Scrollable
-
computeBarVisibility
public int computeBarVisibility(int forWidth, int forHeight, boolean currHorVis, boolean currVertvis) Compute visibility of vertical/horizontal bar using given width/height and current visibility (i.e. is bar size are already in for_xxx)- Parameters:
forWidth- width of foregroundforHeight- height of foregroundcurrHorVis- The current visibility state of horizontal scroll barcurrVertvis- The current visibility state of vertical scroll bar- Returns:
trueif visibility changed elsefalse
-
setCornerControl
public void setCornerControl(org.eclipse.swt.widgets.Control control) Change the control used in the bottom right corner (between two scrollbar), if control is null reset previous corner control. This control is visible only if at least one scrollbar is visible. Given control will be disposed by ScrollView, at dispose() time, at next setCornetControl() call or when calling setOverviewEnabled(). Pay attention calling this reset overview feature until setOverviewEnabled(true) if called.- Parameters:
control- The control for the overview
-
viewToContents
public final org.eclipse.swt.graphics.Point viewToContents(int x, int y) Transform (x,y) point in widget coordinates to contents coordinates.- Parameters:
x- The x widget coordinate.y- The y widget coordinate.- Returns:
- org.eclipse.swt.graphics.Point with content coordinates.
-
viewToContentsX
public int viewToContentsX(int x) Transform x in widget coordinates to contents coordinates- Parameters:
x- The y widget coordinate.- Returns:
- the x content coordinate.
-
viewToContentsY
public int viewToContentsY(int y) Transform y in widget coordinates to contents coordinates- Parameters:
y- The y widget coordinate.- Returns:
- the y content coordinate.
-
contentsToView
public final org.eclipse.swt.graphics.Point contentsToView(int x, int y) Transform (x,y) point from contents coordinates, to widget coordinates.- Parameters:
x- The x content coordinate.y- The y content coordinate.- Returns:
- coordinates widget area as.
-
contentsToViewX
public int contentsToViewX(int x) Transform X axis coordinates from contents to widgets.- Parameters:
x- contents coordinate to transform.- Returns:
- x coordinate in widget area
-
contentsToViewY
public int contentsToViewY(int y) Transform Y axis coordinates from contents to widgets.- Parameters:
y- contents coordinate to transform- Returns:
- y coordinate in widget area
-
getVisibleHeight
public int getVisibleHeight()Return the visible height of scroll view, might be > contentsHeight- Returns:
- the visible height of scroll view, might be > contentsHeight()
-
getVisibleWidth
public int getVisibleWidth()Return int the visible width of scroll view, might be > contentsWidth().- Returns:
- int the visible width of scroll view, might be > contentsWidth()
-
getVerticalBarWidth
public int getVerticalBarWidth()Returns vertical bar width, even if bar isn't visible.- Returns:
- vertical bar width, even if bar isn't visible
-
getHorizontalBarHeight
public int getHorizontalBarHeight()Returns horizontal bar height even if bar isn't visible.- Returns:
- horizontal bar height even if bar isn't visible
-
computeTrim
public org.eclipse.swt.graphics.Rectangle computeTrim(int x, int y, int w, int h) - Overrides:
computeTrimin classorg.eclipse.swt.widgets.Scrollable
-