~ubuntu-branches/debian/stretch/insubstantial/stretch

« back to all changes in this revision

Viewing changes to flamingo/src/main/java/org/pushingpixels/flamingo/internal/ui/common/BasicScrollablePanelUI.java

  • Committer: Package Import Robot
  • Author(s): Felix Natter
  • Date: 2016-01-18 20:58:45 UTC
  • Revision ID: package-import@ubuntu.com-20160118205845-crbmrkda61qsi5qa
Tags: upstream-7.3+dfsg2
ImportĀ upstreamĀ versionĀ 7.3+dfsg2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2005-2010 Flamingo Kirill Grouchnikov. All Rights Reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without 
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 * 
 
7
 *  o Redistributions of source code must retain the above copyright notice, 
 
8
 *    this list of conditions and the following disclaimer. 
 
9
 *     
 
10
 *  o Redistributions in binary form must reproduce the above copyright notice, 
 
11
 *    this list of conditions and the following disclaimer in the documentation 
 
12
 *    and/or other materials provided with the distribution. 
 
13
 *     
 
14
 *  o Neither the name of Flamingo Kirill Grouchnikov nor the names of 
 
15
 *    its contributors may be used to endorse or promote products derived 
 
16
 *    from this software without specific prior written permission. 
 
17
 *     
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 
19
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 
20
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 
21
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 
22
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 
23
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 
24
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 
25
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 
26
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 
27
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 
28
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
29
 */
 
30
package org.pushingpixels.flamingo.internal.ui.common;
 
31
 
 
32
import java.awt.*;
 
33
import java.awt.event.*;
 
34
import java.beans.PropertyChangeEvent;
 
35
import java.beans.PropertyChangeListener;
 
36
 
 
37
import javax.swing.*;
 
38
import javax.swing.plaf.ComponentUI;
 
39
 
 
40
import org.pushingpixels.flamingo.api.common.JCommandButton;
 
41
import org.pushingpixels.flamingo.api.common.JScrollablePanel;
 
42
import org.pushingpixels.flamingo.api.common.JScrollablePanel.ScrollType;
 
43
import org.pushingpixels.flamingo.internal.utils.DoubleArrowResizableIcon;
 
44
 
 
45
/**
 
46
 * Basic UI for scrollable panel {@link JScrollablePanel}.
 
47
 * 
 
48
 * @author Kirill Grouchnikov
 
49
 */
 
50
public class BasicScrollablePanelUI extends ScrollablePanelUI {
 
51
        /**
 
52
         * The associated scrollable panel.
 
53
         */
 
54
        protected JScrollablePanel scrollablePanel;
 
55
 
 
56
        private JPanel viewport;
 
57
 
 
58
        private JCommandButton leadingScroller;
 
59
 
 
60
        private JCommandButton trailingScroller;
 
61
 
 
62
        private int viewOffset;
 
63
 
 
64
        private MouseWheelListener mouseWheelListener;
 
65
 
 
66
        private PropertyChangeListener propertyChangeListener;
 
67
 
 
68
        private ComponentListener componentListener;
 
69
 
 
70
        /*
 
71
         * (non-Javadoc)
 
72
         * 
 
73
         * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
 
74
         */
 
75
        public static ComponentUI createUI(JComponent c) {
 
76
                return new BasicScrollablePanelUI();
 
77
        }
 
78
 
 
79
        /*
 
80
         * (non-Javadoc)
 
81
         * 
 
82
         * @see javax.swing.plaf.ComponentUI#installUI(javax.swing.JComponent)
 
83
         */
 
84
        @Override
 
85
        public void installUI(JComponent c) {
 
86
                this.scrollablePanel = (JScrollablePanel) c;
 
87
                super.installUI(this.scrollablePanel);
 
88
                installDefaults();
 
89
                installComponents();
 
90
                installListeners();
 
91
        }
 
92
 
 
93
        protected void installListeners() {
 
94
                this.mouseWheelListener = new MouseWheelListener() {
 
95
                        @Override
 
96
                        public void mouseWheelMoved(MouseWheelEvent e) {
 
97
                                if (scrollablePanel.getScrollType() != JScrollablePanel.ScrollType.VERTICALLY) {
 
98
                                        return;
 
99
                                }
 
100
 
 
101
                                int scrollAmount = 8 * e.getScrollAmount()
 
102
                                                * e.getWheelRotation();
 
103
                                viewOffset += scrollAmount;
 
104
                                syncScrolling();
 
105
                        }
 
106
                };
 
107
                this.scrollablePanel.addMouseWheelListener(this.mouseWheelListener);
 
108
 
 
109
                this.propertyChangeListener = new PropertyChangeListener() {
 
110
                        @Override
 
111
                        public void propertyChange(PropertyChangeEvent evt) {
 
112
                                if ("scrollOnRollover".equals(evt.getPropertyName())) {
 
113
                                        boolean isScrollOnRollover = (Boolean) evt.getNewValue();
 
114
                                        leadingScroller.setFireActionOnRollover(isScrollOnRollover);
 
115
                                        trailingScroller
 
116
                                                        .setFireActionOnRollover(isScrollOnRollover);
 
117
                                }
 
118
                        }
 
119
                };
 
120
                this.scrollablePanel
 
121
                                .addPropertyChangeListener(this.propertyChangeListener);
 
122
 
 
123
                if (this.scrollablePanel.getView() != null) {
 
124
                        this.componentListener = new ComponentAdapter() {
 
125
                                @Override
 
126
                                public void componentResized(ComponentEvent e) {
 
127
                                        scrollablePanel.doLayout();
 
128
                                }
 
129
                        };
 
130
                        this.scrollablePanel.getView().addComponentListener(
 
131
                                        this.componentListener);
 
132
 
 
133
                }
 
134
        }
 
135
 
 
136
        protected void installComponents() {
 
137
                this.viewport = new JPanel(new LayoutManager() {
 
138
                        @Override
 
139
                        public void addLayoutComponent(String name, Component comp) {
 
140
                        }
 
141
 
 
142
                        @Override
 
143
                        public void removeLayoutComponent(Component comp) {
 
144
                        }
 
145
 
 
146
                        @Override
 
147
                        public Dimension preferredLayoutSize(Container parent) {
 
148
                                return new Dimension(10, 10);
 
149
                        }
 
150
 
 
151
                        @Override
 
152
                        public Dimension minimumLayoutSize(Container parent) {
 
153
                                return preferredLayoutSize(parent);
 
154
                        }
 
155
 
 
156
                        @Override
 
157
                        public void layoutContainer(Container parent) {
 
158
                                JComponent view = scrollablePanel.getView();
 
159
                                if (scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY) {
 
160
                                        int viewWidth = view.getPreferredSize().width;
 
161
                                        int availWidth = parent.getWidth();
 
162
 
 
163
                                        int offsetX = -viewOffset;
 
164
                                        view.setBounds(offsetX, 0, Math.max(viewWidth, availWidth),
 
165
                                                        parent.getHeight());
 
166
                                } else {
 
167
                                        int viewHeight = view.getPreferredSize().height;
 
168
                                        int availHeight = parent.getHeight();
 
169
 
 
170
                                        int offsetY = -viewOffset;
 
171
                                        view.setBounds(0, offsetY, parent.getWidth(), Math.max(
 
172
                                                        viewHeight, availHeight));
 
173
                                }
 
174
                        }
 
175
                });
 
176
                JComponent view = scrollablePanel.getView();
 
177
                if (view != null) {
 
178
                        this.viewport.add(view);
 
179
                }
 
180
                this.scrollablePanel.add(this.viewport);
 
181
 
 
182
                this.leadingScroller = this.createLeadingScroller();
 
183
                this.configureLeftScrollerButtonAction();
 
184
                this.scrollablePanel.add(this.leadingScroller);
 
185
 
 
186
                this.trailingScroller = this.createTrailingScroller();
 
187
                this.configureRightScrollerButtonAction();
 
188
                this.scrollablePanel.add(this.trailingScroller);
 
189
        }
 
190
 
 
191
        protected void installDefaults() {
 
192
                this.scrollablePanel.setLayout(new ScrollablePanelLayout());
 
193
        }
 
194
 
 
195
        /*
 
196
         * (non-Javadoc)
 
197
         * 
 
198
         * @see javax.swing.plaf.ComponentUI#uninstallUI(javax.swing.JComponent)
 
199
         */
 
200
        @Override
 
201
        public void uninstallUI(JComponent c) {
 
202
                uninstallListeners();
 
203
                uninstallComponents();
 
204
                uninstallDefaults();
 
205
                super.uninstallUI(this.scrollablePanel);
 
206
        }
 
207
 
 
208
        protected void uninstallDefaults() {
 
209
        }
 
210
 
 
211
        protected void uninstallComponents() {
 
212
                this.scrollablePanel.remove(this.viewport);
 
213
                this.scrollablePanel.remove(this.leadingScroller);
 
214
                this.scrollablePanel.remove(this.trailingScroller);
 
215
        }
 
216
 
 
217
        protected void uninstallListeners() {
 
218
                this.scrollablePanel
 
219
                                .removePropertyChangeListener(this.propertyChangeListener);
 
220
                this.propertyChangeListener = null;
 
221
 
 
222
                this.scrollablePanel.removeMouseWheelListener(this.mouseWheelListener);
 
223
                this.mouseWheelListener = null;
 
224
 
 
225
                if (this.scrollablePanel.getView() != null) {
 
226
                        this.scrollablePanel.getView().removeComponentListener(
 
227
                                        this.componentListener);
 
228
                        this.componentListener = null;
 
229
                }
 
230
        }
 
231
 
 
232
        protected JCommandButton createLeadingScroller() {
 
233
                JCommandButton b = new JCommandButton(
 
234
                                null,
 
235
                                new DoubleArrowResizableIcon(
 
236
                                                new Dimension(9, 9),
 
237
                                                this.scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY ? SwingConstants.WEST
 
238
                                                                : SwingConstants.NORTH));
 
239
 
 
240
                b.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
 
241
                b.setFocusable(false);
 
242
                b.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 
243
                b.putClientProperty(BasicCommandButtonUI.EMULATE_SQUARE_BUTTON,
 
244
                                Boolean.TRUE);
 
245
                b.putClientProperty(BasicCommandButtonUI.DONT_DISPOSE_POPUPS,
 
246
                                Boolean.TRUE);
 
247
                return b;
 
248
        }
 
249
 
 
250
        protected JCommandButton createTrailingScroller() {
 
251
                JCommandButton b = new JCommandButton(
 
252
                                null,
 
253
                                new DoubleArrowResizableIcon(
 
254
                                                new Dimension(9, 9),
 
255
                                                this.scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY ? SwingConstants.EAST
 
256
                                                                : SwingConstants.SOUTH));
 
257
 
 
258
                b.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
 
259
                b.setFocusable(false);
 
260
                b.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 
261
                b.putClientProperty(BasicCommandButtonUI.EMULATE_SQUARE_BUTTON,
 
262
                                Boolean.TRUE);
 
263
                b.putClientProperty(BasicCommandButtonUI.DONT_DISPOSE_POPUPS,
 
264
                                Boolean.TRUE);
 
265
                return b;
 
266
        }
 
267
 
 
268
        private void syncScrolling() {
 
269
                this.scrollablePanel.doLayout();
 
270
        }
 
271
 
 
272
        public void removeScrollers() {
 
273
                if (this.leadingScroller.getParent() == this.scrollablePanel) {
 
274
                        this.scrollablePanel.remove(this.leadingScroller);
 
275
                        this.scrollablePanel.remove(this.trailingScroller);
 
276
                        syncScrolling();
 
277
                        this.scrollablePanel.revalidate();
 
278
                        this.scrollablePanel.repaint();
 
279
                }
 
280
        }
 
281
 
 
282
        private void addScrollers() {
 
283
                this.scrollablePanel.add(this.leadingScroller);
 
284
                this.scrollablePanel.add(this.trailingScroller);
 
285
                this.scrollablePanel.revalidate();
 
286
                JComponent view = this.scrollablePanel.getView();
 
287
                view.setPreferredSize(view.getMinimumSize());
 
288
                view.setSize(view.getMinimumSize());
 
289
                this.scrollablePanel.doLayout();
 
290
 
 
291
                this.scrollablePanel.repaint();
 
292
        }
 
293
 
 
294
        protected void configureLeftScrollerButtonAction() {
 
295
                this.leadingScroller.setAutoRepeatAction(true);
 
296
                this.leadingScroller.setAutoRepeatActionIntervals(200, 50);
 
297
                this.leadingScroller.setFireActionOnRollover(this.scrollablePanel
 
298
                                .isScrollOnRollover());
 
299
                this.leadingScroller.addActionListener(new ActionListener() {
 
300
                        @Override
 
301
                        public void actionPerformed(ActionEvent e) {
 
302
                                viewOffset -= 12;
 
303
                                syncScrolling();
 
304
                        }
 
305
                });
 
306
        }
 
307
 
 
308
        protected void configureRightScrollerButtonAction() {
 
309
                this.trailingScroller.setAutoRepeatAction(true);
 
310
                this.trailingScroller.setAutoRepeatActionIntervals(200, 50);
 
311
                this.trailingScroller.setFireActionOnRollover(this.scrollablePanel
 
312
                                .isScrollOnRollover());
 
313
                this.trailingScroller.addActionListener(new ActionListener() {
 
314
                        @Override
 
315
                        public void actionPerformed(ActionEvent e) {
 
316
                                viewOffset += 12;
 
317
                                syncScrolling();
 
318
                        }
 
319
                });
 
320
        }
 
321
 
 
322
        @Override
 
323
        public void scrollToIfNecessary(int startPosition, int span) {
 
324
                if (this.scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY) {
 
325
                        if (this.scrollablePanel.getComponentOrientation().isLeftToRight()) {
 
326
                                revealRightEdge(startPosition, span);
 
327
                                revealLeftEdge(startPosition);
 
328
                        } else {
 
329
                                revealLeftEdge(startPosition);
 
330
                                revealRightEdge(startPosition, span);
 
331
                        }
 
332
                } else {
 
333
                        revealBottomEdge(startPosition, span);
 
334
                        revealTopEdge(startPosition);
 
335
                }
 
336
        }
 
337
 
 
338
        private void revealLeftEdge(int x) {
 
339
                if (x < viewOffset) {
 
340
                        // left edge is not visible
 
341
                        viewOffset = x - 5;
 
342
                        syncScrolling();
 
343
                }
 
344
        }
 
345
 
 
346
        private void revealRightEdge(int x, int width) {
 
347
                if ((x + width) > (viewOffset + viewport.getWidth())) {
 
348
                        // right edge is not visible
 
349
                        viewOffset = x + width - viewport.getWidth() + 5;
 
350
                        syncScrolling();
 
351
                }
 
352
        }
 
353
 
 
354
        private void revealTopEdge(int y) {
 
355
                if (y < viewOffset) {
 
356
                        // top edge is not visible
 
357
                        viewOffset = y - 5;
 
358
                        syncScrolling();
 
359
                }
 
360
        }
 
361
 
 
362
        private void revealBottomEdge(int y, int height) {
 
363
                if ((y + height) > (viewOffset + viewport.getHeight())) {
 
364
                        // bottom edge is not visible
 
365
                        viewOffset = y + height - viewport.getHeight() + 5;
 
366
                        syncScrolling();
 
367
                }
 
368
        }
 
369
 
 
370
        @Override
 
371
        public boolean isShowingScrollButtons() {
 
372
                return (this.leadingScroller.isVisible());
 
373
        }
 
374
 
 
375
        /**
 
376
         * Layout for the scrollable panel.
 
377
         * 
 
378
         * @author Kirill Grouchnikov
 
379
         * @author Topologi
 
380
         */
 
381
        protected class ScrollablePanelLayout implements LayoutManager {
 
382
                /**
 
383
                 * Creates new layout manager.
 
384
                 */
 
385
                public ScrollablePanelLayout() {
 
386
                }
 
387
 
 
388
                /*
 
389
                 * (non-Javadoc)
 
390
                 * 
 
391
                 * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String,
 
392
                 * java.awt.Component)
 
393
                 */
 
394
                @Override
 
395
        public void addLayoutComponent(String name, Component c) {
 
396
                }
 
397
 
 
398
                /*
 
399
                 * (non-Javadoc)
 
400
                 * 
 
401
                 * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
 
402
                 */
 
403
                @Override
 
404
        public void removeLayoutComponent(Component c) {
 
405
                }
 
406
 
 
407
                /*
 
408
                 * (non-Javadoc)
 
409
                 * 
 
410
                 * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
 
411
                 */
 
412
                @Override
 
413
        public Dimension preferredLayoutSize(Container c) {
 
414
                        if (scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY) {
 
415
                                return new Dimension(c.getWidth(), 21);
 
416
                        } else {
 
417
                                return new Dimension(21, c.getHeight());
 
418
                        }
 
419
                }
 
420
 
 
421
                /*
 
422
                 * (non-Javadoc)
 
423
                 * 
 
424
                 * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
 
425
                 */
 
426
                @Override
 
427
        public Dimension minimumLayoutSize(Container c) {
 
428
                        if (scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY) {
 
429
                                return new Dimension(10, 21);
 
430
                        } else {
 
431
                                return new Dimension(21, 10);
 
432
                        }
 
433
                }
 
434
 
 
435
                /*
 
436
                 * (non-Javadoc)
 
437
                 * 
 
438
                 * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
 
439
                 */
 
440
                @Override
 
441
        public void layoutContainer(Container c) {
 
442
                        int width = c.getWidth();
 
443
                        int height = c.getHeight();
 
444
 
 
445
                        Insets ins = c.getInsets();
 
446
 
 
447
                        JComponent view = scrollablePanel.getView();
 
448
                        Dimension viewPrefSize = view.getPreferredSize();
 
449
 
 
450
                        // System.out.println(width + "*" + height + " - "
 
451
                        // + viewPrefSize.width + "*" + viewPrefSize.height);
 
452
 
 
453
                        if (scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY) {
 
454
                                boolean shouldShowScrollerButtons = (viewPrefSize.width > width);
 
455
 
 
456
                                leadingScroller.setVisible(shouldShowScrollerButtons);
 
457
                                trailingScroller.setVisible(shouldShowScrollerButtons);
 
458
 
 
459
                                int scrollPanelWidth = shouldShowScrollerButtons ? width
 
460
                                                - ins.left - ins.right
 
461
                                                - leadingScroller.getPreferredSize().width
 
462
                                                - trailingScroller.getPreferredSize().width - 4 : width
 
463
                                                - ins.left - ins.right;
 
464
                                int x = ins.left;
 
465
                                if (shouldShowScrollerButtons) {
 
466
                                        int spw = leadingScroller.getPreferredSize().width;
 
467
                                        leadingScroller.setBounds(x, ins.top, spw, height - ins.top
 
468
                                                        - ins.bottom);
 
469
                                        x += spw + 2;
 
470
                                }
 
471
                                viewport.setBounds(x, ins.top, scrollPanelWidth, height
 
472
                                                - ins.top - ins.bottom);
 
473
 
 
474
                                int viewPreferredWidth = view.getPreferredSize().width;
 
475
                                if (viewOffset < 0) {
 
476
                                        viewOffset = 0;
 
477
                                }
 
478
                                if ((viewPreferredWidth > 0)
 
479
                                                && (viewOffset + scrollPanelWidth > viewPreferredWidth)) {
 
480
                                        viewOffset = Math.max(0, viewPreferredWidth
 
481
                                                        - scrollPanelWidth);
 
482
                                }
 
483
                                viewport.doLayout();
 
484
 
 
485
                                x += scrollPanelWidth + 2;
 
486
                                if (shouldShowScrollerButtons) {
 
487
                                        int spw = trailingScroller.getPreferredSize().width;
 
488
                                        trailingScroller.setBounds(x, ins.top, spw, height
 
489
                                                        - ins.top - ins.bottom);
 
490
                                }
 
491
                        } else {
 
492
                                boolean shouldShowScrollerButtons = (viewPrefSize.height > height);
 
493
 
 
494
                                leadingScroller.setVisible(shouldShowScrollerButtons);
 
495
                                trailingScroller.setVisible(shouldShowScrollerButtons);
 
496
 
 
497
                                int scrollPanelHeight = shouldShowScrollerButtons ? height
 
498
                                                - ins.top - ins.bottom
 
499
                                                - leadingScroller.getPreferredSize().height
 
500
                                                - trailingScroller.getPreferredSize().height - 4
 
501
                                                : height - ins.top - ins.bottom;
 
502
                                int y = ins.top;
 
503
                                if (shouldShowScrollerButtons) {
 
504
                                        int sph = leadingScroller.getPreferredSize().height;
 
505
                                        leadingScroller.setBounds(ins.left, y, width - ins.left
 
506
                                                        - ins.right, sph);
 
507
                                        y += sph + 2;
 
508
                                }
 
509
                                viewport.setBounds(ins.left, y, width - ins.left - ins.right,
 
510
                                                scrollPanelHeight);
 
511
 
 
512
                                int viewPreferredHeight = view.getPreferredSize().height;
 
513
                                if (viewOffset < 0) {
 
514
                                        viewOffset = 0;
 
515
                                }
 
516
                                if ((viewPreferredHeight > 0)
 
517
                                                && (viewOffset + scrollPanelHeight > viewPreferredHeight)) {
 
518
                                        viewOffset = Math.max(0, viewPreferredHeight
 
519
                                                        - scrollPanelHeight);
 
520
                                }
 
521
                                viewport.doLayout();
 
522
 
 
523
                                y += scrollPanelHeight + 2;
 
524
                                if (shouldShowScrollerButtons) {
 
525
                                        int sph = trailingScroller.getPreferredSize().height;
 
526
                                        trailingScroller.setBounds(ins.left, y, width - ins.left
 
527
                                                        - ins.right, sph);
 
528
                                }
 
529
                        }
 
530
 
 
531
                        if (scrollablePanel.getScrollType() == ScrollType.HORIZONTALLY) {
 
532
                                trailingScroller
 
533
                                                .setEnabled((viewOffset + viewport.getWidth()) < view
 
534
                                                                .getWidth());
 
535
                        } else {
 
536
                                trailingScroller
 
537
                                                .setEnabled((viewOffset + viewport.getHeight()) < view
 
538
                                                                .getHeight());
 
539
                        }
 
540
                        leadingScroller.setEnabled(viewOffset > 0);
 
541
                }
 
542
        }
 
543
 
 
544
}