What I am looking to do is to draw an incomplete polygon using Java. I have figured out how to draw only the polygon in one shot, or even fill the polygon. I can also draw the incomplete polygon by using line segments but the problem with this is the BasicStroke.JOIN_BEVEL
does not apply to line segments. Here is how I do it with the line segments:
//polygon is not Java's Polygon, my own implementation, and the methods do as
//they imply
for(int i = 0; i < polygon.getNumberOfPoints(); i++){
Point2D.Double first = polygon.getPoint(i);
Point2D.Double second = new Point2D.Double();
if(polygon.getPoint(i+1) != null){
second = polygon.getPoint(i+1);
trans1 = /* some graphic translation of first */
trans2 = /* some graphic translation of second */
g.setColor(polygon.getColor());
g.setStroke(new BasicStroke(polygon.getWeight(), BasicStroke.JOIN_BEVEL, BasicStroke.CAP_BUTT));
g.draw(new Line2D.Double(trans1[0], trans1[1], trans2[0], trans2[1]));
}
}
this works just fine, but it does not work exactly how I would like it to. The g.setStroke(/*stuff here*/);
has no effect on the joints.