11public class Node {
2- public int i, j, radius ;
2+ public int i, j;
33 private color nodeColor;
44 public boolean isBlocked;
55
@@ -8,6 +8,9 @@ public class Node{
88 public boolean vizited = false ;
99 public Node parent = null ;
1010
11+ // ANIMATION
12+ public int nodeSize = scale - 2 , radius = 9 ;
13+
1114 // NDOE CONSTRUCTOR
1215 Node (int i , int j ){
1316 this . i = i;
@@ -19,10 +22,14 @@ public class Node{
1922
2023 // DRAW FUNCTION WHICH IS CALLED AUTOMATICALLY
2124 void draw (){
22- if (radius > 0 ){
25+ if (radius > 0 && nodeSize == scale - 2 ){
2326 radius-- ;
2427 }
2528
29+ if (this . nodeSize < scale - 2 ){
30+ this . nodeSize++ ;
31+ }
32+
2633 if ( isOverNode() ){
2734 if (MousePress && ! isBlocked && ! searchStarted){
2835 if (endNodeMove){
@@ -52,9 +59,10 @@ public class Node{
5259 // IF THE SELECTED CELL IS NOT START OR END NODE THEN
5360 // MAKE IT BLOCKED
5461 else if (this != startNode && this != endNode){
55- this . resetNode();
62+ resetNode();
5663 nodeColor = color (25 );
5764 isBlocked = true ;
65+ animate();
5866 }
5967 // ELSE WE KNOW THAT THE SELECTED NODE IS START OR END NODE
6068 // AND WE MOVE IT
@@ -72,12 +80,15 @@ public class Node{
7280 // DRAWING A NODE
7381 noStroke ();
7482 fill (nodeColor);
75- rect (j * scale + 2 , i * scale + 2 , scale - 2 , scale - 2 , radius);
83+ rect (j * scale + scale / 2 , i * scale + scale / 2 , this . nodeSize, this . nodeSize, this . radius);
7684 }
7785
7886 // CHANGE THE CELL COLOR WHEN NEEDED
7987 public void nodeColor (color col ){
8088 nodeColor = col;
89+ if (explicitMode && this != startNode && this != endNode){
90+ animate();
91+ }
8192 }
8293
8394 public void resetNode (){
@@ -97,6 +108,11 @@ public class Node{
97108 parent = null ;
98109 }
99110
111+ private void animate (){
112+ nodeSize = 2 ;
113+ radius = 9 ;
114+ }
115+
100116 // IF THE MOUSE IS CLICKED AND OVER THE CELL RETURN TRUE
101117 private boolean isOverNode () {
102118 int offsetX = mouseX - this . j * scale;
0 commit comments