Class ShadowConf

java.lang.Object
swingtree.style.ShadowConf

@Immutable public final class ShadowConf extends Object
An immutable config API designed for defining shadow styles as part of the full StyleConf configuration object. The state of this object can only be updated by using wither like update methods, like horizontalOffset(double), verticalOffset(double), blurRadius(double)... which return a new instance of this class with the updated state.

The following properties with their respective purpose are available:

  1. Horizontal Offset

    The horizontal shadow offset, if positive the shadow will move to the right, if negative the shadow will move to the left.

  2. Vertical Offset

    The vertical shadow offset, if positive the shadow will move down, if negative the shadow will move up.

  3. Blur Radius

    The blur radius of the shadow, which defines the width of the blur effect. The higher the value, the bigger the blur, so the shadow transition will be stretched over a wider area.

  4. Spread Radius

    The spread radius of the shadow defines how far inwards or outwards (isInset()) the shadow begins. This offsets the start of the shadow similarly to the vertical and horizontal offsets, but instead of moving the shadow, it extends the shadow so that it either grows or shrinks in size.
    You can imagine a shadow effect as a rectangular box, where the gradients of the shadow start at the edges of said box. The spread radius then defines the scale of the box, so that the shadow either grows or shrinks in size.

  5. Color

    The color of the shadow.

  6. Inset

    Whether the shadow is inset or outset. If true, the shadow is inset, otherwise it is outset. Inset shadows go inward, starting from the inner edge of the box (and its border), whereas outset shadows go outward, starting from the outer edge of the box's border.

Note that you can use the none() method to specify that no shadow should be used, as the instance returned by that method is a shadow with no offset, no blur, no spread and no color, effectively making it a representation of the absence of a shadow.

  • Method Summary

    Modifier and Type
    Method
    Description
    blurRadius(double shadowBlurRadius)
    The blur radius of a shadow defines the gap size between the start and end of the shadow gradient.
    color(double red, double green, double blue)
    Use this to define the color of the visible shadow gradient in terms of the red, green and blue components consisting of three double values ranging from 0.0 to 1.0, where 0.0 represents the absence of the color component and 1.0 represents the color component at full strength.
    color(double red, double green, double blue, double alpha)
    Use this to define the color of the visible shadow gradient in terms of the red, green, blue and alpha components consisting of four double values ranging from 0.0 to 1.0, where 0.0 represents the absence of the color component and 1.0 represents the color component at full strength.
    color(Color shadowColor)
    Use this to define the color of the visible shadow gradient.
    color(String shadowColor)
    Updates the color of the shadow using a color string which can be specified in various formats.
    boolean
     
    int
     
    horizontalOffset(double horizontalShadowOffset)
    Use this to offset the shadow position along the X axis.
    isInset(boolean shadowInset)
    The isInset parameter determines whether the shadow is inset or outset, in terms of the direction of the shadow gradient either going inward or outward.
    isOutset(boolean shadowOutset)
    Use this to define whether the shadow is outset or inset, which will determine the direction of the shadow gradient.
    static ShadowConf
     
    offset(double shadowOffset)
    Use this to offset the shadow diagonally between the top left corner and the bottom right corner.
    offset(double horizontalShadowOffset, double verticalShadowOffset)
    Use this to offset the shadow position along the X or Y axis using the two supplied horizontalShadowOffset and verticalShadowOffset doubles.
     
    float
     
    spreadRadius(double shadowSpreadRadius)
    The spread radius of a shadow is a sort of scale for the shadow box.
     
    verticalOffset(double verticalShadowOffset)
    Defines the shadow position along the Y axis in terms of the "vertical shadow offset".

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • none

      public static ShadowConf none()
    • spreadRadius

      public float spreadRadius()
    • horizontalOffset

      public ShadowConf horizontalOffset(double horizontalShadowOffset)
      Use this to offset the shadow position along the X axis. If the horizontalShadowOffset is positive, the shadow will move to the right, if negative the shadow will move to the left.
      Parameters:
      horizontalShadowOffset - The horizontal shadow offset, if positive the shadow will move to the right, if negative the shadow will move to the left.
      Returns:
      A new ShadowConf with the specified horizontal shadow offset.
    • verticalOffset

      public ShadowConf verticalOffset(double verticalShadowOffset)
      Defines the shadow position along the Y axis in terms of the "vertical shadow offset". It will move the shadow up if negative and down if positive.
      Parameters:
      verticalShadowOffset - The vertical shadow offset, if positive the shadow will move down, if negative the shadow will move up.
      Returns:
      A new ShadowConf with the specified vertical shadow offset.
    • offset

      public ShadowConf offset(double horizontalShadowOffset, double verticalShadowOffset)
      Use this to offset the shadow position along the X or Y axis using the two supplied horizontalShadowOffset and verticalShadowOffset doubles. The horizontalShadowOffset will shift the shadow along the X axis, while the verticalShadowOffset will shift the shadow along the Y axis.
      Parameters:
      horizontalShadowOffset - The horizontal shadow offset, if positive the shadow will move to the right, if negative the shadow will move to the left.
      verticalShadowOffset - The vertical shadow offset, if positive the shadow will move down, if negative the shadow will move up.
      Returns:
      A new ShadowConf with the specified horizontal and vertical shadow offsets.
    • offset

      public ShadowConf offset(double shadowOffset)
      Use this to offset the shadow diagonally between the top left corner and the bottom right corner. This is effectively a diagonal shadow offset as it is applied to both the X and Y axis. (see offset(double, double) for more information)
      Parameters:
      shadowOffset - The shadow offset, if positive the shadow will move to the right and down, if negative the shadow will move to the left and up.
      Returns:
      A new ShadowConf with the specified horizontal and vertical shadow offsets.
    • blurRadius

      public ShadowConf blurRadius(double shadowBlurRadius)
      The blur radius of a shadow defines the gap size between the start and end of the shadow gradient. The higher the value, the bigger the blur, so the shadow transition will extend further inwards or outwards (isInset()) from the shadow center.
      Parameters:
      shadowBlurRadius - The blur radius of the shadow, which defines the width of the blur effect. The higher the value, the bigger the blur, so the shadow transition will be stretched over a wider area.
      Returns:
      A new ShadowConf with the specified blur radius.
    • spreadRadius

      public ShadowConf spreadRadius(double shadowSpreadRadius)
      The spread radius of a shadow is a sort of scale for the shadow box. So when the spread radius is large the shadow will both begin and end further away from the shadow center. When the spread radius is small the shadow will be more concentrated around the shadow center.
      Parameters:
      shadowSpreadRadius - The spread radius of the shadow, which defines how far the shadow spreads outwards or inwards (isInset()) from the element. This offsets the start of the shadow similarly to the vertical and horizontal offsets, but instead of moving the shadow, it extends the shadow so that it either grows or shrinks in size.
      Returns:
      A new ShadowConf with the specified spread radius.
    • color

      public ShadowConf color(Color shadowColor)
      Use this to define the color of the visible shadow gradient.
      Parameters:
      shadowColor - The color of the shadow.
      Returns:
      A new ShadowConf with the specified color.
    • color

      public ShadowConf color(String shadowColor)
      Updates the color of the shadow using a color string which can be specified in various formats. (see UIFactoryMethods.color(String) for more information)
      Parameters:
      shadowColor - The color of the shadow in the form of a String. The color can be specified in the following formats:
      • HTML color name - like "red"
      • Hexadecimal RGB value - like "#ff0000"
      • Hexadecimal RGBA value - like "#ff0000ff"
      • RGB value - like "rgb(255, 0, 0)"
      • RGBA value - like "rgba(255, 0, 0, 1.0)"
      • HSB value - like "hsb(0, 100%, 100%)"
      • HSBA value - like "hsba(0, 100%, 100%, 1.0)"
      Returns:
      A new ShadowConf with the specified color.
    • color

      public ShadowConf color(double red, double green, double blue)
      Use this to define the color of the visible shadow gradient in terms of the red, green and blue components consisting of three double values ranging from 0.0 to 1.0, where 0.0 represents the absence of the color component and 1.0 represents the color component at full strength.
      Parameters:
      red - The red component of the shadow color.
      green - The green component of the shadow color.
      blue - The blue component of the shadow color.
      Returns:
      A new ShadowConf with the specified color.
    • color

      public ShadowConf color(double red, double green, double blue, double alpha)
      Use this to define the color of the visible shadow gradient in terms of the red, green, blue and alpha components consisting of four double values ranging from 0.0 to 1.0, where 0.0 represents the absence of the color component and 1.0 represents the color component at full strength.
      Parameters:
      red - The red component of the shadow color.
      green - The green component of the shadow color.
      blue - The blue component of the shadow color.
      alpha - The alpha component of the shadow color.
      Returns:
      A new ShadowConf with the specified color.
    • isInset

      public ShadowConf isInset(boolean shadowInset)
      The isInset parameter determines whether the shadow is inset or outset, in terms of the direction of the shadow gradient either going inward or outward. If the isInset parameter is true, the shadow color will fade away towards the center of the shadow box, whereas if the isInset parameter is false, the shadow color will fade away towards the outer edge of the shadow box.
      This is essentially the inverse of the isOutset(boolean) method.
      Parameters:
      shadowInset - Whether the shadow is inset or outset. If true, the shadow is inset, otherwise it is outset. Inset shadows go inward, starting from the inner edge of the box (and its border), whereas outset shadows go outward, starting from the outer edge of the box's border.
      Returns:
      A new ShadowConf with the specified inset/outset state.
    • isOutset

      public ShadowConf isOutset(boolean shadowOutset)
      Use this to define whether the shadow is outset or inset, which will determine the direction of the shadow gradient. If the isOutset parameter is true, the shadow gradient color will fade away towards the outer edge of the shadow box. If the isOutset parameter is false on the other hand, the shadow color fades away towards the center of the shadow box.
      This is essentially the inverse of the isInset(boolean) method.
      Parameters:
      shadowOutset - Whether the shadow is outset or inset. If true, the shadow is outset, otherwise it is inset. Outset shadows go outward, starting from the outer edge of the box's border, whereas inset shadows go inward, starting from the inner edge of the box (and its border).
      Returns:
      A new ShadowConf with the specified outset/inset state.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • simplified

      public ShadowConf simplified()