com.aspose.words

Class DashStyle

  • java.lang.Object
    • com.aspose.words.DashStyle
public class DashStyle 
extends java.lang.Object

Utility class containing constants. Dashed line style.

Example:

Shows to create a variety of shapes
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Draw a dotted horizontal red line with an arrow on the left end and a diamond on the other
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().setDashStyle(DashStyle.DASH);

Assert.assertEquals(arrow.getStroke().getJoinStyle(), JoinStyle.MITER);

builder.insertNode(arrow);

// Draw a 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);

// Draw an 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);

// Draw an arrow filled in with the Aspose logo and flip its orientation
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 flipped the orientation of our arrow, the image content was flipped too
// If we want it to be displayed the right side up, we have to reverse the arrow flip on the image
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);

filledInArrowImg.getStroke().setJoinStyle(JoinStyle.ROUND);

doc.save(getArtifactsDir() + "Drawing.VariousShapes.docx");
See Also:
Stroke.DashStyle

Field Summary
static final intSOLID = 0
Solid (continuous) pen.
static final intSHORT_DASH = 1
System dash style.
static final intSHORT_DOT = 2
System dash style.
static final intSHORT_DASH_DOT = 3
System dash style.
static final intSHORT_DASH_DOT_DOT = 4
System dash style.
static final intDOT = 5
Square dot style.
static final intDASH = 6
Dash style.
static final intLONG_DASH = 7
Long dash style.
static final intDASH_DOT = 8
Dash short dash.
static final intLONG_DASH_DOT = 9
Long dash short dash.
static final intLONG_DASH_DOT_DOT = 10
Long dash short dash short dash.
static final intDEFAULT = 0
Same as SOLID.
 

    • Field Detail

      • SOLID = 0

        public static final int SOLID
        Solid (continuous) pen.
      • SHORT_DASH = 1

        public static final int SHORT_DASH
        System dash style.
      • SHORT_DOT = 2

        public static final int SHORT_DOT
        System dash style.
      • SHORT_DASH_DOT = 3

        public static final int SHORT_DASH_DOT
        System dash style.
      • SHORT_DASH_DOT_DOT = 4

        public static final int SHORT_DASH_DOT_DOT
        System dash style.
      • DOT = 5

        public static final int DOT
        Square dot style.
      • DASH = 6

        public static final int DASH
        Dash style.
      • LONG_DASH = 7

        public static final int LONG_DASH
        Long dash style.
      • DASH_DOT = 8

        public static final int DASH_DOT
        Dash short dash.
      • LONG_DASH_DOT = 9

        public static final int LONG_DASH_DOT
        Long dash short dash.
      • LONG_DASH_DOT_DOT = 10

        public static final int LONG_DASH_DOT_DOT
        Long dash short dash short dash.
      • DEFAULT = 0

        public static final int DEFAULT
        Same as SOLID.