nextDirection &= (byte) (CompassPoints.EAST |
direction &= (byte) (CompassPoints.EAST |
    public void getMapCoordsAndDirections(HashMap mapCoords) {	byte direction, nextDirection;	ListIterator i = segments.listIterator(0);	Point map = new Point();	final Point oldMapPoint = new Point();	nextDirection = 0;	while (i.hasNext()) {	    IntLine l = (IntLine) i.next();	    int dx = l.x2 - l.x1;	    int dy = l.y2 - l.y1;	    map.x = l.x1 / TrackTile.DELTAS_PER_TILE;	    map.y = l.y1 / TrackTile.DELTAS_PER_TILE;	    while (map.x != l.x2 / TrackTile.DELTAS_PER_TILE &&		    map.y != l.y2 / TrackTile.DELTAS_PER_TILE) {		direction = nextDirection;		nextDirection = 0;		oldMapPoint.x = map.x;		oldMapPoint.y = map.y;		if (dx < 0) {		    map.x--;		    nextDirection = (byte) (CompassPoints.NORTHWEST |			CompassPoints.WEST |			CompassPoints.SOUTHWEST);		} else if (dx > 0) {		    map.x++;		    nextDirection = (byte) (CompassPoints.NORTHEAST |			CompassPoints.EAST |			CompassPoints.SOUTHEAST);		} else {		    nextDirection = (byte) (CompassPoints.NORTH |			CompassPoints.SOUTH);		}		if (dy < 0) {		    map.y--;		    nextDirection &= (byte) (CompassPoints.NORTHWEST |			    CompassPoints.NORTH | CompassPoints.NORTHEAST);		} else if (dy > 0) {		    map.y++;		    nextDirection &= (byte) (CompassPoints.SOUTHWEST |			    CompassPoints.SOUTH |			    CompassPoints.SOUTHEAST);		} else {		    nextDirection &= (byte) (CompassPoints.EAST |			    CompassPoints.WEST);		}		direction |= (byte) nextDirection;		Byte oldNextDirection = (Byte) mapCoords.get(map);		if (oldNextDirection != null)		    nextDirection |= oldNextDirection.byteValue();		System.out.println("putting " + oldMapPoint + ", " +			CompassPoints.toString(direction));		mapCoords.put(new Point(oldMapPoint), new Byte(direction));	    };	}	/* add the last point */	mapCoords.put(new Point(map), new Byte(nextDirection));	System.out.println("putting " + map + ", " +		CompassPoints.toString(nextDirection));    }