org.swiftgantt
Class GanttChart

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by org.swiftgantt.GanttChart
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.ScrollPaneConstants, SelectionChangeListener, GanttModelListener

public class GanttChart
extends javax.swing.JScrollPane
implements GanttModelListener, java.beans.PropertyChangeListener, SelectionChangeListener

The GanttChart is a Swing component that represents a Gantt chart. To display the Gantt chart as what you want, you should get the Config object from GanttChart instance, the config object contains all the configuration for the GanttChart, change properties of it to config the gantt chart displaying. To put data into GanttChart,initialize the GanttModel and set to the GanttChart.

Author:
Yuxing Wang
See Also:
Config, TimeUnit, GanttModel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GanttChart()
           
 
Method Summary
 void addSelectionChangeListener(SelectionChangeListener l)
          Add selection change listener.
 void addTimeUnitChangeListener(TimeUnitChangeListener l)
          Add TimeUnit change listener.
 void fireSelectionChange(java.lang.Object source, Task selection)
           
 void fireTimeUnitChange(java.lang.Object source, java.lang.Object oldTimeUnit, java.lang.Object newTimeUnit)
          Invoke this method after TimeUnit of GanttChart has been changed.
 void ganttModelChanged(GanttModelChangeEvent e)
          Handle the event that model changed.
 void generateImageFile(java.lang.String fileName)
          Generate image file from the view of GanttChart.
 Config getConfig()
          get Config
 GanttModel getModel()
          Get the GanttModel for Gantt chart.
static Config getStaticConfig()
          get Config
 org.swiftgantt.ui.TimeUnit getTimeUnit()
          Get TimeUnit as singleton.
 boolean isShowTreeView()
          Whether display task tree view.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Handler the Config changes.
 void resumeUI()
          Resume UI to refresh.
 void selectionChanged(SelectionChangeEvent e)
          Handle Selection Changed Event.
 void setModel(GanttModel ganttModel)
          Set new GanttModel to the GanttChart.
 void setSelectedTasks(java.util.List<Task> tasks)
          Set selected tasks.
 void setSelectedTasks(Task... tasks)
          Set selected tasks.
 void setShowTreeView(boolean showTreeView)
          Set to display or hide the task tree view.
 void setTimeUnit(org.swiftgantt.ui.TimeUnit timeUnit)
          Set the singleton TimeUnit of GanttChart
 void suspendUI()
          Suspend UI to avoid refresh.
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GanttChart

public GanttChart()
Method Detail

ganttModelChanged

public void ganttModelChanged(GanttModelChangeEvent e)
Handle the event that model changed.

Specified by:
ganttModelChanged in interface GanttModelListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Handler the Config changes.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

generateImageFile

public void generateImageFile(java.lang.String fileName)
                       throws java.io.IOException
Generate image file from the view of GanttChart.

Parameters:
fileName - Support *.png and *.jpg file only.
Throws:
java.io.IOException

addTimeUnitChangeListener

public void addTimeUnitChangeListener(TimeUnitChangeListener l)
Add TimeUnit change listener.

Parameters:
l -

addSelectionChangeListener

public void addSelectionChangeListener(SelectionChangeListener l)
Add selection change listener.

Parameters:
l -

getTimeUnit

public org.swiftgantt.ui.TimeUnit getTimeUnit()
Get TimeUnit as singleton.

Returns:
the timeUnit

setTimeUnit

public void setTimeUnit(org.swiftgantt.ui.TimeUnit timeUnit)
Set the singleton TimeUnit of GanttChart

Parameters:
timeUnit - the timeUnit to set

getStaticConfig

public static Config getStaticConfig()
get Config

Returns:

getConfig

public Config getConfig()
get Config

Returns:

getModel

public GanttModel getModel()
Get the GanttModel for Gantt chart.

Returns:
the model

setModel

public void setModel(GanttModel ganttModel)
Set new GanttModel to the GanttChart.

Parameters:
ganttModel -

setSelectedTasks

public void setSelectedTasks(Task... tasks)
Set selected tasks.

Parameters:
task -
Since:
0.3.4

setSelectedTasks

public void setSelectedTasks(java.util.List<Task> tasks)
Set selected tasks.

Parameters:
tasks -
Since:
0.3.4

fireTimeUnitChange

public void fireTimeUnitChange(java.lang.Object source,
                               java.lang.Object oldTimeUnit,
                               java.lang.Object newTimeUnit)
Invoke this method after TimeUnit of GanttChart has been changed.

Parameters:
source -
oldTimeUnit -
newTimeUnit -

fireSelectionChange

public void fireSelectionChange(java.lang.Object source,
                                Task selection)
Parameters:
source -
selection -
Since:
0.3.4

selectionChanged

public void selectionChanged(SelectionChangeEvent e)
Handle Selection Changed Event.

Specified by:
selectionChanged in interface SelectionChangeListener

isShowTreeView

public boolean isShowTreeView()
Whether display task tree view.

Returns:

setShowTreeView

public void setShowTreeView(boolean showTreeView)
Set to display or hide the task tree view.

Parameters:
showTreeView -

suspendUI

public void suspendUI()
Suspend UI to avoid refresh.

Since:
0.3.2

resumeUI

public void resumeUI()
Resume UI to refresh.

Since:
0.3.2