idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
6,700
public static void setAccelerator ( final JMenuItem jmi , final int keyCode , final int modifiers ) { jmi . setAccelerator ( KeyStroke . getKeyStroke ( keyCode , modifiers ) ) ; }
Sets the accelerator for the given menuitem and the given key code and the given modifiers .
52
20
6,701
public static void setAccelerator ( final JMenuItem jmi , final String parsableKeystrokeString ) { jmi . setAccelerator ( KeyStroke . getKeyStroke ( parsableKeystrokeString ) ) ; }
Sets the accelerator for the given menuitem and the given parsable keystroke string .
52
19
6,702
@ Pure @ Inline ( value = "Base64Coder.decode(($1).toCharArray())" , imported = { Base64Coder . class } ) public static byte [ ] decode ( String string ) { return decode ( string . toCharArray ( ) ) ; }
Decodes a byte array from Base64 format .
61
10
6,703
public static void setPreferredClassLoader ( ClassLoader classLoader ) { if ( classLoader != dynamicLoader ) { dynamicLoader = classLoader ; final Thread [ ] threads = new Thread [ Thread . activeCount ( ) ] ; Thread . enumerate ( threads ) ; for ( final Thread t : threads ) { if ( t != null ) { t . setContextClassLoader ( classLoader ) ; } } } }
Set the preferred class loader .
86
6
6,704
public static void popPreferredClassLoader ( ) { final ClassLoader sysLoader = ClassLoaderFinder . class . getClassLoader ( ) ; if ( ( dynamicLoader == null ) || ( dynamicLoader == sysLoader ) ) { dynamicLoader = null ; final Thread [ ] threads = new Thread [ Thread . activeCount ( ) ] ; Thread . enumerate ( threads ) ; for ( final Thread t : threads ) { if ( t != null ) { t . setContextClassLoader ( sysLoader ) ; } } return ; } final ClassLoader parent = dynamicLoader . getParent ( ) ; dynamicLoader = ( parent == sysLoader ) ? null : parent ; final Thread [ ] threads = new Thread [ Thread . activeCount ( ) ] ; Thread . enumerate ( threads ) ; for ( final Thread t : threads ) { if ( t != null ) { t . setContextClassLoader ( parent ) ; } } }
Pop the preferred class loader .
191
6
6,705
public static boolean isMinValue ( Progression model ) { if ( model != null ) { return model . getValue ( ) <= model . getMinimum ( ) ; } return true ; }
Replies if the given progression indicators has its value equal to its min value .
39
16
6,706
protected void defineSmallRectangles ( ZoomableGraphicsContext gc , T element ) { final double ptsSize = element . getPointSize ( ) / 2. ; final Rectangle2afp < ? , ? , ? , ? , ? , ? > visibleArea = gc . getVisibleArea ( ) ; for ( final Point2d point : element . points ( ) ) { if ( visibleArea . contains ( point ) ) { final double x = point . getX ( ) - ptsSize ; final double y = point . getY ( ) - ptsSize ; final double mx = point . getX ( ) + ptsSize ; final double my = point . getY ( ) + ptsSize ; gc . moveTo ( x , y ) ; gc . lineTo ( mx , y ) ; gc . lineTo ( mx , my ) ; gc . lineTo ( x , my ) ; gc . closePath ( ) ; } } }
Define a path that corresponds to the small rectangles around the points .
206
15
6,707
public static Point1dfx convert ( Tuple1dfx < ? > tuple ) { if ( tuple instanceof Point1dfx ) { return ( Point1dfx ) tuple ; } return new Point1dfx ( tuple . getSegment ( ) , tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Point1dfx .
66
12
6,708
public OffsetRange < CharOffset > offsets ( ) { final CharOffset start = tokens . get ( 0 ) . offsets ( ) . startInclusive ( ) ; final CharOffset end = tokens . reverse ( ) . get ( 0 ) . offsets ( ) . endInclusive ( ) ; return OffsetRange . charOffsetRange ( start . asInt ( ) , end . asInt ( ) ) ; }
Span from the start of the first token to the end of the last .
85
16
6,709
@ Override public HashMap readFile ( String arg0 ) { HashMap brMap ; try { brMap = getBufferReader ( arg0 ) ; } catch ( FileNotFoundException fe ) { LOG . warn ( "File not found under following path : [" + arg0 + "]!" ) ; return new HashMap ( ) ; } catch ( IOException e ) { LOG . error ( Functions . getStackTrace ( e ) ) ; return new HashMap ( ) ; } return read ( brMap ) ; }
All DSSAT Data input method used for single file or zip package
110
14
6,710
public HashMap readFile ( List < File > files ) { HashMap brMap ; try { brMap = getBufferReader ( files ) ; } catch ( IOException e ) { LOG . error ( Functions . getStackTrace ( e ) ) ; return new HashMap ( ) ; } return read ( brMap ) ; }
All DSSAT Data input method used for uncompressed multiple files
69
13
6,711
public HashMap readFileFromCRAFT ( String arg0 ) { HashMap brMap ; try { File dir = new File ( arg0 ) ; // Data frin CRAFT with DSSAT format if ( dir . isDirectory ( ) ) { List < File > files = new ArrayList ( ) ; for ( File f : dir . listFiles ( ) ) { String name = f . getName ( ) . toUpperCase ( ) ; // XFile folder if ( name . equals ( "FILEX" ) ) { for ( File exp : f . listFiles ( ) ) { if ( exp . isFile ( ) ) { String expName = exp . getName ( ) . toUpperCase ( ) ; if ( expName . matches ( ".+\\.\\w{2}X" ) ) { files . add ( exp ) ; } } } } // Weather folder else if ( name . equals ( "WEATHER" ) ) { for ( File wth : f . listFiles ( ) ) { if ( wth . isFile ( ) ) { String wthName = wth . getName ( ) . toUpperCase ( ) ; if ( wthName . endsWith ( ".WTH" ) ) { files . add ( wth ) ; } } } } // Soil file else if ( f . isFile ( ) && name . endsWith ( ".SOL" ) ) { files . add ( f ) ; } } brMap = getBufferReader ( files ) ; } else { LOG . error ( "You need to provide the CRAFT working folder used for generating DSSAT files." ) ; return new HashMap ( ) ; } } catch ( IOException e ) { LOG . error ( Functions . getStackTrace ( e ) ) ; return new HashMap ( ) ; } return read ( brMap ) ; }
All DSSAT Data input method specially used for DSSAT files generated by CRAFT
393
18
6,712
private int ensureBuffer ( int offset , int length ) throws IOException { final int lastPos = offset + length - 1 ; final int desiredSize = ( ( lastPos / BUFFER_SIZE ) + 1 ) * BUFFER_SIZE ; final int currentSize = this . buffer . length ; if ( desiredSize > currentSize ) { final byte [ ] readBuffer = new byte [ desiredSize - currentSize ] ; final int count = this . in . read ( readBuffer ) ; if ( count > 0 ) { final byte [ ] newBuffer = new byte [ currentSize + count ] ; System . arraycopy ( this . buffer , 0 , newBuffer , 0 , currentSize ) ; System . arraycopy ( readBuffer , 0 , newBuffer , currentSize , count ) ; this . buffer = newBuffer ; } return ( lastPos < this . buffer . length ) ? length : length - ( lastPos - this . buffer . length + 1 ) ; } return length ; }
Replies the count of characters available for reading .
205
10
6,713
public byte [ ] read ( int offset , int length ) throws IOException { if ( ensureBuffer ( offset , length ) >= length ) { final byte [ ] array = new byte [ length ] ; System . arraycopy ( this . buffer , offset , array , 0 , length ) ; this . pos = offset + length ; return array ; } throw new EOFException ( ) ; }
Replies the bytes at the specified offset .
80
9
6,714
public byte read ( int offset ) throws IOException { if ( ensureBuffer ( offset , 1 ) > 0 ) { this . pos = offset + 1 ; return this . buffer [ offset ] ; } throw new EOFException ( ) ; }
Replies a byte at the specified offset .
50
9
6,715
public String getString ( final String param ) { checkNotNull ( param ) ; checkArgument ( ! param . isEmpty ( ) ) ; final String ret = params . get ( param ) ; observeWithListeners ( param ) ; if ( ret != null ) { return ret ; } else { throw new MissingRequiredParameter ( fullString ( param ) ) ; } }
Gets the value for a parameter as a raw string .
77
12
6,716
public < T > T getMapped ( final String param , final Map < String , T > possibleValues ) { checkNotNull ( possibleValues ) ; checkArgument ( ! possibleValues . isEmpty ( ) ) ; final String value = getString ( param ) ; final T ret = possibleValues . get ( value ) ; if ( ret == null ) { throw new InvalidEnumeratedPropertyException ( fullString ( param ) , value , possibleValues . keySet ( ) ) ; } return ret ; }
Looks up a parameter then uses the value as a key in a map lookup . If the value is not a key in the map throws an exception .
106
30
6,717
public File getExistingFile ( final String param ) { return get ( param , getFileConverter ( ) , new And <> ( new FileExists ( ) , new IsFile ( ) ) , "existing file" ) ; }
Gets a file which is required to exist .
51
10
6,718
public File getAndMakeDirectory ( final String param ) { final File f = get ( param , new StringToFile ( ) , new AlwaysValid < File > ( ) , "existing or creatable directory" ) ; if ( f . exists ( ) ) { if ( f . isDirectory ( ) ) { return f . getAbsoluteFile ( ) ; } else { throw new ParameterValidationException ( fullString ( param ) , f . getAbsolutePath ( ) . toString ( ) , new ValidationException ( "Not an existing or creatable directory" ) ) ; } } else { f . getAbsoluteFile ( ) . mkdirs ( ) ; return f . getAbsoluteFile ( ) ; } }
Gets a directory which is guaranteed to exist after the execution of this method . If the directory does not already exist it and its parents are created . If this is not possible an exception is throws .
153
40
6,719
public File getExistingDirectory ( final String param ) { return get ( param , new StringToFile ( ) , new And <> ( new FileExists ( ) , new IsDirectory ( ) ) , "existing directory" ) ; }
Gets a directory which already exists .
50
8
6,720
public Set < String > getStringSet ( final String param ) { return get ( param , new StringToStringSet ( "," ) , new AlwaysValid < Set < String > > ( ) , "comma-separated list of strings" ) ; }
Gets a - separated set of Strings .
54
10
6,721
public Set < Symbol > getSymbolSet ( final String param ) { return get ( param , new StringToSymbolSet ( "," ) , new AlwaysValid < Set < Symbol > > ( ) , "comma-separated list of strings" ) ; }
Gets a - separated set of Symbols
56
9
6,722
public void assertAtLeastOneDefined ( final String param1 , final String param2 ) { if ( ! isPresent ( param1 ) && ! isPresent ( param2 ) ) { throw new ParameterException ( String . format ( "At least one of %s and %s must be defined." , param1 , param2 ) ) ; } }
Throws a ParameterException if neither parameter is defined .
75
12
6,723
public void assertAtLeastOneDefined ( final String param1 , final String ... moreParams ) { if ( ! isPresent ( param1 ) ) { for ( final String moreParam : moreParams ) { if ( isPresent ( moreParam ) ) { return ; } } final List < String > paramsForError = Lists . newArrayList ( ) ; paramsForError . add ( param1 ) ; paramsForError . addAll ( Arrays . asList ( moreParams ) ) ; throw new ParameterException ( String . format ( "At least one of %s must be defined." , StringUtils . CommaSpaceJoiner . join ( paramsForError ) ) ) ; } }
Throws a ParameterException if none of the supplied parameters are defined .
149
15
6,724
@ Override public Iterator < T > iterator ( ) { final List < T > shuffledList = Lists . newArrayList ( data ) ; Collections . shuffle ( shuffledList , rng ) ; return Collections . unmodifiableList ( shuffledList ) . iterator ( ) ; }
Returns a new iterator that iterates over a new random ordering of the data .
61
16
6,725
private String getCropName ( Map result ) { String ret ; String crid ; // Get crop id crid = getCrid ( result ) ; // Get crop name string ret = LookupCodes . lookupCode ( "CRID" , crid , "common" , "DSSAT" ) ; if ( ret . equals ( crid ) ) { ret = "Unkown" ; sbError . append ( "! Warning: Undefined crop id: [" ) . append ( crid ) . append ( "]\r\n" ) ; } // // Get crop name string // if ("BH".equals(crid)) { // ret = "Bahia"; // } else if ("BA".equals(crid)) { // ret = "Barley"; // } else if ("BR".equals(crid)) { // ret = "Brachiaria"; // } else if ("CB".equals(crid)) { // ret = "Cabbage"; // } else if ("CS".equals(crid)) { // ret = "Cassava"; // } else if ("CH".equals(crid)) { // ret = "Chickpea"; // } else if ("CO".equals(crid)) { // ret = "Cotton"; // } else if ("CP".equals(crid)) { // ret = "Cowpea"; // } else if ("BN".equals(crid)) { // ret = "Drybean"; // } else if ("FB".equals(crid)) { // ret = "FabaBean"; // } else if ("FA".equals(crid)) { // ret = "Fallow"; // } else if ("GB".equals(crid)) { // ret = "GreenBean"; // } else if ("MZ".equals(crid)) { // ret = "Maize"; // } else if ("ML".equals(crid)) { // ret = "Millet"; // } else if ("PN".equals(crid)) { // ret = "Peanut"; // } else if ("PR".equals(crid)) { // ret = "Pepper"; // } else if ("PI".equals(crid)) { // ret = "PineApple"; // } else if ("PT".equals(crid)) { // ret = "Potato"; // } else if ("RI".equals(crid)) { // ret = "Rice"; // } else if ("SG".equals(crid)) { // ret = "Sorghum"; // } else if ("SB".equals(crid)) { // ret = "Soybean"; // } else if ("SC".equals(crid)) { // ret = "Sugarcane"; // } else if ("SU".equals(crid)) { // ret = "Sunflower"; // } else if ("SW".equals(crid)) { // ret = "SweetCorn"; // } else if ("TN".equals(crid)) { // ret = "Tanier"; // } else if ("TR".equals(crid)) { // ret = "Taro"; // } else if ("TM".equals(crid)) { // ret = "Tomato"; // } else if ("VB".equals(crid)) { // ret = "Velvetbean"; // } else if ("WH".equals(crid)) { // ret = "Wheat"; // } else if ("SQ".equals(crid)) { // ret = "Sequence"; // } else { // ret = "Unkown"; // sbError.append("! Warning: Undefined crop id: [").append(crid).append("]\r\n"); // } return ret ; }
Get crop name string
821
4
6,726
private static < T extends Comparable < T > > Optional < Range < T > > smallestContainerForRange ( Collection < Range < T > > ranges , Range < T > target ) { Range < T > best = Range . all ( ) ; for ( final Range < T > r : ranges ) { if ( r . equals ( target ) ) { continue ; } // prefer a smaller range, always; if ( r . encloses ( target ) && best . encloses ( r ) ) { best = r ; } } if ( best . equals ( Range . < T > all ( ) ) ) { return Optional . absent ( ) ; } return Optional . of ( best ) ; }
Assuming our ranges look tree - structured finds the smallest range for the particular target one .
143
17
6,727
@ Override public void validate ( T arg ) throws ValidationException { for ( final Validator < T > validator : validators ) { validator . validate ( arg ) ; } }
Calls each of its child validators on the input short - circuiting and propagating if one throws an exception .
40
25
6,728
public < T > void setSocketOption ( SocketOption < T > socketOption , T value ) { this . socketOptions . put ( socketOption , value ) ; }
Set tcp socket option
35
4
6,729
public void setCenterProperties ( Point3d center1 ) { this . center . setProperties ( center1 . xProperty , center1 . yProperty , center1 . zProperty ) ; }
Set the center property .
42
5
6,730
protected void onChange ( ) { enabled = false ; if ( getDocument ( ) . getLength ( ) > 0 ) { enabled = true ; } buttonModel . setEnabled ( enabled ) ; }
Callback method that can be overwritten to provide specific action on change of document .
41
16
6,731
@ Override public Context addWebapp ( Host host , String contextPath , String docBase ) { final ContextConfig contextConfig = createContextConfig ( ) ; // *extension point return addWebapp ( host , contextPath , docBase , contextConfig ) ; }
copied from super Tomcat because of private methods
56
10
6,732
protected void fireAttributeChange ( AttributeChangeEvent event ) { if ( this . listeners != null && isEventFirable ( ) ) { final AttributeChangeListener [ ] list = new AttributeChangeListener [ this . listeners . size ( ) ] ; this . listeners . toArray ( list ) ; for ( final AttributeChangeListener listener : list ) { listener . onAttributeChangeEvent ( event ) ; } } }
Notifies the listeners about the change of an attribute .
88
11
6,733
@ SuppressWarnings ( "unchecked" ) private static < T > T maskNull ( T value ) { return ( value == null ) ? ( T ) NULL_VALUE : value ; }
Replies the null value given by the user by the corresponding null object .
42
15
6,734
protected void assertRange ( int index , boolean allowLast ) { final int csize = expurge ( ) ; if ( index < 0 ) { throw new IndexOutOfBoundsException ( Locale . getString ( "E1" , index ) ) ; //$NON-NLS-1$ } if ( allowLast && ( index > csize ) ) { throw new IndexOutOfBoundsException ( Locale . getString ( "E2" , csize , index ) ) ; //$NON-NLS-1$ } if ( ! allowLast && ( index >= csize ) ) { throw new IndexOutOfBoundsException ( Locale . getString ( "E3" , csize , index ) ) ; //$NON-NLS-1$ } }
Verify if the specified index is inside the array .
170
11
6,735
public void addReferenceListener ( ReferenceListener listener ) { if ( this . listeners == null ) { this . listeners = new LinkedList <> ( ) ; } final List < ReferenceListener > list = this . listeners ; synchronized ( list ) { list . add ( listener ) ; } }
Add listener on reference s release .
60
7
6,736
public void removeReferenceListener ( ReferenceListener listener ) { final List < ReferenceListener > list = this . listeners ; if ( list != null ) { synchronized ( list ) { list . remove ( listener ) ; if ( list . isEmpty ( ) ) { this . listeners = null ; } } } }
Remove listener on reference s release .
62
7
6,737
protected void fireReferenceRelease ( int released ) { final List < ReferenceListener > list = this . listeners ; if ( list != null && ! list . isEmpty ( ) ) { for ( final ReferenceListener listener : list ) { listener . referenceReleased ( released ) ; } } }
Fire the reference release event .
58
6
6,738
@ Pure @ SuppressWarnings ( "checkstyle:cyclomaticcomplexity" ) public PT getStartingPointFor ( int index ) { if ( ( index < 1 ) || ( this . segmentList . size ( ) <= 1 ) ) { if ( this . startingPoint != null ) { return this . startingPoint ; } } else { int idx = index ; ST currentSegment = this . segmentList . get ( idx ) ; ST previousSegment = this . segmentList . get ( -- idx ) ; // Because the two segments are the same // we must go deeper in the path elements // to detect the right segment int count = 0 ; while ( ( previousSegment != null ) && ( previousSegment . equals ( currentSegment ) ) ) { currentSegment = previousSegment ; idx -- ; previousSegment = ( idx >= 0 ) ? this . segmentList . get ( idx ) : null ; count ++ ; } if ( count > 0 ) { PT sp = null ; if ( previousSegment != null ) { final PT p1 = currentSegment . getBeginPoint ( ) ; final PT p2 = currentSegment . getEndPoint ( ) ; final PT p3 = previousSegment . getBeginPoint ( ) ; final PT p4 = previousSegment . getEndPoint ( ) ; assert p1 != null && p2 != null && p3 != null && p4 != null ; if ( p1 . equals ( p3 ) || p1 . equals ( p4 ) ) { sp = p1 ; } else if ( p2 . equals ( p3 ) || p2 . equals ( p4 ) ) { sp = p2 ; } } else { sp = this . startingPoint ; } if ( sp != null ) { return ( ( count % 2 ) == 0 ) ? sp : currentSegment . getOtherSidePoint ( sp ) ; } } else if ( ( currentSegment != null ) && ( previousSegment != null ) ) { // if the two segments are different // it is simple to detect the // common point final PT p1 = currentSegment . getBeginPoint ( ) ; final PT p2 = currentSegment . getEndPoint ( ) ; final PT p3 = previousSegment . getBeginPoint ( ) ; final PT p4 = previousSegment . getEndPoint ( ) ; assert p1 != null && p2 != null && p3 != null && p4 != null ; if ( p1 . equals ( p3 ) || p1 . equals ( p4 ) ) { return p1 ; } if ( p2 . equals ( p3 ) || p2 . equals ( p4 ) ) { return p2 ; } } } return null ; }
Replies the starting point for the segment at the given index .
581
13
6,739
boolean removeUntil ( int index , boolean inclusive ) { if ( index >= 0 ) { boolean changed = false ; PT startPoint = this . startingPoint ; ST segment ; int limit = index ; if ( inclusive ) { ++ limit ; } for ( int i = 0 ; i < limit ; ++ i ) { segment = this . segmentList . remove ( 0 ) ; this . length -= segment . getLength ( ) ; if ( this . length < 0 ) { this . length = 0 ; } startPoint = segment . getOtherSidePoint ( startPoint ) ; changed = true ; } if ( changed ) { if ( this . segmentList . isEmpty ( ) ) { this . startingPoint = null ; this . endingPoint = null ; this . isReversable = true ; } else { this . startingPoint = startPoint ; } return true ; } } return false ; }
Package access to avoid compilation error . You must not call this function directly .
185
15
6,740
public void invert ( ) { final PT p = this . startingPoint ; this . startingPoint = this . endingPoint ; this . endingPoint = p ; final int middle = this . segmentList . size ( ) / 2 ; ST segment ; for ( int i = 0 , j = this . segmentList . size ( ) - 1 ; i < middle ; ++ i , -- j ) { segment = this . segmentList . get ( i ) ; this . segmentList . set ( i , this . segmentList . get ( j ) ) ; this . segmentList . set ( j , segment ) ; } }
Revert the order of the graph segment in this path .
128
13
6,741
public GP splitAt ( ST obj , PT startPoint ) { return splitAt ( indexOf ( obj , startPoint ) , true ) ; }
Split this path and retains the first part of the part in this object and reply the second part . The first occurrence of this specified element will be in the second part .
30
34
6,742
public GP splitAfterLast ( ST obj , PT startPoint ) { return splitAt ( lastIndexOf ( obj , startPoint ) , false ) ; }
Split this path and retains the first part of the part in this object and reply the second part . The last occurence of the specified element will be in the first part .
32
36
6,743
public GP splitAtLast ( ST obj , PT startPoint ) { return splitAt ( lastIndexOf ( obj , startPoint ) , true ) ; }
Split this path and retains the first part of the part in this object and reply the second part . The last occurence of the specified element will be in the second part .
32
36
6,744
public GP splitAfter ( ST obj , PT startPoint ) { return splitAt ( indexOf ( obj , startPoint ) , false ) ; }
Split this path and retains the first part of the part in this object and reply the second part . The first occurrence of specified element will be in the first part .
30
33
6,745
public void transform ( Transform3D transform , Point3D pivot ) { Point3D refPoint = ( pivot == null ) ? getPivot ( ) : pivot ; Vector3f v = new Vector3f ( this . getEquationComponentA ( ) , this . getEquationComponentB ( ) , this . getEquationComponentC ( ) ) ; transform . transform ( v ) ; // Update the plane equation according // to the desired normal (computed from // the identity vector and the rotations). // a.x + b.y + c.z + d = 0 // where (x,y,z) is the translation point this . set ( v . getX ( ) , v . getY ( ) , v . getZ ( ) , - ( this . getEquationComponentA ( ) * ( refPoint . getX ( ) + transform . m03 ) + this . getEquationComponentB ( ) * ( refPoint . getY ( ) + transform . m13 ) + this . getEquationComponentC ( ) * ( refPoint . getZ ( ) + transform . m23 ) ) ) ; clearBufferedValues ( ) ; }
Apply the given transformation matrix on the plane .
248
9
6,746
public void translate ( double dx , double dy , double dz ) { // Compute the reference point for the plane // (usefull for translation) Point3f refPoint = ( Point3f ) getPivot ( ) ; // a.x + b.y + c.z + d = 0 // where (x,y,z) is the translation point setPivot ( refPoint . getX ( ) + dx , refPoint . getY ( ) + dy , refPoint . getZ ( ) + dz ) ; }
Translate the pivot point of the plane .
114
9
6,747
public void rotate ( Quaternion rotation , Point3D pivot ) { Point3D currentPivot = getPivot ( ) ; // Update the plane equation according // to the desired normal (computed from // the identity vector and the rotations). Transform3D m = new Transform3D ( ) ; m . setRotation ( rotation ) ; Vector3f v = new Vector3f ( this . getEquationComponentA ( ) , this . getEquationComponentB ( ) , this . getEquationComponentC ( ) ) ; m . transform ( v ) ; this . setEquationComponentA ( v . getX ( ) ) ; this . setEquationComponentB ( v . getY ( ) ) ; this . setEquationComponentC ( v . getZ ( ) ) ; if ( pivot == null ) { // a.x + b.y + c.z + d = 0 // where (x,y,z) is the translation point this . setEquationComponentD ( - ( this . getEquationComponentA ( ) * currentPivot . getX ( ) + this . getEquationComponentB ( ) * currentPivot . getY ( ) + this . getEquationComponentC ( ) * currentPivot . getZ ( ) ) ) ; } else { // Compute the new point Point3f nP = new Point3f ( currentPivot . getX ( ) - pivot . getX ( ) , currentPivot . getY ( ) - pivot . getY ( ) , currentPivot . getZ ( ) - pivot . getZ ( ) ) ; m . transform ( nP ) ; nP . setX ( nP . getX ( ) + pivot . getX ( ) ) ; nP . setY ( nP . getY ( ) + pivot . getY ( ) ) ; nP . setZ ( nP . getZ ( ) + pivot . getZ ( ) ) ; // a.x + b.y + c.z + d = 0 // where (x,y,z) is the translation point this . setEquationComponentD ( - ( this . getEquationComponentA ( ) * nP . getX ( ) + this . getEquationComponentB ( ) * nP . getY ( ) + this . getEquationComponentC ( ) * nP . getZ ( ) ) ) ; } clearBufferedValues ( ) ; }
Rotate the plane around the given pivot point .
521
10
6,748
public static double cleanProbability ( double prob , double epsilon , boolean allowOne ) { if ( prob < - epsilon || prob > ( 1.0 + epsilon ) ) { throw new InvalidProbabilityException ( prob ) ; } if ( prob < epsilon ) { prob = epsilon ; } else { final double limit = allowOne ? 1.0 : ( 1.0 - epsilon ) ; if ( prob > limit ) { prob = limit ; } } return prob ; }
Cleans up input which should be probabilities . Occasionally due to numerical stability issues you get input which should be a probability but could actually be very slightly less than 0 or more than 1 . 0 . This function will take values within epsilon of being good probabilities and fix them . If the prob is within epsilon of zero it is changed to + epsilon . One the upper end if allowOne is true anything between 1 . 0 and 1 . 0 + epsilon is mapped to 1 . 0 . If allowOne is false anything between 1 . 0 - epsilon and 1 . 0 + epsilon is mapped to 1 . 0 - epsilon . All other probability values throw an unchecked InvalidProbabilityException .
111
150
6,749
@ Pure public static boolean propertyArraysEquals ( Property < ? > [ ] array , Property < ? > [ ] array2 ) { if ( array . length == array2 . length ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == null ) { if ( array2 [ i ] != null ) return false ; } else if ( array2 [ i ] == null ) { return false ; } else if ( ! array [ i ] . getValue ( ) . equals ( array2 [ i ] . getValue ( ) ) ) { return false ; } } return true ; } return false ; }
Indicates if the two property arrays are strictly equals
140
10
6,750
public void moveTo ( Point3d point ) { if ( this . numTypesProperty . get ( ) > 0 && this . types [ this . numTypesProperty . get ( ) - 1 ] == PathElementType . MOVE_TO ) { this . coordsProperty [ this . numCoordsProperty . get ( ) - 3 ] = point . xProperty ; this . coordsProperty [ this . numCoordsProperty . get ( ) - 2 ] = point . yProperty ; this . coordsProperty [ this . numCoordsProperty . get ( ) - 1 ] = point . zProperty ; } else { ensureSlots ( false , 3 ) ; this . types [ this . numTypesProperty . get ( ) ] = PathElementType . MOVE_TO ; this . numTypesProperty . set ( this . numTypesProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = point . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = point . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = point . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; } this . graphicalBounds = null ; this . logicalBounds = null ; }
Adds a point to the path by moving to the specified coordinates specified in point in paramater .
340
19
6,751
public void lineTo ( Point3d point ) { ensureSlots ( true , 3 ) ; this . types [ this . numTypesProperty . get ( ) ] = PathElementType . LINE_TO ; this . numTypesProperty . set ( this . numTypesProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = point . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = point . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = point . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . isEmptyProperty = null ; this . graphicalBounds = null ; this . logicalBounds = null ; }
Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in the point in paramater .
227
28
6,752
public void quadTo ( Point3d controlPoint , Point3d endPoint ) { ensureSlots ( true , 6 ) ; this . types [ this . numTypesProperty . get ( ) ] = PathElementType . QUAD_TO ; this . numTypesProperty . set ( this . numTypesProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = endPoint . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = endPoint . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = endPoint . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . isEmptyProperty = null ; this . isPolylineProperty . set ( false ) ; this . graphicalBounds = null ; this . logicalBounds = null ; }
Adds a curved segment defined by two new points to the path by drawing a Quadratic curve that intersects both the current coordinates and the specified endPoint using the specified controlPoint as a quadratic parametric control point . All coordinates are specified in Point3d .
391
55
6,753
public void curveTo ( Point3d controlPoint1 , Point3d controlPoint2 , Point3d endPoint ) { ensureSlots ( true , 9 ) ; this . types [ this . numTypesProperty . get ( ) ] = PathElementType . CURVE_TO ; this . numTypesProperty . set ( this . numTypesProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint1 . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint1 . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint1 . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint2 . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint2 . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = controlPoint2 . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = endPoint . xProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = endPoint . yProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . coordsProperty [ this . numCoordsProperty . get ( ) ] = endPoint . zProperty ; this . numCoordsProperty . set ( this . numCoordsProperty . get ( ) + 1 ) ; this . isEmptyProperty = null ; this . isPolylineProperty . set ( false ) ; this . graphicalBounds = null ; this . logicalBounds = null ; }
Adds a curved segment defined by three new points to the path by drawing a B&eacute ; zier curve that intersects both the current coordinates and the specified endPoint using the specified points controlPoint1 and controlPoint2 as B&eacute ; zier control points . All coordinates are specified in Point3d .
547
68
6,754
protected void flush ( ) throws IOException { if ( this . tempStream != null && this . buffer . position ( ) > 0 ) { final int pos = this . buffer . position ( ) ; this . buffer . rewind ( ) ; this . buffer . limit ( pos ) ; this . tempStream . write ( this . buffer ) ; this . buffer . rewind ( ) ; this . buffer . limit ( this . buffer . capacity ( ) ) ; this . bufferPosition += pos ; } }
Force this writer to write the memory buffer inside the temporary file .
104
13
6,755
protected final void writeBEInt ( int v ) throws IOException { ensureAvailableBytes ( 4 ) ; this . buffer . order ( ByteOrder . BIG_ENDIAN ) ; this . buffer . putInt ( v ) ; }
Write a big endian 4 - byte integer .
47
10
6,756
protected final void writeBEDouble ( double v ) throws IOException { ensureAvailableBytes ( 8 ) ; this . buffer . order ( ByteOrder . BIG_ENDIAN ) ; this . buffer . putDouble ( v ) ; }
Write a big endian 8 - byte floating point number .
48
12
6,757
protected final void writeLEInt ( int v ) throws IOException { ensureAvailableBytes ( 4 ) ; this . buffer . order ( ByteOrder . LITTLE_ENDIAN ) ; this . buffer . putInt ( v ) ; }
Write a little endian 4 - byte integer .
49
10
6,758
protected final void writeLEDouble ( double v ) throws IOException { ensureAvailableBytes ( 8 ) ; this . buffer . order ( ByteOrder . LITTLE_ENDIAN ) ; this . buffer . putDouble ( v ) ; }
Write a little endian 8 - byte floating point number .
49
12
6,759
private void writeHeader ( ESRIBounds box , ShapeElementType type , Collection < ? extends E > elements ) throws IOException { if ( ! this . headerWasWritten ) { initializeContentBuffer ( ) ; box . ensureMinMax ( ) ; //Byte 0 : File Code (9994) writeBEInt ( SHAPE_FILE_CODE ) ; //Byte 4 : Unused (0) writeBEInt ( 0 ) ; //Byte 8 : Unused (0) writeBEInt ( 0 ) ; //Byte 12 : Unused (0) writeBEInt ( 0 ) ; //Byte 16 : Unused (0) writeBEInt ( 0 ) ; //Byte 20 : Unused (0) writeBEInt ( 0 ) ; //Byte 24 : File Length, fill later writeBEInt ( 0 ) ; //Byte 28 : Version(1000) writeLEInt ( SHAPE_FILE_VERSION ) ; //Byte 32 : ShapeType writeLEInt ( type . shapeType ) ; //Byte 36 : Xmin writeLEDouble ( toESRI_x ( box . getMinX ( ) ) ) ; //Byte 44 : Ymin writeLEDouble ( toESRI_y ( box . getMinY ( ) ) ) ; //Byte 52 : Xmax writeLEDouble ( toESRI_x ( box . getMaxX ( ) ) ) ; //Byte 60 : Ymax writeLEDouble ( toESRI_y ( box . getMaxY ( ) ) ) ; //Byte 68 : Zmin writeLEDouble ( toESRI_z ( box . getMinZ ( ) ) ) ; //Byte 76 : Zmax writeLEDouble ( toESRI_z ( box . getMaxZ ( ) ) ) ; //Byte 84 : Mmin writeLEDouble ( toESRI_m ( box . getMinM ( ) ) ) ; //Byte 92 : Mmax writeLEDouble ( toESRI_m ( box . getMaxM ( ) ) ) ; this . headerWasWritten = true ; this . recordIndex = 0 ; onHeaderWritten ( box , type , elements ) ; } }
Write the header of a Shape file .
443
8
6,760
public void write ( Collection < ? extends E > elements ) throws IOException { final Progression progressBar = getTaskProgression ( ) ; Progression subTask = null ; if ( progressBar != null ) { progressBar . setProperties ( 0 , 0 , ( elements . size ( ) + 1 ) * 100 , false ) ; } if ( this . fileBounds == null ) { this . fileBounds = getFileBounds ( ) ; } if ( this . fileBounds != null ) { writeHeader ( this . fileBounds , this . elementType , elements ) ; if ( progressBar != null ) { progressBar . setValue ( 100 ) ; subTask = progressBar . subTask ( elements . size ( ) * 100 ) ; subTask . setProperties ( 0 , 0 , elements . size ( ) , false ) ; } for ( final E element : elements ) { writeElement ( this . recordIndex , element , this . elementType ) ; if ( subTask != null ) { subTask . setValue ( this . recordIndex + 1 ) ; } ++ this . recordIndex ; } } else { throw new BoundsNotFoundException ( ) ; } if ( progressBar != null ) { progressBar . end ( ) ; } }
Write the Shape file and its associated files .
266
9
6,761
@ Pure public static double toSeconds ( double value , TimeUnit inputUnit ) { switch ( inputUnit ) { case DAYS : return value * 86400. ; case HOURS : return value * 3600. ; case MINUTES : return value * 60. ; case SECONDS : break ; case MILLISECONDS : return milli2unit ( value ) ; case MICROSECONDS : return micro2unit ( value ) ; case NANOSECONDS : return nano2unit ( value ) ; default : throw new IllegalArgumentException ( ) ; } return value ; }
Convert the given value expressed in the given unit to seconds .
129
13
6,762
@ Pure @ SuppressWarnings ( "checkstyle:returncount" ) public static double toMeters ( double value , SpaceUnit inputUnit ) { switch ( inputUnit ) { case TERAMETER : return value * 1e12 ; case GIGAMETER : return value * 1e9 ; case MEGAMETER : return value * 1e6 ; case KILOMETER : return value * 1e3 ; case HECTOMETER : return value * 1e2 ; case DECAMETER : return value * 1e1 ; case METER : break ; case DECIMETER : return value * 1e-1 ; case CENTIMETER : return value * 1e-2 ; case MILLIMETER : return value * 1e-3 ; case MICROMETER : return value * 1e-6 ; case NANOMETER : return value * 1e-9 ; case PICOMETER : return value * 1e-12 ; case FEMTOMETER : return value * 1e-15 ; default : throw new IllegalArgumentException ( ) ; } return value ; }
Convert the given value expressed in the given unit to meters .
245
13
6,763
@ Pure public static double fromSeconds ( double value , TimeUnit outputUnit ) { switch ( outputUnit ) { case DAYS : return value / 86400. ; case HOURS : return value / 3600. ; case MINUTES : return value / 60. ; case SECONDS : break ; case MILLISECONDS : return unit2milli ( value ) ; case MICROSECONDS : return unit2micro ( value ) ; case NANOSECONDS : return unit2nano ( value ) ; default : throw new IllegalArgumentException ( ) ; } return value ; }
Convert the given value expressed in seconds to the given unit .
130
13
6,764
@ Pure public static double toMetersPerSecond ( double value , SpeedUnit inputUnit ) { switch ( inputUnit ) { case KILOMETERS_PER_HOUR : return 3.6 * value ; case MILLIMETERS_PER_SECOND : return value / 1000. ; case METERS_PER_SECOND : default : } return value ; }
Convert the given value expressed in the given unit to meters per second .
78
15
6,765
@ Pure public static double toRadiansPerSecond ( double value , AngularUnit inputUnit ) { switch ( inputUnit ) { case TURNS_PER_SECOND : return value * ( 2. * MathConstants . PI ) ; case DEGREES_PER_SECOND : return Math . toRadians ( value ) ; case RADIANS_PER_SECOND : default : } return value ; }
Convert the given value expressed in the given unit to radians per second .
87
16
6,766
@ Pure public static double fromMetersPerSecond ( double value , SpeedUnit outputUnit ) { switch ( outputUnit ) { case KILOMETERS_PER_HOUR : return value / 3.6 ; case MILLIMETERS_PER_SECOND : return value * 1000. ; case METERS_PER_SECOND : default : } return value ; }
Convert the given value expressed in meters per second to the given unit .
78
15
6,767
@ Pure public static double fromRadiansPerSecond ( double value , AngularUnit outputUnit ) { switch ( outputUnit ) { case TURNS_PER_SECOND : return value / ( 2. * MathConstants . PI ) ; case DEGREES_PER_SECOND : return Math . toDegrees ( value ) ; case RADIANS_PER_SECOND : default : } return value ; }
Convert the given value expressed in radians per second to the given unit .
88
16
6,768
@ Pure public static SpaceUnit getSmallestUnit ( double amount , SpaceUnit unit ) { final double meters = toMeters ( amount , unit ) ; double v ; final SpaceUnit [ ] units = SpaceUnit . values ( ) ; SpaceUnit u ; for ( int i = units . length - 1 ; i >= 0 ; -- i ) { u = units [ i ] ; v = Math . floor ( fromMeters ( meters , u ) ) ; if ( v > 0. ) { return u ; } } return unit ; }
Compute the smallest unit that permits to have a metric value with its integer part positive .
112
18
6,769
public static Vector3d convert ( Tuple3D < ? > tuple ) { if ( tuple instanceof Vector3d ) { return ( Vector3d ) tuple ; } return new Vector3d ( tuple . getX ( ) , tuple . getY ( ) , tuple . getZ ( ) ) ; }
Convert the given tuple to a real Vector3d .
65
12
6,770
private String ljust ( String s , Integer length ) { if ( s . length ( ) >= length ) { return s ; } length -= s . length ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( Integer i = 0 ; i < length ; i ++ ) { sb . append ( " " ) ; } return s + sb . toString ( ) ; }
Left justify a string by forcing it to be the specified length . This is done by concatonating space characters to the end of the string until the string is of the specified length . If however the string is initially longer than the specified length then the original string is returned .
83
55
6,771
private void appendProperty ( StringBuffer sb , String propertyName , Object propertyValue ) { if ( propertyValue != null ) { propertyValue = propertyValue . toString ( ) . replaceAll ( "\\s+" , " " ) . trim ( ) ; } sb . append ( ljust ( propertyName + ":" , 45 ) + propertyValue + "\n" ) ; }
Append a property to the specified string .
82
9
6,772
public void inflate ( double minx , double miny , double minz , double maxx , double maxy , double maxz ) { this . setFromCorners ( this . getMinX ( ) + minx , this . getMinY ( ) + miny , this . getMinZ ( ) + minz , this . getMaxX ( ) + maxx , this . getMaxY ( ) + maxy , this . getMaxZ ( ) + maxz ) ; }
Inflate this box with the given amounts .
105
10
6,773
@ Pure public static Point3d computeClosestPoint ( double minx , double miny , double minz , double maxx , double maxy , double maxz , double x , double y , double z ) { Point3d closest = new Point3d ( ) ; if ( x < minx ) { closest . setX ( minx ) ; } else if ( x > maxx ) { closest . setX ( maxx ) ; } else { closest . setX ( x ) ; } if ( y < miny ) { closest . setY ( miny ) ; } else if ( y > maxy ) { closest . setY ( maxy ) ; } else { closest . setY ( y ) ; } if ( z < minz ) { closest . setZ ( minz ) ; } else if ( z > maxz ) { closest . setZ ( maxz ) ; } else { closest . setZ ( z ) ; } return closest ; }
Replies the point on the shape that is closest to the given point .
207
15
6,774
@ Override public void setMinX ( double x ) { double o = this . maxxProperty . doubleValue ( ) ; if ( o < x ) { this . minxProperty . set ( o ) ; this . maxxProperty . set ( x ) ; } else { this . minxProperty . set ( x ) ; } }
Set the min X .
72
5
6,775
@ Override public void setMaxX ( double x ) { double o = this . minxProperty . doubleValue ( ) ; if ( o > x ) { this . maxxProperty . set ( o ) ; this . minxProperty . set ( x ) ; } else { this . maxxProperty . set ( x ) ; } }
Set the max X .
72
5
6,776
@ Override public void setMaxY ( double y ) { double o = this . minyProperty . doubleValue ( ) ; if ( o > y ) { this . maxyProperty . set ( o ) ; this . minyProperty . set ( y ) ; } else { this . maxyProperty . set ( y ) ; } }
Set the max Y .
72
5
6,777
@ Pure public static ShapeElementType classifiesElement ( MapElement element ) { final Class < ? extends MapElement > type = element . getClass ( ) ; if ( MapMultiPoint . class . isAssignableFrom ( type ) ) { return ShapeElementType . MULTIPOINT ; } if ( MapPolygon . class . isAssignableFrom ( type ) ) { return ShapeElementType . POLYGON ; } if ( MapPolyline . class . isAssignableFrom ( type ) ) { return ShapeElementType . POLYLINE ; } if ( MapPoint . class . isAssignableFrom ( type ) ) { return ShapeElementType . POINT ; } return ShapeElementType . UNSUPPORTED ; }
Replies the shape type that is corresponding to the given element .
157
13
6,778
void add ( MapElement element ) { final Rectangle2d r = element . getBoundingBox ( ) ; if ( r != null ) { if ( Double . isNaN ( this . minx ) || this . minx > r . getMinX ( ) ) { this . minx = r . getMinX ( ) ; } if ( Double . isNaN ( this . maxx ) || this . maxx < r . getMaxX ( ) ) { this . maxx = r . getMaxX ( ) ; } if ( Double . isNaN ( this . miny ) || this . miny > r . getMinY ( ) ) { this . miny = r . getMinY ( ) ; } if ( Double . isNaN ( this . maxy ) || this . maxy < r . getMaxY ( ) ) { this . maxy = r . getMaxY ( ) ; } } this . elements . add ( element ) ; }
Add the given element into the group .
210
8
6,779
public void addCollection ( Collection < ? extends E > collection ) { if ( collection != null && ! collection . isEmpty ( ) ) { this . collections . add ( collection ) ; } }
Add a collection inside this multicollection .
40
9
6,780
public static Point2ifx convert ( Tuple2D < ? > tuple ) { if ( tuple instanceof Point2ifx ) { return ( Point2ifx ) tuple ; } return new Point2ifx ( tuple . getX ( ) , tuple . getY ( ) ) ; }
Convert the given tuple to a real Point2ifx .
62
13
6,781
public T remove ( final T row ) { final int index = data . indexOf ( row ) ; if ( index != - 1 ) { try { return data . remove ( index ) ; } finally { fireTableDataChanged ( ) ; } } return null ; }
Removes the given Object .
55
6
6,782
public List < T > removeAll ( final List < T > toRemove ) { final List < T > removedList = new ArrayList <> ( ) ; for ( final T t : toRemove ) { final int index = data . indexOf ( t ) ; if ( index != - 1 ) { removedList . add ( data . remove ( index ) ) ; } } fireTableDataChanged ( ) ; return removedList ; }
Removes the all the given Object .
90
8
6,783
public void update ( final T row ) { final int index = data . indexOf ( row ) ; if ( index != - 1 ) { data . set ( index , row ) ; fireTableDataChanged ( ) ; } }
Update the row .
47
4
6,784
public static Point3ifx convert ( Tuple3D < ? > tuple ) { if ( tuple instanceof Point3ifx ) { return ( Point3ifx ) tuple ; } return new Point3ifx ( tuple . getX ( ) , tuple . getY ( ) , tuple . getZ ( ) ) ; }
Convert the given tuple to a real Point3ifx .
69
13
6,785
@ Pure public ReadOnlyBooleanProperty ccwProperty ( ) { if ( this . ccw == null ) { this . ccw = new ReadOnlyBooleanWrapper ( this , MathFXAttributeNames . CCW ) ; this . ccw . bind ( Bindings . createBooleanBinding ( ( ) -> Triangle2afp . isCCW ( getX1 ( ) , getY1 ( ) , getX2 ( ) , getY2 ( ) , getX3 ( ) , getY3 ( ) ) , x1Property ( ) , y1Property ( ) , x2Property ( ) , y2Property ( ) , x3Property ( ) , y3Property ( ) ) ) ; } return this . ccw . getReadOnlyProperty ( ) ; }
Replies the property that indictes if the triangle s points are defined in a counter - clockwise order .
166
22
6,786
public static final double chooseMostCommonRightHandClassAccuracy ( SummaryConfusionMatrix m ) { final double total = m . sumOfallCells ( ) ; double max = 0.0 ; for ( final Symbol right : m . rightLabels ( ) ) { max = Math . max ( max , m . columnSum ( right ) ) ; } return DoubleUtils . XOverYOrZero ( max , total ) ; }
Returns the maximum accuracy that would be achieved if a single classification were selected for all instances .
91
18
6,787
public List < GridCell < P > > consumeCells ( ) { final List < GridCell < P > > list = new ArrayList <> ( this . cells ) ; this . cells . clear ( ) ; return list ; }
Replies the cell on which the given element is located . The cell links were removed from the element .
49
21
6,788
@ Pure public boolean isReferenceCell ( GridCell < P > cell ) { return ! this . cells . isEmpty ( ) && this . cells . get ( 0 ) == cell ; }
Replies if the specified cell is the reference cell for the element . The reference cell is the cell where the element is supported to be attached when it is supposed by be inside only one cell .
39
39
6,789
public static < E > ImmutableList < E > shuffledCopy ( List < ? extends E > list , Random rng ) { final ArrayList < E > shuffled = Lists . newArrayList ( list ) ; Collections . shuffle ( shuffled , rng ) ; return ImmutableList . copyOf ( shuffled ) ; }
Returns a shuffled copy of the provided list .
70
10
6,790
protected synchronized void replaceInFileBuffered ( File sourceFile , File targetFile , ReplacementType replacementType , File [ ] classpath , boolean detectEncoding ) throws MojoExecutionException { if ( this . replacementTreatedFiles . contains ( targetFile ) && targetFile . exists ( ) ) { getLog ( ) . debug ( "Skiping " + targetFile //$NON-NLS-1$ + " because is was already treated for replacements" ) ; //$NON-NLS-1$ return ; } replaceInFile ( sourceFile , targetFile , replacementType , classpath , detectEncoding ) ; }
Replace the Javadoc tags in the given file only if the file was never treated before .
134
20
6,791
@ SuppressWarnings ( "checkstyle:nestedifdepth" ) protected synchronized String replaceAuthor ( File sourceFile , int sourceLine , String text , ExtendedArtifact artifact , ReplacementType replacementType ) throws MojoExecutionException { String result = text ; final Pattern p = buildMacroPatternWithGroup ( Macros . MACRO_AUTHOR ) ; final Matcher m = p . matcher ( text ) ; boolean hasResult = m . find ( ) ; if ( hasResult ) { final StringBuffer sb = new StringBuffer ( ) ; final StringBuilder replacement = new StringBuilder ( ) ; String login ; URL url ; Contributor contributor ; do { login = m . group ( 1 ) ; if ( login != null ) { login = login . trim ( ) ; if ( login . length ( ) > 0 ) { replacement . setLength ( 0 ) ; if ( artifact != null ) { contributor = artifact . getPeople ( login , getLog ( ) ) ; if ( contributor != null ) { url = getContributorURL ( contributor , getLog ( ) ) ; if ( url == null ) { replacement . append ( contributor . getName ( ) ) ; } else if ( replacementType == ReplacementType . HTML ) { replacement . append ( "<a target=\"_blank\" href=\"" ) ; //$NON-NLS-1$ replacement . append ( url . toExternalForm ( ) ) ; replacement . append ( "\">" ) ; //$NON-NLS-1$ replacement . append ( contributor . getName ( ) ) ; replacement . append ( "</a>" ) ; //$NON-NLS-1$ } else { replacement . append ( contributor . getName ( ) ) ; replacement . append ( " [" ) ; //$NON-NLS-1$ replacement . append ( url . toExternalForm ( ) ) ; replacement . append ( "]" ) ; //$NON-NLS-1$ } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "unable to find a developer or a contributor " //$NON-NLS-1$ + "with an id, a name or an email equal to: " //$NON-NLS-1$ + login , BuildContext . SEVERITY_WARNING , null ) ; } } if ( replacement . length ( ) != 0 ) { m . appendReplacement ( sb , Matcher . quoteReplacement ( replacement . toString ( ) ) ) ; } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "no login for Author tag: " + m . group ( 0 ) , //$NON-NLS-1$ BuildContext . SEVERITY_WARNING , null ) ; } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "no login for Author tag: " + m . group ( 0 ) , //$NON-NLS-1$ BuildContext . SEVERITY_WARNING , null ) ; } hasResult = m . find ( ) ; } while ( hasResult ) ; m . appendTail ( sb ) ; result = sb . toString ( ) ; } return result ; }
Replace the author information tags in the given text .
695
11
6,792
@ SuppressWarnings ( "checkstyle:nestedifdepth" ) protected synchronized String replaceProp ( File sourceFile , int sourceLine , String text , MavenProject project , ReplacementType replacementType ) throws MojoExecutionException { String result = text ; final Pattern p = buildMacroPatternWithGroup ( Macros . MACRO_PROP ) ; final Matcher m = p . matcher ( text ) ; boolean hasResult = m . find ( ) ; Properties props = null ; if ( project != null ) { props = project . getProperties ( ) ; } if ( hasResult ) { final StringBuffer sb = new StringBuffer ( ) ; final StringBuilder replacement = new StringBuilder ( ) ; String propName ; do { propName = m . group ( 1 ) ; if ( propName != null ) { propName = propName . trim ( ) ; if ( propName . length ( ) > 0 ) { replacement . setLength ( 0 ) ; if ( props != null ) { final String value = props . getProperty ( propName ) ; if ( value != null && ! value . isEmpty ( ) ) { replacement . append ( value ) ; } } if ( replacement . length ( ) != 0 ) { m . appendReplacement ( sb , Matcher . quoteReplacement ( replacement . toString ( ) ) ) ; } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "no property name for Prop tag: " + m . group ( 0 ) , //$NON-NLS-1$ BuildContext . SEVERITY_WARNING , null ) ; } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "no property name for Prop tag: " + m . group ( 0 ) , //$NON-NLS-1$ BuildContext . SEVERITY_WARNING , null ) ; } hasResult = m . find ( ) ; } while ( hasResult ) ; m . appendTail ( sb ) ; result = sb . toString ( ) ; } return result ; }
Replace the property information tags in the given text .
448
11
6,793
protected void setSourceDirectoryForAllMojo ( File newSourceDirectory ) { final List < String > sourceRoots = this . mavenProject . getCompileSourceRoots ( ) ; getLog ( ) . debug ( "Old source roots: " + sourceRoots . toString ( ) ) ; //$NON-NLS-1$ final Iterator < String > iterator = sourceRoots . iterator ( ) ; final String removableSourcePath = this . javaSourceRoot . getAbsolutePath ( ) ; getLog ( ) . debug ( "Removable source root: " + removableSourcePath ) ; //$NON-NLS-1$ String path ; while ( iterator . hasNext ( ) ) { path = iterator . next ( ) ; if ( path != null && path . equals ( removableSourcePath ) ) { getLog ( ) . debug ( "Removing source root: " + path ) ; //$NON-NLS-1$ iterator . remove ( ) ; } } getLog ( ) . debug ( "Adding source root: " + newSourceDirectory . getAbsolutePath ( ) ) ; //$NON-NLS-1$ this . mavenProject . addCompileSourceRoot ( newSourceDirectory . toString ( ) ) ; this . sourceDirectory = newSourceDirectory ; }
Replace the current source directory by the given directory .
280
11
6,794
public static Optional < OffsetRange < CharOffset > > charOffsetsOfWholeString ( String s ) { if ( s . isEmpty ( ) ) { return Optional . absent ( ) ; } return Optional . of ( charOffsetRange ( 0 , s . length ( ) - 1 ) ) ; }
This returns optional because it is not possible to represent an empty offset span
64
14
6,795
public boolean contains ( final OffsetType x ) { return x . asInt ( ) >= startInclusive ( ) . asInt ( ) && x . asInt ( ) <= endInclusive ( ) . asInt ( ) ; }
Returns if the given offset is within the inclusive bounds of this range .
49
14
6,796
@ Pure public static int getColorFromName ( String colorName , int defaultValue ) { final Integer value = COLOR_MATCHES . get ( Strings . nullToEmpty ( colorName ) . toLowerCase ( ) ) ; if ( value != null ) { return value . intValue ( ) ; } return defaultValue ; }
Replies the color value for the given color name .
71
11
6,797
@ Pure public static String getColorNameFromValue ( int colorValue ) { for ( final Entry < String , Integer > entry : COLOR_MATCHES . entrySet ( ) ) { final int knownValue = entry . getValue ( ) . intValue ( ) ; if ( colorValue == knownValue ) { return entry . getKey ( ) ; } } return null ; }
Replies the color name for the given color value .
80
11
6,798
@ Pure public double getLength ( ) { double length = 0 ; for ( final RoadPath p : this . paths ) { length += p . getLength ( ) ; } return length ; }
Replies the length of the path .
40
8
6,799
@ Pure public int indexOf ( RoadSegment segment ) { int count = 0 ; int index ; for ( final RoadPath p : this . paths ) { index = p . indexOf ( segment ) ; if ( index >= 0 ) { return count + index ; } count += p . size ( ) ; } return - 1 ; }
Replies the index of the first occurrence . of the given road segment .
70
15