Class NoiseConf

java.lang.Object
swingtree.style.NoiseConf

@Immutable public final class NoiseConf extends Object
A noise gradient configuration which is used to define a noise gradient style for a component based on a NoiseFunction which is a function that takes a coordinate and returns a value between 0 and 1.
The noise gradient is then defined by a list of colors which will transition from one to the next in the order they are specified.
The noise gradient can also be offset, scaled, rotated and clipped to a specific area of the component, and positioned at a specific boundary of the component.
  • Method Summary

    Modifier and Type
    Method
    Description
    Define the boundary at which the noise gradient should start in terms of its base position.
    Define the area of the component to which the noise gradient is clipped to.
    colors(Color... colors)
    Define a list of colors which will, as part of the noise gradient, transition from one to the next in the order they are specified.
    colors(String... colors)
    Define a list of String based colors which will, as part of the noise gradient, transition from one to the next in the order they are specified.
    boolean
    equals(@Nullable Object o)
     
    fractions(double... fractions)
    Define the fractions of the noise gradient which is an array of values between 0 and 1 that defines the relative position of each color in the noise gradient.
    Accepts the NoiseFunction, which takes a coordinate and returns a value between 0 and 1.
    int
     
    static NoiseConf
    Use the returned instance as a representation of the absence of a noise gradient.
    offset(double x, double y)
    Define the offset of the noise gradient which is the start position of the noise gradient on the x and y-axis.
    rotation(float rotation)
    Define the rotation of the noise gradient in degrees.
    scale(double scale)
    Define the scale of the noise gradient in terms of its size / granularity.
    scale(double x, double y)
    Define the x and y scale of the noise gradient in terms of its size / granularity.
     
     

    Methods inherited from class java.lang.Object

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

    • none

      public static NoiseConf none()
      Use the returned instance as a representation of the absence of a noise gradient.
      Returns:
      A noise gradient without any colors, effectively representing the absence of a noise gradient.
    • function

      public NoiseConf function(NoiseFunction function)
      Accepts the NoiseFunction, which takes a coordinate and returns a value between 0 and 1.
      The noise function is used to define the noise gradient.

      Take a look at UI.NoiseType for a rich set of predefined noise functions.

      Parameters:
      function - The noise function mapping the translated, scaled and rotated virtual space to a gradient value of a pixel in the color space / view space of the screen.
      Returns:
      A new noise gradient style with the specified noise function.
    • colors

      public NoiseConf colors(Color... colors)
      Define a list of colors which will, as part of the noise gradient, transition from one to the next in the order they are specified.

      Note that you need to specify at least two colors for a noise gradient to be visible.

      Parameters:
      colors - The colors in the noise gradient.
      Returns:
      A new noise gradient style with the specified colors.
      Throws:
      NullPointerException - if any of the colors is null.
    • colors

      public NoiseConf colors(String... colors)
      Define a list of String based colors which will, as part of the noise gradient, transition from one to the next in the order they are specified.

      Note that you need to specify at least two colors for a noise gradient to be visible.

      Parameters:
      colors - The colors in the noise gradient in String format.
      Returns:
      A new noise gradient style with the specified colors.
      Throws:
      NullPointerException - if any of the colors is null.
    • offset

      public NoiseConf offset(double x, double y)
      Define the offset of the noise gradient which is the start position of the noise gradient on the x and y-axis.
      Note that the offset is relative to the component that the noise gradient is applied to.

      Parameters:
      x - The noise gradient start offset on the x-axis.
      y - The noise gradient start offset on the y-axis.
      Returns:
      A new noise gradient style with the specified offset.
    • scale

      public NoiseConf scale(double scale)
      Define the scale of the noise gradient in terms of its size / granularity. It scales the input space of the noise function.
      Parameters:
      scale - The noise gradient size.
      Returns:
      A new noise gradient style with the specified size.
    • scale

      public NoiseConf scale(double x, double y)
      Define the x and y scale of the noise gradient in terms of its size / granularity. It scales the input space of the noise function.
      Parameters:
      x - The noise gradient size on the x-axis.
      y - The noise gradient size on the y-axis.
      Returns:
      A new noise gradient style with the specified size.
    • clipTo

      public NoiseConf clipTo(UI.ComponentArea area)
      Define the area of the component to which the noise gradient is clipped to. Which means that the noise gradient will only be visible within the specified area of the component.
      Parameters:
      area - The area of the component to which the noise gradient is clipped to.
      Returns:
      A new noise gradient style with the specified area.
    • boundary

      public NoiseConf boundary(UI.ComponentBoundary boundary)
      Define the boundary at which the noise gradient should start in terms of its base position. So if the boundary is set to UI.ComponentBoundary.EXTERIOR_TO_BORDER then the noise gradient position will be determined by the margin of the component.
      Here a complete list of the available boundaries:
      • UI.ComponentBoundary.OUTER_TO_EXTERIOR - The outermost boundary of the entire component, including any margin that might be applied. Using this boundary will cause the noise gradient to be positioned somewhere at the outer most edge of the component.
      • UI.ComponentBoundary.EXTERIOR_TO_BORDER - The boundary located after the margin but before the border. This tightly wraps the entire UI.ComponentArea.BODY. Using this boundary will cause the noise gradient to be positioned somewhere at the outer most edge of the component's body, which is between the margin and the border.
      • UI.ComponentBoundary.BORDER_TO_INTERIOR - The boundary located after the border but before the padding. It represents the edge of the component's interior. Using this boundary will cause the noise gradient to be positioned somewhere at the outer most edge of the component's interior, which is between the border and the padding area.
      • UI.ComponentBoundary.INTERIOR_TO_CONTENT - The boundary located after the padding. It represents the innermost boundary of the component, where the actual content of the component begins, like for example the contents of a JPanel or JScrollPane. Using this boundary will cause the noise gradient to be positioned somewhere after the padding area and before the content area, which is where all of the child components are located.

      You can think of this property as a convenient way to define the base position of the noise gradient. So if you want to do the positioning yourself, then you may configure this property to UI.ComponentBoundary.OUTER_TO_EXTERIOR, which will cause the noise gradient to be positioned at the outermost edge of the component, and then use the offset(double, double) method to define the exact position of the noise gradient.

      Parameters:
      boundary - The boundary at which the noise gradient should start in terms of its offset.
      Returns:
      A new noise gradient style with the specified boundary.
    • rotation

      public NoiseConf rotation(float rotation)
      Define the rotation of the noise gradient in degrees. This will rotate the input space of the noise function.
      Parameters:
      rotation - The rotation of the noise gradient in degrees.
    • fractions

      public NoiseConf fractions(double... fractions)
      Define the fractions of the noise gradient which is an array of values between 0 and 1 that defines the relative position of each color in the noise gradient.

      Note that the number of fractions must match the number of colors in the noise gradient. If the number of fractions is less than the number of colors, then the remaining colors will be evenly distributed between the last two fractions.

      Parameters:
      fractions - The fractions of the noise gradient.
    • toString

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

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public NoiseConf simplified()