[]
Use this interface to inspect and modify fill settings such as solid color, pattern, gradient, texture, transparency, and visibility for a drawing object. Instances of this interface are typically obtained from a public formatting API such as IShape.getFill().
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
fillFormat.getColor().setRGB(Color.GetBlue());
getColor()IColorFormat object that represents the specified foreground fill or solid color.doubledoubleintIColorFormat object that represents the specified pattern color.booleanIFillFormat.doubleIFillFormat.doubledoubledoubledoublegetType()booleanvoidoneColorGradient(GradientStyle style,
int variant,
double degree) voidpatterned(PatternType pattern) voidpresetGradient(GradientStyle style,
int variant,
PresetGradientType presetGradientType) voidpresetTextured(PresetTexture presetTexture) voidsetGradientAngle(double value) voidsetGradientPathType(PathShapeType value) voidsetRotateWithObject(boolean value) voidIFillFormat.voidsetTextureHorizontalScale(double value) IFillFormat.voidsetTextureOffsetX(double value) voidsetTextureOffsetY(double value) voidsetTextureVerticalScale(double value) voidsetTransparency(double value) voidsetVisible(boolean value) voidsolid()voidtwoColorGradient(GradientStyle style,
int variant) voiduserPicture(InputStream stream,
ImageType type) voiduserPicture(String fileName) voiduserTextured(InputStream stream,
ImageType type) voiduserTextured(String fileName) IColorFormat object that represents the specified pattern color. Use this property to read or modify the foreground color used by a pattern fill. To apply a pattern fill first, use patterned(PatternType).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.patterned(PatternType.LightDownwardDiagonal);
IColorFormat patternColor = fillFormat.getPatternColor();
patternColor.setRGB(Color.GetBlue());
IColorFormat object that represents the pattern color.IColorFormat object that represents the specified foreground fill or solid color. Use the returned IColorFormat to inspect or modify the color used by the current fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
IColorFormat color = fillFormat.getColor();
color.setRGB(Color.GetBlue());
IColorFormat object that represents the foreground fill or solid color.Use this method to determine whether the fill for the shape is currently displayed.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
fillFormat.setVisible(false);
boolean visible = fillFormat.getVisible();
true if the object is visible; otherwise, false.Use this method to show or hide the fill for the shape.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
fillFormat.setVisible(false);
value - true if the object is visible; otherwise, false.Use this method to get the direction of a gradient that has been applied to the fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
fillFormat.setGradientAngle(45);
double angle = fillFormat.getGradientAngle();
Use this method to set the direction of a gradient that has been applied to the fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
fillFormat.setGradientAngle(45);
value - The angle of the gradient fill for the specified fill format.Use this method to determine which path-based gradient shape is applied to the fill. For radial, rectangular, or path gradients, set the value with setGradientPathType(PathShapeType) before reading it back.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.FromCenter, 1);
fillFormat.setGradientPathType(PathShapeType.Radial);
PathShapeType pathType = fillFormat.getGradientPathType();
Use this method after configuring a gradient fill to change how the gradient is applied to the shape, such as a linear, radial, rectangular, or path-based fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.FromCenter, 1);
fillFormat.setGradientPathType(PathShapeType.Radial);
value - The path shape type for the gradient fill.Use this property to retrieve the shading intensity that was applied by oneColorGradient(GradientStyle,int,double).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.oneColorGradient(GradientStyle.DiagonalDown, 2, 0.5);
double degree = fillFormat.getGradientDegree();
Use the returned IGradientStops collection to inspect or modify the colors and positions that define the gradient.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
IGradientStops gradientStops = fillFormat.getGradientStops();
gradientStops.get(0).getColor().setRGB(Color.GetBlue());
IGradientStops collection for the gradient fill, or null if the fill does not define gradient stops.Use this property to retrieve the GradientStyle that was applied by gradient fill methods such as oneColorGradient(GradientStyle,int,double) and twoColorGradient(GradientStyle,int).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.FromCenter, 1);
GradientStyle style = fillFormat.getGradientStyle();
GradientStyle for the fill.The returned value corresponds to the gradient variant used by the current fill settings.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 3);
int variant = fillFormat.getGradientVariant();
Use this method to retrieve the PatternType applied to the shape's fill after the fill has been configured as a pattern fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.patterned(PatternType.Percent10);
PatternType pattern = fillFormat.getPattern();
PatternType used by the fill.Use this method to retrieve the PresetGradientType that is applied after calling presetGradient(GradientStyle,int,PresetGradientType).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetGradient(GradientStyle.Vertical, 4, PresetGradientType.CalmWater);
PresetGradientType gradientType = fillFormat.getPresetGradientType();
Use this method to get the PresetTexture currently applied to a texture fill set by presetTextured(PresetTexture).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
PresetTexture texture = fillFormat.getPresetTexture();
This property indicates whether the current fill style follows the object's rotation.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
fillFormat.setRotateWithObject(false);
boolean rotateWithObject = fillFormat.getRotateWithObject();
true if the fill style rotates with the object; otherwise, false.This property indicates whether the current fill style follows the object's rotation.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
fillFormat.setRotateWithObject(false);
value - true if the fill style rotates with the object; otherwise, false.IFillFormat. This property specifies the origin of the coordinate grid used to tile the texture fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureAlignment(TextureAlignment.Center);
TextureAlignment alignment = fillFormat.getTextureAlignment();
IFillFormat. Use this method to control how the texture is aligned within the fill area.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureAlignment(TextureAlignment.Center);
value - The texture alignment to apply.IFillFormat. Use this property to retrieve the horizontal scale applied to the current texture fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureHorizontalScale(1.5);
double scale = fillFormat.getTextureHorizontalScale();
IFillFormat. Use this property to set the horizontal scale applied to the current texture fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureHorizontalScale(1.5);
value - The horizontal scale value for the texture fill.Use this property to retrieve the horizontal tile offset applied to the current texture fill. If this value is not set on the current fill and a parent fill exists, the inherited value is returned.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureOffsetX(12.0);
double offsetX = fillFormat.getTextureOffsetX();
Use this property to set the horizontal tile offset applied to the current texture fill. If this value is not set on the current fill and a parent fill exists, the inherited value is returned.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureOffsetX(12.0);
value - The horizontal offset value for the texture fill.Use this property to get the vertical offset applied to a texture fill layout.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureOffsetY(3.2);
double offsetY = fillFormat.getTextureOffsetY();
Use this property to set the vertical offset applied to a texture fill layout.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureOffsetY(3.2);
value - The offset Y value for the specified fill.Use this property to get the vertical scale applied to the current texture fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureVerticalScale(0.8);
double scale = fillFormat.getTextureVerticalScale();
Use this property to set the vertical scale applied to the current texture fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureVerticalScale(0.8);
value - The vertical scale value for the texture fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
fillFormat.setTransparency(0.25);
double transparency = fillFormat.getTransparency();
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
fillFormat.setTransparency(0.25);
value - The degree of transparency of the fill, from 0.0 for a fully opaque fill to 1.0 for a fully clear fill.Use this method to determine which kind of fill is currently applied to the object, such as solid, patterned, gradient, textured, picture, or group fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
FillType fillType = fillFormat.getType();
Use this method to apply a gradient that varies a single color from dark to light. The variant value can be from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, variant can only be 1 or 2.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.oneColorGradient(GradientStyle.Horizontal, 1, 0.5);
double degree = fillFormat.getGradientDegree();
style - The GradientStyle to apply.variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If GradientStyle.FromCenter is used, the value can only be 1 or 2.degree - The gradient degree. Can be a value from 0.0 (dark) through 1.0(light).Use this method to apply a PatternType fill to a shape. After the pattern is set, you can customize the background color and pattern color through getColor() and getPatternColor().
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.patterned(PatternType.LightDownwardDiagonal);
fillFormat.getColor().setRGB(Color.GetRed());
fillFormat.getPatternColor().setRGB(Color.GetBlue());
pattern - The PatternType object.Use this method to apply one of the built-in gradient presets to a shape fill.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetGradient(GradientStyle.Vertical, 4, PresetGradientType.CalmWater);
PresetGradientType gradientType = fillFormat.getPresetGradientType();
style - The GradientStyle object to be set.variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, variant can only be 1 or 2.presetGradientType - The PresetGradientType object.Use this method to apply one of the built-in PresetTexture values to a shape fill. After applying the texture, you can further adjust the texture layout by using methods such as setTextureAlignment(TextureAlignment).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.presetTextured(PresetTexture.Canvas);
fillFormat.setTextureAlignment(TextureAlignment.Center);
presetTexture - The PresetTexture to apply. Must not be null.After calling this method, use getColor() to configure the solid fill color.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.solid();
fillFormat.getColor().setRGB(Color.GetBlue());
Use this method to apply a gradient fill that blends between two colors. After calling this method, configure the gradient colors through the fill's color settings.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
fillFormat.getColor().setRGB(Color.GetBlue());
style - The GradientStyle to apply.variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the value can only be 1 or 2.Use this method to apply an image file as the fill for a shape. To fill the shape with small tiles of an image, use userTextured(String).
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
fillFormat.userPicture(imagePath);
} catch (Exception e) {
throw new IllegalStateException("Unable to use shape fill picture from file", e);
}
fileName - The name of the picture file.IOException - if the picture file cannot be read.Use this method to apply a picture fill from an InputStream. Specify the image format with the ImageType parameter.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
try (InputStream stream = createSampleImageStream()) {
fillFormat.userPicture(stream, ImageType.PNG);
} catch (IOException e) {
throw new IllegalStateException("Unable to use shape fill picture from stream", e);
}
stream - The stream of the picture file.type - The ImageType of the stream.IOException - if an I/O error occurs while reading the image stream.Use this method to apply a texture fill from an image file. The image is tiled across the shape instead of being stretched as a single picture.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
try {
String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
fillFormat.userTextured(imagePath);
} catch (IOException e) {
throw new IllegalStateException("Unable to apply shape texture from file", e);
}
fileName - The name of the picture file.IOException - if the picture file cannot be read.Use this method to apply a texture fill from an image stream. The type parameter specifies the ImageType of the image data in the stream.
IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.getFill();
byte[] imageData = new byte[] {(byte) 137, 80, 78, 71, 13, 10, 26, 10};
try (InputStream stream = new ByteArrayInputStream(imageData)) {
fillFormat.userTextured(stream, ImageType.PNG);
} catch (Exception e) {
throw new IllegalStateException("Unable to apply shape texture from stream", e);
}
stream - The stream of the picture file.type - The ImageType of the stream.