There must be a display window of size (600, 360) containing a grid with the same number of columns and rows . Your program should work correctly with a different size and/or number of partitions.
You set a constant globally at the VERY TOP, as:
final int N_PARTITIONS = 10;
and use it (N_PARTITIONS) throughout the program. your program should work even if the marker changes the value of N_PARTITIONS to 5 or 8 or 15 or ... (obviously, when N_PARTITIONS changes to 15, there should be 15 rows and 15 columns)
When you click anywhere on the display window, circle of diameter 10 (henceforth called a node) should be displayed at that point. Nodes from previous clicks should stay on the screen and there should be lines that join each node with the next one (and the last is joined to the first node). There should be no other lines besides these lines (and the grid lines of course).
For example, if the sequence of clicks is:
Time x: (200, 400)
Time x + 20: (300, 300)
Time x + 70: (60, 100)
There should be nodes drawn at the three points and lines from (200, 400) to (300, 300); (300, 300) to (60, 100); and (60, 100) to (200, 400).
IMPORTANT: You may assume that the maximum number of nodes is 100.
The most useful material for this part is compound data, in particular, arrays - and loops.
When an arrow key is pressed, all nodes must move up by 1 unit grid cell distance in corresponding direction.
Let's say the display window is of size (700, 500) such that each column is 35 pixels wide and each row is 25 pixels high.
Let's say the two nodes so far are at (240, 65) and (124, 75)
If the UP key is pressed, the two nodes should move to (240, 40) and (124, 50).
If the DOWN key is pressed (instead of UP key), the two nodes should move to (240, 90) and (124, 100).
If the LEFT key is pressed (instead of UP key), the two nodes should move to (205, 65) and (89, 75).
If the RIGHT key is pressed (instead of UP key), the two nodes should move to (275, 65) and (159, 75).
When you click at any location, the node should be generated at the closest grid intersection point.
The most useful material for this part is compound data.
For each node, calculate the sum of distances of that node from every other node.
The node that has the lowest cumulative distance should be coloured red.
The node that has the highest cumulative distance should be coloured blue.
The most useful material for this part is compound data and functions.
You can pick-up a node (using mousePressed), drag it and drop it (using mouseReleased) to another point. The node must be dropped at the grid intersection point closest to the where the mouse is released.
TASK 1
Double-clicking at an already existing node should remove the node.
TASK 2
If none of the lines are intersecting (besides adjacent lines having a common point), the whole shape must be filled with colour code (0, 0, 255, 127) (semi-transparent blue).
TASK 3
Each time you press the ENTER key, a new graph is generated. The old graph should still be displayed on the display window.