com.aspose.words
Class GradientStyle

java.lang.Object
    extended by com.aspose.words.GradientStyle

public class GradientStyle 
extends java.lang.Object

Utility class containing constants. Specifies the style for a gradient fill.

Example:

Shows how to fill a shape with a gradients.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertShape(ShapeType.RECTANGLE, 80.0, 80.0);
// Apply One-color gradient fill to the shape with ForeColor of gradient fill.
shape.getFill().oneColorGradient(Color.RED, GradientStyle.HORIZONTAL, GradientVariant.VARIANT_2, 0.1);

Assert.assertEquals(Color.RED.getRGB(), shape.getFill().getForeColor().getRGB());
Assert.assertEquals(GradientStyle.HORIZONTAL, shape.getFill().getGradientStyle());
Assert.assertEquals(GradientVariant.VARIANT_2, shape.getFill().getGradientVariant());
Assert.assertEquals(270, shape.getFill().getGradientAngle());

shape = builder.insertShape(ShapeType.RECTANGLE, 80.0, 80.0);
// Apply Two-color gradient fill to the shape.
shape.getFill().twoColorGradient(GradientStyle.FROM_CORNER, GradientVariant.VARIANT_4);
// Change BackColor of gradient fill.
shape.getFill().setBackColor(Color.YELLOW);
// Note that changes "GradientAngle" for "GradientStyle.FromCorner/GradientStyle.FromCenter"
// gradient fill don't get any effect, it will work only for linear gradient.
shape.getFill().setGradientAngle(15.0);

Assert.assertEquals(Color.YELLOW.getRGB(), shape.getFill().getBackColor().getRGB());
Assert.assertEquals(GradientStyle.FROM_CORNER, shape.getFill().getGradientStyle());
Assert.assertEquals(GradientVariant.VARIANT_4, shape.getFill().getGradientVariant());
Assert.assertEquals(0, shape.getFill().getGradientAngle());

// Use the compliance option to define the shape using DML if you want to get "GradientStyle",
// "GradientVariant" and "GradientAngle" properties after the document saves.
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); { saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT); }

doc.save(getArtifactsDir() + "Shape.GradientFill.docx", saveOptions);

Field Summary
static final intNONE = -1
           No gradient.
static final intHORIZONTAL = 1
           Gradient running horizontally across an object.
static final intVERTICAL = 2
           Gradient running vertically down an object.
static final intDIAGONAL_UP = 3
           Diagonal gradient moving from a bottom corner up to the opposite corner.
static final intDIAGONAL_DOWN = 4
           Diagonal gradient moving from a top corner down to the opposite corner.
static final intFROM_CORNER = 5
           Gradient running from a corner to the other three corners.
static final intFROM_CENTER = 6
           Gradient running from the center out to the corners.
 

Field Detail

NONE = -1

public static final int NONE
No gradient.

HORIZONTAL = 1

public static final int HORIZONTAL
Gradient running horizontally across an object.

VERTICAL = 2

public static final int VERTICAL
Gradient running vertically down an object.

DIAGONAL_UP = 3

public static final int DIAGONAL_UP
Diagonal gradient moving from a bottom corner up to the opposite corner.

DIAGONAL_DOWN = 4

public static final int DIAGONAL_DOWN
Diagonal gradient moving from a top corner down to the opposite corner.

FROM_CORNER = 5

public static final int FROM_CORNER
Gradient running from a corner to the other three corners.

FROM_CENTER = 6

public static final int FROM_CENTER
Gradient running from the center out to the corners.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.