Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public abstract class ScrollSurface
ImplementsAnimation, Editable, StyleListener
A painted component that scrolls on two axes, under an optional pinned header row and pinned header column.
A view that draws thousands of items itself – a calendar, a Gantt chart,
a diagram – cannot afford a component per item, and so cannot use a
scrollable Container. This class does for such a view what a scrollable
container does for components: panning and the fling after it, the mouse
wheel, pinch to zoom, auto scrolling while something is dragged near an
edge, and telling a tap from a double tap, a drag and a long press. The
view only says how big its content is and paints it.
class Sheet extends ScrollSurface {
protected void layoutSurface(int width, int height) {
setHeaderSize(80, 30);
}
protected int getContentWidth() { return 5000; }
protected int getContentHeight() { return 20000; }
protected void paintContent(Graphics g, int x, int y) {
// the content's origin is at x, y; only the visible part is clipped in
}
}Regions
The component is divided into the content, which scrolls on both axes; the
top header, which scrolls only horizontally with it; the left header, which
scrolls only vertically; and the corner where the two meet, which does not
scroll. Each is painted clipped to its own region. paintOverlay paints
last, over all four. A view without headers leaves their size at zero.
Edits
A drag either pans or edits. When a drag or a long press begins, the
surface asks editStarted whether it begins an edit, telling it what kind
of gesture it is (EditTrigger). From then on the pointer goes to
editMoved and, when it lifts, to editEnded. isDragEdits decides
whether a plain drag may start an edit anywhere, which is the default where
there is a mouse, or only on things made to be dragged (EditTrigger.HANDLE_DRAG),
which leaves a finger free to pan.
Bounded and unbounded content
By default the scroll position stays inside the content. A surface whose
content has no edges, such as an infinite canvas, turns that off with
setBounded(false) and reads the moves through scrollChanged.
Nested types
enum ScrollSurface.EditTrigger | What started a possible edit, as editStarted is told. |
class ScrollSurface.PageGrid | How a surface’s content divides into pages, from getPageGrid. |
Fields
protected static final int HOVER_MS = 140 | How long a hover takes to come up and to fade, in milliseconds. |
protected static final int LIFT_MS = 160 | How long an item that is picked up takes to rise, in milliseconds. |
protected static final int SETTLE_MS = 220 | How long a dropped item takes to travel to its place, in milliseconds. |
Constructors
protected ScrollSurface() | A focusable surface that takes every pointer event. |
Methods
protected abstract void layoutSurface(int width, int height) | Lays the surface out for a size: sets the header sizes and whatever the content’s size depends on. |
protected abstract int getContentWidth() | The width of what scrolls, in pixels, without the left header. |
protected abstract int getContentHeight() | The height of what scrolls, in pixels, without the top header. |
protected abstract void paintContent(Graphics g, int x, int y) | Paints what scrolls. |
protected void paintTopHeader(Graphics g, int x, int y) | Paints the pinned top row. |
protected void paintLeftHeader(Graphics g, int x, int y) | Paints the pinned left column. |
protected void paintCorner(Graphics g, int x, int y) | Paints the corner where the two headers meet, at its top left. |
protected void paintOverlay(Graphics g, int x, int y) | Paints over everything, in the component’s own bounds, whose top left is x, y. |
protected final void setHeaderSize(int width, int height) | Sets the width of the pinned left column and the height of the pinned top row, in pixels. |
public final int getHeaderWidth() | The width of the pinned left column, in pixels. |
public final int getHeaderHeight() | The height of the pinned top row, in pixels. |
protected void pressStarted(int x, int y) | The pointer went down at a point, in the component’s coordinates. |
protected boolean editStarted(int x, int y, ScrollSurface.EditTrigger trigger) | Asked when a drag or a long press begins, at the point where the pointer went down, in the component’s coordinates. |
protected void editMoved(int x, int y) | The pointer of an edit moved, or the surface scrolled under it. |
protected void editEnded(boolean committed) | The edit is over. |
protected boolean isEditAutoScroll(int x, int y) | Whether the surface scrolls under an edit dragged near its edge. |
protected void tapped(int x, int y, boolean doubleTap) | A tap that was not a drag or a long press. |
protected void longPressed(int x, int y) | A long press that started no edit. |
protected void scrollChanged() | The scroll position changed. |
protected boolean zoomBy(float factor, int x, int y) | Zooms by factor around a point, for a pinch or Control/Command and the wheel. |
public void setDragEdits(boolean dragEdits) | Whether a plain drag may start an edit anywhere instead of only on handles. |
public boolean isDragEdits() | See setDragEdits. |
public void cancelEdit() | Cancels an edit in progress, as Escape does; editEnded(false) follows. |
public boolean isEditInProgress() | Whether an edit is being dragged. |
public boolean isBounded() | Whether the scroll position stays inside the content; true by default. |
public void setBounded(boolean bounded) | Lets the scroll position go anywhere, for content without edges. |
public final int getBodyWidth() | The width of the content region, in pixels: the component without the left header. |
public final int getBodyHeight() | The height of the content region, in pixels: the component without the top header. |
public final int getMaxOffsetX() | The largest horizontal scroll position of bounded content. |
public final int getMaxOffsetY() | The largest vertical scroll position of bounded content. |
public final int getOffsetX() | How far the content has scrolled to the left, in pixels. |
public final int getOffsetY() | How far the content has scrolled up, in pixels. |
public void scrollTo(int x, int y) | Scrolls to a position, held inside bounded content. |
protected final void setOffsets(int x, int y) | Sets the scroll position without holding it inside the content and without calling scrollChanged, for a view whose content moves under the scroll position (a zoom about a point, a change of date). |
public void refreshLayout() | Lays out for the current size and holds the scroll position inside bounded content. |
protected final void stopFling() | Stops a fling in progress. |
protected final long currentTime() | The time the surface animates by: the clock, or the one it was told to stand still at with setAnimationTime. |
public void setAnimationTime(long millis) | Stops the clock the surface animates hovers and drops by at a time, so a picture taken in the middle of one is the same every run; a negative time starts the clock again. |
protected void hoverAt(int x, int y) | The pointer rests at a point of the surface without being pressed. |
protected void hoverGone() | The pointer left, or nothing is known of it any more. |
protected final void setHoverTarget(Object key, int cursor) | Names what the pointer is over – any object with a meaningful equals, or null for nothing – and the cursor to show. |
protected final void setHoverTooltip(String text) | The tooltip of the thing the pointer is on, for an application that shows tooltips; null for none. |
public final Object getFadingHoverTarget() | What the pointer has just left, while its hover fades. |
public final Object getHoverTarget() | What the pointer is over, as the view named it. |
public final boolean hasHoverFeedback() | Whether anything is lit by the pointer or still fading: a view that paints many items asks once before asking getHoverLevel for each. |
public final float getHoverLevel(Object key) | How far the hover of key has come up, from 0 to 1. |
public final float getLiftLevel() | How far the item being dragged has risen off the surface, from 0 to 1. |
protected final void startSettle(Object key, int x, int y, int w, int h) | An item was let go at a rectangle of the content that is not where it belongs: applySettle moves it from there to its place. |
public final boolean applySettle(Object key, int[] rect) | Moves the rectangle of an item – x, y, width, height, in the content – to where it is on its way from where it was dropped. |
public void pointerHover(int[] x, int[] y) | Invoked for devices where the pointer can hover without actually clicking the display. |
public void setHovered(boolean hovered) | Marks this component as hovered, repainting when the state actually changes AND the theme has a hover style to show for it – otherwise the repaint would be pure cost, because nothing about the render depends on the flag. |
protected void initComponent() | Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state |
protected final void requestAnimation() | Asks for animateSurface to be called on the next frames, for a view with a motion of its own. |
protected boolean animateSurface() | Advances the view’s own motion. |
public final boolean animate() | Allows the animation to reduce “repaint” calls when it returns false. |
protected void deinitialize() | Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
public void paint(Graphics g) | This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API’s to let the PLAF perform the rendering. |
public ScrollSurface.PageGrid getPageGrid(int width, int height) | How the content divides into pages of width by height pixels, with the headers repeated on each. |
public void paintPage(Graphics g, int x, int y, int width, int height, int contentX, int contentY) | Paints one page: the content from contentX, contentY on, under the headers that belong to it, at x, y in a page of width by height. |
protected final boolean isPrinting() | Whether a page is being painted and not the screen. |
protected Object saveZoomState() | The zoom a layout at another size may change, as an object the view alone reads: a view that holds its scale inside limits depending on the room it has may move it when laid out for a page, and does not move it back when laid out for the screen again. |
protected void restoreZoomState(Object state) | Puts back what saveZoomState returned. |
protected int getPageStep(int bodyHeight) | How far down a page of content height bodyHeight goes before the next one starts. |
protected Dimension calcPreferredSize() | Calculates the preferred size based on component content. |
public void pointerPressed(int x, int y) | If this Component is focused, the pointer pressed event will call this method |
public void pointerDragged(int x, int y) | If this Component is focused, the pointer dragged event will call this method |
public void longPointerPress(int x, int y) | If this Component is focused this method is invoked when the user presses and holds the pointer on the Component |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
protected boolean mouseWheel(WheelEvent ev) | Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy. |
protected boolean pinch(float scale) | Invoked by subclasses interested in handling pinch to zoom events, if true is returned other drag events will not be broadcast |
protected void pinchReleased(int x, int y) | To be implemented by subclasses interested in being notified when a pinch zoom has ended (i.e the user has removed one of their fingers, but is still dragging). |
protected boolean shouldBlockSideSwipe() | A component that might need side swipe such as the slider could block it from being used for some other purpose when on top of said component. |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
Inherited methods
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, initLaf, getUIManager, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, clearClientProperties, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, setHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, fireClicked, isSelectableInteraction, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, isScrollableX, isScrollableY, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, getBottomGap, getSideGap, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, setShouldCalcPreferredSize, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyPressed, keyReleased, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, dragInitiated, drawDraggedImage, draggingOver, dragEnter, dragExit, drop, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, getContextMenuCommands, setContextMenuCommands, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, paramString, refreshTheme, refreshTheme, refreshTheme, isDragActivated, getGridPosY, getGridPosX, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, setCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, isEnabled, setEnabled, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, cancelRepaints, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Field details
HOVER_MS
protected static final int HOVER_MS = 140LIFT_MS
protected static final int LIFT_MS = 160SETTLE_MS
protected static final int SETTLE_MS = 220Constructor details
ScrollSurface
protected ScrollSurface()Method details
layoutSurface
protected abstract void layoutSurface(int width, int height)getContentWidth
protected abstract int getContentWidth()getContentHeight
protected abstract int getContentHeight()paintContent
protected abstract void paintContent(Graphics g, int x, int y)x and y are where the content’s own origin is
on screen, which is off screen once it has scrolled. The graphics is
clipped to the content region.paintTopHeader
protected void paintTopHeader(Graphics g, int x, int y)x is where the content’s origin is; y
is the top of the row.paintLeftHeader
protected void paintLeftHeader(Graphics g, int x, int y)x is its left; y is where the
content’s origin is.paintCorner
protected void paintCorner(Graphics g, int x, int y)paintOverlay
protected void paintOverlay(Graphics g, int x, int y)x, y. Not painted on a printed page: it is for what a gesture in
progress shows.setHeaderSize
protected final void setHeaderSize(int width, int height)layoutSurface.getHeaderWidth
public final int getHeaderWidth()getHeaderHeight
public final int getHeaderHeight()pressStarted
protected void pressStarted(int x, int y)editStarted
protected boolean editStarted(int x, int y, ScrollSurface.EditTrigger trigger)Parameters
xint- Not documented.
yint- Not documented.
triggerScrollSurface.EditTrigger- what kind of gesture it is
Returns
editMoved
protected void editMoved(int x, int y)editEnded
protected void editEnded(boolean committed)committed is false when it was cancelled: by
cancelEdit, a second finger, or the surface leaving the form.isEditAutoScroll
protected boolean isEditAutoScroll(int x, int y)tapped
protected void tapped(int x, int y, boolean doubleTap)longPressed
protected void longPressed(int x, int y)scrollChanged
protected void scrollChanged()zoomBy
protected boolean zoomBy(float factor, int x, int y)factor around a point, for a pinch or Control/Command and
the wheel.Returns
setDragEdits
public void setDragEdits(boolean dragEdits)isDragEdits
public boolean isDragEdits()setDragEdits.cancelEdit
public void cancelEdit()editEnded(false)
follows.isEditInProgress
public boolean isEditInProgress()isBounded
public boolean isBounded()setBounded
public void setBounded(boolean bounded)getContentWidth and getContentHeight report are then not
used to limit it.getBodyWidth
public final int getBodyWidth()getBodyHeight
public final int getBodyHeight()getMaxOffsetX
public final int getMaxOffsetX()getMaxOffsetY
public final int getMaxOffsetY()getOffsetX
public final int getOffsetX()getOffsetY
public final int getOffsetY()scrollTo
public void scrollTo(int x, int y)setOffsets
protected final void setOffsets(int x, int y)scrollChanged, for a view whose content moves under
the scroll position (a zoom about a point, a change of date).refreshLayout
public void refreshLayout()stopFling
protected final void stopFling()currentTime
protected final long currentTime()setAnimationTime.setAnimationTime
public void setAnimationTime(long millis)hoverAt
protected void hoverAt(int x, int y)setHoverTarget, naming what is there and the
cursor that says what a press would do.hoverGone
protected void hoverGone()setHoverTarget
protected final void setHoverTarget(Object key, int cursor)equals, or null for nothing – and the cursor to show.setHoverTooltip
protected final void setHoverTooltip(String text)getFadingHoverTarget
public final Object getFadingHoverTarget()getHoverTarget
public final Object getHoverTarget()hasHoverFeedback
public final boolean hasHoverFeedback()getHoverLevel for each.getHoverLevel
public final float getHoverLevel(Object key)key has come up, from 0 to 1.getLiftLevel
public final float getLiftLevel()startSettle
protected final void startSettle(Object key, int x, int y, int w, int h)applySettle moves it from there to its place.applySettle
public final boolean applySettle(Object key, int[] rect)Returns
pointerHover
public void pointerHover(int[] x, int[] y)Parameters
xint[]- the pointer x coordinate
yint[]- the pointer y coordinate
setHovered
public void setHovered(boolean hovered)Parameters
hoveredboolean- true when the pointer is over this component
initComponent
protected void initComponent()requestAnimation
protected final void requestAnimation()animateSurface to be called on the next frames, for a view
with a motion of its own. Frames stop once nothing moves.animateSurface
protected boolean animateSurface()requestAnimation to start the frames.Returns
animate
public final boolean animate()com.codename1.ui.Display class.Returns
deinitialize
protected void deinitialize()paint
public void paint(Graphics g)Parameters
gGraphics- the component graphics
getPageGrid
public ScrollSurface.PageGrid getPageGrid(int width, int height)How the content divides into pages of width by height pixels, with
the headers repeated on each.
The view is laid out at the page’s size for the count, as it is for the painting, and put back as it was.
paintPage
public void paintPage(Graphics g, int x, int y, int width, int height, int contentX, int contentY)Paints one page: the content from contentX, contentY on, under
the headers that belong to it, at x, y in a page of width by
height.
This is the view’s own painting at another size and scroll position, so what prints is what the screen shows. The overlay is left out. The content is clipped to its end, so the last page of a row or column ends where the content does.
isPrinting
protected final boolean isPrinting()saveZoomState
protected Object saveZoomState()restoreZoomState
protected void restoreZoomState(Object state)saveZoomState returned. Called with the view laid out
at its own size again.getPageStep
protected int getPageStep(int bodyHeight)bodyHeight goes before the
next one starts. A view of rows answers a whole number of them, so no
page ends in the middle of one.calcPreferredSize
protected Dimension calcPreferredSize()Returns
pointerPressed
public void pointerPressed(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
pointerDragged
public void pointerDragged(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
longPointerPress
public void longPointerPress(int x, int y)pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
mouseWheel
protected boolean mouseWheel(WheelEvent ev)Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy.
A component that moves its own content – an editor that scrolls itself, a viewer that pans – implements this. Everything else leaves it alone and the wheel scrolls the nearest scrollable ancestor, which is what a wheel means.
This exists because a wheel used to arrive as a synthetic press, drag and release played into the component tree: a component that wanted the wheel got it by handling pointer events, and so did every component that did not want it. The events are gone and this is what replaces them, for the few components that have something of their own to move.
Parameters
evWheelEvent- the wheel event, carrying the scroll deltas in display pixels
Returns
pinch
protected boolean pinch(float scale)Parameters
scalefloat- the scaling of the pinch operation a number larger than 1 means scaling up and smaller than 1 means scaling down. It is recommended that code would threshold the number (so a change between 1.0 and 1.02 shouldn’t necessarily trigger zoom). Notice that this number is relevant to current zoom levels and unaware of them so you should also enforce limits of maximum/minimum zoom levels.
Returns
pinchReleased
protected void pinchReleased(int x, int y)Parameters
xint- The x-coordinate of the remaining finger in the drag. (Absolute)
yint- The y-coordinate of the remaining finger in the drag. (Absolute)
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()