28 import java.awt.Dimension;
29 import java.awt.Rectangle;
30
31
32 /**
33 * An interface that provides information to a scrolling container
34 * like JScrollPane. A complex component that's likely to be used
35 * as a viewing a JScrollPane viewport (or other scrolling container)
36 * should implement this interface.
37 *
38 * @see JViewport
39 * @see JScrollPane
40 * @see JScrollBar
41 * @author Hans Muller
42 * @since 1.2
43 */
44 public interface Scrollable
45 {
46 /**
47 * Returns the preferred size of the viewport for a view component.
48 * For example, the preferred size of a <code>JList</code> component
49 * is the size required to accommodate all of the cells in its list.
50 * However, the value of <code>preferredScrollableViewportSize</code>
51 * is the size required for <code>JList.getVisibleRowCount</code> rows.
52 * A component without any properties that would affect the viewport
53 * size should just return <code>getPreferredSize</code> here.
54 *
55 * @return the preferredSize of a <code>JViewport</code> whose view
56 * is this <code>Scrollable</code>
57 * @see JViewport#getPreferredSize
58 */
59 Dimension getPreferredScrollableViewportSize();
60
61
62 /**
63 * Components that display logical rows or columns should compute
64 * the scroll increment that will completely expose one new row
65 * or column, depending on the value of orientation. Ideally,
66 * components should handle a partially exposed row or column by
67 * returning the distance required to completely expose the item.
68 * <p>
69 * Scrolling containers, like JScrollPane, will use this method
70 * each time the user requests a unit scroll.
71 *
72 * @param visibleRect The view area visible within the viewport
73 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
74 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
75 * @return The "unit" increment for scrolling in the specified direction.
76 * This value should always be positive.
82 /**
83 * Components that display logical rows or columns should compute
84 * the scroll increment that will completely expose one block
85 * of rows or columns, depending on the value of orientation.
86 * <p>
87 * Scrolling containers, like JScrollPane, will use this method
88 * each time the user requests a block scroll.
89 *
90 * @param visibleRect The view area visible within the viewport
91 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
92 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
93 * @return The "block" increment for scrolling in the specified direction.
94 * This value should always be positive.
95 * @see JScrollBar#setBlockIncrement
96 */
97 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
98
99
100 /**
101 * Return true if a viewport should always force the width of this
102 * <code>Scrollable</code> to match the width of the viewport.
103 * For example a normal
104 * text view that supported line wrapping would return true here, since it
105 * would be undesirable for wrapped lines to disappear beyond the right
106 * edge of the viewport. Note that returning true for a Scrollable
107 * whose ancestor is a JScrollPane effectively disables horizontal
108 * scrolling.
109 * <p>
110 * Scrolling containers, like JViewport, will use this method each
111 * time they are validated.
112 *
113 * @return True if a viewport should force the Scrollables width to match its own.
114 */
115 boolean getScrollableTracksViewportWidth();
116
117 /**
118 * Return true if a viewport should always force the height of this
119 * Scrollable to match the height of the viewport. For example a
120 * columnar text view that flowed text in left to right columns
121 * could effectively disable vertical scrolling by returning
122 * true here.
|
28 import java.awt.Dimension;
29 import java.awt.Rectangle;
30
31
32 /**
33 * An interface that provides information to a scrolling container
34 * like JScrollPane. A complex component that's likely to be used
35 * as a viewing a JScrollPane viewport (or other scrolling container)
36 * should implement this interface.
37 *
38 * @see JViewport
39 * @see JScrollPane
40 * @see JScrollBar
41 * @author Hans Muller
42 * @since 1.2
43 */
44 public interface Scrollable
45 {
46 /**
47 * Returns the preferred size of the viewport for a view component.
48 * For example, the preferred size of a {@code JList} component
49 * is the size required to accommodate all of the cells in its list.
50 * However, the value of {@code preferredScrollableViewportSize}
51 * is the size required for {@code JList.getVisibleRowCount} rows.
52 * A component without any properties that would affect the viewport
53 * size should just return {@code getPreferredSize} here.
54 *
55 * @return the preferredSize of a {@code JViewport} whose view
56 * is this {@code Scrollable}
57 * @see JViewport#getPreferredSize
58 */
59 Dimension getPreferredScrollableViewportSize();
60
61
62 /**
63 * Components that display logical rows or columns should compute
64 * the scroll increment that will completely expose one new row
65 * or column, depending on the value of orientation. Ideally,
66 * components should handle a partially exposed row or column by
67 * returning the distance required to completely expose the item.
68 * <p>
69 * Scrolling containers, like JScrollPane, will use this method
70 * each time the user requests a unit scroll.
71 *
72 * @param visibleRect The view area visible within the viewport
73 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
74 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
75 * @return The "unit" increment for scrolling in the specified direction.
76 * This value should always be positive.
82 /**
83 * Components that display logical rows or columns should compute
84 * the scroll increment that will completely expose one block
85 * of rows or columns, depending on the value of orientation.
86 * <p>
87 * Scrolling containers, like JScrollPane, will use this method
88 * each time the user requests a block scroll.
89 *
90 * @param visibleRect The view area visible within the viewport
91 * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
92 * @param direction Less than zero to scroll up/left, greater than zero for down/right.
93 * @return The "block" increment for scrolling in the specified direction.
94 * This value should always be positive.
95 * @see JScrollBar#setBlockIncrement
96 */
97 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
98
99
100 /**
101 * Return true if a viewport should always force the width of this
102 * {@code Scrollable} to match the width of the viewport.
103 * For example a normal
104 * text view that supported line wrapping would return true here, since it
105 * would be undesirable for wrapped lines to disappear beyond the right
106 * edge of the viewport. Note that returning true for a Scrollable
107 * whose ancestor is a JScrollPane effectively disables horizontal
108 * scrolling.
109 * <p>
110 * Scrolling containers, like JViewport, will use this method each
111 * time they are validated.
112 *
113 * @return True if a viewport should force the Scrollables width to match its own.
114 */
115 boolean getScrollableTracksViewportWidth();
116
117 /**
118 * Return true if a viewport should always force the height of this
119 * Scrollable to match the height of the viewport. For example a
120 * columnar text view that flowed text in left to right columns
121 * could effectively disable vertical scrolling by returning
122 * true here.
|