[]
        
(Showing Draft Content)

IColorStops

Interface IColorStops

All Superinterfaces:
Iterable<IColorStop>

public interface IColorStops extends Iterable<IColorStop>
Represents a collection of IColorStop objects for a linear or rectangular gradient fill.

Use this interface to access, add, clear, or iterate gradient stops in a cell or range gradient fill. You can get this collection from ILinearGradient.getColorStops() or IRectangularGradient.getColorStops().


 IRange range = worksheet.getRange("A1");
 range.getInterior().setPattern(Pattern.LinearGradient);

 ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
 IColorStops colorStops = gradient.getColorStops();

 colorStops.get(0).setColor(Color.GetRed());
 colorStops.get(1).setColor(Color.GetBlue());

 IColorStop middleStop = colorStops.add(0.5);
 middleStop.setColor(Color.GetYellow());
 
  • Method Summary

    Modifier and Type
    Method
    Description
    add(double position)
    Adds a gradient stop at the specified relative position and returns the new IColorStop object.
    void
    Clears all gradient stops from the collection.
    get(int index)
    Returns the IColorStop object at the specified index in the collection.
    int
    Gets the number of gradient stops in the collection.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • get

      IColorStop get(int index)
      Returns the IColorStop object at the specified index in the collection.
      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStops colorStops = gradient.getColorStops();
      
       IColorStop startStop = colorStops.get(0);
       startStop.setColor(Color.GetRed());
      
       IColorStop endStop = colorStops.get(1);
       endStop.setColor(Color.GetBlue());
       
      Parameters:
      index - The zero-based index of the gradient stop in the collection.
      Returns:
      The IColorStop object at the specified index in the collection.
    • getCount

      int getCount()
      Gets the number of gradient stops in the collection.
      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStops colorStops = gradient.getColorStops();
      
       int count = colorStops.getCount();
       
      Returns:
      The number of gradient stops in the collection.
    • add

      IColorStop add(double position)
      Adds a gradient stop at the specified relative position and returns the new IColorStop object.

      The position value must be between 0.0 and 1.0, where 0.0 represents the start of the gradient and 1.0 represents the end.

      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStops colorStops = gradient.getColorStops();
      
       colorStops.get(0).setColor(Color.GetRed());
       colorStops.get(1).setColor(Color.GetBlue());
      
       IColorStop middleStop = colorStops.add(0.5);
       middleStop.setColor(Color.GetYellow());
       
      Parameters:
      position - The relative position of the gradient stop, from 0.0 to 1.0.
      Returns:
      The new IColorStop object.
    • clear

      void clear()
      Clears all gradient stops from the collection.
      
       IRange range = worksheet.getRange("A1");
       range.getInterior().setPattern(Pattern.LinearGradient);
      
       ILinearGradient gradient = (ILinearGradient) range.getInterior().getGradient();
       IColorStops colorStops = gradient.getColorStops();
      
       colorStops.clear();
      
       colorStops = gradient.getColorStops();
       colorStops.add(0.0).setColor(Color.GetRed());
       colorStops.add(1.0).setColor(Color.GetBlue());