I hope someone can help as I am struggling with this part of my task at work.I've deliberately not detailed the context of the work task to try and keep the focus on the problem. I have to merge rectangles into a single polygon as shown in the attached image but need the list of points so that I can write these out into Polygon shape (DOM object) for a Swing Canvas and then SVG export.
I know the Origin of each Rectangle ie. the upper left x and y coordinates (float x, float y) and also the Width (float) and Height (float) of each Rectangle so from this can calculate the coordinates of all four corners of each Rectangle ie. Top, Right, Bottom, Left ie. Top = Origin = x, y, Right = x + width, Bottom = x + width, y + height and Left = x, y + height
I have a List<Rectangle> rectangles and would like an algorithm which will translate this list into a single Polygon (List<Points> where a Point represents the coordinates (x, y) of each point as shown in the diagram marked red "x"s.
I will then use this list of Points to write out an Element in the DOM for printing a Web page eventually in SVG. So my end result has to be a List of Points (i.e x,y coordinates for constructing a Polygon shape in SVG).
I did see this answer which does something similar, but not sure if I can apply this to my case - also its written in Python and not Java.

Areatoaddshapes together. Assuming you're using something likejava.awt.Rectangle, then you can wrap it in aAreaandaddit to anotherAreawhich represents the final state. You might also have a lookjava.awt.Rectangle, as it has a number ofaddmethods as well - MadProgrammer