Class GradientTexturePaint

    • Field Detail

      • seedingEnabled

        protected static boolean seedingEnabled
        This is an advanced option only used for testing/debugging.
      • colors

        protected Color[] colors
      • fractions

        protected float[] fractions
      • hasAlpha

        protected boolean hasAlpha
      • needsDiffusion

        protected boolean needsDiffusion
      • x1

        protected float x1
      • y1

        protected float y1
      • x2

        protected float x2
      • y2

        protected float y2
    • Constructor Detail

      • GradientTexturePaint

        public GradientTexturePaint(float x1,
                                    float y1,
                                    Color c1,
                                    float x2,
                                    float y2,
                                    Color c2)
        Create a 2-color gradient using Cycle.NONE.
        Parameters:
        x1 - the x-coordinate of first point
        y1 - the y-coordinate of first point
        c1 - the first color
        x2 - the x-coordinate of second point
        y2 - the y-coordinate of second point
        c2 - the second color
      • GradientTexturePaint

        public GradientTexturePaint(Color[] colors,
                                    float[] fractions,
                                    float x1,
                                    float y1,
                                    float x2,
                                    float y2,
                                    GradientTexturePaint.Cycle cycle)
        Creates a new GradientTexturePaint.
        Parameters:
        colors - the colors to use in this gradient.
        fractions - the fractions to use in this gradient. These must be ascending fractions from [0,1]. Each fraction corresponds to a color.
        x1 - the x-value of the first coordinate.
        y1 - the y-value of the first coordinate.
        x2 - the x-value of the second coordinate.
        y2 - the y-value of the second coordinate.
        cycle - TILE is recommended for best performance.
      • GradientTexturePaint

        public GradientTexturePaint(Color[] colors,
                                    float[] fractions,
                                    Point2D p1,
                                    Point2D p2,
                                    GradientTexturePaint.Cycle cycle)
        Creates a new GradientTexturePaint.
        Parameters:
        colors - the colors to use in this gradient.
        fractions - the fractions to use in this gradient. These must be ascending fractions from [0,1]. Each fraction corresponds to a color.
        p1 - the first point.
        p2 - the second point.
        cycle - TILE is recommended for best performance.
    • Method Detail

      • containsAlpha

        protected static boolean containsAlpha(Color[] colors)
        Return true if any of these colors are not opaque.
        Parameters:
        colors - the colors to check for alpha components
        Returns:
        true if any of the colors in the argument are not fully opaque.
      • needsDiffusion

        public static boolean needsDiffusion(Color[] colors,
                                             float[] fractions,
                                             float x1,
                                             float y1,
                                             float x2,
                                             float y2)
        Return true if this combination of colors and fractions should apply error diffusion prevent color banding.
        Parameters:
        colors - the colors to use in this gradient.
        fractions - the fractions to use in this gradient. These must be ascending fractions from [0,1]. Each fraction corresponds to a color.
        x1 - the x-value of the first coordinate.
        y1 - the y-value of the first coordinate.
        x2 - the x-value of the second coordinate.
        y2 - the y-value of the second coordinate.
        Returns:
        true if the gradient the arguments described should apply error diffusion to prevent color banding.
        See Also:
        Gradients: Avoiding Color Banding
      • getColors

        public Color[] getColors()
        Return the colors in this gradient. Each color corresponds to a value in {link #getFractions()}.
        Returns:
        the colors in this gradient.
      • getFractions

        public float[] getFractions()
        Return the fractions in this gradient. Each fraction corresponds to a value in {link #getColors()}.
        Returns:
        the fractions in this gradient.
      • getTransparency

        public int getTransparency()
        Return Transparency.OPAQUE if all the colors in this gradient are opaque, otherwise this returns Transparency.TRANSLUCENT.
        Specified by:
        getTransparency in interface  Transparency
        Returns:
        the transparency of this gradient.