GradientFormat / PatternFormat — Aspose.Slides FOSS for Java API Reference
The GradientFormat and PatternFormat classes control gradient and pattern fill properties for shapes. Both extend PVIObject.
Package: org.aspose.slides.foss
import org.aspose.slides.foss.*;GradientFormat
public class GradientFormat extends PVIObject implements IGradientFormat, IFillParamSourceProperties
| Property | Type | Access | Description |
|---|---|---|---|
getGradientDirection() / setGradientDirection(GradientDirection) | GradientDirection | Read/Write | Gradient direction (linear, path, etc.). |
getGradientShape() | GradientShape | Read | Gradient shape. |
getLinearGradientAngle() / setLinearGradientAngle(double) | double | Read/Write | Angle for linear gradients (degrees). |
getLinearGradientScaled() / setLinearGradientScaled(NullableBool) | NullableBool | Read/Write | Whether the gradient is scaled. |
getTileFlip() / setTileFlip(TileFlip) | TileFlip | Read/Write | Tile flip mode. |
getGradientStops() | IGradientStopCollection | Read | Collection of gradient stops. |
Usage Example
import org.aspose.slides.foss.*;
import java.awt.Color;
IAutoShape shape = slide.getShapes().addAutoShape(
ShapeType.RECTANGLE, 50, 50, 200, 100);
IFillFormat fill = shape.getFillFormat();
fill.setFillType(FillType.GRADIENT);
IGradientFormat grad = fill.getGradientFormat();
grad.setGradientDirection(GradientDirection.FROM_CORNER1);
grad.setLinearGradientAngle(45.0);PatternFormat
public class PatternFormat extends PVIObject implements IPatternFormatProperties
| Property | Type | Access | Description |
|---|---|---|---|
getPatternStyle() / setPatternStyle(PatternStyle) | PatternStyle | Read/Write | Pattern style (e.g., PERCENT05, HORIZONTAL, etc.). |
getForeColor() | IColorFormat | Read | Foreground color of the pattern. |
getBackColor() | IColorFormat | Read | Background color of the pattern. |
Usage Example
IFillFormat fill = shape.getFillFormat();
fill.setFillType(FillType.PATTERN);
IPatternFormat pattern = fill.getPatternFormat();
pattern.setPatternStyle(PatternStyle.HORIZONTAL);
pattern.getForeColor().setColor(Color.BLACK);
pattern.getBackColor().setColor(Color.WHITE);