Class FXAdvancedLinearGradientPicker

All Implemented Interfaces:
Drawable

public class FXAdvancedLinearGradientPicker extends Composite
A picker for multi-stop LinearGradients.
  • Property Details

  • Field Details

  • Constructor Details

  • Method Details

    • createAdvancedLinearGradient

      public static LinearGradient createAdvancedLinearGradient(Color c1, Color c2, Color c3)
      Creates an "advanced" linear color gradient with 3 stops from the given colors.
      Parameters:
      c1 - The start color.
      c2 - The middle color (t = 0.5).
      c3 - The end color.
      Returns:
      An "advanced" LinearGradient from the given colors.
    • isAdvancedLinearGradient

      public static boolean isAdvancedLinearGradient(Paint paint)
      Returns true if the given Paint is considered to be an "advanced" gradient. Otherwise returns false. An advanced gradient can either be a linear gradient with at least 3 stops, or any radial gradient.
      Parameters:
      paint - The Paint in question.
      Returns:
      true if the given Paint is considered to be an "advanced" gradient, othwerise false.
    • advancedLinearGradientProperty

      public Property<LinearGradient> advancedLinearGradientProperty()
      Returns a writable Property for the advanced gradient.
      See Also:
    • createStop

      protected void createStop(double offset)
      Creates a new spot for the given offset.
      Parameters:
      offset - The offset for the new spot.
    • getAdvancedLinearGradient

      public LinearGradient getAdvancedLinearGradient()
      Returns the currently selected advanced gradient.
      Returns:
      The currently selected advanced gradient.
    • getNextOffset

      protected double getNextOffset(int stopIndex)
      Computes the maximum offset for the given stop index.
      Parameters:
      stopIndex - The index of the stop for which to compute the next offset.
      Returns:
      The maximum offset for the given stop index.
    • getPrevOffset

      protected double getPrevOffset(int stopIndex)
      Computes the minimum offset for the given stop index.
      Parameters:
      stopIndex - The index of the stop for which to compute the previous offset.
      Returns:
      The minimum offset for the given stop index.
    • getStops

      protected List<Stop> getStops()
      Returns a list of the Stops of the currently selected advanced gradient.
      Returns:
      A list of the Stops of the currently selected advanced gradient.
    • removeStop

      protected void removeStop(int index)
      Removes the spot specified by the given index.
      Parameters:
      index - The spot index.
    • setAdvancedGradient

      public void setAdvancedGradient(LinearGradient advancedLinearGradient)
      Sets the gradient managed by this gradient picker to the given value. Does also update the UI so that the new gradient can be manipulated.
      Parameters:
      advancedLinearGradient - The new gradient.
    • updateDirectionLine

      protected void updateDirectionLine()
      Updates the direction line to display the current direction (specified by directionX and directionY).
    • updateGradient

      protected void updateGradient(List<Stop> newStops)
      Changes the currently selected advanced gradient to a new linear gradient that is constructed from the given list of Stops.
      Parameters:
      newStops - The list of Stops from which the newly selected advanced gradient is constructed.
    • updateStop

      protected void updateStop(int index, double offset, Color color)
      Sets the offset and color of the spot specified by the given index to the given values.
      Parameters:
      index - The index of the spot.
      offset - The new offset for that spot.
      color - The new color for that spot.