home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / ingzp26a / carrier.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  2.0 KB  |  87 lines

  1. /* $Id: Carrier.java,v 1.3 1996/03/31 11:43:02 djun Exp djun $
  2.  
  3.    File: Carrier.java
  4.  
  5.    Defines the class Carrier, which extends location.  A carrier
  6.    is a linear location, with a start and end point, which carries
  7.    something: for example, paths, streets, electrical or data lines,
  8.    are all carriers.  Carriers all have a length, and a capacity.
  9.  
  10.    Author: Djun M. Kim
  11.    Copyright (c) 1996 Djun M. Kim.  All rights reserved.
  12.  
  13.  
  14. */
  15.  
  16. import Map;
  17. import MapError;
  18. import java.net.*;
  19. import java.awt.*;
  20. import java.util.Vector;
  21.  
  22. public class Carrier extends Location {
  23.  
  24.     protected Location source;
  25.     protected Location sink;
  26.     protected Integer length;
  27.     protected Integer capacity;
  28.     protected String description;
  29.  
  30.     private final boolean displayable = false;
  31.  
  32.     // Constructor
  33.     Carrier(Map target, Location source, Location sink, int length, int capacity) {
  34.     super(target, source.getBase().x, source.getBase().y);
  35.     super.parent = target;
  36.     name = new String();    
  37.     region = new Region();
  38.     }
  39.  
  40.     // Accessor methods
  41.     public Location getSource() {
  42.     return source;
  43.     }
  44.     public Location getSink() {
  45.     return sink;
  46.     }
  47.     public Integer getLength() {
  48.     return length;
  49.     }
  50.  
  51.     public Integer getCapacity() {
  52.     return capacity;
  53.     }
  54.  
  55.     public String getDescription() {
  56.     return description;
  57.     }
  58.  
  59.     public void showCarrier(Graphics g) {
  60.     g.setColor(Color.red);
  61.     g.drawPolygon(this.region.perim);
  62.     }
  63. }
  64.  
  65.  
  66. /*----------------------------------------------------------------------
  67.     Class to implement "junctions" between carriers
  68.   ----------------------------------------------------------------------*/
  69.  
  70. // A junction is a place where several carriers come together.
  71. class Junction extends Location {
  72.  
  73.     protected final boolean displayable = false;
  74.   
  75.     // constructor
  76.     Junction(Map target, int x, int y) {
  77.     super(target, x, y);
  78.     super.parent = target;
  79.     }
  80.  
  81.     // Constructor - initialize base point to (0, 0)
  82.     Junction(Map target) {
  83.     super(target, 0, 0);
  84.     super.parent = target;
  85.     }
  86. }
  87.