Class ScrollPane

java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.draw2d.ScrollPane
All Implemented Interfaces:
IFigure
Direct Known Subclasses:
PuristicScrollPane

public class ScrollPane extends Figure
A class which implements automatic horizontal and/or vertical scrolling for a single IFigure child.

ScrollBar visibilites are represented by integer class constants:

  • NEVER: Never show the ScrollBar
  • AUTOMATIC: Show as needed, when the ScrollPane can no longer contain its view
  • ALWAYS: Always show the ScrollBar
To use, instantiate a ScrollPane object and call its setView(IFigure) method passing the IFigure that is desired to have scrolling ability.
  • Field Details

    • NEVER

      public static final int NEVER
      Constant indicating to never show the ScrollBar
      See Also:
    • AUTOMATIC

      public static final int AUTOMATIC
      Constant indicating to show as needed, when the ScrollPane can't contain its view
      See Also:
    • ALWAYS

      public static final int ALWAYS
      Constant indicating to always show the ScrollBar
      See Also:
    • viewport

      protected Viewport viewport
      The viewport being scrolled
    • hBar

      protected ScrollBar hBar
      The horizontal scrollbar
    • vBar

      protected ScrollBar vBar
      The vertical scrollbar
  • Constructor Details

    • ScrollPane

      public ScrollPane()
      Constructs a new ScrollPane with a ScrollPaneLayout.
      Since:
      2.0
  • Method Details

    • createHorizontalScrollBar

      protected void createHorizontalScrollBar()
      Creates a new horizontally oriented ScrollBar and adds it to this ScrollPane.
      Since:
      2.0
    • createViewport

      protected void createViewport()
      Creates a new Viewport and adds it to this ScrollPane.
      Since:
      2.0
    • createVerticalScrollBar

      protected void createVerticalScrollBar()
      Creates a new vertically oriented ScrollBar and adds it to this ScrollPane.
      Since:
      2.0
    • getHorizontalScrollBar

      public ScrollBar getHorizontalScrollBar()
      Returns the ScrollPane's horizontal ScrollBar.
      Returns:
      the horizontal scrollbar
      Since:
      2.0
    • getHorizontalScrollBarVisibility

      public int getHorizontalScrollBarVisibility()
      Returns the visibility of the ScrollPane's horizontal ScrollBar. These are represented by the integer class constants NEVER, AUTOMATIC, and ALWAYS. The default is AUTOMATIC.
      Returns:
      the visiblity of the horizontal scrollbar
      Since:
      2.0
    • getVerticalScrollBar

      public ScrollBar getVerticalScrollBar()
      Returns the ScrollPane's vertical ScrollBar.
      Returns:
      teh vertical scrollbar
      Since:
      2.0
    • getVerticalScrollBarVisibility

      public int getVerticalScrollBarVisibility()
      Returns the visibility of the ScrollPane's vertical ScrollBar. These are represented by the integer class constants NEVER, AUTOMATIC, and ALWAYS. The default is AUTOMATIC.
      Returns:
      the visibility of the vertical scrollbar
      Since:
      2.0
    • getContents

      public IFigure getContents()
      Returns the contents of the viewport.
      Returns:
      the contents of the viewport
    • getView

      public IFigure getView()
      Deprecated.
      use getContents()
      Returns the ScrollPane's view. The view is the IFigure that is the contents of the ScrollPane.
      Returns:
      the contents
      Since:
      2.0
    • getViewport

      public Viewport getViewport()
      Returns the ScrollPane's Viewport.
      Returns:
      the viewport
      Since:
      2.0
    • isOpaque

      public boolean isOpaque()
      Returns true because ScrollPanes are always opaque.
      Specified by:
      isOpaque in interface IFigure
      Overrides:
      isOpaque in class Figure
      Returns:
      true if this IFigure is opaque
      See Also:
    • scrollHorizontalTo

      public void scrollHorizontalTo(int x)
      Scrolls the Scrollpane horizontally x pixels from its left-most position.
      Parameters:
      x - the amount to scroll horizontally
      Since:
      2.0
    • scrollTo

      public void scrollTo(Point location)
      Scrolls the Scrollpane horizontally from its left-most position by location.x pixels and vertically from its top-most position by location.y pixels.
      Parameters:
      location - the point to scroll to
      Since:
      2.0
    • scrollVerticalTo

      public void scrollVerticalTo(int y)
      Scrolls the Scrollpane vertically y pixels from its top-most position.
      Parameters:
      y - the amount to scroll vertically
      Since:
      2.0
    • setContents

      public void setContents(IFigure figure)
      Sets the contents of the current viewport.
      Parameters:
      figure - the contents of the viewport
    • setHorizontalScrollBar

      public void setHorizontalScrollBar(ScrollBar bar)
      Sets the ScrollPane's horizontal ScrollBar to the passed ScrollBar.
      Parameters:
      bar - the new horizontal scrollbar
      Since:
      2.0
    • setHorizontalScrollBarVisibility

      public void setHorizontalScrollBarVisibility(int v)
      Sets the horizontal ScrollBar visibility of the ScrollPane to the passed value. These are represented by the integer class constants NEVER, AUTOMATIC, and ALWAYS. The default is AUTOMATIC.
      Parameters:
      v - the new horizontal visibility
      Since:
      2.0
    • setScrollBarVisibility

      public void setScrollBarVisibility(int v)
      Sets both the horizontal and vertical ScrollBar visibilities of the ScrollPane to the passed value. These are represented by the integer class constants NEVER, AUTOMATIC, and ALWAYS. The default is AUTOMATIC.
      Parameters:
      v - the new vertical and horizontal visibility
      Since:
      2.0
    • setVerticalScrollBar

      public void setVerticalScrollBar(ScrollBar bar)
      Sets the ScrollPane's vertical ScrollBar to the passed Scrollbar.
      Parameters:
      bar - the new vertical scrollbar
      Since:
      2.0
    • setVerticalScrollBarVisibility

      public void setVerticalScrollBarVisibility(int v)
      Sets the vertical ScrollBar visibility of the ScrollPane to the passed value. These are represented by the integer class constants NEVER, AUTOMATIC, and ALWAYS. The default is AUTOMATIC.
      Parameters:
      v - the new vertical scrollbar visibility
      Since:
      2.0
    • setView

      public void setView(IFigure figure)
      Deprecated.
      call setContents(IFigure) instead
      Sets the ScrollPane's view to the passed IFigure. The view is the top-level IFigure which represents the contents of the ScrollPane.
      Parameters:
      figure - the new contents
      Since:
      2.0
    • setViewport

      public void setViewport(Viewport vp)
      Sets the ScrollPane's Viewport to the passed value.
      Parameters:
      vp - the new viewport
      Since:
      2.0
    • validate

      public void validate()
      Description copied from interface: IFigure
      Indicates that this figure should make itself valid. Validation includes invoking layout on a LayoutManager if present, and then validating all children figures. Default validation uses pre-order, depth-first ordering.
      Specified by:
      validate in interface IFigure
      Overrides:
      validate in class Figure
      See Also: