com.dlsc.flexgantt.swing.layer.system
Class PopupLayer

java.lang.Object
  extended by com.dlsc.flexgantt.swing.layer.AbstractLayer
      extended by com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
          extended by com.dlsc.flexgantt.swing.layer.system.PopupLayer
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.KeyEventDispatcher, java.util.EventListener

public class PopupLayer
extends AbstractSystemLayer
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.KeyEventDispatcher

A bar underneath a timeline is a nice representation for an activity but it can only carry a limited number of information due to space restrictions. Popups / annotations that show up when the mouse cursor hovers over such a bar is a nice feature that can display a wealth of additional information that the planner might need to make a scheduling decision. The popup layer uses renderers that perform the actual rendering of the popup windows. The layer can display a standard popup and an extended popup depending on whether the user holds down the SHIFT key while hovering over a timeline object.

Since:
1.0
Author:
Dirk Lemmermann

Field Summary
 
Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE
 
Constructor Summary
PopupLayer(LayerContainer lc)
          Constructs a new popup layer.
 
Method Summary
 void addPinnedPopup(TimelineObjectPath path)
          Adds a path to the layer that reference a timeline object with a pinned popup.
 void clearPinnedPopups()
          Removes all pinned popups.
 boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
          Intercepts key events from the KeyboardFocusManager for two reasons: to toggle between the standard and the extended popup when the user presses the SHIFT key to pin the currently showing popup when the user hits the RETURN key
 java.awt.Point getOffset()
          Returns the offset used to move the popup away from or closer to (if negative) the timeline object that was the source of the popup input.
 java.awt.Point getPinnedOffset()
          Returns the offset used to move the pinned popup away from or closer to (if negative) the timeline object that was the source of the popup input.
 java.util.List<TimelineObjectPath> getPinnedPopups()
          Returns a list with all currently pinned popups.
 IPopupRenderer getPopupRenderer(java.lang.Class cl)
          Returns a popup renderer for a given popup value type.
 boolean isAnimating()
          Determines whether the popup layer will use a fade-in effect when showing the popup.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void paintLayer(java.awt.Graphics g)
           
protected  void paintPopup(java.awt.Graphics g, TimelineObjectPath path, boolean pinned)
          Renders the popup for the given object bounds.
 void removePinnedPopup(TimelineObjectPath path)
          Removes a timeline object path from the list of pinned popups.
 void setAnimating(boolean animating)
          Specifies whether the popup layer will use a fade-in effect when showing the popup.
 void setOffset(java.awt.Point offset)
          Sets an offset that gets used to move the popup away from or closer to (if negative) the timeline object that it is describing.
 void setPinnedOffset(java.awt.Point offset)
          Sets an offset that gets used to move the pinned popup away from or closer to (if negative) the timeline object that it is describing.
 void setPinnedPopups(java.util.List<TimelineObjectPath> paths)
          Sets a list with all currently pinned popups.
 void setPopupRenderer(java.lang.Class objectType, IPopupRenderer renderer)
          Maps the implementation of a popup renderer to a popup object definition.
 void setVisible(boolean b)
          Specifies whether the layer is visible or not.
 
Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer
addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, isVisible, removePropertyChangeListener, repaint, repaint, repaint, setAlpha, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PopupLayer

public PopupLayer(LayerContainer lc)
Constructs a new popup layer.

Parameters:
lc - the layer container that contains the popup layer.
Since:
1.0
Method Detail

getOffset

public java.awt.Point getOffset()
Returns the offset used to move the popup away from or closer to (if negative) the timeline object that was the source of the popup input.

Returns:
an offset for the popup
Since:
1.0

setOffset

public void setOffset(java.awt.Point offset)
Sets an offset that gets used to move the popup away from or closer to (if negative) the timeline object that it is describing.

Parameters:
offset - a distance in pixels between the popup and the timeline object
Since:
1.0

getPinnedOffset

public java.awt.Point getPinnedOffset()
Returns the offset used to move the pinned popup away from or closer to (if negative) the timeline object that was the source of the popup input.

Returns:
an offset for the popup
Since:
1.0

setPinnedOffset

public void setPinnedOffset(java.awt.Point offset)
Sets an offset that gets used to move the pinned popup away from or closer to (if negative) the timeline object that it is describing.

Parameters:
offset - a distance in pixels between the popup and the timeline object
Since:
1.0

addPinnedPopup

public void addPinnedPopup(TimelineObjectPath path)
Adds a path to the layer that reference a timeline object with a pinned popup.

Parameters:
path - the path of a timeline object
Since:
1.0

removePinnedPopup

public void removePinnedPopup(TimelineObjectPath path)
Removes a timeline object path from the list of pinned popups. The timeline object referenced by the bounds will no longer display a pinned popup.

Parameters:
path - the path of a timeline object
Since:
1.0

clearPinnedPopups

public void clearPinnedPopups()
Removes all pinned popups.

Since:
1.0

getPinnedPopups

public java.util.List<TimelineObjectPath> getPinnedPopups()
Returns a list with all currently pinned popups.

Returns:
all pinned popups
Since:
1.0

setPinnedPopups

public void setPinnedPopups(java.util.List<TimelineObjectPath> paths)
Sets a list with all currently pinned popups.

Parameters:
paths - all pinned popups
Since:
1.0

paintLayer

protected void paintLayer(java.awt.Graphics g)
Overrides:
paintLayer in class AbstractLayer

paintPopup

protected void paintPopup(java.awt.Graphics g,
                          TimelineObjectPath path,
                          boolean pinned)
Renders the popup for the given object bounds. The method will lookup an appropriate IPopupRenderer implementation based on the object type of the timeline object.

Parameters:
g - the graphics context
path - timeline object path
pinned - if TRUE the popup is a pinned popup
Since:
1.0

setVisible

public void setVisible(boolean b)
Description copied from class: AbstractLayer
Specifies whether the layer is visible or not.

Overrides:
setVisible in class AbstractLayer
Parameters:
b - if TRUE the layer will be visible
See Also:
AbstractLayer.isVisible()

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

setPopupRenderer

public void setPopupRenderer(java.lang.Class objectType,
                             IPopupRenderer renderer)
Maps the implementation of a popup renderer to a popup object definition.

Parameters:
objectType - the type of the popup objects where the popup will be rendered with the given renderer
renderer - an implementation that will be used to renderer instances of the given popup object type
Since:
1.0
See Also:
DefaultPopupRenderer, IPopupPolicy.getPopupValue(Object, Object, IGanttChartModel, boolean)

getPopupRenderer

public IPopupRenderer getPopupRenderer(java.lang.Class cl)
Returns a popup renderer for a given popup value type.

Parameters:
cl - the popup object type in need of rendering
Returns:
a matching popup renderer implementation
Since:
1.0
See Also:
setPopupRenderer(Class, IPopupRenderer), DefaultPopupRenderer, IPopupPolicy

dispatchKeyEvent

public boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
Intercepts key events from the KeyboardFocusManager for two reasons:

Specified by:
dispatchKeyEvent in interface java.awt.KeyEventDispatcher
Since:
1.0

isAnimating

public boolean isAnimating()
Determines whether the popup layer will use a fade-in effect when showing the popup.

Returns:
TRUE if the layer animates the popup
Since:
1.0

setAnimating

public void setAnimating(boolean animating)
Specifies whether the popup layer will use a fade-in effect when showing the popup.

Parameters:
animating - if TRUE if the layer animates the popup
Since:
1.0