System.out.println("newLength = " + newLength + "l" + l.getLength());
    public TrainPath truncateTail (int newLength) {	final Point p = new Point ();	PathLength l = new PathLength();	if ((int) length == newLength) {	    getTail(p);	    return new TrainPath(new IntLine[]{new IntLine(p.x, p.y, p.x, p.y)});	}	ListIterator i = segments.listIterator(0);	IntLine line = null;	LinkedList removedSegments = new LinkedList(); 	while (i.hasNext() && (int) l.getLength() <= newLength) {	    line = (IntLine) i.next();	    l.add(line.getLength());	}	while (i.hasNext()) {	    removedSegments.add(i.next());	    i.remove();	}	if ((int) l.getLength() > newLength) {	    int oldX2 = line.x2;	    int oldY2 = line.y2;	    PathLength segLength = new PathLength(line.getLength());	    l.subtract(segLength);	    System.out.println("newLength = " + newLength + "l" +		    l.getLength());	    segLength.setLength(newLength - l.getLength());	    l.add(segLength);	    line.setLength(segLength);	    removedSegments.addFirst(new IntLine(line.x2, line.y2, oldX2,		       oldY2));	}	length = newLength;	actualLength = l;	if (removedSegments.isEmpty()) {	    getTail(p);	    removedSegments.add(new IntLine(p.x, p.y, p.x, p.y));	}	return new TrainPath((IntLine[]) removedSegments.toArray(new		    IntLine[removedSegments.size()]));    }