idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
15,000
protected String getTargetPath ( File fromDir , String path ) { return path . substring ( 0 , path . length ( ) - 4 ) + ".jar" ; }
Returns the target path in which our bundler will write the tile set .
15,001
public void updateBounds ( ) { invalidate ( ) ; Dimension size = _label . getSize ( ) ; _bounds . width = size . width + PADDING * 2 + ( _style == ROUNDED ? _arcWidth : 0 ) ; _bounds . height = size . height + PADDING * 2 ; invalidate ( ) ; }
Updates this sprite s bounds after a change to the label .
15,002
public static int getClosest ( int direction , int [ ] possible , boolean preferCW ) { int first = direction ; int second = direction ; for ( int ii = 0 ; ii <= FINE_DIRECTION_COUNT / 2 ; ii ++ ) { if ( IntListUtil . contains ( possible , first ) ) { return first ; } if ( ii != 0 && IntListUtil . contains ( possible , second ) ) { return second ; } first = preferCW ? rotateCW ( first , 1 ) : rotateCCW ( first , 1 ) ; second = preferCW ? rotateCCW ( second , 1 ) : rotateCW ( second , 1 ) ; } return NONE ; }
Get the direction closest to the specified direction out of the directions in the possible list .
15,003
public static void moveDirection ( Point p , int direction , int dx , int dy ) { if ( direction >= DIRECTION_COUNT ) { throw new IllegalArgumentException ( "Fine coordinates not supported." ) ; } switch ( direction ) { case NORTH : case NORTHWEST : case NORTHEAST : p . y -= dy ; } switch ( direction ) { case SOUTH : case SOUTHWEST : case SOUTHEAST : p . y += dy ; } switch ( direction ) { case WEST : case SOUTHWEST : case NORTHWEST : p . x -= dx ; } switch ( direction ) { case EAST : case SOUTHEAST : case NORTHEAST : p . x += dx ; } }
Move the specified point in the specified screen direction adjusting by the specified adjustments . Fine directions are not supported .
15,004
protected Component getRoot ( Component comp ) { for ( Component c = comp ; c != null ; c = c . getParent ( ) ) { boolean hidden = ! c . isDisplayable ( ) ; if ( ! RunAnywhere . isMacOS ( ) ) { hidden |= ! c . isVisible ( ) ; } if ( hidden ) { return null ; } if ( c instanceof Window || c instanceof Applet ) { return c ; } } return null ; }
Returns the root component for the supplied component or null if it is not part of a rooted hierarchy or if any parent along the way is found to be hidden or without a peer .
15,005
public void validateComponents ( ) { Object [ ] invalid = null ; synchronized ( this ) { invalid = _invalid ; _invalid = null ; } if ( invalid == null ) { return ; } int icount = invalid . length ; for ( int ii = 0 ; ii < icount ; ii ++ ) { if ( invalid [ ii ] != null ) { if ( DEBUG ) { log . info ( "Validating " + invalid [ ii ] ) ; } ( ( Component ) invalid [ ii ] ) . validate ( ) ; } } }
Validates the invalid components that have been queued up since the last frame tick .
15,006
protected static void dumpHierarchy ( Component comp ) { for ( String indent = "" ; comp != null ; indent += " " ) { log . info ( indent + toString ( comp ) ) ; comp = comp . getParent ( ) ; } }
Dumps the containment hierarchy for the supplied component .
15,007
public void addNode ( int x , int y , int dir ) { _nodes . add ( new PathNode ( x , y , dir ) ) ; }
Add a node to the path with the specified destination point and facing direction .
15,008
public void setDuration ( long millis ) { int ncount = _nodes . size ( ) ; if ( ncount < 2 ) { log . warning ( "Requested to set duration of bogus path" , "path" , this , "duration" , millis ) ; return ; } float distance = 0 ; PathNode start = _nodes . get ( 0 ) ; for ( int ii = 1 ; ii < ncount ; ii ++ ) { PathNode end = _nodes . get ( ii ) ; distance += MathUtil . distance ( start . loc . x , start . loc . y , end . loc . x , end . loc . y ) ; start = end ; } setVelocity ( distance / millis ) ; }
Computes the velocity at which the pathable will need to travel along this path such that it will arrive at the destination in approximately the specified number of milliseconds . Efforts are taken to get the pathable there as close to the desired time as possible but framerate variation may prevent it from arriving exactly on time .
15,009
protected boolean headToNextNode ( Pathable pable , long startstamp , long now ) { if ( _niter == null ) { throw new IllegalStateException ( "headToNextNode() called before init()" ) ; } if ( ! _niter . hasNext ( ) ) { pable . setLocation ( _dest . loc . x , _dest . loc . y ) ; pable . pathCompleted ( now ) ; return true ; } _src = _dest ; _dest = getNextNode ( ) ; if ( _dest . dir != NONE ) { pable . setOrientation ( _dest . dir ) ; } _nodestamp = startstamp ; _seglength = MathUtil . distance ( _src . loc . x , _src . loc . y , _dest . loc . x , _dest . loc . y ) ; if ( _seglength == 0 ) { return headToNextNode ( pable , startstamp , now ) ; } return tick ( pable , now ) ; }
Place the pathable moving along the path at the end of the previous path node face it appropriately for the next node and start it on its way . Returns whether the pathable position moved .
15,010
protected void createPath ( List < Point > points ) { Point last = null ; int size = points . size ( ) ; for ( int ii = 0 ; ii < size ; ii ++ ) { Point p = points . get ( ii ) ; int dir = ( ii == 0 ) ? NORTH : DirectionUtil . getDirection ( last , p ) ; addNode ( p . x , p . y , dir ) ; last = p ; } }
Populate the path with the path nodes that lead the pathable from its starting position to the given destination coordinates following the given list of screen coordinates .
15,011
public static void browseURL ( URL url , ResultListener < Void > listener , String genagent ) { String [ ] cmd ; if ( RunAnywhere . isWindows ( ) ) { String osName = System . getProperty ( "os.name" ) ; if ( osName . indexOf ( "9" ) != - 1 || osName . indexOf ( "Me" ) != - 1 ) { cmd = new String [ ] { "command.com" , "/c" , "start" , "\"" + url . toString ( ) + "\"" } ; } else { cmd = new String [ ] { "cmd.exe" , "/c" , "start" , "\"\"" , "\"" + url . toString ( ) + "\"" } ; } } else if ( RunAnywhere . isMacOS ( ) ) { cmd = new String [ ] { "open" , url . toString ( ) } ; } else { cmd = new String [ ] { genagent , url . toString ( ) } ; } String logcmd = StringUtil . join ( cmd , " " ) ; logcmd = logcmd . replaceAll ( "password=[^&]*" , "password=XXX" ) ; log . info ( "Browsing URL [cmd=" + logcmd + "]." ) ; try { Process process = Runtime . getRuntime ( ) . exec ( cmd ) ; BrowserTracker tracker = new BrowserTracker ( process , url , listener ) ; tracker . start ( ) ; } catch ( Exception e ) { log . warning ( "Failed to launch browser [url=" + url + ", error=" + e + "]." ) ; listener . requestFailed ( e ) ; } }
Opens the user s web browser with the specified URL .
15,012
public void setPosition ( float x , float y , float z ) { if ( _px != x || _py != y || _pz != z ) { AL10 . alSource3f ( _id , AL10 . AL_POSITION , _px = x , _py = y , _pz = z ) ; } }
Sets the position of the source .
15,013
public void setVelocity ( float x , float y , float z ) { if ( _vx != x || _vy != y || _vz != z ) { AL10 . alSource3f ( _id , AL10 . AL_VELOCITY , _vx = x , _vy = y , _vz = z ) ; } }
Sets the velocity of the source .
15,014
public void setGain ( float gain ) { if ( _gain != gain ) { AL10 . alSourcef ( _id , AL10 . AL_GAIN , _gain = gain ) ; } }
Sets the gain of the source .
15,015
public void setSourceRelative ( boolean relative ) { if ( _sourceRelative != relative ) { _sourceRelative = relative ; AL10 . alSourcei ( _id , AL10 . AL_SOURCE_RELATIVE , relative ? AL10 . AL_TRUE : AL10 . AL_FALSE ) ; } }
Sets whether or not the position velocity etc . of the source are relative to the listener .
15,016
public void setLooping ( boolean looping ) { if ( _looping != looping ) { _looping = looping ; AL10 . alSourcei ( _id , AL10 . AL_LOOPING , looping ? AL10 . AL_TRUE : AL10 . AL_FALSE ) ; } }
Sets whether or not the source is looping .
15,017
public void setMinGain ( float gain ) { if ( _minGain != gain ) { AL10 . alSourcef ( _id , AL10 . AL_MIN_GAIN , _minGain = gain ) ; } }
Sets the minimum gain .
15,018
public void setMaxGain ( float gain ) { if ( _maxGain != gain ) { AL10 . alSourcef ( _id , AL10 . AL_MAX_GAIN , _maxGain = gain ) ; } }
Sets the maximum gain .
15,019
public void setReferenceDistance ( float distance ) { if ( _referenceDistance != distance ) { AL10 . alSourcef ( _id , AL10 . AL_REFERENCE_DISTANCE , _referenceDistance = distance ) ; } }
Sets the reference distance for attenuation .
15,020
public void setRolloffFactor ( float rolloff ) { if ( _rolloffFactor != rolloff ) { AL10 . alSourcef ( _id , AL10 . AL_ROLLOFF_FACTOR , _rolloffFactor = rolloff ) ; } }
Sets the rolloff factor for attenuation .
15,021
public void setMaxDistance ( float distance ) { if ( _maxDistance != distance ) { AL10 . alSourcef ( _id , AL10 . AL_MAX_DISTANCE , _maxDistance = distance ) ; } }
Sets the maximum distance for attenuation .
15,022
public void setPitch ( float pitch ) { if ( _pitch != pitch ) { AL10 . alSourcef ( _id , AL10 . AL_PITCH , _pitch = pitch ) ; } }
Sets the pitch multiplier .
15,023
public void setDirection ( float x , float y , float z ) { if ( _dx != x || _dy != y || _dz != z ) { AL10 . alSource3f ( _id , AL10 . AL_DIRECTION , _dx = x , _dy = y , _dz = z ) ; } }
Sets the direction of the source .
15,024
public void setConeInnerAngle ( float angle ) { if ( _coneInnerAngle != angle ) { AL10 . alSourcef ( _id , AL10 . AL_CONE_INNER_ANGLE , _coneInnerAngle = angle ) ; } }
Sets the inside angle of the sound cone .
15,025
public void setConeOuterAngle ( float angle ) { if ( _coneOuterAngle != angle ) { AL10 . alSourcef ( _id , AL10 . AL_CONE_OUTER_ANGLE , _coneOuterAngle = angle ) ; } }
Sets the outside angle of the sound cone .
15,026
public void setConeOuterGain ( float gain ) { if ( _coneOuterGain != gain ) { AL10 . alSourcef ( _id , AL10 . AL_CONE_OUTER_GAIN , _coneOuterGain = gain ) ; } }
Sets the gain outside of the sound cone .
15,027
public void setBuffer ( Buffer buffer ) { _queue . clear ( ) ; if ( buffer != null ) { _queue . add ( buffer ) ; } AL10 . alSourcei ( _id , AL10 . AL_BUFFER , buffer == null ? AL10 . AL_NONE : buffer . getId ( ) ) ; }
Sets the source buffer . Equivalent to unqueueing all buffers then queuing the provided buffer . Cannot be called when the source is playing or paused .
15,028
public void queueBuffers ( Buffer ... buffers ) { IntBuffer idbuf = BufferUtils . createIntBuffer ( buffers . length ) ; for ( int ii = 0 ; ii < buffers . length ; ii ++ ) { Buffer buffer = buffers [ ii ] ; _queue . add ( buffer ) ; idbuf . put ( ii , buffer . getId ( ) ) ; } AL10 . alSourceQueueBuffers ( _id , idbuf ) ; }
Enqueues the specified buffers .
15,029
public void unqueueBuffers ( Buffer ... buffers ) { IntBuffer idbuf = BufferUtils . createIntBuffer ( buffers . length ) ; for ( int ii = 0 ; ii < buffers . length ; ii ++ ) { Buffer buffer = buffers [ ii ] ; _queue . remove ( buffer ) ; idbuf . put ( ii , buffer . getId ( ) ) ; } AL10 . alSourceUnqueueBuffers ( _id , idbuf ) ; }
Removes the specified buffers from the queue .
15,030
public void delete ( ) { IntBuffer idbuf = BufferUtils . createIntBuffer ( 1 ) ; idbuf . put ( _id ) . rewind ( ) ; AL10 . alDeleteSources ( idbuf ) ; _id = 0 ; _queue . clear ( ) ; }
Deletes this source rendering it unusable .
15,031
public UniformTileSet loadTileSet ( String imgPath , int width , int height ) { return loadCachedTileSet ( "" , imgPath , width , height ) ; }
Loads up a tileset from the specified image with the specified metadata parameters .
15,032
public TileSet getTileSet ( String name ) throws NoSuchTileSetException { if ( _setrep == null ) { throw new NoSuchTileSetException ( name ) ; } try { return _setrep . getTileSet ( name ) ; } catch ( PersistenceException pe ) { log . warning ( "Failure loading tileset" , "name" , name , "error" , pe ) ; throw new NoSuchTileSetException ( name ) ; } }
Returns the tileset with the specified name .
15,033
public Map < String , Object > getProperties ( ) { Map < String , Object > clone = new HashMap < String , Object > ( ) ; Set < Entry < String , Object > > set = _properties . entrySet ( ) ; for ( Entry < String , Object > entry : set ) { clone . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } return clone ; }
Returns a clone of the properties HashMap by shallow copying the values .
15,034
public void setAppId ( String appId ) { if ( appId == null ) { _properties . remove ( AMQP_PROP_APP_ID ) ; return ; } _properties . put ( AMQP_PROP_APP_ID , appId ) ; }
Sets the value of appId property . If a null value is passed in it indicates that the property is not set .
15,035
public void setContentType ( String contentType ) { if ( contentType == null ) { _properties . remove ( AMQP_PROP_CONTENT_TYPE ) ; return ; } _properties . put ( AMQP_PROP_CONTENT_TYPE , contentType ) ; }
Sets the value of contentType property . If a null value is passed in it indicates that the property is not set .
15,036
public void setContentEncoding ( String encoding ) { if ( encoding == null ) { _properties . remove ( AMQP_PROP_CONTENT_ENCODING ) ; return ; } _properties . put ( AMQP_PROP_CONTENT_ENCODING , encoding ) ; }
Sets the value of contentEncoding property . If a null value is passed in it indicates that the property is not set .
15,037
public void setCorrelationId ( String correlationId ) { if ( correlationId == null ) { _properties . remove ( AMQP_PROP_CORRELATION_ID ) ; return ; } _properties . put ( AMQP_PROP_CORRELATION_ID , correlationId ) ; }
Sets the value of correlationId property . If a null value is passed in it indicates that the property is not set .
15,038
public void setDeliveryMode ( Integer deliveryMode ) { if ( deliveryMode == null ) { _properties . remove ( AMQP_PROP_DELIVERY_MODE ) ; return ; } int value = deliveryMode . intValue ( ) ; if ( ( value != 1 ) && ( value != 2 ) ) { String s = "AMQP 0-9-1 spec mandates 'deliveryMode' value to be " + "either 1(for non-persistent) or 2(for persistent)" ; throw new IllegalStateException ( s ) ; } _properties . put ( AMQP_PROP_DELIVERY_MODE , deliveryMode ) ; }
Sets the value of deliveryMode property . If a null value is passed in it indicates that the property is not set .
15,039
public void setExpiration ( String expiration ) { if ( expiration == null ) { _properties . remove ( AMQP_PROP_EXPIRATION ) ; return ; } _properties . put ( AMQP_PROP_EXPIRATION , expiration ) ; }
Sets the value of expiration property . If a null value is passed in it indicates that the property is not set .
15,040
public void setHeaders ( AmqpArguments headers ) { if ( headers == null ) { _properties . remove ( AMQP_PROP_HEADERS ) ; return ; } _properties . put ( AMQP_PROP_HEADERS , headers ) ; }
Sets the value of headers property . If a null value is passed in it indicates that the property is not set .
15,041
public void setMessageId ( String messageId ) { if ( messageId == null ) { _properties . remove ( AMQP_PROP_MESSAGE_ID ) ; return ; } _properties . put ( AMQP_PROP_MESSAGE_ID , messageId ) ; }
Sets the value of messageId property . If a null value is passed in it indicates that the property is not set .
15,042
public void setPriority ( Integer priority ) { if ( priority == null ) { _properties . remove ( AMQP_PROP_PRIORITY ) ; return ; } int priorityValue = priority . intValue ( ) ; if ( ( priorityValue < 0 ) || ( priorityValue > 9 ) ) { String s = "AMQP 0-9-1 spec mandates 'priority' value to be between 0 and 9" ; throw new IllegalStateException ( s ) ; } _properties . put ( AMQP_PROP_PRIORITY , priority ) ; }
Sets the value of priority property . If a null value is passed in it indicates that the property is not set .
15,043
public void setReplyTo ( String replyTo ) { if ( replyTo == null ) { _properties . remove ( AMQP_PROP_REPLY_TO ) ; return ; } _properties . put ( AMQP_PROP_REPLY_TO , replyTo ) ; }
Sets the value of replyTo property . If a null value is passed in it indicates that the property is not set .
15,044
public void setTimestamp ( Timestamp timestamp ) { if ( timestamp == null ) { _properties . remove ( AMQP_PROP_TIMESTAMP ) ; return ; } _properties . put ( AMQP_PROP_TIMESTAMP , timestamp ) ; }
Sets the value of timestamp property . If a null value is passed in it indicates that the property is not set .
15,045
public void setType ( String type ) { if ( type == null ) { _properties . remove ( AMQP_PROP_TYPE ) ; return ; } _properties . put ( AMQP_PROP_TYPE , type ) ; }
Sets the value of type property . If a null value is passed in it indicates that the property is not set .
15,046
public void setUserId ( String userId ) { if ( userId == null ) { _properties . remove ( AMQP_PROP_USER_ID ) ; return ; } _properties . put ( AMQP_PROP_USER_ID , userId ) ; }
Sets the value of userId property . If a null value is passed in it indicates that the property is not set .
15,047
public boolean createBundle ( File target , TileSetBundle bundle , ImageProvider improv , String imageBase , long newestMod ) throws IOException { return createBundleJar ( target , bundle , improv , imageBase , _keepRawPngs , _uncompressed ) ; }
Finish the creation of a tileset bundle jar file .
15,048
protected void initBundles ( ResourceManager rmgr , String name ) { ResourceBundle [ ] rbundles = rmgr . getResourceSet ( name ) ; if ( rbundles == null ) { log . warning ( "Unable to fetch tileset resource set " + "[name=" + name + "]. Perhaps it's not defined " + "in the resource manager config?" ) ; return ; } HashIntMap < TileSet > idmap = new HashIntMap < TileSet > ( ) ; HashMap < String , Integer > namemap = Maps . newHashMap ( ) ; for ( ResourceBundle rbundle : rbundles ) { addBundle ( idmap , namemap , rbundle ) ; } synchronized ( this ) { _idmap = idmap ; _namemap = namemap ; notifyAll ( ) ; } }
Initializes our bundles
15,049
protected void addBundle ( HashIntMap < TileSet > idmap , HashMap < String , Integer > namemap , ResourceBundle bundle ) { try { TileSetBundle tsb = BundleUtil . extractBundle ( bundle ) ; tsb . init ( bundle ) ; addBundle ( idmap , namemap , tsb ) ; } catch ( Exception e ) { log . warning ( "Unable to load tileset bundle '" + BundleUtil . METADATA_PATH + "' from resource bundle [rbundle=" + bundle + "]." , e ) ; } }
Extracts the tileset bundle from the supplied resource bundle and registers it .
15,050
protected void addBundle ( HashIntMap < TileSet > idmap , HashMap < String , Integer > namemap , TileSetBundle bundle ) { IMImageProvider improv = ( _imgr == null ) ? null : new IMImageProvider ( _imgr , bundle ) ; for ( IntMap . IntEntry < TileSet > entry : bundle . intEntrySet ( ) ) { Integer tsid = entry . getKey ( ) ; TileSet tset = entry . getValue ( ) ; tset . setImageProvider ( improv ) ; idmap . put ( tsid . intValue ( ) , tset ) ; namemap . put ( tset . getName ( ) , tsid ) ; } }
Adds the tilesets in the supplied bundle to our tileset mapping tables . Any tilesets with the same name or id will be overwritten .
15,051
public SceneObjectIndicator createIndicator ( MisoScenePanel panel , String text , Icon icon ) { return new SceneObjectTip ( text , icon ) ; }
Creates an indicator for this type of object action .
15,052
public static void register ( String prefix , ObjectActionHandler handler ) { if ( _oahandlers . containsKey ( prefix ) ) { log . warning ( "Warning! Overwriting previous object action handler registration, all " + "hell could shortly break loose" , "prefix" , prefix , "handler" , handler ) ; } _oahandlers . put ( prefix , handler ) ; }
Registers an object action handler which will be called when a user clicks on an object in a scene that has an associated action .
15,053
public static int bound ( int low , int value , int high ) { return Math . min ( high , Math . max ( low , value ) ) ; }
Bounds the supplied value within the specified range .
15,054
public static int distanceSq ( int x0 , int y0 , int x1 , int y1 ) { return ( ( x1 - x0 ) * ( x1 - x0 ) ) + ( ( y1 - y0 ) * ( y1 - y0 ) ) ; }
Return the squared distance between the given points .
15,055
public static float [ ] stddev ( int [ ] values , int start , int length ) { float mean = 0f ; for ( int ii = start , end = start + length ; ii < end ; ii ++ ) { mean += values [ ii ] ; } mean /= length ; float variance = 0f ; for ( int ii = start , end = start + length ; ii < end ; ii ++ ) { float value = values [ ii ] - mean ; variance += value * value ; } variance /= ( length - 1 ) ; return new float [ ] { mean , variance , ( float ) Math . sqrt ( variance ) } ; }
Computes the standard deviation of the supplied values .
15,056
private void validateNamesUnique ( List < String > names ) { List < String > seenNames = new ArrayList < > ( names . size ( ) ) ; for ( int i = 0 ; i < names . size ( ) ; i ++ ) { String lowerCaseName = names . get ( i ) . toLowerCase ( ) ; int index = seenNames . indexOf ( lowerCaseName ) ; if ( index != - 1 ) { throw new IllegalArgumentException ( "Duplicate field: " + lowerCaseName + " found at positions " + i + "and" + index + ". Field names are case insensitive and must be unique." ) ; } seenNames . add ( lowerCaseName ) ; } }
For full ORC compatibility field names should be unique when lowercased .
15,057
public void setSpot ( int x , int y , byte orient ) { _spot = new Point ( x , y ) ; _sorient = orient ; }
Configures the spot associated with this object .
15,058
public boolean hasConstraint ( String constraint ) { return ( _constraints == null ) ? false : ListUtil . contains ( _constraints , constraint ) ; }
Checks whether this object has the given constraint .
15,059
public String getSyntax ( ) { if ( name != null && longName != null ) { return String . format ( "-%s (--%s)" , name , longName ) ; } else if ( name != null ) { return String . format ( "-%s" , name ) ; } else if ( longName != null ) { return String . format ( "--%s" , longName ) ; } throw new Error ( ) ; }
Returns the option syntax sans optional token if option takes an argument .
15,060
public void setLocalePrefix ( final String prefix ) { setLocaleHandler ( new LocaleHandler ( ) { public String getLocalePath ( String path ) { return PathUtil . appendPath ( prefix , path ) ; } } ) ; }
Configure a default LocaleHandler with the specified prefix .
15,061
public void initBundles ( String resourceDir , String configPath , InitObserver initObs ) throws IOException { if ( resourceDir != null ) { initResourceDir ( resourceDir ) ; } Properties config = loadConfig ( configPath ) ; List < ResourceBundle > dlist = Lists . newArrayList ( ) ; Enumeration < ? > names = config . propertyNames ( ) ; while ( names . hasMoreElements ( ) ) { String key = ( String ) names . nextElement ( ) ; if ( ! key . startsWith ( RESOURCE_SET_PREFIX ) ) { continue ; } String setName = key . substring ( RESOURCE_SET_PREFIX . length ( ) ) ; String resourceSetType = config . getProperty ( RESOURCE_SET_TYPE_PREFIX + setName , FILE_SET_TYPE ) ; resolveResourceSet ( setName , config . getProperty ( key ) , resourceSetType , dlist ) ; } final boolean [ ] shouldWait = new boolean [ ] { false } ; if ( initObs == null ) { shouldWait [ 0 ] = true ; initObs = new InitObserver ( ) { public void progress ( int percent , long remaining ) { if ( percent >= 100 ) { synchronized ( this ) { shouldWait [ 0 ] = false ; notify ( ) ; } } } public void initializationFailed ( Exception e ) { synchronized ( this ) { shouldWait [ 0 ] = false ; notify ( ) ; } } } ; } Unpacker unpack = new Unpacker ( dlist , initObs ) ; unpack . start ( ) ; if ( shouldWait [ 0 ] ) { synchronized ( initObs ) { if ( shouldWait [ 0 ] ) { try { initObs . wait ( ) ; } catch ( InterruptedException ie ) { log . warning ( "Interrupted while waiting for bundles to unpack." ) ; } } } } }
Initializes the bundle sets to be made available by this resource manager . Applications that wish to make use of resource bundles should call this method after constructing the resource manager .
15,062
public boolean checkBundle ( String path ) { File bfile = getResourceFile ( path ) ; return ( bfile == null ) ? false : new FileResourceBundle ( bfile , true , _unpack ) . isUnpacked ( ) ; }
Checks to see if the specified bundle exists is unpacked and is ready to be used .
15,063
public InputStream getResource ( String path ) throws IOException { String localePath = getLocalePath ( path ) ; InputStream in ; for ( ResourceBundle bundle : _default ) { if ( localePath != null ) { in = bundle . getResource ( localePath ) ; if ( in != null ) { return in ; } } in = bundle . getResource ( path ) ; if ( in != null ) { return in ; } } File file = getResourceFile ( path ) ; if ( file != null && file . exists ( ) ) { return new FileInputStream ( file ) ; } if ( localePath != null ) { in = getInputStreamFromClasspath ( PathUtil . appendPath ( _rootPath , localePath ) ) ; if ( in != null ) { return in ; } } in = getInputStreamFromClasspath ( PathUtil . appendPath ( _rootPath , path ) ) ; if ( in != null ) { return in ; } throw new FileNotFoundException ( "Unable to locate resource [path=" + path + "]" ) ; }
Fetches a resource from the local repository .
15,064
public void addModificationObserver ( String path , ModificationObserver obs ) { ObservedResource resource = _observed . get ( path ) ; if ( resource == null ) { File file = getResourceFile ( path ) ; if ( file == null ) { return ; } _observed . put ( path , resource = new ObservedResource ( file ) ) ; } resource . observers . add ( obs ) ; }
Adds a modification observer for the specified resource . Note that only a weak reference to the observer will be retained and thus this will not prevent the observer from being garbage - collected .
15,065
public void removeModificationObserver ( String path , ModificationObserver obs ) { ObservedResource resource = _observed . get ( path ) ; if ( resource != null ) { resource . observers . remove ( obs ) ; } }
Removes a modification observer from the list maintained for the specified resource .
15,066
protected Properties loadConfig ( String configPath ) throws IOException { Properties config = new Properties ( ) ; try { config . load ( new FileInputStream ( new File ( _rdir , configPath ) ) ) ; } catch ( Exception e ) { String errmsg = "Unable to load resource manager config [rdir=" + _rdir + ", cpath=" + configPath + "]" ; log . warning ( errmsg + "." , e ) ; throw new IOException ( errmsg ) ; } return config ; }
Loads the configuration properties for our resource sets .
15,067
protected void resolveResourceSet ( String setName , String definition , String setType , List < ResourceBundle > dlist ) { List < ResourceBundle > set = Lists . newArrayList ( ) ; StringTokenizer tok = new StringTokenizer ( definition , ":" ) ; while ( tok . hasMoreTokens ( ) ) { set . add ( createResourceBundle ( setType , tok . nextToken ( ) . trim ( ) , dlist ) ) ; } ResourceBundle [ ] setvec = set . toArray ( new ResourceBundle [ set . size ( ) ] ) ; _sets . put ( setName , setvec ) ; if ( DEFAULT_RESOURCE_SET . equals ( setName ) ) { _default = setvec ; } }
Loads up a resource set based on the supplied definition information .
15,068
protected ResourceBundle createResourceBundle ( String setType , String path , List < ResourceBundle > dlist ) { if ( setType . equals ( FILE_SET_TYPE ) ) { FileResourceBundle bundle = createFileResourceBundle ( getResourceFile ( path ) , true , _unpack ) ; if ( ! bundle . isUnpacked ( ) || ! bundle . sourceIsReady ( ) ) { dlist . add ( bundle ) ; } return bundle ; } else if ( setType . equals ( NETWORK_SET_TYPE ) ) { return createNetworkResourceBundle ( _networkRootPath , path , getResourceList ( ) ) ; } else { throw new IllegalArgumentException ( "Unknown set type: " + setType ) ; } }
Creates a ResourceBundle based on the supplied definition information .
15,069
protected FileResourceBundle createFileResourceBundle ( File source , boolean delay , boolean unpack ) { return new FileResourceBundle ( source , delay , unpack ) ; }
Creates an appropriate bundle for fetching resources from files .
15,070
protected ResourceBundle createNetworkResourceBundle ( String root , String path , Set < String > rsrcList ) { return new NetworkResourceBundle ( root , path , rsrcList ) ; }
Creates an appropriate bundle for fetching resources from the network .
15,071
protected InputStream getInputStreamFromClasspath ( final String fullyQualifiedPath ) { return AccessController . doPrivileged ( new PrivilegedAction < InputStream > ( ) { public InputStream run ( ) { return _loader . getResourceAsStream ( fullyQualifiedPath ) ; } } ) ; }
Returns an InputStream from this manager s classloader for the given path .
15,072
protected String getLocalePath ( String path ) { return ( _localeHandler == null ) ? null : _localeHandler . getLocalePath ( path ) ; }
Transform the path into a locale - specific one or return null .
15,073
protected static int getNumericJavaVersion ( String verstr ) { Matcher m = Pattern . compile ( "(\\d+)\\.(\\d+)\\.(\\d+)(_\\d+)?.*" ) . matcher ( verstr ) ; if ( ! m . matches ( ) ) { log . warning ( "Unable to parse VM version, hoping for the best [version=" + verstr + "]" ) ; return 0 ; } int one = Integer . parseInt ( m . group ( 1 ) ) ; int major = Integer . parseInt ( m . group ( 2 ) ) ; int minor = Integer . parseInt ( m . group ( 3 ) ) ; int patch = m . group ( 4 ) == null ? 0 : Integer . parseInt ( m . group ( 4 ) . substring ( 1 ) ) ; return patch + 100 * ( minor + 100 * ( major + 100 * one ) ) ; }
Converts the java version string to a more comparable numeric version number .
15,074
private void writeObject ( ObjectOutputStream out ) throws IOException { out . writeInt ( size ( ) ) ; for ( IntEntry < TileSet > entry : intEntrySet ( ) ) { out . writeInt ( entry . getIntKey ( ) ) ; out . writeObject ( entry . getValue ( ) ) ; } }
custom serialization process
15,075
private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { int count = in . readInt ( ) ; for ( int ii = 0 ; ii < count ; ii ++ ) { int tileSetId = in . readInt ( ) ; TileSet set = ( TileSet ) in . readObject ( ) ; put ( tileSetId , set ) ; } }
custom unserialization process
15,076
public void run ( ) { boolean validation_fail = false ; boolean arg_seen = true ; for ( String file : files ) { final Report v = new Report ( new File ( file ) . getAbsoluteFile ( ) , recursive ) ; if ( v . hasErrors ( ) ) validation_fail = true ; if ( arg_seen ) { arg_seen = false ; } else { System . out . println ( Stream . generate ( ( ) -> "-" ) . limit ( 72 ) . collect ( Collectors . joining ( ) ) ) ; } System . out . print ( v . configString ( ) . filter ( ( x ) -> print ) . orElseGet ( ( ) -> v . toString ( ) ) ) ; } if ( validation_fail ) System . exit ( EX_TEMPFAIL ) ; }
Perform validation .
15,077
private synchronized void onNewMbean ( ObjectName obj ) { if ( detected_groups_ . keySet ( ) . contains ( obj ) ) { LOG . log ( Level . WARNING , "skipping registration of {0}: already present" , obj ) ; return ; } MBeanGroup instance = new MBeanGroup ( obj , resolvedMap ) ; detected_groups_ . put ( obj , instance ) ; LOG . log ( Level . FINE , "registered metrics for {0}: {1}" , new Object [ ] { obj , instance } ) ; }
Respond to MBeans being added .
15,078
private synchronized void onRemovedMbean ( ObjectName obj ) { if ( ! detected_groups_ . keySet ( ) . contains ( obj ) ) { LOG . log ( Level . WARNING , "skipping de-registration of {0}: not present" , obj ) ; return ; } MBeanGroup instance = detected_groups_ . get ( obj ) ; detected_groups_ . remove ( obj ) ; LOG . log ( Level . FINE , "de-registered metrics for {0}: {1}" , new Object [ ] { obj , instance } ) ; }
Respond to MBeans being removed .
15,079
public static void renderIndex ( final PrintWriter out , final Collection < ? extends HelpPage > pages ) { checkNotNull ( out ) ; checkNotNull ( pages ) ; checkArgument ( ! pages . isEmpty ( ) , "No help pages to render index" ) ; int max = pages . stream ( ) . mapToInt ( page -> page . getName ( ) . length ( ) ) . max ( ) . orElse ( 0 ) ; String nameFormat = "%-" + max + 's' ; for ( HelpPage page : pages ) { String formattedName = String . format ( nameFormat , page . getName ( ) ) ; out . format ( " @{bold %s}" , formattedName ) ; String description = page . getDescription ( ) ; if ( description != null ) { out . printf ( " %s%n" , description ) ; } else { out . println ( ) ; } } }
Render a column - formatted index of help pages .
15,080
public void addDirtyRegion ( Rectangle rect ) { for ( AbstractMedia media : _metamgr ) { Rectangle intersection = media . getBounds ( ) . intersection ( rect ) ; if ( ! intersection . isEmpty ( ) ) { _metamgr . getRegionManager ( ) . addDirtyRegion ( intersection ) ; } } }
Adds a dirty region to this overlay .
15,081
private void runEvictor ( ConnectionEvictor evictor2 ) { final Thread evictorThread = new Thread ( evictor2 ) ; evictorThread . setDaemon ( true ) ; evictorThread . setName ( "Redmine communicator connection eviction thread" ) ; evictorThread . start ( ) ; }
Runs an evictor thread .
15,082
public boolean addAll ( Collection < ? extends TimeSeriesCollection > c ) { try { final rh_protoClient client = getRpcClient ( OncRpcProtocols . ONCRPC_TCP ) ; try { final list_of_timeseries_collection enc_c = encodeTSCCollection ( c ) ; return BlockingWrapper . execute ( ( ) -> client . addTSData_1 ( enc_c ) ) ; } finally { client . close ( ) ; } } catch ( OncRpcException | IOException | InterruptedException | RuntimeException ex ) { LOG . log ( Level . SEVERE , "addAll RPC call failed" , ex ) ; throw new RuntimeException ( "RPC call failed" , ex ) ; } }
Add multiple TimeSeriesCollections to the history .
15,083
public DateTime getEnd ( ) { try { final rh_protoClient client = getRpcClient ( OncRpcProtocols . ONCRPC_UDP ) ; try { return decodeTimestamp ( BlockingWrapper . execute ( ( ) -> client . getEnd_1 ( ) ) ) ; } finally { client . close ( ) ; } } catch ( OncRpcException | IOException | InterruptedException | RuntimeException ex ) { LOG . log ( Level . SEVERE , "getEnd RPC call failed" , ex ) ; throw new RuntimeException ( "RPC call failed" , ex ) ; } }
Return the highest timestamp in the stored metrics .
15,084
public MetricValue [ ] getAll ( int startInclusive , int endExclusive ) { return IntStream . range ( startInclusive , endExclusive ) . mapToObj ( this :: getOrNull ) . toArray ( MetricValue [ ] :: new ) ; }
Returns metric values at the given range .
15,085
public List < ChallengeHandler > lookup ( String location ) { List < ChallengeHandler > result = Collections . emptyList ( ) ; if ( location != null ) { Node < ChallengeHandler , UriElement > resultNode = findBestMatchingNode ( location ) ; if ( resultNode != null ) { return resultNode . getValues ( ) ; } } return result ; }
Locate all challenge handlers to serve the given location .
15,086
ChallengeHandler lookup ( ChallengeRequest challengeRequest ) { ChallengeHandler result = null ; String location = challengeRequest . getLocation ( ) ; if ( location != null ) { Node < ChallengeHandler , UriElement > resultNode = findBestMatchingNode ( location ) ; if ( resultNode != null ) { List < ChallengeHandler > handlers = resultNode . getValues ( ) ; if ( handlers != null ) { for ( ChallengeHandler challengeHandler : handlers ) { if ( challengeHandler . canHandle ( challengeRequest ) ) { result = challengeHandler ; break ; } } } } } return result ; }
Locate a challenge handler factory to serve the given location and challenge type .
15,087
private void refresh ( ) { try { final CompletableFuture < ? extends Collection < ResolverTuple > > fut = underlying . getTuples ( ) ; synchronized ( this ) { currentFut = fut . whenCompleteAsync ( this :: update , SCHEDULER ) ; if ( closed ) fut . cancel ( false ) ; } } catch ( Exception ex ) { synchronized ( this ) { exception = ex ; } reschedule ( FAILURE_RESCHEDULE_DELAY ) ; } }
Attempt to refresh the resolver result .
15,088
private void update ( Collection < ResolverTuple > underlyingTuples , Throwable t ) { if ( t != null ) applyException ( t ) ; else if ( underlyingTuples != null ) applyUpdate ( underlyingTuples ) ; else applyException ( null ) ; }
Update callback called when the completable future completes .
15,089
private synchronized void applyUpdate ( Collection < ResolverTuple > underlyingTuples ) { lastRefresh = DateTime . now ( ) ; tuples = underlyingTuples ; exception = null ; reschedule ( minAge . getMillis ( ) ) ; }
Apply updated tuple collection .
15,090
private synchronized void reschedule ( long millis ) { currentFut = null ; if ( ! closed ) { SCHEDULER . schedule ( this :: refresh , millis , TimeUnit . MILLISECONDS ) ; } else { try { underlying . close ( ) ; } catch ( Exception ex ) { LOG . log ( Level . WARNING , "failed to close resolver " + underlying . configString ( ) , ex ) ; } } }
Schedule next invocation of the update task .
15,091
public static Map < String , TileSet > parseActionTileSets ( File file ) throws IOException , SAXException { return parseActionTileSets ( new BufferedInputStream ( new FileInputStream ( file ) ) ) ; }
Parses the action tileset definitions in the supplied file and puts them into a hash map keyed on action name .
15,092
public static Map < String , TileSet > parseActionTileSets ( InputStream in ) throws IOException , SAXException { Digester digester = new Digester ( ) ; digester . addSetProperties ( "actions" + ActionRuleSet . ACTION_PATH ) ; addTileSetRuleSet ( digester , new SwissArmyTileSetRuleSet ( ) ) ; addTileSetRuleSet ( digester , new UniformTileSetRuleSet ( "/uniformTileset" ) ) ; Map < String , TileSet > actsets = new ActionMap ( ) ; digester . push ( actsets ) ; digester . parse ( in ) ; return actsets ; }
Parses the action tileset definitions in the supplied input stream and puts them into a hash map keyed on action name .
15,093
public static TileSetBundle extractBundle ( ResourceBundle bundle ) throws IOException , ClassNotFoundException { InputStream tbin = null ; try { tbin = bundle . getResource ( METADATA_PATH ) ; ObjectInputStream oin = new ObjectInputStream ( new BufferedInputStream ( tbin ) ) ; TileSetBundle tsb = ( TileSetBundle ) oin . readObject ( ) ; return tsb ; } finally { StreamUtil . close ( tbin ) ; } }
Extracts but does not initialize a serialized tileset bundle instance from the supplied resource bundle .
15,094
public static TileSetBundle extractBundle ( File file ) throws IOException , ClassNotFoundException { FileInputStream fin = new FileInputStream ( file ) ; try { ObjectInputStream oin = new ObjectInputStream ( new BufferedInputStream ( fin ) ) ; TileSetBundle tsb = ( TileSetBundle ) oin . readObject ( ) ; return tsb ; } finally { StreamUtil . close ( fin ) ; } }
Extracts but does not initialize a serialized tileset bundle instance from the supplied file .
15,095
public static FileChannel createTempFile ( Path dir , String prefix , String suffix ) throws IOException { return createNewFileImpl ( dir , prefix , suffix , new OpenOption [ ] { READ , WRITE , CREATE_NEW , DELETE_ON_CLOSE } ) . getFileChannel ( ) ; }
Create a temporary file that will be removed when it is closed .
15,096
public static FileChannel createTempFile ( String prefix , String suffix ) throws IOException { return createTempFile ( TMPDIR , prefix , suffix ) ; }
Create a temporary file that will be removed when it is closed in the tmpdir location .
15,097
public static NamedFileChannel createNewFile ( Path dir , String prefix , String suffix ) throws IOException { return createNewFileImpl ( dir , prefix , suffix , new OpenOption [ ] { READ , WRITE , CREATE_NEW } ) ; }
Creates a new file and opens it for reading and writing .
15,098
public void paint ( Graphics2D gfx ) { boolean footpaint = _fprintDebug . getValue ( ) ; if ( footpaint ) { gfx . setColor ( Color . black ) ; gfx . draw ( _footprint ) ; if ( _hideObjects . getValue ( ) ) { Composite ocomp = gfx . getComposite ( ) ; gfx . setComposite ( ALPHA_WARN ) ; gfx . fill ( _footprint ) ; gfx . setComposite ( ocomp ) ; } } if ( _hideObjects . getValue ( ) ) { return ; } if ( _warning ) { Composite ocomp = gfx . getComposite ( ) ; gfx . setComposite ( ALPHA_WARN ) ; gfx . fill ( bounds ) ; gfx . setComposite ( ocomp ) ; } tile . paint ( gfx , bounds . x , bounds . y ) ; if ( footpaint && _sspot != null ) { gfx . translate ( _sspot . x , _sspot . y ) ; double rot = ( Math . PI / 4.0f ) * tile . getSpotOrient ( ) ; gfx . rotate ( rot ) ; gfx . setColor ( Color . green ) ; gfx . fill ( _spotTri ) ; gfx . setColor ( Color . black ) ; gfx . draw ( _spotTri ) ; gfx . rotate ( - rot ) ; gfx . translate ( - _sspot . x , - _sspot . y ) ; } }
Requests that this scene object render itself .
15,099
public void setPriority ( byte priority ) { info . priority = ( byte ) Math . max ( Byte . MIN_VALUE , Math . min ( Byte . MAX_VALUE , priority ) ) ; }
Overrides the render priority of this object .