protected void addCrossing(Collection c,GeoSegment segment,GeoRegion region){
  Geo start=segment.getSeg()[0];
  if (lastSegmentCrossingList != null && lastSegmentStartingPoint.distance(start) > 0) {
    crossings.addAll(lastSegmentCrossingList);
    lastSegmentCrossingList.clear();
  }
 else   if (lastSegmentCrossingList == null) {
    lastSegmentCrossingList=new ArrayList(10);
  }
  LinkedList orderedList=new LinkedList();
  orderedList.addAll(lastSegmentCrossingList);
  lastSegmentCrossingList.clear();
  for (Iterator it=c.iterator(); it.hasNext(); ) {
    Geo current=(Geo)it.next();
    double curDist=start.distance(current);
    BoundaryCrossing currentBC=new BoundaryCrossing(current,region,true);
    int lastCheckedIndex=0;
    BoundaryCrossing lastChecked=null;
    for (Iterator it2=orderedList.iterator(); it2.hasNext(); lastCheckedIndex++) {
      lastChecked=(BoundaryCrossing)it2.next();
      if (curDist < start.distance(lastChecked.geo)) {
        break;
      }
 else {
        lastChecked=null;
      }
    }
    if (lastChecked != null) {
      orderedList.add(lastCheckedIndex,currentBC);
    }
 else {
      orderedList.add(currentBC);
    }
  }
  boolean goinin=!Intersection.isPointInPolygon(start,region.getPoints());
  for (Iterator it=orderedList.iterator(); it.hasNext(); ) {
    BoundaryCrossing bc=(BoundaryCrossing)it.next();
    boolean sameRegion=(bc.in == region);
    if (sameRegion) {
      if (!goinin)       bc.out=bc.in;
      goinin=!goinin;
    }
    lastSegmentCrossingList.add(bc);
  }
  lastSegmentStartingPoint=start;
}

protected void addCrossing ( Collection c , GeoSegment segment , GeoRegion region ) { Geo start = segment . getSeg ( ) [ 0 ] ; if ( lastSegmentCrossingList != null && lastSegmentStartingPoint . distance ( start ) > 0 ) { crossings . addAll ( lastSegmentCrossingList ) ; lastSegmentCrossingList . clear ( ) ; } else if ( lastSegmentCrossingList == null ) { lastSegmentCrossingList = new ArrayList ( 10 ) ; } LinkedList orderedList = new LinkedList ( ) ; orderedList . addAll ( lastSegmentCrossingList ) ; lastSegmentCrossingList . clear ( ) ; for ( Iterator it = c . iterator ( ) ; it . hasNext ( ) ; ) { Geo current = ( Geo ) it . next ( ) ; double curDist = start . distance ( current ) ; BoundaryCrossing currentBC = new BoundaryCrossing ( current , region , true ) ; int lastCheckedIndex = 0 ; BoundaryCrossing lastChecked = null ; for ( Iterator it2 = orderedList . iterator ( ) ; it2 . hasNext ( ) ; lastCheckedIndex ++ ) { lastChecked = ( BoundaryCrossing ) it2 . next ( ) ; if ( curDist < start . distance ( lastChecked . geo ) ) { break ; } else { lastChecked = null ; } } if ( lastChecked != null ) { orderedList . add ( lastCheckedIndex , currentBC ) ; } else { orderedList . add ( currentBC ) ; } } boolean goinin = ! Intersection . isPointInPolygon ( start , region . getPoints ( ) ) ; for ( Iterator it = orderedList . iterator ( ) ; it . hasNext ( ) ; ) { BoundaryCrossing bc = ( BoundaryCrossing ) it . next ( ) ; boolean sameRegion = ( bc . in == region ) ; if ( sameRegion ) { if ( ! goinin ) bc . out = bc . in ; goinin = ! goinin ; } lastSegmentCrossingList . add ( bc ) ; } lastSegmentStartingPoint = start ; }
add a boundarycrossing associated with a segment and region . this is the main thinkin ' method , called by the crossinginspector with lists of crossings . this method organizes and orders bordercrossings according to the segment order of the path that caused the crossings .
