Class FXAdvancedLinearGradientPicker

  • All Implemented Interfaces:
    Drawable

    public class FXAdvancedLinearGradientPicker
    extends Composite
    A picker for multi-stop LinearGradients.
    • Constructor Detail

      • FXAdvancedLinearGradientPicker

        public FXAdvancedLinearGradientPicker​(Composite parent,
                                              javafx.scene.paint.Color color1,
                                              javafx.scene.paint.Color color2,
                                              javafx.scene.paint.Color color3)
        Parameters:
        parent - The parent Composite.
        color1 - The first color of the initial three-stop LinearGradient.
        color2 - The second color of the initial three-stop LinearGradient.
        color3 - The third color of the initial three-stop LinearGradient.
    • Method Detail

      • createAdvancedLinearGradient

        public static javafx.scene.paint.LinearGradient createAdvancedLinearGradient​(javafx.scene.paint.Color c1,
                                                                                     javafx.scene.paint.Color c2,
                                                                                     javafx.scene.paint.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​(javafx.scene.paint.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 javafx.beans.property.Property<javafx.scene.paint.LinearGradient> advancedLinearGradientProperty()
        Returns a writable Property for the advanced gradient.
        Returns:
        A writable Property.
      • createStop

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

        public javafx.scene.paint.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 java.util.List<javafx.scene.paint.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​(javafx.scene.paint.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​(java.util.List<javafx.scene.paint.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,
                                  javafx.scene.paint.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.