static boolean isIllegalHoppingSpecified ( List < NodeInfo > order ) { for ( int i = 0 ; i < order . size ( ) ; i ++ ) { NodeInfo ni = ( NodeInfo ) order . get ( i ) ; // look for move restricted nodes if ( ! ni . getNode ( ) . getAttribute ( Constants . ATT_MOVE_ALLOWED ) . equals ( "false" ) ) continue ; // now check nodes in lower position to see if they "hopped" here // or if they have similar precedence and came from another parent. for ( int j = 0 ; j < i ; j ++ ) { NodeInfo niSib = ( NodeInfo ) order . get ( j ) ; // skip lower precedence nodes from this parent. These will get // bumped during the lower precedence check if ( niSib . getPrecedence ( ) == Precedence . getUserPrecedence ( ) ) continue ; if ( niSib . getPrecedence ( ) . isEqualTo ( ni . getPrecedence ( ) ) && ( niSib . getIndexInCVP ( ) == - 1 || // from another parent ni . getIndexInCVP ( ) < niSib . getIndexInCVP ( ) ) ) // niSib hopping left return true ; } // now check upper positioned nodes to see if they "hopped" for ( int j = i + 1 ; j < order . size ( ) ; j ++ ) { NodeInfo niSib = ( NodeInfo ) order . get ( j ) ; // ignore nodes from other parents and user precedence nodes if ( niSib . getIndexInCVP ( ) == - 1 || niSib . getPrecedence ( ) == Precedence . getUserPrecedence ( ) ) continue ; if ( ni . getIndexInCVP ( ) > niSib . getIndexInCVP ( ) && // niSib hopped right niSib . getPrecedence ( ) . isEqualTo ( ni . getPrecedence ( ) ) ) return true ; } } return false ; }
This method determines if any illegal hopping is being specified . To determine if the positioning is specifying an ordering that will result in hopping I need to determine for each node n in the list if any of the nodes to be positioned to its right currently lie to its left in the CVP and have moveAllowed = false and have the same precedence or if any of the nodes to be positioned to its left currently lie to its right in the CVP and have moveAllowed = false and have the same precedence .