Class ScrollPaneAdjustable
java.lang.Object
vaadinx.awt.ScrollPaneAdjustable
- All Implemented Interfaces:
Adjustable, Serializable
Emulator for
ScrollPaneAdjustable — the value model behind
one axis of a ScrollPane. Emulator-only: it is not a
Component, has no DOM of its own, and Vaadin ships no
scrollbar-object concept (the web component renders its scrollbars
internally). D_viewport_scrollbar_shadows's "shadow JDK component" pattern — except that, unlike
JScrollBar, this one is not inert: setValue(int) really does
scroll the pane.
Adjustable v = pane.getVAdjustable();
v.addAdjustmentListener(e -> log(e.getValue()));
v.setValue(200); // scrolls, and fires
v.setMaximum(500); // AWTError, as in AWT
The range is not yours to set
setMinimum(int) / setMaximum(int) / setVisibleAmount(int) throw
AWTError, verbatim as the JDK does — in AWT the span is
derived by ScrollPane.layout() from the child's preferred size
against the viewport, never set by user code. getMinimum() ignores
its own field and hard-returns 0, also as the JDK does.
Programmatic scrolls fire; user scrolls do not
setValue fires an AdjustmentEvent on change,
synchronously and inline, exactly as the JDK's setTypedValue does
(the JDK comments that the synchronous delivery is deliberate, so listeners
are up to date before the Adjustable mutates again). A user scroll
fires nothing: the browser→server channel is descoped per D_awt_scrollpane, so no
gesture reaches the server. A migrator syncing two panes, or paging on
scroll, will find their listener silent — see the class javadoc of
ScrollPane.
Deliberate divergence: no clamping
The JDK clamps to[minimum, maximum - visibleAmount]. Since the span
is only ever written by setSpan — which only ScrollPane
.layout() calls, and we never compute a pixel span (R_layouts_close_enough) — a faithful clamp
would be min(max(v, 0), 0), i.e. every setValue would collapse to
0 and fire nothing, forever, killing setScrollPosition outright.
So this port does not clamp: the value is stored verbatim, and the browser
clamps it on arrival (verified synchronous). One consequence, named so it is
not rediscovered as a bug: getValue() can exceed getMaximum()
(200 against 0), which the JDK's clamp makes impossible. A migrator
computing value / (double) maximum gets nonsense — but under a
faithful port they would have got 0 / 0, so no working idiom is lost.- See Also:
-
Field Summary
Fields inherited from interface Adjustable
HORIZONTAL, NO_ORIENTATION, VERTICAL -
Method Summary
Modifier and TypeMethodDescriptionvoidNull listener is a documented no-op, as in AWT.intintintintintintgetValue()booleanintVerbatim JDK format.voidNull listener is a documented no-op, as in AWT.voidsetBlockIncrement(int b) Stores the page delta.voidsetMaximum(int max) voidsetMinimum(int min) voidsetUnitIncrement(int u) Stores the arrow-key delta.voidsetValue(int v) Scrolls this axis tovand pushes to the browser.voidsetValueIsAdjusting(boolean b) Fires anAdjustmentEventon a genuine flip, as the JDK does.voidsetVisibleAmount(int v) toString()
-
Method Details
-
getOrientation
public int getOrientation()- Specified by:
getOrientationin interfaceAdjustable
-
setMinimum
public void setMinimum(int min) - Specified by:
setMinimumin interfaceAdjustable- Throws:
AWTError- always — the span belongs to the scroll pane
-
getMinimum
public int getMinimum()- Specified by:
getMinimumin interfaceAdjustable- Returns:
- always 0; the JDK ignores its own field here for the same reason
-
setMaximum
public void setMaximum(int max) - Specified by:
setMaximumin interfaceAdjustable- Throws:
AWTError- always — the span belongs to the scroll pane
-
getMaximum
public int getMaximum()- Specified by:
getMaximumin interfaceAdjustable- Returns:
- always 0 — the JDK's field default, only ever overwritten by
setSpan, which needs a laid-out pane we never produce. Not 1: that issetSpan's floor, reachable only after a layout, so 0 is what an un-laid-out JDK pane actually answers
-
setVisibleAmount
public void setVisibleAmount(int v) - Specified by:
setVisibleAmountin interfaceAdjustable- Throws:
AWTError- always — the span belongs to the scroll pane
-
getVisibleAmount
public int getVisibleAmount()- Specified by:
getVisibleAmountin interfaceAdjustable- Returns:
- always 0, for the same reason as
getMaximum()
-
setUnitIncrement
public void setUnitIncrement(int u) Stores the arrow-key delta. Inert: the browser owns wheel and arrow-key scroll deltas and exposes no hook to override them (R_match_swing_errors sub-bucket (c)). The value round-trips so a migrator's own arithmetic over it still works.- Specified by:
setUnitIncrementin interfaceAdjustable
-
getUnitIncrement
public int getUnitIncrement()- Specified by:
getUnitIncrementin interfaceAdjustable
-
setBlockIncrement
public void setBlockIncrement(int b) Stores the page delta. Inert, assetUnitIncrement(int)is.Unlike the JDK, the stored value survives: AWT's
setSpansilently overwritesblockIncrementwith0.9 * visibleon every layout, andsetSpannever runs here.- Specified by:
setBlockIncrementin interfaceAdjustable
-
getBlockIncrement
public int getBlockIncrement()- Specified by:
getBlockIncrementin interfaceAdjustable
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean b) Fires anAdjustmentEventon a genuine flip, as the JDK does. Only user code can flip it — the browser gives no scroll-drag start/end signal, and we are not listening for one anyway. -
getValueIsAdjusting
public boolean getValueIsAdjusting() -
setValue
public void setValue(int v) Scrolls this axis tovand pushes to the browser.No clamping — see the class javadoc. Fires only on a real change, matching the JDK, and fires before nothing: the JDK's
setTypedValuenotifies synchronously, and so do we.- Specified by:
setValuein interfaceAdjustable
-
getValue
public int getValue()- Specified by:
getValuein interfaceAdjustable
-
addAdjustmentListener
Null listener is a documented no-op, as in AWT.- Specified by:
addAdjustmentListenerin interfaceAdjustable
-
removeAdjustmentListener
Null listener is a documented no-op, as in AWT.- Specified by:
removeAdjustmentListenerin interfaceAdjustable
-
getAdjustmentListeners
-
toString
-
paramString
Verbatim JDK format.
-