public class Stroke
Use the Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a new shape of type Rectangle
Shape rectangle = new Shape(doc, ShapeType.RECTANGLE);
// Change stroke properties
Stroke stroke = rectangle.getStroke();
stroke.setOn(true);
stroke.setWeight(5.0);
stroke.setColor(Color.RED);
stroke.setDashStyle(DashStyle.SHORT_DASH_DOT_DOT);
stroke.setJoinStyle(JoinStyle.MITER);
stroke.setEndCap(EndCap.SQUARE);
stroke.setLineStyle(ShapeLineStyle.TRIPLE);
// Insert shape object
builder.insertNode(rectangle);
Property Getters/Setters Summary | ||
---|---|---|
java.awt.Color | getColor() | |
void | setColor(java.awt.Colorvalue) | |
Defines the color of a stroke. | ||
java.awt.Color | getColor2() | |
void | setColor2(java.awt.Colorvalue) | |
Defines a second color for a stroke. | ||
int | getDashStyle() | |
void | setDashStyle(intvalue) | |
Specifies the dot and dash pattern for a stroke. The value of the property is DashStyle integer constant. | ||
int | getEndArrowLength() | |
void | setEndArrowLength(intvalue) | |
Defines the arrowhead length for the end of a stroke. The value of the property is ArrowLength integer constant. | ||
int | getEndArrowType() | |
void | setEndArrowType(intvalue) | |
Defines the arrowhead for the end of a stroke. The value of the property is ArrowType integer constant. | ||
int | getEndArrowWidth() | |
void | setEndArrowWidth(intvalue) | |
Defines the arrowhead width for the end of a stroke. The value of the property is ArrowWidth integer constant. | ||
int | getEndCap() | |
void | setEndCap(intvalue) | |
Defines the cap style for the end of a stroke. The value of the property is EndCap integer constant. | ||
byte[] | getImageBytes() | |
Defines the image for a stroke image or pattern fill.
|
||
int | getJoinStyle() | |
void | setJoinStyle(intvalue) | |
Defines the join style of a polyline. The value of the property is JoinStyle integer constant. | ||
int | getLineStyle() | |
void | setLineStyle(intvalue) | |
Defines the line style of the stroke. The value of the property is ShapeLineStyle integer constant. | ||
boolean | getOn() | |
void | setOn(booleanvalue) | |
Defines whether the path will be stroked. | ||
double | getOpacity() | |
void | setOpacity(doublevalue) | |
Defines the amount of transparency of a stroke. Valid range is from 0 to 1. | ||
int | getStartArrowLength() | |
void | setStartArrowLength(intvalue) | |
Defines the arrowhead length for the start of a stroke. The value of the property is ArrowLength integer constant. | ||
int | getStartArrowType() | |
void | setStartArrowType(intvalue) | |
Defines the arrowhead for the start of a stroke. The value of the property is ArrowType integer constant. | ||
int | getStartArrowWidth() | |
void | setStartArrowWidth(intvalue) | |
Defines the arrowhead width for the start of a stroke. The value of the property is ArrowWidth integer constant. | ||
double | getWeight() | |
void | setWeight(doublevalue) | |
Defines the brush thickness that strokes the path of a shape in points. |
public java.awt.Color getColor() / public void setColor(java.awt.Color value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public java.awt.Color getColor2() / public void setColor2(java.awt.Color value)
The default value is
Example:
Shows how to process shape stroke features.Document doc = new Document(getMyDir() + "Shape stroke pattern border.docx"); Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true); Stroke stroke = shape.getStroke(); // Strokes can have two colors, which are used to create a pattern defined by two-tone image data. // Strokes with a single color do not use the Color2 attribute. Assert.assertEquals(new Color((128), (0), (0), (255)), stroke.getColor()); Assert.assertEquals(new Color((255), (255), (0), (255)), stroke.getColor2()); Assert.assertNotNull(stroke.getImageBytes()); FileUtils.writeByteArrayToFile(new File(getArtifactsDir() + "Drawing.StrokePattern.png"), stroke.getImageBytes());
public int getDashStyle() / public void setDashStyle(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getEndArrowLength() / public void setEndArrowLength(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getEndArrowType() / public void setEndArrowType(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getEndArrowWidth() / public void setEndArrowWidth(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getEndCap() / public void setEndCap(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public byte[] getImageBytes()
Example:
Shows how to process shape stroke features.Document doc = new Document(getMyDir() + "Shape stroke pattern border.docx"); Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true); Stroke stroke = shape.getStroke(); // Strokes can have two colors, which are used to create a pattern defined by two-tone image data. // Strokes with a single color do not use the Color2 attribute. Assert.assertEquals(new Color((128), (0), (0), (255)), stroke.getColor()); Assert.assertEquals(new Color((255), (255), (0), (255)), stroke.getColor2()); Assert.assertNotNull(stroke.getImageBytes()); FileUtils.writeByteArrayToFile(new File(getArtifactsDir() + "Drawing.StrokePattern.png"), stroke.getImageBytes());
public int getJoinStyle() / public void setJoinStyle(int value)
The default value is
Example:
Shows how change stroke properties.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a new shape of type Rectangle Shape rectangle = new Shape(doc, ShapeType.RECTANGLE); // Change stroke properties Stroke stroke = rectangle.getStroke(); stroke.setOn(true); stroke.setWeight(5.0); stroke.setColor(Color.RED); stroke.setDashStyle(DashStyle.SHORT_DASH_DOT_DOT); stroke.setJoinStyle(JoinStyle.MITER); stroke.setEndCap(EndCap.SQUARE); stroke.setLineStyle(ShapeLineStyle.TRIPLE); // Insert shape object builder.insertNode(rectangle);
public int getLineStyle() / public void setLineStyle(int value)
The default value is
Example:
Shows how change stroke properties.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a new shape of type Rectangle Shape rectangle = new Shape(doc, ShapeType.RECTANGLE); // Change stroke properties Stroke stroke = rectangle.getStroke(); stroke.setOn(true); stroke.setWeight(5.0); stroke.setColor(Color.RED); stroke.setDashStyle(DashStyle.SHORT_DASH_DOT_DOT); stroke.setJoinStyle(JoinStyle.MITER); stroke.setEndCap(EndCap.SQUARE); stroke.setLineStyle(ShapeLineStyle.TRIPLE); // Insert shape object builder.insertNode(rectangle);
public boolean getOn() / public void setOn(boolean value)
The default value is true.
Example:
Shows how change stroke properties.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a new shape of type Rectangle Shape rectangle = new Shape(doc, ShapeType.RECTANGLE); // Change stroke properties Stroke stroke = rectangle.getStroke(); stroke.setOn(true); stroke.setWeight(5.0); stroke.setColor(Color.RED); stroke.setDashStyle(DashStyle.SHORT_DASH_DOT_DOT); stroke.setJoinStyle(JoinStyle.MITER); stroke.setEndCap(EndCap.SQUARE); stroke.setLineStyle(ShapeLineStyle.TRIPLE); // Insert shape object builder.insertNode(rectangle);
public double getOpacity() / public void setOpacity(double value)
The default value is 1.
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getStartArrowLength() / public void setStartArrowLength(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getStartArrowType() / public void setStartArrowType(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public int getStartArrowWidth() / public void setStartArrowWidth(int value)
The default value is
Example:
Shows to create a variety of shapes.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Below are four examples of shapes that we can insert into our documents. // 1 - Dotted, horizontal, half-transparent red line // with an arrow on the left end and a diamond on the right end: Shape arrow = new Shape(doc, ShapeType.LINE); arrow.setWidth(200.0); arrow.getStroke().setColor(Color.RED); arrow.getStroke().setStartArrowType(ArrowType.ARROW); arrow.getStroke().setStartArrowLength(ArrowLength.LONG); arrow.getStroke().setStartArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setEndArrowType(ArrowType.DIAMOND); arrow.getStroke().setEndArrowLength(ArrowLength.LONG); arrow.getStroke().setEndArrowWidth(ArrowWidth.WIDE); arrow.getStroke().setDashStyle(DashStyle.DASH); arrow.getStroke().setOpacity(0.5); Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER); builder.insertNode(arrow); // 2 - Thick black diagonal line with rounded ends: Shape line = new Shape(doc, ShapeType.LINE); line.setTop(40.0); line.setWidth(200.0); line.setHeight(20.0); line.setStrokeWeight(5.0); line.getStroke().setEndCap(EndCap.ROUND); builder.insertNode(line); // 3 - Arrow with a green fill: Shape filledInArrow = new Shape(doc, ShapeType.ARROW); filledInArrow.setWidth(200.0); filledInArrow.setHeight(40.0); filledInArrow.setTop(100.0); filledInArrow.getFill().setColor(Color.GREEN); filledInArrow.getFill().setOn(true); builder.insertNode(filledInArrow); // 4 - Arrow with a flipped orientation filled in with the Aspose logo: Shape filledInArrowImg = new Shape(doc, ShapeType.ARROW); filledInArrowImg.setWidth(200.0); filledInArrowImg.setHeight(40.0); filledInArrowImg.setTop(160.0); filledInArrowImg.setFlipOrientation(FlipOrientation.BOTH); BufferedImage image = ImageIO.read(getAsposelogoUri().toURL().openStream()); Graphics2D graphics2D = image.createGraphics(); // When we flip the orientation of our arrow, we also flip the image that the arrow contains. // Flip the image the other way to cancel this out before getting the shape to display it. AffineTransform at = new AffineTransform(); at.concatenate(AffineTransform.getScaleInstance(1, -1)); at.concatenate(AffineTransform.getTranslateInstance(0, -image.getHeight())); graphics2D.transform(at); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); filledInArrowImg.getImageData().setImage(image); builder.insertNode(filledInArrowImg); doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
public double getWeight() / public void setWeight(double value)
The default value is 0.75.
Example:
Shows how change stroke properties.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a new shape of type Rectangle Shape rectangle = new Shape(doc, ShapeType.RECTANGLE); // Change stroke properties Stroke stroke = rectangle.getStroke(); stroke.setOn(true); stroke.setWeight(5.0); stroke.setColor(Color.RED); stroke.setDashStyle(DashStyle.SHORT_DASH_DOT_DOT); stroke.setJoinStyle(JoinStyle.MITER); stroke.setEndCap(EndCap.SQUARE); stroke.setLineStyle(ShapeLineStyle.TRIPLE); // Insert shape object builder.insertNode(rectangle);