Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class Gantt
ImplementsAnimation, Editable, Iterable<Component>, StyleListener
A Gantt chart of a ProjectModel: the tree of tasks in a table on the
left, a bar for each against a time axis on the right, the links between
them, and under them how much of every resource the plan asks for.
WorkCalendar calendar = new WorkCalendar();
// A duration is working time: a day of it is the calendar's hours.
long day = calendar.getMillisPerDay();
ProjectModel project = new ProjectModel(calendar, System.currentTimeMillis());
GanttTask design = new GanttTask("design", "Design", 5 * day);
GanttTask build = new GanttTask("build", "Build", 10 * day);
project.addTask(design).addTask(build);
project.link(design, build);
project.update();
Form form = new Form("Plan", new BorderLayout());
form.add(BorderLayout.CENTER, new Gantt(project));
form.show();

The chart draws its rows and keeps no component for each, so a plan of
thousands of tasks scrolls as one of ten does. Time zooms with a pinch,
with the wheel and the control key held, or with zoomIn, zoomOut and
zoomToFit.
Editing
A bar is dragged to move it and by its end to change its duration. With a mouse that is a plain drag; on a touch screen a drag scrolls, so a long press picks the bar up. The selected task shows a marker under its bar, dragged to set how much of it is done, and a dot after its end, dragged onto another bar to make that one depend on it.
A task the project schedules is not placed by a drag: the drag sets a
“start no earlier than” constraint, and the task then starts there or
later if its predecessors say so. A manually scheduled task is given the
dates as they are. Every change is offered to the listeners first, which
may refuse it, and then the project is scheduled again and the bars slide
to where they now are. A summary task follows its children and is not
dragged. The table is not edited in place: a double tap is reported to
GanttListener#taskOpened, for an application’s own editor.
Under a mouse the bar the pointer is over lights up together with the links into and out of it, the row is marked in the table and in the chart, the cursor says what a drag would do and a tooltip gives the task’s dates and progress. A bar that is picked up lifts over a shadow.

setAnimationTime stops the clock these run by, for a screenshot or a
test of a moment in the middle of one.
Resources
setLoadVisible(true) shows the load of every resource under the chart.
A stretch over the resource’s capacity is drawn in GanttOverload.
level() delays tasks until no resource is asked for more than it has,
as far as that can be done.

Styling
GanttRow is a row, with its selected style the selected one, and
GanttSummaryRow the row of a summary task; GanttHeader the time
axis and the titles of the table. The bars are GanttBar, with
GanttBarProgress the part done, GanttBarCritical, GanttSummaryBar
and GanttMilestone; GanttBaseline is the plan as it was captured.
GanttLink and GanttLinkCritical give the links their foreground
colour, GanttLoad and GanttOverload the resource load. A task that
names a UIID or a colour of its own is painted with that.
Nested types
enum Gantt.Column | The columns the table can show after the name of a task. |
Constructors
public Gantt() | A chart with no project yet. |
public Gantt(ProjectModel model) |
Methods
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 Container
encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, keyReleased, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, 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, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, 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, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, getHoverStyle, setHoverStyle, isHovered, setHovered, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, animate, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, getPropertyNames, getPropertyTypes, getPropertyTypeNames, getPropertyValue, setPropertyValue, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, 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
From Iterable
Constructor details
Gantt
public Gantt()Gantt
public Gantt(ProjectModel model)Method details
layoutContainer
public void layoutContainer()isToolbarVisible
public boolean isToolbarVisible()setToolbarVisible
public void setToolbarVisible(boolean v)getModel
public ProjectModel getModel()setModel
public void setModel(ProjectModel m)m is null.refresh
public void refresh()initComponent
protected void initComponent()deinitialize
protected void deinitialize()level
public LevelingResult level()isShowCriticalPath
public boolean isShowCriticalPath()setShowCriticalPath
public void setShowCriticalPath(boolean v)isShowBaseline
public boolean isShowBaseline()setShowBaseline
public void setShowBaseline(boolean v)isShowLinks
public boolean isShowLinks()setShowLinks
public void setShowLinks(boolean v)isEditable
public boolean isEditable()setEditable
public void setEditable(boolean v)setDragEdits
public void setDragEdits(boolean v)isLoadVisible
public boolean isLoadVisible()setLoadVisible
public void setLoadVisible(boolean v)isTableVisible
public boolean isTableVisible()setTableVisible
public void setTableVisible(boolean v)setColumns
public void setColumns(Gantt.Column... c)is24Hours
public boolean is24Hours()set24Hours
public void set24Hours(boolean v)getFirstDayOfWeek
public int getFirstDayOfWeek()setFirstDayOfWeek
public void setFirstDayOfWeek(int isoDay)getBarRenderer
public GanttBarRenderer getBarRenderer()setBarRenderer
public void setBarRenderer(GanttBarRenderer r)setCurrentTime
public void setCurrentTime(long millis)setAnimationTime
public void setAnimationTime(long millis)Stops the clock the chart 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 slide of the bars to their new dates are drawn as far along as that time makes them. A negative value returns to the clock.
Gantt gantt = new Gantt();
gantt.setAnimationTime(1000); // nothing has started
// ... press, drag, release ...
gantt.setAnimationTime(1100); // 100 milliseconds into what followed
isCollapsed
public boolean isCollapsed(GanttTask task)setCollapsed
public void setCollapsed(GanttTask task, boolean v)expandAll
public void expandAll()collapseAll
public void collapseAll()zoomIn
public void zoomIn()zoomOut
public void zoomOut()zoomToFit
public void zoomToFit()scrollToTask
public void scrollToTask(GanttTask task)scrollToDate
public void scrollToDate(long time)getSelectedTask
public GanttTask getSelectedTask()setSelectedTask
public void setSelectedTask(GanttTask task)task is null. The listeners are
not told: this is the application’s own doing.addGanttListener
public void addGanttListener(GanttListener l)removeGanttListener
public void removeGanttListener(GanttListener l)