-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoolbar.java
More file actions
executable file
·206 lines (194 loc) · 6.25 KB
/
toolbar.java
File metadata and controls
executable file
·206 lines (194 loc) · 6.25 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* 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
{
int status = -1; //. toolbar selecction
hDrawArea parent;
final int NUM_ICONS = 11 ;
Image img[] = new Image[NUM_ICONS] ;
// JToolTip myToolTip = new JToolTip();
// class construction
toolbar()
{
setBackground(Color.lightGray);
for (int i=0; i<NUM_ICONS; i++) {
URL url = null;
switch (i) {
case 0:
//url = getClass().getResource("Arrow.png");
url = getImageResource("Arrow");
break ;
case 1:
//url = getClass().getResource("ZoomIn.png");
url = getImageResource("ZoomIn");
break ;
case 2:
//url = getClass().getResource("ZoomOut.png");
url = getImageResource("ZoomOut");
break ;
case 3:
//url = getClass().getResource("Move.png");
url = getImageResource("Move");
break ;
case 4:
//url = getClass().getResource("Line.png");
url = getImageResource("Line");
break ;
case 5:
//url = getClass().getResource("Curve.png");
url = getImageResource("Curve");
break ;
case 6:
//url = getClass().getResource("modify.png");
url = getImageResource("modify");
break ;
case 7:
//url = getClass().getResource("markerH.png");
url = getImageResource("hAlign1");
break ;
case 8:
//url = getClass().getResource("markerH.png");
url = getImageResource("markerH");
break ;
case 9:
//url = getClass().getResource("Refresh1.png");
//url = getImageResource("Refresh1");
url = getImageResource("markerInsert");
break ;
case 10:
//url = getClass().getResource("vertical_align1.png");
url = getImageResource("vertical_align1");
break ;
}
img[i] = Toolkit.getDefaultToolkit().getImage(url);
}
}
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);
g.drawImage(img[i], i*33+4,4,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 depressed
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(Color.black);
g.drawString("MTO/CE/ITS Institute, University of Minnesota", 383, 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>NUM_ICONS) status = NUM_ICONS;
//if(oldstatus!=status)
//{
String str = "" ;
switch (status) {
case 0:
str = " Select Segment" ;
//myToolTip.setToolTipText("Pointer tool");
break ;
case 1:
str = " Zoom In" ;
break ;
case 2:
str = " Zoom Out" ;
break ;
case 3:
str = " Move" ;
break ;
case 4:
str = " Line Tool" ;
break ;
case 5:
str = " Curve Tool" ;
break ;
case 6:
str = " Modify End Point" ;
break ;
case 7:
str = " Align Horizontal Curve" ;
break ;
case 8:
str = " Set Station/Landmark" ;
break ;
case 9:
//str = " Refresh" ;
str = " Insert Station/Landmark" ;
break ;
case 10:
str = " Vertical Alignment" ;
break ;
} // switch
if (status==10) {
parent.setValign_flag = true ;
} else {
parent.newstatus(status, str);
}
repaint();
//}
}
return(true);
} //mouseDown
}