idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
5,900
public static Vector2dfx convert ( Tuple2D < ? > tuple ) { if ( tuple instanceof Vector2dfx ) { return ( Vector2dfx ) tuple ; } return new Vector2dfx ( tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Vector2dfx .
5,901
public static Point2d convert ( Tuple2D < ? > tuple ) { if ( tuple instanceof Point2d ) { return ( Point2d ) tuple ; } return new Point2d ( tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Point2d .
5,902
public static < R , C , V , C2 > ImmutableTable < R , C2 , V > columnTransformerByCell ( final Table < R , C , V > table , final Function < Table . Cell < R , C , V > , C2 > columnTransformer ) { final ImmutableTable . Builder < R , C2 , V > newTable = ImmutableTable . builder ( ) ; for ( Table . Cell < R , C , V > cell : table . cellSet ( ) ) { C2 col = columnTransformer . apply ( cell ) ; newTable . put ( cell . getRowKey ( ) , col , cell . getValue ( ) ) ; } return newTable . build ( ) ; }
columnTransformer has access to Key Value information in each Table . Cell
5,903
public static double setDistanceEpsilon ( double newPrecisionValue ) { if ( ( newPrecisionValue >= 1 ) || ( newPrecisionValue <= 0 ) ) { throw new IllegalArgumentException ( ) ; } final double old = distancePrecision ; distancePrecision = newPrecisionValue ; return old ; }
Replies the precision used to test a distance value .
5,904
public static boolean epsilonEqualsDistance ( double value1 , double value2 ) { return value1 >= ( value2 - distancePrecision ) && value1 <= ( value2 + distancePrecision ) ; }
Replies if the specified distances are approximatively equal .
5,905
public static int epsilonCompareToDistance ( double distance1 , double distance2 ) { final double min = distance2 - distancePrecision ; final double max = distance2 + distancePrecision ; if ( distance1 >= min && distance1 <= max ) { return 0 ; } if ( distance1 < min ) { return - 1 ; } return 1 ; }
Replies if the specified distances are approximatively equal less or greater than .
5,906
public static String makeInternalId ( float x , float y ) { final StringBuilder buf = new StringBuilder ( "point" ) ; buf . append ( x ) ; buf . append ( ';' ) ; buf . append ( y ) ; return Encryption . md5 ( buf . toString ( ) ) ; }
Compute and replies the internal identifier that may be used to create a GeoId from the given point .
5,907
public static String makeInternalId ( UUID uid ) { final StringBuilder buf = new StringBuilder ( "nowhere(?" ) ; buf . append ( uid . toString ( ) ) ; buf . append ( "?)" ) ; return Encryption . md5 ( buf . toString ( ) ) ; }
Compute and replies the internal identifier that may be used to create a GeoId from the given identifier . The replied identifier is not geolocalized .
5,908
public static String makeInternalId ( float minx , float miny , float maxx , float maxy ) { final StringBuilder buf = new StringBuilder ( "rectangle" ) ; buf . append ( '(' ) ; buf . append ( minx ) ; buf . append ( ';' ) ; buf . append ( miny ) ; buf . append ( ")-(" ) ; buf . append ( maxx ) ; buf . append ( ';' ) ; buf . append ( maxy ) ; buf . append ( ')' ) ; return Encryption . md5 ( buf . toString ( ) ) ; }
Compute and replies the internal identifier that may be used to create a GeoId from the given rectangle .
5,909
public static String get2BitCrid ( String str ) { if ( str != null ) { String crid = LookupCodes . lookupCode ( "CRID" , str , "DSSAT" ) ; if ( crid . equals ( str ) && crid . length ( ) > 2 ) { crid = def2BitVal ; } return crid . toUpperCase ( ) ; } else { return def2BitVal ; } }
get 2 - bit version of crop id by given string
5,910
public static String get3BitCrid ( String str ) { if ( str != null ) { return LookupCodes . lookupCode ( "CRID" , str , "code" , "DSSAT" ) . toUpperCase ( ) ; } else { return def3BitVal ; } }
get 3 - bit version of crop id by given string
5,911
private static CharBuffer decodeString ( byte [ ] bytes , Charset charset , int referenceLength ) { try { final Charset autodetectedCharset ; final CharsetDecoder decoder = charset . newDecoder ( ) ; final CharBuffer buffer = decoder . decode ( ByteBuffer . wrap ( bytes ) ) ; if ( ( decoder . isAutoDetecting ( ) ) && ( decoder . isCharsetDetected ( ) ) ) { autodetectedCharset = decoder . detectedCharset ( ) ; if ( charset . contains ( autodetectedCharset ) ) { buffer . position ( 0 ) ; if ( ( referenceLength >= 0 ) && ( buffer . remaining ( ) == referenceLength ) ) { return buffer ; } return null ; } } buffer . position ( 0 ) ; char c ; int type ; while ( buffer . hasRemaining ( ) ) { c = buffer . get ( ) ; type = Character . getType ( c ) ; switch ( type ) { case Character . UNASSIGNED : case Character . CONTROL : case Character . FORMAT : case Character . PRIVATE_USE : case Character . SURROGATE : return null ; default : } } buffer . position ( 0 ) ; if ( ( referenceLength >= 0 ) && ( buffer . remaining ( ) == referenceLength ) ) { return buffer ; } } catch ( CharacterCodingException e ) { } return null ; }
Decode the specified array of bytes with the specified charset .
5,912
public Iterator < E > iterator ( Rectangle2afp < ? , ? , ? , ? , ? , ? > bounds ) { return new BoundedElementIterator < > ( bounds , iterator ( ) ) ; }
Iterates on the elements that intersect the specified bounds .
5,913
protected HashMap readFile ( HashMap brMap ) throws IOException { HashMap ret = new HashMap ( ) ; ArrayList < HashMap > expArr = new ArrayList < HashMap > ( ) ; HashMap < String , HashMap > files = readObvData ( brMap ) ; ArrayList < HashMap > obvData ; HashMap obv ; HashMap expData ; for ( String exname : files . keySet ( ) ) { obvData = ( ArrayList ) files . get ( exname ) . get ( obvDataKey ) ; for ( HashMap obvSub : obvData ) { expData = new HashMap ( ) ; obv = new HashMap ( ) ; copyItem ( expData , files . get ( exname ) , "exname" ) ; copyItem ( expData , files . get ( exname ) , "crid" ) ; copyItem ( expData , files . get ( exname ) , "local_name" ) ; expData . put ( jsonKey , obv ) ; obv . put ( obvFileKey , obvSub . get ( obvDataKey ) ) ; expArr . add ( expData ) ; } } ArrayList idNames = new ArrayList ( ) ; idNames . add ( "trno_t" ) ; removeIndex ( expArr , idNames ) ; ret . put ( "experiments" , expArr ) ; return ret ; }
DSSAT TFile Data input method for Controller using
5,914
public Path normalizeOutputPath ( FileResource resource ) { Path resourcePath = resource . getPath ( ) ; Path rel = Optional . ofNullable ( ( contentDir . relativize ( resourcePath ) ) . getParent ( ) ) . orElseGet ( ( ) -> resourcePath . getFileSystem ( ) . getPath ( "" ) ) ; String finalOutput = rel . resolve ( finalOutputName ( resource ) ) . toString ( ) ; return outputDir . resolve ( finalOutput ) ; }
Generate the output path given the resource and the output dir .
5,915
public void setModel ( Progression model ) { this . model . removeProgressionListener ( new WeakListener ( this , this . model ) ) ; if ( model == null ) { this . model = new DefaultProgression ( ) ; } else { this . model = model ; } this . previousValue = this . model . getValue ( ) ; this . model . addProgressionListener ( new WeakListener ( this , this . model ) ) ; }
Change the task progression model .
5,916
@ SuppressWarnings ( "static-method" ) protected String buildMessage ( double progress , String comment , boolean isRoot , boolean isFinished , NumberFormat numberFormat ) { final StringBuilder txt = new StringBuilder ( ) ; txt . append ( '[' ) ; txt . append ( numberFormat . format ( progress ) ) ; txt . append ( "] " ) ; if ( comment != null ) { txt . append ( comment ) ; } return txt . toString ( ) ; }
Build the logging message from the given data . This function is defined for enabling overriding in sub classes .
5,917
public boolean setLeftChild ( N newChild ) { final N oldChild = this . left ; if ( oldChild == newChild ) { return false ; } if ( oldChild != null ) { oldChild . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 0 , oldChild ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . left = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 0 , newChild ) ; } return true ; }
Set the left child of this node .
5,918
public boolean setMiddleChild ( N newChild ) { final N oldChild = this . middle ; if ( oldChild == newChild ) { return false ; } if ( oldChild != null ) { oldChild . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 1 , oldChild ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . middle = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 1 , newChild ) ; } return true ; }
Set the middle child of this node .
5,919
public boolean hasChild ( N potentialChild ) { if ( ( this . left == potentialChild ) || ( this . middle == potentialChild ) || ( this . right == potentialChild ) ) { return true ; } return false ; }
Returns true if the specified node is effectively a child of this node false otherwise .
5,920
protected void getHeights ( int currentHeight , List < Integer > heights ) { if ( isLeaf ( ) ) { heights . add ( new Integer ( currentHeight ) ) ; } else { if ( this . left != null ) { this . left . getHeights ( currentHeight + 1 , heights ) ; } if ( this . middle != null ) { this . middle . getHeights ( currentHeight + 1 , heights ) ; } if ( this . right != null ) { this . right . getHeights ( currentHeight + 1 , heights ) ; } } }
Replies the heights of all the leaf nodes . The order of the heights is given by a depth - first iteration .
5,921
private static Iterable < List < Map . Entry < Symbol , File > > > splitToNChunks ( final ImmutableMap < Symbol , File > inputMap , int numChunks ) { checkArgument ( numChunks > 0 ) ; final List < Map . Entry < Symbol , File > > emptyChunk = ImmutableList . of ( ) ; if ( inputMap . isEmpty ( ) ) { return Collections . nCopies ( numChunks , emptyChunk ) ; } final int chunkSize = IntMath . divide ( inputMap . size ( ) , numChunks , RoundingMode . UP ) ; final ImmutableList < List < Map . Entry < Symbol , File > > > chunks = ImmutableList . copyOf ( splitToChunksOfFixedSize ( inputMap , chunkSize ) ) ; if ( chunks . size ( ) == numChunks ) { return chunks ; } else { final int shortage = numChunks - chunks . size ( ) ; final List < List < Map . Entry < Symbol , File > > > padding = Collections . nCopies ( shortage , emptyChunk ) ; return Iterables . concat ( chunks , padding ) ; } }
If there are fewer files than chunks fewer than numChunks will be returned .
5,922
private static ImmutableMap < Symbol , File > loadDocIdToFileMap ( final Optional < File > inputFileListFile , final Optional < File > inputFileMapFile ) throws IOException { checkArgument ( inputFileListFile . isPresent ( ) || inputFileMapFile . isPresent ( ) ) ; final Optional < ImmutableList < File > > fileList ; if ( inputFileListFile . isPresent ( ) ) { fileList = Optional . of ( FileUtils . loadFileList ( inputFileListFile . get ( ) ) ) ; } else { fileList = Optional . absent ( ) ; } final Optional < ImmutableMap < Symbol , File > > fileMap ; if ( inputFileMapFile . isPresent ( ) ) { fileMap = Optional . of ( FileUtils . loadSymbolToFileMap ( inputFileMapFile . get ( ) ) ) ; } else { fileMap = Optional . absent ( ) ; } if ( fileList . isPresent ( ) ) { final boolean containsDuplicates = ImmutableSet . copyOf ( fileList . get ( ) ) . size ( ) != fileList . get ( ) . size ( ) ; if ( containsDuplicates ) { throw new RuntimeException ( "Input file list contains duplicates" ) ; } } if ( fileList . isPresent ( ) && fileMap . isPresent ( ) ) { if ( fileList . get ( ) . size ( ) != fileMap . get ( ) . size ( ) ) { throw new RuntimeException ( "Input file list and file map do not match in size (" + fileList . get ( ) . size ( ) + " vs " + fileMap . get ( ) . size ( ) ) ; } final boolean haveExactlyTheSameFiles = ImmutableSet . copyOf ( fileList . get ( ) ) . equals ( ImmutableSet . copyOf ( fileMap . get ( ) . values ( ) ) ) ; if ( ! haveExactlyTheSameFiles ) { throw new RuntimeException ( "Input file list and file map do not containe exactly the same files" ) ; } } if ( fileMap . isPresent ( ) ) { return fileMap . get ( ) ; } else { final Function < File , Symbol > fileNameAsSymbolFunction = compose ( SymbolUtils . symbolizeFunction ( ) , FileUtils . toAbsolutePathFunction ( ) ) ; return Maps . uniqueIndex ( fileList . get ( ) , fileNameAsSymbolFunction ) ; } }
Gets a doc - id - to - file map for the input either directly or making a fake one based on an input file list .
5,923
public void writeFile ( String arg0 , Map result ) { HashMap culData ; ArrayList < HashMap > culArr ; BufferedWriter bwC ; StringBuilder sbData = new StringBuilder ( ) ; try { setDefVal ( ) ; culData = getObjectOr ( result , "dssat_cultivar_info" , new HashMap ( ) ) ; culArr = getObjectOr ( culData , "data" , new ArrayList ( ) ) ; if ( culArr . isEmpty ( ) ) { return ; } String fileName = getFileName ( result , "X" ) ; if ( fileName . matches ( "TEMP\\d{4}\\.\\w{2}X" ) ) { fileName = "Cultivar.CUL" ; } else { try { fileName = fileName . replaceAll ( "\\." , "_" ) + ".CUL" ; } catch ( Exception e ) { fileName = "Cultivar.CUL" ; } } arg0 = revisePath ( arg0 ) ; outputFile = new File ( arg0 + fileName ) ; bwC = new BufferedWriter ( new FileWriter ( outputFile , outputFile . exists ( ) ) ) ; String lastHeaderInfo = "" ; String lastTitles = "" ; for ( HashMap culSubData : culArr ) { if ( ! getObjectOr ( culSubData , "header_info" , "" ) . equals ( lastHeaderInfo ) ) { lastHeaderInfo = getObjectOr ( culSubData , "header_info" , "" ) ; sbData . append ( lastHeaderInfo ) . append ( "\r\n" ) ; lastTitles = getObjectOr ( culSubData , "cul_titles" , "" ) ; sbData . append ( lastTitles ) . append ( "\r\n" ) ; } if ( ! getObjectOr ( culSubData , "cul_titles" , "" ) . equals ( lastTitles ) ) { lastTitles = getObjectOr ( culSubData , "cul_titles" , "" ) ; sbData . append ( lastTitles ) . append ( "\r\n" ) ; } sbData . append ( getObjectOr ( culSubData , "cul_info" , "" ) ) . append ( "\r\n" ) ; } bwC . write ( sbError . toString ( ) ) ; bwC . write ( sbData . toString ( ) ) ; bwC . close ( ) ; } catch ( IOException e ) { LOG . error ( DssatCommonOutput . getStackTrace ( e ) ) ; } }
DSSAT Cultivar Data Output method
5,924
public static CodepointMatcher anyOf ( final String sequence ) { switch ( sequence . length ( ) ) { case 0 : return none ( ) ; case 1 : return is ( sequence ) ; default : return new AnyOf ( sequence ) ; } }
Matches any character in the sequence
5,925
public final String removeFrom ( String s ) { final StringBuilder sb = new StringBuilder ( ) ; for ( int offset = 0 ; offset < s . length ( ) ; ) { final int codePoint = s . codePointAt ( offset ) ; if ( ! matches ( codePoint ) ) { sb . appendCodePoint ( codePoint ) ; } offset += Character . charCount ( codePoint ) ; } return sb . toString ( ) ; }
Returns a copy of the input string with all Unicode codepoints matching this matcher removed
5,926
public final String trimFrom ( String s ) { int first ; int last ; for ( first = 0 ; first < s . length ( ) ; ) { final int codePoint = s . codePointAt ( first ) ; if ( ! matches ( codePoint ) ) { break ; } first += Character . charCount ( codePoint ) ; } for ( last = s . length ( ) - 1 ; last >= first ; -- last ) { if ( Character . isLowSurrogate ( s . charAt ( last ) ) ) { -- last ; } if ( ! matches ( s . codePointAt ( last ) ) ) { break ; } } return s . substring ( first , last + 1 ) ; }
Returns a copy of the input string with all leading and trailing codepoints matching this matcher removed
5,927
private UTF16Offset codeUnitOffsetFor ( final CharOffset codePointOffset ) { int charOffset = 0 ; int codePointsConsumed = 0 ; for ( ; charOffset < utf16CodeUnits ( ) . length ( ) && codePointsConsumed < codePointOffset . asInt ( ) ; ++ codePointsConsumed ) { final int codePoint = utf16CodeUnits ( ) . codePointAt ( charOffset ) ; charOffset += Character . charCount ( codePoint ) ; } if ( codePointsConsumed == codePointOffset . asInt ( ) ) { return UTF16Offset . of ( charOffset ) ; } else { throw new IndexOutOfBoundsException ( ) ; } }
something like LocatedString s like CharacterRegions
5,928
public static void expandAll ( JTree tree , TreePath path , boolean expand ) { TreeNode node = ( TreeNode ) path . getLastPathComponent ( ) ; if ( node . getChildCount ( ) >= 0 ) { Enumeration < ? > enumeration = node . children ( ) ; while ( enumeration . hasMoreElements ( ) ) { TreeNode n = ( TreeNode ) enumeration . nextElement ( ) ; TreePath p = path . pathByAddingChild ( n ) ; expandAll ( tree , p , expand ) ; } } if ( expand ) { tree . expandPath ( path ) ; } else { tree . collapsePath ( path ) ; } }
Expand all nodes recursive
5,929
protected void fireValidityChangedFor ( Object changedObject , int index , BusPrimitiveInvalidity oldReason , BusPrimitiveInvalidity newReason ) { resetBoundingBox ( ) ; final BusChangeEvent event = new BusChangeEvent ( this , BusChangeEventType . VALIDITY , changedObject , index , "validity" , oldReason , newReason ) ; firePrimitiveChanged ( event ) ; }
Fire the event that indicates the validity of the object has changed .
5,930
public int getColor ( int defaultColor ) { final Integer c = getRawColor ( ) ; if ( c != null ) { return c ; } final BusContainer < ? > container = getContainer ( ) ; if ( container != null ) { return container . getColor ( ) ; } return defaultColor ; }
Replies the color of this element or the color of the container .
5,931
@ SuppressWarnings ( "unlikely-arg-type" ) protected final void setPrimitiveValidity ( BusPrimitiveInvalidity invalidityReason ) { if ( ( invalidityReason == null && this . invalidityReason != null ) || ( invalidityReason != null && ! invalidityReason . equals ( BusPrimitiveInvalidityType . VALIDITY_NOT_CHECKED ) && ! invalidityReason . equals ( this . invalidityReason ) ) ) { final BusPrimitiveInvalidity old = this . invalidityReason ; this . invalidityReason = invalidityReason ; fireValidityChanged ( old , this . invalidityReason ) ; } }
Set if this component has invalid or not .
5,932
public UnitVectorProperty secondAxisProperty ( ) { if ( this . saxis == null ) { this . saxis = new UnitVectorProperty ( this , MathFXAttributeNames . SECOND_AXIS , getGeomFactory ( ) ) ; } return this . saxis ; }
Replies the property for the second axis .
5,933
public DoubleProperty firstAxisExtentProperty ( ) { if ( this . extentR == null ) { this . extentR = new SimpleDoubleProperty ( this , MathFXAttributeNames . FIRST_AXIS_EXTENT ) { protected void invalidated ( ) { if ( get ( ) < 0. ) { set ( 0. ) ; } } } ; } return this . extentR ; }
Replies the property for the extent of the first axis .
5,934
public DoubleProperty secondAxisExtentProperty ( ) { if ( this . extentS == null ) { this . extentS = new SimpleDoubleProperty ( this , MathFXAttributeNames . SECOND_AXIS_EXTENT ) { protected void invalidated ( ) { if ( get ( ) < 0. ) { set ( 0. ) ; } } } ; } return this . extentS ; }
Replies the property for the extent of the second axis .
5,935
public View < ? , ? > getRootParentView ( ) { View < ? , ? > currentView = this ; while ( currentView . hasParent ( ) ) { currentView = currentView . getParent ( ) ; } return currentView ; }
Gets the root parent view .
5,936
public Optional < CoreNLPParseNode > terminalHead ( ) { if ( terminal ( ) ) { return Optional . of ( this ) ; } if ( immediateHead ( ) . isPresent ( ) ) { return immediateHead ( ) . get ( ) . terminalHead ( ) ; } return Optional . absent ( ) ; }
Resolves a head down to a terminal node . A terminal node is its own head here .
5,937
public static AbstractPathElement3D newInstance ( PathElementType type , Point3d last , Point3d [ ] coords ) { switch ( type ) { case MOVE_TO : return new MovePathElement3d ( coords [ 0 ] ) ; case LINE_TO : return new LinePathElement3d ( last , coords [ 0 ] ) ; case QUAD_TO : return new QuadPathElement3d ( last , coords [ 0 ] , coords [ 1 ] ) ; case CURVE_TO : return new CurvePathElement3d ( last , coords [ 0 ] , coords [ 1 ] , coords [ 2 ] ) ; case CLOSE : return new ClosePathElement3d ( last , coords [ 0 ] ) ; default : } throw new IllegalArgumentException ( ) ; }
Create an instance of path element associating properties of points to the PathElement .
5,938
protected void extractConfigValues ( Map < String , Object > yaml , List < ConfigMetadataNode > configs ) { for ( final ConfigMetadataNode config : configs ) { Configs . defineConfig ( yaml , config , this . injector ) ; } }
Extract the definition from the given configurations .
5,939
@ SuppressWarnings ( "static-method" ) protected String generateYaml ( Map < String , Object > map ) throws JsonProcessingException { final YAMLFactory yamlFactory = new YAMLFactory ( ) ; yamlFactory . configure ( Feature . WRITE_DOC_START_MARKER , false ) ; final ObjectMapper mapper = new ObjectMapper ( yamlFactory ) ; return mapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( map ) ; }
Generate the Yaml representation of the given map .
5,940
@ SuppressWarnings ( "static-method" ) protected String generateJson ( Map < String , Object > map ) throws JsonProcessingException { final ObjectMapper mapper = new ObjectMapper ( ) ; return mapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( map ) ; }
Generate the Json representation of the given map .
5,941
@ SuppressWarnings ( { "static-method" } ) protected String generateXml ( Map < String , Object > map ) throws JsonProcessingException { final XmlMapper mapper = new XmlMapper ( ) ; return mapper . writerWithDefaultPrettyPrinter ( ) . withRootName ( XML_ROOT_NAME ) . writeValueAsString ( map ) ; }
Generate the Xml representation of the given map .
5,942
@ SuppressWarnings ( "unchecked" ) private void parseOptionsFromFile ( String optionFileName ) throws ParseException { List < String > options = OptionsFileLoader . loadOptions ( optionFileName ) ; options . addAll ( commandLine . getArgList ( ) ) ; commandLine = cliParser . parse ( cliOptions , options . toArray ( new String [ 0 ] ) ) ; }
Parse options from a file . Reload commandLine that after calling this method contains both options coming from the command line and from the file .
5,943
void disconnect ( ) { final DefaultProgression parentInstance = getParent ( ) ; if ( parentInstance != null ) { parentInstance . disconnectSubTask ( this , this . maxValueInParent , this . overwriteCommentWhenDisconnect ) ; } this . parent = null ; }
Set the parent value and disconnect this subtask from its parent .
5,944
private void initOptions ( ) { List < CLIOption > options = new ArrayList < CLIOption > ( ) ; options . addAll ( Arrays . asList ( ProxyDestroyOptions . values ( ) ) ) ; initOptions ( options ) ; }
Initialize options .
5,945
@ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) void updateSizes ( int fieldLength , int decimalPointPosition ) { switch ( this . type ) { case STRING : if ( fieldLength > this . length ) { this . length = fieldLength ; } break ; case FLOATING_NUMBER : case NUMBER : if ( decimalPointPosition > this . decimal ) { final int intPart = this . length - this . decimal ; this . decimal = decimalPointPosition ; this . length = intPart + this . decimal ; } if ( fieldLength > this . length ) { this . length = fieldLength ; } break ; default : } }
Update the sizes with the given ones if and only if they are greater than the existing ones . This test is done according to the type of the field .
5,946
public int compare ( HashMap m1 , HashMap m2 ) { double val1 ; double val2 ; for ( String sortId : sortIds ) { val1 = getValue ( m1 , sortId ) ; val2 = getValue ( m2 , sortId ) ; if ( val1 > val2 ) { return decVal ; } else if ( val1 < val2 ) { return ascVal ; } } return 0 ; }
Compare two element in the array by using sorting IDs .
5,947
private double getValue ( HashMap m , String key ) { try { return Double . parseDouble ( getValueOr ( m , key , "" ) ) ; } catch ( Exception e ) { return Double . MIN_VALUE ; } }
Get number value by using key from map
5,948
protected void onNext ( ) { stateMachine . next ( ) ; updateButtonState ( ) ; final String name = getStateMachine ( ) . getCurrentState ( ) . getName ( ) ; final CardLayout cardLayout = getWizardContentPanel ( ) . getCardLayout ( ) ; cardLayout . show ( getWizardContentPanel ( ) , name ) ; }
Callback method for the next action .
5,949
protected void onPrevious ( ) { stateMachine . previous ( ) ; updateButtonState ( ) ; final String name = getStateMachine ( ) . getCurrentState ( ) . getName ( ) ; final CardLayout cardLayout = getWizardContentPanel ( ) . getCardLayout ( ) ; cardLayout . show ( getWizardContentPanel ( ) , name ) ; }
Callback method for the previous action .
5,950
protected void updateButtonState ( ) { getNavigationPanel ( ) . getBtnPrevious ( ) . setEnabled ( getStateMachine ( ) . getCurrentState ( ) . hasPrevious ( ) ) ; getNavigationPanel ( ) . getBtnNext ( ) . setEnabled ( getStateMachine ( ) . getCurrentState ( ) . hasNext ( ) ) ; }
Update the button states . Overwrite this method for activate or disable the navigation buttons .
5,951
public final void conjugate ( Quaternion q1 ) { this . x = - q1 . x ; this . y = - q1 . y ; this . z = - q1 . z ; this . w = q1 . w ; }
Sets the value of this quaternion to the conjugate of quaternion q1 .
5,952
public final void inverse ( Quaternion q1 ) { double norm ; norm = 1f / ( q1 . w * q1 . w + q1 . x * q1 . x + q1 . y * q1 . y + q1 . z * q1 . z ) ; this . w = norm * q1 . w ; this . x = - norm * q1 . x ; this . y = - norm * q1 . y ; this . z = - norm * q1 . z ; }
Sets the value of this quaternion to quaternion inverse of quaternion q1 .
5,953
public final void inverse ( ) { double norm ; norm = 1f / ( this . w * this . w + this . x * this . x + this . y * this . y + this . z * this . z ) ; this . w *= norm ; this . x *= - norm ; this . y *= - norm ; this . z *= - norm ; }
Sets the value of this quaternion to the quaternion inverse of itself .
5,954
public final void normalize ( Quaternion q1 ) { double norm ; norm = ( q1 . x * q1 . x + q1 . y * q1 . y + q1 . z * q1 . z + q1 . w * q1 . w ) ; if ( norm > 0f ) { norm = 1f / Math . sqrt ( norm ) ; this . x = norm * q1 . x ; this . y = norm * q1 . y ; this . z = norm * q1 . z ; this . w = norm * q1 . w ; } else { this . x = 0f ; this . y = 0f ; this . z = 0f ; this . w = 0f ; } }
Sets the value of this quaternion to the normalized value of quaternion q1 .
5,955
public final void normalize ( ) { double norm ; norm = ( this . x * this . x + this . y * this . y + this . z * this . z + this . w * this . w ) ; if ( norm > 0f ) { norm = 1f / Math . sqrt ( norm ) ; this . x *= norm ; this . y *= norm ; this . z *= norm ; this . w *= norm ; } else { this . x = 0f ; this . y = 0f ; this . z = 0f ; this . w = 0f ; } }
Normalizes the value of this quaternion in place .
5,956
public final void setFromMatrix ( Matrix4f m1 ) { double ww = 0.25f * ( m1 . m00 + m1 . m11 + m1 . m22 + m1 . m33 ) ; if ( ww >= 0 ) { if ( ww >= EPS2 ) { this . w = Math . sqrt ( ww ) ; ww = 0.25f / this . w ; this . x = ( m1 . m21 - m1 . m12 ) * ww ; this . y = ( m1 . m02 - m1 . m20 ) * ww ; this . z = ( m1 . m10 - m1 . m01 ) * ww ; return ; } } else { this . w = 0 ; this . x = 0 ; this . y = 0 ; this . z = 1 ; return ; } this . w = 0 ; ww = - 0.5f * ( m1 . m11 + m1 . m22 ) ; if ( ww >= 0 ) { if ( ww >= EPS2 ) { this . x = Math . sqrt ( ww ) ; ww = 1.0f / ( 2.0f * this . x ) ; this . y = m1 . m10 * ww ; this . z = m1 . m20 * ww ; return ; } } else { this . x = 0 ; this . y = 0 ; this . z = 1 ; return ; } this . x = 0 ; ww = 0.5f * ( 1.0f - m1 . m22 ) ; if ( ww >= EPS2 ) { this . y = Math . sqrt ( ww ) ; this . z = m1 . m21 / ( 2.0f * this . y ) ; return ; } this . y = 0 ; this . z = 1 ; }
Sets the value of this quaternion to the rotational component of the passed matrix .
5,957
public final Vector3f getAxis ( ) { double mag = this . x * this . x + this . y * this . y + this . z * this . z ; if ( mag > EPS ) { mag = Math . sqrt ( mag ) ; double invMag = 1f / mag ; return new Vector3f ( this . x * invMag , this . y * invMag , this . z * invMag ) ; } return new Vector3f ( 0f , 0f , 1f ) ; }
Replies the rotation axis - angle represented by this quaternion .
5,958
public final double getAngle ( ) { double mag = this . x * this . x + this . y * this . y + this . z * this . z ; if ( mag > EPS ) { mag = Math . sqrt ( mag ) ; return ( 2.f * Math . atan2 ( mag , this . w ) ) ; } return 0f ; }
Replies the rotation angle represented by this quaternion .
5,959
@ SuppressWarnings ( "synthetic-access" ) public final AxisAngle getAxisAngle ( ) { double mag = this . x * this . x + this . y * this . y + this . z * this . z ; if ( mag > EPS ) { mag = Math . sqrt ( mag ) ; double invMag = 1f / mag ; return new AxisAngle ( this . x * invMag , this . y * invMag , this . z * invMag , ( 2. * Math . atan2 ( mag , this . w ) ) ) ; } return new AxisAngle ( 0 , 0 , 1 , 0 ) ; }
Replies the rotation axis represented by this quaternion .
5,960
public final void interpolate ( Quaternion q1 , double alpha ) { double dot , s1 , s2 , om , sinom ; dot = this . x * q1 . x + this . y * q1 . y + this . z * q1 . z + this . w * q1 . w ; if ( dot < 0 ) { q1 . x = - q1 . x ; q1 . y = - q1 . y ; q1 . z = - q1 . z ; q1 . w = - q1 . w ; dot = - dot ; } if ( ( 1.0 - dot ) > EPS ) { om = Math . acos ( dot ) ; sinom = Math . sin ( om ) ; s1 = Math . sin ( ( 1.0 - alpha ) * om ) / sinom ; s2 = Math . sin ( alpha * om ) / sinom ; } else { s1 = 1.0 - alpha ; s2 = alpha ; } this . w = ( s1 * this . w + s2 * q1 . w ) ; this . x = ( s1 * this . x + s2 * q1 . x ) ; this . y = ( s1 * this . y + s2 * q1 . y ) ; this . z = ( s1 * this . z + s2 * q1 . z ) ; }
Performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion .
5,961
@ SuppressWarnings ( "synthetic-access" ) public EulerAngles getEulerAngles ( CoordinateSystem3D system ) { Quaternion q = new Quaternion ( this ) ; system . toSystem ( q , CoordinateSystem3D . XZY_RIGHT_HAND ) ; double sqw = q . w * q . w ; double sqx = q . x * q . x ; double sqy = q . y * q . y ; double sqz = q . z * q . z ; double unit = sqx + sqy + sqz + sqw ; double test = q . x * q . y + q . z * q . w ; if ( MathUtil . compareEpsilon ( test , .5 * unit ) >= 0 ) { return new EulerAngles ( 2. * Math . atan2 ( q . x , q . w ) , MathConstants . DEMI_PI , 0. , system ) ; } if ( MathUtil . compareEpsilon ( test , - .5 * unit ) <= 0 ) { return new EulerAngles ( - 2. * Math . atan2 ( q . x , q . w ) , - MathConstants . DEMI_PI , 0. , system ) ; } return new EulerAngles ( Math . atan2 ( 2. * q . y * q . w - 2. * q . x * q . z , sqx - sqy - sqz + sqw ) , Math . asin ( 2. * test / unit ) , Math . atan2 ( 2. * q . x * q . w - 2. * q . y * q . z , - sqx + sqy - sqz + sqw ) , system ) ; }
Replies the Euler s angles that corresponds to the quaternion .
5,962
public static void writeRoadNetwork ( Element xmlNode , RoadNetwork primitive , URL geometryURL , MapMetricProjection mapProjection , URL attributeURL , XMLBuilder builder , PathBuilder pathBuilder , XMLResources resources ) throws IOException { final ContainerWrapper w = new ContainerWrapper ( primitive ) ; w . setElementGeometrySource ( geometryURL , mapProjection ) ; w . setElementAttributeSourceURL ( attributeURL ) ; writeGISElementContainer ( xmlNode , w , NODE_ROAD , builder , pathBuilder , resources ) ; final Rectangle2d bounds = primitive . getBoundingBox ( ) ; if ( bounds != null ) { xmlNode . setAttribute ( ATTR_X , Double . toString ( bounds . getMinX ( ) ) ) ; xmlNode . setAttribute ( ATTR_Y , Double . toString ( bounds . getMinY ( ) ) ) ; xmlNode . setAttribute ( ATTR_WIDTH , Double . toString ( bounds . getWidth ( ) ) ) ; xmlNode . setAttribute ( ATTR_HEIGHT , Double . toString ( bounds . getHeight ( ) ) ) ; } }
Write the XML description for the given container of roads .
5,963
@ SuppressWarnings ( "static-method" ) protected void printSynopsis ( HelpAppender out , String name , String argumentSynopsis ) { out . printSectionName ( SYNOPSIS ) ; assert name != null ; if ( Strings . isNullOrEmpty ( argumentSynopsis ) ) { out . printText ( name , OPTION_SYNOPSIS ) ; } else { out . printText ( name , OPTION_SYNOPSIS , argumentSynopsis ) ; } }
Print the synopsis of the command .
5,964
@ SuppressWarnings ( "static-method" ) protected void printDetailedDescription ( SynopsisHelpAppender out , String detailedDescription ) { if ( ! Strings . isNullOrEmpty ( detailedDescription ) ) { out . printSectionName ( DETAILED_DESCRIPTION ) ; out . printLongDescription ( detailedDescription . split ( "[\r\n\f]+" ) ) ; } }
Print the detailed description of the command .
5,965
protected Drawer < ? super T > draw ( ZoomableGraphicsContext gc , GISElementContainer < T > primitive , Drawer < ? super T > drawer ) { Drawer < ? super T > drw = drawer ; final Iterator < T > iterator = primitive . iterator ( gc . getVisibleArea ( ) ) ; while ( iterator . hasNext ( ) ) { final T mapelement = iterator . next ( ) ; if ( drw == null ) { drw = Drawers . getDrawerFor ( mapelement . getClass ( ) ) ; if ( drw != null ) { gc . save ( ) ; drw . draw ( gc , mapelement ) ; gc . restore ( ) ; } } else { gc . save ( ) ; drw . draw ( gc , mapelement ) ; gc . restore ( ) ; } } return drw ; }
Draw the primitive with the given drawer .
5,966
public static boolean intersectsSolidSphereOrientedBox ( double sphereCenterx , double sphereCentery , double sphereCenterz , double sphereRadius , double boxCenterx , double boxCentery , double boxCenterz , double boxAxis1x , double boxAxis1y , double boxAxis1z , double boxAxis2x , double boxAxis2y , double boxAxis2z , double boxAxis3x , double boxAxis3y , double boxAxis3z , double boxExtentAxis1 , double boxExtentAxis2 , double boxExtentAxis3 ) { Point3f closest = new Point3f ( ) ; Point3f farest = new Point3f ( ) ; AbstractOrientedBox3F . computeClosestFarestOBBPoints ( sphereCenterx , sphereCentery , sphereCenterz , boxCenterx , boxCentery , boxCenterz , boxAxis1x , boxAxis1y , boxAxis1z , boxAxis2x , boxAxis2y , boxAxis2z , boxAxis3x , boxAxis3y , boxAxis3z , boxExtentAxis1 , boxExtentAxis2 , boxExtentAxis3 , closest , farest ) ; double squaredRadius = sphereRadius * sphereRadius ; return ( FunctionalPoint3D . distanceSquaredPointPoint ( sphereCenterx , sphereCentery , sphereCenterz , closest . getX ( ) , closest . getY ( ) , closest . getZ ( ) ) < squaredRadius ) ; }
Replies if the specified box intersects the specified sphere .
5,967
public static boolean intersectsSphereCapsule ( double sphereCenterx , double sphereCentery , double sphereCenterz , double sphereRadius , double capsuleAx , double capsuleAy , double capsuleAz , double capsuleBx , double capsuleBy , double capsuleBz , double capsuleRadius ) { double dist2 = AbstractSegment3F . distanceSquaredSegmentPoint ( capsuleAx , capsuleAy , capsuleAz , capsuleBx , capsuleBy , capsuleBz , sphereCenterx , sphereCentery , sphereCenterz ) ; double radius = sphereRadius + capsuleRadius ; return dist2 < radius * radius ; }
Replies if the specified sphere intersects the specified capsule .
5,968
public static boolean containsSpherePoint ( double cx , double cy , double cz , double radius , double px , double py , double pz ) { return FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , cx , cy , cz ) <= ( radius * radius ) ; }
Replies if the given point is inside the given sphere .
5,969
public static boolean containsSphereAlignedBox ( double cx , double cy , double cz , double radius , double bx , double by , double bz , double bsx , double bsy , double bsz ) { double rcx = ( bx + bsx / 2f ) ; double rcy = ( by + bsy / 2f ) ; double rcz = ( bz + bsz / 2f ) ; double farX ; if ( cx <= rcx ) farX = bx + bsx ; else farX = bx ; double farY ; if ( cy <= rcy ) farY = by + bsy ; else farY = by ; double farZ ; if ( cz <= rcz ) farZ = bz + bsz ; else farZ = bz ; return containsSpherePoint ( cx , cy , cz , radius , farX , farY , farZ ) ; }
Replies if an aligned box is inside in the sphere .
5,970
public static boolean intersectsSphereSphere ( double x1 , double y1 , double z1 , double radius1 , double x2 , double y2 , double z2 , double radius2 ) { double r = radius1 + radius2 ; return FunctionalPoint3D . distanceSquaredPointPoint ( x1 , y1 , z1 , x2 , y2 , z2 ) < ( r * r ) ; }
Replies if two spheres are intersecting .
5,971
public static boolean intersectsSphereLine ( double x1 , double y1 , double z1 , double radius , double x2 , double y2 , double z2 , double x3 , double y3 , double z3 ) { double d = AbstractSegment3F . distanceSquaredLinePoint ( x2 , y2 , z2 , x3 , y3 , z3 , x1 , y1 , z1 ) ; return d < ( radius * radius ) ; }
Replies if a sphere and a line are intersecting .
5,972
public static boolean intersectsSphereSegment ( double x1 , double y1 , double z1 , double radius , double x2 , double y2 , double z2 , double x3 , double y3 , double z3 ) { double d = AbstractSegment3F . distanceSquaredSegmentPoint ( x2 , y2 , z2 , x3 , y3 , z3 , x1 , y1 , z1 ) ; return d < ( radius * radius ) ; }
Replies if a sphere and a segment are intersecting .
5,973
protected String encodeCookie ( SerializableHttpCookie cookie ) { if ( cookie == null ) return null ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; try { ObjectOutputStream outputStream = new ObjectOutputStream ( os ) ; outputStream . writeObject ( cookie ) ; } catch ( IOException e ) { Util . log ( "IOException in encodeCookie" , e ) ; return null ; } return byteArrayToHexString ( os . toByteArray ( ) ) ; }
Serializes Cookie object into String
5,974
protected Cookie decodeCookie ( String cookieString ) { byte [ ] bytes = hexStringToByteArray ( cookieString ) ; ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream ( bytes ) ; Cookie cookie = null ; try { ObjectInputStream objectInputStream = new ObjectInputStream ( byteArrayInputStream ) ; cookie = ( ( SerializableHttpCookie ) objectInputStream . readObject ( ) ) . getCookie ( ) ; } catch ( IOException e ) { Util . log ( "IOException in decodeCookie" , e ) ; } catch ( ClassNotFoundException e ) { Util . log ( "ClassNotFoundException in decodeCookie" , e ) ; } return cookie ; }
Returns cookie decoded from cookie string
5,975
public static < T > Collection < Class < ? super T > > getSuperClasses ( Class < T > className ) { assert className != null ; final Collection < Class < ? super T > > list = new ArrayList < > ( ) ; Class < ? super T > type = className . getSuperclass ( ) ; while ( type != null && ! Object . class . equals ( type ) ) { list . add ( type ) ; type = type . getSuperclass ( ) ; } return list ; }
Replies the list of all the superclasses of the given class .
5,976
public static Class < ? > getCommonType ( Class < ? > type1 , Class < ? > type2 ) { if ( type1 == null ) { return type2 ; } if ( type2 == null ) { return type1 ; } Class < ? > top = type1 ; while ( ! top . isAssignableFrom ( type2 ) ) { top = top . getSuperclass ( ) ; assert top != null ; } return top ; }
Replies the top - most type which is common to both given types .
5,977
public static Class < ? > getCommonType ( Object instance1 , Object instance2 ) { if ( instance1 == null ) { return instance2 == null ? null : instance2 . getClass ( ) ; } if ( instance2 == null ) { return instance1 . getClass ( ) ; } Class < ? > top = instance1 . getClass ( ) ; while ( ! top . isInstance ( instance2 ) ) { top = top . getSuperclass ( ) ; assert top != null ; } return top ; }
Replies the top - most type which is common to both given objects .
5,978
@ SuppressWarnings ( { "checkstyle:returncount" , "npathcomplexity" } ) public static Class < ? > getOutboxingType ( Class < ? > type ) { if ( void . class . equals ( type ) ) { return Void . class ; } if ( boolean . class . equals ( type ) ) { return Boolean . class ; } if ( byte . class . equals ( type ) ) { return Byte . class ; } if ( char . class . equals ( type ) ) { return Character . class ; } if ( double . class . equals ( type ) ) { return Double . class ; } if ( float . class . equals ( type ) ) { return Float . class ; } if ( int . class . equals ( type ) ) { return Integer . class ; } if ( long . class . equals ( type ) ) { return Long . class ; } if ( short . class . equals ( type ) ) { return Short . class ; } return type ; }
Replies the outboxing type for the given type .
5,979
public static boolean matchesParameters ( Class < ? > [ ] formalParameters , Object ... parameterValues ) { if ( formalParameters == null ) { return parameterValues == null ; } if ( parameterValues != null && formalParameters . length == parameterValues . length ) { for ( int i = 0 ; i < formalParameters . length ; ++ i ) { if ( ! isInstance ( formalParameters [ i ] , parameterValues [ i ] ) ) { return false ; } } return true ; } return false ; }
Replies if the formal parameters are matching the given values .
5,980
@ Inline ( value = "ReflectionUtil.matchesParameters(($1).getParameterTypes(), ($2))" , imported = { ReflectionUtil . class } ) public static boolean matchesParameters ( Method method , Object ... parameters ) { return matchesParameters ( method . getParameterTypes ( ) , parameters ) ; }
Replies if the parameters of the given method are matching the given values .
5,981
public static void toJson ( Object object , JsonBuffer output ) { if ( object == null ) { return ; } for ( final Method method : object . getClass ( ) . getMethods ( ) ) { try { if ( ! method . isSynthetic ( ) && ! Modifier . isStatic ( method . getModifiers ( ) ) && method . getParameterCount ( ) == 0 && ( method . getReturnType ( ) . isPrimitive ( ) || String . class . equals ( method . getReturnType ( ) ) || method . getReturnType ( ) . isEnum ( ) ) ) { final String name = method . getName ( ) ; if ( name . startsWith ( "get" ) && name . length ( ) > 3 ) { output . add ( makeName ( name , 3 ) , method . invoke ( object ) ) ; } else if ( name . startsWith ( "is" ) && name . length ( ) > 2 ) { output . add ( makeName ( name , 2 ) , method . invoke ( object ) ) ; } } } catch ( Exception e ) { } } }
Replies the string representation of the given object .
5,982
public Point3d getCenter ( ) { return new Point3d ( ( this . medial1 . getX ( ) + this . medial2 . getX ( ) ) / 2. , ( this . medial1 . getY ( ) + this . medial2 . getY ( ) ) / 2. , ( this . medial1 . getZ ( ) + this . medial2 . getZ ( ) ) / 2. ) ; }
Replies the center point of the capsule .
5,983
protected void onSetColumnNames ( ) { columnNames = ReflectionExtensions . getDeclaredFieldNames ( getType ( ) , "serialVersionUID" ) ; for ( int i = 0 ; i < columnNames . length ; i ++ ) { columnNames [ i ] = StringUtils . capitalize ( columnNames [ i ] ) ; } }
Callback method for set the column names array from the generic given type . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a column names
5,984
protected void onSetCanEdit ( ) { Field [ ] fields = ReflectionExtensions . getDeclaredFields ( getType ( ) , "serialVersionUID" ) ; canEdit = new boolean [ fields . length ] ; for ( int i = 0 ; i < fields . length ; i ++ ) { canEdit [ i ] = false ; } }
Callback method for set the canEdit array from the generic given type . This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a column classes
5,985
public boolean setChildAt ( int index , N newChild ) throws IndexOutOfBoundsException { final N oldChild = ( index < this . children . length ) ? this . children [ index ] : null ; if ( oldChild == newChild ) { return false ; } if ( oldChild != null ) { oldChild . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( index , oldChild ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . children [ index ] = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( index , newChild ) ; } return true ; }
Set the child at the given index in this node .
5,986
public void addIterator ( SizedIterator < ? extends M > iterator ) { if ( this . iterators . add ( iterator ) ) { this . total += iterator . totalSize ( ) ; this . update = true ; } }
Add an iterator in the list of iterators .
5,987
public void write ( Collection < ? extends MapLayer > layers ) throws IOException { if ( this . progression != null ) { this . progression . setProperties ( 0 , 0 , layers . size ( ) + 1 , false ) ; } if ( ! this . isHeaderWritten ) { this . isHeaderWritten = true ; writeHeader ( ) ; } if ( this . progression != null ) { this . progression . increment ( ) ; } final ObjectOutputStream oos = new ObjectOutputStream ( this . tmpOutput ) ; for ( final MapLayer layer : layers ) { oos . writeObject ( layer ) ; ++ this . length ; if ( this . progression != null ) { this . progression . increment ( ) ; } } if ( this . progression != null ) { this . progression . end ( ) ; } }
Write the given layers into the output .
5,988
protected void writeHeader ( ) throws IOException { this . tmpOutput . write ( HEADER_KEY . getBytes ( ) ) ; this . tmpOutput . write ( new byte [ ] { MAJOR_SPEC_NUMBER , MINOR_SPEC_NUMBER } ) ; this . tmpOutput . write ( new byte [ ] { 0 , 0 , 0 , 0 } ) ; }
Write the header of the file .
5,989
protected static String runCommand ( String ... command ) { try { final Process p = Runtime . getRuntime ( ) . exec ( command ) ; if ( p == null ) { return null ; } final StringBuilder bStr = new StringBuilder ( ) ; try ( InputStream standardOutput = p . getInputStream ( ) ) { final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int len ; while ( ( len = standardOutput . read ( buffer ) ) > 0 ) { bStr . append ( new String ( buffer , 0 , len ) ) ; } p . waitFor ( ) ; return bStr . toString ( ) ; } } catch ( Exception e ) { return null ; } }
Run a shell command .
5,990
protected static String grep ( String selector , String text ) { if ( text == null || text . isEmpty ( ) ) { return null ; } final StringBuilder line = new StringBuilder ( ) ; final int textLength = text . length ( ) ; char c ; String string ; for ( int i = 0 ; i < textLength ; ++ i ) { c = text . charAt ( i ) ; if ( c == '\n' || c == '\r' ) { string = line . toString ( ) ; if ( string . contains ( selector ) ) { return string ; } line . setLength ( 0 ) ; } else { line . append ( c ) ; } } if ( line . length ( ) > 0 ) { string = line . toString ( ) ; if ( string . contains ( selector ) ) { return string ; } } return null ; }
Replies the first line that contains the given selector .
5,991
protected static String cut ( String delimiter , int column , String lineText ) { if ( lineText == null || lineText . isEmpty ( ) ) { return null ; } final String [ ] columns = lineText . split ( Pattern . quote ( delimiter ) ) ; if ( columns != null && column >= 0 && column < columns . length ) { return columns [ column ] . trim ( ) ; } return null ; }
Cut the line in columns and replies the given column .
5,992
protected static Plane3D < ? > toPlane ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 ) { Vector3f norm = new Vector3f ( ) ; FunctionalVector3D . crossProduct ( tx2 - tx1 , ty2 - ty1 , tz2 - tz1 , tx3 - tx1 , ty3 - ty1 , tz3 - tz1 , norm ) ; assert ( norm != null ) ; if ( norm . getY ( ) == 0. && norm . getZ ( ) == 0. ) return new PlaneYZ4f ( tx1 ) ; if ( norm . getX ( ) == 0. && norm . getZ ( ) == 0. ) return new PlaneXZ4f ( ty1 ) ; if ( norm . getX ( ) == 0. && norm . getY ( ) == 0. ) return new PlaneXY4f ( tz1 ) ; return new Plane4f ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 ) ; }
Compute the plane of the given triangle .
5,993
public static void computeClosestPointTrianglePoint ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double px , double py , double pz , Point3D closestPoint ) { if ( containsTrianglePoint ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , px , py , pz , false , MathConstants . EPSILON ) ) { closestPoint . set ( toPlane ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 ) . getProjection ( px , py , pz ) ) ; return ; } double f ; f = AbstractSegment3F . getPointProjectionFactorOnSegmentLine ( px , py , pz , tx1 , ty1 , tz1 , tx2 , ty2 , tz2 ) ; double p1x = tx1 + f * ( tx2 - tx1 ) ; double p1y = ty1 + f * ( ty2 - ty1 ) ; double p1z = tz1 + f * ( tz2 - tz1 ) ; f = AbstractSegment3F . getPointProjectionFactorOnSegmentLine ( px , py , pz , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 ) ; double p2x = tx2 + f * ( tx3 - tx2 ) ; double p2y = ty2 + f * ( ty3 - ty2 ) ; double p2z = tz2 + f * ( tz3 - tz2 ) ; f = AbstractSegment3F . getPointProjectionFactorOnSegmentLine ( px , py , pz , tx3 , ty3 , tz3 , tx1 , ty1 , tz1 ) ; double p3x = tx3 + f * ( tx1 - tx3 ) ; double p3y = ty3 + f * ( ty1 - ty3 ) ; double p3z = tz3 + f * ( tz1 - tz3 ) ; double d1 = FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , p1x , p1y , p1z ) ; double d2 = FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , p2x , p2y , p3z ) ; double d3 = FunctionalPoint3D . distanceSquaredPointPoint ( px , py , pz , p3x , p3y , p3z ) ; if ( d1 <= d2 ) { if ( d1 <= d3 ) { closestPoint . set ( p1x , p1y , p1z ) ; } else { closestPoint . set ( p3x , p3y , p3z ) ; } } if ( d2 <= d3 ) { closestPoint . set ( p2x , p2y , p2z ) ; } else { closestPoint . set ( p3x , p3y , p3z ) ; } }
Replies the closest point from the triangle to the point .
5,994
public static double distanceSquaredTriangleSegment ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 ) { double t = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; if ( Double . isInfinite ( t ) || ( ! Double . isNaN ( t ) && t >= 0. && t <= 1. ) ) { return 0. ; } double d1 = AbstractSegment3F . distanceSquaredSegmentSegment ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; double d2 = AbstractSegment3F . distanceSquaredSegmentSegment ( tx1 , ty1 , tz1 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; double d3 = AbstractSegment3F . distanceSquaredSegmentSegment ( tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; return MathUtil . min ( d1 , d2 , d3 ) ; }
Replies the squared distance from the triangle to the segment .
5,995
public static boolean intersectsTriangleCapsule ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double cx1 , double cy1 , double cz1 , double cx2 , double cy2 , double cz2 , double radius ) { double d = distanceSquaredTriangleSegment ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , cx1 , cy1 , cz1 , cx2 , cy2 , cz2 ) ; return d < ( radius * radius ) ; }
Replies if the triangle intersects the capsule .
5,996
public static boolean intersectsTriangleOrientedBox ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double cx , double cy , double cz , double ax1 , double ay1 , double az1 , double ax2 , double ay2 , double az2 , double ax3 , double ay3 , double az3 , double ae1 , double ae2 , double ae3 ) { double nx , ny , nz ; nx = tx1 - cx ; ny = ty1 - cy ; nz = tz1 - cz ; double ntx1 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax1 , ay1 , az1 ) ; double nty1 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax2 , ay2 , az2 ) ; double ntz1 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax3 , ay3 , az3 ) ; nx = tx2 - cx ; ny = ty2 - cy ; nz = tz2 - cz ; double ntx2 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax1 , ay1 , az1 ) ; double nty2 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax2 , ay2 , az2 ) ; double ntz2 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax3 , ay3 , az3 ) ; nx = tx3 - cx ; ny = ty3 - cy ; nz = tz3 - cz ; double ntx3 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax1 , ay1 , az1 ) ; double nty3 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax2 , ay2 , az2 ) ; double ntz3 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax3 , ay3 , az3 ) ; return intersectsTriangleAlignedBox ( ntx1 , nty1 , ntz1 , ntx2 , nty2 , ntz2 , ntx3 , nty3 , ntz3 , - ae1 , - ae2 , - ae3 , ae1 , ae2 , ae3 ) ; }
Replies if the triangle intersects the oriented box .
5,997
public static boolean intersectsTriangleSegment ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 ) { double factor = getTriangleSegmentIntersectionFactorWithJimenezAlgorithm ( tx1 , ty1 , tz1 , tx2 , ty2 , tz2 , tx3 , ty3 , tz3 , sx1 , sy1 , sz1 , sx2 , sy2 , sz2 ) ; return ! Double . isNaN ( factor ) ; }
Replies if the triangle intersects the segment .
5,998
private static boolean containsTrianglePoint ( int i0 , int i1 , double [ ] v , double [ ] u1 , double [ ] u2 , double [ ] u3 ) { double a = u2 [ i1 ] - u1 [ i1 ] ; double b = - ( u2 [ i0 ] - u1 [ i0 ] ) ; double c = - a * u1 [ i0 ] - b * u1 [ i1 ] ; double d0 = a * v [ i0 ] + b * v [ i1 ] + c ; a = u3 [ i1 ] - u2 [ i1 ] ; b = - ( u3 [ i0 ] - u2 [ i0 ] ) ; c = - a * u2 [ i0 ] - b * u2 [ i1 ] ; double d1 = a * v [ i0 ] + b * v [ i1 ] + c ; a = u1 [ i1 ] - u2 [ i1 ] ; b = - ( u1 [ i0 ] - u3 [ i0 ] ) ; c = - a * u3 [ i0 ] - b * u3 [ i1 ] ; double d2 = a * v [ i0 ] + b * v [ i1 ] + c ; return ( ( d0 * d1 > 0. ) && ( d0 * d2 > 0.0 ) ) ; }
Replies if a point is inside a triangle .
5,999
private static boolean intersectsCoplanarTriangle ( int i0 , int i1 , int con , double [ ] s1 , double [ ] s2 , double [ ] u1 , double [ ] u2 , double [ ] u3 ) { double Ax , Ay ; Ax = s2 [ i0 ] - s1 [ i0 ] ; Ay = s2 [ i1 ] - s1 [ i1 ] ; if ( intersectEdgeEdge ( i0 , i1 , con , Ax , Ay , s1 , u1 , u2 ) ) return true ; if ( intersectEdgeEdge ( i0 , i1 , con , Ax , Ay , s1 , u2 , u3 ) ) return true ; if ( intersectEdgeEdge ( i0 , i1 , con , Ax , Ay , s1 , u3 , u1 ) ) return true ; return false ; }
Replies if coplanar segment - triangle intersect .