1. /*
  2. * @(#)Scrollable.java 1.5 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing;
  8. import java.awt.Dimension;
  9. import java.awt.Rectangle;
  10. /**
  11. * An interface that provides information to a scrolling container
  12. * like JScrollPane. A complex component that's likely to be used
  13. * as a viewin a JScrollPane viewport (or other scrolling container)
  14. * should implement this interface.
  15. *
  16. * @see JViewport
  17. * @see JScrollPane
  18. * @see JScrollBar
  19. * @version 1.5 11/29/01
  20. * @author Hans Muller
  21. */
  22. public interface Scrollable
  23. {
  24. /**
  25. * Returns the preferred size of the viewport for a view component.
  26. * For example the preferredSize of a JList component is the size
  27. * required to acommodate all of the cells in its list however the
  28. * value of preferredScrollableViewportSize is the size required for
  29. * JList.getVisibleRowCount() rows. A component without any properties
  30. * that would effect the viewport size should just return
  31. * getPreferredSize() here.
  32. *
  33. * @return The preferredSize of a JViewport whose view is this Scrollable.
  34. * @see JViewport#getPreferredSize
  35. */
  36. Dimension getPreferredScrollableViewportSize();
  37. /**
  38. * Components that display logical rows or columns should compute
  39. * the scroll increment that will completely expose one new row
  40. * or column, depending on the value of orientation. Ideally,
  41. * components should handle a partially exposed row or column by
  42. * returning the distance required to completely expose the item.
  43. * <p>
  44. * Scrolling containers, like JScrollPane, will use this method
  45. * each time the user requests a unit scroll.
  46. *
  47. * @param visibleRect The view area visible within the viewport
  48. * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  49. * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  50. * @return The "unit" increment for scrolling in the specified direction
  51. * @see JScrollBar#setUnitIncrement
  52. */
  53. int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction);
  54. /**
  55. * Components that display logical rows or columns should compute
  56. * the scroll increment that will completely expose one block
  57. * of rows or columns, depending on the value of orientation.
  58. * <p>
  59. * Scrolling containers, like JScrollPane, will use this method
  60. * each time the user requests a block scroll.
  61. *
  62. * @param visibleRect The view area visible within the viewport
  63. * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  64. * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  65. * @return The "block" increment for scrolling in the specified direction.
  66. * @see JScrollBar#setBlockIncrement
  67. */
  68. int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
  69. /**
  70. * Return true if a viewport should always force the width of this
  71. * Scrollable to match the width of the viewport. For example a noraml
  72. * text view that supported line wrapping would return true here, since it
  73. * would be undesirable for wrapped lines to disappear beyond the right
  74. * edge of the viewport. Note that returning true for a Scrollable
  75. * whose ancestor is a JScrollPane effectively disables horizontal
  76. * scrolling.
  77. * <p>
  78. * Scrolling containers, like JViewport, will use this method each
  79. * time they are validated.
  80. *
  81. * @return True if a viewport should force the Scrollables width to match its own.
  82. */
  83. boolean getScrollableTracksViewportWidth();
  84. /**
  85. * Return true if a viewport should always force the height of this
  86. * Scrollable to match the height of the viewport. For example a
  87. * columnar text view that flowed text in left to right columns
  88. * could effectively disable vertical scrolling by returning
  89. * true here.
  90. * <p>
  91. * Scrolling containers, like JViewport, will use this method each
  92. * time they are validated.
  93. *
  94. * @return True if a viewport should force the Scrollables height to match its own.
  95. */
  96. boolean getScrollableTracksViewportHeight();
  97. }