idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
6,400
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static File convertURLToFile ( URL url ) { URL theUrl = url ; if ( theUrl == null ) { return null ; } if ( URISchemeType . RESOURCE . isURL ( theUrl ) ) { theUrl = Resources . getResource ( decodeHTMLEntities ( theUrl . getFile ( ) ) ) ; if ( theUrl == null ) { theUrl = url ; } } URI uri ; try { uri = theUrl . toURI ( ) ; } catch ( URISyntaxException e ) { try { uri = new URI ( theUrl . getProtocol ( ) , theUrl . getUserInfo ( ) , theUrl . getHost ( ) , theUrl . getPort ( ) , decodeHTMLEntities ( theUrl . getPath ( ) ) , decodeHTMLEntities ( theUrl . getQuery ( ) ) , theUrl . getRef ( ) ) ; } catch ( URISyntaxException e1 ) { throw new IllegalArgumentException ( Locale . getString ( "E1" , theUrl ) ) ; } } if ( uri != null && URISchemeType . FILE . isURI ( uri ) ) { final String auth = uri . getAuthority ( ) ; String path = uri . getPath ( ) ; if ( path == null ) { path = uri . getRawPath ( ) ; } if ( path == null ) { path = uri . getSchemeSpecificPart ( ) ; } if ( path == null ) { path = uri . getRawSchemeSpecificPart ( ) ; } if ( path != null ) { if ( auth == null || "" . equals ( auth ) ) { path = decodeHTMLEntities ( path ) ; } else { path = decodeHTMLEntities ( auth + path ) ; } if ( Pattern . matches ( "^" + Pattern . quote ( URL_PATH_SEPARATOR ) + "[a-zA-Z][:|].*$" , path ) ) { path = path . substring ( URL_PATH_SEPARATOR . length ( ) ) ; } return new File ( path ) ; } } throw new IllegalArgumentException ( Locale . getString ( "E2" , theUrl ) ) ; }
Convert an URL which represents a local file or a resource into a File .
6,401
@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" } ) public static URL getParentURL ( URL url ) throws MalformedURLException { if ( url == null ) { return url ; } String path = url . getPath ( ) ; final String prefix ; final String parentStr ; switch ( URISchemeType . getSchemeType ( url ) ) { case JAR : final int index = path . indexOf ( JAR_URL_FILE_ROOT ) ; assert index > 0 ; prefix = path . substring ( 0 , index + 1 ) ; path = path . substring ( index + 1 ) ; parentStr = URL_PATH_SEPARATOR ; break ; case FILE : prefix = null ; parentStr = ".." + URL_PATH_SEPARATOR ; break ; default : prefix = null ; parentStr = URL_PATH_SEPARATOR ; } if ( path == null || "" . equals ( path ) ) { path = parentStr ; } int index = path . lastIndexOf ( URL_PATH_SEPARATOR_CHAR ) ; if ( index == - 1 ) { path = parentStr ; } else if ( index == path . length ( ) - 1 ) { index = path . lastIndexOf ( URL_PATH_SEPARATOR_CHAR , index - 1 ) ; if ( index == - 1 ) { path = parentStr ; } else { path = path . substring ( 0 , index + 1 ) ; } } else { path = path . substring ( 0 , index + 1 ) ; } if ( prefix != null ) { path = prefix + path ; } return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , path ) ; }
Replies the parent URL for the given URL .
6,402
@ SuppressWarnings ( "checkstyle:magicnumber" ) private static String extractLocalPath ( String filename ) { if ( filename == null ) { return null ; } final int max = Math . min ( FILE_PREFIX . length , filename . length ( ) ) ; final int inner = max - 2 ; if ( inner <= 0 ) { return filename ; } boolean foundInner = false ; boolean foundFull = false ; for ( int i = 0 ; i < max ; ++ i ) { final char c = Character . toLowerCase ( filename . charAt ( i ) ) ; if ( FILE_PREFIX [ i ] != c ) { foundFull = false ; foundInner = i >= inner ; break ; } foundFull = true ; } String fn ; if ( foundFull ) { fn = filename . substring ( FILE_PREFIX . length ) ; } else if ( foundInner ) { fn = filename . substring ( inner ) ; } else { fn = filename ; } if ( Pattern . matches ( "^(" + Pattern . quote ( URL_PATH_SEPARATOR ) + "|" + Pattern . quote ( WINDOWS_SEPARATOR_STRING ) + ")[a-zA-Z][:|].*$" , fn ) ) { fn = fn . substring ( 1 ) ; } return fn ; }
Test if the given filename is a local filename and extract the path component .
6,403
public static boolean isWindowsNativeFilename ( String filename ) { final String fn = extractLocalPath ( filename ) ; if ( fn == null || fn . length ( ) == 0 ) { return false ; } final Pattern pattern = Pattern . compile ( WINDOW_NATIVE_FILENAME_PATTERN ) ; final Matcher matcher = pattern . matcher ( fn ) ; return matcher . matches ( ) ; }
Replies if the given string contains a Windows&reg ; native long filename .
6,404
public static File normalizeWindowsNativeFilename ( String filename ) { final String fn = extractLocalPath ( filename ) ; if ( fn != null && fn . length ( ) > 0 ) { final Pattern pattern = Pattern . compile ( WINDOW_NATIVE_FILENAME_PATTERN ) ; final Matcher matcher = pattern . matcher ( fn ) ; if ( matcher . find ( ) ) { return new File ( fn . replace ( WINDOWS_SEPARATOR_CHAR , File . separatorChar ) ) ; } } return null ; }
Normalize the given string contains a Windows&reg ; native long filename and replies a Java - standard version .
6,405
public static URL makeCanonicalURL ( URL url ) { if ( url != null ) { final String [ ] pathComponents = url . getPath ( ) . split ( Pattern . quote ( URL_PATH_SEPARATOR ) ) ; final List < String > canonicalPath = new LinkedList < > ( ) ; for ( final String component : pathComponents ) { if ( ! CURRENT_DIRECTORY . equals ( component ) ) { if ( PARENT_DIRECTORY . equals ( component ) ) { if ( ! canonicalPath . isEmpty ( ) ) { canonicalPath . remove ( canonicalPath . size ( ) - 1 ) ; } else { canonicalPath . add ( component ) ; } } else { canonicalPath . add ( component ) ; } } } final StringBuilder newPathBuffer = new StringBuilder ( ) ; boolean isFirst = true ; for ( final String component : canonicalPath ) { if ( ! isFirst ) { newPathBuffer . append ( URL_PATH_SEPARATOR_CHAR ) ; } else { isFirst = false ; } newPathBuffer . append ( component ) ; } try { return new URI ( url . getProtocol ( ) , url . getUserInfo ( ) , url . getHost ( ) , url . getPort ( ) , newPathBuffer . toString ( ) , url . getQuery ( ) , url . getRef ( ) ) . toURL ( ) ; } catch ( MalformedURLException | URISyntaxException exception ) { } try { return new URL ( url . getProtocol ( ) , url . getHost ( ) , newPathBuffer . toString ( ) ) ; } catch ( Throwable exception ) { } } return url ; }
Make the given URL canonical .
6,406
public static void zipFile ( File input , File output ) throws IOException { try ( FileOutputStream fos = new FileOutputStream ( output ) ) { zipFile ( input , fos ) ; } }
Create a zip file from the given input file .
6,407
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static void zipFile ( File input , OutputStream output ) throws IOException { try ( ZipOutputStream zos = new ZipOutputStream ( output ) ) { if ( input == null ) { return ; } final LinkedList < File > candidates = new LinkedList < > ( ) ; candidates . add ( input ) ; final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int len ; File file ; File relativeFile ; String zipFilename ; final File rootDirectory = ( input . isDirectory ( ) ) ? input : input . getParentFile ( ) ; while ( ! candidates . isEmpty ( ) ) { file = candidates . removeFirst ( ) ; assert file != null ; if ( file . getAbsoluteFile ( ) . equals ( rootDirectory . getAbsoluteFile ( ) ) ) { relativeFile = null ; } else { relativeFile = makeRelative ( file , rootDirectory , false ) ; } if ( file . isDirectory ( ) ) { if ( relativeFile != null ) { zipFilename = fromFileStandardToURLStandard ( relativeFile ) + URL_PATH_SEPARATOR ; final ZipEntry zipEntry = new ZipEntry ( zipFilename ) ; zos . putNextEntry ( zipEntry ) ; zos . closeEntry ( ) ; } candidates . addAll ( Arrays . asList ( file . listFiles ( ) ) ) ; } else if ( relativeFile != null ) { try ( FileInputStream fis = new FileInputStream ( file ) ) { zipFilename = fromFileStandardToURLStandard ( relativeFile ) ; final ZipEntry zipEntry = new ZipEntry ( zipFilename ) ; zos . putNextEntry ( zipEntry ) ; while ( ( len = fis . read ( buffer ) ) > 0 ) { zos . write ( buffer , 0 , len ) ; } zos . closeEntry ( ) ; } } } } }
Create a zip file from the given input file . If the input file is a directory the content of the directory is zipped . If the input file is a standard file it is zipped .
6,408
public static void unzipFile ( InputStream input , File output ) throws IOException { if ( output == null ) { return ; } output . mkdirs ( ) ; if ( ! output . isDirectory ( ) ) { throw new IOException ( Locale . getString ( "E3" , output ) ) ; } try ( ZipInputStream zis = new ZipInputStream ( input ) ) { final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int len ; ZipEntry zipEntry = zis . getNextEntry ( ) ; while ( zipEntry != null ) { final String name = zipEntry . getName ( ) ; final File outFile = new File ( output , name ) . getCanonicalFile ( ) ; if ( zipEntry . isDirectory ( ) ) { outFile . mkdirs ( ) ; } else { outFile . getParentFile ( ) . mkdirs ( ) ; try ( FileOutputStream fos = new FileOutputStream ( outFile ) ) { while ( ( len = zis . read ( buffer ) ) > 0 ) { fos . write ( buffer , 0 , len ) ; } } } zipEntry = zis . getNextEntry ( ) ; } } }
Unzip the given stream and write out the file in the output . If the input file is a directory the content of the directory is zipped . If the input file is a standard file it is zipped .
6,409
public static void unzipFile ( File input , File output ) throws IOException { try ( FileInputStream fis = new FileInputStream ( input ) ) { unzipFile ( fis , output ) ; } }
Unzip a file into the output directory .
6,410
public static KeyValueSink < Symbol , byte [ ] > forPalDB ( final File dbFile , final boolean compressValues ) throws IOException { return PalDBKeyValueSink . forFile ( dbFile , compressValues ) ; }
Creates a new key - value sink backed by an embedded database .
6,411
public static < T > Set < T > sampleHashingSetWithoutReplacement ( final Set < T > sourceSet , final int numSamples , final Random rng ) { checkArgument ( numSamples <= sourceSet . size ( ) ) ; final List < Integer > selectedItems = distinctRandomIntsInRange ( rng , 0 , sourceSet . size ( ) , numSamples ) ; final Set < T > ret = Sets . newHashSet ( ) ; final Iterator < Integer > selectedItemsIterator = selectedItems . iterator ( ) ; if ( numSamples > 0 ) { int nextSelectedIdx = selectedItemsIterator . next ( ) ; int idx = 0 ; for ( final T item : sourceSet ) { if ( idx == nextSelectedIdx ) { ret . add ( item ) ; if ( selectedItemsIterator . hasNext ( ) ) { nextSelectedIdx = selectedItemsIterator . next ( ) ; } else { break ; } } ++ idx ; } } return ret ; }
Given a hash - based set and a desired number of samples N will create a new set by drawing N items without replacement from the original set . This takes at least linear time in the size of the source set since there is no way to pick out arbitrary elements of a set except by iteration .
6,412
public List < S > getPath ( ) { if ( this . path == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . path ) ; }
Replies the path used by this transformation .
6,413
public void setPath ( List < ? extends S > path , Direction1D direction ) { this . path = path == null || path . isEmpty ( ) ? null : new ArrayList < > ( path ) ; this . firstSegmentDirection = detectFirstSegmentDirection ( direction ) ; }
Set the path used by this transformation .
6,414
public void setIdentity ( ) { this . path = null ; this . firstSegmentDirection = detectFirstSegmentDirection ( null ) ; this . curvilineTranslation = 0. ; this . shiftTranslation = 0. ; this . isIdentity = Boolean . TRUE ; }
Set this transformation as identify ie all set to zero and no path .
6,415
public boolean isIdentity ( ) { if ( this . isIdentity == null ) { this . isIdentity = MathUtil . isEpsilonZero ( this . curvilineTranslation ) && MathUtil . isEpsilonZero ( this . curvilineTranslation ) ; } return this . isIdentity . booleanValue ( ) ; }
Replies if the transformation is the identity transformation .
6,416
public void setTranslation ( Tuple2D < ? > position ) { assert position != null : AssertMessages . notNullParameter ( ) ; this . curvilineTranslation = position . getX ( ) ; this . shiftTranslation = position . getY ( ) ; this . isIdentity = null ; }
Set the position . This function does not change the path .
6,417
public void translate ( Tuple2D < ? > move ) { assert move != null : AssertMessages . notNullParameter ( ) ; this . curvilineTranslation += move . getX ( ) ; this . shiftTranslation += move . getY ( ) ; this . isIdentity = null ; }
Translate the coordinates . This function does not change the path .
6,418
void add ( Iterable < SGraphSegment > segments ) { for ( final SGraphSegment segment : segments ) { this . segments . add ( segment ) ; } }
Add the given segments in the connection .
6,419
public static List < ConfigMetadataNode > extractConfigs ( ModulesMetadata modulesMetadata ) { final List < ModuleMetadata > modules = modulesMetadata . getModules ( ) . stream ( ) . collect ( Collectors . toList ( ) ) ; return modules . stream ( ) . map ( ModuleMetadata :: getConfigs ) . flatMap ( Collection :: stream ) . sorted ( Comparator . comparing ( MetadataNode :: getName ) ) . collect ( Collectors . toList ( ) ) ; }
Extract the configuration metadata nodes from the given metadata .
6,420
@ SuppressWarnings ( "checkstyle:npathcomplexity" ) public static void defineConfig ( Map < String , Object > content , ConfigMetadataNode config , Injector injector ) { assert content != null ; assert config != null ; final Class < ? > type = ( Class < ? > ) config . getType ( ) ; final String sectionName = config . getName ( ) ; final Pattern setPattern = Pattern . compile ( "^set([A-Z])([a-zA-Z0-9]+)$" ) ; Object theConfig = null ; for ( final Method setterMethod : type . getMethods ( ) ) { final Matcher matcher = setPattern . matcher ( setterMethod . getName ( ) ) ; if ( matcher . matches ( ) ) { final String firstLetter = matcher . group ( 1 ) ; final String rest = matcher . group ( 2 ) ; final String getterName = "get" + firstLetter + rest ; Method getterMethod = null ; try { getterMethod = type . getMethod ( getterName ) ; } catch ( Throwable exception ) { } if ( getterMethod != null && Modifier . isPublic ( getterMethod . getModifiers ( ) ) && ! Modifier . isAbstract ( getterMethod . getModifiers ( ) ) && ! Modifier . isStatic ( getterMethod . getModifiers ( ) ) ) { try { if ( theConfig == null ) { theConfig = injector . getInstance ( type ) ; } if ( theConfig != null ) { final Object value = filterValue ( getterMethod . getReturnType ( ) , getterMethod . invoke ( theConfig ) ) ; final String id = sectionName + "." + firstLetter . toLowerCase ( ) + rest ; defineScalar ( content , id , value ) ; } } catch ( Throwable exception ) { } } } } }
Add a config to a Yaml configuration map .
6,421
public static void defineScalar ( Map < String , Object > content , String bootiqueVariable , Object value ) throws Exception { final String [ ] elements = bootiqueVariable . split ( "\\." ) ; final Map < String , Object > entry = getScalarParent ( content , elements ) ; entry . put ( elements [ elements . length - 1 ] , value ) ; }
Add a scalar to a Yaml configuration map .
6,422
public static Permutation createForNElements ( final int numElements , final Random rng ) { final int [ ] permutation = IntUtils . arange ( numElements ) ; IntUtils . shuffle ( permutation , checkNotNull ( rng ) ) ; return new Permutation ( permutation ) ; }
Creates a random permutation of n elements using the supplied random number generator . Note that for all but small numbers of elements most possible permutations will not be sampled by this because the random generator s space is much smaller than the number of possible permutations .
6,423
public void permute ( final int [ ] arr ) { checkArgument ( arr . length == sources . length ) ; final int [ ] tmp = new int [ arr . length ] ; for ( int i = 0 ; i < tmp . length ; ++ i ) { tmp [ i ] = arr [ sources [ i ] ] ; } System . arraycopy ( tmp , 0 , arr , 0 , arr . length ) ; }
Applies this permutation in - place to the elements of an integer array
6,424
private boolean setChild1 ( N newChild ) { if ( this . child1 == newChild ) { return false ; } if ( this . child1 != null ) { this . child1 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 0 , this . child1 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child1 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 0 , newChild ) ; } return true ; }
Set the child 1 .
6,425
private boolean setChild2 ( N newChild ) { if ( this . child2 == newChild ) { return false ; } if ( this . child2 != null ) { this . child2 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 1 , this . child2 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child2 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 1 , newChild ) ; } return true ; }
Set the child 2 .
6,426
private boolean setChild3 ( N newChild ) { if ( this . child3 == newChild ) { return false ; } if ( this . child3 != null ) { this . child3 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 2 , this . child3 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child3 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 2 , newChild ) ; } return true ; }
Set the child 3 .
6,427
private boolean setChild4 ( N newChild ) { if ( this . child4 == newChild ) { return false ; } if ( this . child4 != null ) { this . child4 . setParentNodeReference ( null , true ) ; -- this . notNullChildCount ; firePropertyChildRemoved ( 3 , this . child4 ) ; } if ( newChild != null ) { final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this ) { newChild . removeFromParent ( ) ; } } this . child4 = newChild ; if ( newChild != null ) { newChild . setParentNodeReference ( toN ( ) , true ) ; ++ this . notNullChildCount ; firePropertyChildAdded ( 3 , newChild ) ; } return true ; }
Set the child 4 .
6,428
public static Vector2i convert ( Tuple2D < ? > tuple ) { if ( tuple instanceof Vector2i ) { return ( Vector2i ) tuple ; } return new Vector2i ( tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Vector2i .
6,429
String constructLogMsg ( ) { final StringBuilder msg = new StringBuilder ( ) ; for ( final Map . Entry < String , List < StackTraceElement > > e : paramToStackTrace . build ( ) . entries ( ) ) { msg . append ( "Parameter " ) . append ( e . getKey ( ) ) . append ( " accessed at \n" ) ; msg . append ( FluentIterable . from ( e . getValue ( ) ) . filter ( not ( IS_THIS_CLASS ) ) . filter ( not ( IS_PARAMETERS_ITSELF ) ) . filter ( not ( IS_THREAD_CLASS ) ) . join ( StringUtils . unixNewlineJoiner ( ) ) ) ; msg . append ( "\n\n" ) ; } return msg . toString ( ) ; }
pulled into method for testing
6,430
public static GraphicsDevice [ ] getAvailableScreens ( ) { final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; final GraphicsDevice [ ] graphicsDevices = graphicsEnvironment . getScreenDevices ( ) ; return graphicsDevices ; }
Gets the available screens .
6,431
public static boolean isScreenAvailableToShow ( final int screen ) { final GraphicsDevice [ ] graphicsDevices = getAvailableScreens ( ) ; boolean screenAvailableToShow = false ; if ( ( screen > - 1 && screen < graphicsDevices . length ) || ( graphicsDevices . length > 0 ) ) { screenAvailableToShow = true ; } return screenAvailableToShow ; }
Checks if the given screen number is available to show .
6,432
@ SuppressWarnings ( "unchecked" ) public static Module classNameToModule ( final Parameters parameters , final Class < ? > clazz , Optional < ? extends Class < ? extends Annotation > > annotation ) throws IllegalAccessException , InvocationTargetException , InstantiationException { if ( Module . class . isAssignableFrom ( clazz ) ) { return instantiateModule ( ( Class < ? extends Module > ) clazz , parameters , annotation ) ; } else { for ( final String fallbackInnerClassName : FALLBACK_INNER_CLASS_NAMES ) { final String fullyQualifiedName = clazz . getName ( ) + "$" + fallbackInnerClassName ; final Class < ? extends Module > innerModuleClazz ; try { innerModuleClazz = ( Class < ? extends Module > ) Class . forName ( fullyQualifiedName ) ; } catch ( ClassNotFoundException cnfe ) { continue ; } if ( Module . class . isAssignableFrom ( innerModuleClazz ) ) { return instantiateModule ( innerModuleClazz , parameters , annotation ) ; } else { throw new RuntimeException ( clazz . getName ( ) + " is not a module; " + fullyQualifiedName + " exists but is not a module" ) ; } } throw new RuntimeException ( "Could not find inner class of " + clazz . getName ( ) + " matching any of " + FALLBACK_INNER_CLASS_NAMES ) ; } }
Attempts to convert a module class name to an instantiate module by applying heuristics to construct it .
6,433
private static Optional < Module > instantiateWithPrivateConstructor ( Class < ? > clazz , Class < ? > [ ] parameters , Object ... paramVals ) throws InvocationTargetException , IllegalAccessException , InstantiationException { final Constructor < ? > constructor ; try { constructor = clazz . getDeclaredConstructor ( parameters ) ; } catch ( NoSuchMethodException e ) { return Optional . absent ( ) ; } final boolean oldAccessible = constructor . isAccessible ( ) ; constructor . setAccessible ( true ) ; try { return Optional . of ( ( Module ) constructor . newInstance ( paramVals ) ) ; } catch ( InstantiationException | IllegalAccessException | InvocationTargetException e ) { throw e ; } finally { constructor . setAccessible ( oldAccessible ) ; } }
Instantiates a module which may have a private constructor . You can t call private constructors in Java unless you first make the constructor un - private . After doing so however we should clean up after ourselves and restore the previous state .
6,434
public static < K , V > PairedMapValues < V > zipValues ( final Map < K , V > left , final Map < K , V > right ) { checkNotNull ( left ) ; checkNotNull ( right ) ; final ImmutableList . Builder < ZipPair < V , V > > pairedValues = ImmutableList . builder ( ) ; final ImmutableList . Builder < V > leftOnly = ImmutableList . builder ( ) ; final ImmutableList . Builder < V > rightOnly = ImmutableList . builder ( ) ; for ( final Map . Entry < K , V > leftEntry : left . entrySet ( ) ) { final K key = leftEntry . getKey ( ) ; if ( right . containsKey ( key ) ) { pairedValues . add ( ZipPair . from ( leftEntry . getValue ( ) , right . get ( key ) ) ) ; } else { leftOnly . add ( leftEntry . getValue ( ) ) ; } } for ( final Map . Entry < K , V > rightEntry : right . entrySet ( ) ) { if ( ! left . containsKey ( rightEntry . getKey ( ) ) ) { rightOnly . add ( rightEntry . getValue ( ) ) ; } } return new PairedMapValues < V > ( pairedValues . build ( ) , leftOnly . build ( ) , rightOnly . build ( ) ) ; }
Pairs up the values of a map by their common keys .
6,435
public static < T > ImmutableMap < T , Integer > indexMap ( Iterable < ? extends T > items ) { final ImmutableMap . Builder < T , Integer > ret = ImmutableMap . builder ( ) ; int idx = 0 ; for ( final T item : items ) { ret . put ( item , idx ++ ) ; } return ret . build ( ) ; }
Builds a map from sequence items to their zero - indexed positions in the sequence .
6,436
public static < V > int longestKeyLength ( Map < String , V > map ) { if ( map . isEmpty ( ) ) { return 0 ; } return Ordering . natural ( ) . max ( FluentIterable . from ( map . keySet ( ) ) . transform ( StringUtils . lengthFunction ( ) ) ) ; }
Returns the length of the longest key in a map or 0 if the map is empty . Useful for printing tables etc . The map may not have any null keys .
6,437
public static double getPreferredRadius ( ) { final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { return prefs . getDouble ( "RADIUS" , DEFAULT_RADIUS ) ; } return DEFAULT_RADIUS ; }
Replies the default radius for map elements .
6,438
public static void setPreferredRadius ( double radius ) { assert ! Double . isNaN ( radius ) ; final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { prefs . putDouble ( "RADIUS" , radius ) ; try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { } } }
Set the default radius for map elements .
6,439
public static int getPreferredColor ( ) { final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { return prefs . getInt ( "COLOR" , DEFAULT_COLOR ) ; } return DEFAULT_COLOR ; }
Replies the default color for map elements .
6,440
public static void setPreferredColor ( int color ) { final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { prefs . putInt ( "COLOR" , color ) ; try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { } } }
Set the default color for map elements .
6,441
public static PhysicsEngine setPhysicsEngine ( PhysicsEngine newEngine ) { final PhysicsEngine oldEngine = engine ; if ( newEngine == null ) { engine = new JavaPhysicsEngine ( ) ; } else { engine = newEngine ; } return oldEngine ; }
Set the current physics engine .
6,442
@ Inline ( value = "PhysicsUtil.getPhysicsEngine().speed(($1), ($2))" , imported = { PhysicsUtil . class } ) public static double speed ( double movement , double dt ) { return engine . speed ( movement , dt ) ; }
Replies the new velocity according to a previous velocity and a mouvement during a given time .
6,443
@ Inline ( value = "PhysicsUtil.getPhysicsEngine().acceleration(($1), ($2), ($3))" , imported = { PhysicsUtil . class } ) public static double acceleration ( double previousSpeed , double currentSpeed , double dt ) { return engine . acceleration ( previousSpeed , currentSpeed , dt ) ; }
Replies the new acceleration according to a previous velocity and a current velocity and given time .
6,444
public static List < Point > computeDialogPositions ( final int dialogWidth , final int dialogHeight ) { List < Point > dialogPosition = null ; final int windowBesides = ScreenSizeExtensions . getScreenWidth ( ) / dialogWidth ; final int windowBelow = ScreenSizeExtensions . getScreenHeight ( ) / dialogHeight ; final int listSize = windowBesides * windowBelow ; dialogPosition = new ArrayList < > ( listSize ) ; int dotWidth = 0 ; int dotHeight = 0 ; for ( int y = 0 ; y < windowBelow ; y ++ ) { dotWidth = 0 ; for ( int x = 0 ; x < windowBesides ; x ++ ) { final Point p = new Point ( dotWidth , dotHeight ) ; dialogPosition . add ( p ) ; dotWidth = dotWidth + dialogWidth ; } dotHeight = dotHeight + dialogHeight ; } return dialogPosition ; }
Compute how much dialog can be put into the screen and returns a list with the coordinates from the dialog positions as Point objects .
6,445
public static GraphicsDevice [ ] getScreenDevices ( ) { final GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; final GraphicsDevice [ ] gs = ge . getScreenDevices ( ) ; return gs ; }
Gets all the screen devices .
6,446
public static Dimension getScreenDimension ( Component component ) { int screenID = getScreenID ( component ) ; Dimension dimension = new Dimension ( 0 , 0 ) ; GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; GraphicsConfiguration defaultConfiguration = ge . getScreenDevices ( ) [ screenID ] . getDefaultConfiguration ( ) ; Rectangle rectangle = defaultConfiguration . getBounds ( ) ; dimension . setSize ( rectangle . getWidth ( ) , rectangle . getHeight ( ) ) ; return dimension ; }
Gets the screen dimension .
6,447
public static int getScreenID ( Component component ) { int screenID ; final AtomicInteger counter = new AtomicInteger ( - 1 ) ; Stream . of ( getScreenDevices ( ) ) . forEach ( graphicsDevice -> { GraphicsConfiguration gc = graphicsDevice . getDefaultConfiguration ( ) ; Rectangle rectangle = gc . getBounds ( ) ; if ( rectangle . contains ( component . getLocation ( ) ) ) { try { Object object = ReflectionExtensions . getFieldValue ( graphicsDevice , "screen" ) ; Integer sid = ( Integer ) object ; counter . set ( sid ) ; } catch ( NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e ) { e . printStackTrace ( ) ; } } } ) ; screenID = counter . get ( ) ; return screenID ; }
Gets the screen ID from the given component
6,448
public Rectangle2d getCellBounds ( int row , int column ) { final double cellWidth = getCellWidth ( ) ; final double cellHeight = getCellHeight ( ) ; final double x = this . bounds . getMinX ( ) + cellWidth * column ; final double y = this . bounds . getMinY ( ) + cellHeight * row ; return new Rectangle2d ( x , y , cellWidth , cellHeight ) ; }
Replies the bounds covered by a cell at the specified location .
6,449
public GridCell < P > createCellAt ( int row , int column ) { GridCell < P > cell = this . cells [ row ] [ column ] ; if ( cell == null ) { cell = new GridCell < > ( row , column , getCellBounds ( row , column ) ) ; this . cells [ row ] [ column ] = cell ; ++ this . cellCount ; } return cell ; }
Create a cell at the specified location if there is no cell at this location .
6,450
public GridCell < P > removeCellAt ( int row , int column ) { final GridCell < P > cell = this . cells [ row ] [ column ] ; if ( cell != null ) { this . cells [ row ] [ column ] = null ; -- this . cellCount ; for ( final P element : cell ) { removeElement ( element ) ; } } return cell ; }
Remove the cell at the specified location .
6,451
public boolean addElement ( P element ) { boolean changed = false ; if ( element != null ) { final GridCellElement < P > gridElement = new GridCellElement < > ( element ) ; for ( final GridCell < P > cell : getGridCellsOn ( element . getGeoLocation ( ) . toBounds2D ( ) , true ) ) { if ( cell . addElement ( gridElement ) ) { changed = true ; } } } if ( changed ) { ++ this . elementCount ; } return changed ; }
Add the element in the grid .
6,452
public boolean removeElement ( P element ) { boolean changed = false ; if ( element != null ) { GridCellElement < P > gridElement ; for ( final GridCell < P > cell : getGridCellsOn ( element . getGeoLocation ( ) . toBounds2D ( ) ) ) { gridElement = cell . removeElement ( element ) ; if ( gridElement != null ) { if ( cell . isEmpty ( ) ) { this . cells [ cell . row ( ) ] [ cell . column ( ) ] = null ; -- this . cellCount ; } for ( final GridCell < P > otherCell : gridElement . consumeCells ( ) ) { assert otherCell != cell ; otherCell . removeElement ( element ) ; if ( otherCell . isEmpty ( ) ) { this . cells [ otherCell . row ( ) ] [ otherCell . column ( ) ] = null ; -- this . cellCount ; } } changed = true ; } } } if ( changed ) { -- this . elementCount ; } return changed ; }
Remove the element at the specified location .
6,453
public int getColumnFor ( double x ) { final double xx = x - this . bounds . getMinX ( ) ; if ( xx >= 0. ) { final int idx = ( int ) ( xx / getCellWidth ( ) ) ; assert idx >= 0 ; if ( idx < getColumnCount ( ) ) { return idx ; } return getColumnCount ( ) - 1 ; } return 0 ; }
Replies the column index for the specified position .
6,454
public int getRowFor ( double y ) { final double yy = y - this . bounds . getMinY ( ) ; if ( yy >= 0. ) { final int idx = ( int ) ( yy / getCellHeight ( ) ) ; assert idx >= 0 ; if ( idx < getRowCount ( ) ) { return idx ; } return getRowCount ( ) - 1 ; } return 0 ; }
Replies the row index for the specified position .
6,455
public AroundCellIterable < P > getGridCellsAround ( Point2D < ? , ? > position , double maximalDistance ) { final int column = getColumnFor ( position . getX ( ) ) ; final int row = getRowFor ( position . getY ( ) ) ; return new AroundIterable ( row , column , position , maximalDistance ) ; }
Replies the cells around the specified point . The order of the replied cells follows cocentric circles around the cell that contains the specified point .
6,456
public Iterator < P > iterator ( Rectangle2afp < ? , ? , ? , ? , ? , ? > bounds ) { if ( this . bounds . intersects ( bounds ) ) { final int c1 = getColumnFor ( bounds . getMinX ( ) ) ; final int r1 = getRowFor ( bounds . getMinY ( ) ) ; final int c2 = getColumnFor ( bounds . getMaxX ( ) ) ; final int r2 = getRowFor ( bounds . getMaxY ( ) ) ; return new BoundedElementIterator ( new CellIterator ( r1 , c1 , r2 , c2 , false ) , - 1 , bounds ) ; } return Collections . < P > emptyList ( ) . iterator ( ) ; }
Replies the elements that are inside the cells intersecting the specified bounds .
6,457
public P getElementAt ( int index ) { if ( index >= 0 ) { int idx = 0 ; int eIdx ; for ( final GridCell < P > cell : getGridCells ( ) ) { eIdx = idx + cell . getReferenceElementCount ( ) ; if ( index < eIdx ) { try { return cell . getElementAt ( index - idx ) ; } catch ( IndexOutOfBoundsException exception ) { throw new IndexOutOfBoundsException ( Integer . toString ( index ) ) ; } } idx = eIdx ; } } throw new IndexOutOfBoundsException ( Integer . toString ( index ) ) ; }
Replies the element at the specified index .
6,458
protected final Object blockingWrite ( SelectableChannel channel , WriteMessage message , IoBuffer writeBuffer ) throws IOException , ClosedChannelException { SelectionKey tmpKey = null ; Selector writeSelector = null ; int attempts = 0 ; int bytesProduced = 0 ; try { while ( writeBuffer . hasRemaining ( ) ) { long len = doRealWrite ( channel , writeBuffer ) ; if ( len > 0 ) { attempts = 0 ; bytesProduced += len ; statistics . statisticsWrite ( len ) ; } else { attempts ++ ; if ( writeSelector == null ) { writeSelector = SelectorFactory . getSelector ( ) ; if ( writeSelector == null ) { continue ; } tmpKey = channel . register ( writeSelector , SelectionKey . OP_WRITE ) ; } if ( writeSelector . select ( 1000 ) == 0 ) { if ( attempts > 2 ) { throw new IOException ( "Client disconnected" ) ; } } } } if ( ! writeBuffer . hasRemaining ( ) && message . getWriteFuture ( ) != null ) { message . getWriteFuture ( ) . setResult ( Boolean . TRUE ) ; } } finally { if ( tmpKey != null ) { tmpKey . cancel ( ) ; tmpKey = null ; } if ( writeSelector != null ) { writeSelector . selectNow ( ) ; SelectorFactory . returnSelector ( writeSelector ) ; } } scheduleWritenBytes . addAndGet ( 0 - bytesProduced ) ; return message . getMessage ( ) ; }
Blocking write using temp selector
6,459
private int setSecDataArr ( HashMap m , ArrayList arr , boolean isEvent ) { int idx = setSecDataArr ( m , arr ) ; if ( idx != 0 && isEvent && getValueOr ( m , "date" , "" ) . equals ( "" ) ) { return - 1 ; } else { return idx ; } }
Get index value of the record and set new id value in the array . In addition it will check if the event date is available . If not then return 0 .
6,460
private boolean isPlotInfoExist ( Map expData ) { String [ ] plotIds = { "plta" , "pltr#" , "pltln" , "pldr" , "pltsp" , "pllay" , "pltha" , "plth#" , "plthl" , "plthm" } ; for ( String plotId : plotIds ) { if ( ! getValueOr ( expData , plotId , "" ) . equals ( "" ) ) { return true ; } } return false ; }
To check if there is plot info data existed in the experiment
6,461
private boolean isSoilAnalysisExist ( ArrayList < HashMap > icSubArr ) { for ( HashMap icSubData : icSubArr ) { if ( ! getValueOr ( icSubData , "slsc" , "" ) . equals ( "" ) ) { return true ; } } return false ; }
To check if there is soil analysis info data existed in the experiment
6,462
private ArrayList < HashMap > getDataList ( Map expData , String blockName , String dataListName ) { HashMap dataBlock = getObjectOr ( expData , blockName , new HashMap ( ) ) ; return getObjectOr ( dataBlock , dataListName , new ArrayList < HashMap > ( ) ) ; }
Get sub data array from experiment data object
6,463
public Set < CellFiller > entries ( ) { return FluentIterable . from ( table . cellSet ( ) ) . transformAndConcat ( CollectionUtils . < List < CellFiller > > TableCellValue ( ) ) . toSet ( ) ; }
Returns all provenance entries in this matrix regardless of cell .
6,464
public < SignatureType > BrokenDownProvenancedConfusionMatrix < SignatureType , CellFiller > breakdown ( Function < ? super CellFiller , SignatureType > signatureFunction , Ordering < SignatureType > keyOrdering ) { final Map < SignatureType , Builder < CellFiller > > ret = Maps . newHashMap ( ) ; for ( final Symbol leftLabel : leftLabels ( ) ) { for ( final Symbol rightLabel : rightLabels ( ) ) { for ( final CellFiller provenance : cell ( leftLabel , rightLabel ) ) { final SignatureType signature = signatureFunction . apply ( provenance ) ; checkNotNull ( signature , "Provenance function may never return null" ) ; if ( ! ret . containsKey ( signature ) ) { ret . put ( signature , ProvenancedConfusionMatrix . < CellFiller > builder ( ) ) ; } ret . get ( signature ) . record ( leftLabel , rightLabel , provenance ) ; } } } final ImmutableMap . Builder < SignatureType , ProvenancedConfusionMatrix < CellFiller > > trueRet = ImmutableMap . builder ( ) ; for ( final Map . Entry < SignatureType , Builder < CellFiller > > entry : MapUtils . < SignatureType , Builder < CellFiller > > byKeyOrdering ( keyOrdering ) . sortedCopy ( ret . entrySet ( ) ) ) { trueRet . put ( entry . getKey ( ) , entry . getValue ( ) . build ( ) ) ; } return BrokenDownProvenancedConfusionMatrix . fromMap ( trueRet . build ( ) ) ; }
Allows generating breakdowns of a provenanced confusion matrix according to some criteria . For example a confusion matrix for an event detection task could be further broken down into separate confusion matrices for each event type .
6,465
public static String getContentType ( String filename ) { final ContentFileTypeMap map = ensureContentTypeManager ( ) ; return map . getContentType ( filename ) ; }
Replies the MIME type of the given file .
6,466
public static String getFormatVersion ( File filename ) { final ContentFileTypeMap map = ensureContentTypeManager ( ) ; return map . getFormatVersion ( filename ) ; }
Replies the version of the format of the given file .
6,467
public static boolean isImage ( String mime ) { try { final MimeType type = new MimeType ( mime ) ; return IMAGE . equalsIgnoreCase ( type . getPrimaryType ( ) ) ; } catch ( MimeTypeParseException e ) { } return false ; }
Replies if the specified MIME type corresponds to an image .
6,468
public static boolean isContentType ( URL filename , String desiredMimeType ) { final ContentFileTypeMap map = ensureContentTypeManager ( ) ; return map . isContentType ( filename , desiredMimeType ) ; }
Replies if the given file is compatible with the given MIME type .
6,469
public static Method getPublicMethod ( Class < ? > clazz , String methodName , Class < ? > [ ] argTypes ) { assertObjectNotNull ( "clazz" , clazz ) ; assertStringNotNullAndNotTrimmedEmpty ( "methodName" , methodName ) ; return findMethod ( clazz , methodName , argTypes , VisibilityType . PUBLIC , false ) ; }
Get the public method .
6,470
public static Object invoke ( Method method , Object target , Object [ ] args ) { assertObjectNotNull ( "method" , method ) ; try { return method . invoke ( target , args ) ; } catch ( InvocationTargetException e ) { Throwable t = e . getCause ( ) ; if ( t instanceof RuntimeException ) { throw ( RuntimeException ) t ; } if ( t instanceof Error ) { throw ( Error ) t ; } String msg = "The InvocationTargetException occurred: " ; msg = msg + " method=" + method + " target=" + target ; msg = msg + " args=" + ( args != null ? Arrays . asList ( args ) : "" ) ; throw new ReflectionFailureException ( msg , t ) ; } catch ( IllegalArgumentException e ) { String msg = "Illegal argument for the method:" ; msg = msg + " method=" + method + " target=" + target ; msg = msg + " args=" + ( args != null ? Arrays . asList ( args ) : "" ) ; throw new ReflectionFailureException ( msg , e ) ; } catch ( IllegalAccessException e ) { String msg = "Illegal access to the method:" ; msg = msg + " method=" + method + " target=" + target ; msg = msg + " args=" + ( args != null ? Arrays . asList ( args ) : "" ) ; throw new ReflectionFailureException ( msg , e ) ; } }
Invoke the method by reflection .
6,471
public static void assertStringNotNullAndNotTrimmedEmpty ( String variableName , String value ) { assertObjectNotNull ( "variableName" , variableName ) ; assertObjectNotNull ( "value" , value ) ; if ( value . trim ( ) . length ( ) == 0 ) { String msg = "The value should not be empty: variableName=" + variableName + " value=" + value ; throw new IllegalArgumentException ( msg ) ; } }
Assert that the entity is not null and not trimmed empty .
6,472
public static Optional < Element > nextSibling ( final Element element , final String name ) { for ( Node childNode = element . getNextSibling ( ) ; childNode != null ; childNode = childNode . getNextSibling ( ) ) { if ( childNode instanceof Element && ( ( Element ) childNode ) . getTagName ( ) . equalsIgnoreCase ( name ) ) { return Optional . of ( ( Element ) childNode ) ; } } return Optional . absent ( ) ; }
Returns the element s next sibling with a tag matching the given name .
6,473
public static String prettyPrintElementLocally ( Element e ) { final ImmutableMap . Builder < String , String > ret = ImmutableMap . builder ( ) ; final NamedNodeMap attributes = e . getAttributes ( ) ; for ( int i = 0 ; i < attributes . getLength ( ) ; ++ i ) { final Node attr = attributes . item ( i ) ; ret . put ( attr . getNodeName ( ) , "\"" + attr . getNodeValue ( ) + "\"" ) ; } return "<" + e . getNodeName ( ) + " " + Joiner . on ( " " ) . withKeyValueSeparator ( "=" ) . join ( ret . build ( ) ) + "/>" ; }
A human - consumable string representation of an element with its attributes but without its children . Do not depend on the particular form of this .
6,474
public static Point1d convert ( Tuple1d < ? > tuple ) { if ( tuple instanceof Point1d ) { return ( Point1d ) tuple ; } return new Point1d ( tuple . getSegment ( ) , tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Point1d .
6,475
public static GeodesicPosition EL2_WSG84 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2E_N , LAMBERT_2E_C , LAMBERT_2E_XS , LAMBERT_2E_YS ) ; return NTFLambdaPhi_WSG84 ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) ) ; }
This function convert extended France Lambert II coordinate to geographic WSG84 Data .
6,476
public static Point2d EL2_L2 ( double x , double y ) { return new Point2d ( x , y + ( LAMBERT_2E_YS - LAMBERT_2_YS ) ) ; }
This function convert extended France Lambert II coordinate to France Lambert II coordinate .
6,477
public static Point2d EL2_L3 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2E_N , LAMBERT_2E_C , LAMBERT_2E_XS , LAMBERT_2E_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; }
This function convert extended France Lambert II coordinate to France Lambert III coordinate .
6,478
public static GeodesicPosition L1_WSG84 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; return NTFLambdaPhi_WSG84 ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) ) ; }
This function convert France Lambert I coordinate to geographic WSG84 Data .
6,479
public static Point2d L1_EL2 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_2E_N , LAMBERT_2E_C , LAMBERT_2E_XS , LAMBERT_2E_YS ) ; }
This function convert France Lambert I coordinate to extended France Lambert II coordinate .
6,480
public static Point2d L1_L3 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; }
This function convert France Lambert I coordinate to France Lambert III coordinate .
6,481
public static Point2d L1_L4 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; }
This function convert France Lambert I coordinate to France Lambert IV coordinate .
6,482
public static GeodesicPosition L2_WSG84 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2_N , LAMBERT_2_C , LAMBERT_2_XS , LAMBERT_2_YS ) ; return NTFLambdaPhi_WSG84 ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) ) ; }
This function convert France Lambert II coordinate to geographic WSG84 Data .
6,483
public static Point2d L2_EL2 ( double x , double y ) { return new Point2d ( x , y - ( LAMBERT_2E_YS - LAMBERT_2_YS ) ) ; }
This function convert France Lambert II coordinate to extended France Lambert II coordinate .
6,484
public static Point2d L2_L1 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2_N , LAMBERT_2_C , LAMBERT_2_XS , LAMBERT_2_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; }
This function convert France Lambert II coordinate to France Lambert I coordinate .
6,485
public static Point2d L2_L3 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2_N , LAMBERT_2_C , LAMBERT_2_XS , LAMBERT_2_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; }
This function convert France Lambert II coordinate to France Lambert III coordinate .
6,486
public static Point2d L2_L4 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2_N , LAMBERT_2_C , LAMBERT_2_XS , LAMBERT_2_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; }
This function convert France Lambert II coordinate to France Lambert IV coordinate .
6,487
public static Point2d L2_L93 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_2_N , LAMBERT_2_C , LAMBERT_2_XS , LAMBERT_2_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; }
This function convert France Lambert II coordinate to France Lambert 93 coordinate .
6,488
public static GeodesicPosition L3_WSG84 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; return NTFLambdaPhi_WSG84 ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) ) ; }
This function convert France Lambert III coordinate to geographic WSG84 Data .
6,489
public static Point2d L3_L4 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; }
This function convert France Lambert III coordinate to France Lambert IV coordinate .
6,490
public static Point2d L3_L93 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; }
This function convert France Lambert III coordinate to France Lambert 93 coordinate .
6,491
public static GeodesicPosition L4_WSG84 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; return NTFLambdaPhi_WSG84 ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) ) ; }
This function convert France Lambert IV coordinate to geographic WSG84 Data .
6,492
public static Point2d L4_EL2 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_2E_N , LAMBERT_2E_C , LAMBERT_2E_XS , LAMBERT_2E_YS ) ; }
This function convert France Lambert IV coordinate to extended France Lambert II coordinate .
6,493
public static GeodesicPosition L93_WSG84 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; return NTFLambdaPhi_WSG84 ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) ) ; }
This function convert France Lambert 93 coordinate to geographic WSG84 Data .
6,494
public static Point2d L93_EL2 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_2E_N , LAMBERT_2E_C , LAMBERT_2E_XS , LAMBERT_2E_YS ) ; }
This function convert France Lambert 93 coordinate to extended France Lambert II coordinate .
6,495
public static Point2d L93_L1 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; }
This function convert France Lambert 93 coordinate to France Lambert I coordinate .
6,496
public static Point2d L93_L4 ( double x , double y ) { final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi ( x , y , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; }
This function convert France Lambert 93 coordinate to France Lambert IV coordinate .
6,497
@ SuppressWarnings ( { "checkstyle:parametername" , "checkstyle:localfinalvariablename" } ) private static Point2d NTFLambert_NTFLambdaPhi ( double x , double y , double n , double c , double Xs , double Ys ) { final double lambda_0 = 0. ; final double R = Math . hypot ( x - Xs , y - Ys ) ; final double g = Math . atan ( ( x - Xs ) / ( Ys - y ) ) ; final double lamdda_ntf = lambda_0 + ( g / n ) ; final double L = - ( 1 / n ) * Math . log ( Math . abs ( R / c ) ) ; final double phi0 = 2 * Math . atan ( Math . exp ( L ) ) - ( Math . PI / 2.0 ) ; double phiprec = phi0 ; double phii = compute1 ( phiprec , L ) ; while ( Math . abs ( phii - phiprec ) >= EPSILON ) { phiprec = phii ; phii = compute1 ( phiprec , L ) ; } final double phi_ntf = phii ; return new Point2d ( lamdda_ntf , phi_ntf ) ; }
This function convert extended France NTF Lambert coordinate to Angular NTF coordinate .
6,498
@ SuppressWarnings ( { "checkstyle:magicnumber" , "checkstyle:localfinalvariablename" , "checkstyle:localvariablename" } ) private static GeodesicPosition NTFLambdaPhi_WSG84 ( double lambda_ntf , double phi_ntf ) { double a = 6378249.2 ; final double h = 100 ; final double N = a / Math . pow ( 1. - ( NTF_E * NTF_E ) * ( Math . sin ( phi_ntf ) * Math . sin ( phi_ntf ) ) , .5 ) ; final double x_ntf = ( N + h ) * Math . cos ( phi_ntf ) * Math . cos ( lambda_ntf ) ; final double y_ntf = ( N + h ) * Math . cos ( phi_ntf ) * Math . sin ( lambda_ntf ) ; final double z_ntf = ( ( N * ( 1. - ( NTF_E * NTF_E ) ) ) + h ) * Math . sin ( phi_ntf ) ; final double x_w = x_ntf - 168. ; final double y_w = y_ntf - 60. ; final double z_w = z_ntf + 320 ; final double l840 = 0.04079234433 ; a = 6378137.0 ; final double P = Math . hypot ( x_w , y_w ) ; double lambda_w = l840 + Math . atan ( y_w / x_w ) ; double phi0_w = Math . atan ( z_w / ( P * ( 1 - ( ( a * WSG84_E * WSG84_E ) ) / Math . sqrt ( ( x_w * x_w ) + ( y_w * y_w ) + ( z_w * z_w ) ) ) ) ) ; double phi_w = Math . atan ( ( z_w / P ) / ( 1 - ( ( a * WSG84_E * WSG84_E * Math . cos ( phi0_w ) ) / ( P * Math . sqrt ( 1 - NTF_E * NTF_E * ( Math . sin ( phi0_w ) * Math . sin ( phi0_w ) ) ) ) ) ) ) ; while ( Math . abs ( phi_w - phi0_w ) >= EPSILON ) { phi0_w = phi_w ; phi_w = Math . atan ( ( z_w / P ) / ( 1 - ( ( a * WSG84_E * WSG84_E * Math . cos ( phi0_w ) ) / ( P * Math . sqrt ( 1 - ( ( WSG84_E * WSG84_E ) * ( Math . sin ( phi0_w ) * Math . sin ( phi0_w ) ) ) ) ) ) ) ) ; } lambda_w = Math . toDegrees ( lambda_w ) ; phi_w = Math . toDegrees ( phi_w ) ; return new GeodesicPosition ( lambda_w , phi_w ) ; }
This function convert extended France NTF Lambert coordinate to geographic WSG84 Data .
6,499
public static Point2d WSG84_EL2 ( double lambda , double phi ) { final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi ( lambda , phi ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_2E_N , LAMBERT_2E_C , LAMBERT_2E_XS , LAMBERT_2E_YS ) ; }
This function convert WSG84 GPS coordinate to extended France Lambert II coordinate .