-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolbar.java
More file actions
executable file
·191 lines (179 loc) · 5.88 KB
/
toolbar.java
File metadata and controls
executable file
·191 lines (179 loc) · 5.88 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* toolbar.java
* Horizontal curve design toolbar.
*
* Created on March 16, 2006, 8:25 PM
*/
/**
* @author Chen-Fu Liao
* Sr. Systems Engineer
* ITS Institute, ITS Laboratory
* Center For Transportation Studies
* University of Minnesota
* 200 Transportation and Safety Building
* 511 Washington Ave. SE
* Minneapolis, MN 55455
*/
import java.awt.*;
import java.applet.*;
import java.net.URL;
import java.io.*;
//import javax.swing.*;
public class toolbar extends Panel
{
private static Font dialogFontB12 = new Font("Dialog", Font.BOLD | Font.PLAIN, 12) ;
private final int NUM_ICONS = 9 ;
public int status = -1;
intscDrawArea parent;
// JToolTip myToolTip = new JToolTip();
// class construction
toolbar()
{
setBackground(Color.lightGray);
}
public void paint(Graphics g)
{
Rectangle r = bounds();
for(int i=0;i<NUM_ICONS;i++)
{
if(i==status)
{
g.setColor(new Color(192,192,192));
g.fillRect(i*33, 0,32,32);
}
//g.setColor(Color.black);
//g.drawLine(i*33+32, 0,i*33+32, 32);
URL url = null;
switch (i) {
case 0:
//url = getClass().getResource("Arrow.png");
url = getImageResource("volume");
break ;
case 1:
//url = getClass().getResource("ZoomIn.png");
url = getImageResource("actuation"); // actuation
break ;
case 2:
//url = getClass().getResource("ZoomIn.png");
url = getImageResource("controller"); // controller settings
break ;
case 3:
//url = getClass().getResource("ZoomOut.png");
url = getImageResource("simstart");
break ;
case 4:
//url = getClass().getResource("Move.png");
url = getImageResource("simstep");
break ;
case 5:
//url = getClass().getResource("Move.png");
url = getImageResource("simpause");
break ;
case 6:
//url = getClass().getResource("Move.png");
url = getImageResource("simstop");
break ;
case 7:
//url = getClass().getResource("Move.png");
url = getImageResource("simstepback");
break ;
case 8:
//url = getClass().getResource("Move.png");
url = getImageResource("help");
break ;
}
Image img = Toolkit.getDefaultToolkit().getImage(url);
g.drawImage(img, i*33,0,this) ;
if (i!=status) {
// button boundary depressed
g.setColor(Color.white);
g.drawLine(i*33+1, 1,(i+1)*33-2, 1);
g.drawLine(i*33+1, 1,i*33+1, 30);
g.setColor(Color.black);
g.drawLine(i*33+2, 30,(i+1)*33-2, 30);
g.drawLine((i+1)*33-2, 2,(i+1)*33-2, 30);
} else {
// button pressed
// button boundary pressed
g.setColor(Color.black);
g.drawLine(i*33+1, 1,(i+1)*33-2, 1);
g.drawLine(i*33+1, 1,i*33+1, 30);
g.setColor(Color.white);
g.drawLine(i*33+2, 30,(i+1)*33-2, 30);
g.drawLine((i+1)*33-2, 2,(i+1)*33-2, 30);
}
} // i
g.setColor(new Color(126,20,1));
g.setFont(dialogFontB12) ;
g.drawString("MTO, CE, ITS Institute, TEL, University of Minnesota", 350, 20) ;
} // paint
public URL getImageResource(String img) {
URL url = null;
//try {
url = getClass().getResource(img+".png");
if (url==null) {
url = getClass().getResource(img+".PNG");
}
//} catch (IOException ioe) {
// System.out.println(url.toString());
//}
return url ;
} //getImageResource
public Dimension preferredSize()
{
return(new Dimension(32,32));
}
public boolean mouseDown(Event e, int x, int y)
{
if(x<NUM_ICONS*33)
{
int oldstatus = status;
status = x/33;
if(status<0) status = 0;
if(status>9) status = 9;
//if(oldstatus!=status)
//{
String str = "" ;
switch (status) {
case 0:
parent.SetVol_flag = true ;
//myToolTip.setToolTipText("Pointer tool");
break ;
case 1:
parent.SetActuationType_flag = true ;
break ;
case 2:
parent.SetTiming_flag = true ;
break ;
case 3:
str = " Start Simulation" ;
parent.newstatus(status, str);
break ;
case 4:
str = " Step Simulation" ;
parent.newstatus(status, str);
break ;
case 5:
str = " Pause Simulation" ;
parent.newstatus(status, str);
break ;
case 6:
str = " Terminate Simulation" ;
parent.newstatus(status, str);
break ;
case 7:
str = " Step Back Simulation" ;
parent.newstatus(status, str);
break ;
case 8:
str = " Help" ;
parent.newstatus(status, str);
break ;
} // switch
//parent.newstatus(status, str);
repaint();
//}
}
return(true);
} //mouseDown
}