idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
38,300
private void linkToEmitter ( String name , LinearInterpolator interpol ) { valueMap . put ( name , interpol ) ; boolean checked = interpol . isActive ( ) ; JCheckBox enableControl = ( JCheckBox ) valueNameToControl . get ( name ) ; enableControl . setSelected ( false ) ; if ( checked ) enableControl . setSelected ( checked ) ; }
Link this set of controls to a linear interpolater within the particle emitter
38,301
private void blur ( BufferedImage image ) { float [ ] matrix = GAUSSIAN_BLUR_KERNELS [ blurKernelSize - 1 ] ; Kernel gaussianBlur1 = new Kernel ( matrix . length , 1 , matrix ) ; Kernel gaussianBlur2 = new Kernel ( 1 , matrix . length , matrix ) ; RenderingHints hints = new RenderingHints ( RenderingHints . KEY_RENDERING , RenderingHints . VALUE_RENDER_SPEED ) ; ConvolveOp gaussianOp1 = new ConvolveOp ( gaussianBlur1 , ConvolveOp . EDGE_NO_OP , hints ) ; ConvolveOp gaussianOp2 = new ConvolveOp ( gaussianBlur2 , ConvolveOp . EDGE_NO_OP , hints ) ; BufferedImage scratchImage = EffectUtil . getScratchImage ( ) ; for ( int i = 0 ; i < blurPasses ; i ++ ) { gaussianOp1 . filter ( image , scratchImage ) ; gaussianOp2 . filter ( scratchImage , image ) ; } }
Apply blurring to the generate image
38,302
public Texture getTexture ( File source , boolean flipped , int filter ) throws IOException { String resourceName = source . getAbsolutePath ( ) ; InputStream in = new FileInputStream ( source ) ; return getTexture ( in , resourceName , flipped , filter , null ) ; }
Get a texture from a specific file
38,303
public Texture getTexture ( String resourceName , boolean flipped , int filter ) throws IOException { InputStream in = ResourceLoader . getResourceAsStream ( resourceName ) ; return getTexture ( in , resourceName , flipped , filter , null ) ; }
Get a texture from a resource location
38,304
public void reload ( ) { Iterator texs = texturesLinear . values ( ) . iterator ( ) ; while ( texs . hasNext ( ) ) { ( ( TextureImpl ) texs . next ( ) ) . reload ( ) ; } texs = texturesNearest . values ( ) . iterator ( ) ; while ( texs . hasNext ( ) ) { ( ( TextureImpl ) texs . next ( ) ) . reload ( ) ; } }
Reload all the textures loaded in this loader
38,305
public int reload ( TextureImpl texture , int srcPixelFormat , int componentCount , int minFilter , int magFilter , ByteBuffer textureBuffer ) { int target = SGL . GL_TEXTURE_2D ; int textureID = createTextureID ( ) ; GL . glBindTexture ( target , textureID ) ; GL . glTexParameteri ( target , SGL . GL_TEXTURE_MIN_FILTER , minFilter ) ; GL . glTexParameteri ( target , SGL . GL_TEXTURE_MAG_FILTER , magFilter ) ; GL . glTexImage2D ( target , 0 , dstPixelFormat , texture . getTextureWidth ( ) , texture . getTextureHeight ( ) , 0 , srcPixelFormat , SGL . GL_UNSIGNED_BYTE , textureBuffer ) ; return textureID ; }
Reload a given texture blob
38,306
public Image getSprite ( String name ) { Section section = ( Section ) sections . get ( name ) ; if ( section == null ) { throw new RuntimeException ( "Unknown sprite from packed sheet: " + name ) ; } return image . getSubImage ( section . x , section . y , section . width , section . height ) ; }
Get a single named sprite from the sheet
38,307
public SpriteSheet getSpriteSheet ( String name ) { Image image = getSprite ( name ) ; Section section = ( Section ) sections . get ( name ) ; return new SpriteSheet ( image , section . width / section . tilesx , section . height / section . tilesy ) ; }
Get a sprite sheet that has been packed into the greater image
38,308
private void loadDefinition ( String def , Color trans ) throws SlickException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( ResourceLoader . getResourceAsStream ( def ) ) ) ; try { image = new Image ( basePath + reader . readLine ( ) , false , filter , trans ) ; while ( reader . ready ( ) ) { if ( reader . readLine ( ) == null ) { break ; } Section sect = new Section ( reader ) ; sections . put ( sect . name , sect ) ; if ( reader . readLine ( ) == null ) { break ; } } } catch ( Exception e ) { Log . error ( e ) ; throw new SlickException ( "Failed to process definitions file - invalid format?" , e ) ; } }
Load the definition file and parse each of the sections
38,309
public void reset ( ) { while ( holes != null ) { holes = freePointBag ( holes ) ; } contour . clear ( ) ; holes = null ; }
Reset the internal state of the triangulator
38,310
private void addPoint ( Vector2f pt ) { if ( holes == null ) { Point p = getPoint ( pt ) ; contour . add ( p ) ; } else { Point p = getPoint ( pt ) ; holes . add ( p ) ; } }
Add a defined point to the current contour
38,311
private PointBag freePointBag ( PointBag pb ) { PointBag next = pb . next ; pb . clear ( ) ; pb . next = nextFreePointBag ; nextFreePointBag = pb ; return next ; }
Release a pooled bag
38,312
private Point getPoint ( Vector2f pt ) { Point p = nextFreePoint ; if ( p != null ) { nextFreePoint = p . next ; p . next = null ; p . prev = null ; p . pt = pt ; return p ; } return new Point ( pt ) ; }
Create or reuse a point
38,313
private void freePoints ( Point head ) { head . prev . next = nextFreePoint ; head . prev = null ; nextFreePoint = head ; }
Release all points
38,314
private void initStreams ( ) throws IOException { if ( audio != null ) { audio . close ( ) ; } OggInputStream audio ; if ( url != null ) { audio = new OggInputStream ( url . openStream ( ) ) ; } else { audio = new OggInputStream ( ResourceLoader . getResourceAsStream ( ref ) ) ; } this . audio = audio ; positionOffset = 0 ; }
Initialise our connection to the underlying resource
38,315
public void play ( boolean loop ) throws IOException { this . loop = loop ; initStreams ( ) ; done = false ; AL10 . alSourceStop ( source ) ; removeBuffers ( ) ; startPlayback ( ) ; }
Start this stream playing
38,316
public boolean stream ( int bufferId ) { try { int count = audio . read ( buffer ) ; if ( count != - 1 ) { bufferData . clear ( ) ; bufferData . put ( buffer , 0 , count ) ; bufferData . flip ( ) ; int format = audio . getChannels ( ) > 1 ? AL10 . AL_FORMAT_STEREO16 : AL10 . AL_FORMAT_MONO16 ; try { AL10 . alBufferData ( bufferId , format , bufferData , audio . getRate ( ) ) ; } catch ( OpenALException e ) { Log . error ( "Failed to loop buffer: " + bufferId + " " + format + " " + count + " " + audio . getRate ( ) , e ) ; return false ; } } else { if ( loop ) { initStreams ( ) ; stream ( bufferId ) ; } else { done = true ; return false ; } } return true ; } catch ( IOException e ) { Log . error ( e ) ; return false ; } }
Stream some data from the audio stream to the buffer indicates by the ID
38,317
public boolean setPosition ( float position ) { try { if ( getPosition ( ) > position ) { initStreams ( ) ; } float sampleRate = audio . getRate ( ) ; float sampleSize ; if ( audio . getChannels ( ) > 1 ) { sampleSize = 4 ; } else { sampleSize = 2 ; } while ( positionOffset < position ) { int count = audio . read ( buffer ) ; if ( count != - 1 ) { float bufferLength = ( count / sampleSize ) / sampleRate ; positionOffset += bufferLength ; } else { if ( loop ) { initStreams ( ) ; } else { done = true ; } return false ; } } startPlayback ( ) ; return true ; } catch ( IOException e ) { Log . error ( e ) ; return false ; } }
Seeks to a position in the music .
38,318
private void startPlayback ( ) { AL10 . alSourcei ( source , AL10 . AL_LOOPING , AL10 . AL_FALSE ) ; AL10 . alSourcef ( source , AL10 . AL_PITCH , pitch ) ; remainingBufferCount = BUFFER_COUNT ; for ( int i = 0 ; i < BUFFER_COUNT ; i ++ ) { stream ( bufferNames . get ( i ) ) ; } AL10 . alSourceQueueBuffers ( source , bufferNames ) ; AL10 . alSourcePlay ( source ) ; }
Starts the streaming .
38,319
public void reset ( ) { Iterator pools = particlesByEmitter . values ( ) . iterator ( ) ; while ( pools . hasNext ( ) ) { ParticlePool pool = ( ParticlePool ) pools . next ( ) ; pool . reset ( this ) ; } for ( int i = 0 ; i < emitters . size ( ) ; i ++ ) { ParticleEmitter emitter = ( ParticleEmitter ) emitters . get ( i ) ; emitter . resetState ( ) ; } }
Reset the state of the system
38,320
public void addEmitter ( ParticleEmitter emitter ) { emitters . add ( emitter ) ; ParticlePool pool = new ParticlePool ( this , maxParticlesPerEmitter ) ; particlesByEmitter . put ( emitter , pool ) ; }
Add a particle emitter to be used on this system
38,321
public void removeAllEmitters ( ) { for ( int i = 0 ; i < emitters . size ( ) ; i ++ ) { removeEmitter ( ( ParticleEmitter ) emitters . get ( i ) ) ; i -- ; } }
Remove all the emitters from the system
38,322
public void render ( float x , float y ) { if ( ( sprite == null ) && ( defaultImageName != null ) ) { loadSystemParticleImage ( ) ; } if ( ! visible ) { return ; } GL . glTranslatef ( x , y , 0 ) ; if ( blendingMode == BLEND_ADDITIVE ) { GL . glBlendFunc ( SGL . GL_SRC_ALPHA , SGL . GL_ONE ) ; } if ( usePoints ( ) ) { GL . glEnable ( SGL . GL_POINT_SMOOTH ) ; TextureImpl . bindNone ( ) ; } for ( int emitterIdx = 0 ; emitterIdx < emitters . size ( ) ; emitterIdx ++ ) { ParticleEmitter emitter = ( ParticleEmitter ) emitters . get ( emitterIdx ) ; if ( ! emitter . isEnabled ( ) ) { continue ; } if ( emitter . useAdditive ( ) ) { GL . glBlendFunc ( SGL . GL_SRC_ALPHA , SGL . GL_ONE ) ; } ParticlePool pool = ( ParticlePool ) particlesByEmitter . get ( emitter ) ; Image image = emitter . getImage ( ) ; if ( image == null ) { image = this . sprite ; } if ( ! emitter . isOriented ( ) && ! emitter . usePoints ( this ) ) { image . startUse ( ) ; } for ( int i = 0 ; i < pool . particles . length ; i ++ ) { if ( pool . particles [ i ] . inUse ( ) ) pool . particles [ i ] . render ( ) ; } if ( ! emitter . isOriented ( ) && ! emitter . usePoints ( this ) ) { image . endUse ( ) ; } if ( emitter . useAdditive ( ) ) { GL . glBlendFunc ( SGL . GL_SRC_ALPHA , SGL . GL_ONE_MINUS_SRC_ALPHA ) ; } } if ( usePoints ( ) ) { GL . glDisable ( SGL . GL_POINT_SMOOTH ) ; } if ( blendingMode == BLEND_ADDITIVE ) { GL . glBlendFunc ( SGL . GL_SRC_ALPHA , SGL . GL_ONE_MINUS_SRC_ALPHA ) ; } Color . white . bind ( ) ; GL . glTranslatef ( - x , - y , 0 ) ; }
Render the particles in the system
38,323
private void loadSystemParticleImage ( ) { AccessController . doPrivileged ( new PrivilegedAction ( ) { public Object run ( ) { try { if ( mask != null ) { sprite = new Image ( defaultImageName , mask ) ; } else { sprite = new Image ( defaultImageName ) ; } } catch ( SlickException e ) { Log . error ( e ) ; defaultImageName = null ; } return null ; } } ) ; }
Load the system particle image as the extension permissions
38,324
public void update ( int delta ) { if ( ( sprite == null ) && ( defaultImageName != null ) ) { loadSystemParticleImage ( ) ; } removeMe . clear ( ) ; ArrayList emitters = new ArrayList ( this . emitters ) ; for ( int i = 0 ; i < emitters . size ( ) ; i ++ ) { ParticleEmitter emitter = ( ParticleEmitter ) emitters . get ( i ) ; if ( emitter . isEnabled ( ) ) { emitter . update ( this , delta ) ; if ( removeCompletedEmitters ) { if ( emitter . completed ( ) ) { removeMe . add ( emitter ) ; particlesByEmitter . remove ( emitter ) ; } } } } this . emitters . removeAll ( removeMe ) ; pCount = 0 ; if ( ! particlesByEmitter . isEmpty ( ) ) { Iterator it = particlesByEmitter . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { ParticleEmitter emitter = ( ParticleEmitter ) it . next ( ) ; if ( emitter . isEnabled ( ) ) { ParticlePool pool = ( ParticlePool ) particlesByEmitter . get ( emitter ) ; for ( int i = 0 ; i < pool . particles . length ; i ++ ) { if ( pool . particles [ i ] . life > 0 ) { pool . particles [ i ] . update ( delta ) ; pCount ++ ; } } } } } }
Update the system request the assigned emitters update the particles
38,325
public Particle getNewParticle ( ParticleEmitter emitter , float life ) { ParticlePool pool = ( ParticlePool ) particlesByEmitter . get ( emitter ) ; ArrayList available = pool . available ; if ( available . size ( ) > 0 ) { Particle p = ( Particle ) available . remove ( available . size ( ) - 1 ) ; p . init ( emitter , life ) ; p . setImage ( sprite ) ; return p ; } Log . warn ( "Ran out of particles (increase the limit)!" ) ; return dummy ; }
Get a new particle from the system . This should be used by emitters to request particles
38,326
public void release ( Particle particle ) { if ( particle != dummy ) { ParticlePool pool = ( ParticlePool ) particlesByEmitter . get ( particle . getEmitter ( ) ) ; pool . available . add ( particle ) ; } }
Release a particle back to the system once it has expired
38,327
public void releaseAll ( ParticleEmitter emitter ) { if ( ! particlesByEmitter . isEmpty ( ) ) { Iterator it = particlesByEmitter . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { ParticlePool pool = ( ParticlePool ) it . next ( ) ; for ( int i = 0 ; i < pool . particles . length ; i ++ ) { if ( pool . particles [ i ] . inUse ( ) ) { if ( pool . particles [ i ] . getEmitter ( ) == emitter ) { pool . particles [ i ] . setLife ( - 1 ) ; release ( pool . particles [ i ] ) ; } } } } } }
Release all the particles owned by the specified emitter
38,328
public void moveAll ( ParticleEmitter emitter , float x , float y ) { ParticlePool pool = ( ParticlePool ) particlesByEmitter . get ( emitter ) ; for ( int i = 0 ; i < pool . particles . length ; i ++ ) { if ( pool . particles [ i ] . inUse ( ) ) { pool . particles [ i ] . move ( x , y ) ; } } }
Move all the particles owned by the specified emitter
38,329
public ParticleSystem duplicate ( ) throws SlickException { for ( int i = 0 ; i < emitters . size ( ) ; i ++ ) { if ( ! ( emitters . get ( i ) instanceof ConfigurableEmitter ) ) { throw new SlickException ( "Only systems contianing configurable emitters can be duplicated" ) ; } } ParticleSystem theCopy = null ; try { ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; ParticleIO . saveConfiguredSystem ( bout , this ) ; ByteArrayInputStream bin = new ByteArrayInputStream ( bout . toByteArray ( ) ) ; theCopy = ParticleIO . loadConfiguredSystem ( bin ) ; } catch ( IOException e ) { Log . error ( "Failed to duplicate particle system" ) ; throw new SlickException ( "Unable to duplicated particle system" , e ) ; } return theCopy ; }
Create a duplicate of this system . This would have been nicer as a different interface but may cause to much API change headache . Maybe next full version release it should be rethought .
38,330
public static void setRenderer ( int type ) { switch ( type ) { case IMMEDIATE_RENDERER : setRenderer ( new ImmediateModeOGLRenderer ( ) ) ; return ; case VERTEX_ARRAY_RENDERER : setRenderer ( new VAOGLRenderer ( ) ) ; return ; } throw new RuntimeException ( "Unknown renderer type: " + type ) ; }
Set the renderer to one of the known types
38,331
public static void setLineStripRenderer ( int type ) { switch ( type ) { case DEFAULT_LINE_STRIP_RENDERER : setLineStripRenderer ( new DefaultLineStripRenderer ( ) ) ; return ; case QUAD_BASED_LINE_STRIP_RENDERER : setLineStripRenderer ( new QuadBasedLineStripRenderer ( ) ) ; return ; } throw new RuntimeException ( "Unknown line strip renderer type: " + type ) ; }
Set the line strip renderer to one of the known types
38,332
public void transform ( float source [ ] , int sourceOffset , float destination [ ] , int destOffset , int numberOfPoints ) { float result [ ] = source == destination ? new float [ numberOfPoints * 2 ] : destination ; for ( int i = 0 ; i < numberOfPoints * 2 ; i += 2 ) { for ( int j = 0 ; j < 6 ; j += 3 ) { result [ i + ( j / 3 ) ] = source [ i + sourceOffset ] * matrixPosition [ j ] + source [ i + sourceOffset + 1 ] * matrixPosition [ j + 1 ] + 1 * matrixPosition [ j + 2 ] ; } } if ( source == destination ) { for ( int i = 0 ; i < numberOfPoints * 2 ; i += 2 ) { destination [ i + destOffset ] = result [ i ] ; destination [ i + destOffset + 1 ] = result [ i + 1 ] ; } } }
Transform the point pairs in the source array and store them in the destination array . All operations will be done before storing the results in the destination . This way the source and destination array can be the same without worry of overwriting information before it is transformed .
38,333
public Transform concatenate ( Transform tx ) { float [ ] mp = new float [ 9 ] ; float n00 = matrixPosition [ 0 ] * tx . matrixPosition [ 0 ] + matrixPosition [ 1 ] * tx . matrixPosition [ 3 ] ; float n01 = matrixPosition [ 0 ] * tx . matrixPosition [ 1 ] + matrixPosition [ 1 ] * tx . matrixPosition [ 4 ] ; float n02 = matrixPosition [ 0 ] * tx . matrixPosition [ 2 ] + matrixPosition [ 1 ] * tx . matrixPosition [ 5 ] + matrixPosition [ 2 ] ; float n10 = matrixPosition [ 3 ] * tx . matrixPosition [ 0 ] + matrixPosition [ 4 ] * tx . matrixPosition [ 3 ] ; float n11 = matrixPosition [ 3 ] * tx . matrixPosition [ 1 ] + matrixPosition [ 4 ] * tx . matrixPosition [ 4 ] ; float n12 = matrixPosition [ 3 ] * tx . matrixPosition [ 2 ] + matrixPosition [ 4 ] * tx . matrixPosition [ 5 ] + matrixPosition [ 5 ] ; mp [ 0 ] = n00 ; mp [ 1 ] = n01 ; mp [ 2 ] = n02 ; mp [ 3 ] = n10 ; mp [ 4 ] = n11 ; mp [ 5 ] = n12 ; matrixPosition = mp ; return this ; }
Update this Transform by concatenating the given Transform to this one .
38,334
public static Transform createRotateTransform ( float angle ) { return new Transform ( ( float ) FastTrig . cos ( angle ) , - ( float ) FastTrig . sin ( angle ) , 0 , ( float ) FastTrig . sin ( angle ) , ( float ) FastTrig . cos ( angle ) , 0 ) ; }
Create a new rotation Transform
38,335
public static Transform createRotateTransform ( float angle , float x , float y ) { Transform temp = Transform . createRotateTransform ( angle ) ; float sinAngle = temp . matrixPosition [ 3 ] ; float oneMinusCosAngle = 1.0f - temp . matrixPosition [ 4 ] ; temp . matrixPosition [ 2 ] = x * oneMinusCosAngle + y * sinAngle ; temp . matrixPosition [ 5 ] = y * oneMinusCosAngle - x * sinAngle ; return temp ; }
Create a new rotation Transform around the specified point
38,336
public Vector2f transform ( Vector2f pt ) { float [ ] in = new float [ ] { pt . x , pt . y } ; float [ ] out = new float [ 2 ] ; transform ( in , 0 , out , 0 , 1 ) ; return new Vector2f ( out [ 0 ] , out [ 1 ] ) ; }
Transform the vector2f based on the matrix defined in this transform
38,337
public List getUniqueCommands ( ) { List uniqueCommands = new ArrayList ( ) ; for ( Iterator it = commands . values ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Command command = ( Command ) it . next ( ) ; if ( ! uniqueCommands . contains ( command ) ) { uniqueCommands . add ( command ) ; } } return uniqueCommands ; }
Get the list of commands that have been registered with the provider i . e . the commands that can be issued to the listeners
38,338
public void bindCommand ( Control control , Command command ) { commands . put ( control , command ) ; if ( commandState . get ( command ) == null ) { commandState . put ( command , new CommandState ( ) ) ; } }
Bind an command to a control .
38,339
public void clearCommand ( Command command ) { List controls = getControlsFor ( command ) ; for ( int i = 0 ; i < controls . size ( ) ; i ++ ) { unbindCommand ( ( Control ) controls . get ( i ) ) ; } }
Clear all the controls that have been configured for a given command
38,340
public void unbindCommand ( Control control ) { Command command = ( Command ) commands . remove ( control ) ; if ( command != null ) { if ( ! commands . keySet ( ) . contains ( command ) ) { commandState . remove ( command ) ; } } }
Unbinds the command associated with this control
38,341
protected void firePressed ( Command command ) { getState ( command ) . down = true ; getState ( command ) . pressed = true ; if ( ! isActive ( ) ) { return ; } for ( int i = 0 ; i < listeners . size ( ) ; i ++ ) { ( ( InputProviderListener ) listeners . get ( i ) ) . controlPressed ( command ) ; } }
Fire notification to any interested listeners that a control has been pressed indication an particular command
38,342
protected void fireReleased ( Command command ) { getState ( command ) . down = false ; if ( ! isActive ( ) ) { return ; } for ( int i = 0 ; i < listeners . size ( ) ; i ++ ) { ( ( InputProviderListener ) listeners . get ( i ) ) . controlReleased ( command ) ; } }
Fire notification to any interested listeners that a control has been released indication an particular command should be stopped
38,343
public void addStep ( Diagram diagram ) { if ( diagram . getFigureCount ( ) != figures . size ( ) ) { throw new RuntimeException ( "Mismatched diagrams, missing ids" ) ; } for ( int i = 0 ; i < diagram . getFigureCount ( ) ; i ++ ) { Figure figure = diagram . getFigure ( i ) ; String id = figure . getData ( ) . getMetaData ( ) ; for ( int j = 0 ; j < figures . size ( ) ; j ++ ) { Figure existing = ( Figure ) figures . get ( j ) ; if ( existing . getData ( ) . getMetaData ( ) . equals ( id ) ) { MorphShape morph = ( MorphShape ) existing . getShape ( ) ; morph . addShape ( figure . getShape ( ) ) ; break ; } } } }
Add a subsquent step to the morphing
38,344
public void updateMorphTime ( float delta ) { for ( int i = 0 ; i < figures . size ( ) ; i ++ ) { Figure figure = ( Figure ) figures . get ( i ) ; MorphShape shape = ( MorphShape ) figure . getShape ( ) ; shape . updateMorphTime ( delta ) ; } }
Update the morph time index by the amount specified
38,345
public void setMorphTime ( float time ) { for ( int i = 0 ; i < figures . size ( ) ; i ++ ) { Figure figure = ( Figure ) figures . get ( i ) ; MorphShape shape = ( MorphShape ) figure . getShape ( ) ; shape . setMorphTime ( time ) ; } }
Set the time index for this morph . This is given in terms of diagrams so 0 . 5f would give you the position half way between the first and second diagrams .
38,346
private void build ( ) { if ( list == - 1 ) { list = GL . glGenLists ( 1 ) ; SlickCallable . enterSafeBlock ( ) ; GL . glNewList ( list , SGL . GL_COMPILE ) ; runnable . run ( ) ; GL . glEndList ( ) ; SlickCallable . leaveSafeBlock ( ) ; } else { throw new RuntimeException ( "Attempt to build the display list more than once in CachedRender" ) ; } }
Build the display list
38,347
public void render ( ) { if ( list == - 1 ) { throw new RuntimeException ( "Attempt to render cached operations that have been destroyed" ) ; } SlickCallable . enterSafeBlock ( ) ; GL . glCallList ( list ) ; SlickCallable . leaveSafeBlock ( ) ; }
Render the cached operations . Note that this doesn t call the operations but rather calls the cached version
38,348
public static ImageWriter getWriterForFormat ( String format ) throws SlickException { ImageWriter writer = ( ImageWriter ) writers . get ( format ) ; if ( writer != null ) { return writer ; } writer = ( ImageWriter ) writers . get ( format . toLowerCase ( ) ) ; if ( writer != null ) { return writer ; } writer = ( ImageWriter ) writers . get ( format . toUpperCase ( ) ) ; if ( writer != null ) { return writer ; } throw new SlickException ( "No image writer available for: " + format ) ; }
Get a Slick image writer for the given format
38,349
public double getNumber ( String nameOfField , double defaultValue ) { Double value = ( ( Double ) numericData . get ( nameOfField ) ) ; if ( value == null ) { return defaultValue ; } return value . doubleValue ( ) ; }
Get number stored at given location
38,350
public String getString ( String nameOfField , String defaultValue ) { String value = ( String ) stringData . get ( nameOfField ) ; if ( value == null ) { return defaultValue ; } return value ; }
Get the String at the given location
38,351
private boolean isWebstartAvailable ( ) { try { Class . forName ( "javax.jnlp.ServiceManager" ) ; ServiceManager . lookup ( "javax.jnlp.PersistenceService" ) ; Log . info ( "Webstart detected using Muffins" ) ; } catch ( Exception e ) { Log . info ( "Using Local File System" ) ; return false ; } return true ; }
Quick test to see if running through Java webstart
38,352
public void init ( ) { try { AL . create ( ) ; soundWorks = true ; } catch ( LWJGLException e ) { System . err . println ( "Failed to initialise LWJGL OpenAL" ) ; soundWorks = false ; return ; } if ( soundWorks ) { IntBuffer sources = BufferUtils . createIntBuffer ( 1 ) ; AL10 . alGenSources ( sources ) ; if ( AL10 . alGetError ( ) != AL10 . AL_NO_ERROR ) { System . err . println ( "Failed to create sources" ) ; soundWorks = false ; } else { source = sources . get ( 0 ) ; } } }
Initialise OpenAL LWJGL styley
38,353
public void setup ( float pitch , float gain ) { AL10 . alSourcef ( source , AL10 . AL_PITCH , pitch ) ; AL10 . alSourcef ( source , AL10 . AL_GAIN , gain ) ; }
Setup the playback properties
38,354
public static Module loadModule ( InputStream in ) throws IOException { Module module ; DataInputStream din ; byte [ ] xm_header , s3m_header , mod_header , output_buffer ; int frames ; din = new DataInputStream ( in ) ; module = null ; xm_header = new byte [ 60 ] ; din . readFully ( xm_header ) ; if ( FastTracker2 . is_xm ( xm_header ) ) { module = FastTracker2 . load_xm ( xm_header , din ) ; } else { s3m_header = new byte [ 96 ] ; System . arraycopy ( xm_header , 0 , s3m_header , 0 , 60 ) ; din . readFully ( s3m_header , 60 , 36 ) ; if ( ScreamTracker3 . is_s3m ( s3m_header ) ) { module = ScreamTracker3 . load_s3m ( s3m_header , din ) ; } else { mod_header = new byte [ 1084 ] ; System . arraycopy ( s3m_header , 0 , mod_header , 0 , 96 ) ; din . readFully ( mod_header , 96 , 988 ) ; module = ProTracker . load_mod ( mod_header , din ) ; } } din . close ( ) ; return module ; }
Load a module using the IBXM
38,355
public void setImage ( BufferedImage image ) { this . image = image ; setPreferredSize ( new Dimension ( image . getWidth ( ) , image . getHeight ( ) ) ) ; setSize ( new Dimension ( image . getWidth ( ) , image . getHeight ( ) ) ) ; getParent ( ) . repaint ( 0 ) ; }
Set the image to be displayed
38,356
public static File [ ] listFiles ( final String ext ) { init ( ) ; return config . listFiles ( new FilenameFilter ( ) { public boolean accept ( File dir , String name ) { return name . endsWith ( ext ) ; } } ) ; }
List the files with a given extension in the configuration directory
38,357
public void setEnabledForced ( boolean e ) { enabled . setEnabled ( e ) ; minSpinner . setEnabled ( e ) ; maxSpinner . setEnabled ( e ) ; }
Force the state of this component
38,358
public void setMin ( int value ) { updateDisable = true ; minSpinner . setValue ( new Integer ( value ) ) ; updateDisable = false ; }
Set the minimum value
38,359
public void setMax ( int value ) { updateDisable = true ; maxSpinner . setValue ( new Integer ( value ) ) ; updateDisable = false ; }
Set the maximum value
38,360
void fireUpdated ( Object source ) { if ( updateDisable ) { return ; } if ( source == maxSpinner ) { if ( getMax ( ) < getMin ( ) ) { setMin ( getMax ( ) ) ; } } if ( source == minSpinner ) { if ( getMax ( ) < getMin ( ) ) { setMax ( getMin ( ) ) ; } } for ( int i = 0 ; i < listeners . size ( ) ; i ++ ) { ( ( InputPanelListener ) listeners . get ( i ) ) . minMaxUpdated ( this ) ; } }
Notify listeners a change has occured on this panel
38,361
public void setEnabledValue ( boolean e ) { if ( enablement ) { enabled . setSelected ( e ) ; } minSpinner . setEnabled ( enabled . isSelected ( ) || ! enablement ) ; maxSpinner . setEnabled ( enabled . isSelected ( ) || ! enablement ) ; }
Indicate if this panel should be enabled
38,362
public void setTileSetImage ( Image image ) { tiles = new SpriteSheet ( image , tileWidth , tileHeight , tileSpacing , tileMargin ) ; tilesAcross = tiles . getHorizontalCount ( ) ; tilesDown = tiles . getVerticalCount ( ) ; if ( tilesAcross <= 0 ) { tilesAcross = 1 ; } if ( tilesDown <= 0 ) { tilesDown = 1 ; } lastGID = ( tilesAcross * tilesDown ) + firstGID - 1 ; }
Set the image to use for this sprite sheet image to use for this tileset
38,363
private void remeasure ( ) { forceLayout ( ) ; measure ( MeasureSpec . makeMeasureSpec ( getMeasuredWidth ( ) , MeasureSpec . EXACTLY ) , MeasureSpec . makeMeasureSpec ( getMeasuredHeight ( ) , MeasureSpec . EXACTLY ) ) ; requestLayout ( ) ; }
Convenience for calling own measure method .
38,364
public void setSplitterPosition ( int position ) { mSplitterPosition = clamp ( position , 0 , Integer . MAX_VALUE ) ; mSplitterPositionPercent = - 1 ; remeasure ( ) ; notifySplitterPositionChanged ( false ) ; }
Sets the current position of the splitter in pixels .
38,365
public void setSplitterPositionPercent ( float position ) { mSplitterPosition = Integer . MIN_VALUE ; mSplitterPositionPercent = clamp ( position , 0 , 1 ) ; remeasure ( ) ; notifySplitterPositionChanged ( false ) ; }
Sets the current position of the splitter as a percentage of the layout .
38,366
public void setPaneSizeMin ( int paneSizeMin ) { mPaneSizeMin = paneSizeMin ; if ( isMeasured ) { int newSplitterPosition = clamp ( mSplitterPosition , getMinSplitterPosition ( ) , getMaxSplitterPosition ( ) ) ; if ( newSplitterPosition != mSplitterPosition ) { setSplitterPosition ( newSplitterPosition ) ; } } }
Sets the minimum size of panes in pixels .
38,367
public boolean differs ( ClassInfo oldInfo , ClassInfo newInfo ) { if ( Tools . isClassAccessChange ( oldInfo . getAccess ( ) , newInfo . getAccess ( ) ) ) return true ; if ( oldInfo . getSupername ( ) == null ) { if ( newInfo . getSupername ( ) != null ) { return true ; } } else if ( ! oldInfo . getSupername ( ) . equals ( newInfo . getSupername ( ) ) ) { return true ; } final Set < String > oldInterfaces = new HashSet ( Arrays . asList ( oldInfo . getInterfaces ( ) ) ) ; final Set < String > newInterfaces = new HashSet ( Arrays . asList ( newInfo . getInterfaces ( ) ) ) ; if ( ! oldInterfaces . equals ( newInterfaces ) ) return true ; return false ; }
Check if there is a change between two versions of a class . Returns true if the access flags differ or if the superclass differs or if the implemented interfaces differ .
38,368
public boolean differs ( MethodInfo oldInfo , MethodInfo newInfo ) { if ( Tools . isMethodAccessChange ( oldInfo . getAccess ( ) , newInfo . getAccess ( ) ) ) return true ; if ( oldInfo . getExceptions ( ) == null || newInfo . getExceptions ( ) == null ) { if ( oldInfo . getExceptions ( ) != newInfo . getExceptions ( ) ) return true ; } else { final Set < String > oldExceptions = new HashSet ( Arrays . asList ( oldInfo . getExceptions ( ) ) ) ; final Set < String > newExceptions = new HashSet ( Arrays . asList ( newInfo . getExceptions ( ) ) ) ; if ( ! oldExceptions . equals ( newExceptions ) ) return true ; } return false ; }
Check if there is a change between two versions of a method . Returns true if the access flags differ or if the thrown exceptions differ .
38,369
public boolean differs ( FieldInfo oldInfo , FieldInfo newInfo ) { if ( Tools . isFieldAccessChange ( oldInfo . getAccess ( ) , newInfo . getAccess ( ) ) ) return true ; if ( oldInfo . getValue ( ) == null || newInfo . getValue ( ) == null ) { if ( oldInfo . getValue ( ) != newInfo . getValue ( ) ) return true ; } else if ( ! oldInfo . getValue ( ) . equals ( newInfo . getValue ( ) ) ) return true ; return false ; }
Check if there is a change between two versions of a field . Returns true if the access flags differ or if the inital value of the field differs .
38,370
public ClassInfo getClassInfo ( ) { return new ClassInfo ( version , access , name , signature , supername , interfaces , methodMap , fieldMap ) ; }
The the classInfo this ClassInfoVisitor has built up about a class
38,371
public void visit ( int version , int access , String name , String signature , String supername , String [ ] interfaces ) { this . version = version ; this . access = access ; this . name = name ; this . signature = signature ; this . supername = supername ; this . interfaces = interfaces ; }
Receive notification of information about a class from ASM .
38,372
public synchronized ClassInfo loadClassInfo ( ClassReader reader ) throws IOException { infoVisitor . reset ( ) ; reader . accept ( infoVisitor , 0 ) ; return infoVisitor . getClassInfo ( ) ; }
Load classinfo given a ClassReader .
38,373
public void diff ( DiffHandler handler , DiffCriteria criteria ) throws DiffException { diff ( handler , criteria , oldVersion , newVersion , oldClassInfo , newClassInfo ) ; }
Perform a diff sending the output to the specified handler using the specified criteria to select diffs .
38,374
private static ClassInfo cloneDeprecated ( ClassInfo classInfo ) { return new ClassInfo ( classInfo . getVersion ( ) , classInfo . getAccess ( ) | Opcodes . ACC_DEPRECATED , classInfo . getName ( ) , classInfo . getSignature ( ) , classInfo . getSupername ( ) , classInfo . getInterfaces ( ) , classInfo . getMethodMap ( ) , classInfo . getFieldMap ( ) ) ; }
Clones the class info but changes access setting deprecated flag .
38,375
private static MethodInfo cloneDeprecated ( MethodInfo methodInfo ) { return new MethodInfo ( methodInfo . getAccess ( ) | Opcodes . ACC_DEPRECATED , methodInfo . getName ( ) , methodInfo . getDesc ( ) , methodInfo . getSignature ( ) , methodInfo . getExceptions ( ) ) ; }
Clones the method but changes access setting deprecated flag .
38,376
private static FieldInfo cloneDeprecated ( FieldInfo fieldInfo ) { return new FieldInfo ( fieldInfo . getAccess ( ) | Opcodes . ACC_DEPRECATED , fieldInfo . getName ( ) , fieldInfo . getDesc ( ) , fieldInfo . getSignature ( ) , fieldInfo . getValue ( ) ) ; }
Clones the field info but changes access setting deprecated flag .
38,377
public void startDiff ( String oldJar , String newJar ) throws DiffException { Element tmp = doc . createElementNS ( XML_URI , "diff" ) ; tmp . setAttribute ( "old" , oldJar ) ; tmp . setAttribute ( "new" , newJar ) ; doc . appendChild ( tmp ) ; currentNode = tmp ; }
Start the diff . This writes out the start of a &lt ; diff&gt ; node .
38,378
public void contains ( ClassInfo info ) throws DiffException { Element tmp = doc . createElementNS ( XML_URI , "class" ) ; tmp . setAttribute ( "name" , info . getName ( ) ) ; currentNode . appendChild ( tmp ) ; }
Add a contained class .
38,379
public void startAdded ( ) throws DiffException { Element tmp = doc . createElementNS ( XML_URI , "added" ) ; currentNode . appendChild ( tmp ) ; currentNode = tmp ; }
Start the added section . This opens the &lt ; added&gt ; tag .
38,380
public void startClassChanged ( String internalName ) throws DiffException { Element tmp = doc . createElementNS ( XML_URI , "classchanged" ) ; tmp . setAttribute ( "name" , internalName ) ; currentNode . appendChild ( tmp ) ; currentNode = tmp ; }
Start a changed section for an individual class . This writes out an &lt ; classchanged&gt ; node with the real class name as the name attribute .
38,381
public void classChanged ( ClassInfo oldInfo , ClassInfo newInfo ) throws DiffException { Node currentNode = this . currentNode ; Element tmp = doc . createElementNS ( XML_URI , "classchange" ) ; Element from = doc . createElementNS ( XML_URI , "from" ) ; Element to = doc . createElementNS ( XML_URI , "to" ) ; tmp . appendChild ( from ) ; tmp . appendChild ( to ) ; currentNode . appendChild ( tmp ) ; this . currentNode = from ; writeClassInfo ( oldInfo ) ; this . currentNode = to ; writeClassInfo ( newInfo ) ; this . currentNode = currentNode ; }
Write out info aboout a changed class . This writes out a &lt ; classchange&gt ; node followed by a &lt ; from&gt ; node with the old information about the class followed by a &lt ; to&gt ; node with the new information about the class .
38,382
public void fieldChanged ( FieldInfo oldInfo , FieldInfo newInfo ) throws DiffException { Node currentNode = this . currentNode ; Element tmp = doc . createElementNS ( XML_URI , "fieldchange" ) ; Element from = doc . createElementNS ( XML_URI , "from" ) ; Element to = doc . createElementNS ( XML_URI , "to" ) ; tmp . appendChild ( from ) ; tmp . appendChild ( to ) ; currentNode . appendChild ( tmp ) ; this . currentNode = from ; writeFieldInfo ( oldInfo ) ; this . currentNode = to ; writeFieldInfo ( newInfo ) ; this . currentNode = currentNode ; }
Write out info aboout a changed field . This writes out a &lt ; fieldchange&gt ; node followed by a &lt ; from&gt ; node with the old information about the field followed by a &lt ; to&gt ; node with the new information about the field .
38,383
public void methodChanged ( MethodInfo oldInfo , MethodInfo newInfo ) throws DiffException { Node currentNode = this . currentNode ; Element tmp = doc . createElementNS ( XML_URI , "methodchange" ) ; Element from = doc . createElementNS ( XML_URI , "from" ) ; Element to = doc . createElementNS ( XML_URI , "to" ) ; tmp . appendChild ( from ) ; tmp . appendChild ( to ) ; currentNode . appendChild ( tmp ) ; this . currentNode = from ; writeMethodInfo ( oldInfo ) ; this . currentNode = to ; writeMethodInfo ( newInfo ) ; this . currentNode = currentNode ; }
Write out info aboout a changed method . This writes out a &lt ; methodchange&gt ; node followed by a &lt ; from&gt ; node with the old information about the method followed by a &lt ; to&gt ; node with the new information about the method .
38,384
public void endDiff ( ) throws DiffException { DOMSource source = new DOMSource ( doc ) ; try { transformer . transform ( source , result ) ; } catch ( TransformerException te ) { throw new DiffException ( te ) ; } }
End the diff . This closes the &lt ; diff&gt ; node .
38,385
protected void writeClassInfo ( ClassInfo info ) { Node currentNode = this . currentNode ; Element tmp = doc . createElementNS ( XML_URI , "class" ) ; currentNode . appendChild ( tmp ) ; this . currentNode = tmp ; addAccessFlags ( info ) ; if ( info . getName ( ) != null ) tmp . setAttribute ( "name" , info . getName ( ) ) ; if ( info . getSignature ( ) != null ) tmp . setAttribute ( "signature" , info . getSignature ( ) ) ; if ( info . getSupername ( ) != null ) tmp . setAttribute ( "superclass" , info . getSupername ( ) ) ; String [ ] interfaces = info . getInterfaces ( ) ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { Element iface = doc . createElementNS ( XML_URI , "implements" ) ; tmp . appendChild ( iface ) ; iface . setAttribute ( "name" , interfaces [ i ] ) ; } this . currentNode = currentNode ; }
Write out information about a class . This writes out a &lt ; class&gt ; node which contains information about what interfaces are implemented each in a &lt ; implements&gt ; node .
38,386
protected void writeMethodInfo ( MethodInfo info ) { Node currentNode = this . currentNode ; Element tmp = doc . createElementNS ( XML_URI , "method" ) ; currentNode . appendChild ( tmp ) ; this . currentNode = tmp ; addAccessFlags ( info ) ; if ( info . getName ( ) != null ) tmp . setAttribute ( "name" , info . getName ( ) ) ; if ( info . getSignature ( ) != null ) tmp . setAttribute ( "signature" , info . getSignature ( ) ) ; if ( info . getDesc ( ) != null ) addMethodNodes ( info . getDesc ( ) ) ; String [ ] exceptions = info . getExceptions ( ) ; if ( exceptions != null ) { for ( int i = 0 ; i < exceptions . length ; i ++ ) { Element excep = doc . createElementNS ( XML_URI , "exception" ) ; excep . setAttribute ( "name" , exceptions [ i ] ) ; tmp . appendChild ( excep ) ; } } this . currentNode = currentNode ; }
Write out information about a method . This writes out a &lt ; method&gt ; node which contains information about the arguments the return type and the exceptions thrown by the method .
38,387
protected void writeFieldInfo ( FieldInfo info ) { Node currentNode = this . currentNode ; Element tmp = doc . createElementNS ( XML_URI , "field" ) ; currentNode . appendChild ( tmp ) ; this . currentNode = tmp ; addAccessFlags ( info ) ; if ( info . getName ( ) != null ) tmp . setAttribute ( "name" , info . getName ( ) ) ; if ( info . getSignature ( ) != null ) tmp . setAttribute ( "signature" , info . getSignature ( ) ) ; if ( info . getValue ( ) != null ) tmp . setAttribute ( "value" , info . getValue ( ) . toString ( ) ) ; if ( info . getDesc ( ) != null ) addTypeNode ( info . getDesc ( ) ) ; this . currentNode = currentNode ; }
Write out information about a field . This writes out a &lt ; field&gt ; node with attributes describing the field .
38,388
protected void addAccessFlags ( AbstractInfo info ) { Element currentNode = ( Element ) this . currentNode ; currentNode . setAttribute ( "access" , info . getAccessType ( ) ) ; if ( info . isAbstract ( ) ) currentNode . setAttribute ( "abstract" , "yes" ) ; if ( info . isAnnotation ( ) ) currentNode . setAttribute ( "annotation" , "yes" ) ; if ( info . isBridge ( ) ) currentNode . setAttribute ( "bridge" , "yes" ) ; if ( info . isDeprecated ( ) ) currentNode . setAttribute ( "deprecated" , "yes" ) ; if ( info . isEnum ( ) ) currentNode . setAttribute ( "enum" , "yes" ) ; if ( info . isFinal ( ) ) currentNode . setAttribute ( "final" , "yes" ) ; if ( info . isInterface ( ) ) currentNode . setAttribute ( "interface" , "yes" ) ; if ( info . isNative ( ) ) currentNode . setAttribute ( "native" , "yes" ) ; if ( info . isStatic ( ) ) currentNode . setAttribute ( "static" , "yes" ) ; if ( info . isStrict ( ) ) currentNode . setAttribute ( "strict" , "yes" ) ; if ( info . isSuper ( ) ) currentNode . setAttribute ( "super" , "yes" ) ; if ( info . isSynchronized ( ) ) currentNode . setAttribute ( "synchronized" , "yes" ) ; if ( info . isSynthetic ( ) ) currentNode . setAttribute ( "synthetic" , "yes" ) ; if ( info . isTransient ( ) ) currentNode . setAttribute ( "transient" , "yes" ) ; if ( info . isVarargs ( ) ) currentNode . setAttribute ( "varargs" , "yes" ) ; if ( info . isVolatile ( ) ) currentNode . setAttribute ( "volatile" , "yes" ) ; }
Add attributes describing some access flags . This adds the attributes to the attr field .
38,389
public static String encrypt ( final String aText , final String aSalt ) throws NullPointerException , IOException { Objects . requireNonNull ( aText , LOGGER . getI18n ( "Text to encrypt is null" ) ) ; Objects . requireNonNull ( aSalt , LOGGER . getI18n ( "Salt to encrypt with is null" ) ) ; try { final MessageDigest digest = MessageDigest . getInstance ( "SHA" ) ; final String saltedText = aText + aSalt ; digest . update ( saltedText . getBytes ( "UTF-8" ) ) ; return Base64 . encodeBytes ( digest . digest ( ) ) ; } catch ( final NoSuchAlgorithmException details ) { throw new I18nRuntimeException ( details ) ; } catch ( final UnsupportedEncodingException details ) { throw new I18nRuntimeException ( details ) ; } }
Encrypts the supplied text using the supplied salt .
38,390
private MDCCloseable setLineNumber ( ) { final int lineNum = Thread . currentThread ( ) . getStackTrace ( ) [ 3 ] . getLineNumber ( ) ; return MDC . putCloseable ( LINE_NUM , Integer . toString ( lineNum ) ) ; }
Sets the line number .
38,391
private static Writer getWriter ( final File aFile ) throws FileNotFoundException { try { return new OutputStreamWriter ( new FileOutputStream ( aFile ) , StandardCharsets . UTF_8 . name ( ) ) ; } catch ( final java . io . UnsupportedEncodingException details ) { throw new UnsupportedEncodingException ( details , StandardCharsets . UTF_8 . name ( ) ) ; } }
Gets a writer that can write to the supplied file using the UTF - 8 charset .
38,392
public Stopwatch stop ( ) { if ( ! myTimerIsRunning ) { throw new IllegalStateException ( LOGGER . getI18n ( MessageCodes . UTIL_041 ) ) ; } myStop = System . currentTimeMillis ( ) ; myTimerIsRunning = false ; return this ; }
Stop the stopwatch .
38,393
public String getSeconds ( ) { if ( myTimerIsRunning ) { throw new IllegalStateException ( LOGGER . getI18n ( MessageCodes . UTIL_042 ) ) ; } final StringBuilder result = new StringBuilder ( ) ; final long timeGap = myStop - myStart ; return result . append ( timeGap / 1000 ) . append ( " secs, " ) . append ( timeGap % 1000 ) . append ( " msecs " ) . toString ( ) ; }
Express the reading on the stopwatch in seconds .
38,394
public String getMilliseconds ( ) { if ( myTimerIsRunning ) { throw new IllegalStateException ( LOGGER . getI18n ( MessageCodes . UTIL_042 ) ) ; } return new StringBuilder ( ) . append ( myStop - myStart ) . append ( " msecs" ) . toString ( ) ; }
Express the reading on the stopwatch in milliseconds .
38,395
public static void load ( final String aNativeLibrary ) throws IOException { final String libFileName = getPlatformLibraryName ( aNativeLibrary ) ; final File tmpDir = new File ( System . getProperty ( "java.io.tmpdir" ) ) ; final File libFile = new File ( tmpDir , libFileName ) ; if ( ! libFile . exists ( ) || libFile . length ( ) == 0 ) { final URL url = ClasspathUtils . findFirst ( libFileName ) ; if ( url == null ) { throw new FileNotFoundException ( LOGGER . getMessage ( MessageCodes . UTIL_002 , aNativeLibrary ) ) ; } final JarFile jarFile = new JarFile ( url . getFile ( ) ) ; final JarEntry jarEntry = jarFile . getJarEntry ( libFileName ) ; final InputStream inStream = jarFile . getInputStream ( jarEntry ) ; final BufferedOutputStream outStream = new BufferedOutputStream ( new FileOutputStream ( libFile ) ) ; IOUtils . copyStream ( inStream , outStream ) ; IOUtils . closeQuietly ( inStream ) ; IOUtils . closeQuietly ( outStream ) ; IOUtils . closeQuietly ( jarFile ) ; } if ( libFile . exists ( ) && libFile . length ( ) > 0 ) { System . load ( libFile . getAbsolutePath ( ) ) ; } else { throw new IOException ( LOGGER . getI18n ( MessageCodes . UTIL_039 , libFile ) ) ; } }
Loads a native library from the classpath .
38,396
public static Architecture getArchitecture ( ) { if ( Architecture . UNKNOWN == myArchitecture ) { final Processor processor = getProcessor ( ) ; if ( Processor . UNKNOWN != processor ) { final String name = System . getProperty ( OS_NAME ) . toLowerCase ( Locale . US ) ; if ( name . indexOf ( "nix" ) >= 0 || name . indexOf ( "nux" ) >= 0 ) { if ( Processor . INTEL_32 == processor ) { myArchitecture = Architecture . LINUX_32 ; } else if ( Processor . INTEL_64 == processor ) { myArchitecture = Architecture . LINUX_64 ; } else if ( Processor . ARM == processor ) { myArchitecture = Architecture . LINUX_ARM ; } } else if ( name . indexOf ( "win" ) >= 0 ) { if ( Processor . INTEL_32 == processor ) { myArchitecture = Architecture . WINDOWS_32 ; } else if ( Processor . INTEL_64 == processor ) { myArchitecture = Architecture . WINDOWS_64 ; } } else if ( name . indexOf ( "mac" ) >= 0 ) { if ( Processor . INTEL_32 == processor ) { myArchitecture = Architecture . OSX_32 ; } else if ( Processor . INTEL_64 == processor ) { myArchitecture = Architecture . OSX_64 ; } else if ( Processor . PPC == processor ) { myArchitecture = Architecture . OSX_PPC ; } } } } LOGGER . debug ( MessageCodes . UTIL_023 , myArchitecture , System . getProperty ( OS_NAME ) . toLowerCase ( Locale . US ) ) ; return myArchitecture ; }
Gets the architecture of the machine running the JVM .
38,397
public static String getPlatformLibraryName ( final String aLibraryName ) { String libName = null ; switch ( getArchitecture ( ) ) { case LINUX_32 : case LINUX_64 : case LINUX_ARM : libName = LIB_PREFIX + aLibraryName + ".so" ; break ; case WINDOWS_32 : case WINDOWS_64 : libName = aLibraryName + ".dll" ; break ; case OSX_32 : case OSX_64 : libName = LIB_PREFIX + aLibraryName + ".dylib" ; break ; default : LOGGER . warn ( "Unexpected architecture value: {}" , getArchitecture ( ) ) ; break ; } LOGGER . debug ( MessageCodes . UTIL_025 , libName ) ; return libName ; }
Gets the library name for the current platform .
38,398
public static String trimTo ( final String aString , final String aDefault ) { if ( aString == null ) { return aDefault ; } final String trimmed = aString . trim ( ) ; return trimmed . length ( ) == 0 ? aDefault : trimmed ; }
Trims a string ; if there is nothing left after the trimming returns whatever the default value passed in is .
38,399
public static String padStart ( final String aString , final String aPadding , final int aRepeatCount ) { if ( aRepeatCount != 0 ) { final StringBuilder buffer = new StringBuilder ( ) ; for ( int index = 0 ; index < aRepeatCount ; index ++ ) { buffer . append ( aPadding ) ; } return buffer . append ( aString ) . toString ( ) ; } return aString ; }
Pads the beginning of a supplied string with the repetition of a supplied value .