home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 2.0 KB | 87 lines |
- /* $Id: Carrier.java,v 1.3 1996/03/31 11:43:02 djun Exp djun $
-
- File: Carrier.java
-
- Defines the class Carrier, which extends location. A carrier
- is a linear location, with a start and end point, which carries
- something: for example, paths, streets, electrical or data lines,
- are all carriers. Carriers all have a length, and a capacity.
-
- Author: Djun M. Kim
- Copyright (c) 1996 Djun M. Kim. All rights reserved.
-
-
- */
-
- import Map;
- import MapError;
- import java.net.*;
- import java.awt.*;
- import java.util.Vector;
-
- public class Carrier extends Location {
-
- protected Location source;
- protected Location sink;
- protected Integer length;
- protected Integer capacity;
- protected String description;
-
- private final boolean displayable = false;
-
- // Constructor
- Carrier(Map target, Location source, Location sink, int length, int capacity) {
- super(target, source.getBase().x, source.getBase().y);
- super.parent = target;
- name = new String();
- region = new Region();
- }
-
- // Accessor methods
- public Location getSource() {
- return source;
- }
- public Location getSink() {
- return sink;
- }
- public Integer getLength() {
- return length;
- }
-
- public Integer getCapacity() {
- return capacity;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void showCarrier(Graphics g) {
- g.setColor(Color.red);
- g.drawPolygon(this.region.perim);
- }
- }
-
-
- /*----------------------------------------------------------------------
- Class to implement "junctions" between carriers
- ----------------------------------------------------------------------*/
-
- // A junction is a place where several carriers come together.
- class Junction extends Location {
-
- protected final boolean displayable = false;
-
- // constructor
- Junction(Map target, int x, int y) {
- super(target, x, y);
- super.parent = target;
- }
-
- // Constructor - initialize base point to (0, 0)
- Junction(Map target) {
- super(target, 0, 0);
- super.parent = target;
- }
- }
-