Пример #1
0
 public void remRoad(int pos) throws InfraException {
   if (pos > 3 || pos < 0) throw new InfraException("Position out of range");
   Road road = allRoads[pos];
   if (road == null) throw new InfraException("Road at position " + pos + " does not exist");
   allRoads[pos] = null;
   alphaRoads = (Road[]) Arrayutils.remElement(alphaRoads, road);
   updateLanes();
   calculateWidth();
 }
Пример #2
0
 public void addRoad(Road r, int pos) throws InfraException {
   if (r == null) throw new InfraException("Parameter r is null");
   if (pos > 3 || pos < 0) throw new InfraException("Position out of range");
   if (allRoads[pos] != null)
     throw new InfraException("Road already connected to position " + pos);
   allRoads[pos] = r;
   Node other = r.getOtherNode(this);
   if (other == null || !other.isAlphaRoad(r))
     alphaRoads = (Road[]) Arrayutils.addElement(alphaRoads, r);
   updateLanes();
   calculateWidth();
 }
Пример #3
0
 public void remRoad(Road r) throws InfraException {
   if (r == null) throw new InfraException("Parameter r is null");
   alphaRoads = (Road[]) Arrayutils.remElement(alphaRoads, r);
   for (int i = 0; i < 4; i++) {
     if (allRoads[i] == r) {
       allRoads[i] = null;
       updateLanes();
       calculateWidth();
       return;
     }
   }
   throw new InfraException("Road not found in this node");
 }
Пример #4
0
  /**
   * Returns an array of all lanes connected to this node, in clock-wise order, starting at the
   * given lane
   */
  public Drivelane[] getAllLanesCW(Drivelane lane) throws InfraException {
    Drivelane[] lanes = getAllLanes(); // in clockwise order starting at road 0, lane 0

    // find the starting-lane
    int i = Arrayutils.findElement(lanes, lane);
    if (i == -1) throw new InfraException("Lane is not on this node");

    // shift all the lanes i places and remove the i-th element
    Drivelane[] result = new Drivelane[lanes.length - 1];
    System.arraycopy(lanes, i + 1, result, 0, lanes.length - i - 1);
    System.arraycopy(lanes, 0, result, lanes.length - i - 1, i);

    return result;
  }
Пример #5
0
 /** Removes a sign configuration */
 public void remSignconfig(Sign[] conf) throws InfraException {
   if (conf == null) throw new InfraException("Parameter conf is null");
   int i = Arrayutils.findElement(signconfigs, conf);
   if (i == -1) throw new InfraException("Sign configuration is not in the list");
   signconfigs = (Sign[][]) Arrayutils.remElement(signconfigs, i);
 }
Пример #6
0
 /** Adds a sign configuration */
 public void addSignconfig(Sign[] conf) throws InfraException {
   if (conf == null) throw new InfraException("Parameter conf is null");
   signconfigs = (Sign[][]) Arrayutils.addElement(signconfigs, conf);
 }
Пример #7
0
 public void setAlphaRoad(int pos) throws InfraException {
   if (pos > 3 || pos < 0) throw new InfraException("Position out of range");
   if (allRoads[pos] == null) throw new InfraException("No road is conencted at position " + pos);
   alphaRoads = (Road[]) Arrayutils.addElementUnique(alphaRoads, allRoads[pos]);
   updateLanes();
 }