Class ColorCache


  • public final class ColorCache
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map _cache  
      private static ColorCache _instance  
      static org.eclipse.swt.graphics.RGB BLACK  
      static org.eclipse.swt.graphics.RGB WHITE  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ColorCache()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void checkInstance()  
      private void dispose()  
      static void disposeAll()
      Disposes all colors held in the cache and colors created when class is created.
      static void disposeCachedColor()
      Disposes the cached colors only.
      static org.eclipse.swt.graphics.Color getBlack()
      Returns the color black R0, G0, B0
      static org.eclipse.swt.graphics.Color getColor​(int red, int green, int blue)
      Returns a color that is also cached if it has not been created before.
      static org.eclipse.swt.graphics.Color getColor​(org.eclipse.swt.graphics.RGB rgb)
      Returns a color that is also cached if it has not been created before.
      static org.eclipse.swt.graphics.Color getRandomColor()
      Returns a random color.
      static org.eclipse.swt.graphics.Color getWhite()
      Returns the color white R255, G255, B255
      • Methods inherited from class java.lang.Object

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

      • BLACK

        public static final org.eclipse.swt.graphics.RGB BLACK
      • WHITE

        public static final org.eclipse.swt.graphics.RGB WHITE
      • _cache

        private static java.util.Map _cache
    • Constructor Detail

      • ColorCache

        private ColorCache()
    • Method Detail

      • disposeAll

        public static void disposeAll()
        Disposes all colors held in the cache and colors created when class is created.

        IMPORTANT: ONLY CALL WHEN YOU WANT TO DISPOSE THE WIDGET USING THIS CLASS!

        If you only wish to dispose colors you have created through the use of the class, please use disposeCachedColors()

        See Also:
        disposeCachedColor()
      • disposeCachedColor

        public static void disposeCachedColor()
        Disposes the cached colors only.
      • checkInstance

        private static void checkInstance()
      • dispose

        private void dispose()
      • getWhite

        public static org.eclipse.swt.graphics.Color getWhite()
        Returns the color white R255, G255, B255
        Returns:
        White color
      • getBlack

        public static org.eclipse.swt.graphics.Color getBlack()
        Returns the color black R0, G0, B0
        Returns:
        Black color
      • getColor

        public static org.eclipse.swt.graphics.Color getColor​(org.eclipse.swt.graphics.RGB rgb)
        Returns a color that is also cached if it has not been created before.
        Parameters:
        rgb - RGB colors
        Returns:
        Color
      • getColor

        public static org.eclipse.swt.graphics.Color getColor​(int red,
                                                              int green,
                                                              int blue)
        Returns a color that is also cached if it has not been created before.
        Parameters:
        red - Red
        green - Green
        blue - Blue
        Returns:
        Color
      • getRandomColor

        public static org.eclipse.swt.graphics.Color getRandomColor()
        Returns a random color.
        Returns:
        random color