idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
25,200 | public void setClassLoaderProvider ( String id , ClassLoaderProvider classLoaderProvider ) { if ( classLoaderProvider != null ) { classLoaderProviderMap . put ( id , classLoaderProvider ) ; } else { classLoaderProviderMap . remove ( id ) ; } } | Registers a named class loader provider or removes it if the classLoaderProvider is null |
25,201 | public SortedSet < String > findClassNames ( String search , Integer limit ) { Map < Package , ClassLoader [ ] > packageMap = Packages . getPackageMap ( getClassLoaders ( ) , ignorePackages ) ; return findClassNamesInPackages ( search , limit , packageMap ) ; } | Searches for the available class names given the text search |
25,202 | public SortedMap < String , Class < ? > > getAllClassesMap ( ) { Package [ ] packages = Package . getPackages ( ) ; return getClassesMap ( packages ) ; } | Returns all the classes found in a sorted map |
25,203 | public SortedMap < String , Class < ? > > getClassesMap ( Package ... packages ) { SortedMap < String , Class < ? > > answer = new TreeMap < String , Class < ? > > ( ) ; Map < String , ClassResource > urlSet = new HashMap < String , ClassResource > ( ) ; for ( Package aPackage : packages ) { addPackageResources ( aPackage , urlSet , classLoaders ) ; } for ( ClassResource classResource : urlSet . values ( ) ) { Set < Class < ? > > classes = getClassesForPackage ( classResource , null , null ) ; for ( Class < ? > aClass : classes ) { answer . put ( aClass . getName ( ) , aClass ) ; } } return answer ; } | Returns all the classes found in a sorted map for the given list of packages |
25,204 | public Class < ? > findClass ( String className ) throws ClassNotFoundException { for ( String skip : SKIP_CLASSES ) { if ( skip . equals ( className ) ) { return null ; } } for ( ClassLoader classLoader : getClassLoaders ( ) ) { try { return classLoader . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { } } return Class . forName ( className ) ; } | Finds a class from its name |
25,205 | public List < Class < ? > > optionallyFindClasses ( Iterable < String > classNames ) { List < Class < ? > > answer = new ArrayList < Class < ? > > ( ) ; for ( String className : classNames ) { Class < ? > aClass = optionallyFindClass ( className ) ; if ( aClass != null ) { answer . add ( aClass ) ; } } return answer ; } | Tries to find as many of the class names on the class loaders as possible and return them |
25,206 | protected boolean withinLimit ( Integer limit , Collection < ? > collection ) { if ( limit == null ) { return true ; } else { int value = limit . intValue ( ) ; return value <= 0 || value > collection . size ( ) ; } } | Returns true if we are within the limit value for the number of results in the collection |
25,207 | protected static Class findClass ( final String className ) throws ClassNotFoundException { try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { try { return Class . forName ( className ) ; } catch ( ClassNotFoundException e1 ) { return MavenCoordHelper . class . getClassLoader ( ) . loadClass ( className ) ; } } } | Find class given class name . |
25,208 | public File getConfigDirectory ( ) { String dirName = getConfigDir ( ) ; File answer = null ; if ( Strings . isNotBlank ( dirName ) ) { answer = new File ( dirName ) ; } else { answer = new File ( ".hawtio" ) ; } answer . mkdirs ( ) ; return answer ; } | Returns the configuration directory ; lazily attempting to create it if it does not yet exist |
25,209 | public void start ( ) { MBeanServer server = getMbeanServer ( ) ; if ( server != null ) { registerMBeanServer ( server ) ; } else { LOG . error ( "No MBeanServer available so cannot register mbean" ) ; } } | Registers the object with JMX |
25,210 | protected String checkAgentUrl ( Object pVm ) throws NoSuchMethodException , InvocationTargetException , IllegalAccessException { Properties systemProperties = getAgentSystemProperties ( pVm ) ; return systemProperties . getProperty ( JvmAgent . JOLOKIA_AGENT_URL ) ; } | borrowed these from AbstractBaseCommand for now |
25,211 | protected int indexOf ( String text , String ... values ) { int answer = - 1 ; for ( String value : values ) { int idx = text . indexOf ( value ) ; if ( idx >= 0 ) { if ( answer < 0 || idx < answer ) { answer = idx ; } } } return answer ; } | Returns the lowest index of the given list of values |
25,212 | public static FileLocker getLock ( File lockFile ) { lockFile . getParentFile ( ) . mkdirs ( ) ; if ( ! lockFile . exists ( ) ) { try { IOHelper . write ( lockFile , "I have the lock!" ) ; lockFile . deleteOnExit ( ) ; return new FileLocker ( lockFile ) ; } catch ( IOException e ) { } } return null ; } | Attempts to grab the lock for the given file returning a FileLock if the lock has been created ; otherwise it returns null |
25,213 | public static String getVersion ( Class < ? > aClass , String groupId , String artifactId ) { String version = null ; InputStream is = null ; String fileName = "/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties" ; try { Properties p = new Properties ( ) ; is = aClass . getResourceAsStream ( fileName ) ; if ( is != null ) { p . load ( is ) ; version = p . getProperty ( "version" , "" ) ; } } catch ( Exception e ) { } finally { if ( is != null ) { IOHelper . close ( is , fileName , LOG ) ; } } if ( version == null ) { Package aPackage = aClass . getPackage ( ) ; if ( aPackage != null ) { version = aPackage . getImplementationVersion ( ) ; if ( Strings . isBlank ( version ) ) { version = aPackage . getSpecificationVersion ( ) ; } } } if ( version == null ) { Enumeration < URL > resources = null ; try { resources = aClass . getClassLoader ( ) . getResources ( "META-INF/MANIFEST.MF" ) ; } catch ( IOException e ) { } if ( resources != null ) { String expectedBundleName = groupId + "." + artifactId ; while ( resources . hasMoreElements ( ) ) { try { Manifest manifest = new Manifest ( resources . nextElement ( ) . openStream ( ) ) ; Attributes attributes = manifest . getMainAttributes ( ) ; String bundleName = attributes . getValue ( "Bundle-SymbolicName" ) ; if ( Objects . equals ( expectedBundleName , bundleName ) ) { version = attributes . getValue ( "Implementation-Version" ) ; if ( Strings . isNotBlank ( version ) ) break ; } } catch ( IOException e ) { } } } } return version ; } | Returns the version of the given class s package or the group and artifact of the jar |
25,214 | public void clear ( ) { mCardNumberEditText . setText ( "" ) ; mExpiryDateEditText . setText ( "" ) ; mCvcEditText . setText ( "" ) ; mPostalCodeEditText . setText ( "" ) ; mCardNumberEditText . setShouldShowError ( false ) ; mExpiryDateEditText . setShouldShowError ( false ) ; mCvcEditText . setShouldShowError ( false ) ; mPostalCodeEditText . setShouldShowError ( false ) ; updateBrand ( Card . UNKNOWN ) ; } | Clear all entered data and hide all error messages . |
25,215 | public boolean validateCardNumber ( ) { boolean cardNumberIsValid = CardUtils . isValidCardNumber ( mCardNumberEditText . getCardNumber ( ) ) ; mCardNumberEditText . setShouldShowError ( ! cardNumberIsValid ) ; return cardNumberIsValid ; } | Checks whether the current card number is valid |
25,216 | public void setExpiryDate ( @ IntRange ( from = 1 , to = 12 ) int month , @ IntRange ( from = 0 , to = 9999 ) int year ) { mExpiryDateEditText . setText ( DateUtils . createDateStringFromIntegerInput ( month , year ) ) ; } | Set the expiration date . Method invokes completion listener and changes focus to the CVC field if a valid date is entered . |
25,217 | public void clear ( ) { if ( mCardNumberEditText . hasFocus ( ) || mExpiryDateEditText . hasFocus ( ) || mCvcNumberEditText . hasFocus ( ) || this . hasFocus ( ) ) { mCardNumberEditText . requestFocus ( ) ; } mCvcNumberEditText . setText ( "" ) ; mExpiryDateEditText . setText ( "" ) ; mCardNumberEditText . setText ( "" ) ; } | Clear all text fields in the CardInputWidget . |
25,218 | public void setEnabled ( boolean isEnabled ) { mCardNumberEditText . setEnabled ( isEnabled ) ; mExpiryDateEditText . setEnabled ( isEnabled ) ; mCvcNumberEditText . setEnabled ( isEnabled ) ; } | Enable or disable text fields |
25,219 | public void setHintDelayed ( final int hintResource , long delayMilliseconds ) { final Runnable hintRunnable = new Runnable ( ) { public void run ( ) { setHint ( hintResource ) ; } } ; mHandler . postDelayed ( hintRunnable , delayMilliseconds ) ; } | Change the hint value of this control after a delay . |
25,220 | public void setShouldShowError ( boolean shouldShowError ) { if ( mErrorMessage != null && mErrorMessageListener != null ) { String errorMessage = shouldShowError ? mErrorMessage : null ; mErrorMessageListener . displayErrorMessage ( errorMessage ) ; mShouldShowError = shouldShowError ; } else { mShouldShowError = shouldShowError ; if ( mShouldShowError ) { setTextColor ( mErrorColor ) ; } else { setTextColor ( mCachedColorStateList ) ; } refreshDrawableState ( ) ; } } | Sets whether or not the text should be put into error mode which displays the text in an error color determined by the original text color . |
25,221 | private void showDialog ( final Source source ) { mRedirectSource = source ; final SourceRedirect sourceRedirect = source . getRedirect ( ) ; final String redirectUrl = sourceRedirect != null ? sourceRedirect . getUrl ( ) : null ; if ( redirectUrl != null ) { mRedirectDialogController . showDialog ( redirectUrl ) ; } } | Show a dialog with a link to the external verification site . |
25,222 | private void handlePostAuthReturn ( ) { final Uri intentUri = getIntent ( ) . getData ( ) ; if ( intentUri != null ) { if ( "stripe" . equals ( intentUri . getScheme ( ) ) && "payment-auth-return" . equals ( intentUri . getHost ( ) ) ) { final String paymentIntentClientSecret = intentUri . getQueryParameter ( "payment_intent_client_secret" ) ; if ( paymentIntentClientSecret != null ) { final Stripe stripe = new Stripe ( getApplicationContext ( ) , PaymentConfiguration . getInstance ( ) . getPublishableKey ( ) ) ; final PaymentIntentParams paymentIntentParams = PaymentIntentParams . createRetrievePaymentIntentParams ( paymentIntentClientSecret ) ; mCompositeDisposable . add ( Observable . fromCallable ( ( ) -> stripe . retrievePaymentIntentSynchronous ( paymentIntentParams , PaymentConfiguration . getInstance ( ) . getPublishableKey ( ) ) ) . subscribeOn ( Schedulers . io ( ) ) . observeOn ( AndroidSchedulers . mainThread ( ) ) . subscribe ( ( paymentIntent -> { if ( paymentIntent != null ) { handleRetrievedPaymentIntent ( paymentIntent ) ; } } ) ) ) ; } } } } | If the intent URI matches the post auth deep - link URI the user attempted to authenticate payment and was returned to the app . Retrieve the PaymentIntent and inform the user about the state of their payment . |
25,223 | @ Size ( 2 ) static String [ ] separateDateStringParts ( @ Size ( max = 4 ) String expiryInput ) { String [ ] parts = new String [ 2 ] ; if ( expiryInput . length ( ) >= 2 ) { parts [ 0 ] = expiryInput . substring ( 0 , 2 ) ; parts [ 1 ] = expiryInput . substring ( 2 ) ; } else { parts [ 0 ] = expiryInput ; parts [ 1 ] = "" ; } return parts ; } | Separates raw string input of the format MMYY into a month group and a year group . Either or both of these may be incomplete . This method does not check to see if the input is valid . |
25,224 | @ IntRange ( from = 1000 , to = 9999 ) static int convertTwoDigitYearToFour ( @ IntRange ( from = 0 , to = 99 ) int inputYear ) { return convertTwoDigitYearToFour ( inputYear , Calendar . getInstance ( ) ) ; } | Converts a two - digit input year to a four - digit year . As the current calendar year approaches a century we assume small values to mean the next century . For instance if the current year is 2090 and the input value is 18 the user probably means 2118 not 2018 . However in 2017 the input 18 probably means 2018 . This code should be updated before the year 9981 . |
25,225 | public static SourceParams createSourceFromTokenParams ( String tokenId ) { SourceParams sourceParams = SourceParams . createCustomParams ( ) ; sourceParams . setType ( Source . CARD ) ; sourceParams . setToken ( tokenId ) ; return sourceParams ; } | Create parameters necessary for converting a token into a source |
25,226 | public static Map < String , Object > createRetrieveSourceParams ( @ Size ( min = 1 ) String clientSecret ) { final Map < String , Object > params = new HashMap < > ( ) ; params . put ( API_PARAM_CLIENT_SECRET , clientSecret ) ; return params ; } | Create parameters needed to retrieve a source . |
25,227 | public void clearReferences ( ) { if ( mAsyncTaskController != null ) { mAsyncTaskController . detach ( ) ; } if ( mRxTokenController != null ) { mRxTokenController . detach ( ) ; } if ( mIntentServiceTokenController != null ) { mIntentServiceTokenController . detach ( ) ; } mAsyncTaskController = null ; mRxTokenController = null ; mIntentServiceTokenController = null ; } | Clear all the references so that we can start over again . |
25,228 | public Surface rotate ( float angle ) { float sr = ( float ) Math . sin ( angle ) ; float cr = ( float ) Math . cos ( angle ) ; transform ( cr , sr , - sr , cr , 0 , 0 ) ; return this ; } | Rotates the current transformation matrix by the specified angle in radians . |
25,229 | public Surface transform ( float m00 , float m01 , float m10 , float m11 , float tx , float ty ) { AffineTransform top = tx ( ) ; Transforms . multiply ( top , m00 , m01 , m10 , m11 , tx , ty , top ) ; return this ; } | Multiplies the current transformation matrix by the given matrix . |
25,230 | public boolean intersects ( float x , float y , float w , float h ) { tx ( ) . transform ( intersectionTestPoint . set ( x , y ) , intersectionTestPoint ) ; tx ( ) . transform ( intersectionTestSize . set ( w , h ) , intersectionTestSize ) ; float ix = intersectionTestPoint . x , iy = intersectionTestPoint . y ; float iw = intersectionTestSize . x , ih = intersectionTestSize . y ; if ( scissorDepth > 0 ) { Rectangle scissor = scissors . get ( scissorDepth - 1 ) ; return scissor . intersects ( ( int ) ix , ( int ) iy , ( int ) iw , ( int ) ih ) ; } float tw = target . width ( ) , th = target . height ( ) ; return ( ix + iw > 0 ) && ( ix < tw ) && ( iy + ih > 0 ) && ( iy < th ) ; } | Returns whether the given rectangle intersects the render target area of this surface . |
25,231 | public Surface fillRect ( float x , float y , float width , float height ) { if ( patternTex != null ) { batch . addQuad ( patternTex , tint , tx ( ) , x , y , width , height ) ; } else { batch . addQuad ( colorTex , Tint . combine ( fillColor , tint ) , tx ( ) , x , y , width , height ) ; } return this ; } | Fills the specified rectangle . |
25,232 | private String [ ] platformNames ( String libraryName ) { if ( isWindows ) return new String [ ] { libraryName + ( is64Bit ? "64.dll" : ".dll" ) } ; if ( isLinux ) return new String [ ] { "lib" + libraryName + ( is64Bit ? "64.so" : ".so" ) } ; if ( isMac ) return new String [ ] { "lib" + libraryName + ".jnilib" , "lib" + libraryName + ".dylib" } ; return new String [ ] { libraryName } ; } | Maps a platform independent library name to one or more platform dependent names . |
25,233 | private String crc ( InputStream input ) { if ( input == null ) throw new IllegalArgumentException ( "input cannot be null." ) ; CRC32 crc = new CRC32 ( ) ; byte [ ] buffer = new byte [ 4096 ] ; try { while ( true ) { int length = input . read ( buffer ) ; if ( length == - 1 ) break ; crc . update ( buffer , 0 , length ) ; } } catch ( Exception ex ) { try { input . close ( ) ; } catch ( Exception ignored ) { } } return Long . toString ( crc . getValue ( ) ) ; } | Returns a CRC of the remaining bytes in the stream . |
25,234 | public CharBuffer put ( String str , int start , int end ) { int length = str . length ( ) ; if ( start < 0 || end < start || end > length ) { throw new IndexOutOfBoundsException ( ) ; } if ( end - start > remaining ( ) ) { throw new BufferOverflowException ( ) ; } for ( int i = start ; i < end ; i ++ ) { put ( str . charAt ( i ) ) ; } return this ; } | Writes chars of the given string to the current position of this buffer and increases the position by the number of chars written . |
25,235 | public RFuture < String > get ( String url ) { return req ( url ) . execute ( ) . map ( GET_PAYLOAD ) ; } | Performs an HTTP GET request to the specified URL . |
25,236 | public RFuture < String > post ( String url , String data ) { return req ( url ) . setPayload ( data ) . execute ( ) . map ( GET_PAYLOAD ) ; } | Performs an HTTP POST request to the specified URL . |
25,237 | public Region region ( final float rx , final float ry , final float rwidth , final float rheight ) { final Image image = this ; return new Region ( ) { private Tile tile ; public boolean isLoaded ( ) { return image . isLoaded ( ) ; } public Tile tile ( ) { if ( tile == null ) tile = image . texture ( ) . tile ( rx , ry , rwidth , rheight ) ; return tile ; } public RFuture < Tile > tileAsync ( ) { return image . state . map ( new Function < Image , Tile > ( ) { public Tile apply ( Image image ) { return tile ( ) ; } } ) ; } public float width ( ) { return rwidth ; } public float height ( ) { return rheight ; } public void draw ( Object ctx , float x , float y , float width , float height ) { image . draw ( ctx , x , y , width , height , rx , ry , rwidth , rheight ) ; } public void draw ( Object ctx , float dx , float dy , float dw , float dh , float sx , float sy , float sw , float sh ) { image . draw ( ctx , dx , dy , dw , dh , rx + sx , ry + sy , sw , sh ) ; } } ; } | Returns a region of this image which can be drawn independently . |
25,238 | public void resize ( float width , float height ) { if ( canvas != null ) canvas . close ( ) ; canvas = gfx . createCanvas ( width , height ) ; } | Resizes the canvas that is displayed by this layer . |
25,239 | public void end ( ) { Texture tex = ( Texture ) tile ( ) ; Image image = canvas . image ; if ( tex != null && tex . pixelWidth == image . pixelWidth ( ) && tex . pixelHeight == image . pixelHeight ( ) ) tex . update ( image ) ; else super . setTile ( canvas . image . createTexture ( Texture . Config . DEFAULT ) ) ; } | Informs this layer that a drawing operation has just completed . The backing canvas image data is uploaded to the GPU . |
25,240 | public void close ( ) { if ( parent != null ) parent . remove ( this ) ; setState ( State . DISPOSED ) ; setBatch ( null ) ; } | Disposes this layer removing it from its parent layer . Any resources associated with this layer are freed and it cannot be reused after being disposed . Disposing a layer that has children will dispose them as well . |
25,241 | public AffineTransform transform ( ) { if ( isSet ( Flag . XFDIRTY ) ) { float sina = FloatMath . sin ( rotation ) , cosa = FloatMath . cos ( rotation ) ; float m00 = cosa * scaleX , m01 = sina * scaleX ; float m10 = - sina * scaleY , m11 = cosa * scaleY ; float tx = transform . tx ( ) , ty = transform . ty ( ) ; transform . setTransform ( m00 , m01 , m10 , m11 , tx , ty ) ; setFlag ( Flag . XFDIRTY , false ) ; } return transform ; } | Returns the layer s current transformation matrix . If any changes have been made to the layer s scale rotation or translation they will be applied to the transform matrix before it is returned . |
25,242 | public float originX ( ) { if ( isSet ( Flag . ODIRTY ) ) { float width = width ( ) ; if ( width > 0 ) { this . originX = origin . ox ( width ) ; this . originY = origin . oy ( height ( ) ) ; setFlag ( Flag . ODIRTY , false ) ; } } return originX ; } | Returns the x - component of the layer s origin . |
25,243 | public float originY ( ) { if ( isSet ( Flag . ODIRTY ) ) { float height = height ( ) ; if ( height > 0 ) { this . originX = origin . ox ( width ( ) ) ; this . originY = origin . oy ( height ) ; setFlag ( Flag . ODIRTY , false ) ; } } return originY ; } | Returns the y - component of the layer s origin . |
25,244 | public Layer setOrigin ( Origin origin ) { this . origin = origin ; setFlag ( Flag . ODIRTY , true ) ; return this ; } | Configures the origin of this layer based on a logical location which is recomputed whenever the layer changes size . |
25,245 | public void debugPrint ( final Log log ) { this . visit ( new Visitor ( ) { public void visit ( Layer layer , int depth ) { String prefix = repeat ( '.' , depth ) ; log . debug ( prefix + layer . toString ( ) ) ; } } ) ; } | Prints a debug representation of this layer and its children . |
25,246 | public SoundImpl < ? > createSound ( AssetFileDescriptor fd ) { PooledSound sound = new PooledSound ( pool . load ( fd , 1 ) ) ; loadingSounds . put ( sound . soundId , sound ) ; return sound ; } | Creates a sound instance from the supplied asset file descriptor . |
25,247 | public SoundImpl < ? > createSound ( FileDescriptor fd , long offset , long length ) { PooledSound sound = new PooledSound ( pool . load ( fd , offset , length , 1 ) ) ; loadingSounds . put ( sound . soundId , sound ) ; return sound ; } | Creates a sound instance from the supplied file descriptor offset . |
25,248 | public int compareTo ( ByteBuffer otherBuffer ) { int compareRemaining = ( remaining ( ) < otherBuffer . remaining ( ) ) ? remaining ( ) : otherBuffer . remaining ( ) ; int thisPos = position ; int otherPos = otherBuffer . position ; byte thisByte , otherByte ; while ( compareRemaining > 0 ) { thisByte = get ( thisPos ) ; otherByte = otherBuffer . get ( otherPos ) ; if ( thisByte != otherByte ) { return thisByte < otherByte ? - 1 : 1 ; } thisPos ++ ; otherPos ++ ; compareRemaining -- ; } return remaining ( ) - otherBuffer . remaining ( ) ; } | Compares the remaining bytes of this buffer to another byte buffer s remaining bytes . |
25,249 | public final ByteBuffer get ( byte [ ] dest , int off , int len ) { int length = dest . length ; if ( off < 0 || len < 0 || ( long ) off + ( long ) len > length ) { throw new IndexOutOfBoundsException ( ) ; } if ( len > remaining ( ) ) { throw new BufferUnderflowException ( ) ; } for ( int i = 0 ; i < len ; i ++ ) { dest [ i + off ] = get ( position + i ) ; } position += len ; return this ; } | Reads bytes from the current position into the specified byte array starting at the specified offset and increases the position by the number of bytes read . |
25,250 | public ByteBuffer put ( byte [ ] src , int off , int len ) { int length = src . length ; if ( off < 0 || len < 0 || off + len > length ) { throw new IndexOutOfBoundsException ( ) ; } if ( len > remaining ( ) ) { throw new BufferOverflowException ( ) ; } for ( int i = 0 ; i < len ; i ++ ) { byteArray . set ( i + position , src [ off + i ] ) ; } position += len ; return this ; } | Writes bytes in the given byte array starting from the specified offset to the current position and increases the position by the number of bytes written . |
25,251 | public void close ( ) { if ( ! disposed ) { disposed = true ; if ( gfx . exec ( ) . isMainThread ( ) ) { gfx . gl . glDeleteTexture ( id ) ; } else { gfx . exec ( ) . invokeNextFrame ( new Runnable ( ) { public void run ( ) { gfx . gl . glDeleteTexture ( id ) ; } } ) ; } } } | Deletes this texture s GPU resources and renders it unusable . |
25,252 | public void onSurfaceChanged ( int pixelWidth , int pixelHeight , int orient ) { viewportChanged ( pixelWidth , pixelHeight ) ; screenSize . setSize ( viewSize ) ; switch ( orient ) { case Configuration . ORIENTATION_LANDSCAPE : orientDetailM . update ( OrientationDetail . LANDSCAPE_LEFT ) ; break ; case Configuration . ORIENTATION_PORTRAIT : orientDetailM . update ( OrientationDetail . PORTRAIT ) ; break ; default : orientDetailM . update ( OrientationDetail . UNKNOWN ) ; break ; } } | Informs the graphics system that the surface into which it is rendering has changed size . The supplied width and height are in pixels not display units . |
25,253 | void viewDidInit ( CGRect bounds ) { defaultFramebuffer = gl . glGetInteger ( GL20 . GL_FRAMEBUFFER_BINDING ) ; if ( defaultFramebuffer == 0 ) throw new IllegalStateException ( "Failed to determine defaultFramebuffer" ) ; boundsChanged ( bounds ) ; } | called when our view appears |
25,254 | public RFuture < String > getText ( Keyboard . TextType textType , String label , String initialValue ) { return getText ( textType , label , initialValue , "Ok" , "Cancel" ) ; } | Requests a line of text from the user . On platforms that have only a virtual keyboard this will display a text entry interface obtain the line of text and dismiss the text entry interface when finished . |
25,255 | public RFuture < String > getText ( Keyboard . TextType textType , String label , String initialValue , String ok , String cancel ) { return RFuture . failure ( new Exception ( "getText not supported" ) ) ; } | Requests a line of text from the user . On platforms that have only a virtual keyboard this will display a text entry interface obtain the line of text and dismiss the text entry interface when finished . Note that HTML5 and some Java backends do not support customization of the OK and Cancel labels . Thus those platforms will ignore the supplied labels and use their mandatory labels . |
25,256 | public RFuture < Boolean > sysDialog ( String title , String text , String ok , String cancel ) { return RFuture . failure ( new Exception ( "sysDialog not supported" ) ) ; } | Displays a system dialog with the specified title and text an OK button and optionally a Cancel button . |
25,257 | public static Point layerToScreen ( Layer layer , float x , float y ) { Point into = new Point ( x , y ) ; return layerToScreen ( layer , into , into ) ; } | Converts the supplied point from coordinates relative to the specified layer to screen coordinates . |
25,258 | public static Point layerToParent ( Layer layer , Layer parent , float x , float y ) { Point into = new Point ( x , y ) ; return layerToParent ( layer , parent , into , into ) ; } | Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer . |
25,259 | public static Point screenToLayer ( Layer layer , float x , float y ) { Point into = new Point ( x , y ) ; return screenToLayer ( layer , into , into ) ; } | Converts the supplied point from screen coordinates to coordinates relative to the specified layer . |
25,260 | public static Layer layerUnderPoint ( Layer root , float x , float y ) { Point p = new Point ( x , y ) ; root . transform ( ) . inverseTransform ( p , p ) ; p . x += root . originX ( ) ; p . y += root . originY ( ) ; return layerUnderPoint ( root , p ) ; } | Gets the layer underneath the given screen coordinates ignoring hit testers . This is useful for inspecting the scene graph for debugging purposes and is not intended for use is shipped code . The layer returned is the one that has a size and is the deepest within the graph and contains the coordinate . |
25,261 | public static int indexInParent ( Layer layer ) { GroupLayer parent = layer . parent ( ) ; if ( parent == null ) return - 1 ; for ( int ii = parent . children ( ) - 1 ; ii >= 0 ; ii -- ) { if ( parent . childAt ( ii ) == layer ) return ii ; } throw new AssertionError ( ) ; } | Returns the index of the given layer within its parent or - 1 if the parent is null . |
25,262 | public void bind ( ) { gfx . gl . glBindFramebuffer ( GL_FRAMEBUFFER , id ( ) ) ; gfx . gl . glViewport ( 0 , 0 , width ( ) , height ( ) ) ; } | Binds the framebuffer . |
25,263 | public void close ( ) { gl . glDeleteShader ( vertexShader ) ; gl . glDeleteShader ( fragmentShader ) ; gl . glDeleteProgram ( id ) ; } | Frees this program and associated compiled shaders . The program must not be used after closure . |
25,264 | private void emitStringValue ( String s ) { raw ( '"' ) ; char b = 0 , c = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { b = c ; c = s . charAt ( i ) ; switch ( c ) { case '\\' : case '"' : raw ( '\\' ) ; raw ( c ) ; break ; case '/' : if ( b == '<' ) raw ( '\\' ) ; raw ( c ) ; break ; case '\b' : raw ( "\\b" ) ; break ; case '\t' : raw ( "\\t" ) ; break ; case '\n' : raw ( "\\n" ) ; break ; case '\f' : raw ( "\\f" ) ; break ; case '\r' : raw ( "\\r" ) ; break ; default : if ( shouldBeEscaped ( c ) ) { String t = "000" + Integer . toHexString ( c ) ; raw ( "\\u" + t . substring ( t . length ( ) - "0000" . length ( ) ) ) ; } else { raw ( c ) ; } } } raw ( '"' ) ; } | Emits a quoted string value escaping characters that are required to be escaped . |
25,265 | FontRenderContext aaFontContext ( ) { if ( aaFontContext == null ) { Graphics2D aaGfx = new BufferedImage ( 1 , 1 , BufferedImage . TYPE_INT_ARGB ) . createGraphics ( ) ; aaGfx . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; aaFontContext = aaGfx . getFontRenderContext ( ) ; } return aaFontContext ; } | these are initialized lazily to avoid doing any AWT stuff during startup |
25,266 | public int compareTo ( DoubleBuffer otherBuffer ) { int compareRemaining = ( remaining ( ) < otherBuffer . remaining ( ) ) ? remaining ( ) : otherBuffer . remaining ( ) ; int thisPos = position ; int otherPos = otherBuffer . position ; double thisDouble , otherDouble ; while ( compareRemaining > 0 ) { thisDouble = get ( thisPos ) ; otherDouble = otherBuffer . get ( otherPos ) ; if ( ( thisDouble != otherDouble ) && ( ( thisDouble == thisDouble ) || ( otherDouble == otherDouble ) ) ) { return thisDouble < otherDouble ? - 1 : 1 ; } thisPos ++ ; otherPos ++ ; compareRemaining -- ; } return remaining ( ) - otherBuffer . remaining ( ) ; } | Compare the remaining doubles of this buffer to another double buffer s remaining doubles . |
25,267 | public DoubleBuffer get ( double [ ] dest , int off , int len ) { int length = dest . length ; if ( off < 0 || len < 0 || ( long ) off + ( long ) len > length ) { throw new IndexOutOfBoundsException ( ) ; } if ( len > remaining ( ) ) { throw new BufferUnderflowException ( ) ; } for ( int i = off ; i < off + len ; i ++ ) { dest [ i ] = get ( ) ; } return this ; } | Reads doubles from the current position into the specified double array starting from the specified offset and increases the position by the number of doubles read . |
25,268 | public DoubleBuffer put ( double [ ] src , int off , int len ) { int length = src . length ; if ( off < 0 || len < 0 || ( long ) off + ( long ) len > length ) { throw new IndexOutOfBoundsException ( ) ; } if ( len > remaining ( ) ) { throw new BufferOverflowException ( ) ; } for ( int i = off ; i < off + len ; i ++ ) { put ( src [ i ] ) ; } return this ; } | Writes doubles from the given double array starting from the specified offset to the current position and increases the position by the number of doubles written . |
25,269 | public synchronized void succeed ( I impl ) { this . impl = impl ; setVolumeImpl ( volume ) ; setLoopingImpl ( looping ) ; if ( playing ) playImpl ( ) ; ( ( RPromise < Sound > ) state ) . succeed ( this ) ; } | Configures this sound with its platform implementation . This may be called from any thread . |
25,270 | private int toModifierFlags ( int mods ) { return modifierFlags ( ( mods & GLFW_MOD_ALT ) != 0 , ( mods & GLFW_MOD_CONTROL ) != 0 , ( mods & GLFW_MOD_SUPER ) != 0 , ( mods & GLFW_MOD_SHIFT ) != 0 ) ; } | Converts GLFW modifier key flags into PlayN modifier key flags . |
25,271 | public < T > RPromise < T > deferredPromise ( ) { return new RPromise < T > ( ) { public void succeed ( final T value ) { invokeLater ( new Runnable ( ) { public void run ( ) { superSucceed ( value ) ; } } ) ; } public void fail ( final Throwable cause ) { invokeLater ( new Runnable ( ) { public void run ( ) { superFail ( cause ) ; } } ) ; } private void superSucceed ( T value ) { super . succeed ( value ) ; } private void superFail ( Throwable cause ) { super . fail ( cause ) ; } } ; } | Creates a promise which defers notification of success or failure to the game thread regardless of what thread on which it is completed . Note that even if it is completed on the game thread it will still defer completion until the next frame . |
25,272 | public void addTris ( Texture tex , int tint , AffineTransform xf , float [ ] xys , int xysOffset , int xysLen , float tw , float th , int [ ] indices , int indicesOffset , int indicesLen , int indexBase ) { setTexture ( tex ) ; prepare ( tint , xf ) ; addTris ( xys , xysOffset , xysLen , tw , th , indices , indicesOffset , indicesLen , indexBase ) ; } | Adds a collection of textured triangles to the current render operation . |
25,273 | public float adjustWidth ( float width ) { switch ( font . style ) { case ITALIC : return width + emwidth / 8 ; case BOLD_ITALIC : return width + emwidth / 6 ; default : return width ; } } | Adjusts a measured width to account for italic and bold italic text . We have to handle this hackily because there s no way to measure exact text extent in HTML5 . |
25,274 | private File getWarDirectory ( TreeLogger logger ) throws UnableToCompleteException { File currentDirectory = new File ( "." ) ; try { String canonicalPath = currentDirectory . getCanonicalPath ( ) ; logger . log ( TreeLogger . INFO , "Current directory in which this generator is executing: " + canonicalPath ) ; if ( canonicalPath . endsWith ( "war" ) ) { return currentDirectory ; } else { return new File ( "war" ) ; } } catch ( IOException e ) { logger . log ( TreeLogger . ERROR , "Failed to get canonical path" , e ) ; throw new UnableToCompleteException ( ) ; } } | When invoking the GWT compiler from GPE the working directory is the Eclipse project directory . However when launching a GPE project the working directory is the project war directory . This methods returns the war directory in either case in a fairly naive and non - robust manner . |
25,275 | protected void paintScene ( ) { viewSurf . saveTx ( ) ; viewSurf . begin ( ) ; viewSurf . clear ( cred , cgreen , cblue , calpha ) ; try { rootLayer . paint ( viewSurf ) ; } finally { viewSurf . end ( ) ; viewSurf . restoreTx ( ) ; } } | Renders the main scene graph into the OpenGL frame buffer . |
25,276 | protected Resource requireResource ( String path ) throws IOException { URL url = getClass ( ) . getClassLoader ( ) . getResource ( pathPrefix + path ) ; if ( url != null ) { return url . getProtocol ( ) . equals ( "file" ) ? new FileResource ( new File ( URLDecoder . decode ( url . getPath ( ) , "UTF-8" ) ) ) : new URLResource ( url ) ; } for ( File dir : directories ) { File f = new File ( dir , path ) . getCanonicalFile ( ) ; if ( f . exists ( ) ) { return new FileResource ( f ) ; } } throw new FileNotFoundException ( path ) ; } | Attempts to locate the resource at the given path and returns a wrapper which allows its data to be efficiently read . |
25,277 | protected void prepareDraw ( ) { VertexAttribArrayState previousNio = null ; int previousElementSize = 0 ; if ( useNioBuffer == 0 && enabledArrays == previouslyEnabledArrays ) { return ; } for ( int i = 0 ; i < VERTEX_ATTRIB_ARRAY_COUNT ; i ++ ) { int mask = 1 << i ; int enabled = enabledArrays & mask ; if ( enabled != ( previouslyEnabledArrays & mask ) ) { if ( enabled != 0 ) { gl . enableVertexAttribArray ( i ) ; } else { gl . disableVertexAttribArray ( i ) ; } } if ( enabled != 0 && ( useNioBuffer & mask ) != 0 ) { VertexAttribArrayState data = vertexAttribArrayState [ i ] ; if ( previousNio != null && previousNio . nioBuffer == data . nioBuffer && previousNio . nioBufferLimit >= data . nioBufferLimit ) { if ( boundArrayBuffer != previousNio . webGlBuffer ) { gl . bindBuffer ( ARRAY_BUFFER , previousNio . webGlBuffer ) ; boundArrayBuffer = data . webGlBuffer ; } gl . vertexAttribPointer ( i , data . size , data . type , data . normalize , data . stride , data . nioBufferPosition * previousElementSize ) ; } else { if ( boundArrayBuffer != data . webGlBuffer ) { gl . bindBuffer ( ARRAY_BUFFER , data . webGlBuffer ) ; boundArrayBuffer = data . webGlBuffer ; } int elementSize = getElementSize ( data . nioBuffer ) ; int savePosition = data . nioBuffer . position ( ) ; if ( data . nioBufferPosition * elementSize < data . stride ) { data . nioBuffer . position ( 0 ) ; gl . bufferData ( ARRAY_BUFFER , getTypedArray ( data . nioBuffer , data . type , data . nioBufferLimit * elementSize ) , STREAM_DRAW ) ; gl . vertexAttribPointer ( i , data . size , data . type , data . normalize , data . stride , data . nioBufferPosition * elementSize ) ; previousNio = data ; previousElementSize = elementSize ; } else { data . nioBuffer . position ( data . nioBufferPosition ) ; gl . bufferData ( ARRAY_BUFFER , getTypedArray ( data . nioBuffer , data . type , ( data . nioBufferLimit - data . nioBufferPosition ) * elementSize ) , STREAM_DRAW ) ; gl . vertexAttribPointer ( i , data . size , data . type , data . normalize , data . stride , 0 ) ; } data . nioBuffer . position ( savePosition ) ; } } } previouslyEnabledArrays = enabledArrays ; } | The content of non - VBO buffers may be changed between the glVertexAttribPointer call and the glDrawXxx call . Thus we need to defer copying them to a VBO buffer until just before the actual glDrawXxx call . |
25,278 | private void setFillColor ( Color3f color ) { if ( cacheFillR == color . x && cacheFillG == color . y && cacheFillB == color . z ) { } else { cacheFillR = color . x ; cacheFillG = color . y ; cacheFillB = color . z ; setFillColorFromCache ( ) ; } } | Sets the fill color from a Color3f |
25,279 | private void setStrokeColor ( Color3f color ) { if ( cacheStrokeR == color . x && cacheStrokeG == color . y && cacheStrokeB == color . z ) { } else { cacheStrokeR = color . x ; cacheStrokeG = color . y ; cacheStrokeB = color . z ; setStrokeColorFromCache ( ) ; } } | Sets the stroke color from a Color3f |
25,280 | public void start ( ) { if ( config . activationKey != null ) { input ( ) . keyboardEvents . connect ( new Slot < Keyboard . Event > ( ) { public void onEmit ( Keyboard . Event event ) { if ( event instanceof Keyboard . KeyEvent ) { Keyboard . KeyEvent kevent = ( Keyboard . KeyEvent ) event ; if ( kevent . key == config . activationKey && kevent . down ) { toggleActivation ( ) ; } } } } ) ; } synchronized ( this ) { mainThread = Thread . currentThread ( ) ; } loop ( ) ; dispatchEvent ( lifecycle , Lifecycle . EXIT ) ; try { pool . shutdown ( ) ; pool . awaitTermination ( 1 , TimeUnit . SECONDS ) ; } catch ( InterruptedException ie ) { } System . exit ( 0 ) ; } | Starts the game loop . This method will not return until the game exits . |
25,281 | public static IntBuffer allocate ( int capacity ) { if ( capacity < 0 ) { throw new IllegalArgumentException ( ) ; } ByteBuffer bb = ByteBuffer . allocateDirect ( capacity * 4 ) ; bb . order ( ByteOrder . nativeOrder ( ) ) ; return bb . asIntBuffer ( ) ; } | Creates an int buffer based on a newly allocated int array . |
25,282 | public int compareTo ( IntBuffer otherBuffer ) { int compareRemaining = ( remaining ( ) < otherBuffer . remaining ( ) ) ? remaining ( ) : otherBuffer . remaining ( ) ; int thisPos = position ; int otherPos = otherBuffer . position ; int thisInt , otherInt ; while ( compareRemaining > 0 ) { thisInt = get ( thisPos ) ; otherInt = otherBuffer . get ( otherPos ) ; if ( thisInt != otherInt ) { return thisInt < otherInt ? - 1 : 1 ; } thisPos ++ ; otherPos ++ ; compareRemaining -- ; } return remaining ( ) - otherBuffer . remaining ( ) ; } | Compares the remaining ints of this buffer to another int buffer s remaining ints . |
25,283 | public TextFormat withFont ( String name , Font . Style style , float size ) { return withFont ( new Font ( name , style , size ) ) ; } | Returns a clone of this text format with the font configured as specified . |
25,284 | public Image getImageSync ( String path ) { ImageImpl image = createImage ( false , 0 , 0 , path ) ; try { image . succeed ( load ( path ) ) ; } catch ( Throwable t ) { image . fail ( t ) ; } return image ; } | Synchronously loads and returns an image . The calling thread will block while the image is loaded from disk and decoded . When this call returns the image s width and height will be valid and the image can be immediately converted to a texture and drawn into a canvas . |
25,285 | public RFuture < String > getText ( final String path ) { final RPromise < String > result = exec . deferredPromise ( ) ; exec . invokeAsync ( new Runnable ( ) { public void run ( ) { try { result . succeed ( getTextSync ( path ) ) ; } catch ( Throwable t ) { result . fail ( t ) ; } } } ) ; return result ; } | Loads UTF - 8 encoded text asynchronously . The returned state instance provides a means to listen for the arrival of the text . |
25,286 | public RFuture < ByteBuffer > getBytes ( final String path ) { final RPromise < ByteBuffer > result = exec . deferredPromise ( ) ; exec . invokeAsync ( new Runnable ( ) { public void run ( ) { try { result . succeed ( getBytesSync ( path ) ) ; } catch ( Throwable t ) { result . fail ( t ) ; } } } ) ; return result ; } | Loads binary data asynchronously . The returned state instance provides a means to listen for the arrival of the data . |
25,287 | static float getRelativeX ( NativeEvent e , Element target ) { return ( e . getClientX ( ) - target . getAbsoluteLeft ( ) + target . getScrollLeft ( ) + target . getOwnerDocument ( ) . getScrollLeft ( ) ) / HtmlGraphics . experimentalScale ; } | Gets the event s x - position relative to a given element . |
25,288 | static float getRelativeY ( NativeEvent e , Element target ) { return ( e . getClientY ( ) - target . getAbsoluteTop ( ) + target . getScrollTop ( ) + target . getOwnerDocument ( ) . getScrollTop ( ) ) / HtmlGraphics . experimentalScale ; } | Gets the event s y - position relative to a given element . |
25,289 | public synchronized void succeed ( Data data ) { scale = data . scale ; pixelWidth = data . pixelWidth ; assert pixelWidth > 0 ; pixelHeight = data . pixelHeight ; assert pixelHeight > 0 ; setBitmap ( data . bitmap ) ; ( ( RPromise < Image > ) state ) . succeed ( this ) ; } | Notifies this image that its implementation bitmap is available . This can be called from any thread . |
25,290 | public synchronized void fail ( Throwable error ) { if ( pixelWidth == 0 ) pixelWidth = 50 ; if ( pixelHeight == 0 ) pixelHeight = 50 ; setBitmap ( createErrorBitmap ( pixelWidth , pixelHeight ) ) ; ( ( RPromise < Image > ) state ) . fail ( error ) ; } | Notifies this image that its implementation bitmap failed to load . This can be called from any thread . |
25,291 | protected boolean accept ( String path ) { if ( path . equals ( "hosted.html" ) || path . endsWith ( ".devmode.js" ) ) { return false ; } if ( path . equals ( "/" ) ) { return true ; } int pos = path . lastIndexOf ( '.' ) ; if ( pos != - 1 ) { String extension = path . substring ( pos + 1 ) ; if ( DEFAULT_EXTENSION_WHITELIST . contains ( extension ) ) { return true ; } } return false ; } | Determines whether our not the given should be included in the app cache manifest . Subclasses may override this method in order to filter out specific file patterns . |
25,292 | public Texture createTexture ( float width , float height , Texture . Config config ) { int texWidth = config . toTexWidth ( scale . scaledCeil ( width ) ) ; int texHeight = config . toTexHeight ( scale . scaledCeil ( height ) ) ; if ( texWidth <= 0 || texHeight <= 0 ) throw new IllegalArgumentException ( "Invalid texture size: " + texWidth + "x" + texHeight ) ; int id = createTexture ( config ) ; gl . glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , texWidth , texHeight , 0 , GL_RGBA , GL_UNSIGNED_BYTE , null ) ; return new Texture ( this , id , config , texWidth , texHeight , scale , width , height ) ; } | Creates an empty texture into which one can render . The supplied width and height are in display units and will be converted to pixels based on the current scale factor . |
25,293 | protected void viewportChanged ( int pixelWidth , int pixelHeight ) { viewPixelWidth = pixelWidth ; viewPixelHeight = pixelHeight ; viewSizeM . width = scale . invScaled ( pixelWidth ) ; viewSizeM . height = scale . invScaled ( pixelHeight ) ; plat . log ( ) . info ( "viewPortChanged " + pixelWidth + "x" + pixelHeight + " / " + scale . factor + " -> " + viewSize ) ; } | Informs the graphics system that the main framebuffer size has changed . The supplied size should be in physical pixels . |
25,294 | public static ShortBuffer allocate ( int capacity ) { if ( capacity < 0 ) { throw new IllegalArgumentException ( ) ; } ByteBuffer bb = ByteBuffer . allocateDirect ( capacity * 2 ) ; bb . order ( ByteOrder . nativeOrder ( ) ) ; return bb . asShortBuffer ( ) ; } | Creates a short buffer based on a newly allocated short array . |
25,295 | @ SuppressWarnings ( "unchecked" ) < T > T parse ( Class < T > clazz ) throws JsonParserException { advanceToken ( ) ; Object parsed = currentValue ( ) ; if ( advanceToken ( ) != Token . EOF ) throw createParseException ( null , "Expected end of input, got " + token , true ) ; if ( clazz != Object . class && ( parsed == null || clazz != parsed . getClass ( ) ) ) throw createParseException ( null , "JSON did not contain the correct type, expected " + clazz . getName ( ) + "." , true ) ; return ( T ) ( parsed ) ; } | Parse a single JSON value from the string expecting an EOF at the end . |
25,296 | private Object currentValue ( ) throws JsonParserException { if ( token . isValue ) return value ; throw createParseException ( null , "Expected JSON value, got " + token , true ) ; } | Starts parsing a JSON value at the current token position . |
25,297 | private void consumeKeyword ( char first , char [ ] expected ) throws JsonParserException { for ( int i = 0 ; i < expected . length ; i ++ ) if ( advanceChar ( ) != expected [ i ] ) throw createHelpfulException ( first , expected , i ) ; if ( isAsciiLetter ( peekChar ( ) ) ) throw createHelpfulException ( first , expected , expected . length ) ; } | Expects a given string at the current position . |
25,298 | private char stringChar ( ) throws JsonParserException { int c = advanceChar ( ) ; if ( c == - 1 ) throw createParseException ( null , "String was not terminated before end of input" , true ) ; if ( c < 32 ) throw createParseException ( null , "Strings may not contain control characters: 0x" + Integer . toString ( c , 16 ) , false ) ; return ( char ) c ; } | Advances a character throwing if it is illegal in the context of a JSON string . |
25,299 | private int stringHexChar ( ) throws JsonParserException { int c = "0123456789abcdef0123456789ABCDEF" . indexOf ( advanceChar ( ) ) % 16 ; if ( c == - 1 ) throw createParseException ( null , "Expected unicode hex escape character" , false ) ; return c ; } | Advances a character throwing if it is illegal in the context of a JSON string hex unicode escape . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.