In this section, you will see different types of strokes.
To give the the impressive and stylistic outline, class BasicStroke is used. The value passed in the constructor of the class BasicStroke shows the thickness of outline. The class GlyphVector provides the collection of glyphs. A glyph is a shape of a character. The method createGlyphVector() creates a glyphVector by mapping characters to glyphs. The method getOutline() of class GlyphVector returns a shape.
We have defined three types of strokes. The first one is the predefined stroke, Stroke1 strokes twice, Stroke2 shows the vertices and control points. The shape, we are taken is 'HELLO'.
The stroke1 uses the class BasicStroke twice. Here we are outlining the outline of the shape. The stroke2 strokes the shape using a thin line and displays the end points and control points.
The method createStrokesShape() returns the stroked outline of a specified shape. The class PathIterator retrieves the path and provides some fields. The SEG_CLOSE, closed the path by appending a line segment. The SEG_CUBICTO specifies a cubic parametric curve. The SEG_LINETO specifies the end point of a line. The SEG_MOVETO specifies the starting location for a new path. The SEG_QUADTO specify a quadratic parametric curve.
Here is the code of ShowDifferentStrokes.java
Output will be displayed as:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial