[]
        
(Showing Draft Content)

IGradientStops

Interface IGradientStops

All Superinterfaces:
Iterable<IGradientStop>

public interface IGradientStops extends Iterable<IGradientStop>
Represents a collection of IGradientStop objects.

Use this collection to access, add, and remove the gradient stops that define a gradient fill or line. Instances of this interface are typically obtained from APIs such as IFillFormat.getGradientStops().


 IComment comment = worksheet.getRange("A1").addComment("Gradient fill");
 comment.getShape().getFill().twoColorGradient(GradientStyle.Horizontal, 1);
 IGradientStops gradientStops = comment.getShape().getFill().getGradientStops();
 gradientStops.get(0).getColor().setRGB(Color.FromArgb(255, 0, 0));
 gradientStops.get(1).getColor().setRGB(Color.FromArgb(0, 0, 255));
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(int index)
    Removes the gradient stop at the specified index.
    get(int index)
    Gets the IGradientStop object at the specified index from this IGradientStops collection.
    int
    Gets the number of gradient stops in this IGradientStops collection.
    void
    insert(int rgb, double position)
    Adds a gradient stop with the specified color and position.
    void
    insert(int rgb, double position, double transparency, int index, double brightness)
    Inserts a gradient stop at the specified index and sets its color, position, transparency, and brightness.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • getCount

      int getCount()
      Gets the number of gradient stops in this IGradientStops collection.

      Each gradient stop defines a color transition point in a gradient fill or line.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
       IFillFormat fill = shape.getFill();
       fill.twoColorGradient(GradientStyle.Horizontal, 1);
       IGradientStops stops = fill.getGradientStops();
       int count = stops.getCount();
       
      Returns:
      The number of IGradientStop objects in this collection.
    • get

      IGradientStop get(int index)
      Gets the IGradientStop object at the specified index from this IGradientStops collection.
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
       IFillFormat fill = shape.getFill();
       fill.twoColorGradient(GradientStyle.Horizontal, 1);
       IGradientStops stops = fill.getGradientStops();
       IGradientStop stop = stops.get(0);
       double position = stop.getPosition();
       
      Parameters:
      index - The zero-based index of the gradient stop to retrieve.
      Returns:
      The IGradientStop object at the specified index.
    • delete

      void delete(int index)
      Removes the gradient stop at the specified index.

      Use this method to remove a color transition point from the gradient definition.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
       IFillFormat fill = shape.getFill();
       fill.twoColorGradient(GradientStyle.Horizontal, 1);
       IGradientStops stops = fill.getGradientStops();
       stops.delete(0);
       
      Parameters:
      index - The zero-based index of the gradient stop to remove.
    • insert

      void insert(int rgb, double position)
      Adds a gradient stop with the specified color and position.

      This overload forwards to insert(int,double,double,int,double) with transparency set to 0, index set to -1, and brightness set to 0.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
       IFillFormat fill = shape.getFill();
       fill.twoColorGradient(GradientStyle.Horizontal, 1);
       IGradientStops stops = fill.getGradientStops();
       stops.insert(Color.GetBlue().toArgb(), 0.5);
       
      Parameters:
      rgb - The color at the gradient stop, specified as an ARGB color value.
      position - The position of the stop within the gradient, expressed as a percentage.
    • insert

      void insert(int rgb, double position, double transparency, int index, double brightness)
      Inserts a gradient stop at the specified index and sets its color, position, transparency, and brightness.

      Use this method to add a stop to an existing gradient definition and control how the color appears at a specific point in the gradient.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 120, 80);
       IFillFormat fill = shape.getFill();
       fill.twoColorGradient(GradientStyle.Horizontal, 1);
       IGradientStops stops = fill.getGradientStops();
       stops.insert(Color.GetBlue().toArgb(), 0.5, 0.2, 1, 0.1);
       
      Parameters:
      rgb - The color of the gradient stop.
      position - The position of the stop within the gradient, expressed as a percentage.
      transparency - The opacity of the color at the gradient stop.
      index - The zero-based index at which to insert the gradient stop.
      brightness - The brightness of the color at the gradient stop.