![]() G.setStroke ( new BasicStroke ( 20.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL ) ) G.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ) Void draw ( Graphics2D g, int width, int height ) SwingUtilities.invokeLater ( new Runnable () You probably don't want to use bevel for the arrow head, as bevels are a flat instead use the mitre option: import java.awt.* Nicer looking nicer arrows have curved sides and are filled. ![]() To draw a simple arrow, draw a line for the stalk as you're doing, then a polyline for the vee. ( or rather the image or OS window holds the pixels ). It has no bearing if you are drawing a line which happens to be drawn near some other pixels which are of a certain colour - once you've drawn the rectangle, the Graphics object doesn't know about the rectangle, it (in effect) only holds the pixels. The bevel is drawn between segments in a polyline if they are at certain angles. The line I am drawing meets the border of a rectangle but no directed arrow is drawn. It is applied when two line segments meet. BasicStroke.Join_BEVEL is used to draw a directed arrow. ![]() I want to draw a directed arrow line through Java.Īt present, I am using class to draw a line g2.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)) // g2 is an instance of Graphics2Dīut only the line appears and no directed arrow appears.
0 Comments
Leave a Reply. |