JIDE 3.5.15

com.jidesoft.gantt
Class GanttChart<T,S extends GanttEntry<T>>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.jidesoft.gantt.GanttChart<T,S>
Type Parameters:
T - The type of the bases unit of the scale, for example Date or Integer.
S - The type of the GanttEnty in the model.
All Implemented Interfaces:
GanttEntryRelationListener, GanttModelListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, ListSelectionListener, Scrollable
Direct Known Subclasses:
DateGanttChart

public class GanttChart<T,S extends GanttEntry<T>>
extends JComponent
implements Scrollable, GanttModelListener, GanttEntryRelationListener, ListSelectionListener, PropertyChangeListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String PROPERTY_EDITABLE
           
static String PROPERTY_GANTT_MODEL
           
static String PROPERTY_GRID_COLOR
           
static String PROPERTY_LABEL_ENTRY_GAP
           
static String PROPERTY_LABEL_POSITION
           
static String PROPERTY_ROW_HEIGHT
           
static String PROPERTY_ROW_MARGIN
           
static String PROPERTY_SCALE_AREA
           
static String PROPERTY_SHOW_GRID
           
static String PROPERTY_VIEW_MODE
           
static int VIEW_MODE_EDITING
           
static int VIEW_MODE_PANNING
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GanttChart()
           
GanttChart(GanttModel<T,S> model)
           
GanttChart(GanttModel<T,S> model, ScaleArea<T> scaleArea)
           
GanttChart(ScaleArea<T> scaleArea)
           
 
Method Summary
 void addNotify()
          Calls the configureEnclosingScrollPane method.
 void addPeriodBackgroundPainter(int index, PeriodBackgroundPainter<T> painter)
          Adds a painter to chart to paint behind the Gantt entries.
 void addPeriodBackgroundPainter(PeriodBackgroundPainter<T> painter)
           
 void addSelectionInterval(int index0, int index1)
          Adds the rows from index0 to index1, inclusive, to the current selection.
 void autoResizePeriods(boolean visibleRowsOnly)
          Automatically resizes the periods width and changes the visible periods to fit the range of the GanttModel.
 void changeSelection(int rowIndex, boolean toggle, boolean extend)
          Updates the selection models of the table, depending on the state of the two flags: toggle and extend.
 void clearSelection()
          Deselects all selected entries.
protected  void configureEnclosingScrollPane()
          If this GanttChart is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's scaleArea as the columnHeaderView of the scroll pane.
protected  ListSelectionModel createDefaultSelectionModel()
          Returns the default selection model object, which is a DefaultListSelectionModel.
 void ensureRowIsVisible(int index)
          Scrolls the list within an enclosing viewport to make the specified cell completely visible.
 void ganttChartChanged(GanttModelEvent e)
          This method notifies the listeners that something is changed in the GanttModel.
 void ganttEntryRelationChanged(GanttEntryRelationEvent e)
           
 int getAnchorSelectionIndex()
          Returns the anchor selection index.
 GanttEntryRenderer getDefaultEntryRenderer()
          Gets the default GanttEntryRenderer.
 GanttLabelRenderer getDefaultLabelRenderer()
          Gets the default GanttLabelRenderer.
 S getEntryAt(int index)
          Gets the gantt entry by index.
 S getEntryAt(int index, int subEntryIndex)
          Gets the gantt entry by index and sub entry index.
 S getEntryAt(Point point)
          Gets the gantt entry at the point.
 int getEntryCount()
          Gets the count of entries inside the gantt model.
 Rectangle getEntryRect(GanttEntry<T> entry, int row)
           
 Rectangle getEntryRect(int row)
          Returns a rectangle for the row, clipped by the Range of the GanttEntry at that row.
 GanttEntryRenderer getEntryRenderer(int row)
          Returns an appropriate renderer for the row specified by the row index.
 GanttEntryRenderer getEntryRenderer(int row, int column)
          Returns an appropriate renderer for the row specified by the row index.
 Color getGridColor()
          Returns the color used to draw grid lines.
 int getIndexOf(S entry)
          Gets the index of gantt entry.
 int getLabelEntryGap()
          Gets the gap between the label and the entry.
 int getLabelPosition()
          Gets the label position relative to the entry.
 GanttLabelRenderer getLabelRenderer(int row)
          Returns an appropriate renderer for the row specified by the row index.
 GanttLabelRenderer getLabelRenderer(int row, int column)
          Returns an appropriate renderer for the row specified by the row index.
 int getLeadSelectionIndex()
          Returns the lead selection index.
 int getMaxSelectionIndex()
          Returns the largest selected cell index, or -1 if the selection is empty.
 int getMinSelectionIndex()
          Returns the smallest selected cell index, or -1 if the selection is empty.
 GanttModel<T,S> getModel()
           
 List<PeriodBackgroundPainter<T>> getPeriodBackgroundPainters()
           
 Dimension getPreferredScrollableViewportSize()
           
 GanttEntryRelationPainter getRelationPainter(int relationType)
           
 int getResizeAreaWidth()
          Gets the pixels for the width of the resize area.
 String getResourceString(String key)
          Gets the localized string from resource bundle.
 int getRowHeight()
          Returns the height of a table row, in pixels.
 int getRowHeight(int row)
          Returns the height, in pixels, of the cells in row.
 int getRowMargin()
          Gets the amount of empty space, in pixels, between cells.
 Rectangle getRowRect(int row, boolean includingSpacing)
           
 ScaleArea<T> getScaleArea()
           
 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
           
 boolean getScrollableTracksViewportHeight()
           
 boolean getScrollableTracksViewportWidth()
           
 int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
           
 int getSelectedRow()
          Returns the index of the first selected entry, -1 if no entry is selected.
 int getSelectedRowCount()
          Returns the number of selected entries.
 int[] getSelectedRows()
          Returns the indices of all selected entries.
 Color getSelectionBackground()
          Returns the background color for selected cells.
 Color getSelectionForeground()
          Returns the foreground color for the rows of the selected entries.
 int getSelectionMode()
          Returns the current selection mode for the list.
 ListSelectionModel getSelectionModel()
           
 String getToolTipText(MouseEvent event)
           
 int getTotalRowHeight()
           
 GanttChartUI getUI()
           
 String getUIClassID()
           
 boolean getValueIsAdjusting()
          Returns the value of the selection model's isAdjusting property.
 int getViewMode()
           
 boolean isAllowMoveEntry()
          Gets the flag indicating if drag and move gantt entry is allowed.
 boolean isAllowResizeEntry(GanttEntry<T> entry, T start, T end)
          Checks if the entry is allowed to be resized as designated start & end.
 boolean isEditable()
           
 boolean isResizeEastArea(Point point, Rectangle entryRect)
          Checks if the point is in the resize east area.
 boolean isResizeWestArea(Point point, Rectangle entryRect)
          Checks if the point is in the resize west area.
 boolean isRowHeightSet()
           
 boolean isRowSelected(int index)
          Returns true if the specified index is in the valid range of entries, and the entry at that index is selected.
 boolean isShowGrid()
           
 Component prepareLabelRenderer(GanttLabelRenderer renderer, int row)
          Prepares the renderer by querying the data model for the value and selection state of the cell at row, column.
 Component prepareLabelRenderer(GanttLabelRenderer renderer, int row, int column)
          Prepares the renderer by querying the data model for the value and selection state of the cell at row, column.
 Component prepareRenderer(GanttEntryRenderer renderer, int row, Insets insets)
          Deprecated. replaced by prepareRenderer(GanttEntryRenderer, int, int, java.awt.Insets)
 Component prepareRenderer(GanttEntryRenderer renderer, int row, int column, Insets insets)
          Prepares the renderer by querying the data model for the value and selection state of the cell at row, column.
 void propertyChange(PropertyChangeEvent evt)
           
 void removePeriodBackgroundPainter(PeriodBackgroundPainter<T> painter)
           
 void removeSelectionInterval(int index0, int index1)
          Deselects the rows from index0 to index1, inclusive.
 void repaint(long tm, int x, int y, int width, int height)
           
protected  void resizeAndRepaint()
          Equivalent to revalidate followed by repaint.
 int rowAtPoint(Point point)
          Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].
 void scrollRowToVisible(int rowIndex)
           
 void scrollSpanToVisible(Range<T> span)
           
 void scrollSpanToVisible(T start, T end)
           
 void selectAll()
           
 void setAllowMoveEntry(boolean allowMoveEntry)
          Sets the flag indicating if drag and move gantt entry is allowed.
 void setDefaultEntryRenderer(GanttEntryRenderer defaultEntryRenderer)
          Sets the default GanttEntryRenderer.
 void setDefaultLabelRenderer(GanttLabelRenderer defaultLabelRenderer)
          Sets the default GanttLabelRenderer.
 void setEditable(boolean editable)
           
 void setGridColor(Color gridColor)
          Sets the color used to draw grid lines to gridColor and redisplays.
 void setLabelEntryGap(int labelEntryGap)
          Sets the label and the entry gap.
 void setLabelPosition(int labelPosition)
          Sets the label position.
 void setModel(GanttModel<T,S> model)
           
 void setRelationPainter(int relationType, GanttEntryRelationPainter painter)
           
 void setResizeAreaWidth(int resizeAreaWidth)
          Sets the pixels for the width of the resize area.
 void setRowHeight(int rowHeight)
          Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints.
 void setRowHeight(int row, int rowHeight)
          Sets the height for row to rowHeight, revalidates, and repaints.
 void setRowMargin(int rowMargin)
          Sets the amount of empty space between cells in adjacent rows.
 void setScaleArea(ScaleArea<T> scaleArea)
           
 void setSelectedIndex(int index)
          Selects a single cell.
 void setSelectionBackground(Color selectionBackground)
          Sets the background color for selected cells.
 void setSelectionForeground(Color selectionForeground)
          Sets the foreground color for the rows of the selected entries.
 void setSelectionInterval(int index0, int index1)
          Selects the rows from index0 to index1, inclusive.
 void setSelectionMode(int selectionMode)
          Sets the gantt chart's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.
 void setSelectionModel(ListSelectionModel selectionModel)
           
 void setShowGrid(boolean showGrid)
          Sets whether the table draws grid lines around cells.
protected  void setUI(GanttChartUI newUI)
           
 void setValueIsAdjusting(boolean b)
          Sets the selection model's valueIsAdjusting property.
 void setViewMode(int viewMode)
          If enabled, mouse editing and mouse drag selection is disabled.
 void updateUI()
           
 void valueChanged(ListSelectionEvent e)
           
 void zoomInPeriods()
           
 void zoomOutPeriods()
           
 void zoomPeriods(double factor)
           
 void zoomPeriods(T start, T end)
          Automatically resizes the periods width and changes the visible periods to fit the specified range.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_SCALE_AREA

public static final String PROPERTY_SCALE_AREA
See Also:
Constant Field Values

PROPERTY_GANTT_MODEL

public static final String PROPERTY_GANTT_MODEL
See Also:
Constant Field Values

PROPERTY_EDITABLE

public static final String PROPERTY_EDITABLE
See Also:
Constant Field Values

PROPERTY_VIEW_MODE

public static final String PROPERTY_VIEW_MODE
See Also:
Constant Field Values

PROPERTY_ROW_HEIGHT

public static final String PROPERTY_ROW_HEIGHT
See Also:
Constant Field Values

PROPERTY_ROW_MARGIN

public static final String PROPERTY_ROW_MARGIN
See Also:
Constant Field Values

PROPERTY_GRID_COLOR

public static final String PROPERTY_GRID_COLOR
See Also:
Constant Field Values

PROPERTY_SHOW_GRID

public static final String PROPERTY_SHOW_GRID
See Also:
Constant Field Values

PROPERTY_LABEL_POSITION

public static final String PROPERTY_LABEL_POSITION
See Also:
Constant Field Values

PROPERTY_LABEL_ENTRY_GAP

public static final String PROPERTY_LABEL_ENTRY_GAP
See Also:
Constant Field Values

VIEW_MODE_EDITING

public static final int VIEW_MODE_EDITING
See Also:
Constant Field Values

VIEW_MODE_PANNING

public static final int VIEW_MODE_PANNING
See Also:
Constant Field Values
Constructor Detail

GanttChart

public GanttChart()

GanttChart

public GanttChart(GanttModel<T,S> model)

GanttChart

public GanttChart(ScaleArea<T> scaleArea)

GanttChart

public GanttChart(GanttModel<T,S> model,
                  ScaleArea<T> scaleArea)
Method Detail

setScaleArea

public void setScaleArea(ScaleArea<T> scaleArea)

getScaleArea

public ScaleArea<T> getScaleArea()

getModel

public GanttModel<T,S> getModel()

isEditable

public boolean isEditable()

setEditable

public void setEditable(boolean editable)

ganttEntryRelationChanged

public void ganttEntryRelationChanged(GanttEntryRelationEvent e)
Specified by:
ganttEntryRelationChanged in interface GanttEntryRelationListener

ganttChartChanged

public void ganttChartChanged(GanttModelEvent e)
Description copied from interface: GanttModelListener
This method notifies the listeners that something is changed in the GanttModel.

Specified by:
ganttChartChanged in interface GanttModelListener
Parameters:
e - the GanttModelEvent.

setModel

public void setModel(GanttModel<T,S> model)

getPreferredScrollableViewportSize

public Dimension getPreferredScrollableViewportSize()
Specified by:
getPreferredScrollableViewportSize in interface Scrollable

getScrollableBlockIncrement

public int getScrollableBlockIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Specified by:
getScrollableBlockIncrement in interface Scrollable

getScrollableTracksViewportHeight

public boolean getScrollableTracksViewportHeight()
Specified by:
getScrollableTracksViewportHeight in interface Scrollable

getScrollableTracksViewportWidth

public boolean getScrollableTracksViewportWidth()
Specified by:
getScrollableTracksViewportWidth in interface Scrollable

getScrollableUnitIncrement

public int getScrollableUnitIncrement(Rectangle visibleRect,
                                      int orientation,
                                      int direction)
Specified by:
getScrollableUnitIncrement in interface Scrollable

setUI

protected void setUI(GanttChartUI newUI)

getUIClassID

public String getUIClassID()
Overrides:
getUIClassID in class JComponent

getUI

public GanttChartUI getUI()

updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

addNotify

public void addNotify()
Calls the configureEnclosingScrollPane method.

Overrides:
addNotify in class JComponent
See Also:
configureEnclosingScrollPane()

configureEnclosingScrollPane

protected void configureEnclosingScrollPane()
If this GanttChart is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's scaleArea as the columnHeaderView of the scroll pane. When a GanttChart is added to a JScrollPane in the usual way, using new JScrollPane(myGanttChart), addNotify is called in the GanttChart (when the table is added to the viewport). GanttChart's addNotify method in turn calls this method, which is protected so that this default installation procedure can be overridden by a subclass.

See Also:
addNotify()

getEntryCount

public int getEntryCount()
Gets the count of entries inside the gantt model.

Returns:
the entry count.

getEntryAt

public S getEntryAt(Point point)
Gets the gantt entry at the point.

Parameters:
point - the mouse point
Returns:
the gantt entry.

getEntryAt

public S getEntryAt(int index)
Gets the gantt entry by index.

Parameters:
index - the index
Returns:
the gantt entry.

getEntryAt

public S getEntryAt(int index,
                    int subEntryIndex)
Gets the gantt entry by index and sub entry index.

Parameters:
index - the index
subEntryIndex - the sub entry index
Returns:
the gantt entry.

getIndexOf

public int getIndexOf(S entry)
Gets the index of gantt entry.

Parameters:
entry - the gantt entry
Returns:
the index of the entry inside the model. -1 if not found.

resizeAndRepaint

protected void resizeAndRepaint()
Equivalent to revalidate followed by repaint.


setRowHeight

public void setRowHeight(int rowHeight)
Sets the height, in pixels, of all cells to rowHeight, revalidates, and repaints. The height of the cells will be equal to the row height minus the row margin.

Parameters:
rowHeight - new row height
Throws:
IllegalArgumentException - if rowHeight is less than 1

isRowHeightSet

public boolean isRowHeightSet()

getRowHeight

public int getRowHeight()
Returns the height of a table row, in pixels. The default row height is 16.0.

Returns:
the height in pixels of a table row
See Also:
setRowHeight(int)

getTotalRowHeight

public int getTotalRowHeight()

setRowHeight

public void setRowHeight(int row,
                         int rowHeight)
Sets the height for row to rowHeight, revalidates, and repaints. The height of the cells in this row will be equal to the row height minus the row margin.

Parameters:
row - the row whose height is being changed
rowHeight - new row height, in pixels
Throws:
IllegalArgumentException - if rowHeight is less than 1

getRowHeight

public int getRowHeight(int row)
Returns the height, in pixels, of the cells in row.

Parameters:
row - the row whose height is to be returned
Returns:
the height, in pixels, of the cells in the row

setRowMargin

public void setRowMargin(int rowMargin)
Sets the amount of empty space between cells in adjacent rows.

Parameters:
rowMargin - the number of pixels between cells in a row
See Also:
getRowMargin()

getRowMargin

public int getRowMargin()
Gets the amount of empty space, in pixels, between cells. Equivalent to: getIntercellSpacing().height.

Returns:
the number of pixels between cells in a row
See Also:
setRowMargin(int)

setGridColor

public void setGridColor(Color gridColor)
Sets the color used to draw grid lines to gridColor and redisplays. The default color is look and feel dependent.

Parameters:
gridColor - the new color of the grid lines
Throws:
IllegalArgumentException - if gridColor is null

getGridColor

public Color getGridColor()
Returns the color used to draw grid lines. The default color is look and feel dependent.

Returns:
the color used to draw grid lines
See Also:
setGridColor(java.awt.Color)

setShowGrid

public void setShowGrid(boolean showGrid)
Sets whether the table draws grid lines around cells. If showGrid is true it does; if it is false it doesn't.

Parameters:
showGrid - true if table view should draw grid lines

isShowGrid

public boolean isShowGrid()

setViewMode

public void setViewMode(int viewMode)
If enabled, mouse editing and mouse drag selection is disabled. Instead mouse double clicks center the chart and mouse drag pans the chart.

Selection is still possible by clicked exactly on a GanttEntry or by holding down CTRL or SHIFT.

Parameters:
viewMode - the new view mode.

getViewMode

public int getViewMode()

rowAtPoint

public int rowAtPoint(Point point)
Returns the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1].

Parameters:
point - the location of interest
Returns:
the index of the row that point lies in, or -1 if the result is not in the range [0, getRowCount()-1]

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides:
getToolTipText in class JComponent

getEntryRect

public Rectangle getEntryRect(int row)
Returns a rectangle for the row, clipped by the Range of the GanttEntry at that row. If there is no entry at the row or the range of the entry is null or has a null lower or upper boundary, null is returned.

Parameters:
row - the row index.
Returns:
Returns the entry rectangle at the row or null if there is no entry or the entry has no valid Range

getEntryRect

public Rectangle getEntryRect(GanttEntry<T> entry,
                              int row)

getRowRect

public Rectangle getRowRect(int row,
                            boolean includingSpacing)

autoResizePeriods

public void autoResizePeriods(boolean visibleRowsOnly)
Automatically resizes the periods width and changes the visible periods to fit the range of the GanttModel. If visibleRowsOnly is true the periods are resized to fit the union of the range of the GanttEntries of the currently visible rows.

If no valid range can be found (either null or the start or end is null) the periods are changed to fit the default range of the ScaleModel.

Parameters:
visibleRowsOnly - true if the periods should be resized to combined range of the GanttEntries of the visible rows.
See Also:
zoomPeriods(T, T), GanttModel.getRange()

zoomPeriods

public void zoomPeriods(T start,
                        T end)
Automatically resizes the periods width and changes the visible periods to fit the specified range.

Parameters:
start - The start of the range (not null).
end - The end of the range (not null).

zoomInPeriods

public void zoomInPeriods()

zoomOutPeriods

public void zoomOutPeriods()

zoomPeriods

public void zoomPeriods(double factor)

scrollSpanToVisible

public void scrollSpanToVisible(Range<T> span)

scrollSpanToVisible

public void scrollSpanToVisible(T start,
                                T end)

scrollRowToVisible

public void scrollRowToVisible(int rowIndex)

getEntryRenderer

public GanttEntryRenderer getEntryRenderer(int row)
Returns an appropriate renderer for the row specified by the row index. Subclass can override this method to return different renderer for different rows.

Parameters:
row - the row of the cell to render, where 0 is the first row
Returns:
the assigned renderer.

getEntryRenderer

public GanttEntryRenderer getEntryRenderer(int row,
                                           int column)
Returns an appropriate renderer for the row specified by the row index. Subclass can override this method to return different renderer for different rows.

Parameters:
row - the row of the cell to render, where 0 is the first row
column - the column index of the sub entry. -1 if there is no sub entry
Returns:
the assigned renderer.

getDefaultEntryRenderer

public GanttEntryRenderer getDefaultEntryRenderer()
Gets the default GanttEntryRenderer.

Returns:
the default GanttEntryRenderer.

setDefaultEntryRenderer

public void setDefaultEntryRenderer(GanttEntryRenderer defaultEntryRenderer)
Sets the default GanttEntryRenderer. Please remember to call repaint() after you change the default GanttEntryRenderer.

Parameters:
defaultEntryRenderer - the new default GanttEntryRenderer.

getLabelRenderer

public GanttLabelRenderer getLabelRenderer(int row)
Returns an appropriate renderer for the row specified by the row index. Subclass can override this method to return different renderer for different rows.

Parameters:
row - the row of the cell to render, where 0 is the first row
Returns:
the assigned renderer.

getLabelRenderer

public GanttLabelRenderer getLabelRenderer(int row,
                                           int column)
Returns an appropriate renderer for the row specified by the row index. Subclass can override this method to return different renderer for different rows.

Parameters:
row - the row of the cell to render, where 0 is the first row
column - the column index of the sub entry. -1 if there is no sub entry
Returns:
the assigned renderer.

getDefaultLabelRenderer

public GanttLabelRenderer getDefaultLabelRenderer()
Gets the default GanttLabelRenderer.

Returns:
the default GanttLabelRenderer.

setDefaultLabelRenderer

public void setDefaultLabelRenderer(GanttLabelRenderer defaultLabelRenderer)
Sets the default GanttLabelRenderer. Please remember to call repaint() after you change the default GanttLabelRenderer.

Parameters:
defaultLabelRenderer - the new default GanttLabelRenderer.

getLabelPosition

public int getLabelPosition()
Gets the label position relative to the entry. It could be either SwingConstants.LEADING or SwingConstants.TRAILING.

Returns:
the label position

setLabelPosition

public void setLabelPosition(int labelPosition)
Sets the label position. The valid values are SwingConstants.LEADING or SwingConstants.TRAILING. Please remember to call repaint() after you change the label position.

Parameters:
labelPosition - the label position.

getLabelEntryGap

public int getLabelEntryGap()
Gets the gap between the label and the entry.

Returns:
the gap between the label and the entry.

setLabelEntryGap

public void setLabelEntryGap(int labelEntryGap)
Sets the label and the entry gap. Please remember to call repaint() after you change the gap.

Parameters:
labelEntryGap - the gap between the label and the entry.

prepareRenderer

@Deprecated
public Component prepareRenderer(GanttEntryRenderer renderer,
                                            int row,
                                            Insets insets)
Deprecated. replaced by prepareRenderer(GanttEntryRenderer, int, int, java.awt.Insets)

Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

During a printing operation, this method will configure the renderer without indicating selection or focus, to prevent them from appearing in the printed output. To do other customizations based on whether or not the table is being printed, you can check the value of JComponent#isPaintingForPrint(), either here or within custom renderers.

Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
insets - the insets of the component
Returns:
the Component under the event location

prepareRenderer

public Component prepareRenderer(GanttEntryRenderer renderer,
                                 int row,
                                 int column,
                                 Insets insets)
Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

During a printing operation, this method will configure the renderer without indicating selection or focus, to prevent them from appearing in the printed output. To do other customizations based on whether or not the table is being printed, you can check the value of JComponent#isPaintingForPrint(), either here or within custom renderers.

Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
column - the column index of the sub entry. -1 if there is no sub entry
insets - the insets of the component
Returns:
the Component under the event location

prepareLabelRenderer

public Component prepareLabelRenderer(GanttLabelRenderer renderer,
                                      int row)
Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

During a printing operation, this method will configure the renderer without indicating selection or focus, to prevent them from appearing in the printed output. To do other customizations based on whether or not the table is being printed, you can check the value of JComponent#isPaintingForPrint(), either here or within custom renderers.

Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
Returns:
the Component under the event location

prepareLabelRenderer

public Component prepareLabelRenderer(GanttLabelRenderer renderer,
                                      int row,
                                      int column)
Prepares the renderer by querying the data model for the value and selection state of the cell at row, column. Returns the component (may be a Component or a JComponent) under the event location.

During a printing operation, this method will configure the renderer without indicating selection or focus, to prevent them from appearing in the printed output. To do other customizations based on whether or not the table is being printed, you can check the value of JComponent#isPaintingForPrint(), either here or within custom renderers.

Parameters:
renderer - the TableCellRenderer to prepare
row - the row of the cell to render, where 0 is the first row
column - the column index of the sub entry. -1 if there is no sub entry
Returns:
the Component under the event location

getRelationPainter

public GanttEntryRelationPainter getRelationPainter(int relationType)

setRelationPainter

public void setRelationPainter(int relationType,
                               GanttEntryRelationPainter painter)

getPeriodBackgroundPainters

public List<PeriodBackgroundPainter<T>> getPeriodBackgroundPainters()

addPeriodBackgroundPainter

public void addPeriodBackgroundPainter(PeriodBackgroundPainter<T> painter)

addPeriodBackgroundPainter

public void addPeriodBackgroundPainter(int index,
                                       PeriodBackgroundPainter<T> painter)
Adds a painter to chart to paint behind the Gantt entries.

Painters paint in order of index with later painters overwriting the previous ones if they paint in the same location (unless painting with transparent colors).

Parameters:
index - the location in the painter list
painter - the PeriodBackgroundPainter which paints the background
Since:
3.4.2

removePeriodBackgroundPainter

public void removePeriodBackgroundPainter(PeriodBackgroundPainter<T> painter)

getSelectionMode

public int getSelectionMode()
Returns the current selection mode for the list. This is a cover method that delegates to the method of the same name on the list's selection model.

Returns:
the current selection mode
See Also:
setSelectionMode(int)

getSelectionModel

public ListSelectionModel getSelectionModel()

setSelectionModel

public void setSelectionModel(ListSelectionModel selectionModel)

setSelectionMode

public void setSelectionMode(int selectionMode)
Sets the gantt chart's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.

Parameters:
selectionMode - the new selection mode

clearSelection

public void clearSelection()
Deselects all selected entries.


selectAll

public void selectAll()

setSelectedIndex

public void setSelectedIndex(int index)
Selects a single cell. Does nothing if the given index is greater than or equal to the model size. This is a convenience method that uses setSelectionInterval on the selection model. Refer to the documentation for the selection model class being used for details on how values less than 0 are handled.

Parameters:
index - the index of the cell to select
See Also:
ListSelectionModel.setSelectionInterval(int, int)

setSelectionInterval

public void setSelectionInterval(int index0,
                                 int index1)
Selects the rows from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval
Throws:
IllegalArgumentException - if index0 or index1 lie outside [0, getRowCount()-1]

addSelectionInterval

public void addSelectionInterval(int index0,
                                 int index1)
Adds the rows from index0 to index1, inclusive, to the current selection.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval
Throws:
IllegalArgumentException - if index0 or index1 lie outside [0, getRowCount()-1]

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Deselects the rows from index0 to index1, inclusive.

Parameters:
index0 - one end of the interval
index1 - the other end of the interval
Throws:
IllegalArgumentException - if index0 or index1 lie outside [0, getRowCount()-1]

getSelectedRow

public int getSelectedRow()
Returns the index of the first selected entry, -1 if no entry is selected.

Returns:
the index of the first selected entry

getSelectedRows

public int[] getSelectedRows()
Returns the indices of all selected entries.

Returns:
an array of integers containing the indices of all selected entries, or an empty array if no entries is selected
See Also:
getSelectedRow()

getSelectedRowCount

public int getSelectedRowCount()
Returns the number of selected entries.

Returns:
the number of selected entries, 0 if no entries are selected

getAnchorSelectionIndex

public int getAnchorSelectionIndex()
Returns the anchor selection index. This is a cover method that delegates to the method of the same name on the list's selection model.

Returns:
the anchor selection index
See Also:
ListSelectionModel.getAnchorSelectionIndex()

getLeadSelectionIndex

public int getLeadSelectionIndex()
Returns the lead selection index. This is a cover method that delegates to the method of the same name on the list's selection model.

Returns:
the lead selection index
See Also:
ListSelectionModel.getLeadSelectionIndex()

getMinSelectionIndex

public int getMinSelectionIndex()
Returns the smallest selected cell index, or -1 if the selection is empty. This is a cover method that delegates to the method of the same name on the list's selection model.

Returns:
the smallest selected cell index, or -1
See Also:
ListSelectionModel.getMinSelectionIndex()

getMaxSelectionIndex

public int getMaxSelectionIndex()
Returns the largest selected cell index, or -1 if the selection is empty. This is a cover method that delegates to the method of the same name on the list's selection model.

Returns:
the largest selected cell index
See Also:
ListSelectionModel.getMaxSelectionIndex()

setValueIsAdjusting

public void setValueIsAdjusting(boolean b)
Sets the selection model's valueIsAdjusting property. When true, upcoming changes to selection should be considered part of a single change. This property is used internally and developers typically need not call this method. For example, when the model is being updated in response to a user drag, the value of the property is set to true when the drag is initiated and set to false when the drag is finished. This allows listeners to update only when a change has been finalized, rather than handling all of the intermediate values.

You may want to use this directly if making a series of changes that should be considered part of a single change.

This is a cover method that delegates to the method of the same name on the list's selection model. See the documentation for ListSelectionModel.setValueIsAdjusting(boolean) for more details.

Parameters:
b - the new value for the property
See Also:
ListSelectionModel.setValueIsAdjusting(boolean), ListSelectionEvent.getValueIsAdjusting(), getValueIsAdjusting()

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns the value of the selection model's isAdjusting property.

This is a cover method that delegates to the method of the same name on the list's selection model.

Returns:
the value of the selection model's isAdjusting property.
See Also:
setValueIsAdjusting(boolean), ListSelectionModel.getValueIsAdjusting()

isRowSelected

public boolean isRowSelected(int index)
Returns true if the specified index is in the valid range of entries, and the entry at that index is selected.

Parameters:
index - the entry index
Returns:
true if row is a valid index and the entry at that index is selected (where 0 is the first entry)

changeSelection

public void changeSelection(int rowIndex,
                            boolean toggle,
                            boolean extend)
Updates the selection models of the table, depending on the state of the two flags: toggle and extend. Most changes to the selection that are the result of keyboard or mouse events received by the UI are channeled through this method so that the behavior may be overridden by a subclass. Some UIs may need more functionality than this method provides, such as when manipulating the lead for discontiguous selection, and may not call into this method for some selection changes.

This implementation uses the following conventions:

Parameters:
rowIndex - affects the selection at row
toggle - see description above
extend - if true, extend the current selection

getSelectionForeground

public Color getSelectionForeground()
Returns the foreground color for the rows of the selected entries.

Returns:
the Color object for the foreground property
See Also:
setSelectionForeground(java.awt.Color), setSelectionBackground(java.awt.Color)

setSelectionForeground

public void setSelectionForeground(Color selectionForeground)
Sets the foreground color for the rows of the selected entries.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionForeground - the Color to use in the foreground for selected list items
See Also:
getSelectionForeground(), setSelectionBackground(java.awt.Color), JComponent.setForeground(java.awt.Color), JComponent.setBackground(java.awt.Color), JComponent.setFont(java.awt.Font)

getSelectionBackground

public Color getSelectionBackground()
Returns the background color for selected cells.

Returns:
the Color used for the background of selected list items
See Also:
setSelectionBackground(java.awt.Color), setSelectionForeground(java.awt.Color)

setSelectionBackground

public void setSelectionBackground(Color selectionBackground)
Sets the background color for selected cells. Cell renderers can use this color to the fill selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionBackground - the Color to use for the background of selected cells
See Also:
getSelectionBackground(), setSelectionForeground(java.awt.Color), JComponent.setForeground(java.awt.Color), JComponent.setBackground(java.awt.Color), JComponent.setFont(java.awt.Font)

createDefaultSelectionModel

protected ListSelectionModel createDefaultSelectionModel()
Returns the default selection model object, which is a DefaultListSelectionModel. A subclass can override this method to return a different selection model object.

Returns:
the default selection model object
See Also:
DefaultListSelectionModel

ensureRowIsVisible

public void ensureRowIsVisible(int index)
Scrolls the list within an enclosing viewport to make the specified cell completely visible. This calls scrollRectToVisible with the bounds of the specified cell. For this method to work, the JList must be within a JViewport.

If the given index is outside the list's range of cells, this method results in nothing.

Parameters:
index - the index of the cell to make visible
See Also:
JComponent.scrollRectToVisible(java.awt.Rectangle), JComponent.getVisibleRect()

repaint

public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Overrides:
repaint in class JComponent

valueChanged

public void valueChanged(ListSelectionEvent e)
Specified by:
valueChanged in interface ListSelectionListener

getResourceString

public String getResourceString(String key)
Gets the localized string from resource bundle. Subclass can override it to provide its own string. Available keys are defined in gantt.properties.

Parameters:
key - the resource string key
Returns:
the localized string.

isAllowMoveEntry

public boolean isAllowMoveEntry()
Gets the flag indicating if drag and move gantt entry is allowed.

Returns:
true if drag and move gantt entry is allowed. Otherwise false.
See Also:
setAllowMoveEntry(boolean)

setAllowMoveEntry

public void setAllowMoveEntry(boolean allowMoveEntry)
Sets the flag indicating if drag and move gantt entry is allowed.

By default, the flag is true. If you want only resize but would like to avoid drag to move entire entry, please set this flag to false.

Parameters:
allowMoveEntry - the flag

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getResizeAreaWidth

public int getResizeAreaWidth()
Gets the pixels for the width of the resize area.

Returns:
the pixels for the width of the resize area.

setResizeAreaWidth

public void setResizeAreaWidth(int resizeAreaWidth)
Sets the pixels for the width of the resize area.

Parameters:
resizeAreaWidth - the pixels for the width of the resize area

isResizeWestArea

public boolean isResizeWestArea(Point point,
                                Rectangle entryRect)
Checks if the point is in the resize west area.

By default, it simply returns true if point.x < entryRect.x. You could override this method to let the condition be point.x < entryRect.x + getResizeAreaWidth() / 2 to enlarge the resize west area.

Parameters:
point - the mouse point
entryRect - the rectangle of the entry area
Returns:
true if the point is in the resize west area. Otherwise false.

isResizeEastArea

public boolean isResizeEastArea(Point point,
                                Rectangle entryRect)
Checks if the point is in the resize east area.

By default, it simply returns true if point.x < entryRect.x + entryRect.width. You could override this method to let the condition be point.x < entryRect.x + entryRect.width + getResizeAreaWidth() / 2 to enlarge the resize east area.

Parameters:
point - the mouse point
entryRect - the rectangle of the entry area
Returns:
true if the point is in the resize east area. Otherwise false.

isAllowResizeEntry

public boolean isAllowResizeEntry(GanttEntry<T> entry,
                                  T start,
                                  T end)
Checks if the entry is allowed to be resized as designated start & end.

Parameters:
entry - the gantt entry
start - the new start of the range
end - the new end of the range
Returns:
true by default. You could override this method to restrict the dragging to resize behavior.
Since:
3.4.5

JIDE 3.5.15