# Class LinearGradientPaint

java.lang.Object
com.codename1.ui.MultipleGradientPaint
com.codename1.ui.LinearGradientPaint

All Implemented Interfaces:
  `Paint`

public class LinearGradientPaint extends MultipleGradientPaint
LinearGradientPaint provides a way to fill a `Shape` with a linear gradient.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class MultipleGradientPaint

  `MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod`
  Modifier and Type
  Class
  Description
  `static enum`
  `MultipleGradientPaint.ColorSpaceType`
  Colors spaces for gradients.
  `static enum`
  `MultipleGradientPaint.CycleMethod`
  Cycle methods for gradients.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LinearGradientPaint(double startX, double startY, double endX, double endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)`
  Creates a LinearGradientPaint with the specified settings.
  `LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)`
  Creates a LinearGradientPaint with the specified settings.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `paint(Graphics g, double x, double y, double w, double h)`
  Painds the linear gradient in the given bounds.
  `final void`
  `paint(Graphics g, Rectangle2D bounds)`
  Paints linear gradient in the given bounds.

  ### Methods inherited from class MultipleGradientPaint

  `getColors, getColorSpace, getCycleMethod, getFractions, getTransform, getTransparency, setColors, setColorSpace, setCycleMethod, setFractions, setTransform, setTransparency`
  Modifier and Type
  Method
  Description
  `int[]`
  `getColors()`
  Gets the colors used in the gradient.
  `MultipleGradientPaint.ColorSpaceType`
  `getColorSpace()`
  Gets the color space for the gradient.
  `MultipleGradientPaint.CycleMethod`
  `getCycleMethod()`
  Gets the cycle method.
  `float[]`
  `getFractions()`
  Gets the fractional positions for the color gradients.
  `Transform`
  `getTransform()`
  Gets the gradient transform.
  `int`
  `getTransparency()`
  Gets the transparency for the gradient.
  `void`
  `setColors(int[] colors)`
  Sets the colors used in the gradient.
  `void`
  `setColorSpace(MultipleGradientPaint.ColorSpaceType colorSpaceType)`
  Sets the color space for the gradient.
  `void`
  `setCycleMethod(MultipleGradientPaint.CycleMethod cycleMethod)`
  Sets the cycle method.
  `void`
  `setFractions(float[] fractions)`
  Sets the fractional positions of the color gradients.
  `void`
  `setTransform(Transform transform)`
  Sets the transform for the gradient.
  `void`
  `setTransparency(int transparency)`
  Sets the transparency for the gradient.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## Constructor Details

  - ### LinearGradientPaint

    public LinearGradientPaint(float startX, float startY, float endX, float endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)

    Creates a LinearGradientPaint with the specified settings.

    ###### Parameters

    - `startX`: The startX coordinate of the gradient in user space.

    - `startY`: The startY coordinate of the gradient in user space.

    - `endX`: The endX coordinate of the gradient in user space.

    - `endY`: THe endY coordinate of the gradient in user space.

    - `fractions`: Fractional positions of where gradient colors begin. Each value should be between 0 and 1.

    - `colors`: The colors to use in the gradient. There should be the same number of colors as there are fractions.

    - `cycleMethod`: The cycle method to use.

    - `colorSpace`: The color space to use.

    - `gradientTransform`: Transform to use for the gradient. Not used right now.

  - ### LinearGradientPaint

    public LinearGradientPaint(double startX, double startY, double endX, double endY, float[] fractions, int[] colors, MultipleGradientPaint.CycleMethod cycleMethod, MultipleGradientPaint.ColorSpaceType colorSpace, Transform gradientTransform)

    Creates a LinearGradientPaint with the specified settings.

    ###### Parameters

    - `startX`: The startX coordinate of the gradient in user space.

    - `startY`: The startY coordinate of the gradient in user space.

    - `endX`: The endX coordinate of the gradient in user space.

    - `endY`: THe endY coordinate of the gradient in user space.

    - `fractions`: Fractional positions of where gradient colors begin. Each value should be between 0 and 1.

    - `colors`: The colors to use in the gradient. There should be the same number of colors as there are fractions.

    - `cycleMethod`: The cycle method to use.

    - `colorSpace`: The color space to use.

    - `gradientTransform`: Transform to use for the gradient. Not used right now.

- ## Method Details

  - ### paint

    public final void paint(Graphics g, Rectangle2D bounds)

    Paints linear gradient in the given bounds.

    ###### Parameters

    - `g`

    - `bounds`

  - ### paint

    public void paint(Graphics g, double x, double y, double w, double h)

    Painds the linear gradient in the given bounds.

    ###### Parameters

    - `g`

    - `x`

    - `y`

    - `w`

    - `h`