public void invert ( ) { final boolean isEventFirable = isEventFirable ( ) ; setEventFirable ( false ) ; try { final int count = this . roadSegments . getRoadSegmentCount ( ) ; // Invert the segments this . roadSegments . invert ( ) ; // Invert the bus halts and their indexes. final int middle = this . validHalts . size ( ) / 2 ; for ( int i = 0 , j = this . validHalts . size ( ) - 1 ; i < middle ; ++ i , -- j ) { final BusItineraryHalt h1 = this . validHalts . get ( i ) ; final BusItineraryHalt h2 = this . validHalts . get ( j ) ; this . validHalts . set ( i , h2 ) ; this . validHalts . set ( j , h1 ) ; int idx = h1 . getRoadSegmentIndex ( ) ; idx = count - idx - 1 ; h1 . setRoadSegmentIndex ( idx ) ; idx = h2 . getRoadSegmentIndex ( ) ; idx = count - idx - 1 ; h2 . setRoadSegmentIndex ( idx ) ; } if ( middle * 2 != this . validHalts . size ( ) ) { final BusItineraryHalt h1 = this . validHalts . get ( middle ) ; int idx = h1 . getRoadSegmentIndex ( ) ; idx = count - idx - 1 ; h1 . setRoadSegmentIndex ( idx ) ; } } finally { setEventFirable ( isEventFirable ) ; } fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ITINERARY_INVERTED , this , indexInParent ( ) , "busHalts" , //$NON-NLS-1$ null , null ) ) ; }
Invert the order of this itinerary .