Inheritance diagram for Simulation::

Public Methods | |
| void | init () |
| void | destroy () |
| void | start () |
| void | stop () |
| void | actionPerformed (ActionEvent event) |
| void | itemStateChanged (ItemEvent event) |
| String | getAppletInfo () |
Private Attributes | |
| NetworkSpacePanel | network_panel |
| Panel | control_panel |
| Button | traceroute = new Button("Put") |
| TracerouteDialog | traceroute_dialog = null |
| Button | add_line = new Button("Dodaj liniju") |
| AddLineDialog | add_line_dialog = null |
| Button | delete_line = new Button("Obri\u0161i liniju") |
| DeleteLineDialog | delete_line_dialog = null |
| Button | add_node = new Button("Dodaj \u010dvor") |
| AddNodeDialog | add_node_dialog = null |
| Button | delete_node = new Button("Obri\u0161i \u010dvor") |
| DeleteNodeDialog | delete_node_dialog = null |
| Button | start_stop_simulation = new Button("Pokreni") |
| Checkbox | all_packets = new Checkbox("Svi paketi") |
| Checkbox | line_capacities = new Checkbox("Kapaciteti linija") |
Definition at line 27 of file Simulation.java.
|
|
Action events handler. Definition at line 212 of file Simulation.java. 00213 {
00214 Object source = event.getSource();
00215 String command = event.getActionCommand();
00216 int modifier = event.getModifiers();
00217
00218 /* traceroute event */
00219 if (source == traceroute)
00220 {
00221 if (null == traceroute_dialog)
00222 {
00223 traceroute_dialog = new TracerouteDialog(this);
00224 }
00225 }
00226 /* traceroute dialog event */
00227 if (source == traceroute_dialog)
00228 {
00229 if (command.equals("OK"))
00230 {
00231 network_panel.stopSimulation();
00232 network_panel.tracePackets(traceroute_dialog.left_name,
00233 traceroute_dialog.right_name
00234 );
00235 String name = start_stop_simulation.getLabel();
00236 if (name.equals("Zaustavi"))
00237 {
00238 network_panel.startSimulation();
00239 }
00240 }
00241 traceroute_dialog = null;
00242 }
00243 /* add_line event */
00244 if (source == add_line)
00245 {
00246 if (null == add_line_dialog)
00247 {
00248 add_line_dialog = new AddLineDialog(this);
00249 }
00250 }
00251 /* add_line_dialog event */
00252 if (source == add_line_dialog)
00253 {
00254 if (command.equals("OK"))
00255 {
00256 network_panel.stopSimulation();
00257 Node first = network_panel.addNode(add_line_dialog.left_name);
00258 Node second = network_panel.addNode(add_line_dialog.right_name);
00259 network_panel.addLine(first, second, add_line_dialog.capacity);
00260 String name = start_stop_simulation.getLabel();
00261 if (name.equals("Zaustavi"))
00262 {
00263 network_panel.startSimulation();
00264 }
00265 }
00266 add_line_dialog = null;
00267 }
00268 /* add_node event */
00269 if (source == add_node)
00270 {
00271 if (null == add_node_dialog)
00272 {
00273 add_node_dialog = new AddNodeDialog(this);
00274 }
00275 }
00276 /* add_node_dialog event */
00277 if (source == add_node_dialog)
00278 {
00279 if (command.equals("OK"))
00280 {
00281 network_panel.stopSimulation();
00282 Node new_node = network_panel.addNode(add_node_dialog.node_name);
00283 String name = start_stop_simulation.getLabel();
00284 if (name.equals("Zaustavi"))
00285 {
00286 network_panel.startSimulation();
00287 }
00288 }
00289 add_node_dialog = null;
00290 }
00291 /* delete_line event */
00292 if (source == delete_line)
00293 {
00294 if (null == delete_line_dialog)
00295 {
00296 delete_line_dialog = new DeleteLineDialog(this);
00297 }
00298 }
00299 /* delete_line_dialog event */
00300 if (source == delete_line_dialog)
00301 {
00302 if (command.equals("OK"))
00303 {
00304 network_panel.stopSimulation();
00305 Line deleted = network_panel.deleteLine(delete_line_dialog.left_name,
00306 delete_line_dialog.right_name
00307 );
00308 String name = start_stop_simulation.getLabel();
00309 if (name.equals("Zaustavi"))
00310 {
00311 network_panel.startSimulation();
00312 }
00313 }
00314 delete_line_dialog = null;
00315 }
00316 /* delete_node event */
00317 if (source == delete_node)
00318 {
00319 if (null == delete_node_dialog)
00320 {
00321 delete_node_dialog = new DeleteNodeDialog(this);
00322 }
00323 }
00324 /* delete_node_dialog event */
00325 if (source == delete_node_dialog)
00326 {
00327 if (command.equals("OK"))
00328 {
00329 network_panel.stopSimulation();
00330 Node deleted = network_panel.deleteNode(delete_node_dialog.node_name);
00331 String name = start_stop_simulation.getLabel();
00332 if (name.equals("Zaustavi"))
00333 {
00334 network_panel.startSimulation();
00335 }
00336 }
00337 delete_node_dialog = null;
00338 }
00339 /* start_stop_simulation event */
00340 if (source == start_stop_simulation)
00341 {
00342 String name = start_stop_simulation.getLabel();
00343 if (name.equals("Pokreni"))
00344 {
00345 start_stop_simulation.setLabel("Zaustavi");
00346 network_panel.startSimulation();
00347 }
00348 else
00349 {
00350 start_stop_simulation.setLabel("Pokreni");
00351 network_panel.stopSimulation();
00352 }
00353 }
00354 }
|
|
|
Applet destroy method. Simulation is stopped. Definition at line 183 of file Simulation.java. 00184 {
00185 network_panel.endSimulation();
00186 remove(network_panel);
00187 remove(control_panel);
00188 }
|
|
|
Gets applet information. Definition at line 381 of file Simulation.java. 00382 {
00383 return "Cyclops simulator\nFER/SPVP 2001\nD. Vasić, T. Petković, Z. Kostanjčar";
00384 }
|
|
|
Applet initialization. Creates controls and initializes network from parameters. Definition at line 86 of file Simulation.java. 00087 {
00088 setLayout(new BorderLayout());
00089 network_panel = new NetworkSpacePanel(this);
00090 control_panel = new Panel();
00091 network_panel.setName("Network space interface");
00092 add("Center", network_panel);
00093 add("South", control_panel);
00094
00095 control_panel.add(traceroute);
00096 control_panel.add(add_node);
00097 control_panel.add(delete_node);
00098 control_panel.add(add_line);
00099 control_panel.add(delete_line);
00100 control_panel.add(start_stop_simulation);
00101 control_panel.add(all_packets);
00102 control_panel.add(line_capacities);
00103
00104 traceroute.addActionListener(this);
00105 add_node.addActionListener(this);
00106 delete_node.addActionListener(this);
00107 add_line.addActionListener(this);
00108 delete_line.addActionListener(this);
00109 start_stop_simulation.addActionListener(this);
00110 all_packets.addItemListener(this);
00111 line_capacities.addItemListener(this);
00112
00113 /* Parse input parameters. */
00114 Node first;
00115 Node second;
00116 int i;
00117 int j;
00118 int capacity;
00119 String network = getParameter("network");
00120 /* Parse input network configuration. */
00121 if (null != network)
00122 {
00123 StringTokenizer tokenizer = new StringTokenizer(network, ",");
00124 while (tokenizer.hasMoreTokens())
00125 {
00126 String connection = tokenizer.nextToken();
00127 i = connection.indexOf('-');
00128 if (0 < i)
00129 {
00130 capacity = 10;
00131 j = connection.indexOf('/');
00132 if (0 < j)
00133 {
00134 capacity = Integer.valueOf(connection.substring(j+1)).intValue();
00135 connection = connection.substring(0,j);
00136 }
00137 /* Add nodes and connections to network. */
00138 first = network_panel.addNode(connection.substring(0, i));
00139 second = network_panel.addNode(connection.substring(i + 1));
00140 network_panel.addLine(first, second, capacity);
00141 }
00142 /* if */
00143 }
00144 /* while */
00145 }
00146 /* if */
00147 String packets = getParameter("dummypackets");
00148 /* Parse dummy packets input. */
00149 if (null != packets)
00150 {
00151 i = packets.indexOf(',');
00152 if (0 < i)
00153 {
00154 int ttl = Integer.valueOf(packets.substring(i+1)).intValue();
00155 int n = Integer.valueOf(packets.substring(0,i)).intValue();
00156 network_panel.addDummyPackets(n, ttl);
00157 }
00158 }
00159 else if (null != network)
00160 {
00161 network_panel.addDummyPackets(40, -1);
00162 }
00163 /* else */
00164 String route = getParameter("route");
00165 /* Parse initial route. */
00166 if (null != route)
00167 {
00168 i = route.indexOf('-');
00169 if (0 < i)
00170 {
00171 network_panel.tracePackets(route.substring(0,i),
00172 route.substring(i+1)
00173 );
00174 }
00175 }
00176 /* if */
00177 }
|
|
|
Item events handler. Definition at line 360 of file Simulation.java. 00361 {
00362 Object source;
00363 boolean on;
00364
00365 source = event.getSource();
00366 on = event.getStateChange() == ItemEvent.SELECTED;
00367 if (source == all_packets)
00368 {
00369 network_panel.all_packets = on;
00370 }
00371 if (source ==line_capacities)
00372 {
00373 network_panel.show_line_capacities = on;
00374 }
00375 }
|
|
|
Start method. Resumes screen updating. Definition at line 194 of file Simulation.java. 00195 {
00196 network_panel.start();
00197 }
|
|
|
Stop method. Stops screen updating. Definition at line 203 of file Simulation.java. 00204 {
00205 network_panel.stop();
00206 }
|
|
|
Add line control. Definition at line 50 of file Simulation.java. |
|
|
Add line dialog. Definition at line 53 of file Simulation.java. |
|
|
Add node control. Definition at line 62 of file Simulation.java. |
|
|
Add node dialog. Definition at line 65 of file Simulation.java. |
|
|
All packets visibilty control. Definition at line 77 of file Simulation.java. |
|
|
Control panel. Definition at line 35 of file Simulation.java. |
|
|
Delete line control. Definition at line 56 of file Simulation.java. |
|
|
Delete line control dialog. Definition at line 59 of file Simulation.java. |
|
|
Delete node control. Definition at line 68 of file Simulation.java. |
|
|
Delete node dialog. Definition at line 71 of file Simulation.java. |
|
|
Line capacity visibility control. Definition at line 80 of file Simulation.java. |
|
|
Panel for network display. Definition at line 32 of file Simulation.java. |
|
|
Start/stop simulation control. Definition at line 74 of file Simulation.java. |
|
|
Traceroute control. Definition at line 44 of file Simulation.java. |
|
|
Traceroute dialog. Definition at line 47 of file Simulation.java. |
1.2.7 written by Dimitri van Heesch,
© 1997-2001