Java calls the setstroke () method to set the syntax of the stroke attribute
By default, the stroke attribute used by the graphics drawing class is a square with a thickness of 1 pixel, while the graphics2d class of Java2D can call the setstroke() method to set the stroke attribute, such as changing the thickness and virtual reality of the line, and defining the shape and style of the end point of the line segment. The syntax is as follows:
The parameter stroke is the implementation class of the stroke interface. The setstroke () method must accept an implementation class of the stroke interface as a parameter, Java The AWT package provides the basicstroke class, which implements the stroke interface and creates objects with different stroke attributes through different construction methods. These construction methods include:
The parameters in these construction methods are described as follows: width: stroke width, which must be greater than or equal to 0.0F. If the width is set to 0.0F, the stroke is set to the default width of the current device. Cap: decorative join at the end of the line: decorative miterlimit applied at the intersection of path segments: clipping limit at the miter. The parameter value must be greater than or equal to 1.0F Dash: array representing dashed line mode dash phase: offset from starting dashed line mode
Note: cap can be used for cap parameter_ BUTT、CAP_ Round and cap_ Square constant. The join parameter is used to decorate the intersection effect of line segments. You can use join_ BEVEL 、JOIN_ Miter and join_ Round constant.
The above is the whole content of this article. Thank you for your support to this site.