Class ScrollSurface
- All Implemented Interfaces:
Animation, 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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat started a possible edit, aseditStartedis told.static final classHow a surface's content divides into pages, fromgetPageGrid. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intHow long a hover takes to come up and to fade, in milliseconds.protected static final intHow long an item that is picked up takes to rise, in milliseconds.protected static final intHow long a dropped item takes to travel to its place, in milliseconds.Fields inherited from class Component
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedA focusable surface that takes every pointer event. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleananimate()Allows the animation to reduce "repaint" calls when it returns false.protected booleanAdvances the view's own motion.final booleanapplySettle(Object key, int[] rect) Moves the rectangle of an item -- x, y, width, height, in the contentprotected DimensionCalculates the preferred size based on component content.voidCancels an edit in progress, as Escape does;editEnded(false)follows.protected final longThe time the surface animates by: the clock, or the one it was told to stand still at withsetAnimationTime.protected voidInvoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.protected voideditEnded(boolean committed) The edit is over.protected voideditMoved(int x, int y) The pointer of an edit moved, or the surface scrolled under it.protected booleaneditStarted(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.final intThe height of the content region, in pixels: the component without the top header.final intThe width of the content region, in pixels: the component without the left header.protected abstract intThe height of what scrolls, in pixels, without the top header.protected abstract intThe width of what scrolls, in pixels, without the left header.final ObjectWhat the pointer has just left, while its hover fades.final intThe height of the pinned top row, in pixels.final intThe width of the pinned left column, in pixels.final floatgetHoverLevel(Object key) How far the hover ofkeyhas come up, from 0 to 1.final ObjectWhat the pointer is over, as the view named it.final floatHow far the item being dragged has risen off the surface, from 0 to 1.final intThe largest horizontal scroll position of bounded content.final intThe largest vertical scroll position of bounded content.final intHow far the content has scrolled to the left, in pixels.final intHow far the content has scrolled up, in pixels.getPageGrid(int width, int height) How the content divides into pages ofwidthbyheightpixels, with the headers repeated on each.protected intgetPageStep(int bodyHeight) How far down a page of content heightbodyHeightgoes before the next one starts.final booleanWhether anything is lit by the pointer or still fading: a view that paints many items asks once before askinggetHoverLevelfor each.protected voidhoverAt(int x, int y) The pointer rests at a point of the surface without being pressed.protected voidThe pointer left, or nothing is known of it any more.protected voidAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component statebooleanWhether the scroll position stays inside the content; true by default.booleanSeesetDragEdits.protected booleanisEditAutoScroll(int x, int y) Whether the surface scrolls under an edit dragged near its edge.booleanWhether an edit is being dragged.protected final booleanWhether a page is being painted and not the screen.protected abstract voidlayoutSurface(int width, int height) Lays the surface out for a size: sets the header sizes and whatever the content's size depends on.voidlongPointerPress(int x, int y) If this Component is focused this method is invoked when the user presses and holds the pointer on the Componentprotected voidlongPressed(int x, int y) A long press that started no edit.protected booleanmouseWheel(WheelEvent ev) Handles a scroll wheel or trackpad scroll over this component, before its listeners and before anything above it in the hierarchy.voidThis 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.protected abstract voidpaintContent(Graphics g, int x, int y) Paints what scrolls.protected voidpaintCorner(Graphics g, int x, int y) Paints the corner where the two headers meet, at its top left.protected voidpaintLeftHeader(Graphics g, int x, int y) Paints the pinned left column.protected voidpaintOverlay(Graphics g, int x, int y) Paints over everything, in the component's own bounds, whose top left isx,y.voidPaints one page: the content fromcontentX,contentYon, under the headers that belong to it, atx,yin a page ofwidthbyheight.protected voidpaintTopHeader(Graphics g, int x, int y) Paints the pinned top row.protected booleanpinch(float scale) Invoked by subclasses interested in handling pinch to zoom events, if true is returned other drag events will not be broadcastprotected voidpinchReleased(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).voidpointerDragged(int x, int y) If this Component is focused, the pointer dragged event will call this methodvoidpointerHover(int[] x, int[] y) Invoked for devices where the pointer can hover without actually clicking the display.voidpointerPressed(int x, int y) If this Component is focused, the pointer pressed event will call this methodvoidpointerReleased(int x, int y) If this Component is focused, the pointer released event will call this methodprotected voidpressStarted(int x, int y) The pointer went down at a point, in the component's coordinates.voidLays out for the current size and holds the scroll position inside bounded content.protected final voidAsks foranimateSurfaceto be called on the next frames, for a view with a motion of its own.protected voidrestoreZoomState(Object state) Puts back whatsaveZoomStatereturned.protected ObjectThe 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 voidThe scroll position changed.voidscrollTo(int x, int y) Scrolls to a position, held inside bounded content.voidsetAnimationTime(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.voidsetBounded(boolean bounded) Lets the scroll position go anywhere, for content without edges.voidsetDragEdits(boolean dragEdits) Whether a plain drag may start an edit anywhere instead of only on handles.protected final voidsetHeaderSize(int width, int height) Sets the width of the pinned left column and the height of the pinned top row, in pixels.voidsetHovered(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 final voidsetHoverTarget(Object key, int cursor) Names what the pointer is over -- any object with a meaningfulequals, or null for nothing -- and the cursor to show.protected final voidsetHoverTooltip(String text) The tooltip of the thing the pointer is on, for an application that shows tooltips; null for none.protected final voidsetOffsets(int x, int y) Sets the scroll position without holding it inside the content and without callingscrollChanged, for a view whose content moves under the scroll position (a zoom about a point, a change of date).protected booleanA 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.protected final voidstartSettle(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:applySettlemoves it from there to its place.protected final voidStops a fling in progress.protected voidtapped(int x, int y, boolean doubleTap) A tap that was not a drag or a long press.protected booleanzoomBy(float factor, int x, int y) Zooms byfactoraround a point, for a pinch or Control/Command and the wheel.Methods inherited from class Component
accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addNativeDragOverListener, addNativeDropListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, canAcceptNativeDrop, cancelRepaints, clearClientProperties, consumesRawTextInput, contains, containsOrOwns, createNativeDragOperation, createStyleAnimation, deinitializeCustomStyle, deregisterFromAnimation, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAcceptedDropActions, getAcceptedDropMimeTypes, getAccessibilityNode, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBottomGap, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getContextMenuCommands, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getHoverStyle, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeDragOperation, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSemantics, getSideGap, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getTopLevelContainer, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initLaf, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHovered, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isNativeDragSource, isNativeDropTarget, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollableY, isScrollVisible, isSelectableInteraction, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, nativeDragEnter, nativeDragExit, nativeDragOver, nativeDrop, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, paramString, parsePreferredSize, pinch, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, registerForAnimation, remove, removeContextMenuListener, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removeMouseWheelListener, removeNativeDragOverListener, removeNativeDropListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, removeStylusListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, rotation, scrollRectToVisible, scrollRectToVisible, setAcceptedDropActions, setAcceptedDropMimeTypes, setAccessibilityText, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setContextMenuCommands, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setHoverStyle, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNativeDragOperation, setNativeDragSource, setNativeDropTarget, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setPullToRefresh, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stopScrollMomentum, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains
-
Field Details
-
HOVER_MS
protected static final int HOVER_MSHow long a hover takes to come up and to fade, in milliseconds.- See Also:
-
LIFT_MS
protected static final int LIFT_MSHow long an item that is picked up takes to rise, in milliseconds.- See Also:
-
SETTLE_MS
protected static final int SETTLE_MSHow long a dropped item takes to travel to its place, in milliseconds.- See Also:
-
-
Constructor Details
-
ScrollSurface
protected ScrollSurface()A focusable surface that takes every pointer event.
-
-
Method Details
-
layoutSurface
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. Called before every paint and every pointer event, so it has to return at once when nothing has changed. -
getContentWidth
protected abstract int getContentWidth()The width of what scrolls, in pixels, without the left header. -
getContentHeight
protected abstract int getContentHeight()The height of what scrolls, in pixels, without the top header. -
paintContent
Paints what scrolls.xandyare 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
Paints the pinned top row.xis where the content's origin is;yis the top of the row. -
paintLeftHeader
Paints the pinned left column.xis its left;yis where the content's origin is. -
paintCorner
Paints the corner where the two headers meet, at its top left. -
paintOverlay
Paints over everything, in the component's own bounds, whose top left isx,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) Sets the width of the pinned left column and the height of the pinned top row, in pixels. Called fromlayoutSurface. -
getHeaderWidth
public final int getHeaderWidth()The width of the pinned left column, in pixels. -
getHeaderHeight
public final int getHeaderHeight()The height of the pinned top row, in pixels. -
pressStarted
protected void pressStarted(int x, int y) The pointer went down at a point, in the component's coordinates. Whatever it turns into -- a tap, a drag, a long press -- follows. -
editStarted
Asked when a drag or a long press begins, at the point where the pointer went down, in the component's coordinates.
Parameters
trigger: what kind of gesture it is
Returns
true when an edit has begun and the drag belongs to it; false to pan
-
editMoved
protected void editMoved(int x, int y) The pointer of an edit moved, or the surface scrolled under it. -
editEnded
protected void editEnded(boolean committed) The edit is over.committedis false when it was cancelled: bycancelEdit, a second finger, or the surface leaving the form. -
isEditAutoScroll
protected boolean isEditAutoScroll(int x, int y) Whether the surface scrolls under an edit dragged near its edge. Asked on every move of an edit; true by default. -
tapped
protected void tapped(int x, int y, boolean doubleTap) A tap that was not a drag or a long press. -
longPressed
protected void longPressed(int x, int y) A long press that started no edit. -
scrollChanged
protected void scrollChanged()The scroll position changed. -
zoomBy
protected boolean zoomBy(float factor, int x, int y) Zooms by
factoraround a point, for a pinch or Control/Command and the wheel.Returns
false when the surface has no zoom, so the gesture is left alone
-
setDragEdits
public void setDragEdits(boolean dragEdits) Whether a plain drag may start an edit anywhere instead of only on handles. On by default where there is a mouse, which has a wheel to scroll with. -
isDragEdits
public boolean isDragEdits()SeesetDragEdits. -
cancelEdit
public void cancelEdit()Cancels an edit in progress, as Escape does;editEnded(false)follows. -
isEditInProgress
public boolean isEditInProgress()Whether an edit is being dragged. -
isBounded
public boolean isBounded()Whether the scroll position stays inside the content; true by default. -
setBounded
public void setBounded(boolean bounded) Lets the scroll position go anywhere, for content without edges. The sizesgetContentWidthandgetContentHeightreport are then not used to limit it. -
getBodyWidth
public final int getBodyWidth()The width of the content region, in pixels: the component without the left header. -
getBodyHeight
public final int getBodyHeight()The height of the content region, in pixels: the component without the top header. -
getMaxOffsetX
public final int getMaxOffsetX()The largest horizontal scroll position of bounded content. -
getMaxOffsetY
public final int getMaxOffsetY()The largest vertical scroll position of bounded content. -
getOffsetX
public final int getOffsetX()How far the content has scrolled to the left, in pixels. -
getOffsetY
public final int getOffsetY()How far the content has scrolled up, in pixels. -
scrollTo
public void scrollTo(int x, int y) Scrolls to a position, held inside bounded content. -
setOffsets
protected final void setOffsets(int x, int y) Sets the scroll position without holding it inside the content and without callingscrollChanged, for a view whose content moves under the scroll position (a zoom about a point, a change of date). -
refreshLayout
public void refreshLayout()Lays out for the current size and holds the scroll position inside bounded content. -
stopFling
protected final void stopFling()Stops a fling in progress. -
currentTime
protected final long currentTime()The time the surface animates by: the clock, or the one it was told to stand still at withsetAnimationTime. -
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. -
hoverAt
protected void hoverAt(int x, int y) The pointer rests at a point of the surface without being pressed. A view answers withsetHoverTarget, naming what is there and the cursor that says what a press would do. -
hoverGone
protected void hoverGone()The pointer left, or nothing is known of it any more. -
setHoverTarget
Names what the pointer is over -- any object with a meaningfulequals, or null for nothing -- and the cursor to show. -
setHoverTooltip
The tooltip of the thing the pointer is on, for an application that shows tooltips; null for none. -
getFadingHoverTarget
What the pointer has just left, while its hover fades. -
getHoverTarget
What the pointer is over, as the view named it. -
hasHoverFeedback
public final boolean hasHoverFeedback()Whether anything is lit by the pointer or still fading: a view that paints many items asks once before askinggetHoverLevelfor each. -
getHoverLevel
How far the hover ofkeyhas come up, from 0 to 1. -
getLiftLevel
public final float getLiftLevel()How far the item being dragged has risen off the surface, from 0 to 1. -
startSettle
An item was let go at a rectangle of the content that is not where it belongs:applySettlemoves it from there to its place. -
applySettle
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.
Returns
true while it travels
-
pointerHover
public void pointerHover(int[] x, int[] y) Description copied from class:ComponentInvoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerHoverin classComponent
-
-
setHovered
public void setHovered(boolean hovered) Description copied from class:ComponentMarks 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.
Parameters
hovered: true when the pointer is over this component
- Overrides:
setHoveredin classComponent
-
initComponent
protected void initComponent()Description copied from class:ComponentAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component state- Overrides:
initComponentin classComponent
-
requestAnimation
protected final void requestAnimation()Asks foranimateSurfaceto be called on the next frames, for a view with a motion of its own. Frames stop once nothing moves. -
animateSurface
protected boolean animateSurface()Advances the view's own motion. Called every frame while the surface animates; call
requestAnimationto start the frames.Returns
true while the view still has something moving
-
animate
public final boolean animate()Description copied from class:ComponentAllows the animation to reduce "repaint" calls when it returns false. It is called once for every frame. Frames are defined by the
com.codename1.ui.Displayclass.Returns
true if a repaint is desired or false if no repaint is necessary
-
deinitialize
protected void deinitialize()Description copied from class:ComponentInvoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. This allows the component to deregister animators and cleanup after itself. This method is the opposite of the initComponent() method.- Overrides:
deinitializein classComponent
-
paint
Description copied from class:ComponentThis 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.
Parameters
g: the component graphics
-
getPageGrid
How the content divides into pages of
widthbyheightpixels, 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
Paints one page: the content from
contentX,contentYon, under the headers that belong to it, atx,yin a page ofwidthbyheight.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()Whether a page is being painted and not the screen. -
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. Null for a view without a zoom. -
restoreZoomState
Puts back whatsaveZoomStatereturned. Called with the view laid out at its own size again. -
getPageStep
protected int getPageStep(int bodyHeight) How far down a page of content heightbodyHeightgoes 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
Description copied from class:ComponentCalculates the preferred size based on component content. This method is invoked lazily by getPreferred size.
Returns
the calculated preferred size based on component content
- Overrides:
calcPreferredSizein classComponent
-
pointerPressed
public void pointerPressed(int x, int y) Description copied from class:ComponentIf this Component is focused, the pointer pressed event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerPressedin classComponent
-
-
pointerDragged
public void pointerDragged(int x, int y) Description copied from class:ComponentIf this Component is focused, the pointer dragged event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerDraggedin classComponent
-
-
longPointerPress
public void longPointerPress(int x, int y) Description copied from class:ComponentIf this Component is focused this method is invoked when the user presses and holds the pointer on the Component- Overrides:
longPointerPressin classComponent
-
pointerReleased
public void pointerReleased(int x, int y) Description copied from class:ComponentIf this Component is focused, the pointer released event will call this method
Parameters
-
x: the pointer x coordinate -
y: the pointer y coordinate
- Overrides:
pointerReleasedin classComponent
-
-
mouseWheel
Description copied from class:ComponentHandles 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
ev: the wheel event, carrying the scroll deltas in display pixels
Returns
true when this component handled the wheel and nothing else should act on it
- Overrides:
mouseWheelin classComponent
-
pinch
protected boolean pinch(float scale) Description copied from class:ComponentInvoked by subclasses interested in handling pinch to zoom events, if true is returned other drag events will not be broadcast
Parameters
scale: @param scale 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
false by default
-
pinchReleased
protected void pinchReleased(int x, int y) Description copied from class:ComponentTo 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).
Parameters
-
x: The x-coordinate of the remaining finger in the drag. (Absolute) -
y: The y-coordinate of the remaining finger in the drag. (Absolute)
- Overrides:
pinchReleasedin classComponent
-
-
shouldBlockSideSwipe
protected boolean shouldBlockSideSwipe()Description copied from class:ComponentA 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.- Overrides:
shouldBlockSideSwipein classComponent
-