-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkPanel.java
More file actions
executable file
·150 lines (131 loc) · 4.18 KB
/
LinkPanel.java
File metadata and controls
executable file
·150 lines (131 loc) · 4.18 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
/*
* LinkPanel.java
* Display panel for an intersection link
* Created on June 6, 2006, 11:35 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.awt.event.* ; // doesn//t automatically load with java.awt.*
public class LinkPanel extends Panel
{
public LinkPanel approach ;
int panelWidth=200 ; // default panel size
int panelHeight=150 ;
Label title = new Label();
Checkbox exclLeft = new Checkbox("Exclusive Left Turn");
TextField speed = new TextField("35") ;
public TextField volume = new TextField("450") ;
Choice laneSize = new Choice() ;
Checkbox mainStreet = new Checkbox("Main") ; // 3/14/07 added
LinkPanel(String _titleStr, String _iconStr)
{
title.setText(_titleStr) ;
setBackground(new Color(121,217,157));
setLayout(new BorderLayout(3,1));
title.setForeground(Color.black) ;
title.setAlignment(title.CENTER) ;
title.setFont(Font.getFont("TimesRoman-BOLD-15")) ;
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(0,0,0,0) ;
c.gridx = 0;
c.gridy = 0;
add(title, c);
c.gridy = 1;
add(new Label("Speed (mph)"), c);
c.gridy = 2;
add(new Label("Volume (vph)"), c);
c.gridy = 3;
add(new Label("# of Lanes"), c);
c.gridx = 1;
c.gridy = 0;
add(new iconPanel(_iconStr), c);
c.gridy = 1;
add(speed, c);
c.gridy = 2;
add(volume, c);
c.gridy = 3;
add(laneSize, c);
laneSize.add("2") ;
laneSize.add("4") ;
laneSize.add("6") ;
c.gridx = 0;
c.gridy = 4;
c.gridwidth = 2 ;
add(exclLeft, c);
//c.gridy = 5; ;
//add(mainStreet, c);
// temperary set
laneSize.select(1) ; // 3/7/07, 4 lanes
exclLeft.setState(true) ; // 3/7/07
laneSize.setEnabled(false) ; // not allow for changes
exclLeft.setEnabled(false) ; // disabled
// lane sixe
ItemListener laneSize_listener = new ItemListener() {
public void itemStateChanged(ItemEvent ie) {
int index = laneSize.getSelectedIndex();
approach.setLaneSize(index) ;
}
} ;
laneSize.addItemListener(laneSize_listener) ;
// main street
ItemListener mainSt_listener = new ItemListener() {
public void itemStateChanged(ItemEvent ie) {
approach.setMainStreet(mainStreet.getState()) ;
}
} ;
mainStreet.addItemListener(mainSt_listener) ;
}
public void setMainStreet(boolean state) {
mainStreet.setState(state) ;
}
public void setLaneSize(int _laneSize)
{
laneSize.select(_laneSize) ;
}
public float getSpeed()
{
// return entered speed
float _spd = new Float(speed.getText()).floatValue() ;
//System.out.println("speed="+_spd) ;
return _spd ;
}
public float getVolume()
{
// return entered volume
float _vol = 0f ;
_vol = new Float(volume.getText()).floatValue() ;
return _vol ;
}
public boolean hasExclusiveLeftTurn()
{
// return checked uxclusive left turn setting
return exclLeft.getState() ;
}
public int getLaneSize()
{
int data = new Integer(laneSize.getSelectedItem()).intValue() ;
return data ;
}
public void paint(Graphics g)
{
}
public Dimension preferredSize()
{
return(new Dimension(panelWidth,panelHeight));
}
public boolean mouseDown(Event e,int x,int y)
{
return(true);
}
}