I created a draw method in order to draw a regular hexagon using the fillPolygon and strokePolygon methods in java.Currently I am stuck trying to figure out how to get the six x and y coordinates needed to draw the regular polygon. Would anyone be able to help me? Here is the structure of fill polygon:
Public void fillPolygon(double[] xPoints,
double[] yPoints,
int nPoints)
Fills a polygon with the given points using the currently set fill paint. A null value for any of the arrays will be ignored and nothing will be drawn. This method will be affected by any of the global common, fill, or Fill Rule attributes as specified in the Rendering Attributes Table.
Parameters: xPoints - array containing the x coordinates of the polygon's points or null. yPoints - array containing the y coordinates of the polygon's points or null. nPoints - the number of points that make the polygon.
I wrote you a class to do what you need:
Result for hexagon of radius 1.0:
You can either put this code in your code and call it every time you need coordinates, or you can just hard-code the above coordinates for a Unit Hexagon into your code and then scale all of the coordinates by whatever radius you want your hexagon to have.
If you want to do the latter, you wouldn't really even need this code. I found this cool Polygon Vertex Calculator online that will give you the coordinates for any 'agon.
If you do want to use this code directly, you can get the two separated arrays of vertexes like this: