public class FlipOrientation
Example:
Document doc = new Document();
// The lines will cross the whole page
float pageWidth = (float) doc.getFirstSection().getPageSetup().getPageWidth();
float pageHeight = (float) doc.getFirstSection().getPageSetup().getPageHeight();
// This line goes from top left to bottom right by default
Shape lineA = new Shape(doc, ShapeType.LINE);
{
lineA.setBounds(new Rectangle2D.Float(0f, 0f, pageWidth, pageHeight));
lineA.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
lineA.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
}
Assert.assertEquals(new Rectangle2D.Float(0f, 0f, pageWidth, pageHeight), lineA.getBoundsInPoints());
// This line goes from bottom left to top right because we flipped it
Shape lineB = new Shape(doc, ShapeType.LINE);
{
lineB.setBounds(new Rectangle2D.Float(0f, 0f, pageWidth, pageHeight));
lineB.setFlipOrientation(FlipOrientation.HORIZONTAL);
lineB.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
lineB.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
}
Assert.assertEquals(new Rectangle2D.Float(0f, 0f, pageWidth, pageHeight), lineB.getBoundsInPoints());
// Add lines to the document
doc.getFirstSection().getBody().getFirstParagraph().appendChild(lineA);
doc.getFirstSection().getBody().getFirstParagraph().appendChild(lineB);
doc.save(getArtifactsDir() + "Shape.LineFlipOrientation.docx");
Field Summary | ||
---|---|---|
static final int | NONE | |
Coordinates are not flipped.
|
||
static final int | HORIZONTAL | |
Flip along the y-axis, reversing the x-coordinates.
|
||
static final int | VERTICAL | |
Flip along the x-axis, reversing the y-coordinates.
|
||
static final int | BOTH | |
Flip along both the y- and x-axis.
|
public static final int NONE
public static final int HORIZONTAL
public static final int VERTICAL
public static final int BOTH