Public Methods | |
| Line (Node left, Node right, int capacity) | |
| Line (Node left, Node right, int leftCapacity, int rightCapacity) | |
| void | transmitAll () | 
| int | getCapacity () | 
| int | getLeftToRightCapacity () | 
| int | getRightToLeftCapacity () | 
| void | setCapacity (int capacity) | 
| void | setLeftToRightCapacity (int capacity) | 
| void | setRightToLeftCapacity (int capacity) | 
| void | delete () | 
| boolean | isDisconnected () | 
| boolean | areEndingNodes (Node first_node, Node second_node) | 
| void | paint (Graphics g, FontMetrics metrics, Color line_color) | 
| void | paint (Graphics g, FontMetrics metrics, Color line_color, Color left_packet_color, Color right_packet_color, Color traced_packet_color, boolean show_line_capacity, boolean show_all_packets) | 
Public Attributes | |
| LineEnd | left_end | 
| LineEnd | right_end | 
Protected Attributes | |
| boolean | show_capacity = true | 
| boolean | deleted = false | 
| Node | left_node | 
| Node | right_node | 
| int | left_capacity | 
| int | right_capacity | 
Definition at line 22 of file Line.java.
      
  | 
  
| 
 Default constructor. Line can be created only if both starting and ending nodes are known. Line capacity must also be specified (symmetric line is assumed). 
 Definition at line 78 of file Line.java. 00079     {
00080         left_end = new LineEnd(this);
00081         right_end = new LineEnd(this);
00082         left_node = left;
00083         right_node = right;
00084         left_node.attach(left_end, right_node);
00085         right_node.attach(right_end, left_node);
00086         left_capacity = capacity;
00087         right_capacity = capacity;
00088         left_end.setCapacity(left_capacity);
00089         right_end.setCapacity(right_capacity);
00090     }
 | 
  
      
  | 
  
| 
 Normal constructor. Line can be created only if both starting and ending nodes are known (left and right node). Asymmetric line is created. 
 Definition at line 102 of file Line.java. 00103     {
00104         left_end = new LineEnd(this);
00105         right_end = new LineEnd(this);
00106         left_node = left;
00107         right_node = right;
00108         left_end.setCapacity(left_capacity);
00109         right_end.setCapacity(right_capacity);
00110         left_node.attach(left_end, right_node);
00111         right_node.attach(right_end, left_node);
00112         this.left_capacity = left_capacity;
00113         this.right_capacity = right_capacity;
00114     }
 | 
  
      
  | 
  
| 
 Test if ending nodes are equal to given nodes. 
 
 Definition at line 238 of file Line.java. Referenced by CyclopsSimulator::deleteLine(). 
 00239     {
00240         if (left_node == first_node)
00241             {
00242                 if (right_node == second_node)
00243                     {
00244                         return true;
00245                     }
00246             }
00247         else if (right_node == first_node)
00248             {
00249                 if (left_node == second_node)
00250                     {
00251                         return true;
00252                     }
00253             }
00254         return false;
00255     }
 | 
  
      
  | 
  
| 
 Deletes line. Definition at line 215 of file Line.java. Referenced by LineEnd::delete(), and CyclopsSimulator::deleteLine(). 
  | 
  
      
  | 
  
| 
 Gets line capacity. If line is asymmetric returns minimal capacity. 
 Definition at line 142 of file Line.java. 00143     {
00144         if (left_capacity < right_capacity)
00145             {
00146                 return left_capacity;
00147             }
00148         else
00149             {
00150                 return right_capacity;
00151             }
00152     }
 | 
  
      
  | 
  
| 
 Gets line capacity for left-to-right transfer. 
 Definition at line 159 of file Line.java. 00160     {
00161         return left_capacity;
00162     }
 | 
  
      
  | 
  
| 
 Gets line capacity for right-to-left transfer. 
 Definition at line 170 of file Line.java. 00171     {
00172         return right_capacity;
00173     }
 | 
  
      
  | 
  
| 
 Test if line is disconnected. Definition at line 226 of file Line.java. Referenced by CyclopsSimulator::deleteNode(). 
 00227     {
00228         return deleted;
00229     }
 | 
  
      
  | 
  
| 
 Draws line on screen. 
 Definition at line 304 of file Line.java. 00309     {
00310         int x1;
00311         int y1;
00312         int x2;
00313         int y2;
00314         int x;
00315         int y;
00316         int i;
00317         Packet packet;
00318 
00319         x1 = left_node.getXCoordinate();
00320         y1 = left_node.getYCoordinate();
00321         x2 = right_node.getXCoordinate();
00322         y2 = right_node.getYCoordinate();
00323         g.setColor(line_color);
00324         g.drawLine(x1, y1, x2, y2);
00325         x = x1 + (x2 - x1) / 2;
00326         y = y1 + (y2 - y1) / 2;
00327         if (show_line_capacity)
00328             {
00329                 String capacity;
00330                 if (left_capacity < right_capacity)
00331                     {
00332                         capacity = String.valueOf(left_capacity);
00333                     }
00334                 else
00335                     {
00336                         capacity = String.valueOf(left_capacity);
00337                     }
00338                 g.setColor(Color.black);
00339                 g.drawString(capacity, x, y);
00340             }
00341         /* if */ /* show_line_capacity */
00342         boolean axis = Math.abs(y2 - y1) > Math.abs(x2 - x1);
00343         if (show_all_packets)
00344             {
00345                 x = x1 + (x2 - x1) / 2;
00346                 y = y1 + (y2 - y1) / 2;
00347                 for (i=0; i<left_end.size(); i++)
00348                     {
00349                         if (axis) y = y + 6;
00350                         else x = x + 6;
00351                         packet = (Packet)left_end.elementAt(i);
00352                         if (packet.getDrawingFlag())
00353                             {
00354                                 packet.paint(g, metrics, traced_packet_color, x, y);
00355                             }
00356                         else
00357                             {
00358                                 packet.paint(g, metrics, left_packet_color, x, y);
00359                             }
00360                     }
00361                 /* for */
00362                 for (i=0; i<right_end.size(); i++)
00363                     {
00364                         if (axis) y = y + 6;
00365                         else x = x + 6;
00366                         packet = (Packet)right_end.elementAt(i);
00367                         if (packet.getDrawingFlag())
00368                             {
00369                                 packet.paint(g, metrics, traced_packet_color, x, y);
00370                             }
00371                         else
00372                             {
00373                                 packet.paint(g, metrics, right_packet_color, x, y);
00374                             }
00375                     }
00376                 /* for */
00377             }
00378         else
00379             {
00380                 x = x1 + (x2 - x1) / 2;
00381                 y = y1 + (y2 - y1) / 2;
00382                 for (i=0; i<left_end.size(); i++)
00383                     {
00384                         packet = (Packet)left_end.elementAt(i);
00385                         if (packet.getDrawingFlag())
00386                             {
00387                                 if (axis) y = y + 6;
00388                                 else x = x + 6;
00389                                 packet.paint(g, metrics, traced_packet_color, x, y);
00390                             }
00391                     }
00392                 /* for */
00393                 for (i=0; i<right_end.size(); i++)
00394                     {
00395                         packet = (Packet)right_end.elementAt(i);
00396                         if (packet.getDrawingFlag())
00397                             {
00398                                 if (axis) y = y + 6;
00399                                 else x = x + 6;
00400                                 packet.paint(g, metrics, traced_packet_color, x, y);
00401                             }
00402                     }
00403                 /* for */
00404             }
00405         /* if else */ /* show_all_packets */
00406     }
 | 
  
      
  | 
  
| 
 Draws line on screen. 
 Definition at line 264 of file Line.java. Referenced by CyclopsSimulator::paint(). 
 00265     {
00266         int x1;
00267         int y1;
00268         int x2;
00269         int y2;
00270 
00271         x1 = left_node.getXCoordinate();
00272         y1 = left_node.getYCoordinate();
00273         x2 = right_node.getXCoordinate();
00274         y2 = right_node.getYCoordinate();
00275         g.setColor(line_color);
00276         g.drawLine(x1, y1, x2, y2);
00277         if (show_capacity)
00278             {
00279                 String capacity;
00280                 if (left_capacity < right_capacity)
00281                     {
00282                         capacity = String.valueOf(left_capacity);
00283                     }
00284                 else
00285                     {
00286                         capacity = String.valueOf(left_capacity);
00287                     }
00288                 g.setColor(Color.black);
00289                 g.drawString(capacity, x1 + (x2 - x1) / 2, y1 + (y2 - y1) / 2);
00290             }
00291     }
 | 
  
      
  | 
  
| 
 Sets line capacity (forces symmetric line). 
 Definition at line 181 of file Line.java. 00182     {
00183         left_capacity = capacity;
00184         right_capacity = capacity;
00185         left_end.setCapacity(left_capacity);
00186         right_end.setCapacity(right_capacity);
00187     }
 | 
  
      
  | 
  
| 
 Sets line capacity for left-to-right transfer. 
 Definition at line 194 of file Line.java. 00195     {
00196         left_capacity = capacity;
00197         left_end.setCapacity(left_capacity);
00198     }
 | 
  
      
  | 
  
| 
 Sets line capacity for right-to-left transfer. 
 Definition at line 205 of file Line.java. 00206     {
00207         right_capacity = capacity;
00208         right_end.setCapacity(right_capacity);
00209     }
 | 
  
      
  | 
  
| 
 Passes all packets to appropriate nodes. This function is used in simulation. Definition at line 121 of file Line.java. Referenced by CyclopsSimulator::simulate(). 
  | 
  
      
  | 
  
| 
 Disconnect flag.  | 
  
      
  | 
  
| 
 Line capacity is maximum number of packets that can pass through the line in one simulation cycle. Asyimmetric connections between node are possible.  | 
  
      
  | 
  
| 
 Left line end. When line is created, node must know is it connected to left or right end.  | 
  
      
  | 
  
| 
 Node at left end. Line must know to which nodes it is connected.  | 
  
      
  | 
  
| 
 Line capacity is maximum number of packets that can pass through the line in one simulation cycle. Asyimmetric connections between node are possible.  | 
  
      
  | 
  
| 
 Right line end. When line is created, node must know is it connected to left or right end.  | 
  
      
  | 
  
| 
 Node at right end. Line must know to which nodes it is connected.  | 
  
      
  | 
  
| 
 Show capacity flag. If set, minimum capacity will be diplayed on screen.  | 
  
1.2.7 written by Dimitri van Heesch,
 © 1997-2001