Class ScrollBar

java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.draw2d.ScrollBar
All Implemented Interfaces:
PropertyChangeListener, EventListener, IFigure, Orientable, PositionConstants
Direct Known Subclasses:
PuristicScrollPane.PuristicScrollBar

public class ScrollBar extends Figure implements Orientable, PropertyChangeListener
Provides for the scrollbars used by the ScrollPane. A ScrollBar is made up of five essential Figures: An 'Up' arrow button, a 'Down' arrow button, a draggable 'Thumb', a 'Pageup' button, and a 'Pagedown' button.
  • Field Details

    • MAX_FLAG

      protected static final int MAX_FLAG
      See Also:
    • thumbDragger

      protected ScrollBar.ThumbDragger thumbDragger
      Listens to mouse events on the scrollbar to take care of scrolling.
    • transposer

      protected final Transposer transposer
      Transposes from vertical to horizontal if needed.
  • Constructor Details

    • ScrollBar

      public ScrollBar()
      Constructs a ScrollBar. ScrollBar orientation is vertical by default. Call setHorizontal(boolean) with true to set horizontal orientation.
      Since:
      2.0
  • Method Details

    • createDefaultUpButton

      protected Clickable createDefaultUpButton()
      Creates the default 'Up' ArrowButton for the ScrollBar.
      Returns:
      the up button
      Since:
      2.0
    • createDefaultDownButton

      protected Clickable createDefaultDownButton()
      Creates the default 'Down' ArrowButton for the ScrollBar.
      Returns:
      the down button
      Since:
      2.0
    • createPageDown

      protected Clickable createPageDown()
      Creates the pagedown Figure for the Scrollbar.
      Returns:
      the page down figure
      Since:
      2.0
    • createPageUp

      protected Clickable createPageUp()
      Creates the pageup Figure for the Scrollbar.
      Returns:
      the page up figure
      Since:
      2.0
    • createDefaultThumb

      protected IFigure createDefaultThumb()
      Creates the Scrollbar's "thumb", the draggable Figure that indicates the Scrollbar's position.
      Returns:
      the thumb figure
      Since:
      2.0
    • getButtonUp

      protected IFigure getButtonUp()
      Returns the figure used as the up button.
      Returns:
      the up button
    • getButtonDown

      protected IFigure getButtonDown()
      Returns the figure used as the down button.
      Returns:
      the down button
    • getExtent

      public int getExtent()
      Returns the extent.
      Returns:
      the extent
      See Also:
    • getMinimum

      public int getMinimum()
      Returns the minumum value.
      Returns:
      the minimum
      See Also:
    • getMaximum

      public int getMaximum()
      Returns the maximum value.
      Returns:
      the maximum
      See Also:
    • getPageDown

      protected IFigure getPageDown()
      Returns the figure used for page down.
      Returns:
      the page down figure
    • getPageIncrement

      public int getPageIncrement()
      Returns the the amound the scrollbar will move when the page up or page down areas are pressed.
      Returns:
      the page increment
    • getPageUp

      protected IFigure getPageUp()
      Returns the figure used for page up.
      Returns:
      the page up figure
    • getRangeModel

      public RangeModel getRangeModel()
      Returns the range model for this scrollbar.
      Returns:
      the range model
    • getStepIncrement

      public int getStepIncrement()
      Returns the amount the scrollbar will move when the up or down arrow buttons are pressed.
      Returns:
      the step increment
    • getThumb

      protected IFigure getThumb()
      Returns the figure used as the scrollbar's thumb.
      Returns:
      the thumb figure
    • getValue

      public int getValue()
      Returns the current scroll position of the scrollbar.
      Returns:
      the current value
      See Also:
    • getValueRange

      protected int getValueRange()
      Returns the size of the range of allowable values.
      Returns:
      the value range
    • initialize

      protected void initialize()
      Initilization of the ScrollBar. Sets the Scrollbar to have a ScrollBarLayout with vertical orientation. Creates the Figures that make up the components of the ScrollBar.
      Since:
      2.0
    • isHorizontal

      public boolean isHorizontal()
      Returns true if this scrollbar is orientated horizontally, false otherwise.
      Returns:
      whether this scrollbar is horizontal
    • propertyChange

      public void propertyChange(PropertyChangeEvent event)
      Specified by:
      propertyChange in interface PropertyChangeListener
      See Also:
    • revalidate

      public void revalidate()
      Description copied from interface: IFigure
      Invalidates this figure and revalidates() its parent. If a figure does not have a parent, it will request a validation from it UpdateManager. Calling this method does not guarantee that a repaint will occur.
      Specified by:
      revalidate in interface IFigure
      Overrides:
      revalidate in class Figure
      See Also:
    • setDirection

      public void setDirection(int direction)
      Does nothing because this doesn't make sense for a scrollbar.
      Specified by:
      setDirection in interface Orientable
      Parameters:
      direction - The direction
      See Also:
    • setDownClickable

      public void setDownClickable(Clickable down)
      Sets the Clickable that represents the down arrow of the Scrollbar to down.
      Parameters:
      down - the down button
      Since:
      2.0
    • setUpClickable

      public void setUpClickable(Clickable up)
      Sets the Clickable that represents the up arrow of the Scrollbar to up.
      Parameters:
      up - the up button
      Since:
      2.0
    • setEnabled

      public void setEnabled(boolean value)
      Description copied from interface: IFigure
      Sets this IFigure to be enabled.
      Specified by:
      setEnabled in interface IFigure
      Overrides:
      setEnabled in class Figure
      Parameters:
      value - true if this IFigure should be enabled
      See Also:
    • setExtent

      public void setExtent(int ext)
      Sets the extent of the Scrollbar to ext
      Parameters:
      ext - the extent
      Since:
      2.0
    • setHorizontal

      public final void setHorizontal(boolean value)
      Sets the orientation of the ScrollBar. If true, the Scrollbar will have a horizontal orientation. If false, the scrollBar will have a vertical orientation.
      Parameters:
      value - true if the scrollbar should be horizontal
      Since:
      2.0
    • setMaximum

      public void setMaximum(int max)
      Sets the maximum position to max.
      Parameters:
      max - the maximum position
      Since:
      2.0
    • setMinimum

      public void setMinimum(int min)
      Sets the minimum position to min.
      Parameters:
      min - the minumum position
      Since:
      2.0
    • setOrientation

      public void setOrientation(int value)
      Description copied from interface: Orientable
      Sets the orientation. Can be either Orientable.HORIZONTAL or Orientable.VERTICAL.
      Specified by:
      setOrientation in interface Orientable
      Parameters:
      value - The orientation
      See Also:
    • setPageIncrement

      public void setPageIncrement(int increment)
      Sets the ScrollBar to scroll increment pixels when its pageup or pagedown buttons are pressed. (Note that the pageup and pagedown buttons are NOT the arrow buttons, they are the figures between the arrow buttons and the ScrollBar's thumb figure).
      Parameters:
      increment - the new page increment
      Since:
      2.0
    • setPageDown

      public void setPageDown(Clickable down)
      Sets the pagedown button to the passed Clickable. The pagedown button is the figure between the down arrow button and the ScrollBar's thumb figure.
      Parameters:
      down - the page down figure
      Since:
      2.0
    • setPageUp

      public void setPageUp(Clickable up)
      Sets the pageup button to the passed Clickable. The pageup button is the rectangular figure between the down arrow button and the ScrollBar's thumb figure.
      Parameters:
      up - the page up figure
      Since:
      2.0
    • setRangeModel

      public void setRangeModel(RangeModel rangeModel)
      Sets the ScrollBar's RangeModel to the passed value.
      Parameters:
      rangeModel - the new range model
      Since:
      2.0
    • setStepIncrement

      public void setStepIncrement(int increment)
      Sets the ScrollBar's step increment to the passed value. The step increment indicates how many pixels the ScrollBar will scroll when its up or down arrow button is pressed.
      Parameters:
      increment - the new step increment
      Since:
      2.0
    • setThumb

      public void setThumb(IFigure figure)
      Sets the ScrollBar's thumb to the passed Figure. The thumb is the draggable component of the ScrollBar that indicates the ScrollBar's position.
      Parameters:
      figure - the thumb figure
      Since:
      2.0
    • setValue

      public void setValue(int v)
      Sets the value of the Scrollbar to v
      Parameters:
      v - the new value
      Since:
      2.0
    • stepDown

      protected void stepDown()
      Causes the ScrollBar to scroll down (or right) by the value of its step increment.
      Since:
      2.0
    • stepUp

      protected void stepUp()
      Causes the ScrollBar to scroll up (or left) by the value of its step increment.
      Since:
      2.0