Class Scheduler
- All Implemented Interfaces:
Animation, Editable, StyleListener, Iterable<Component>
A schedule on screen: the items of a ScheduleModel by day, week, month,
as an agenda, or by resource.
long start = System.currentTimeMillis();
DefaultScheduleModel model = new DefaultScheduleModel();
model.addItem(new ScheduleItem("1", "Design review", start, start + TimeMath.HOUR));
Scheduler scheduler = new Scheduler(model);
scheduler.setView(Scheduler.View.WEEK);
Form form = new Form("Schedule", new BorderLayout());
form.add(BorderLayout.CENTER, scheduler);
form.show();

The same items by the day, by the month and against the people they are booked for:

The views draw their items and keep no component for each, so a schedule of thousands of items scrolls as one of ten does. Time zooms with a pinch or with the wheel and the control key held.
Editing
With a mouse an item is dragged to move it and by its edge to resize it,
and a drag across empty time selects a range. On a touch screen a drag
scrolls, so a long press picks an item up or starts a range, and the
selected item has handles to resize it by. Every change is offered to the
listeners first, then made through ScheduleModel#updateItem, and either
may refuse. setEditable(false) makes the scheduler read only.
Pointer and motion
Under a mouse the item the pointer is over lights up, free time shows the slot a drag would start in, the cursor says what a drag would do, and a tooltip gives the item's title and time. An item that is picked up lifts: a shadow comes up under it and the place it left dims. Let go, it glides from where it was dropped to where it belongs. Each takes under a quarter of a second.

setAnimationTime stops the clock these run by, for a screenshot or a
test of a moment in the middle of one.
Styling
SchedulerGrid is the background, with its foreground the colour of the
lines; SchedulerOffHours shades the time outside a WorkCalendar;
SchedulerHeader, SchedulerHeaderToday and SchedulerTimeLabel are the
headings; SchedulerItem, SchedulerBackgroundItem and
SchedulerBlocked the items by kind; SchedulerNow the current time and
SchedulerSelection a range being dragged out. The bar above the views
is SchedulerToolbar, SchedulerTitle and SchedulerViewButton. An item
that names a UIID of its own is painted with that one.

-
Nested Class Summary
Nested Classes -
Field Summary
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidInvoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy.formatRange(long start, long end) A start and an end as the views write them: "9:00 AM - 10:30 AM".formatTime(long millis) The time of day of an instant, as the views write it.intlonggetDate()The start of the day the view is anchored on.intintintgetModel()getResource(String id) The resource with an id, or null.intintgetView()longThe end of what the view shows, exclusive.longThe start of what the view shows, inclusive.getZone()protected voidAllows subclasses to bind functionality that relies on fully initialized and "ready for action" component statebooleanWhether times are written on a 24 hour clock.booleanbooleanChecks to see if the component is editable.booleanbooleanvoidThe bar is a row where there is room for one, and two rows on a screen as narrow as a phone's.voidnext()Moves forward by what the view shows: a day, a week, a month.voidprevious()voidrefresh()Reads the model again.voidvoidset24Hours(boolean v) voidsetAgendaDays(int days) How many days the agenda lists.voidsetAnimationTime(long millis) Stops the clock the scheduler animates by at a time, for a screenshot of an animation or a test of one: the light of a hover, the rise of an item that is picked up and the travel of one that was dropped are drawn as far along as that time makes them.voidsetCompactToolbar(boolean v) Whether the views are picked from one button with a menu, as on a phone, or each has a button of its own.voidsetCurrentTime(long millis) Fixes what the scheduler takes the current time to be, for a screenshot or a test.voidsetDate(long millis) Shows the day, week or month that an instant is in.voidsetDefaultMinutes(int minutes) The length of a range chosen without dragging, by a long press or a double click.voidsetDragEdits(boolean v) Whether a plain drag edits: moves the item under it, or selects a range of empty time.voidsetEditable(boolean v) Whether items can be dragged and ranges selected.voidsetFirstDayOfWeek(int isoDay) The day a week starts on: 1 for Monday, which is the default, to 7 for Sunday.voidsetInitialMinute(int minute) The time of day the day and week views open scrolled to, in minutes since midnight.voidvoidvoidsetOpenOnTap(boolean v) Whether a single tap opens an item.voidsetSelectedItem(ScheduleItem item) Selects an item, or nothing whenitemis null.voidsetSnapMinutes(int minutes) What a drag snaps to, in minutes.voidsetTimelineDays(int days) How many days the resource timeline covers.voidsetToolbarVisible(boolean v) Whether the bar with the title and the buttons is shown.voidvoidsetViews(Scheduler.View... offered) The views the toolbar offers, in order.voidThe working hours: time outside them is shaded, and the work week shows the days this calendar works.voidThe zone the days and hours are those of.voidtoday()Shows the current day, week or month.Methods inherited from class Container
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, calcPreferredSize, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndicesMethods inherited from class Component
accessibilityChanged, accessibilityChanged, addContextMenuListener, addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addMouseWheelListener, addNativeDragOverListener, addNativeDropListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, addStylusListener, animate, announceForAccessibility, bindProperty, blocksSideSwipe, calcScrollSize, canAcceptNativeDrop, consumesRawTextInput, contains, containsOrOwns, createNativeDragOperation, createStyleAnimation, deinitializeCustomStyle, deregisterFromAnimation, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAcceptedDropActions, getAcceptedDropMimeTypes, getAccessibilityNode, getAccessibilityText, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getContextMenuCommands, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, 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, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getTopLevelContainer, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isHovered, isHScrollThumbGrabbed, isHScrollThumbHover, isIgnorePointerEvents, isInClippingRegion, isInitialized, isNativeDragSource, isNativeDropTarget, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, isVScrollThumbGrabbed, isVScrollThumbHover, keyRepeated, laidOut, longKeyPress, longPointerPress, mouseWheel, nativeDragEnter, nativeDragExit, nativeDragOver, nativeDrop, onScrollX, onScrollY, onSetFocusable, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, 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, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setContextMenuCommands, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setHorizontalScrollBounds, setHovered, 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, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUIIDFinal, setUnselectedStyle, setVerticalScrollBounds, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stopScrollMomentum, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContainsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
Scheduler
public Scheduler()A scheduler with nothing in it yet. -
Scheduler
-
-
Method Details
-
layoutContainer
public void layoutContainer()The bar is a row where there is room for one, and two rows on a screen as narrow as a phone's. It is decided here because this is the first place the width is known.- Overrides:
layoutContainerin classContainer
-
setToolbarVisible
public void setToolbarVisible(boolean v) Whether the bar with the title and the buttons is shown. An application with navigation of its own hides it and callsnext,previous,todayandsetViewitself. -
isToolbarVisible
public boolean isToolbarVisible() -
setCompactToolbar
public void setCompactToolbar(boolean v) Whether the views are picked from one button with a menu, as on a phone, or each has a button of its own. -
isCompactToolbar
public boolean isCompactToolbar() -
getModel
-
setModel
-
refresh
public void refresh()Reads the model again. A model that fires its change listeners needs no call to this. -
getResource
The resource with an id, or null. -
getView
-
setView
-
setViews
The views the toolbar offers, in order. The default is day, week, month and agenda; a schedule with resources adds the two resource views. -
setDate
public void setDate(long millis) Shows the day, week or month that an instant is in. -
getDate
public long getDate()The start of the day the view is anchored on. -
next
public void next()Moves forward by what the view shows: a day, a week, a month. -
previous
public void previous() -
today
public void today()Shows the current day, week or month. -
getVisibleStart
public long getVisibleStart()The start of what the view shows, inclusive. -
getVisibleEnd
public long getVisibleEnd()The end of what the view shows, exclusive. -
getZone
-
setZone
The zone the days and hours are those of. The default is the device's. -
getFirstDayOfWeek
public int getFirstDayOfWeek() -
setFirstDayOfWeek
public void setFirstDayOfWeek(int isoDay) The day a week starts on: 1 for Monday, which is the default, to 7 for Sunday. -
getWorkCalendar
-
setWorkCalendar
The working hours: time outside them is shaded, and the work week shows the days this calendar works. A resource with a calendar of its own is shaded by that one. Null, the default, shades nothing. -
is24Hours
public boolean is24Hours()Whether times are written on a 24 hour clock. The default follows the device's locale. -
set24Hours
public void set24Hours(boolean v) -
getSnapMinutes
public int getSnapMinutes() -
setSnapMinutes
public void setSnapMinutes(int minutes) What a drag snaps to, in minutes. The default is 15. -
getDefaultMinutes
public int getDefaultMinutes() -
setDefaultMinutes
public void setDefaultMinutes(int minutes) The length of a range chosen without dragging, by a long press or a double click. The default is 60. -
getInitialMinute
public int getInitialMinute() -
setInitialMinute
public void setInitialMinute(int minute) The time of day the day and week views open scrolled to, in minutes since midnight. The default is 07:00. -
getTimelineDays
public int getTimelineDays() -
setTimelineDays
public void setTimelineDays(int days) How many days the resource timeline covers. The default is 7. -
getAgendaDays
public int getAgendaDays() -
setAgendaDays
public void setAgendaDays(int days) How many days the agenda lists. The default is 30. -
isEditable
public boolean isEditable()Description copied from class:ComponentChecks to see if the component is editable. This is used for next/previous focus traversal on forms.
See also
-
#getEditingDelegate()
-
#setEditingDelegate(com.codename1.ui.Editable)
-
#isEditing()
-
#startEditingAsync()
-
#stopEditing(java.lang.Runnable)
- Specified by:
isEditablein interfaceEditable- Overrides:
isEditablein classComponent
-
-
setEditable
public void setEditable(boolean v) Whether items can be dragged and ranges selected. Selecting and opening an item work either way. -
isOpenOnTap
public boolean isOpenOnTap() -
setOpenOnTap
public void setOpenOnTap(boolean v) Whether a single tap opens an item. The default is true on a touch screen and false where there is a mouse, which double clicks to open. -
setDragEdits
public void setDragEdits(boolean v) Whether a plain drag edits: moves the item under it, or selects a range of empty time. The default is true where there is a mouse and false on a touch screen, where a drag scrolls and a long press edits. -
getItemRenderer
-
setItemRenderer
-
setCurrentTime
public void setCurrentTime(long millis) Fixes what the scheduler takes the current time to be, for a screenshot or a test. A negative value returns to the clock. -
setAnimationTime
public void setAnimationTime(long millis) Stops the clock the scheduler animates by at a time, for a screenshot of an animation or a test of one: the light of a hover, the rise of an item that is picked up and the travel of one that was dropped are drawn as far along as that time makes them. A negative value returns to the clock.
scheduler.setAnimationTime(1000); // nothing has started // ... press, drag, release ... scheduler.setAnimationTime(1100); // 100 milliseconds into what followed -
getSelectedItem
-
setSelectedItem
Selects an item, or nothing whenitemis null. The listeners are not told: this is the application's own doing. -
addSchedulerListener
-
removeSchedulerListener
-
formatTime
The time of day of an instant, as the views write it. -
formatRange
A start and an end as the views write them: "9:00 AM - 10:30 AM". -
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
-
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
-