-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoolbarV.java
More file actions
executable file
·190 lines (178 loc) · 5.8 KB
/
toolbarV.java
File metadata and controls
executable file
·190 lines (178 loc) · 5.8 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
/*
* toolbarV.java
* Vertical curve design toolbar
*
* Created on March 23, 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;
public class toolbarV extends Panel
{
final int NUM_ICONS=9; // Number of tool items
final int imgSize=40; // default image size
int status = -1;
vDrawArea parent;
boolean constructEnabled = true; // vertical curve construction flag
Image img[] = new Image[NUM_ICONS] ;
// class construction
toolbarV()
{
setBackground(Color.lightGray);
for (int i=0; i<NUM_ICONS; i++) {
URL url = null;
switch (i) {
case 0:
if (constructEnabled) {
url = getImageResource("construction");
} else {
url = getImageResource("constructdisabled");
}
break ;
case 1:
url = getImageResource("constructoff");
break ;
case 2:
url = getImageResource("calcPVI");
break ;
case 3:
url = getImageResource("modCurve");
break ;
case 4:
url = getImageResource("elevation");
break ;
case 5:
url = getImageResource("fillncut");
break ;
case 6:
url = getImageResource("massdiagram");
break ;
case 7:
url = getImageResource("report");
break ;
case 8:
url = getImageResource("animation");
break ;
}
img[i] = Toolkit.getDefaultToolkit().getImage(url);
}
}
public void paint(Graphics g)
{
Rectangle r = bounds();
int i ;
for(i=0;i<NUM_ICONS;i++)
{
if(i==status)
{
g.setColor(new Color(192,192,192));
g.fillRect(i*(imgSize+1), 0,imgSize,imgSize);
}
g.setColor(Color.black);
g.drawLine(i*(imgSize+1)+imgSize, 0,i*(imgSize+1)+imgSize, imgSize);
g.drawImage(img[i], i*(imgSize+1)+4,4,this) ;
if (i!=status) {
// button boundary depressed
g.setColor(Color.white);
g.drawLine(i*(imgSize+1)+3, 3,(i+1)*(imgSize+1)-4, 3);
g.drawLine(i*(imgSize+1)+3, 3,i*(imgSize+1)+3, (imgSize-4));
g.setColor(Color.black);
g.drawLine(i*(imgSize+1)+3, (imgSize-4),(i+1)*(imgSize+1)-4, (imgSize-4));
g.drawLine((i+1)*(imgSize+1)-4, 3,(i+1)*(imgSize+1)-4, (imgSize-4));
} else {
// button pressed
// button boundary depressed
g.setColor(Color.black);
g.drawLine(i*(imgSize+1)+3, 3,(i+1)*(imgSize+1)-4, 3);
g.drawLine(i*(imgSize+1)+3, 3,i*(imgSize+1)+3, (imgSize-4));
g.setColor(Color.white);
g.drawLine(i*(imgSize+1)+3, (imgSize-4),(i+1)*(imgSize+1)-4, (imgSize-4));
g.drawLine((i+1)*(imgSize+1)-4, 3,(i+1)*(imgSize+1)-4, (imgSize-4));
}
} // i
g.setColor(Color.black);
g.drawString("ITS Institute, University of Minnesota", i*(imgSize+1)+20, 25) ;
}
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 ;
}
public Dimension preferredSize()
{
return(new Dimension(imgSize,imgSize));
}
public void setConstructEnabled(boolean state) {
constructEnabled = state ;
repaint();
}
public boolean mouseDown(Event e, int x, int y)
{
if(x<NUM_ICONS*(imgSize+1))
{
int oldstatus = status;
status = x/(imgSize+1);
if(status<0) status = 0;
if(status>NUM_ICONS) status = NUM_ICONS;
//if(oldstatus!=status)
//{
String str = "" ;
switch (status) {
case 0:
str = " Grade Construction ON" ;
break ;
case 1:
str = " Grade Construction OFF" ;
break ;
case 2:
str = " Generate Vertical Curves" ;
break ;
case 3:
str = " Modify Curve Length" ;
break ;
case 4:
str = " View Elevation Profile" ;
break ;
case 5:
str = " View Fill/Cut Profile" ;
break ;
case 6:
str = " View Mass Diagram" ;
break ;
case 7:
str = ""; //" Generate Report" ; defined in runThread0, vDrawArea
break ;
case 8:
str = " Create 3D Animation Model" ;
break ;
} // switch
if (status==3) {
parent.setCurvelenEdit_flag = true ;
} else if (status==7) {
parent.setReport_flag = true ;
} else {
parent.newstatus(status, str);
}
repaint();
//}
}
return(true);
}
}