-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
74 lines (69 loc) · 1.55 KB
/
Node.java
File metadata and controls
74 lines (69 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
public class Node extends JButton implements ActionListener
{
Node parent;
int col;
int row;
int gCost;
int hCost;
int fCost;
boolean start;
boolean goal;
boolean solid;
boolean open;
boolean checked;
public Node(int col, int row)
{
this.col=col;
this.row=row;
setBackground(Color.white);
setForeground(Color.black);
addActionListener(this);
}
public void setAsStart()
{
setBackground(Color.blue);
setForeground(Color.white);
setText("Start");
start=true;
}
public void setAsGoal()
{
setBackground(Color.yellow);
setForeground(Color.black);
setText("Goal");
goal=true;
}
public void setAsSolid()
{
setBackground(Color.black);
setForeground(Color.black);
solid=true;
}
public void setAsOpen()
{
open=true;
}
public void setAsChecked()
{
if(start==false && goal==false)
{
setBackground(Color.orange);
setForeground(Color.black);
}
checked=true;
}
public void setAsPath()
{
setBackground(Color.green);
setForeground(Color.black);
}
@Override
public void actionPerformed(ActionEvent e)
{
setBackground(Color.orange);
}
}