Class GanttComposite
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.nebula.widgets.ganttchart.GanttComposite
- All Implemented Interfaces:
java.util.EventListener
,IZoomHandler
,org.eclipse.swt.events.KeyListener
,org.eclipse.swt.events.MouseListener
,org.eclipse.swt.events.MouseMoveListener
,org.eclipse.swt.events.MouseTrackListener
,org.eclipse.swt.graphics.Drawable
,org.eclipse.swt.internal.SWTEventListener
public final class GanttComposite extends org.eclipse.swt.widgets.Canvas implements org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.events.MouseTrackListener, org.eclipse.swt.events.KeyListener, IZoomHandler
The GanttComposite is the workhorse of the GANTT chart. It contains a few public methods available for use, but most
of the functionality is private.
There is a serious amount of calculation done in this chart, it's about 80% calculation and 20% drawing. In fact, most of the drawing is delegated to other classes.
A lot of settings method calls are set as class variables, but some are called straight off the settings object. The logic isn't that deep, it's mostly just the over-and-over used variables that get class members. Slow stuff is cached, such as the use of
This class may not be subclassed.
There is a serious amount of calculation done in this chart, it's about 80% calculation and 20% drawing. In fact, most of the drawing is delegated to other classes.
A lot of settings method calls are set as class variables, but some are called straight off the settings object. The logic isn't that deep, it's mostly just the over-and-over used variables that get class members. Slow stuff is cached, such as the use of
gc.stringExtent()
, image rotation and so on. Anything that is slow _should_
be cached as it is a slowdown to the chart. A redraw should be as fast as possible and whenever possible should be
specific to certain bounds instead of a full redraw.This class may not be subclassed.
-
Field Summary
Fields Modifier and Type Field Description static int
_osType
-
Constructor Summary
Constructors Constructor Description GanttComposite(GanttChart parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager)
GanttComposite(GanttChart parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager, Holiday[] holidays)
-
Method Summary
Modifier and Type Method Description void
addConnection(GanttEvent source, GanttEvent target)
Same as addDependency().void
addConnection(GanttEvent source, GanttEvent target, org.eclipse.swt.graphics.Color color)
Same as addDependency().void
addDependency(GanttEvent source, GanttEvent target)
Adds a connection between two GanttEvents. ge1 will connect to ge2.void
addDependency(GanttEvent source, GanttEvent target, org.eclipse.swt.graphics.Color color)
Adds a connection between two GanttEvents.void
addEvent(GanttEvent event)
Adds a GanttEvent to the chart.void
addEvent(GanttEvent event, boolean redraw)
Adds an GanttEvent to the chart and redraws.void
addEvent(GanttEvent event, int index)
Adds an event at a given index.void
addGanttEventListener(IGanttEventListener listener)
Adds a listener that will be notified of Gantt events.void
addGroup(GanttGroup group)
Adds a GanttGroup to the chart.void
addPhase(GanttPhase phase)
Adds a GanttPhase to the chart.void
addPhase(GanttPhase phase, boolean redraw)
Adds a GanttPhase to the chart with optional redraw call.void
addSection(GanttSection section)
Adds a GanttSection to the chart.void
addSection(GanttSection section, int index)
Adds a GanttSection to the chart.void
addSelectionDetailClickListener(ISectionDetailMoreClickListener listener)
void
addSpecialDateRange(GanttSpecialDateRange range)
Adds aGanttSpecialDateRange
to the chart.void
addSpecialDateRange(GanttSpecialDateRange range, boolean redraw)
Adds aGanttSpecialDateRange
and optionally redraws.void
clearAllSelectedHeaders()
Clears all selected headers and redraws the chart.void
clearChart()
Clears the entire chart of everything (all types of events) and leaves the chart blank.void
clearGanttEvents()
Clears all GanttEvents events from the chart.void
clearGanttGroups()
Clears all GanttGroups from the chart.void
clearGanttSections()
Clears all GanttSections from the chart.void
clearPhases()
Removes all GanttPhases from the chartvoid
clearSpecialDateRanges()
Removes allGanttSpecialDateRange
s and redraws.(package private) void
connectionAdded(GanttConnection conn)
(package private) void
connectionRemoved(GanttConnection conn)
void
deselectAll()
Clears all selected eventsvoid
drawMarker(java.util.Date date)
Draws a dotted vertical marker at the given date.(package private) void
eventDatesChanged(GanttEvent ge, boolean redraw)
(package private) void
flagForceFullUpdate()
(package private) static org.eclipse.swt.graphics.ImageData
flip(org.eclipse.swt.graphics.ImageData srcData, boolean vertical)
(package private) void
forceFullUpdate()
java.util.List
getAllSelectedHeaderDates()
Returns a list of all selected header dates (Calendar).GanttEvent
getBottomEvent()
Returns the bottom most visible event in the current view of the chart.org.eclipse.swt.graphics.Rectangle
getBounds()
int
getCurrentView()
Returns the current view.java.util.Calendar
getDate()
Returns the current date (left-most date).java.util.Calendar
getDateAt(int x)
Gets the date for a given x position.int
getDaysVisible()
int
getDayWidth()
Returns the width of one day in the current zoom level.java.util.Calendar
getDDayCalendar()
Returns (a clone) of the D-Day calendarjava.util.List
getEvents()
Returns all events.org.eclipse.swt.graphics.Image
getFullImage()
Returns the image that is the entire chart, regardless of what is currently visible.java.util.List
getGanttConnections()
Returns all currently connected events as a list ofGanttConnection
objects.java.util.List
getGanttSections()
Returns a list of all GanttSections.java.util.List<GanttGroup>
getGroups()
Returns a list of all GanttGroups.int
getHeaderHeight()
org.eclipse.swt.graphics.Image
getImage()
Returns the current visible area of the chart as an imageorg.eclipse.swt.graphics.Image
getImage(org.eclipse.swt.graphics.Rectangle bounds)
Returns the chart as an image for the given bounds.int
getLayerOpacity(int layer)
Returns the layer opacity for a layer.(package private) int
getLeftMostPixel()
(package private) int
getRightMostPixel()
java.util.Calendar
getRootCalendar()
Returns the non-cloned root calendar of the chart.java.util.Calendar
getRootEndCalendar()
Returns the non-cloned root end calendar of the chart.java.util.Calendar
getRootStartCalendar()
Returns the non-cloned root start calendar of the chart.GanttSection
getSectionAt(org.eclipse.swt.events.MouseEvent me)
Returns a section that corresponds to where the given MouseEvent is firedjava.util.List<java.lang.Object>
getSelectedEvents()
Returns the a list of all currently selected events, or an emtpy list if none.ISettings
getSettings()
int
getStartingXFor(java.util.Calendar date)
Returns the starting x for a given date.int
getStartingXForEventDate(java.util.Calendar date)
Returns the starting x position for a given date in the current view.GanttEvent
getTopEvent()
Returns the topmost visible event in the current view of the chart.int
getTotalVisibileGanttEvents()
Returns the number of visible events on in the current viewportGanttUndoRedoManager
getUndoRedoManager()
Returns the Undo/Redo manager.org.eclipse.swt.graphics.Image
getVerticallyFullImage()
Returns the chart as an image with the visible horizontal area but showing all information in the chart vertically.IViewPortHandler
getViewPortHandler()
org.eclipse.swt.graphics.Rectangle
getVisibleBounds()
Returns a rectangle with the bounds of what is actually visible inside the chart.int
getXForDate(java.util.Calendar cal)
Gets the x position where the given date starts in the current visible area.int
getXForDate(java.util.Date date)
Gets the X for a given date.boolean
hasEvent(GanttEvent event)
Checks whether the chart has a given event.(package private) boolean
hasGanttPhases()
(package private) boolean
hasGanttSections()
(package private) boolean
hasSpecialDateRanges()
void
heavyRedraw()
This will cause a full recaclulation of events and a lot of other things.void
hideAllLayers()
Hides all layers and redraws the event area.void
hideLayer(int layer)
Hides all layers of the given value and redraws the event area.(package private) boolean
isChartReady()
boolean
isConnected(GanttEvent ge)
Returns true if the given event is connected to another.boolean
isConnected(GanttEvent source, GanttEvent target)
Checks whether two events are connected to each other.(package private) boolean
isDDayCalendar()
boolean
isEventVisible(GanttEvent event, org.eclipse.swt.graphics.Rectangle bounds)
Checks whether a certain event is visible in the current bounds.boolean
isShowingDaysOnEvents()
Returns whether event day number drawing is currently on or off.boolean
isShowingGanttSections()
Whether the chart has gantt sections or notboolean
isShowingPlannedDates()
Returns whether planned date drawing is currently on or off.void
jumpToEarliestEvent()
Moves the calendar to the earliest event date.void
jumpToEvent(GanttEvent event, boolean start, int side)
Moves the calendar to a particular event date horizontally.void
jumpToLatestEvent()
Moves the calendar to the latest event date.void
jumpToToday()
Moves calendar to the current date/time.void
jumpToToday(int side)
Moves calendar to the current date/time.void
keyPressed(org.eclipse.swt.events.KeyEvent e)
void
keyReleased(org.eclipse.swt.events.KeyEvent e)
(package private) void
killDialogs()
void
mouseDoubleClick(org.eclipse.swt.events.MouseEvent me)
void
mouseDown(org.eclipse.swt.events.MouseEvent me)
void
mouseEnter(org.eclipse.swt.events.MouseEvent event)
void
mouseExit(org.eclipse.swt.events.MouseEvent event)
void
mouseHover(org.eclipse.swt.events.MouseEvent me)
void
mouseMove(org.eclipse.swt.events.MouseEvent me)
void
mouseUp(org.eclipse.swt.events.MouseEvent event)
(package private) void
moveXBounds(boolean positive)
void
nextDay()
Jumps one day forward.void
nextHour()
Jumps to the next hour.void
nextMinute()
Jumps to the next hour.void
nextMonth()
Jumps to the next month.void
nextWeek()
Jumps one week forward.void
prevDay()
Jumps one day backwards.void
prevHour()
Jumps to the previous hour.void
prevMinute()
Jumps to the previous minute.void
prevMonth()
Jumps to the previous month.void
prevWeek()
Jumps one week backwards.void
redraw()
void
redraw(org.eclipse.swt.graphics.Rectangle rect)
void
refresh()
Redraws the calendar should some event not do it automatically.void
reindex(GanttEvent event, int newIndex)
Re-indexes an event to a new index.void
reindex(GanttGroup group, int newIndex)
Re-indexes a GanttGroup to a new index.void
reindex(GanttSection section, int newIndex)
Re-indexes a GanttSection to a new index.boolean
removeEvent(GanttEvent event)
Removes a GanttEvent from the chart.void
removeGanttEventListener(IGanttEventListener listener)
Removes a listener from being notified of Gantt events.void
removeGroup(GanttGroup group)
Removes a GanttGroup from the chart.void
removePhase(GanttPhase phase)
Removes a GanttPhase from the chart.void
removePhase(GanttPhase phase, boolean redraw)
Removes a GanttPhase from the chart with optional redraw call.void
removeSection(GanttSection section)
Removes a GanttSection from the chart.void
removeSelectionDetailClickListener(ISectionDetailMoreClickListener listener)
void
removeSpecialDateRange(GanttSpecialDateRange range)
Removes aGanttSpecialDateRange
to the chart and redraws.void
removeSpecialDateRange(GanttSpecialDateRange range, boolean redraw)
Removes aGanttSpecialDateRange
to the chart and redraws.void
resetZoom()
Resets the zoom level to that set in the settings.(package private) static org.eclipse.swt.graphics.ImageData
rotate(org.eclipse.swt.graphics.ImageData srcData, int direction)
void
selectAll()
Selects all eventsvoid
setDate(java.util.Calendar date)
Sets the calendar date.void
setDate(java.util.Calendar date, boolean applyOffset)
Sets the new date of the calendar and redraws.void
setDate(java.util.Calendar date, int side)
Sets the calendar date to the given date and shows it on the chart.void
setDate(java.util.Calendar date, int side, boolean clearMinutes)
Sets the calendar date to the given date and shows it on the chart.void
setDrawHorizontalLinesOverride(boolean drawHorizontal)
Setting this to true will force horizontal lines to draw despite what may be set in the settings.void
setDrawVerticalLinesOverride(boolean drawVertical)
Setting this to true will force vertical lines to draw despite what may be set in the settings.void
setEventFactory(IEventFactory factory)
void
setEventMenuItemFactory(IEventMenuItemFactory factory)
void
setEventSpacerOverride(int height)
Setting a fixed event spacer overrides all individual event space settings on chart items and all settings.void
setFixedRowHeightOverride(int height)
Setting a fixed row height override causes all rows to be the set height regardless of individual row heights set on items themselves and all settings.void
setHolidays(Holiday[] holidays)
void
setLayerOpacity(int layer, int opacity)
Sets the drawing opacity for a layer.void
setMenuItemFactory(IMenuItemFactory factory)
(package private) void
setNoRecalc()
void
setSelectedHeaderDates(java.util.List dates)
Sets a list of header dates that should be the selected dates.void
setSelection(java.util.List list)
Sets the selection to be a set of GanttEvents.void
setSelection(GanttEvent event)
Sets the selection to be a specific GanttEvent.void
setShowDaysOnEvents(boolean showDates)
Flag whether to show the number of days on events.void
setShowPlannedDates(boolean showPlanned)
Flag whether to show planned dates or not.void
setTopItem(GanttEvent ge, int side)
Sets the top visible item in the chart and scrolls to show it.void
setTopItem(GanttEvent ge, int yOffset, int side)
Sets the top visible item in the chart and scrolls to show it.void
setUseAdvancedTooltips(boolean useAdvancedTooltips)
Sets whether to use advanced tooltips or not.void
setView(int view)
Sets the current view.void
setViewPortHandler(IViewPortHandler2 vph)
void
setZoomHandler(IZoomHandler zoomHandler)
void
setZoomLevel(int level)
Sets the zoom level.void
showAllLayers()
Shows all layers and redraws the event area.void
showEvent(GanttEvent ge, int side)
Scrolls the chart to the selected item regardless if it is visible or not.void
showLayer(int layer)
Shows all layers of the given value and redraws the event area.(package private) void
showScrollDate()
(package private) void
updateHorizontalScrollbar()
(package private) void
updateVerticalScrollBar(boolean redraw)
void
vScroll()
void
zoomIn()
Zooms in.void
zoomIn(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)
void
zoomOut()
Zooms out.void
zoomOut(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
_osType
public static int _osType
-
-
Constructor Details
-
GanttComposite
public GanttComposite(GanttChart parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager) -
GanttComposite
public GanttComposite(GanttChart parent, int style, ISettings settings, IColorManager colorManager, IPaintManager paintManager, ILanguageManager languageManager, Holiday[] holidays)
-
-
Method Details
-
vScroll
public void vScroll() -
updateVerticalScrollBar
void updateVerticalScrollBar(boolean redraw) -
getDate
public java.util.Calendar getDate()Returns the current date (left-most date).- Returns:
-
getRootCalendar
public java.util.Calendar getRootCalendar()Returns the non-cloned root calendar of the chart. DO NOT modify this outside of the chart. This method is considered internal public and will be removed later.- Returns:
- Calendar
-
getRootEndCalendar
public java.util.Calendar getRootEndCalendar()Returns the non-cloned root end calendar of the chart. DO NOT modify this outside of the chart. This method is considered internal public and will be removed later.- Returns:
- Calendar
-
getRootStartCalendar
public java.util.Calendar getRootStartCalendar()Returns the non-cloned root start calendar of the chart. DO NOT modify this outside of the chart. This method is considered internal public and will be removed later.- Returns:
- Calendar
-
hideLayer
public void hideLayer(int layer)Hides all layers of the given value and redraws the event area.- Parameters:
layer
- Layer to hide.
-
showLayer
public void showLayer(int layer)Shows all layers of the given value and redraws the event area.- Parameters:
layer
- Layer to show.
-
redraw
public void redraw(org.eclipse.swt.graphics.Rectangle rect) -
showAllLayers
public void showAllLayers()Shows all layers and redraws the event area. -
hideAllLayers
public void hideAllLayers()Hides all layers and redraws the event area. -
setLayerOpacity
public void setLayerOpacity(int layer, int opacity)Sets the drawing opacity for a layer. Do note that this may reduce the drawing speed of the chart by a lot. The opacity range is from 0 to 255. Note that if alpha settings are turned on in settings, those values will still be used, so it may be wise to turn them off if you are doing layer blending.- Parameters:
layer
- Layer to set opacity onopacity
- Opacity between 0 and 255
-
getLayerOpacity
public int getLayerOpacity(int layer)Returns the layer opacity for a layer.- Parameters:
layer
- Layer to get opacity for- Returns:
- Layer opacity, -1 if layer has no opacity set.
-
setFixedRowHeightOverride
public void setFixedRowHeightOverride(int height)Setting a fixed row height override causes all rows to be the set height regardless of individual row heights set on items themselves and all settings.- Parameters:
height
- Height to set. Set to zero to turn off.
-
setEventSpacerOverride
public void setEventSpacerOverride(int height)Setting a fixed event spacer overrides all individual event space settings on chart items and all settings.- Parameters:
height
- Height to set. Set to zero to turn off.
-
setDrawHorizontalLinesOverride
public void setDrawHorizontalLinesOverride(boolean drawHorizontal)Setting this to true will force horizontal lines to draw despite what may be set in the settings.- Parameters:
drawHorizontal
- true to draw horizontal lines.
-
setDrawVerticalLinesOverride
public void setDrawVerticalLinesOverride(boolean drawVertical)Setting this to true will force vertical lines to draw despite what may be set in the settings.- Parameters:
drawVertical
- true to draw vertical lines.
-
setSelection
Sets the selection to be a specific GanttEvent. This method will cause a redraw.- Parameters:
event
- GanttEvent to select
-
setSelection
public void setSelection(java.util.List list)Sets the selection to be a set of GanttEvents. If the chart is set toSWT.SINGLE
you should be usingsetSelection(GanttEvent)
as this method will do nothing. This method will cause a redraw.- Parameters:
list
- List of GanttEvents to select
-
addGroup
Adds a GanttGroup to the chart.- Parameters:
group
- Group to add
-
getGroups
Returns a list of all GanttGroups.- Returns:
- List of GanttGroups
-
removeGroup
Removes a GanttGroup from the chart.- Parameters:
group
- Group to remove
-
addSection
Adds a GanttSection to the chart.- Parameters:
section
- Section to add
-
addSection
Adds a GanttSection to the chart.- Parameters:
section
- Section to addindex
- the index to add the Section at
-
removeSection
Removes a GanttSection from the chart.- Parameters:
section
- Section to remove
-
getGanttSections
public java.util.List getGanttSections()Returns a list of all GanttSections.- Returns:
- List of GanttSections.
-
showScrollDate
void showScrollDate() -
getTopEvent
Returns the topmost visible event in the current view of the chart.- Returns:
- GanttEvent or null
-
getBottomEvent
Returns the bottom most visible event in the current view of the chart.- Returns:
- GanttEvent or null
-
killDialogs
void killDialogs() -
setShowPlannedDates
public void setShowPlannedDates(boolean showPlanned)Flag whether to show planned dates or not. This will override any settings value and will cause a redraw.- Parameters:
showPlanned
- true to show planned dates
-
isShowingPlannedDates
public boolean isShowingPlannedDates()Returns whether planned date drawing is currently on or off.- Returns:
- true if on
-
setShowDaysOnEvents
public void setShowDaysOnEvents(boolean showDates)Flag whether to show the number of days on events. This will override any settings value and will cause a redraw.- Parameters:
showDates
-
-
isShowingDaysOnEvents
public boolean isShowingDaysOnEvents()Returns whether event day number drawing is currently on or off.- Returns:
- true if on
-
isShowingGanttSections
public boolean isShowingGanttSections()Whether the chart has gantt sections or not- Returns:
- true if has gantt sections
-
getSelectedEvents
public java.util.List<java.lang.Object> getSelectedEvents()Returns the a list of all currently selected events, or an emtpy list if none.- Returns:
- GanttEvent or null
-
setTopItem
Sets the top visible item in the chart and scrolls to show it. Passing SWT.NONE prevents any horizontal alignment from occurring.- Parameters:
ge
- Event to showyOffset
- y offset modifierside
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
,SWT.NONE
-
setTopItem
Sets the top visible item in the chart and scrolls to show it. Passing SWT.NONE prevents any horizontal alignment from occurring.- Parameters:
ge
- Event to showside
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
,SWT.NONE
-
showEvent
Scrolls the chart to the selected item regardless if it is visible or not.- Parameters:
ge
- GanttEvent to scroll to.side
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
-
getBounds
public org.eclipse.swt.graphics.Rectangle getBounds()- Overrides:
getBounds
in classorg.eclipse.swt.widgets.Control
-
getHeaderHeight
public int getHeaderHeight() -
addDependency
Adds a connection between two GanttEvents. ge1 will connect to ge2.- Parameters:
source
- Source eventtarget
- Target event
-
addDependency
public void addDependency(GanttEvent source, GanttEvent target, org.eclipse.swt.graphics.Color color)Adds a connection between two GanttEvents.Source
will connect toTarget
.- Parameters:
source
- Source eventtarget
- Target eventColor
- to use to draw connection. Set null to use default color from Settings.
-
connectionAdded
-
connectionRemoved
-
isConnected
Returns true if the given event is connected to another.- Parameters:
ge
- GanttEvent to check- Returns:
- true if the GanttEvent is connected
-
isConnected
Checks whether two events are connected to each other.- Parameters:
source
- Source eventtarget
- Target event- Returns:
- true if a connection exists
-
addConnection
Same as addDependency().- Parameters:
source
- Source eventtarget
- Target event
-
addConnection
public void addConnection(GanttEvent source, GanttEvent target, org.eclipse.swt.graphics.Color color)Same as addDependency().- Parameters:
source
- Source eventtarget
- Target eventColor
- to use to draw connection. Set null to use defaults.
-
setDate
public void setDate(java.util.Calendar date)Sets the calendar date.- Parameters:
date
-- See Also:
setDate(Calendar, boolean)
,setDate(Calendar, int)
,setDate(Calendar, int, boolean)
-
jumpToToday
public void jumpToToday()Moves calendar to the current date/time. -
jumpToToday
public void jumpToToday(int side)Moves calendar to the current date/time.- Parameters:
side
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
-
jumpToEarliestEvent
public void jumpToEarliestEvent()Moves the calendar to the earliest event date. -
jumpToLatestEvent
public void jumpToLatestEvent()Moves the calendar to the latest event date. -
jumpToEvent
Moves the calendar to a particular event date horizontally. To move to an event completely, you may use#setTopItem(GanttEvent)
orsetTopItem(GanttEvent, int)
.- Parameters:
event
- Event to move tostart
- true if to jump to the start date, false if to jump to the end date.side
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
-
setDate
public void setDate(java.util.Calendar date, int side, boolean clearMinutes)Sets the calendar date to the given date and shows it on the chart. You may provide the side that the date is to be visible on. This method does not apply any offset or other settings-related magic, but sets the date "purely". This method will only clear minutes, seconds and milliseconds if the clearMinutes variable is set to true.- Parameters:
date
- Dateside
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
clearMinutes
- true if to clear minutes, seconds, milliseconds- See Also:
setDate(Calendar, int)
-
setDate
public void setDate(java.util.Calendar date, int side)Sets the calendar date to the given date and shows it on the chart. You may provide the side that the date is to be visible on. This method does not apply any offset or other settings-related magic, but sets the date "purely". This method will clear minutes, seconds and milliseconds and set them to zero. If you do not wish this, usesetDate(Calendar, int, boolean)
- Parameters:
date
- Dateside
- one ofSWT.LEFT
,SWT.CENTER
,SWT.RIGHT
-
setDate
public void setDate(java.util.Calendar date, boolean applyOffset)Sets the new date of the calendar and redraws. This method will apply any offsets and other date magic that is set in the Settings.- Parameters:
date
- Date to setapplyOffset
- whether to apply the settings offset- See Also:
setDate(Calendar)
,setDate(Calendar, int)
,setDate(Calendar, int, boolean)
-
reindex
Re-indexes an event to a new index.- Parameters:
event
- GanttEvent to reindexnewIndex
- new index
-
reindex
Re-indexes a GanttSection to a new index.- Parameters:
section
- GanttSection to reindexnewIndex
- new index
-
reindex
Re-indexes a GanttGroup to a new index.- Parameters:
group
- GanttGroup to reindexnewIndex
- new index
-
addPhase
Adds a GanttPhase to the chart.- Parameters:
phase
- GanttPhase to add
-
removePhase
Removes a GanttPhase from the chart.- Parameters:
phase
- GanttPhase to remove
-
addSpecialDateRange
Adds aGanttSpecialDateRange
to the chart.- Parameters:
range
-GanttSpecialDateRange
to add.
-
removeSpecialDateRange
Removes aGanttSpecialDateRange
to the chart and redraws.- Parameters:
range
-GanttSpecialDateRange
to remove
-
removeSpecialDateRange
Removes aGanttSpecialDateRange
to the chart and redraws.- Parameters:
range
-GanttSpecialDateRange
to removeredraw
- true to redraw
-
clearSpecialDateRanges
public void clearSpecialDateRanges()Removes allGanttSpecialDateRange
s and redraws. -
addSpecialDateRange
Adds aGanttSpecialDateRange
and optionally redraws.- Parameters:
range
-GanttSpecialDateRange
to addredraw
- true to redraw
-
addPhase
Adds a GanttPhase to the chart with optional redraw call.- Parameters:
phase
- GanttPhase to addredraw
- true to redraw
-
removePhase
Removes a GanttPhase from the chart with optional redraw call.- Parameters:
phase
- GanttPhase to removeredraw
- true to redraw
-
clearPhases
public void clearPhases()Removes all GanttPhases from the chart -
addEvent
Adds a GanttEvent to the chart.- Parameters:
event
- GanttEvent
-
addEvent
Adds an event at a given index.- Parameters:
event
- GanttEventindex
- index
-
addEvent
Adds an GanttEvent to the chart and redraws.- Parameters:
event
- GanttEventredraw
- true if to redraw chart
-
removeEvent
Removes a GanttEvent from the chart.- Parameters:
event
- GanttEvent to remove- Returns:
- true if removed
-
getGanttConnections
public java.util.List getGanttConnections()Returns all currently connected events as a list ofGanttConnection
objects.- Returns:
- List of connections.
-
eventDatesChanged
-
clearGanttEvents
public void clearGanttEvents()Clears all GanttEvents events from the chart. -
clearGanttGroups
public void clearGanttGroups()Clears all GanttGroups from the chart. -
clearGanttSections
public void clearGanttSections()Clears all GanttSections from the chart. -
clearChart
public void clearChart()Clears the entire chart of everything (all types of events) and leaves the chart blank. -
hasEvent
Checks whether the chart has a given event.- Parameters:
event
- GanttEvent- Returns:
- true if event exists
-
nextMonth
public void nextMonth()Jumps to the next month. -
prevMonth
public void prevMonth()Jumps to the previous month. -
nextWeek
public void nextWeek()Jumps one week forward. -
prevWeek
public void prevWeek()Jumps one week backwards. -
nextHour
public void nextHour()Jumps to the next hour. -
prevMinute
public void prevMinute()Jumps to the previous minute. -
nextMinute
public void nextMinute()Jumps to the next hour. -
prevHour
public void prevHour()Jumps to the previous hour. -
nextDay
public void nextDay()Jumps one day forward. -
prevDay
public void prevDay()Jumps one day backwards. -
setNoRecalc
void setNoRecalc() -
moveXBounds
void moveXBounds(boolean positive) -
refresh
public void refresh()Redraws the calendar should some event not do it automatically. -
isEventVisible
Checks whether a certain event is visible in the current bounds.- Parameters:
event
- GanttEventbounds
- Bounds- Returns:
- true if event is visible
-
getStartingXForEventDate
public int getStartingXForEventDate(java.util.Calendar date)Returns the starting x position for a given date in the current view.- Parameters:
date
- Date- Returns:
- x position, -1 should it for some reason not be found
-
getStartingXFor
public int getStartingXFor(java.util.Calendar date)Returns the starting x for a given date.- Parameters:
date
- Calendar date- Returns:
- x position or -1 if it for some reason should not be found
-
getDayWidth
public int getDayWidth()Returns the width of one day in the current zoom level. Do note that "one day" refers to 1 tick mark, so it might not be one day in a smaller or larger zoom level.- Returns:
- One tick mark width
-
mouseDoubleClick
public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent me)- Specified by:
mouseDoubleClick
in interfaceorg.eclipse.swt.events.MouseListener
-
getAllSelectedHeaderDates
public java.util.List getAllSelectedHeaderDates()Returns a list of all selected header dates (Calendar).- Returns:
- List of calendars or empty list if none
-
clearAllSelectedHeaders
public void clearAllSelectedHeaders()Clears all selected headers and redraws the chart. -
setSelectedHeaderDates
public void setSelectedHeaderDates(java.util.List dates)Sets a list of header dates that should be the selected dates. This list must be a list of Calendars.- Parameters:
dates
- List of Calendar objects representing selected header dates.
-
mouseDown
public void mouseDown(org.eclipse.swt.events.MouseEvent me)- Specified by:
mouseDown
in interfaceorg.eclipse.swt.events.MouseListener
-
mouseUp
public void mouseUp(org.eclipse.swt.events.MouseEvent event)- Specified by:
mouseUp
in interfaceorg.eclipse.swt.events.MouseListener
-
getSectionAt
Returns a section that corresponds to where the given MouseEvent is fired- Parameters:
event
- MouseEvent to check- Returns:
- Section it is over or null if none
-
keyPressed
public void keyPressed(org.eclipse.swt.events.KeyEvent e)- Specified by:
keyPressed
in interfaceorg.eclipse.swt.events.KeyListener
-
keyReleased
public void keyReleased(org.eclipse.swt.events.KeyEvent e)- Specified by:
keyReleased
in interfaceorg.eclipse.swt.events.KeyListener
-
mouseMove
public void mouseMove(org.eclipse.swt.events.MouseEvent me)- Specified by:
mouseMove
in interfaceorg.eclipse.swt.events.MouseMoveListener
-
getDaysVisible
public int getDaysVisible() -
isChartReady
boolean isChartReady() -
getXForDate
public int getXForDate(java.util.Date date)Gets the X for a given date.- Parameters:
date
- Date- Returns:
- x position or -1 if date was not found
-
getXForDate
public int getXForDate(java.util.Calendar cal)Gets the x position where the given date starts in the current visible area.- Parameters:
cal
- Calendar- Returns:
- -1 if date was not found
-
getDateAt
public java.util.Calendar getDateAt(int x)Gets the date for a given x position.- Parameters:
x
- x location- Returns:
- Calendar of date
-
drawMarker
public void drawMarker(java.util.Date date)Draws a dotted vertical marker at the given date. It will get removed on repaint, so make sure it's drawn as often as needed.- Parameters:
date
- Date to draw it at
-
mouseEnter
public void mouseEnter(org.eclipse.swt.events.MouseEvent event)- Specified by:
mouseEnter
in interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseExit
public void mouseExit(org.eclipse.swt.events.MouseEvent event)- Specified by:
mouseExit
in interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseHover
public void mouseHover(org.eclipse.swt.events.MouseEvent me)- Specified by:
mouseHover
in interfaceorg.eclipse.swt.events.MouseTrackListener
-
getVisibleBounds
public org.eclipse.swt.graphics.Rectangle getVisibleBounds()Returns a rectangle with the bounds of what is actually visible inside the chart.- Returns:
- Rectangle
-
getCurrentView
public int getCurrentView()Returns the current view.- Returns:
- View
-
setView
public void setView(int view)Sets the current view.- Parameters:
view
- View
-
getEvents
public java.util.List getEvents()Returns all events.- Returns:
- List of all events.
-
getImage
public org.eclipse.swt.graphics.Image getImage()Returns the current visible area of the chart as an image- Returns:
- Image of the chart
-
getVerticallyFullImage
public org.eclipse.swt.graphics.Image getVerticallyFullImage()Returns the chart as an image with the visible horizontal area but showing all information in the chart vertically.- Returns:
- Image of the chart
-
getFullImage
public org.eclipse.swt.graphics.Image getFullImage()Returns the image that is the entire chart, regardless of what is currently visible. If chart contains no events,getImage()
is called from within.Do note that if the chart is "huge", you may need to increase your heap size. If you're zoomed in that's also taken into account and you may need a massive heap to work with hours views as they are simply huge in a pixel-size sense.
- Returns:
- Image
-
getImage
public org.eclipse.swt.graphics.Image getImage(org.eclipse.swt.graphics.Rectangle bounds)Returns the chart as an image for the given bounds.- Parameters:
bounds
- Rectangle bounds- Returns:
- Image of chart
-
heavyRedraw
public void heavyRedraw()This will cause a full recaclulation of events and a lot of other things. Normally this is used internally when there are zoom changes and/or other events that cause the chart to need a full recalculation. It is NOT intended to be used outside of the chart, but is available as a workaround if there is a bug that you can't get around and you need to force a full update. See this method as a temporary solution if you need to use it. -
forceFullUpdate
void forceFullUpdate() -
flagForceFullUpdate
void flagForceFullUpdate() -
getViewPortHandler
-
setViewPortHandler
-
updateHorizontalScrollbar
void updateHorizontalScrollbar() -
getLeftMostPixel
int getLeftMostPixel() -
getRightMostPixel
int getRightMostPixel() -
setZoomLevel
public void setZoomLevel(int level)Sets the zoom level. If the new level is zoomed in from the previous set zoom level a zoom in event will be reported, otherwise a zoom out.- Parameters:
level
- Level to set
-
zoomIn
public void zoomIn()Zooms in. If zooming is disabled, does nothing.- Specified by:
zoomIn
in interfaceIZoomHandler
-
zoomIn
public void zoomIn(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)- Specified by:
zoomIn
in interfaceIZoomHandler
-
zoomOut
public void zoomOut()Zooms out. If zooming is disabled, does nothing.- Specified by:
zoomOut
in interfaceIZoomHandler
-
zoomOut
public void zoomOut(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)- Specified by:
zoomOut
in interfaceIZoomHandler
-
resetZoom
public void resetZoom()Resets the zoom level to that set in the settings.- Specified by:
resetZoom
in interfaceIZoomHandler
-
redraw
public void redraw()- Overrides:
redraw
in classorg.eclipse.swt.widgets.Control
-
addGanttEventListener
Adds a listener that will be notified of Gantt events.- Parameters:
listener
- Listener
-
removeGanttEventListener
Removes a listener from being notified of Gantt events.- Parameters:
listener
- Listener
-
setUseAdvancedTooltips
public void setUseAdvancedTooltips(boolean useAdvancedTooltips)Sets whether to use advanced tooltips or not. This method will override the settings implementation with the same name.- Parameters:
useAdvancedTooltips
- true whether to use advanced tooltips.
-
getDDayCalendar
public java.util.Calendar getDDayCalendar()Returns (a clone) of the D-Day calendar- Returns:
- D-Day calendar
-
getUndoRedoManager
Returns the Undo/Redo manager.- Returns:
GanttUndoRedoManager
-
getTotalVisibileGanttEvents
public int getTotalVisibileGanttEvents()Returns the number of visible events on in the current viewport- Returns:
- number of visible events on in the current viewport
-
selectAll
public void selectAll()Selects all events -
deselectAll
public void deselectAll()Clears all selected events -
rotate
static org.eclipse.swt.graphics.ImageData rotate(org.eclipse.swt.graphics.ImageData srcData, int direction) -
flip
static org.eclipse.swt.graphics.ImageData flip(org.eclipse.swt.graphics.ImageData srcData, boolean vertical) -
hasGanttPhases
boolean hasGanttPhases() -
hasGanttSections
boolean hasGanttSections() -
hasSpecialDateRanges
boolean hasSpecialDateRanges() -
isDDayCalendar
boolean isDDayCalendar() -
getSettings
-
setEventFactory
-
setEventMenuItemFactory
-
setMenuItemFactory
-
setZoomHandler
-
addSelectionDetailClickListener
-
removeSelectionDetailClickListener
-
setHolidays
-