Inheritance diagram for NetworkSpacePanel::
Public Methods | |
NetworkSpacePanel (Simulation simulation_applet) | |
Node | addNode (String name) |
Node | deleteNode (String name) |
void | addDummyPackets (int number, int time_to_live) |
void | tracePackets (String start_node, String end_node) |
void | addLine (Node first, Node second, int capacity) |
Line | deleteLine (String first, String second) |
void | run () |
synchronized void | update (Graphics g) |
void | mouseClicked (MouseEvent event) |
void | mousePressed (MouseEvent event) |
void | mouseReleased (MouseEvent event) |
void | mouseEntered (MouseEvent event) |
void | mouseExited (MouseEvent event) |
void | mouseDragged (MouseEvent event) |
void | mouseMoved (MouseEvent event) |
void | start () |
void | stop () |
void | startSimulation () |
void | stopSimulation () |
void | endSimulation () |
Private Attributes | |
CyclopsSimulator | cyclops = new CyclopsSimulator() |
Simulation | simulation_applet |
Node | currently_manipulated |
Thread | simulator |
boolean | all_packets |
boolean | show_line_capacities |
Image | off_screen |
Dimension | off_screen_size |
Graphics | off_graphics |
final Color | node_color = new Color(250, 220, 100) |
final Color | line_color = Color.black |
final Color | left_packet_color = new Color(250, 200, 80) |
final Color | right_packet_color = new Color(250, 240, 120) |
Definition at line 394 of file Simulation.java.
|
Default constructor. Definition at line 420 of file Simulation.java. 00421 { 00422 this.simulation_applet = simulation_applet; 00423 addMouseListener(this); 00424 addMouseMotionListener(this); 00425 cyclops.start(); 00426 cyclops.setName("Cyclops simulator"); 00427 } |
|
Adds dummy packets.
Definition at line 470 of file Simulation.java. Referenced by Simulation::init().
00471 { 00472 cyclops.addDummyPackets(number, time_to_live); 00473 } |
|
Adds line to network. Symmetric line is created.
Definition at line 496 of file Simulation.java. Referenced by Simulation::actionPerformed(), and Simulation::init().
|
|
Adds node to network. Node is identified by its name. If node already exists, method will return reference of existing node, otherwise a new node will be created.
Definition at line 437 of file Simulation.java. Referenced by Simulation::actionPerformed(), and Simulation::init().
|
|
Deletes line from network.
Definition at line 509 of file Simulation.java. Referenced by Simulation::actionPerformed().
00510 { 00511 Line deleted; 00512 deleted = cyclops.deleteLine(first, second); 00513 return deleted; 00514 } |
|
Deletes node from network. Node is identified by its name. If node already exists, method will return reference of existing node. Otherwise null reference will be returned.
Definition at line 457 of file Simulation.java. Referenced by Simulation::actionPerformed().
00458 { 00459 Node removed_node; 00460 removed_node = cyclops.deleteNode(name); 00461 return removed_node; 00462 } |
|
Ends simulation. Definition at line 711 of file Simulation.java. Referenced by Simulation::destroy().
00712 { 00713 cyclops.endSimulation(); 00714 } |
|
Empty event.
Definition at line 582 of file Simulation.java. 00583 { 00584 } |
|
Moves node.
Definition at line 654 of file Simulation.java. 00655 { 00656 currently_manipulated.setCoordinates(event.getX(), event.getY()); 00657 repaint(); 00658 event.consume(); 00659 } |
|
Empty event.
Definition at line 636 of file Simulation.java. 00637 { 00638 } |
|
Empty event.
Definition at line 645 of file Simulation.java. 00646 { 00647 } |
|
Empty event.
Definition at line 666 of file Simulation.java. 00667 { 00668 } |
|
Findes closes node to mouse pointer and selects it.
Definition at line 591 of file Simulation.java. 00592 { 00593 double best_distance = Double.MAX_VALUE; 00594 double distance; 00595 int n = cyclops.numberOfNodes(); 00596 int x = event.getX(); 00597 int y = event.getY(); 00598 Node current_node; 00599 int i; 00600 for (i=0; i!=n; i++) 00601 { 00602 current_node = cyclops.nodeAt(i); 00603 distance = (x - current_node.getXCoordinate()) 00604 * (x - current_node.getXCoordinate()) 00605 + (y - current_node.getYCoordinate()) 00606 * (y - current_node.getYCoordinate()); 00607 if (distance < best_distance) 00608 { 00609 currently_manipulated = current_node; 00610 best_distance = distance; 00611 } 00612 } 00613 currently_manipulated.setCoordinates(x, y); 00614 repaint(); 00615 event.consume(); 00616 } |
|
Releases hold on node and sets new screen coordinates.
Definition at line 623 of file Simulation.java. 00624 { 00625 currently_manipulated.setCoordinates(event.getX(), event.getY()); 00626 currently_manipulated = null; 00627 repaint(); 00628 event.consume(); 00629 } |
|
Run method. Only updates the screen. Definition at line 520 of file Simulation.java. |
|
Starts thread. Definition at line 674 of file Simulation.java. Referenced by Simulation::start().
00675 { 00676 simulator = new Thread(this); 00677 simulator.start(); 00678 } |
|
Starts/resumes simulation. Definition at line 693 of file Simulation.java. Referenced by Simulation::actionPerformed().
00694 { 00695 cyclops.startSimulation(); 00696 } |
|
Stops thread. Definition at line 684 of file Simulation.java. Referenced by Simulation::stop().
00685 { 00686 simulator = null; 00687 } |
|
Stops/suspends simulation. Definition at line 702 of file Simulation.java. Referenced by Simulation::actionPerformed().
00703 { 00704 cyclops.stopSimulation(); 00705 } |
|
Trace packets.
Definition at line 481 of file Simulation.java. Referenced by Simulation::actionPerformed(), and Simulation::init().
00482 { 00483 if (!start_node.equals(end_node)) 00484 { 00485 cyclops.tracePackets(start_node, end_node); 00486 } 00487 } |
|
Updates the screen.
Definition at line 553 of file Simulation.java. 00554 { 00555 Dimension d = getSize(); 00556 if ((null == off_screen) || 00557 (d.width != off_screen_size.width) || 00558 (d.height != off_screen_size.height) 00559 ) 00560 { 00561 off_screen = createImage(d.width, d.height); 00562 off_screen_size = d; 00563 off_graphics = off_screen.getGraphics(); 00564 off_graphics.setFont(getFont()); 00565 } 00566 off_graphics.setColor(getBackground()); 00567 off_graphics.fillRect(0, 0, d.width, d.height); 00568 FontMetrics metrics = off_graphics.getFontMetrics(); 00569 cyclops.paint(off_graphics, metrics, 00570 node_color, line_color, 00571 left_packet_color, right_packet_color, Color.red, 00572 show_line_capacities, all_packets 00573 ); 00574 g.drawImage(off_screen, 0, 0, null); 00575 } |
|
All packets visibility flag. Definition at line 412 of file Simulation.java. |
|
Node object. Definition at line 406 of file Simulation.java. |
|
Simulator thread. Definition at line 400 of file Simulation.java. |
|
Definition at line 546 of file Simulation.java. |
|
Definition at line 545 of file Simulation.java. |
|
Definition at line 544 of file Simulation.java. |
|
Definition at line 542 of file Simulation.java. |
|
Definition at line 540 of file Simulation.java. |
|
Definition at line 541 of file Simulation.java. |
|
Definition at line 547 of file Simulation.java. |
|
Line capacity visibility flag. Definition at line 415 of file Simulation.java. |
|
Simulator applet. Definition at line 403 of file Simulation.java. |
|
Current thread. Definition at line 409 of file Simulation.java. |