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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Scroll bar mode ALWAYS_OFF
    static final int
    Scroll bar mode ALWAYS_ON
    static final int
    Scroll bar mode AUTO
    static final int
    Bit mask for visible horizontal scroll bar
    static final int
    Bit mask for visible vertical scroll bar

    Fields inherited from class org.eclipse.swt.widgets.Control

    handle

    Fields inherited from class org.eclipse.swt.widgets.Widget

    nativeZoom
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScrollView(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 Type
    Method
    Description
    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.
    org.eclipse.swt.graphics.Rectangle
    computeTrim(int x, int y, int w, int h)
     
    final org.eclipse.swt.graphics.Point
    contentsToView(int x, int y)
    Transform (x,y) point from contents coordinates, to widget coordinates.
    int
    Transform X axis coordinates from contents to widgets.
    int
    Transform Y axis coordinates from contents to widgets.
    void
    ensureVisible(int px, int py)
    Scroll to ensure point(in contents coordinates) is visible.
    void
    ensureVisible(int xValue, int yValue, int width, int height, int align)
    Make rectangle (x,y,w,h, in contents coordinates) visible.
    org.eclipse.swt.graphics.Rectangle
     
    int
    Access method for the contentsHeight property.
    int
    Access method for the contentsWidth property.
    int
    Access method for the contentsX property.
    int
    Access method for the contentsY property.
    int
    Return auto scroll period.
    org.eclipse.swt.widgets.ScrollBar
     
    int
    Returns horizontal bar height even if bar isn't visible.
    int
    Return horizontal scroll bar increment, default:1
    int
    Access method for the hScrollBarMode property.
    int
    Returns the overview size at ratio 1:1.
    org.eclipse.swt.widgets.ScrollBar
     
    int
    Returns vertical bar width, even if bar isn't visible.
    org.eclipse.swt.widgets.Control
    Returns control used to display view (might not be this object).
    int
    Return the visible height of scroll view, might be > contentsHeight
    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.
    final org.eclipse.swt.graphics.Rectangle
    getVisiblePart(org.eclipse.swt.graphics.Rectangle rect)
    Returns the visible part for given rectangle.
    int
    Return int the visible width of scroll view, might be > contentsWidth().
    int
    Return vertical scroll bar increment, default:1
    int
    Access method for the vScrollBarMode property.
    boolean
    Determines if the dragAutoScroll property is true.
    boolean
    Returns whether the overview is enabled or not.
    boolean
    isVisible(int px, int py)
    Returns true if point is visible (expressed in contents coordinates).
    boolean
    isVisible(int xValue, int yValue, int width, int height)
    Returns true if rectangle if partially visible.
    void
     
    void
    replaceControlListener(org.eclipse.swt.events.ControlListener nlistener)
    Remove the local Listener and add the new listener.
    void
    replaceKeyListener(org.eclipse.swt.events.KeyListener nlistener)
    Remove the local Listener and add the new listener.
    void
    replaceMouseListener(org.eclipse.swt.events.MouseListener nlistener)
    Remove the local Listener and add the new listener.
    void
    replaceMouseMoveListener(org.eclipse.swt.events.MouseMoveListener nlistener)
    Remove the local Listener and add the new listener.
    void
    replacePaintListener(org.eclipse.swt.events.PaintListener nlistener)
    Remove the local Listener and add the new listener.
    void
    resizeContents(int width, int height)
    Change the size of the contents area.
    void
    scrollBy(int delataX, int deltaY)
     
    void
    setBackground(org.eclipse.swt.graphics.Color c)
     
    boolean
    setContentsPos(int xValue, int yValue)
    Change top left position of visible area.
    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.
    void
    setCursor(org.eclipse.swt.graphics.Cursor cursor)
     
    void
    setDragAutoScroll(boolean aDragAutoScroll)
    Sets the value of the dragAutoScroll property.
    void
    Change delay (in millisec) used for auto scroll feature.
    boolean
     
    void
    Change horizontal scroll bar increment, minimum:1.
    void
    setHScrollBarMode(int aHScrollBarMode)
    Sets the value of the hScrollBarMode property.
    void
    setOverviewEnabled(boolean value)
    Enable or disable overview feature.
    void
    setOverviewSize(int size)
    Change overview size (at ratio 1:1), default is 100
    void
     
    void
    Change vertical scroll bar increment, minimum:1.
    void
    setVScrollBarMode(int aVScrollBarMode)
    Sets the value of the vScrollBarMode property.
    final org.eclipse.swt.graphics.Point
    viewToContents(int x, int y)
    Transform (x,y) point in widget coordinates to contents coordinates.
    int
    Transform x in widget coordinates to contents coordinates
    int
    Transform y in widget coordinates to contents coordinates

    Methods 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, toString

    Methods inherited from class org.eclipse.swt.widgets.Scrollable

    getScrollbarsMode, setScrollbarsMode

    Methods 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, update

    Methods 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, setData

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.swt.graphics.Drawable

    isAutoScalable
  • Field Details

  • 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 composite
      style - 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 SWT
      mouseWheel - Flag to force scrollView to handles mouse wheel
  • Method Details

    • setFocus

      public boolean setFocus()
      Overrides:
      setFocus in class org.eclipse.swt.widgets.Composite
    • setCursor

      public void setCursor(org.eclipse.swt.graphics.Cursor cursor)
      Overrides:
      setCursor in class org.eclipse.swt.widgets.Control
    • getClientArea

      public org.eclipse.swt.graphics.Rectangle getClientArea()
      Overrides:
      getClientArea in class org.eclipse.swt.widgets.Scrollable
    • setBackground

      public void setBackground(org.eclipse.swt.graphics.Color c)
      Overrides:
      setBackground in class org.eclipse.swt.widgets.Control
    • setToolTipText

      public void setToolTipText(String text)
      Overrides:
      setToolTipText in class org.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:
      true if 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:
      redraw in class org.eclipse.swt.widgets.Control
    • scrollBy

      public void scrollBy(int delataX, int deltaY)
      Parameters:
      delataX - The delta in X
      deltaY - 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 position
      py - 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 position
      py - 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:
      getVerticalBar in class org.eclipse.swt.widgets.Scrollable
    • getHorizontalBar

      public org.eclipse.swt.widgets.ScrollBar getHorizontalBar()
      Overrides:
      getHorizontalBar in class org.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 foreground
      forHeight - height of foreground
      currHorVis - The current visibility state of horizontal scroll bar
      currVertvis - The current visibility state of vertical scroll bar
      Returns:
      true if visibility changed else false
    • 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:
      computeTrim in class org.eclipse.swt.widgets.Scrollable