Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where's Polygon.Double in Java?

Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double or Polygon.Float classes whereas there is Rectangle2D.Float and Rectangle2D.Double class.

Does anyone know why this is? I just need to draw a triangle using doubles as points.

like image 619
openidsucks Avatar asked Mar 04 '10 07:03

openidsucks


People also ask

How does Java define a polygon object?

Internally, a polygon comprises of a list of (x,y) coordinate pairs, where each pair defines a vertex of the polygon, and two successive pairs are the endpoints of a line that is a side of the polygon. The first and final pairs of (x,y) points are joined by a line segment that closes the polygon.

How do you fill a polygon in Java?

To draw or fill a Polygon Use the Graphics methods g. drawPolygon(p) or g. fillPolygon(p) to draw or fill a polygon, where p is the polygon.


1 Answers

You can use a Path2D (or a Path2D.Float or Path2D.Double) to get the same effect.

like image 115
Joachim Sauer Avatar answered Oct 02 '22 14:10

Joachim Sauer