@Override public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { return getScrollable(orientation).getScrollableUnitIncrement( visibleRect, orientation, direction); }
int blockIncr = scrollComp.getScrollableBlockIncrement(viewRect, orientation, direction); if (direction < 0) { int unitIncr = scrollComp.getScrollableUnitIncrement(viewRect, orientation, direction); if (orientation == SwingConstants.VERTICAL) {
if (view instanceof Scrollable) { scrollable = (Scrollable) view; if (scrollable.getScrollableTracksViewportWidth()) viewSize.width = actualSize.width; if (scrollable.getScrollableTracksViewportHeight()) viewSize.height = actualSize.height;
public void layoutContainer(Container parent) { super.layoutContainer(parent); Component view = (viewport != null) ? viewport.getView() : null; Dimension viewPrefSize = (view != null) ? view.getPreferredSize() : new Dimension(0, 0); Dimension extentSize = (viewport != null) ? viewport.toViewCoordinates(viewport.getSize()) : new Dimension(0, 0); boolean viewTracksViewportWidth = (view instanceof Scrollable) && ((Scrollable) view).getScrollableTracksViewportWidth(); boolean hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width); // enable horizontal scrollbar only if it is needed if (hsb != null) { hsb.setEnabled(hsbNeeded); } // make dependent horizontal scrollbar visible by setting scrollbar policy JScrollPane scrollPane = (JScrollPane) parent; if (scrollPane.getHorizontalScrollBarPolicy() != JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS) { int newPolicy = hsbNeeded ? JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS : JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; if (newPolicy != dependentScrollPane.getHorizontalScrollBarPolicy()) { dependentScrollPane.setHorizontalScrollBarPolicy(newPolicy); dependentScrollPane.getViewport().invalidate(); } } } }
/** * Returns false to indicate that the height of the viewport does not * determine the height of the layer, unless the preferred height * of the layer is smaller than the viewports height. * * @return whether the layer should track the height of the viewport * @see Scrollable#getScrollableTracksViewportHeight() */ public boolean getScrollableTracksViewportHeight(JXLayer<? extends V> l) { if (l.getView() instanceof Scrollable) { return ((Scrollable) l.getView()).getScrollableTracksViewportHeight(); } if (l.getParent() instanceof JViewport) { return (((JViewport) l.getParent()).getHeight() > l.getPreferredSize().height); } return false; }
@Override public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { return getScrollable(orientation).getScrollableBlockIncrement( visibleRect, orientation, direction); }
if (view instanceof Scrollable) { canScroll = !((Scrollable) view) .getScrollableTracksViewportHeight(); if (view instanceof Scrollable) { canScroll = !((Scrollable) view) .getScrollableTracksViewportWidth();
public void layoutContainer(Container parent) { super.layoutContainer(parent); Component view = (viewport != null) ? viewport.getView() : null; Dimension viewPrefSize = (view != null) ? view.getPreferredSize() : new Dimension(0,0); Dimension extentSize = (viewport != null) ? viewport.toViewCoordinates(viewport.getSize()) : new Dimension(0,0); boolean viewTracksViewportWidth = (view instanceof Scrollable) && ((Scrollable)view).getScrollableTracksViewportWidth(); boolean hsbNeeded = !viewTracksViewportWidth && viewPrefSize.width > extentSize.width; // enable horizontal scrollbar only if it is needed if (hsb != null) { hsb.setEnabled(hsbNeeded); } // make dependent horizontal scrollbar visible by setting scrollbar policy JScrollPane scrollPane = (JScrollPane)parent; if (scrollPane.getHorizontalScrollBarPolicy() != JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS) { int newPolicy = hsbNeeded ? JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS : JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; if (newPolicy != dependentScrollPane.getHorizontalScrollBarPolicy()) { dependentScrollPane.setHorizontalScrollBarPolicy(newPolicy); dependentScrollPane.getViewport().invalidate(); } } } }
/** * Components that display logical rows or columns should compute * the scroll increment that will completely expose one block * of rows or columns, depending on the value of orientation. * * @return the "block" increment for scrolling in the specified direction * @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int) */ public int getScrollableBlockIncrement(JXLayer<? extends V> l, Rectangle visibleRect, int orientation, int direction) { if (l.getView() instanceof Scrollable) { return ((Scrollable) l.getView()).getScrollableBlockIncrement( visibleRect, orientation, direction); } return (orientation == SwingConstants.VERTICAL) ? visibleRect.height : visibleRect.width; }
boolean canScroll = true; if (view instanceof Scrollable) { canScroll = !((Scrollable) view).getScrollableTracksViewportHeight(); boolean canScroll = true; if (view instanceof Scrollable) { canScroll = !((Scrollable) view).getScrollableTracksViewportWidth();
if (c instanceof Scrollable) { Scrollable s = (Scrollable) c; i.left = s.getScrollableUnitIncrement(visible, SwingConstants.HORIZONTAL, 1); i.top = s.getScrollableUnitIncrement(visible, SwingConstants.VERTICAL, 1); i.right = s.getScrollableUnitIncrement(visible, SwingConstants.HORIZONTAL, -1); i.bottom = s.getScrollableUnitIncrement(visible, SwingConstants.VERTICAL, -1);
amount = ((Scrollable)view).getScrollableBlockIncrement (visRect, orientation, direction); amount = ((Scrollable)view).getScrollableUnitIncrement (visRect, orientation, direction);
public void layoutContainer(Container parent) { super.layoutContainer(parent); Component view = (viewport != null) ? viewport.getView() : null; Dimension viewPrefSize = (view != null) ? view.getPreferredSize() : new Dimension(0,0); Dimension extentSize = (viewport != null) ? viewport.toViewCoordinates(viewport.getSize()) : new Dimension(0,0); boolean viewTracksViewportWidth = (view instanceof Scrollable) && ((Scrollable)view).getScrollableTracksViewportWidth(); boolean hsbNeeded = !viewTracksViewportWidth && viewPrefSize.width > extentSize.width; // enable horizontal scrollbar only if it is needed if (hsb != null) { hsb.setEnabled(hsbNeeded); } // make dependent horizontal scrollbar visible by setting scrollbar policy JScrollPane scrollPane = (JScrollPane)parent; if (scrollPane.getHorizontalScrollBarPolicy() != JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS) { int newPolicy = hsbNeeded ? JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS : JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; if (newPolicy != dependentScrollPane.getHorizontalScrollBarPolicy()) { dependentScrollPane.setHorizontalScrollBarPolicy(newPolicy); dependentScrollPane.getViewport().invalidate(); } } } }
public int getBlockIncrement(int direction) { JViewport vp = getViewport(); if (blockIncrementSet || vp == null) { return super.getBlockIncrement(direction); } else if (vp.getView() instanceof Scrollable) { Scrollable view = (Scrollable) (vp.getView()); Rectangle vr = vp.getViewRect(); return view.getScrollableBlockIncrement(vr, getOrientation(), direction); } else if (getOrientation() == VERTICAL) { return vp.getExtentSize().height; } else { return vp.getExtentSize().width; } }
viewTracksViewportWidth = sv.getScrollableTracksViewportWidth(); viewTracksViewportHeight = sv.getScrollableTracksViewportHeight(); } else { sv = null; viewTracksViewportWidth = sv.getScrollableTracksViewportWidth(); viewTracksViewportHeight = sv .getScrollableTracksViewportHeight(); if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) { boolean newVSBNeeded = !viewTracksViewportHeight
if (c instanceof Scrollable) { Scrollable s = (Scrollable) c; i.left = s.getScrollableUnitIncrement(visible, SwingConstants.HORIZONTAL, 1); i.top = s.getScrollableUnitIncrement(visible, SwingConstants.VERTICAL, 1); i.right = s.getScrollableUnitIncrement(visible, SwingConstants.HORIZONTAL, -1); i.bottom = s.getScrollableUnitIncrement(visible, SwingConstants.VERTICAL, -1);
amount = ((Scrollable) view).getScrollableBlockIncrement(visRect, orientation, direction); } else { amount = ((Scrollable) view).getScrollableUnitIncrement(visRect, orientation, direction);
/** * Returns false to indicate that the width of the viewport does not * determine the width of the layer, unless the preferred width * of the layer is smaller than the viewports width. * * @return whether the layer should track the width of the viewport * @see Scrollable * @see LayerUI#getScrollableTracksViewportWidth(JXLayer) */ public boolean getScrollableTracksViewportWidth(JXLayer<? extends V> l) { if (l.getView() instanceof Scrollable) { return ((Scrollable) l.getView()).getScrollableTracksViewportWidth(); } if (l.getParent() instanceof JViewport) { return (((JViewport) l.getParent()).getWidth() > l.getPreferredSize().width); } return false; }
if (!isEmpty && view instanceof Scrollable) { sv = (Scrollable) view; viewTracksViewportWidth = sv.getScrollableTracksViewportWidth(); viewTracksViewportHeight = sv.getScrollableTracksViewportHeight(); } else { sv = null; viewTracksViewportWidth = sv.getScrollableTracksViewportWidth(); viewTracksViewportHeight = sv.getScrollableTracksViewportHeight(); if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) { boolean newVSBNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height);
if (pos.y < inner.y) { int dy = s.getScrollableUnitIncrement(outer, SwingConstants.VERTICAL, 1); Rectangle r = new Rectangle(inner.x, outer.y - dy, inner.width, dy); c.scrollRectToVisible(r); } else if (pos.y > (inner.y + inner.height)) { int dy = s.getScrollableUnitIncrement(outer, SwingConstants.VERTICAL, -1); Rectangle r = new Rectangle(inner.x, outer.y + outer.height, inner.width, dy); c.scrollRectToVisible(r); int dx = s.getScrollableUnitIncrement(outer, SwingConstants.HORIZONTAL, 1); Rectangle r = new Rectangle(outer.x - dx, inner.y, dx, inner.height); c.scrollRectToVisible(r); } else if (pos.x > (inner.x + inner.width)) { int dx = s.getScrollableUnitIncrement(outer, SwingConstants.HORIZONTAL, -1); Rectangle r = new Rectangle(outer.x + outer.width, inner.y, dx, inner.height); c.scrollRectToVisible(r);