com.dlsc.flexgantt.swing.layer.system

## Class PopupLayer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.AbstractLayer
  - - com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
    - - com.dlsc.flexgantt.swing.layer.system.PopupLayer

- All Implemented Interfaces:
    MouseListener, MouseMotionListener, KeyEventDispatcher, EventListener

      public class PopupLayer
      extends AbstractSystemLayer
      implements MouseListener, MouseMotionListener, 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
  Version:
    $Revision: 1.11 $
  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

    Constructors
    Constructor and Description
    `PopupLayer(LayerContainer lc)` Constructs a new popup layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `protected org.jdesktop.animation.timing.Animator` | `createAnimator(org.jdesktop.animation.timing.TimingTarget fadeIn)` Creates the animator, which performs the fading in of the popup.
    `boolean` | `dispatchKeyEvent(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
    `int` | `getAnimationDelay()` Returns the number of milliseconds to wait before popups will appear.
    `int` | `getAnimationDuration()` Returns the duration it takes for the popups to become fully visible.
    `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.
    `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.
    `List<TimelineObjectPath>` | `getPinnedPopups()` Returns a list with all currently pinned popups.
    `IPopupRenderer` | `getPopupRenderer(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.
    `boolean` | `isShowingRelationshipObjectPopups()` Determines whether the layer will show popups for relationships (lines between timeline objets).
    `boolean` | `isShowingTimlineObjectPopups()` Determines whether the layer will show popups for timeline objects.
    `boolean` | `isShowingTreeNodePopups()` Determines whether the layer will show popups for tree nodes.
    `boolean` | `isVisible()` Determines whether the layer is currently visible or not.
    `void` | `mouseClicked(MouseEvent e)`
    `void` | `mouseDragged(MouseEvent e)`
    `void` | `mouseEntered(MouseEvent e)`
    `void` | `mouseExited(MouseEvent e)`
    `void` | `mouseMoved(MouseEvent e)`
    `void` | `mousePressed(MouseEvent e)`
    `void` | `mouseReleased(MouseEvent e)`
    `protected void` | `paintLayer(Graphics g)`
    `protected void` | `paintRelationshipPopup(Graphics g, IRelationship relationship)` Renders the popup for the given timeline object path.
    `protected void` | `paintTimelineObjectPathPopup(Graphics g, TimelineObjectPath path, boolean pinned)` Renders the popup for the given timeline object path.
    `protected void` | `paintTreePathPopup(Graphics g, TreePath path, boolean pinned)` Renders the popup for the given tree path.
    `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` | `setAnimationDelay(int animationDelay)` Sets the number of milliseconds to wait before popups will appear.
    `void` | `setAnimationDuration(int animationDuration)` Specifies the duration it takes for the popups to become fully visible.
    `void` | `setOffset(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(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(List<TimelineObjectPath> paths)` Sets a list with all currently pinned popups.
    `void` | `setPopupRenderer(Class objectType, IPopupRenderer renderer)` Maps the implementation of a popup renderer to a popup object definition.
    `void` | `setShowingRelationshipObjectPopups(boolean showing)` Controls whether the popup layer will show popups for relationships (lines between timeline objects).
    `void` | `setShowingTimlineObjectPopups(boolean showing)` Controls whether the popup layer will show popups for timeline objects.
    `void` | `setShowingTreeNodePopups(boolean showing)` Controls whether the popup layer will show popups for tree nodes.
    `void` | `setVisible(boolean b)` Specifies whether the layer is visible or not.
    `void` | `tearDown()` Removes the layer from the keyboard focus manager.

    - ### Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getHeight, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, getWidth, removePropertyChangeListener, repaint, repaint, repaint, setAlpha`

    - ### 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

    - #### setShowingRelationshipObjectPopups

          public void setShowingRelationshipObjectPopups(boolean showing)

      Controls whether the popup layer will show popups for relationships (lines between timeline objects).
      Parameters:
        `showing` - if TRUE the layer will show popups for relationships
      Since:
        2.0

    - #### isShowingRelationshipObjectPopups

          public boolean isShowingRelationshipObjectPopups()

      Determines whether the layer will show popups for relationships (lines between timeline objets).
      Returns:
        TRUE if the layer shows relationship popups
      Since:
        2.0

    - #### setShowingTimlineObjectPopups

          public void setShowingTimlineObjectPopups(boolean showing)

      Controls whether the popup layer will show popups for timeline objects.
      Parameters:
        `showing` - if TRUE the layer will show popups for timeline objects
      Since:
        2.0

    - #### isShowingTimlineObjectPopups

          public boolean isShowingTimlineObjectPopups()

      Determines whether the layer will show popups for timeline objects.
      Returns:
        TRUE if the layer shows timeline object popups
      Since:
        2.0

    - #### setShowingTreeNodePopups

          public void setShowingTreeNodePopups(boolean showing)

      Controls whether the popup layer will show popups for tree nodes.
      Parameters:
        `showing` - if TRUE the layer will show popups for tree nodes
      Since:
        2.0

    - #### isShowingTreeNodePopups

          public boolean isShowingTreeNodePopups()

      Determines whether the layer will show popups for tree nodes.
      Returns:
        TRUE if the layer shows tree node popups
      Since:
        2.0

    - #### isVisible

          public boolean isVisible()

      Description copied from class: `AbstractLayer`
      Determines whether the layer is currently visible or not.
      Overrides:
        `isVisible` in class `AbstractLayer`
      Returns:
        TRUE if the layer is currently visible
      See Also:
        `AbstractLayer.setVisible(boolean)`

    - #### getOffset

          public 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(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 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(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 List<TimelineObjectPath> getPinnedPopups()

      Returns a list with all currently pinned popups.
      Returns:
        all pinned popups
      Since:
        1.0

    - #### setPinnedPopups

          public void setPinnedPopups(List<TimelineObjectPath> paths)

      Sets a list with all currently pinned popups.
      Parameters:
        `paths` - all pinned popups
      Since:
        1.0

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### paintTimelineObjectPathPopup

          protected void paintTimelineObjectPathPopup(Graphics g,
                                                      TimelineObjectPath path,
                                                      boolean pinned)

      Renders the popup for the given timeline object path. 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.1

    - #### paintTreePathPopup

          protected void paintTreePathPopup(Graphics g,
                                            TreePath path,
                                            boolean pinned)

      Renders the popup for the given tree path. The method will lookup an appropriate `IPopupRenderer` implementation based on the object type of the timeline object.
      Parameters:
        `g` - the graphics context
        `path` - the tree path
        `pinned` - if TRUE the popup is a pinned popup
      Since:
        1.1

    - #### paintRelationshipPopup

          protected void paintRelationshipPopup(Graphics g,
                                                IRelationship relationship)

      Renders the popup for the given timeline object path. The method will lookup an appropriate `IPopupRenderer` implementation based on the object type of the timeline object.
      Parameters:
        `g` - the graphics context
        `relationship` - the relationship for which to draw a popup
      Since:
        2.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(MouseEvent e)

      Specified by:
        `mouseMoved` in interface `MouseMotionListener`

    - #### createAnimator

          protected org.jdesktop.animation.timing.Animator createAnimator(org.jdesktop.animation.timing.TimingTarget fadeIn)

      Creates the animator, which performs the fading in of the popup. Subclasses are free to override this method to provide their own animator object.
      Parameters:
        `fadeIn` - the timing target that gets animated
      Returns:
        an animator instance
      Since:
        1.1.5

    - #### setAnimationDuration

          public void setAnimationDuration(int animationDuration)

      Specifies the duration it takes for the popups to become fully visible.
      Parameters:
        `animationDuration` - the duration in milliseconds
      Since:
        2.1

    - #### getAnimationDuration

          public int getAnimationDuration()

      Returns the duration it takes for the popups to become fully visible.
      Returns:
        the duration in milliseconds
      Since:
        2.1

    - #### setAnimationDelay

          public void setAnimationDelay(int animationDelay)

      Sets the number of milliseconds to wait before popups will appear.
      Parameters:
        `animationDelay` - the popup delay in milliseconds.
      Since:
        2.0
      See Also:
        `createAnimator(TimingTarget)`

    - #### getAnimationDelay

          public int getAnimationDelay()

      Returns the number of milliseconds to wait before popups will appear.
      Returns:
        the popup delay in milliseconds.
      Since:
        2.0
      See Also:
        `createAnimator(TimingTarget)`

    - #### mouseDragged

          public void mouseDragged(MouseEvent e)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`

    - #### mouseClicked

          public void mouseClicked(MouseEvent e)

      Specified by:
        `mouseClicked` in interface `MouseListener`

    - #### mouseEntered

          public void mouseEntered(MouseEvent e)

      Specified by:
        `mouseEntered` in interface `MouseListener`

    - #### mouseExited

          public void mouseExited(MouseEvent e)

      Specified by:
        `mouseExited` in interface `MouseListener`

    - #### mousePressed

          public void mousePressed(MouseEvent e)

      Specified by:
        `mousePressed` in interface `MouseListener`

    - #### mouseReleased

          public void mouseReleased(MouseEvent e)

      Specified by:
        `mouseReleased` in interface `MouseListener`

    - #### setPopupRenderer

          public void setPopupRenderer(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(TimelineObjectPath, IGanttChartModel, boolean)`

    - #### getPopupRenderer

          public IPopupRenderer getPopupRenderer(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(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
      Specified by:
        `dispatchKeyEvent` in interface `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

    - #### tearDown

          public void tearDown()

      Removes the layer from the keyboard focus manager.
      Overrides:
        `tearDown` in class `AbstractLayer`
      Since:
        1.1

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.