idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
6,000
public boolean contains ( FunctionalPoint3D point ) { return containsTrianglePoint ( this . getP1 ( ) . getX ( ) , this . getP1 ( ) . getY ( ) , this . getP1 ( ) . getZ ( ) , this . getP2 ( ) . getX ( ) , this . getP2 ( ) . getY ( ) , this . getP2 ( ) . getZ ( ) , this . getP3 ( ) . getX ( ) , this . getP3 ( ) . getY ( ) , this . getP3 ( ) . getZ ( ) , point . getX ( ) , point . getY ( ) , point . getZ ( ) , true , 0. ) ; }
Checks if a point is inside this triangle .
6,001
public Plane3D < ? > getPlane ( ) { return toPlane ( getX1 ( ) , getY1 ( ) , getZ1 ( ) , getX1 ( ) , getY1 ( ) , getZ1 ( ) , getX1 ( ) , getY1 ( ) , getZ1 ( ) ) ; }
Replies the plane on which this triangle is coplanar .
6,002
public void writeln ( String text ) throws IOException { this . writer . write ( text ) ; if ( text != null && text . length ( ) > 0 ) { this . writer . write ( "\n" ) ; } }
Write a sequence of characters followed by a carriage return .
6,003
public static < X , Y > Iterable < ZipPair < X , Y > > zip ( final Iterable < X > iter1 , final Iterable < Y > iter2 ) { return new ZipIterable < X , Y > ( iter1 , iter2 ) ; }
An implementation of Python s zip .
6,004
public static < A , B > B reduce ( final Iterable < A > iterable , final B initial , final Function2 < A , B > func ) { B b = initial ; for ( final A item : iterable ) { b = func . apply ( b , item ) ; } return b ; }
reduces an iterable to a single value starting from an initial value and applying down the iterable .
6,005
public static < K , V > ImmutableMap < K , V > mapFromPairedKeyValueSequences ( final Iterable < K > keys , final Iterable < V > values ) { final ImmutableMap . Builder < K , V > builder = ImmutableMap . builder ( ) ; for ( final ZipPair < K , V > pair : zip ( keys , values ) ) { builder . put ( pair . first ( ) , pair . second ( ) ) ; } return builder . build ( ) ; }
Given a paired sequence of Iterables produce a map with keys from the first and values from the second . An exception will be raised if the Iterables have different numbers of elements or if there are multiple mappings for the same key .
6,006
public static < T > boolean allTheSame ( final Iterable < T > iterable ) { if ( Iterables . isEmpty ( iterable ) ) { return true ; } final T reference = Iterables . getFirst ( iterable , null ) ; for ( final T x : iterable ) { if ( ! x . equals ( reference ) ) { return false ; } } return true ; }
Prefer allEqual whose name is less ambiguous between equality and identity
6,007
public static Vector1dfx convert ( Tuple1dfx < ? > tuple ) { if ( tuple instanceof Vector1dfx ) { return ( Vector1dfx ) tuple ; } return new Vector1dfx ( tuple . getSegment ( ) , tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Vector1dfx .
6,008
protected boolean buildGetParams ( StringBuilder sb , boolean isFirst ) { BuilderListener listener = mListener ; if ( listener != null ) { return listener . onBuildGetParams ( sb , isFirst ) ; } else { return isFirst ; } }
In this we should add same default params to the get builder
6,009
private ProxyType extendedProxyTypeAsProxyType ( ExtendedProxyType pt ) { switch ( pt ) { case DRAFT_RFC : return ProxyType . DRAFT_RFC ; case LEGACY : return ProxyType . LEGACY ; case RFC3820 : return ProxyType . RFC3820 ; default : return null ; } }
Why we have to do this nonsense?
6,010
@ SuppressWarnings ( "checkstyle:magicnumber" ) public static String encodeBase26 ( int number ) { final StringBuilder value = new StringBuilder ( ) ; int code = number ; do { final int rest = code % 26 ; value . insert ( 0 , ( char ) ( 'A' + rest ) ) ; code = code / 26 - 1 ; } while ( code >= 0 ) ; return value . toString ( ) ; }
Replies a base 26 encoding string for the given number .
6,011
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static Map < Character , String > getJavaToHTMLTranslationTable ( ) { Map < Character , String > map = null ; try { LOCK . lock ( ) ; if ( javaToHtmlTransTbl != null ) { map = javaToHtmlTransTbl . get ( ) ; } } finally { LOCK . unlock ( ) ; } if ( map != null ) { return map ; } ResourceBundle resource = null ; try { resource = ResourceBundle . getBundle ( TextUtil . class . getCanonicalName ( ) , java . util . Locale . getDefault ( ) ) ; } catch ( MissingResourceException exep ) { return null ; } final String result ; try { result = resource . getString ( "HTML_TRANS_TBL" ) ; } catch ( Exception e ) { return null ; } map = new TreeMap < > ( ) ; final String [ ] pairs = result . split ( "(\\}\\{)|\\{|\\}" ) ; Integer isoCode ; String entity ; String code ; for ( int i = 1 ; ( i + 1 ) < pairs . length ; i += 2 ) { try { entity = pairs [ i ] ; code = pairs [ i + 1 ] ; isoCode = Integer . valueOf ( code ) ; if ( isoCode != null ) { map . put ( ( char ) isoCode . intValue ( ) , entity ) ; } } catch ( Throwable exception ) { } } try { LOCK . lock ( ) ; javaToHtmlTransTbl = new SoftReference < > ( map ) ; } finally { LOCK . unlock ( ) ; } return map ; }
Replies the java - to - html s translation table .
6,012
@ SuppressWarnings ( "checkstyle:magicnumber" ) public static String parseHTML ( String html ) { if ( html == null ) { return null ; } final Map < String , Integer > transTbl = getHtmlToJavaTranslationTable ( ) ; assert transTbl != null ; if ( transTbl . isEmpty ( ) ) { return html ; } final Pattern pattern = Pattern . compile ( "[&](([a-zA-Z]+)|(#x?[0-9]+))[;]" ) ; final Matcher matcher = pattern . matcher ( html ) ; final StringBuilder result = new StringBuilder ( ) ; String entity ; Integer isoCode ; int lastIndex = 0 ; while ( matcher . find ( ) ) { final int idx = matcher . start ( ) ; result . append ( html . substring ( lastIndex , idx ) ) ; lastIndex = matcher . end ( ) ; entity = matcher . group ( 1 ) ; if ( entity . startsWith ( "#x" ) ) { try { isoCode = Integer . valueOf ( entity . substring ( 2 ) , 16 ) ; } catch ( Throwable exception ) { isoCode = null ; } } else if ( entity . startsWith ( "#" ) ) { try { isoCode = Integer . valueOf ( entity . substring ( 1 ) ) ; } catch ( Throwable exception ) { isoCode = null ; } } else { isoCode = transTbl . get ( entity ) ; } if ( isoCode == null ) { result . append ( matcher . group ( ) ) ; } else { result . append ( ( char ) isoCode . intValue ( ) ) ; } } if ( lastIndex < html . length ( ) ) { result . append ( html . substring ( lastIndex ) ) ; } return result . toString ( ) ; }
Parse the given HTML text and replace all the HTML entities by the corresponding unicode character .
6,013
public static String toHTML ( String text ) { if ( text == null ) { return null ; } final Map < Character , String > transTbl = getJavaToHTMLTranslationTable ( ) ; assert transTbl != null ; if ( transTbl . isEmpty ( ) ) { return text ; } final StringBuilder patternStr = new StringBuilder ( ) ; for ( final Character c : transTbl . keySet ( ) ) { if ( patternStr . length ( ) > 0 ) { patternStr . append ( "|" ) ; } patternStr . append ( Pattern . quote ( c . toString ( ) ) ) ; } final Pattern pattern = Pattern . compile ( patternStr . toString ( ) ) ; final Matcher matcher = pattern . matcher ( text ) ; final StringBuilder result = new StringBuilder ( ) ; String character ; String entity ; int lastIndex = 0 ; while ( matcher . find ( ) ) { final int idx = matcher . start ( ) ; result . append ( text . substring ( lastIndex , idx ) ) ; lastIndex = matcher . end ( ) ; character = matcher . group ( ) ; if ( character . length ( ) == 1 ) { entity = transTbl . get ( Character . valueOf ( character . charAt ( 0 ) ) ) ; if ( entity != null ) { entity = "&" + entity + ";" ; } else { entity = character ; } } else { entity = character ; } result . append ( entity ) ; } if ( lastIndex < text . length ( ) ) { result . append ( text . substring ( lastIndex ) ) ; } return result . toString ( ) ; }
Translate all the special character from the given text to their equivalent HTML entities .
6,014
public static void cutStringAsArray ( String text , CutStringCritera critera , List < String > output ) { cutStringAlgo ( text , critera , new CutStringToArray ( output ) ) ; }
Format the text to be sure that each line is not more longer than the specified critera .
6,015
public static char getMnemonicChar ( String text ) { if ( text != null ) { final int pos = text . indexOf ( '&' ) ; if ( ( pos != - 1 ) && ( pos < text . length ( ) - 1 ) ) { return text . charAt ( pos + 1 ) ; } } return '\0' ; }
Replies the character which follow the first &amp ; .
6,016
public static String removeMnemonicChar ( String text ) { if ( text == null ) { return text ; } return text . replaceFirst ( "&" , "" ) ; }
Remove the mnemonic char from the specified string .
6,017
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static Map < Character , String > getAccentTranslationTable ( ) { Map < Character , String > map = null ; try { LOCK . lock ( ) ; if ( accentTransTbl != null ) { map = accentTransTbl . get ( ) ; } } finally { LOCK . unlock ( ) ; } if ( map != null ) { return map ; } ResourceBundle resource = null ; try { resource = ResourceBundle . getBundle ( TextUtil . class . getCanonicalName ( ) , java . util . Locale . getDefault ( ) ) ; } catch ( MissingResourceException exep ) { return null ; } final String result ; try { result = resource . getString ( "ACCENT_TRANS_TBL" ) ; } catch ( Exception e ) { return null ; } map = new TreeMap < > ( ) ; final String [ ] pairs = result . split ( "(\\}\\{)|\\{|\\}" ) ; for ( final String pair : pairs ) { if ( pair . length ( ) > 1 ) { map . put ( pair . charAt ( 0 ) , pair . substring ( 1 ) ) ; } } try { LOCK . lock ( ) ; accentTransTbl = new SoftReference < > ( map ) ; } finally { LOCK . unlock ( ) ; } return map ; }
Replies the accent s translation table .
6,018
public static String removeAccents ( String text ) { final Map < Character , String > map = getAccentTranslationTable ( ) ; if ( ( map == null ) || ( map . isEmpty ( ) ) ) { return text ; } return removeAccents ( text , map ) ; }
Remove the accents inside the specified string .
6,019
public static String [ ] split ( char leftSeparator , char rightSeparator , String str ) { final SplitSeparatorToArrayAlgorithm algo = new SplitSeparatorToArrayAlgorithm ( ) ; splitSeparatorAlgorithm ( leftSeparator , rightSeparator , str , algo ) ; return algo . toArray ( ) ; }
Split the given string according to the separators . The separators are used to delimit the groups of characters .
6,020
public static < T > String join ( char leftSeparator , char rightSeparator , @ SuppressWarnings ( "unchecked" ) T ... strs ) { final StringBuilder buffer = new StringBuilder ( ) ; for ( final Object s : strs ) { buffer . append ( leftSeparator ) ; if ( s != null ) { buffer . append ( s . toString ( ) ) ; } buffer . append ( rightSeparator ) ; } return buffer . toString ( ) ; }
Merge the given strings with to separators . The separators are used to delimit the groups of characters .
6,021
public static String toUpperCaseWithoutAccent ( String text , Map < Character , String > map ) { final StringBuilder buffer = new StringBuilder ( ) ; for ( final char c : text . toCharArray ( ) ) { final String trans = map . get ( c ) ; if ( trans != null ) { buffer . append ( trans . toUpperCase ( ) ) ; } else { buffer . append ( Character . toUpperCase ( c ) ) ; } } return buffer . toString ( ) ; }
Translate the specified string to upper case and remove the accents .
6,022
public static String formatDouble ( double amount , int decimalCount ) { final int dc = ( decimalCount < 0 ) ? 0 : decimalCount ; final StringBuilder str = new StringBuilder ( "#0" ) ; if ( dc > 0 ) { str . append ( '.' ) ; for ( int i = 0 ; i < dc ; ++ i ) { str . append ( '0' ) ; } } final DecimalFormat fmt = new DecimalFormat ( str . toString ( ) ) ; return fmt . format ( amount ) ; }
Format the given double value .
6,023
public static int getLevenshteinDistance ( String firstString , String secondString ) { final String s0 = firstString == null ? "" : firstString ; final String s1 = secondString == null ? "" : secondString ; final int len0 = s0 . length ( ) + 1 ; final int len1 = s1 . length ( ) + 1 ; int [ ] cost = new int [ len0 ] ; int [ ] newcost = new int [ len0 ] ; for ( int i = 0 ; i < len0 ; ++ i ) { cost [ i ] = i ; } for ( int j = 1 ; j < len1 ; ++ j ) { newcost [ 0 ] = j ; for ( int i = 1 ; i < len0 ; ++ i ) { final int match = ( s0 . charAt ( i - 1 ) == s1 . charAt ( j - 1 ) ) ? 0 : 1 ; final int costReplace = cost [ i - 1 ] + match ; final int costInsert = cost [ i ] + 1 ; final int costDelete = newcost [ i - 1 ] + 1 ; newcost [ i ] = Math . min ( Math . min ( costInsert , costDelete ) , costReplace ) ; } final int [ ] swap = cost ; cost = newcost ; newcost = swap ; } return cost [ len0 - 1 ] ; }
Compute the Levenshstein distance between two strings .
6,024
public static String toJavaString ( String text ) { final StringEscaper escaper = new StringEscaper ( ) ; return escaper . escape ( text ) ; }
Translate the given string to its Java string equivalent . All the special characters will be escaped . The enclosing double quote characters are not added .
6,025
public static String toJsonString ( String text ) { final StringEscaper escaper = new StringEscaper ( StringEscaper . JAVA_ESCAPE_CHAR , StringEscaper . JAVA_STRING_CHAR , StringEscaper . JAVA_ESCAPE_CHAR , StringEscaper . JSON_SPECIAL_ESCAPED_CHAR ) ; return escaper . escape ( text ) ; }
Translate the given string to its Json string equivalent . All the special characters will be escaped . The enclosing double quote characters are not added .
6,026
public static VariableDecls extend ( Binder binder ) { return new VariableDecls ( io . bootique . BQCoreModule . extend ( binder ) ) ; }
Create an extended from the given binder .
6,027
public VariableDecls declareVar ( String bootiqueVariable ) { this . extender . declareVar ( bootiqueVariable , VariableNames . toEnvironmentVariableName ( bootiqueVariable ) ) ; return this ; }
Declare an environment variable which is linked to the given Bootique variable and has its name defined from the name of the Bootique variable .
6,028
protected void initializeElements ( ) { final BusItinerary itinerary = getBusItinerary ( ) ; if ( itinerary != null ) { int i = 0 ; for ( final BusItineraryHalt halt : itinerary . busHalts ( ) ) { onBusItineraryHaltAdded ( halt , i , null ) ; ++ i ; } } }
Run the initialization of the elements from the current bus itinerary .
6,029
@ SuppressWarnings ( "unchecked" ) protected static < VALUET > VALUET maskNull ( VALUET value ) { return ( value == null ) ? ( VALUET ) NULL_VALUE : value ; }
Mask the null values given by the used of this map .
6,030
protected static < VALUET > VALUET unmaskNull ( VALUET value ) { return ( value == NULL_VALUE ) ? null : value ; }
Unmask the null values given by the used of this map .
6,031
@ SuppressWarnings ( "unchecked" ) static < T > T [ ] finishToArray ( T [ ] array , Iterator < ? > it ) { T [ ] rp = array ; int i = rp . length ; while ( it . hasNext ( ) ) { final int cap = rp . length ; if ( i == cap ) { int newCap = ( ( cap / 2 ) + 1 ) * 3 ; if ( newCap <= cap ) { if ( cap == Integer . MAX_VALUE ) { throw new OutOfMemoryError ( ) ; } newCap = Integer . MAX_VALUE ; } rp = Arrays . copyOf ( rp , newCap ) ; } rp [ ++ i ] = ( T ) it . next ( ) ; } return ( i == rp . length ) ? rp : Arrays . copyOf ( rp , i ) ; }
Reallocates the array being used within toArray when the iterator returned more elements than expected and finishes filling it from the iterator .
6,032
protected final ReferencableValue < K , V > makeValue ( K key , V value ) { return makeValue ( key , value , this . queue ) ; }
Create a storage object that permits to put the specified elements inside this map .
6,033
public static String getFirstFreeBusItineraryName ( BusLine busline ) { if ( busline == null ) { return null ; } int nb = busline . getBusItineraryCount ( ) ; String name ; do { ++ nb ; name = Locale . getString ( "NAME_TEMPLATE" , Integer . toString ( nb ) ) ; } while ( busline . getBusItinerary ( name ) != null ) ; return name ; }
Replies a bus itinerary name that was not exist in the specified bus line .
6,034
public void invert ( ) { final boolean isEventFirable = isEventFirable ( ) ; setEventFirable ( false ) ; try { final int count = this . roadSegments . getRoadSegmentCount ( ) ; this . roadSegments . invert ( ) ; 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" , null , null ) ) ; }
Invert the order of this itinerary .
6,035
public boolean hasBusHaltOnSegment ( RoadSegment segment ) { if ( this . roadSegments . isEmpty ( ) || this . validHalts . isEmpty ( ) ) { return false ; } int cIdxSegment ; int lIdxSegment = - 1 ; RoadSegment cSegment ; for ( final BusItineraryHalt bushalt : this . validHalts ) { cIdxSegment = bushalt . getRoadSegmentIndex ( ) ; if ( cIdxSegment >= 0 && cIdxSegment < this . roadSegments . getRoadSegmentCount ( ) && cIdxSegment != lIdxSegment ) { cSegment = this . roadSegments . getRoadSegmentAt ( cIdxSegment ) ; lIdxSegment = cIdxSegment ; if ( segment == cSegment ) { return true ; } } } return false ; }
Replies if the given segment has a bus halt on it .
6,036
public List < BusItineraryHalt > getBusHaltsOnSegment ( RoadSegment segment ) { if ( this . roadSegments . isEmpty ( ) || this . validHalts . isEmpty ( ) ) { return Collections . emptyList ( ) ; } int cIdxSegment ; int lIdxSegment = - 1 ; int sIdxSegment = - 1 ; RoadSegment cSegment ; final List < BusItineraryHalt > halts = new ArrayList < > ( ) ; for ( final BusItineraryHalt bushalt : this . validHalts ) { cIdxSegment = bushalt . getRoadSegmentIndex ( ) ; if ( cIdxSegment >= 0 && cIdxSegment < this . roadSegments . getRoadSegmentCount ( ) && cIdxSegment != lIdxSegment ) { cSegment = this . roadSegments . getRoadSegmentAt ( cIdxSegment ) ; lIdxSegment = cIdxSegment ; if ( segment == cSegment ) { sIdxSegment = cIdxSegment ; } else if ( sIdxSegment != - 1 ) { break ; } } if ( sIdxSegment != - 1 ) { halts . add ( bushalt ) ; } } return halts ; }
Replies the bus halts on the given segment .
6,037
public Map < BusItineraryHalt , Pair < Integer , Double > > getBusHaltBinding ( ) { final Comparator < BusItineraryHalt > comp = ( elt1 , elt2 ) -> { if ( elt1 == elt2 ) { return 0 ; } if ( elt1 == null ) { return - 1 ; } if ( elt2 == null ) { return 1 ; } return elt1 . getName ( ) . compareTo ( elt2 . getName ( ) ) ; } ; final Map < BusItineraryHalt , Pair < Integer , Double > > haltBinding = new TreeMap < > ( comp ) ; for ( final BusItineraryHalt halt : busHalts ( ) ) { haltBinding . put ( halt , new Pair < > ( halt . getRoadSegmentIndex ( ) , halt . getPositionOnSegment ( ) ) ) ; } return haltBinding ; }
Replies the binding informations for all the bus halts of this itinerary .
6,038
public void setBusHaltBinding ( Map < BusItineraryHalt , Pair < Integer , Float > > binding ) { if ( binding != null ) { BusItineraryHalt halt ; boolean shapeChanged = false ; for ( final Entry < BusItineraryHalt , Pair < Integer , Float > > entry : binding . entrySet ( ) ) { halt = entry . getKey ( ) ; halt . setRoadSegmentIndex ( entry . getValue ( ) . getKey ( ) ) ; halt . setPositionOnSegment ( entry . getValue ( ) . getValue ( ) ) ; halt . checkPrimitiveValidity ( ) ; shapeChanged = true ; } if ( shapeChanged ) { fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ITINERARY_CHANGED , null , - 1 , "shape" , null , null ) ) ; } checkPrimitiveValidity ( ) ; } }
Set the binding informations for all the bus halts of this itinerary .
6,039
public double getLength ( ) { double length = this . roadSegments . getLength ( ) ; if ( isValidPrimitive ( ) ) { BusItineraryHalt halt = this . validHalts . get ( 0 ) ; assert halt != null ; RoadSegment sgmt = halt . getRoadSegment ( ) ; assert sgmt != null ; Direction1D dir = this . roadSegments . getRoadSegmentDirectionAt ( halt . getRoadSegmentIndex ( ) ) ; assert dir != null ; if ( dir == Direction1D . SEGMENT_DIRECTION ) { length -= halt . getPositionOnSegment ( ) ; } else { length -= sgmt . getLength ( ) - halt . getPositionOnSegment ( ) ; } halt = this . validHalts . get ( this . validHalts . size ( ) - 1 ) ; assert halt != null ; sgmt = halt . getRoadSegment ( ) ; assert sgmt != null ; dir = this . roadSegments . getRoadSegmentDirectionAt ( halt . getRoadSegmentIndex ( ) ) ; assert dir != null ; if ( dir == Direction1D . SEGMENT_DIRECTION ) { length -= sgmt . getLength ( ) - halt . getPositionOnSegment ( ) ; } else { length -= halt . getPositionOnSegment ( ) ; } if ( length < 0. ) { length = 0. ; } } return length ; }
Replies the length of this itinerary .
6,040
public double getDistanceBetweenBusHalts ( int firsthaltIndex , int lasthaltIndex ) { if ( firsthaltIndex < 0 || firsthaltIndex >= this . validHalts . size ( ) - 1 ) { throw new ArrayIndexOutOfBoundsException ( firsthaltIndex ) ; } if ( lasthaltIndex <= firsthaltIndex || lasthaltIndex >= this . validHalts . size ( ) ) { throw new ArrayIndexOutOfBoundsException ( lasthaltIndex ) ; } double length = 0 ; final BusItineraryHalt b1 = this . validHalts . get ( firsthaltIndex ) ; final BusItineraryHalt b2 = this . validHalts . get ( lasthaltIndex ) ; final int firstSegment = b1 . getRoadSegmentIndex ( ) ; final int lastSegment = b2 . getRoadSegmentIndex ( ) ; for ( int i = firstSegment + 1 ; i < lastSegment ; ++ i ) { final RoadSegment segment = this . roadSegments . getRoadSegmentAt ( i ) ; length += segment . getLength ( ) ; } Direction1D direction = getRoadSegmentDirection ( firstSegment ) ; if ( direction . isRevertedSegmentDirection ( ) ) { length += b1 . getPositionOnSegment ( ) ; } else { length += this . roadSegments . getRoadSegmentAt ( firstSegment ) . getLength ( ) - b1 . getPositionOnSegment ( ) ; } direction = getRoadSegmentDirection ( lastSegment ) ; if ( direction . isSegmentDirection ( ) ) { length += b2 . getPositionOnSegment ( ) ; } else { length += this . roadSegments . getRoadSegmentAt ( firstSegment ) . getLength ( ) - b2 . getPositionOnSegment ( ) ; } return length ; }
Replies the distance between two bus halt .
6,041
boolean addBusHalt ( BusItineraryHalt halt , int insertToIndex ) { if ( insertToIndex < 0 ) { halt . setInvalidListIndex ( this . insertionIndex ) ; } else { halt . setInvalidListIndex ( insertToIndex ) ; } if ( halt . isValidPrimitive ( ) ) { ListUtil . addIfAbsent ( this . validHalts , VALID_HALT_COMPARATOR , halt ) ; } else { ListUtil . addIfAbsent ( this . invalidHalts , INVALID_HALT_COMPARATOR , halt ) ; } halt . setEventFirable ( isEventFirable ( ) ) ; ++ this . insertionIndex ; if ( isEventFirable ( ) ) { fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ITINERARY_HALT_ADDED , halt , halt . indexInParent ( ) , "shape" , null , null ) ) ; checkPrimitiveValidity ( ) ; } return true ; }
Add the given bus halt in this itinerary .
6,042
public void removeAllBusHalts ( ) { for ( final BusItineraryHalt bushalt : this . invalidHalts ) { bushalt . setContainer ( null ) ; bushalt . setRoadSegmentIndex ( - 1 ) ; bushalt . setPositionOnSegment ( Float . NaN ) ; bushalt . checkPrimitiveValidity ( ) ; } final BusItineraryHalt [ ] halts = new BusItineraryHalt [ this . validHalts . size ( ) ] ; this . validHalts . toArray ( halts ) ; this . validHalts . clear ( ) ; this . invalidHalts . clear ( ) ; for ( final BusItineraryHalt bushalt : halts ) { bushalt . setContainer ( null ) ; bushalt . setRoadSegmentIndex ( - 1 ) ; bushalt . setPositionOnSegment ( Float . NaN ) ; bushalt . checkPrimitiveValidity ( ) ; } fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ALL_ITINERARY_HALTS_REMOVED , null , - 1 , "shape" , null , null ) ) ; checkPrimitiveValidity ( ) ; }
Remove all the bus halts from the current itinerary .
6,043
public boolean removeBusHalt ( BusItineraryHalt bushalt ) { try { int index = ListUtil . indexOf ( this . validHalts , VALID_HALT_COMPARATOR , bushalt ) ; if ( index >= 0 ) { return removeBusHalt ( index ) ; } index = ListUtil . indexOf ( this . invalidHalts , INVALID_HALT_COMPARATOR , bushalt ) ; if ( index >= 0 ) { index += this . validHalts . size ( ) ; return removeBusHalt ( index ) ; } } catch ( Throwable exception ) { } return false ; }
Remove a bus bus from this itinerary .
6,044
public boolean removeBusHalt ( String name ) { Iterator < BusItineraryHalt > iterator = this . validHalts . iterator ( ) ; BusItineraryHalt bushalt ; int i = 0 ; while ( iterator . hasNext ( ) ) { bushalt = iterator . next ( ) ; if ( name . equals ( bushalt . getName ( ) ) ) { return removeBusHalt ( i ) ; } ++ i ; } iterator = this . invalidHalts . iterator ( ) ; i = 0 ; while ( iterator . hasNext ( ) ) { bushalt = iterator . next ( ) ; if ( name . equals ( bushalt . getName ( ) ) ) { return removeBusHalt ( i ) ; } ++ i ; } return false ; }
Remove the bus halt with the given name .
6,045
public boolean removeBusHalt ( int index ) { try { final BusItineraryHalt removedBushalt ; if ( index < this . validHalts . size ( ) ) { removedBushalt = this . validHalts . remove ( index ) ; } else { final int idx = index - this . validHalts . size ( ) ; removedBushalt = this . invalidHalts . remove ( idx ) ; } removedBushalt . setContainer ( null ) ; removedBushalt . setRoadSegmentIndex ( - 1 ) ; removedBushalt . setPositionOnSegment ( Float . NaN ) ; removedBushalt . setEventFirable ( true ) ; removedBushalt . checkPrimitiveValidity ( ) ; fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ITINERARY_HALT_REMOVED , removedBushalt , removedBushalt . indexInParent ( ) , "shape" , null , null ) ) ; checkPrimitiveValidity ( ) ; return true ; } catch ( Throwable exception ) { } return false ; }
Remove the bus halt at the specified index .
6,046
public int indexOf ( BusItineraryHalt bushalt ) { if ( bushalt == null ) { return - 1 ; } if ( bushalt . isValidPrimitive ( ) ) { return ListUtil . indexOf ( this . validHalts , VALID_HALT_COMPARATOR , bushalt ) ; } int idx = ListUtil . indexOf ( this . invalidHalts , INVALID_HALT_COMPARATOR , bushalt ) ; if ( idx >= 0 ) { idx += this . validHalts . size ( ) ; } return idx ; }
Replies the index of the specified bus halt .
6,047
public boolean contains ( BusItineraryHalt bushalt ) { if ( bushalt == null ) { return false ; } if ( bushalt . isValidPrimitive ( ) ) { return ListUtil . contains ( this . validHalts , VALID_HALT_COMPARATOR , bushalt ) ; } return ListUtil . contains ( this . invalidHalts , INVALID_HALT_COMPARATOR , bushalt ) ; }
Replies if the given bus halt is inside this bus itinerary .
6,048
public BusItineraryHalt getBusHaltAt ( int index ) { if ( index < this . validHalts . size ( ) ) { return this . validHalts . get ( index ) ; } return this . invalidHalts . get ( index - this . validHalts . size ( ) ) ; }
Replies the halt at the specified index .
6,049
public BusItineraryHalt getBusHalt ( UUID uuid ) { if ( uuid == null ) { return null ; } for ( final BusItineraryHalt busHalt : this . validHalts ) { if ( uuid . equals ( busHalt . getUUID ( ) ) ) { return busHalt ; } } for ( final BusItineraryHalt busHalt : this . invalidHalts ) { if ( uuid . equals ( busHalt . getUUID ( ) ) ) { return busHalt ; } } return null ; }
Replies the bus halt with the specified uuid .
6,050
public BusItineraryHalt getBusHalt ( String name , Comparator < String > nameComparator ) { if ( name == null ) { return null ; } final Comparator < String > cmp = nameComparator == null ? BusNetworkUtilities . NAME_COMPARATOR : nameComparator ; for ( final BusItineraryHalt bushalt : this . validHalts ) { if ( cmp . compare ( name , bushalt . getName ( ) ) == 0 ) { return bushalt ; } } for ( final BusItineraryHalt bushalt : this . invalidHalts ) { if ( cmp . compare ( name , bushalt . getName ( ) ) == 0 ) { return bushalt ; } } return null ; }
Replies the bus halt with the specified name .
6,051
public BusItineraryHalt [ ] toBusHaltArray ( ) { final BusItineraryHalt [ ] tab = new BusItineraryHalt [ this . validHalts . size ( ) + this . invalidHalts . size ( ) ] ; int i = 0 ; for ( final BusItineraryHalt h : this . validHalts ) { tab [ i ] = h ; ++ i ; } for ( final BusItineraryHalt h : this . invalidHalts ) { tab [ i ] = h ; ++ i ; } return tab ; }
Replies an array of the bus halts inside this itinerary . This function copy the internal data structures into the array .
6,052
public BusItineraryHalt [ ] toInvalidBusHaltArray ( ) { final BusItineraryHalt [ ] tab = new BusItineraryHalt [ this . invalidHalts . size ( ) ] ; return this . invalidHalts . toArray ( tab ) ; }
Replies an array of the invalid bus halts inside this itinerary . This function copy the internal data structures into the array .
6,053
public BusItineraryHalt [ ] toValidBusHaltArray ( ) { final BusItineraryHalt [ ] tab = new BusItineraryHalt [ this . validHalts . size ( ) ] ; return this . validHalts . toArray ( tab ) ; }
Replies an array of the valid bus halts inside this itinerary . This function copy the internal data structures into the array .
6,054
public RoadSegment getNearestRoadSegment ( Point2D < ? , ? > point ) { assert point != null ; double distance = Double . MAX_VALUE ; RoadSegment nearestSegment = null ; final Iterator < RoadSegment > iterator = this . roadSegments . roadSegments ( ) ; RoadSegment segment ; while ( iterator . hasNext ( ) ) { segment = iterator . next ( ) ; final double d = segment . distance ( point ) ; if ( d < distance ) { distance = d ; nearestSegment = segment ; } } return nearestSegment ; }
Replies the nearest road segment from this itinerary to the given point .
6,055
public boolean addRoadSegments ( RoadPath segments , boolean autoConnectHalts , boolean enableLoopAutoBuild ) { if ( segments == null || segments . isEmpty ( ) ) { return false ; } BusItineraryHalt halt ; RoadSegment sgmt ; final Map < BusItineraryHalt , RoadSegment > haltMapping = new TreeMap < > ( ( obj1 , obj2 ) -> Integer . compare ( System . identityHashCode ( obj1 ) , System . identityHashCode ( obj2 ) ) ) ; final Iterator < BusItineraryHalt > haltIterator = this . validHalts . iterator ( ) ; while ( haltIterator . hasNext ( ) ) { halt = haltIterator . next ( ) ; sgmt = this . roadSegments . getRoadSegmentAt ( halt . getRoadSegmentIndex ( ) ) ; haltMapping . put ( halt , sgmt ) ; } final boolean isValidBefore = isValidPrimitive ( ) ; final RoadPath changedPath = this . roadSegments . addAndGetPath ( segments ) ; if ( changedPath != null ) { if ( enableLoopAutoBuild ) { autoLoop ( isValidBefore , changedPath , segments ) ; } int nIdx ; for ( final Entry < BusItineraryHalt , RoadSegment > entry : haltMapping . entrySet ( ) ) { halt = entry . getKey ( ) ; sgmt = entry . getValue ( ) ; nIdx = this . roadSegments . indexOf ( sgmt ) ; halt . setRoadSegmentIndex ( nIdx ) ; halt . checkPrimitiveValidity ( ) ; } final BusItineraryHalt [ ] tabV = new BusItineraryHalt [ this . validHalts . size ( ) ] ; this . validHalts . toArray ( tabV ) ; this . validHalts . clear ( ) ; for ( final BusItineraryHalt busHalt : tabV ) { assert busHalt != null && busHalt . isValidPrimitive ( ) ; ListUtil . addIfAbsent ( this . validHalts , VALID_HALT_COMPARATOR , busHalt ) ; } if ( this . roadNetwork == null ) { final RoadNetwork network = segments . getFirstSegment ( ) . getRoadNetwork ( ) ; this . roadNetwork = new WeakReference < > ( network ) ; network . addRoadNetworkListener ( this ) ; } fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . SEGMENT_ADDED , segments . getLastSegment ( ) , this . roadSegments . indexOf ( segments . getLastSegment ( ) ) , "shape" , null , null ) ) ; if ( autoConnectHalts ) { putInvalidHaltsOnRoads ( ) ; } else { checkPrimitiveValidity ( ) ; } return true ; } return false ; }
Add road segments inside the bus itinerary .
6,056
@ SuppressWarnings ( "checkstyle:nestedifdepth" ) public boolean putHaltOnRoad ( BusItineraryHalt halt , RoadSegment road ) { if ( contains ( halt ) ) { final BusStop stop = halt . getBusStop ( ) ; if ( stop != null ) { final Point2d stopPosition = stop . getPosition2D ( ) ; if ( stopPosition != null ) { final int idx = indexOf ( road ) ; if ( idx >= 0 ) { final Point1d pos = road . getNearestPosition ( stopPosition ) ; if ( pos != null ) { halt . setRoadSegmentIndex ( idx ) ; halt . setPositionOnSegment ( pos . getCurvilineCoordinate ( ) ) ; halt . checkPrimitiveValidity ( ) ; fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ITINERARY_CHANGED , null , - 1 , "shape" , null , null ) ) ; checkPrimitiveValidity ( ) ; return true ; } } return false ; } } } return true ; }
Put the given bus itinerary halt on the nearest point on road .
6,057
public void removeAllRoadSegments ( ) { for ( final BusItineraryHalt halt : this . invalidHalts ) { halt . setRoadSegmentIndex ( - 1 ) ; halt . setPositionOnSegment ( Float . NaN ) ; halt . checkPrimitiveValidity ( ) ; } final BusItineraryHalt [ ] halts = new BusItineraryHalt [ this . validHalts . size ( ) ] ; this . validHalts . toArray ( halts ) ; for ( final BusItineraryHalt halt : halts ) { halt . setRoadSegmentIndex ( - 1 ) ; halt . setPositionOnSegment ( Float . NaN ) ; halt . checkPrimitiveValidity ( ) ; } if ( this . roadNetwork != null ) { final RoadNetwork network = this . roadNetwork . get ( ) ; if ( network != null ) { network . removeRoadNetworkListener ( this ) ; } this . roadNetwork = null ; } this . roadSegments . clear ( ) ; fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . ALL_SEGMENTS_REMOVED , null , - 1 , "shape" , null , null ) ) ; checkPrimitiveValidity ( ) ; }
Remove all the road segments from the current itinerary .
6,058
public boolean removeRoadSegment ( int segmentIndex ) { if ( segmentIndex >= 0 && segmentIndex < this . roadSegments . getRoadSegmentCount ( ) ) { final RoadSegment segment = this . roadSegments . getRoadSegmentAt ( segmentIndex ) ; if ( segment != null ) { final Map < BusItineraryHalt , RoadSegment > segmentMap = new TreeMap < > ( ( obj1 , obj2 ) -> Integer . compare ( System . identityHashCode ( obj1 ) , System . identityHashCode ( obj2 ) ) ) ; final Iterator < BusItineraryHalt > haltIterator = this . validHalts . iterator ( ) ; while ( haltIterator . hasNext ( ) ) { final BusItineraryHalt halt = haltIterator . next ( ) ; final int sgmtIndex = halt . getRoadSegmentIndex ( ) ; if ( sgmtIndex == segmentIndex ) { segmentMap . put ( halt , null ) ; } else { final RoadSegment sgmt = this . roadSegments . getRoadSegmentAt ( sgmtIndex ) ; segmentMap . put ( halt , sgmt ) ; } } this . roadSegments . removeRoadSegmentAt ( segmentIndex ) ; for ( final Entry < BusItineraryHalt , RoadSegment > entry : segmentMap . entrySet ( ) ) { final BusItineraryHalt halt = entry . getKey ( ) ; final RoadSegment sgmt = entry . getValue ( ) ; if ( sgmt == null ) { halt . setRoadSegmentIndex ( - 1 ) ; halt . setPositionOnSegment ( Float . NaN ) ; halt . checkPrimitiveValidity ( ) ; } else { final int sgmtIndex = halt . getRoadSegmentIndex ( ) ; final int idx = this . roadSegments . indexOf ( sgmt ) ; if ( idx != sgmtIndex ) { halt . setRoadSegmentIndex ( idx ) ; halt . checkPrimitiveValidity ( ) ; } } } if ( this . roadSegments . isEmpty ( ) && this . roadNetwork != null ) { final RoadNetwork network = this . roadNetwork . get ( ) ; if ( network != null ) { network . removeRoadNetworkListener ( this ) ; } this . roadNetwork = null ; } fireShapeChanged ( new BusChangeEvent ( this , BusChangeEventType . SEGMENT_REMOVED , segment , segmentIndex , "shape" , null , null ) ) ; checkPrimitiveValidity ( ) ; return true ; } } return false ; }
Remove a road segment from this itinerary .
6,059
public Iterable < RoadSegment > roadSegments ( ) { return new Iterable < RoadSegment > ( ) { public Iterator < RoadSegment > iterator ( ) { return roadSegmentsIterator ( ) ; } } ; }
Replies the list of the road segments of the bus itinerary .
6,060
@ SuppressWarnings ( "unchecked" ) public static < InT , EqClass > EquivalenceBasedProvenancedAligner < InT , InT , EqClass > forEquivalenceFunction ( Function < ? super InT , ? extends EqClass > equivalenceFunction ) { return new EquivalenceBasedProvenancedAligner < InT , InT , EqClass > ( ( Function < InT , EqClass > ) equivalenceFunction , ( Function < InT , EqClass > ) equivalenceFunction ) ; }
we don t need
6,061
public static String getExecutableFilename ( String name ) { if ( OperatingSystem . WIN . isCurrentOS ( ) ) { return name + ".exe" ; } return name ; }
Replies a binary executable filename depending of the current platform .
6,062
public static String getVMBinary ( ) { final String javaHome = System . getProperty ( "java.home" ) ; final File binDir = new File ( new File ( javaHome ) , "bin" ) ; if ( binDir . isDirectory ( ) ) { File exec = new File ( binDir , getExecutableFilename ( "javaw" ) ) ; if ( exec . isFile ( ) ) { return exec . getAbsolutePath ( ) ; } exec = new File ( binDir , getExecutableFilename ( "java" ) ) ; if ( exec . isFile ( ) ) { return exec . getAbsolutePath ( ) ; } } return null ; }
Replies the current java VM binary .
6,063
@ SuppressWarnings ( "checkstyle:magicnumber" ) public static Process launchVMWithJar ( File jarFile , String ... additionalParams ) throws IOException { final String javaBin = getVMBinary ( ) ; if ( javaBin == null ) { throw new FileNotFoundException ( "java" ) ; } final long totalMemory = Runtime . getRuntime ( ) . maxMemory ( ) / 1024 ; final String userDir = FileSystem . getUserHomeDirectoryName ( ) ; final int nParams = 4 ; final String [ ] params = new String [ additionalParams . length + nParams ] ; params [ 0 ] = javaBin ; params [ 1 ] = "-Xmx" + totalMemory + "k" ; params [ 2 ] = "-jar" ; params [ 3 ] = jarFile . getAbsolutePath ( ) ; System . arraycopy ( additionalParams , 0 , params , nParams , additionalParams . length ) ; return Runtime . getRuntime ( ) . exec ( params , null , new File ( userDir ) ) ; }
Run a jar file inside a new VM .
6,064
@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" } ) public static String [ ] getAllCommandLineParameters ( ) { final int osize = commandLineOptions == null ? 0 : commandLineOptions . size ( ) ; final int psize = commandLineParameters == null ? 0 : commandLineParameters . length ; final int tsize = ( osize > 0 && psize > 0 ) ? 1 : 0 ; final List < String > params = new ArrayList < > ( osize + tsize ) ; if ( osize > 0 ) { List < Object > values ; String name ; String prefix ; String v ; for ( final Entry < String , List < Object > > entry : commandLineOptions . entrySet ( ) ) { name = entry . getKey ( ) ; prefix = ( name . length ( ) > 1 ) ? "--" : "-" ; values = entry . getValue ( ) ; if ( values == null || values . isEmpty ( ) ) { params . add ( prefix + name ) ; } else { for ( final Object value : values ) { if ( value != null ) { v = value . toString ( ) ; if ( v != null && v . length ( ) > 0 ) { params . add ( prefix + name + "=" + v ) ; } else { params . add ( prefix + name ) ; } } } } } } if ( tsize > 0 ) { params . add ( "--" ) ; } final String [ ] tab = new String [ params . size ( ) + psize ] ; params . toArray ( tab ) ; params . clear ( ) ; if ( psize > 0 ) { System . arraycopy ( commandLineParameters , 0 , tab , osize + tsize , psize ) ; } return tab ; }
Replies the command line including the options and the standard parameters .
6,065
public static String shiftCommandLineParameters ( ) { String removed = null ; if ( commandLineParameters != null ) { if ( commandLineParameters . length == 0 ) { commandLineParameters = null ; } else if ( commandLineParameters . length == 1 ) { removed = commandLineParameters [ 0 ] ; commandLineParameters = null ; } else { removed = commandLineParameters [ 0 ] ; final String [ ] newTab = new String [ commandLineParameters . length - 1 ] ; System . arraycopy ( commandLineParameters , 1 , newTab , 0 , commandLineParameters . length - 1 ) ; commandLineParameters = newTab ; } } return removed ; }
Shift the command line parameters by one on the left . The first parameter is removed from the list .
6,066
public static Map < String , List < Object > > getCommandLineOptions ( ) { if ( commandLineOptions != null ) { return Collections . unmodifiableSortedMap ( commandLineOptions ) ; } return Collections . emptyMap ( ) ; }
Replies the command line options .
6,067
public static List < Object > getCommandLineOption ( String name ) { if ( commandLineOptions != null && commandLineOptions . containsKey ( name ) ) { final List < Object > value = commandLineOptions . get ( name ) ; return value == null ? Collections . emptyList ( ) : value ; } return Collections . emptyList ( ) ; }
Replies one command option .
6,068
@ SuppressWarnings ( "static-method" ) public Object getFirstOptionValue ( String optionLabel ) { final List < Object > options = getCommandLineOption ( optionLabel ) ; if ( options == null || options . isEmpty ( ) ) { return null ; } return options . get ( 0 ) ; }
Replies the first value of the option .
6,069
@ SuppressWarnings ( "static-method" ) public List < Object > getOptionValues ( String optionLabel ) { final List < Object > options = getCommandLineOption ( optionLabel ) ; if ( options == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( options ) ; }
Replies the values of the option .
6,070
@ SuppressWarnings ( "static-method" ) public boolean isParameterExists ( int index ) { final String [ ] params = getCommandLineParameters ( ) ; return index >= 0 && index < params . length && params [ index ] != null ; }
Replies if the given index corresponds to a command line parameter .
6,071
private int firstInGroup ( int groupIndex ) { if ( this . pointCoordinates == null ) { throw new IndexOutOfBoundsException ( ) ; } final int count = getGroupCount ( ) ; if ( groupIndex < 0 ) { throw new IndexOutOfBoundsException ( groupIndex + "<0" ) ; } if ( groupIndex >= count ) { throw new IndexOutOfBoundsException ( groupIndex + ">=" + count ) ; } final int g = groupIndex - 1 ; if ( g >= 0 && this . partIndexes != null && g < this . partIndexes . length ) { return this . partIndexes [ g ] ; } return 0 ; }
Replies the starting index of a point in a group .
6,072
private int lastInGroup ( int groupIndex ) { if ( this . pointCoordinates == null ) { throw new IndexOutOfBoundsException ( ) ; } final int count = getGroupCount ( ) ; if ( groupIndex < 0 ) { throw new IndexOutOfBoundsException ( groupIndex + "<0" ) ; } if ( groupIndex >= count ) { throw new IndexOutOfBoundsException ( groupIndex + ">=" + count ) ; } if ( this . partIndexes != null && groupIndex < this . partIndexes . length ) { return this . partIndexes [ groupIndex ] - 2 ; } return this . pointCoordinates . length - 2 ; }
Replies the ending index of a point in a group .
6,073
private int groupIndexForPoint ( int pointIndex ) { if ( this . pointCoordinates == null || pointIndex < 0 || pointIndex >= this . pointCoordinates . length ) { throw new IndexOutOfBoundsException ( ) ; } if ( this . partIndexes == null ) { return 0 ; } for ( int i = 0 ; i < this . partIndexes . length ; ++ i ) { if ( pointIndex < this . partIndexes [ i ] ) { return i ; } } return this . partIndexes . length ; }
Replies the group index inside which the point is located at the specified index .
6,074
public int getPointCountInGroup ( int groupIndex ) { if ( groupIndex == 0 && this . pointCoordinates == null ) { return 0 ; } final int firstInGroup = firstInGroup ( groupIndex ) ; final int lastInGroup = lastInGroup ( groupIndex ) ; return ( lastInGroup - firstInGroup ) / 2 + 1 ; }
Replies the count of points in the specified group .
6,075
public int getPointIndex ( int groupIndex , int position ) { final int groupMemberCount = getPointCountInGroup ( groupIndex ) ; final int pos ; if ( position < 0 ) { pos = 0 ; } else if ( position >= groupMemberCount ) { pos = groupMemberCount - 1 ; } else { pos = position ; } return ( firstInGroup ( groupIndex ) + pos * 2 ) / 2 ; }
Replies the global index of the point that corresponds to the position in the given group .
6,076
public int getPointIndex ( int groupIndex , Point2D < ? , ? > point2d ) { if ( ! this . containsPoint ( point2d , groupIndex ) ) { return - 1 ; } Point2d cur = null ; int pos = - 1 ; for ( int i = 0 ; i < getPointCountInGroup ( groupIndex ) ; ++ i ) { cur = getPointAt ( groupIndex , i ) ; if ( cur . epsilonEquals ( point2d , MapElementConstants . POINT_FUSION_DISTANCE ) ) { pos = i ; break ; } } return ( firstInGroup ( groupIndex ) + pos * 2 ) / 2 ; }
Replies the global index of the point2d in the given group .
6,077
public PointGroup getGroupAt ( int index ) { final int count = getGroupCount ( ) ; if ( index < 0 ) { throw new IndexOutOfBoundsException ( index + "<0" ) ; } if ( index >= count ) { throw new IndexOutOfBoundsException ( index + ">=" + count ) ; } return new PointGroup ( index ) ; }
Replies the part at the specified index .
6,078
public Iterable < PointGroup > groups ( ) { return new Iterable < PointGroup > ( ) { public Iterator < PointGroup > iterator ( ) { return MapComposedElement . this . groupIterator ( ) ; } } ; }
Replies the iterator on the groups .
6,079
public Iterable < Point2d > points ( ) { return new Iterable < Point2d > ( ) { public Iterator < Point2d > iterator ( ) { return MapComposedElement . this . pointIterator ( ) ; } } ; }
Replies the iterator on the points .
6,080
public int addPoint ( double x , double y ) { int pointIndex ; if ( this . pointCoordinates == null ) { this . pointCoordinates = new double [ ] { x , y } ; this . partIndexes = null ; pointIndex = 0 ; } else { double [ ] pts = new double [ this . pointCoordinates . length + 2 ] ; System . arraycopy ( this . pointCoordinates , 0 , pts , 0 , this . pointCoordinates . length ) ; pointIndex = pts . length - 2 ; pts [ pointIndex ] = x ; pts [ pointIndex + 1 ] = y ; this . pointCoordinates = pts ; pts = null ; pointIndex /= 2 ; } fireShapeChanged ( ) ; fireElementChanged ( ) ; return pointIndex ; }
Add the specified point at the end of the last group .
6,081
public int addGroup ( double x , double y ) { int pointIndex ; if ( this . pointCoordinates == null ) { this . pointCoordinates = new double [ ] { x , y } ; this . partIndexes = null ; pointIndex = 0 ; } else { double [ ] pts = new double [ this . pointCoordinates . length + 2 ] ; System . arraycopy ( this . pointCoordinates , 0 , pts , 0 , this . pointCoordinates . length ) ; pointIndex = pts . length - 2 ; pts [ pointIndex ] = x ; pts [ pointIndex + 1 ] = y ; final int groupCount = getGroupCount ( ) ; int [ ] grps = new int [ groupCount ] ; if ( this . partIndexes != null ) { System . arraycopy ( this . partIndexes , 0 , grps , 0 , groupCount - 1 ) ; } grps [ groupCount - 1 ] = pointIndex ; this . pointCoordinates = pts ; pts = null ; this . partIndexes = grps ; grps = null ; pointIndex /= 2 ; } fireShapeChanged ( ) ; fireElementChanged ( ) ; return pointIndex ; }
Add the specified point into a newgroup .
6,082
public MapComposedElement invertPointsIn ( int groupIndex ) { if ( this . pointCoordinates == null ) { throw new IndexOutOfBoundsException ( ) ; } final int grpCount = getGroupCount ( ) ; if ( groupIndex < 0 ) { throw new IndexOutOfBoundsException ( groupIndex + "<0" ) ; } if ( groupIndex > grpCount ) { throw new IndexOutOfBoundsException ( groupIndex + ">" + grpCount ) ; } final int count = this . getPointCountInGroup ( groupIndex ) ; final int first = firstInGroup ( groupIndex ) ; double [ ] tmp = new double [ count * 2 ] ; for ( int i = 0 ; i < count * 2 ; i += 2 ) { tmp [ i ] = this . pointCoordinates [ first + 2 * count - 1 - ( i + 1 ) ] ; tmp [ i + 1 ] = this . pointCoordinates [ first + 2 * count - 1 - i ] ; } System . arraycopy ( tmp , 0 , this . pointCoordinates , first , tmp . length ) ; tmp = null ; return this ; }
invert the points coordinates of this element on the groupIndex in argument .
6,083
public MapComposedElement invert ( ) { if ( this . pointCoordinates == null ) { throw new IndexOutOfBoundsException ( ) ; } double [ ] tmp = new double [ this . pointCoordinates . length ] ; for ( int i = 0 ; i < this . pointCoordinates . length ; i += 2 ) { tmp [ i ] = this . pointCoordinates [ this . pointCoordinates . length - 1 - ( i + 1 ) ] ; tmp [ i + 1 ] = this . pointCoordinates [ this . pointCoordinates . length - 1 - i ] ; } System . arraycopy ( tmp , 0 , this . pointCoordinates , 0 , this . pointCoordinates . length ) ; if ( this . partIndexes != null ) { int [ ] tmpint = new int [ this . partIndexes . length ] ; for ( int i = 0 ; i < this . partIndexes . length ; ++ i ) { tmpint [ this . partIndexes . length - 1 - i ] = this . pointCoordinates . length - this . partIndexes [ i ] ; } System . arraycopy ( tmpint , 0 , this . partIndexes , 0 , this . partIndexes . length ) ; tmpint = null ; } tmp = null ; return this ; }
Invert the order of points coordinates of this element and reorder the groupIndex too .
6,084
public Point2d getPointAt ( int index ) { final int count = getPointCount ( ) ; int idx = index ; if ( idx < 0 ) { idx = count + idx ; } if ( idx < 0 ) { throw new IndexOutOfBoundsException ( idx + "<0" ) ; } if ( idx >= count ) { throw new IndexOutOfBoundsException ( idx + ">=" + count ) ; } return new Point2d ( this . pointCoordinates [ idx * 2 ] , this . pointCoordinates [ idx * 2 + 1 ] ) ; }
Replies the specified point at the given index .
6,085
public Point2d getPointAt ( int groupIndex , int indexInGroup ) { final int startIndex = firstInGroup ( groupIndex ) ; final int groupMemberCount = getPointCountInGroup ( groupIndex ) ; if ( indexInGroup < 0 ) { throw new IndexOutOfBoundsException ( indexInGroup + "<0" ) ; } if ( indexInGroup >= groupMemberCount ) { throw new IndexOutOfBoundsException ( indexInGroup + ">=" + groupMemberCount ) ; } return new Point2d ( this . pointCoordinates [ startIndex + indexInGroup * 2 ] , this . pointCoordinates [ startIndex + indexInGroup * 2 + 1 ] ) ; }
Replies the specified point at the given index in the specified group .
6,086
public boolean removeGroupAt ( int groupIndex ) { try { final int startIndex = firstInGroup ( groupIndex ) ; final int lastIndex = lastInGroup ( groupIndex ) ; final int ptsToRemoveCount = ( lastIndex - startIndex + 2 ) / 2 ; int rest = this . pointCoordinates . length / 2 - ptsToRemoveCount ; if ( rest > 0 ) { rest *= 2 ; final double [ ] newPts = new double [ rest ] ; System . arraycopy ( this . pointCoordinates , 0 , newPts , 0 , startIndex ) ; System . arraycopy ( this . pointCoordinates , lastIndex + 2 , newPts , startIndex , rest - startIndex ) ; this . pointCoordinates = newPts ; if ( this . partIndexes != null ) { for ( int i = groupIndex ; i < this . partIndexes . length ; ++ i ) { this . partIndexes [ i ] -= ptsToRemoveCount * 2 ; } int [ ] newGroups = null ; if ( this . partIndexes . length > 1 ) { newGroups = new int [ this . partIndexes . length - 1 ] ; if ( groupIndex == 0 ) { System . arraycopy ( this . partIndexes , 1 , newGroups , 0 , this . partIndexes . length - 1 ) ; } else { System . arraycopy ( this . partIndexes , 0 , newGroups , 0 , groupIndex - 1 ) ; System . arraycopy ( this . partIndexes , groupIndex , newGroups , groupIndex - 1 , this . partIndexes . length - groupIndex ) ; } } this . partIndexes = newGroups ; } } else { this . pointCoordinates = null ; this . partIndexes = null ; } fireShapeChanged ( ) ; fireElementChanged ( ) ; return true ; } catch ( IndexOutOfBoundsException exception ) { } return false ; }
Remove the specified group .
6,087
public Point2d removePointAt ( int groupIndex , int indexInGroup ) { final int startIndex = firstInGroup ( groupIndex ) ; final int lastIndex = lastInGroup ( groupIndex ) ; final int g = indexInGroup * 2 + startIndex ; if ( g < startIndex ) { throw new IndexOutOfBoundsException ( g + "<" + startIndex ) ; } if ( g > lastIndex ) { throw new IndexOutOfBoundsException ( g + ">" + lastIndex ) ; } final Point2d p = new Point2d ( this . pointCoordinates [ g ] , this . pointCoordinates [ g + 1 ] ) ; final double [ ] newPtsArray ; if ( this . pointCoordinates . length <= 2 ) { newPtsArray = null ; } else { newPtsArray = new double [ this . pointCoordinates . length - 2 ] ; System . arraycopy ( this . pointCoordinates , 0 , newPtsArray , 0 , g ) ; System . arraycopy ( this . pointCoordinates , g + 2 , newPtsArray , g , this . pointCoordinates . length - g - 2 ) ; } this . pointCoordinates = newPtsArray ; if ( this . partIndexes != null ) { for ( int i = groupIndex ; i < this . partIndexes . length ; ++ i ) { this . partIndexes [ i ] -= 2 ; } final int ptsCount = ( lastIndex - startIndex ) / 2 ; if ( ptsCount <= 0 ) { int [ ] newGroups = null ; if ( this . partIndexes . length > 1 ) { newGroups = new int [ this . partIndexes . length - 1 ] ; if ( groupIndex == 0 ) { System . arraycopy ( this . partIndexes , 1 , newGroups , 0 , this . partIndexes . length - 1 ) ; } else { System . arraycopy ( this . partIndexes , 0 , newGroups , 0 , groupIndex - 1 ) ; System . arraycopy ( this . partIndexes , groupIndex , newGroups , groupIndex - 1 , this . partIndexes . length - groupIndex ) ; } } this . partIndexes = newGroups ; } } fireShapeChanged ( ) ; fireElementChanged ( ) ; return p ; }
Remove the specified point at the given index in the specified group .
6,088
private boolean canonize ( int index ) { final int count = getPointCount ( ) ; int ix = index ; if ( ix < 0 ) { ix = count + ix ; } if ( ix < 0 ) { throw new IndexOutOfBoundsException ( ix + "<0" ) ; } if ( ix >= count ) { throw new IndexOutOfBoundsException ( ix + ">=" + count ) ; } final int partIndex = groupIndexForPoint ( ix ) ; final int firstPts = firstInGroup ( partIndex ) ; final int endPts = lastInGroup ( partIndex ) ; final int myIndex = ix * 2 ; int firstToRemove = myIndex ; int lastToRemove = myIndex ; boolean removeOne = false ; final double xbase = this . pointCoordinates [ ix * 2 ] ; final double ybase = this . pointCoordinates [ ix * 2 + 1 ] ; final PointFusionValidator validator = getPointFusionValidator ( ) ; for ( int idx = myIndex - 2 ; idx >= firstPts ; idx -= 2 ) { final double x = this . pointCoordinates [ idx ] ; final double y = this . pointCoordinates [ idx + 1 ] ; if ( validator . isSame ( xbase , ybase , x , y ) ) { firstToRemove = idx ; removeOne = true ; } else { break ; } } for ( int idx = myIndex + 2 ; idx <= endPts ; idx += 2 ) { final double x = this . pointCoordinates [ idx ] ; final double y = this . pointCoordinates [ idx + 1 ] ; if ( validator . isSame ( xbase , ybase , x , y ) ) { lastToRemove = idx ; removeOne = true ; } else { break ; } } if ( removeOne ) { final int removalCount = ( lastToRemove / 2 - firstToRemove / 2 ) * 2 ; final double [ ] newPtsArray = new double [ this . pointCoordinates . length - removalCount ] ; assert newPtsArray . length >= 2 ; System . arraycopy ( this . pointCoordinates , 0 , newPtsArray , 0 , firstToRemove ) ; System . arraycopy ( this . pointCoordinates , lastToRemove + 2 , newPtsArray , firstToRemove + 2 , this . pointCoordinates . length - lastToRemove - 2 ) ; newPtsArray [ firstToRemove ] = xbase ; newPtsArray [ firstToRemove + 1 ] = ybase ; this . pointCoordinates = newPtsArray ; if ( this . partIndexes != null ) { for ( int i = partIndex ; i < this . partIndexes . length ; ++ i ) { this . partIndexes [ i ] -= removalCount ; } } return true ; } return false ; }
Remove unnecessary points from the specified index .
6,089
private Optional < IncludeAllPageWithOutput > addOutputInformation ( IncludeAllPage pages , FileResource baseResource , Path includeAllBasePath , Locale locale ) { if ( pages . depth == 0 ) { return of ( new IncludeAllPageWithOutput ( pages , pages . files . get ( 0 ) , pages . files . get ( 0 ) . getPath ( ) , locale ) ) ; } Path baseResourceParentPath = baseResource . getPath ( ) . getParent ( ) ; Optional < FileResource > virtualResource = pages . files . stream ( ) . findFirst ( ) . map ( fr -> new VirtualPathFileResource ( baseResourceParentPath . resolve ( includeAllBasePath . relativize ( fr . getPath ( ) ) . toString ( ) ) , fr ) ) ; return virtualResource . map ( vr -> { Path finalOutputPath = outputPathExtractor . apply ( vr ) . normalize ( ) ; return new IncludeAllPageWithOutput ( pages , vr , finalOutputPath , locale ) ; } ) ; }
generate the final output path
6,090
public Reactor getReactorByIndex ( int index ) { if ( index < 0 || index > reactorSet . length - 1 ) { throw new ArrayIndexOutOfBoundsException ( ) ; } return reactorSet [ index ] ; }
Find reactor by index
6,091
@ SuppressWarnings ( "rawtypes" ) public static CompoundPainter getCompoundPainter ( final Color matte , final Color gloss , final GlossPainter . GlossPosition position , final double angle , final Color pinstripe ) { final MattePainter mp = new MattePainter ( matte ) ; final GlossPainter gp = new GlossPainter ( gloss , position ) ; final PinstripePainter pp = new PinstripePainter ( pinstripe , angle ) ; final CompoundPainter compoundPainter = new CompoundPainter ( mp , pp , gp ) ; return compoundPainter ; }
Gets a CompoundPainter object .
6,092
@ SuppressWarnings ( "rawtypes" ) public static CompoundPainter getCompoundPainter ( final Color color , final GlossPainter . GlossPosition position , final double angle ) { final MattePainter mp = new MattePainter ( color ) ; final GlossPainter gp = new GlossPainter ( color , position ) ; final PinstripePainter pp = new PinstripePainter ( color , angle ) ; final CompoundPainter compoundPainter = new CompoundPainter ( mp , pp , gp ) ; return compoundPainter ; }
Gets the compound painter .
6,093
public static MattePainter getMattePainter ( final int width , final int height , final float [ ] fractions , final Color ... colors ) { final LinearGradientPaint gradientPaint = new LinearGradientPaint ( 0.0f , 0.0f , width , height , fractions , colors ) ; final MattePainter mattePainter = new MattePainter ( gradientPaint ) ; return mattePainter ; }
Gets a MattePainter object .
6,094
public void set ( Point3D center , double radius1 ) { this . cx = center . getX ( ) ; this . cy = center . getY ( ) ; this . cz = center . getZ ( ) ; this . radius = Math . abs ( radius1 ) ; }
Change the frame of te sphere .
6,095
public ListProperty < T > elementsProperty ( ) { if ( this . elements == null ) { this . elements = new SimpleListProperty < > ( this , MathFXAttributeNames . ELEMENTS , new InternalObservableList < > ( ) ) ; } return this . elements ; }
Replies the property that contains all the shapes in this multishape .
6,096
@ SuppressWarnings ( "unchecked" ) protected static < E > Class < ? extends E > extractClassFrom ( Collection < ? extends E > collection ) { Class < ? extends E > clazz = null ; for ( final E elt : collection ) { clazz = ( Class < ? extends E > ) ReflectionUtil . getCommonType ( clazz , elt . getClass ( ) ) ; } return clazz == null ? ( Class < E > ) Object . class : clazz ; }
Extract the upper class that contains all the elements of this array .
6,097
public HelpSet getHelpSet ( ) { HelpSet hs = null ; final String filename = "simple-hs.xml" ; final String path = "help/" + filename ; URL hsURL ; hsURL = ClassExtensions . getResource ( path ) ; try { if ( hsURL != null ) { hs = new HelpSet ( ClassExtensions . getClassLoader ( ) , hsURL ) ; } else { hs = new HelpSet ( ) ; } } catch ( final HelpSetException e ) { String title = e . getLocalizedMessage ( ) ; String htmlMessage = "<html><body width='650'>" + "<h2>" + title + "</h2>" + "<p>" + e . getMessage ( ) + "\n" + path ; JOptionPane . showMessageDialog ( this . getParent ( ) , htmlMessage , title , JOptionPane . ERROR_MESSAGE ) ; log . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } return hs ; }
Gets the help set .
6,098
protected JMenu newHelpMenu ( final ActionListener listener ) { final JMenu menuHelp = new JMenu ( newLabelTextHelp ( ) ) ; menuHelp . setMnemonic ( 'H' ) ; final JMenuItem mihHelpContent = JComponentFactory . newJMenuItem ( newLabelTextContent ( ) , 'c' , 'H' ) ; menuHelp . add ( mihHelpContent ) ; CSH . setHelpIDString ( mihHelpContent , newLabelTextOverview ( ) ) ; final CSH . DisplayHelpFromSource displayHelpFromSource = new CSH . DisplayHelpFromSource ( helpBroker ) ; mihHelpContent . addActionListener ( displayHelpFromSource ) ; final JMenuItem mihDonate = new JMenuItem ( newLabelTextDonate ( ) ) ; mihDonate . addActionListener ( newOpenBrowserToDonateAction ( newLabelTextDonate ( ) , applicationFrame ) ) ; menuHelp . add ( mihDonate ) ; final JMenuItem mihLicence = new JMenuItem ( newLabelTextLicence ( ) ) ; mihLicence . addActionListener ( newShowLicenseFrameAction ( newLabelTextLicence ( ) + "Action" , newLabelTextLicence ( ) ) ) ; menuHelp . add ( mihLicence ) ; final JMenuItem mihInfo = new JMenuItem ( newLabelTextInfo ( ) , 'i' ) ; MenuExtensions . setCtrlAccelerator ( mihInfo , 'I' ) ; mihInfo . addActionListener ( newShowInfoDialogAction ( newLabelTextInfo ( ) , ( Frame ) applicationFrame , newLabelTextInfo ( ) ) ) ; menuHelp . add ( mihInfo ) ; return menuHelp ; }
Creates the help menu .
6,099
protected JMenu newLookAndFeelMenu ( final ActionListener listener ) { final JMenu menuLookAndFeel = new JMenu ( "Look and Feel" ) ; menuLookAndFeel . setMnemonic ( 'L' ) ; JMenuItem jmiPlafGTK ; jmiPlafGTK = new JMenuItem ( "GTK" , 'g' ) ; MenuExtensions . setCtrlAccelerator ( jmiPlafGTK , 'G' ) ; jmiPlafGTK . addActionListener ( new LookAndFeelGTKAction ( "GTK" , this . applicationFrame ) ) ; menuLookAndFeel . add ( jmiPlafGTK ) ; JMenuItem jmiPlafMetal ; jmiPlafMetal = new JMenuItem ( "Metal" , 'm' ) ; MenuExtensions . setCtrlAccelerator ( jmiPlafMetal , 'M' ) ; jmiPlafMetal . addActionListener ( new LookAndFeelMetalAction ( "Metal" , this . applicationFrame ) ) ; menuLookAndFeel . add ( jmiPlafMetal ) ; JMenuItem jmiPlafOcean ; jmiPlafOcean = new JMenuItem ( "Ocean" , 'o' ) ; MenuExtensions . setCtrlAccelerator ( jmiPlafOcean , 'O' ) ; jmiPlafOcean . addActionListener ( new LookAndFeelMetalAction ( "Ocean" , this . applicationFrame ) ) ; menuLookAndFeel . add ( jmiPlafOcean ) ; JMenuItem jmiPlafMotiv ; jmiPlafMotiv = new JMenuItem ( "Motif" , 't' ) ; MenuExtensions . setCtrlAccelerator ( jmiPlafMotiv , 'T' ) ; jmiPlafMotiv . addActionListener ( new LookAndFeelMotifAction ( "Motif" , this . applicationFrame ) ) ; menuLookAndFeel . add ( jmiPlafMotiv ) ; JMenuItem jmiPlafNimbus ; jmiPlafNimbus = new JMenuItem ( "Nimbus" , 'n' ) ; MenuExtensions . setCtrlAccelerator ( jmiPlafNimbus , 'N' ) ; jmiPlafNimbus . addActionListener ( new LookAndFeelNimbusAction ( "Nimbus" , this . applicationFrame ) ) ; menuLookAndFeel . add ( jmiPlafNimbus ) ; JMenuItem jmiPlafSystem ; jmiPlafSystem = new JMenuItem ( "System" , 'd' ) ; MenuExtensions . setCtrlAccelerator ( jmiPlafSystem , 'W' ) ; jmiPlafSystem . addActionListener ( new LookAndFeelSystemAction ( "System" , this . applicationFrame ) ) ; menuLookAndFeel . add ( jmiPlafSystem ) ; return menuLookAndFeel ; }
Creates the look and feel menu .