idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
6,400
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 .
46
9
6,401
@ Nonnull 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 .
53
14
6,402
public static < T > Set < T > sampleHashingSetWithoutReplacement ( final Set < T > sourceSet , final int numSamples , final Random rng ) { checkArgument ( numSamples <= sourceSet . size ( ) ) ; // first we find the indices of the selected elements 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 ) { // now we walk through sourceSet in order to find the items at // the indices we selected. It doens't matter that the iteration // order over the set isn't guaranteed because the indices are // random anyway 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 { // we may (and probably will) run out of selected indices // before we run out of items in the set, unless the // last index is selected. 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 .
304
59
6,403
@ Pure public List < S > getPath ( ) { if ( this . path == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( this . path ) ; }
Replies the path used by this transformation .
44
9
6,404
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 .
64
8
6,405
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 .
61
14
6,406
@ Pure 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 .
77
10
6,407
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 .
66
12
6,408
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 .
65
13
6,409
void add ( Iterable < SGraphSegment > segments ) { for ( final SGraphSegment segment : segments ) { this . segments . add ( segment ) ; } }
Add the given segments in the connection .
37
8
6,410
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 .
110
11
6,411
@ 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]+)$" ) ; //$NON-NLS-1$ 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 ; //$NON-NLS-1$ 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 ; //$NON-NLS-1$ defineScalar ( content , id , value ) ; } } catch ( Throwable exception ) { // } } } } }
Add a config to a Yaml configuration map .
446
10
6,412
public static void defineScalar ( Map < String , Object > content , String bootiqueVariable , Object value ) throws Exception { final String [ ] elements = bootiqueVariable . split ( "\\." ) ; //$NON-NLS-1$ final Map < String , Object > entry = getScalarParent ( content , elements ) ; entry . put ( elements [ elements . length - 1 ] , value ) ; }
Add a scalar to a Yaml configuration map .
91
11
6,413
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 .
70
52
6,414
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
89
15
6,415
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 .
170
5
6,416
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 .
170
5
6,417
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 .
170
5
6,418
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 .
170
5
6,419
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 .
58
12
6,420
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 ( ) ) // but exclude code in Parameters itself . 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
186
6
6,421
public static GraphicsDevice [ ] getAvailableScreens ( ) { final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; final GraphicsDevice [ ] graphicsDevices = graphicsEnvironment . getScreenDevices ( ) ; return graphicsDevices ; }
Gets the available screens .
54
6
6,422
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 .
81
12
6,423
@ Nonnull // it's reflection, can't avoid unchecked cast @ 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 { // to abbreviate the names of modules in param files, if a class name is provided which // is not a Module, we check if there is an inner-class named Module which is a Module 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 ) { // it's okay, we just try the next one 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" ) ; } } // if we got here, we didn't find any 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 .
397
21
6,424
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 .
171
47
6,425
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 .
298
13
6,426
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 .
82
17
6,427
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 .
72
33
6,428
@ Pure public static double getPreferredRadius ( ) { final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { return prefs . getDouble ( "RADIUS" , DEFAULT_RADIUS ) ; //$NON-NLS-1$ } return DEFAULT_RADIUS ; }
Replies the default radius for map elements .
85
9
6,429
public static void setPreferredRadius ( double radius ) { assert ! Double . isNaN ( radius ) ; final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { prefs . putDouble ( "RADIUS" , radius ) ; //$NON-NLS-1$ try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { // } } }
Set the default radius for map elements .
101
8
6,430
@ Pure public static int getPreferredColor ( ) { final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { return prefs . getInt ( "COLOR" , DEFAULT_COLOR ) ; //$NON-NLS-1$ } return DEFAULT_COLOR ; }
Replies the default color for map elements .
75
9
6,431
public static void setPreferredColor ( int color ) { final Preferences prefs = Preferences . userNodeForPackage ( MapElementConstants . class ) ; if ( prefs != null ) { prefs . putInt ( "COLOR" , color ) ; //$NON-NLS-1$ try { prefs . flush ( ) ; } catch ( BackingStoreException exception ) { // } } }
Set the default color for map elements .
86
8
6,432
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 .
55
6
6,433
@ Pure @ 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 .
64
21
6,434
@ Pure @ 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 .
78
18
6,435
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 .
189
26
6,436
public static GraphicsDevice [ ] getScreenDevices ( ) { final GraphicsEnvironment ge = GraphicsEnvironment . getLocalGraphicsEnvironment ( ) ; final GraphicsDevice [ ] gs = ge . getScreenDevices ( ) ; return gs ; }
Gets all the screen devices .
50
7
6,437
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 .
109
6
6,438
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
176
9
6,439
@ Pure 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 .
98
13
6,440
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 .
87
16
6,441
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 .
81
8
6,442
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 .
113
7
6,443
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 .
221
8
6,444
@ Pure 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 .
91
10
6,445
@ Pure 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 .
94
10
6,446
@ Pure 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 .
80
28
6,447
@ Pure 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 .
165
15
6,448
@ Pure 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 .
148
9
6,449
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 using the main one. 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 ) { // Cancel the key. writeSelector . selectNow ( ) ; SelectorFactory . returnSelector ( writeSelector ) ; } } scheduleWritenBytes . addAndGet ( 0 - bytesProduced ) ; return message . getMessage ( ) ; }
Blocking write using temp selector
339
6
6,450
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 .
78
33
6,451
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
122
12
6,452
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
69
13
6,453
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
71
8
6,454
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 .
57
12
6,455
public < SignatureType > BrokenDownProvenancedConfusionMatrix < SignatureType , CellFiller > breakdown ( Function < ? super CellFiller , SignatureType > signatureFunction , Ordering < SignatureType > keyOrdering ) { final Map < SignatureType , Builder < CellFiller > > ret = Maps . newHashMap ( ) ; // a more efficient implementation should be used if the confusion matrix is // large and sparse, but this is unlikely. ~ rgabbard 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 ( ) ; // to get consistent output, we make sure to sort by the keys 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 .
385
40
6,456
public static String getContentType ( String filename ) { final ContentFileTypeMap map = ensureContentTypeManager ( ) ; return map . getContentType ( filename ) ; }
Replies the MIME type of the given file .
36
11
6,457
public static String getFormatVersion ( File filename ) { final ContentFileTypeMap map = ensureContentTypeManager ( ) ; return map . getFormatVersion ( filename ) ; }
Replies the version of the format of the given file .
36
12
6,458
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 .
64
13
6,459
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 .
47
15
6,460
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 .
85
5
6,461
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 .
311
7
6,462
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 .
99
13
6,463
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 .
106
14
6,464
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 .
159
28
6,465
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 .
66
12
6,466
@ Pure 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 .
132
15
6,467
@ Pure 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 .
53
14
6,468
@ Pure 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 .
168
14
6,469
@ Pure 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 .
128
14
6,470
@ Pure 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 .
168
14
6,471
@ Pure 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 .
164
13
6,472
@ Pure 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 .
164
13
6,473
@ Pure 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 .
128
14
6,474
@ Pure 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 .
53
14
6,475
@ Pure 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 .
164
13
6,476
@ Pure 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 .
164
13
6,477
@ Pure 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 .
164
13
6,478
@ Pure 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 .
164
13
6,479
@ Pure 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 .
128
14
6,480
@ Pure 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 .
164
13
6,481
@ Pure 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 .
164
13
6,482
@ Pure 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 .
128
14
6,483
@ Pure 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 .
168
14
6,484
@ Pure 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 .
128
14
6,485
@ Pure 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 .
168
14
6,486
@ Pure 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 .
164
13
6,487
@ Pure 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 .
164
13
6,488
@ SuppressWarnings ( { "checkstyle:parametername" , "checkstyle:localfinalvariablename" } ) private static Point2d NTFLambert_NTFLambdaPhi ( double x , double y , double n , double c , double Xs , double Ys ) { // Several constants from the IGN specifications //Longitude in radians of Paris (2°20'14.025" E) from Greenwich final double lambda_0 = 0. ; // Extended Lambert II (x,y) -> graphical coordinate NTF (lambda_ntf,phi_ntf) // ALG0004 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 .
346
15
6,489
@ Pure 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 .
133
15
6,490
@ Pure public static Point2d WSG84_L1 ( double lambda , double phi ) { final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi ( lambda , phi ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_1_N , LAMBERT_1_C , LAMBERT_1_XS , LAMBERT_1_YS ) ; }
This function convert WSG84 GPS coordinate to France Lambert I coordinate .
129
14
6,491
@ Pure public static Point2d WSG84_L2 ( double lambda , double phi ) { final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi ( lambda , phi ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_2_N , LAMBERT_2_C , LAMBERT_2_XS , LAMBERT_2_YS ) ; }
This function convert WSG84 GPS coordinate to France Lambert II coordinate .
129
14
6,492
@ Pure public static Point2d WSG84_L3 ( double lambda , double phi ) { final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi ( lambda , phi ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_3_N , LAMBERT_3_C , LAMBERT_3_XS , LAMBERT_3_YS ) ; }
This function convert WSG84 GPS coordinate to France Lambert III coordinate .
129
14
6,493
public static Point2d WSG84_L4 ( double lambda , double phi ) { final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi ( lambda , phi ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_4_N , LAMBERT_4_C , LAMBERT_4_XS , LAMBERT_4_YS ) ; }
This function convert WSG84 GPS coordinate to France Lambert IV coordinate .
127
14
6,494
@ Pure public static Point2d WSG84_L93 ( double lambda , double phi ) { final Point2d ntfLambdaPhi = WSG84_NTFLamdaPhi ( lambda , phi ) ; return NTFLambdaPhi_NTFLambert ( ntfLambdaPhi . getX ( ) , ntfLambdaPhi . getY ( ) , LAMBERT_93_N , LAMBERT_93_C , LAMBERT_93_XS , LAMBERT_93_YS ) ; }
This function convert WSG84 GPS coordinate to France Lambert 93 coordinate .
129
14
6,495
@ SuppressWarnings ( { "checkstyle:parametername" , "checkstyle:magicnumber" , "checkstyle:localfinalvariablename" , "checkstyle:localvariablename" } ) private static Point2d NTFLambdaPhi_NTFLambert ( double lambda , double phi , double n , double c , double Xs , double Ys ) { //--------------------------------------------------------- // 3) cartesian coordinate NTF (X_n,Y_n,Z_n) // -> geographical coordinate NTF (phi_n,lambda_n) // One formula is given by the IGN, and two constants about // the ellipsoide are from the NTF system specification of Clarke 1880. // Ref: // http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_80.pdf // http://support.esrifrance.fr/Documents/Generalites/Projections/Generalites/Generalites.htm#2 final double a_n = 6378249.2 ; final double b_n = 6356515.0 ; // then final double e2_n = ( a_n * a_n - b_n * b_n ) / ( a_n * a_n ) ; //--------------------------------------------------------- // 4) Geographical coordinate NTF (phi_n,lambda_n) // -> Extended Lambert II coordinate (X_l2e, Y_l2e) // Formula are given by the IGN from another specification // Ref: // http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_71.pdf final double e_n = Math . sqrt ( e2_n ) ; // Let the longitude in radians of Paris (2°20'14.025" E) from the Greenwich meridian final double lambda0 = 0.04079234433198 ; // Compute the isometric latitude final double L = Math . log ( Math . tan ( Math . PI / 4. + phi / 2. ) * Math . pow ( ( 1. - e_n * Math . sin ( phi ) ) / ( 1. + e_n * Math . sin ( phi ) ) , e_n / 2. ) ) ; // Then do the projection according to extended Lambert II final double X_l2e = Xs + c * Math . exp ( - n * L ) * Math . sin ( n * ( lambda - lambda0 ) ) ; final double Y_l2e = Ys - c * Math . exp ( - n * L ) * Math . cos ( n * ( lambda - lambda0 ) ) ; return new Point2d ( X_l2e , Y_l2e ) ; }
This function convert the geographical NTF Lambda - Phi coordinate to one of the France NTF standard coordinate .
603
22
6,496
@ Pure public ObjectProperty < WeakReference < Segment1D < ? , ? > > > segmentProperty ( ) { if ( this . segment == null ) { this . segment = new SimpleObjectProperty <> ( this , MathFXAttributeNames . SEGMENT ) ; } return this . segment ; }
Replies the segment property .
64
6
6,497
void set ( ObjectProperty < WeakReference < Segment1D < ? , ? > > > segment , DoubleProperty x , DoubleProperty y ) { this . segment = segment ; this . x = x ; this . y = y ; }
Change the x and y properties .
50
7
6,498
@ Pure public static boolean intersectsSegmentCapsule ( double sx1 , double sy1 , double sz1 , double sx2 , double sy2 , double sz2 , double mx1 , double my1 , double mz1 , double mx2 , double my2 , double mz2 , double radius ) { double d = distanceSquaredSegmentSegment ( sx1 , sy1 , sz1 , sx2 , sy2 , sz2 , mx1 , my1 , mz1 , mx2 , my2 , mz2 ) ; return d < ( radius * radius ) ; }
Tests if the capsule is intersecting a segment .
139
11
6,499
@ Pure public static boolean intersectsLineLine ( double x1 , double y1 , double z1 , double x2 , double y2 , double z2 , double x3 , double y3 , double z3 , double x4 , double y4 , double z4 ) { double s = computeLineLineIntersectionFactor ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 , x4 , y4 , z4 ) ; return ! Double . isNaN ( s ) ; }
Replies if two lines are intersecting .
118
9