Class GhostPaintingUtils


  • public class GhostPaintingUtils
    extends java.lang.Object
    Utility class that implements the ghost effects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.LinkedHashMap<java.lang.String,​java.awt.image.BufferedImage> componentGhostCache
      Cache of component ghost images.
      static float DECAY_FACTOR
      Global decay factor.
      private static java.util.LinkedHashMap<java.lang.String,​java.awt.image.BufferedImage> iconGhostCache
      Cache of icon ghost images.
      static float MAX_ICON_GHOSTING_ALPHA
      Maximal starting opacity for icon ghosting.
      static float MAX_PRESS_GHOSTING_ALPHA
      Maximal starting opacity for press ghosting.
      static float MIN_ICON_GHOSTING_ALPHA
      Minimal starting opacity for icon ghosting.
      static float MIN_PRESS_GHOSTING_ALPHA
      Minimal starting opacity for press ghosting.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.awt.image.BufferedImage getComponentGhostImage​(javax.swing.JComponent comp, Timeline ghostPressTimeline, double ghostScaleFactor)
      Returns a scaled ghost image of the specified component.
      private static java.awt.image.BufferedImage getIconGhostImage​(javax.swing.JComponent comp, Timeline ghostRolloverTimeline, javax.swing.Icon icon, double ghostScaleFactor)
      Returns a scaled ghost image of the specified icon.
      static void paintGhostIcon​(java.awt.Graphics2D graphics, java.awt.Component b, javax.swing.Icon icon, java.awt.Rectangle iconRectangle)
      Paints the ghost icon inside the bounds of the specified button.
      static void paintGhostIcon​(java.awt.Graphics2D graphics, javax.swing.AbstractButton b, java.awt.Rectangle iconRectangle)
      Paints the ghost icon inside the bounds of the specified button.
      static void paintGhostImages​(java.awt.Component mainComponent, java.awt.Graphics g)
      Paints ghost images on the specified component.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MIN_ICON_GHOSTING_ALPHA

        public static float MIN_ICON_GHOSTING_ALPHA
        Minimal starting opacity for icon ghosting. Change to a higher value for debugging / demoing purposes.
      • MAX_ICON_GHOSTING_ALPHA

        public static float MAX_ICON_GHOSTING_ALPHA
        Maximal starting opacity for icon ghosting. Change to a higher value for debugging / demoing purposes.
      • MIN_PRESS_GHOSTING_ALPHA

        public static float MIN_PRESS_GHOSTING_ALPHA
        Minimal starting opacity for press ghosting. Change to a higher value for debugging / demoing purposes.
      • MAX_PRESS_GHOSTING_ALPHA

        public static float MAX_PRESS_GHOSTING_ALPHA
        Maximal starting opacity for press ghosting. Change to a higher value for debugging / demoing purposes.
      • DECAY_FACTOR

        public static float DECAY_FACTOR
        Global decay factor.
      • componentGhostCache

        private static java.util.LinkedHashMap<java.lang.String,​java.awt.image.BufferedImage> componentGhostCache
        Cache of component ghost images. Used to speed up the rendering of the ghost effects.
      • iconGhostCache

        private static java.util.LinkedHashMap<java.lang.String,​java.awt.image.BufferedImage> iconGhostCache
        Cache of icon ghost images. Used to speed up the rendering of the ghost effects.
    • Constructor Detail

      • GhostPaintingUtils

        public GhostPaintingUtils()
    • Method Detail

      • getComponentGhostImage

        private static java.awt.image.BufferedImage getComponentGhostImage​(javax.swing.JComponent comp,
                                                                           Timeline ghostPressTimeline,
                                                                           double ghostScaleFactor)
        Returns a scaled ghost image of the specified component.
        Parameters:
        comp - Component.
        ghostScaleFactor - Scale factor.
        Returns:
        A scaled ghost image of the specified component.
      • getIconGhostImage

        private static java.awt.image.BufferedImage getIconGhostImage​(javax.swing.JComponent comp,
                                                                      Timeline ghostRolloverTimeline,
                                                                      javax.swing.Icon icon,
                                                                      double ghostScaleFactor)
        Returns a scaled ghost image of the specified icon.
        Parameters:
        comp - Component.
        icon - Icon.
        ghostScaleFactor - Scale factor.
        Returns:
        A scaled ghost image of the specified icon.
      • paintGhostImages

        public static void paintGhostImages​(java.awt.Component mainComponent,
                                            java.awt.Graphics g)
        Paints ghost images on the specified component.
        Parameters:
        mainComponent - Component.
        g - Graphics context.
      • paintGhostIcon

        public static void paintGhostIcon​(java.awt.Graphics2D graphics,
                                          javax.swing.AbstractButton b,
                                          java.awt.Rectangle iconRectangle)
        Paints the ghost icon inside the bounds of the specified button.
        Parameters:
        graphics - Graphics context.
        b - Button.
        iconRectangle - Rectangle of the button icon.
      • paintGhostIcon

        public static void paintGhostIcon​(java.awt.Graphics2D graphics,
                                          java.awt.Component b,
                                          javax.swing.Icon icon,
                                          java.awt.Rectangle iconRectangle)
        Paints the ghost icon inside the bounds of the specified button.
        Parameters:
        graphics - Graphics context.
        b - Button.
        icon - Icon to paint.
        iconRectangle - Rectangle of the button icon.