1. /*
  2. * @(#)Scrollable.java 1.10 03/01/23
  3. *
  4. * Copyright 2003 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 viewing 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.10 01/23/03
  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 accommodate 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. * This value should always be positive.
  52. * @see JScrollBar#setUnitIncrement
  53. */
  54. int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction);
  55. /**
  56. * Components that display logical rows or columns should compute
  57. * the scroll increment that will completely expose one block
  58. * of rows or columns, depending on the value of orientation.
  59. * <p>
  60. * Scrolling containers, like JScrollPane, will use this method
  61. * each time the user requests a block scroll.
  62. *
  63. * @param visibleRect The view area visible within the viewport
  64. * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  65. * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  66. * @return The "block" increment for scrolling in the specified direction.
  67. * This value should always be positive.
  68. * @see JScrollBar#setBlockIncrement
  69. */
  70. int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
  71. /**
  72. * Return true if a viewport should always force the width of this
  73. * <code>Scrollable</code> to match the width of the viewport.
  74. * For example a normal
  75. * text view that supported line wrapping would return true here, since it
  76. * would be undesirable for wrapped lines to disappear beyond the right
  77. * edge of the viewport. Note that returning true for a Scrollable
  78. * whose ancestor is a JScrollPane effectively disables horizontal
  79. * scrolling.
  80. * <p>
  81. * Scrolling containers, like JViewport, will use this method each
  82. * time they are validated.
  83. *
  84. * @return True if a viewport should force the Scrollables width to match its own.
  85. */
  86. boolean getScrollableTracksViewportWidth();
  87. /**
  88. * Return true if a viewport should always force the height of this
  89. * Scrollable to match the height of the viewport. For example a
  90. * columnar text view that flowed text in left to right columns
  91. * could effectively disable vertical scrolling by returning
  92. * true here.
  93. * <p>
  94. * Scrolling containers, like JViewport, will use this method each
  95. * time they are validated.
  96. *
  97. * @return True if a viewport should force the Scrollables height to match its own.
  98. */
  99. boolean getScrollableTracksViewportHeight();
  100. }