1. /*
  2. * @(#)Scrollable.java 1.6 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing;
  11. import java.awt.Dimension;
  12. import java.awt.Rectangle;
  13. /**
  14. * An interface that provides information to a scrolling container
  15. * like JScrollPane. A complex component that's likely to be used
  16. * as a viewin a JScrollPane viewport (or other scrolling container)
  17. * should implement this interface.
  18. *
  19. * @see JViewport
  20. * @see JScrollPane
  21. * @see JScrollBar
  22. * @version 1.6 02/02/00
  23. * @author Hans Muller
  24. */
  25. public interface Scrollable
  26. {
  27. /**
  28. * Returns the preferred size of the viewport for a view component.
  29. * For example the preferredSize of a JList component is the size
  30. * required to acommodate all of the cells in its list however the
  31. * value of preferredScrollableViewportSize is the size required for
  32. * JList.getVisibleRowCount() rows. A component without any properties
  33. * that would effect the viewport size should just return
  34. * getPreferredSize() here.
  35. *
  36. * @return The preferredSize of a JViewport whose view is this Scrollable.
  37. * @see JViewport#getPreferredSize
  38. */
  39. Dimension getPreferredScrollableViewportSize();
  40. /**
  41. * Components that display logical rows or columns should compute
  42. * the scroll increment that will completely expose one new row
  43. * or column, depending on the value of orientation. Ideally,
  44. * components should handle a partially exposed row or column by
  45. * returning the distance required to completely expose the item.
  46. * <p>
  47. * Scrolling containers, like JScrollPane, will use this method
  48. * each time the user requests a unit scroll.
  49. *
  50. * @param visibleRect The view area visible within the viewport
  51. * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  52. * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  53. * @return The "unit" increment for scrolling in the specified direction
  54. * @see JScrollBar#setUnitIncrement
  55. */
  56. int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction);
  57. /**
  58. * Components that display logical rows or columns should compute
  59. * the scroll increment that will completely expose one block
  60. * of rows or columns, depending on the value of orientation.
  61. * <p>
  62. * Scrolling containers, like JScrollPane, will use this method
  63. * each time the user requests a block scroll.
  64. *
  65. * @param visibleRect The view area visible within the viewport
  66. * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
  67. * @param direction Less than zero to scroll up/left, greater than zero for down/right.
  68. * @return The "block" increment for scrolling in the specified direction.
  69. * @see JScrollBar#setBlockIncrement
  70. */
  71. int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
  72. /**
  73. * Return true if a viewport should always force the width of this
  74. * Scrollable to match the width of the viewport. For example a noraml
  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. }