Class ColorPaintUIResource

java.lang.Object
java.awt.Color
javax.swing.plaf.ColorUIResource
com.github.tadukoo.view.paint.ColorPaintUIResource
All Implemented Interfaces:
PaintUIResource, SizablePaint, Paint, Transparency, Serializable, UIResource

public class ColorPaintUIResource extends ColorUIResource implements PaintUIResource
ColorPaintUIResource is a PaintUIResource to be used in Tadukoo Look & Feel (or other custom Look & Feels if desired) for custom paints if you want a solid color. Using this class allows supporting other component UI classes that may not allow a solid color. It extends ColorUIResource.
Since:
Alpha v.0.2
Version:
Alpha v.0.3
Author:
Logan Ferree (Tadukoo)
See Also:
  • Constructor Details

    • ColorPaintUIResource

      public ColorPaintUIResource(ColorUIResource colorUIResource)
      Create a ColorPaintUIResource using a ColorUIResource.
      Parameters:
      colorUIResource - The ColorUIResource to use for this ColorPaintUIResource
    • ColorPaintUIResource

      public ColorPaintUIResource(Color color)
      Create a ColorPaintUIResource using a Color.
      Parameters:
      color - The Color to use for this ColorPaintUIResource
    • ColorPaintUIResource

      public ColorPaintUIResource(int rgb)
      Create a ColorPaintUIResource using the combined RGB components.
      Parameters:
      rgb - The combined RGB components to use for this ColorPaintUIResource
    • ColorPaintUIResource

      public ColorPaintUIResource(int r, int g, int b)
      Create a ColorPaintUIResource using the separate RGB components.
      Parameters:
      r - The red component of the color
      g - The green component of the color
      b - The blue component of the color
    • ColorPaintUIResource

      public ColorPaintUIResource(float r, float g, float b)
      Create a ColorPaintUIResource using the separate RGB components as floats.
      Parameters:
      r - The red component of the color
      g - The green component of the color
      b - The blue component of the color
  • Method Details

    • getPaint

      public Paint getPaint(Dimension size)
      Returns this as the Paint, since it's an extension of Color.
      Specified by:
      getPaint in interface SizablePaint
      Parameters:
      size - The Dimensions of the object to be painted
      Returns:
      this
    • getColorUIResource

      public ColorUIResource getColorUIResource()
      Description copied from interface: PaintUIResource
      In some cases, we need to return a ColorUIResource to support the Look & Feel properly. I don't like it, but it needs to be done for those Look & Feel pieces to work, and I'm trying to support all of them.
      Specified by:
      getColorUIResource in interface PaintUIResource
      Returns:
      this
    • getMetalGradientList

      public List<Object> getMetalGradientList()
      Description copied from interface: PaintUIResource
      Metal Look and Feel has a trash way of handling gradients. Basically it takes 3 colors and 2 fractions, but with the 3 colors, it repeats color 1 and does 1, 2, 1, 3. The fractions represent the 2 middle points, but the 2nd point is calculated as mid1 * 2 + mid2.

      This method exists for the purpose of appeasing the Metal Look & Feel god who decided this disgusting way of code.
      Specified by:
      getMetalGradientList in interface PaintUIResource
      Returns:
      A List<Object> for use in Metal gradients that will produce a solid color