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 voidaddConnection(GanttEvent source, GanttEvent target)Same as addDependency().voidaddConnection(GanttEvent source, GanttEvent target, org.eclipse.swt.graphics.Color color)Same as addDependency().voidaddDependency(GanttEvent source, GanttEvent target)Adds a connection between two GanttEvents. ge1 will connect to ge2.voidaddDependency(GanttEvent source, GanttEvent target, org.eclipse.swt.graphics.Color color)Adds a connection between two GanttEvents.voidaddEvent(GanttEvent event)Adds a GanttEvent to the chart.voidaddEvent(GanttEvent event, boolean redraw)Adds an GanttEvent to the chart and redraws.voidaddEvent(GanttEvent event, int index)Adds an event at a given index.voidaddGanttEventListener(IGanttEventListener listener)Adds a listener that will be notified of Gantt events.voidaddGroup(GanttGroup group)Adds a GanttGroup to the chart.voidaddPhase(GanttPhase phase)Adds a GanttPhase to the chart.voidaddPhase(GanttPhase phase, boolean redraw)Adds a GanttPhase to the chart with optional redraw call.voidaddSection(GanttSection section)Adds a GanttSection to the chart.voidaddSection(GanttSection section, int index)Adds a GanttSection to the chart.voidaddSelectionDetailClickListener(ISectionDetailMoreClickListener listener)voidaddSpecialDateRange(GanttSpecialDateRange range)Adds aGanttSpecialDateRangeto the chart.voidaddSpecialDateRange(GanttSpecialDateRange range, boolean redraw)Adds aGanttSpecialDateRangeand optionally redraws.voidclearAllSelectedHeaders()Clears all selected headers and redraws the chart.voidclearChart()Clears the entire chart of everything (all types of events) and leaves the chart blank.voidclearGanttEvents()Clears all GanttEvents events from the chart.voidclearGanttGroups()Clears all GanttGroups from the chart.voidclearGanttSections()Clears all GanttSections from the chart.voidclearPhases()Removes all GanttPhases from the chartvoidclearSpecialDateRanges()Removes allGanttSpecialDateRanges and redraws.(package private) voidconnectionAdded(GanttConnection conn)(package private) voidconnectionRemoved(GanttConnection conn)voiddeselectAll()Clears all selected eventsvoiddrawMarker(java.util.Date date)Draws a dotted vertical marker at the given date.(package private) voideventDatesChanged(GanttEvent ge, boolean redraw)(package private) voidflagForceFullUpdate()(package private) static org.eclipse.swt.graphics.ImageDataflip(org.eclipse.swt.graphics.ImageData srcData, boolean vertical)(package private) voidforceFullUpdate()java.util.ListgetAllSelectedHeaderDates()Returns a list of all selected header dates (Calendar).GanttEventgetBottomEvent()Returns the bottom most visible event in the current view of the chart.org.eclipse.swt.graphics.RectanglegetBounds()intgetCurrentView()Returns the current view.java.util.CalendargetDate()Returns the current date (left-most date).java.util.CalendargetDateAt(int x)Gets the date for a given x position.intgetDaysVisible()intgetDayWidth()Returns the width of one day in the current zoom level.java.util.CalendargetDDayCalendar()Returns (a clone) of the D-Day calendarjava.util.ListgetEvents()Returns all events.org.eclipse.swt.graphics.ImagegetFullImage()Returns the image that is the entire chart, regardless of what is currently visible.java.util.ListgetGanttConnections()Returns all currently connected events as a list ofGanttConnectionobjects.java.util.ListgetGanttSections()Returns a list of all GanttSections.java.util.List<GanttGroup>getGroups()Returns a list of all GanttGroups.intgetHeaderHeight()org.eclipse.swt.graphics.ImagegetImage()Returns the current visible area of the chart as an imageorg.eclipse.swt.graphics.ImagegetImage(org.eclipse.swt.graphics.Rectangle bounds)Returns the chart as an image for the given bounds.intgetLayerOpacity(int layer)Returns the layer opacity for a layer.(package private) intgetLeftMostPixel()(package private) intgetRightMostPixel()java.util.CalendargetRootCalendar()Returns the non-cloned root calendar of the chart.java.util.CalendargetRootEndCalendar()Returns the non-cloned root end calendar of the chart.java.util.CalendargetRootStartCalendar()Returns the non-cloned root start calendar of the chart.GanttSectiongetSectionAt(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.ISettingsgetSettings()intgetStartingXFor(java.util.Calendar date)Returns the starting x for a given date.intgetStartingXForEventDate(java.util.Calendar date)Returns the starting x position for a given date in the current view.GanttEventgetTopEvent()Returns the topmost visible event in the current view of the chart.intgetTotalVisibileGanttEvents()Returns the number of visible events on in the current viewportGanttUndoRedoManagergetUndoRedoManager()Returns the Undo/Redo manager.org.eclipse.swt.graphics.ImagegetVerticallyFullImage()Returns the chart as an image with the visible horizontal area but showing all information in the chart vertically.IViewPortHandlergetViewPortHandler()org.eclipse.swt.graphics.RectanglegetVisibleBounds()Returns a rectangle with the bounds of what is actually visible inside the chart.intgetXForDate(java.util.Calendar cal)Gets the x position where the given date starts in the current visible area.intgetXForDate(java.util.Date date)Gets the X for a given date.booleanhasEvent(GanttEvent event)Checks whether the chart has a given event.(package private) booleanhasGanttPhases()(package private) booleanhasGanttSections()(package private) booleanhasSpecialDateRanges()voidheavyRedraw()This will cause a full recaclulation of events and a lot of other things.voidhideAllLayers()Hides all layers and redraws the event area.voidhideLayer(int layer)Hides all layers of the given value and redraws the event area.(package private) booleanisChartReady()booleanisConnected(GanttEvent ge)Returns true if the given event is connected to another.booleanisConnected(GanttEvent source, GanttEvent target)Checks whether two events are connected to each other.(package private) booleanisDDayCalendar()booleanisEventVisible(GanttEvent event, org.eclipse.swt.graphics.Rectangle bounds)Checks whether a certain event is visible in the current bounds.booleanisShowingDaysOnEvents()Returns whether event day number drawing is currently on or off.booleanisShowingGanttSections()Whether the chart has gantt sections or notbooleanisShowingPlannedDates()Returns whether planned date drawing is currently on or off.voidjumpToEarliestEvent()Moves the calendar to the earliest event date.voidjumpToEvent(GanttEvent event, boolean start, int side)Moves the calendar to a particular event date horizontally.voidjumpToLatestEvent()Moves the calendar to the latest event date.voidjumpToToday()Moves calendar to the current date/time.voidjumpToToday(int side)Moves calendar to the current date/time.voidkeyPressed(org.eclipse.swt.events.KeyEvent e)voidkeyReleased(org.eclipse.swt.events.KeyEvent e)(package private) voidkillDialogs()voidmouseDoubleClick(org.eclipse.swt.events.MouseEvent me)voidmouseDown(org.eclipse.swt.events.MouseEvent me)voidmouseEnter(org.eclipse.swt.events.MouseEvent event)voidmouseExit(org.eclipse.swt.events.MouseEvent event)voidmouseHover(org.eclipse.swt.events.MouseEvent me)voidmouseMove(org.eclipse.swt.events.MouseEvent me)voidmouseUp(org.eclipse.swt.events.MouseEvent event)(package private) voidmoveXBounds(boolean positive)voidnextDay()Jumps one day forward.voidnextHour()Jumps to the next hour.voidnextMinute()Jumps to the next hour.voidnextMonth()Jumps to the next month.voidnextWeek()Jumps one week forward.voidprevDay()Jumps one day backwards.voidprevHour()Jumps to the previous hour.voidprevMinute()Jumps to the previous minute.voidprevMonth()Jumps to the previous month.voidprevWeek()Jumps one week backwards.voidredraw()voidredraw(org.eclipse.swt.graphics.Rectangle rect)voidrefresh()Redraws the calendar should some event not do it automatically.voidreindex(GanttEvent event, int newIndex)Re-indexes an event to a new index.voidreindex(GanttGroup group, int newIndex)Re-indexes a GanttGroup to a new index.voidreindex(GanttSection section, int newIndex)Re-indexes a GanttSection to a new index.booleanremoveEvent(GanttEvent event)Removes a GanttEvent from the chart.voidremoveGanttEventListener(IGanttEventListener listener)Removes a listener from being notified of Gantt events.voidremoveGroup(GanttGroup group)Removes a GanttGroup from the chart.voidremovePhase(GanttPhase phase)Removes a GanttPhase from the chart.voidremovePhase(GanttPhase phase, boolean redraw)Removes a GanttPhase from the chart with optional redraw call.voidremoveSection(GanttSection section)Removes a GanttSection from the chart.voidremoveSelectionDetailClickListener(ISectionDetailMoreClickListener listener)voidremoveSpecialDateRange(GanttSpecialDateRange range)Removes aGanttSpecialDateRangeto the chart and redraws.voidremoveSpecialDateRange(GanttSpecialDateRange range, boolean redraw)Removes aGanttSpecialDateRangeto the chart and redraws.voidresetZoom()Resets the zoom level to that set in the settings.(package private) static org.eclipse.swt.graphics.ImageDatarotate(org.eclipse.swt.graphics.ImageData srcData, int direction)voidselectAll()Selects all eventsvoidsetDate(java.util.Calendar date)Sets the calendar date.voidsetDate(java.util.Calendar date, boolean applyOffset)Sets the new date of the calendar and redraws.voidsetDate(java.util.Calendar date, int side)Sets the calendar date to the given date and shows it on the chart.voidsetDate(java.util.Calendar date, int side, boolean clearMinutes)Sets the calendar date to the given date and shows it on the chart.voidsetDrawHorizontalLinesOverride(boolean drawHorizontal)Setting this to true will force horizontal lines to draw despite what may be set in the settings.voidsetDrawVerticalLinesOverride(boolean drawVertical)Setting this to true will force vertical lines to draw despite what may be set in the settings.voidsetEventFactory(IEventFactory factory)voidsetEventMenuItemFactory(IEventMenuItemFactory factory)voidsetEventSpacerOverride(int height)Setting a fixed event spacer overrides all individual event space settings on chart items and all settings.voidsetFixedRowHeightOverride(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.voidsetHolidays(Holiday[] holidays)voidsetLayerOpacity(int layer, int opacity)Sets the drawing opacity for a layer.voidsetMenuItemFactory(IMenuItemFactory factory)(package private) voidsetNoRecalc()voidsetSelectedHeaderDates(java.util.List dates)Sets a list of header dates that should be the selected dates.voidsetSelection(java.util.List list)Sets the selection to be a set of GanttEvents.voidsetSelection(GanttEvent event)Sets the selection to be a specific GanttEvent.voidsetShowDaysOnEvents(boolean showDates)Flag whether to show the number of days on events.voidsetShowPlannedDates(boolean showPlanned)Flag whether to show planned dates or not.voidsetTopItem(GanttEvent ge, int side)Sets the top visible item in the chart and scrolls to show it.voidsetTopItem(GanttEvent ge, int yOffset, int side)Sets the top visible item in the chart and scrolls to show it.voidsetUseAdvancedTooltips(boolean useAdvancedTooltips)Sets whether to use advanced tooltips or not.voidsetView(int view)Sets the current view.voidsetViewPortHandler(IViewPortHandler2 vph)voidsetZoomHandler(IZoomHandler zoomHandler)voidsetZoomLevel(int level)Sets the zoom level.voidshowAllLayers()Shows all layers and redraws the event area.voidshowEvent(GanttEvent ge, int side)Scrolls the chart to the selected item regardless if it is visible or not.voidshowLayer(int layer)Shows all layers of the given value and redraws the event area.(package private) voidshowScrollDate()(package private) voidupdateHorizontalScrollbar()(package private) voidupdateVerticalScrollBar(boolean redraw)voidvScroll()voidzoomIn()Zooms in.voidzoomIn(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)voidzoomOut()Zooms out.voidzoomOut(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIMEMethods 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, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods 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, updateMethods 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.SINGLEyou 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:
getBoundsin 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.Sourcewill 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.RIGHTclearMinutes- 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 aGanttSpecialDateRangeto the chart.- Parameters:
range-GanttSpecialDateRangeto add.
-
removeSpecialDateRange
Removes aGanttSpecialDateRangeto the chart and redraws.- Parameters:
range-GanttSpecialDateRangeto remove
-
removeSpecialDateRange
Removes aGanttSpecialDateRangeto the chart and redraws.- Parameters:
range-GanttSpecialDateRangeto removeredraw- true to redraw
-
clearSpecialDateRanges
public void clearSpecialDateRanges()Removes allGanttSpecialDateRanges and redraws. -
addSpecialDateRange
Adds aGanttSpecialDateRangeand optionally redraws.- Parameters:
range-GanttSpecialDateRangeto 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 ofGanttConnectionobjects.- 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:
mouseDoubleClickin 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:
mouseDownin interfaceorg.eclipse.swt.events.MouseListener
-
mouseUp
public void mouseUp(org.eclipse.swt.events.MouseEvent event)- Specified by:
mouseUpin 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:
keyPressedin interfaceorg.eclipse.swt.events.KeyListener
-
keyReleased
public void keyReleased(org.eclipse.swt.events.KeyEvent e)- Specified by:
keyReleasedin interfaceorg.eclipse.swt.events.KeyListener
-
mouseMove
public void mouseMove(org.eclipse.swt.events.MouseEvent me)- Specified by:
mouseMovein 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:
mouseEnterin interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseExit
public void mouseExit(org.eclipse.swt.events.MouseEvent event)- Specified by:
mouseExitin interfaceorg.eclipse.swt.events.MouseTrackListener
-
mouseHover
public void mouseHover(org.eclipse.swt.events.MouseEvent me)- Specified by:
mouseHoverin 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:
zoomInin interfaceIZoomHandler
-
zoomIn
public void zoomIn(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)- Specified by:
zoomInin interfaceIZoomHandler
-
zoomOut
public void zoomOut()Zooms out. If zooming is disabled, does nothing.- Specified by:
zoomOutin interfaceIZoomHandler
-
zoomOut
public void zoomOut(boolean fromMouseWheel, org.eclipse.swt.graphics.Point mouseLoc)- Specified by:
zoomOutin interfaceIZoomHandler
-
resetZoom
public void resetZoom()Resets the zoom level to that set in the settings.- Specified by:
resetZoomin interfaceIZoomHandler
-
redraw
public void redraw()- Overrides:
redrawin 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
-