Using a linked list, write the moveToTop method for the class named OverLappedRectangles that models a list of possibly overlapping rectangular two-dimensional window regions, like the windows for the programs open on your computer.
You are to complete the class OverLappedRectangles.java
You are provided classes named WindowsTester.java, RectangleNode.java, Rectangle143.java, Rectangle.java, Point.java, and starter code for OverLappedRectangles.java
WindowsTester contains the method main and instantiates a JFrame to show what is happening with your code. Mouse clicks in the JFrame are sent to your class, to determine which rectangle should be moved to the top. To run a test on your program, all you do is click points in the JFrame. Each time you do so, the GUI is updated according to your code for moveToTop. The class WindowsTester displays the rectangles graphically. It is provided by, so you can guess how reliable it is. It is not at all robust, so occasionally no rectangles will appear at all. If that happens, close the JFrame and re-launch the program until they do appear. RectangleNode is a class that has a Rectangle143 as its data field and a pointer to the next RectangleNode.
OverLappedRectangles uses these nodes to form a linked list of Rectangle143 s.
Rectangle143 is a class derived from Rectangle and extends it by adding a Color field for the GUI display. Your OverLappedRectangles class will have a field consisting of an ArrayList of Rectangle143s. The class named Point is as we have used it before. See page 506 of textbook for description of Point class if you need further documentation.
Your rectangle list class, OverLappedRectangles, will keep a linked list of RectangleNodes to implement the model of possibly overlapping rectangular two-dimensional window regions.
Your rectangle list class will have a method, moveToTop, that takes a Point as a parameter, treats it as though the user clicked that Point on the screen, and moves the topmost rectangle touching that Point to the front of the list, leaving the order of the rest of the list unchanged. If the Point clicked is not on any of the rectangles, nothing is moved. To make your moveToTop method work correctly, you will need to determine which rectangle needs to be moved to the top by examining the coordinates of the Point passed to your method.