예제 #1
0
 public boolean use(LayoutNode n, LayoutTypes nodeType) {
   if (isUsed(n.coord())) return false;
   used.put(getHashCode(n.coord()[0], n.coord()[1]), n);
   set.add(n);
   if (nodeType != null) n.reType(nodeType);
   return true;
 }
예제 #2
0
 public void fillInFlags() {
   for (Enumeration<LayoutNode> e = set().elements(); e.hasMoreElements(); ) {
     LayoutNode n = e.nextElement();
     int[] dirs = new int[n.links().size()];
     int x = 0;
     for (Integer dirLink : n.links().keySet()) dirs[x++] = dirLink.intValue();
     n.setExits(dirs);
     if ((dirs.length == 1) && (!n.isFlagged(LayoutFlags.gate))) n.reType(LayoutTypes.leaf);
   }
   for (Enumeration<LayoutNode> e = set().elements(); e.hasMoreElements(); ) {
     LayoutNode n = e.nextElement();
     if (n.links().size() == 2) {
       LayoutFlags flag = null;
       if (n.type() == LayoutTypes.interior)
         for (Integer dirLink : n.links().keySet()) {
           LayoutNode n2 = n.links().get(dirLink);
           if ((n2 != null) && (n2.type() == LayoutTypes.leaf)) flag = LayoutFlags.offleaf;
         }
       if (flag != null) n.flag(flag);
       else {
         Enumeration<Integer> dirs = n.links().keys();
         Integer lN1 = dirs.nextElement();
         Integer lN2 = dirs.nextElement();
         if (lN1.intValue() != Directions.getOpDirectionCode(lN2.intValue()))
           n.flag(LayoutFlags.corner);
       }
     } else if ((n.links().size() == 3)
         && (((n.type() == LayoutTypes.street) || (n.type() != LayoutTypes.surround)))) {
       boolean allStreet = true;
       for (Integer dirLink : n.links().keySet()) {
         LayoutNode n2 = n.links().get(dirLink);
         if ((n2 == null)
             || ((n2.type() != LayoutTypes.street) && (n2.type() != LayoutTypes.surround)))
           allStreet = false;
       }
       if (allStreet) n.flag(LayoutFlags.tee);
     } else if ((n.links().size() == 4)
         && (((n.type() == LayoutTypes.street) || (n.type() != LayoutTypes.surround)))) {
       boolean allStreet = true;
       for (Integer dirLink : n.links().keySet()) {
         LayoutNode n2 = n.links().get(dirLink);
         if ((n2 == null)
             || ((n2.type() != LayoutTypes.street) && (n2.type() != LayoutTypes.surround)))
           allStreet = false;
       }
       if (allStreet) n.flag(LayoutFlags.intersection);
     }
   }
 }