How to draw a polygon

Obtain a polygon primitive (with the configured default style).
OpenMap4u om4u = new OpenMap4u();
...
SetAreaOfInterestOrDrawOrWriteable myCanvas =  om4u.getCanvas(4, 1);
...
Polygon myPolygon = om4u.get(Polygon.class);
Set the polygon to draw
myPolygon.text("Hello world");
Set the position where to draw
myPolygon.lineTo(0.25, 0.125).lineTo(2.0,0.75).lineTo(3.75,0.25).lineTo(0.25,0.125).fill(Color.LIGHT_GRAY);
And last but not least draw it
myCanvas.draw(myPolygon);
Write the result
canvas.write("myPolygon.png");
Which results in the following output.
the result
But wait you can do it much faster and simpler with the fluent builder pattern
myCanvas.draw(
  om4u.get(Polygon.class).lineTo(0.25, 0.125).lineTo(2.0,0.75).lineTo(3.75,0.25).lineTo(0.25,0.125).fill(Color.LIGHT_GRAY)
).write("myPolygon.png");