public class GradientVariant
extends java.lang.Object
Remarks:
Corresponds to the four variants on the Gradient tab in the Fill Effects dialog box in Word.
Examples:
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);
| Modifier and Type | Field and Description |
|---|---|
static int |
length |
static int |
NONE
Gradient variant 'None'.
|
static int |
VARIANT_1
Gradient variant 1.
|
static int |
VARIANT_2
Gradient variant 2.
|
static int |
VARIANT_3
Gradient variant 3.
|
static int |
VARIANT_4
Gradient variant 4.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String gradientVariantName) |
static java.lang.String |
getName(int gradientVariant) |
static int[] |
getValues() |
static java.lang.String |
toString(int gradientVariant) |
public static int NONE
public static int VARIANT_1
public static int VARIANT_2
public static int VARIANT_3
Remarks:
This variant is not applicable to gradient fill with the style GradientStyle.FROM_CENTER, if object has markup language ShapeMarkupLanguage.VML.
public static int VARIANT_4
Remarks:
This variant is not applicable to gradient fill with the style GradientStyle.FROM_CENTER, if object has markup language ShapeMarkupLanguage.VML.
public static int length