idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
138,600
public FunctionInfo getFunction ( String name ) { if ( functions == null || functions . length == 0 ) { System . err . println ( "No functions" ) ; return null ; } for ( int i = 0 ; i < functions . length ; i ++ ) { if ( functions [ i ] . getName ( ) . equals ( name ) ) { return functions [ i ] ; } } return null ; }
Get the FunctionInfo for a given function name looking through all the functions in this tag library .
138,601
protected int readSamples ( ) throws IOException { int samples ; while ( ( samples = _dsp . synthesis_pcmout ( _pcm , _offsets ) ) <= 0 ) { if ( samples == 0 && ! readPacket ( ) ) { return 0 ; } if ( _block . synthesis ( _packet ) == 0 ) { _dsp . synthesis_blockin ( _block ) ; } } return samples ; }
Reads a buffer s worth of samples .
138,602
protected boolean readPacket ( ) throws IOException { int result ; while ( ( result = _stream . packetout ( _packet ) ) != 1 ) { if ( result == 0 && ! readPage ( ) ) { return false ; } } return true ; }
Reads a packet .
138,603
protected boolean readPage ( ) throws IOException { int result ; while ( ( result = _sync . pageout ( _page ) ) != 1 ) { if ( result == 0 && ! readChunk ( ) ) { return false ; } } _stream . pagein ( _page ) ; return true ; }
Reads in a page .
138,604
protected boolean readChunk ( ) throws IOException { int offset = _sync . buffer ( BUFFER_SIZE ) ; int bytes = _in . read ( _sync . data , offset , BUFFER_SIZE ) ; if ( bytes > 0 ) { _sync . wrote ( bytes ) ; return true ; } return false ; }
Reads in a chunk of data from the underlying input stream .
138,605
public static TrimmedTileSet trimTileSet ( TileSet source , OutputStream destImage ) throws IOException { return trimTileSet ( source , destImage , FastImageIO . FILE_SUFFIX ) ; }
Convenience function to trim the tile set and save it using FastImageIO .
138,606
public boolean sourceIsReady ( ) { _sourceLastMod = _source . lastModified ( ) ; if ( _unpacked != null && _unpacked . lastModified ( ) != _sourceLastMod ) { try { resolveJarFile ( ) ; } catch ( IOException ioe ) { log . warning ( "Failure resolving jar file" , "source" , _source , ioe ) ; wipeBundle ( true ) ; return ...
Called by the resource manager once it has ensured that our resource jar file is up to date and ready for reading .
138,607
public void wipeBundle ( boolean deleteJar ) { if ( _cache != null ) { FileUtil . recursiveClean ( _cache ) ; } if ( _unpacked != null ) { _unpacked . delete ( ) ; } File vfile = new File ( FileUtil . resuffix ( _source , ".jar" , ".jarv" ) ) ; if ( vfile . exists ( ) && ! vfile . delete ( ) ) { log . warning ( "Failed...
Clears out everything associated with this resource bundle in the hopes that we can download it afresh and everything will work the next time around .
138,608
public File getResourceFile ( String path ) throws IOException { if ( resolveJarFile ( ) ) { return null ; } if ( _cache != null ) { File cfile = new File ( _cache , path ) ; if ( cfile . exists ( ) ) { return cfile ; } else { return null ; } } String tpath = StringUtil . md5hex ( _source . getPath ( ) + "%" + path ) ;...
Returns a file from which the specified resource can be loaded . This method will unpack the resource into a temporary directory and return a reference to that file .
138,609
public boolean containsResource ( String path ) { try { if ( resolveJarFile ( ) ) { return false ; } return ( _jarSource . getJarEntry ( path ) != null ) ; } catch ( IOException ioe ) { return false ; } }
Returns true if this resource bundle contains the resource with the specified path . This avoids actually loading the resource in the event that the caller only cares to know that the resource exists .
138,610
protected boolean resolveJarFile ( ) throws IOException { if ( _sourceLastMod == - 1 ) { return true ; } if ( ! _source . exists ( ) ) { throw new IOException ( "Missing jar file for resource bundle: " + _source + "." ) ; } try { if ( _jarSource == null ) { _jarSource = new JarFile ( _source ) ; } return false ; } catc...
Creates the internal jar file reference if we ve not already got it ; we do this lazily so as to avoid any jar - or zip - file - related antics until and unless doing so is required and because the resource manager would like to be able to create bundles before the associated files have been fully downloaded .
138,611
public static File getCacheDir ( ) { if ( _tmpdir == null ) { String tmpdir = System . getProperty ( "java.io.tmpdir" ) ; if ( tmpdir == null ) { log . info ( "No system defined temp directory. Faking it." ) ; tmpdir = System . getProperty ( "user.home" ) ; } setCacheDir ( new File ( tmpdir ) ) ; } return _tmpdir ; }
Returns the cache directory used for unpacked resources .
138,612
public static void setCacheDir ( File tmpdir ) { String rando = Long . toHexString ( ( long ) ( Math . random ( ) * Long . MAX_VALUE ) ) ; _tmpdir = new File ( tmpdir , "narcache_" + rando ) ; if ( ! _tmpdir . exists ( ) ) { if ( _tmpdir . mkdirs ( ) ) { log . debug ( "Created narya temp cache directory '" + _tmpdir + ...
Specifies the directory in which our temporary resource files should be stored .
138,613
protected static String stripSuffix ( String path ) { if ( path . endsWith ( ".jar" ) ) { return path . substring ( 0 , path . length ( ) - 4 ) ; } else { return path + "-cache" ; } }
Strips the . jar off of jar file paths .
138,614
public static < T > CloseableIterator < T > distinct ( final CloseableIterator < T > iterator ) { return wrap ( Iterators2 . distinct ( iterator ) , iterator ) ; }
If we can assume the closeable iterator is sorted return the distinct elements . This only works if the data provided is sorted .
138,615
public Stream < RangeWithCount > stream ( ) { return buckets_ . stream ( ) . map ( bucket -> new RangeWithCount ( bucket . getRange ( ) , bucket . getEvents ( ) ) ) ; }
Returns a map of range - &gt ; event count . The elements of the stream are a mutable copy of the internal data .
138,616
public Optional < Double > avg ( ) { if ( isEmpty ( ) ) return Optional . empty ( ) ; return Optional . of ( sum ( ) / getEventCount ( ) ) ; }
Return the average of the histogram .
138,617
public double sum ( ) { return buckets_ . stream ( ) . mapToDouble ( b -> b . getRange ( ) . getMidPoint ( ) * b . getEvents ( ) ) . sum ( ) ; }
Return the sum of the histogram .
138,618
public double get ( double index ) { ListIterator < Bucket > b = buckets_ . listIterator ( 0 ) ; ListIterator < Bucket > e = buckets_ . listIterator ( buckets_ . size ( ) ) ; while ( b . nextIndex ( ) < e . previousIndex ( ) ) { final ListIterator < Bucket > mid = buckets_ . listIterator ( b . nextIndex ( ) / 2 + e . n...
Get the value at a given position .
138,619
public Histogram modifyEventCounters ( BiFunction < Range , Double , Double > fn ) { return new Histogram ( stream ( ) . map ( entry -> { entry . setCount ( fn . apply ( entry . getRange ( ) , entry . getCount ( ) ) ) ; return entry ; } ) ) ; }
Create a new histogram after applying the function on each of the event counters .
138,620
public static Histogram add ( Histogram x , Histogram y ) { return new Histogram ( Stream . concat ( x . stream ( ) , y . stream ( ) ) ) ; }
Add two histograms together .
138,621
public static Histogram subtract ( Histogram x , Histogram y ) { return new Histogram ( Stream . concat ( x . stream ( ) , y . stream ( ) . map ( rwc -> { rwc . setCount ( - rwc . getCount ( ) ) ; return rwc ; } ) ) ) ; }
Subtracts two histograms .
138,622
public static Histogram multiply ( Histogram x , double y ) { return x . modifyEventCounters ( ( r , d ) -> d * y ) ; }
Multiply histogram by scalar .
138,623
public static Histogram divide ( Histogram x , double y ) { return x . modifyEventCounters ( ( r , d ) -> d / y ) ; }
Divide histogram by scalar .
138,624
public int compareTo ( Histogram o ) { int cmp = 0 ; final Iterator < Bucket > iter = buckets_ . iterator ( ) , o_iter = o . buckets_ . iterator ( ) ; while ( cmp == 0 && iter . hasNext ( ) && o_iter . hasNext ( ) ) { final Bucket next = iter . next ( ) , o_next = o_iter . next ( ) ; cmp = Double . compare ( next . get...
Compare two histograms .
138,625
protected final Object convertToObject ( final String text ) throws Exception { Map map = CollectionUtil . toMap ( text , keyEditor , valueEditor ) ; if ( map == null ) { return null ; } return createMap ( map ) ; }
Treats the text value of this property as an input stream that is converted into a Property bundle .
138,626
public NodeGraphicDefinition getGroupGraphics ( Object group , Set < String > groupElements ) { return null ; }
we have no groups in this example
138,627
public static final String name ( SimpleGroupPath group , MetricName metric ) { return name ( Stream . concat ( group . getPath ( ) . stream ( ) , metric . getPath ( ) . stream ( ) ) . collect ( Collectors . joining ( "." ) ) ) ; }
Convert a group + metric to a wavefront name .
138,628
private static Optional < Map . Entry < String , String > > createTagEntry ( Map . Entry < String , MetricValue > tag_entry ) { final Optional < String > opt_tag_value = tag_entry . getValue ( ) . asString ( ) ; return opt_tag_value . map ( tag_value -> SimpleMapEntry . create ( name ( tag_entry . getKey ( ) ) , escape...
Transform a tag entry into a wavefront tag .
138,629
private static Map . Entry < String , String > maybeTruncateTagEntry ( Map . Entry < String , String > tag_entry ) { String k = tag_entry . getKey ( ) ; String v = tag_entry . getValue ( ) ; if ( k . length ( ) + v . length ( ) <= MAX_TAG_KEY_VAL_CHARS - 2 ) return tag_entry ; if ( k . length ( ) > TRUNCATE_TAG_NAME ) ...
Truncate tag keys and values to prevent them from exceeding the max length of a tag entry .
138,630
public static Map < String , String > tags ( Tags tags ) { return tags . stream ( ) . map ( WavefrontStrings :: createTagEntry ) . flatMap ( opt -> opt . map ( Stream :: of ) . orElseGet ( Stream :: empty ) ) . map ( WavefrontStrings :: maybeTruncateTagEntry ) . collect ( Collectors . toMap ( Map . Entry :: getKey , Ma...
Create a map of tags for wavefront .
138,631
public static Optional < String > wavefrontValue ( MetricValue mv ) { if ( mv . isInfiniteOrNaN ( ) ) return Optional . empty ( ) ; return mv . value ( ) . map ( Number :: toString ) ; }
Create a wavefront compatible string representation of the metric value .
138,632
private static String extractTagSource ( Map < String , String > tag_map ) { return Optional . ofNullable ( tag_map . remove ( "source" ) ) . orElseGet ( ( ) -> { return Optional . ofNullable ( tag_map . get ( "cluster" ) ) . map ( WavefrontStrings :: escapeTagValue ) . orElseGet ( ( ) -> tag_map . getOrDefault ( "monc...
Extract the source tag from the tag_map .
138,633
private static String wavefrontLine ( DateTime ts , SimpleGroupPath group , MetricName metric , String value , String source , Map < String , String > tag_map ) { return new StringBuilder ( ) . append ( name ( group , metric ) ) . append ( ' ' ) . append ( value ) . append ( ' ' ) . append ( timestamp ( ts ) ) . append...
Build the wavefront line from its parts .
138,634
public static Optional < String > wavefrontLine ( DateTime ts , GroupName group , MetricName metric , MetricValue metric_value ) { return wavefrontValue ( metric_value ) . map ( value -> { final Map < String , String > tag_map = tags ( group . getTags ( ) ) ; final String source = extractTagSource ( tag_map ) ; return ...
Convert a metric to a wavefront string .
138,635
public static Stream < String > wavefrontLine ( DateTime ts , TimeSeriesValue tsv ) { final GroupName group = tsv . getGroup ( ) ; return tsv . getMetrics ( ) . entrySet ( ) . stream ( ) . flatMap ( metricEntry -> wavefrontLineForMetric ( ts , group , metricEntry ) ) ; }
Convert a time series value into the string entries for wavefront .
138,636
public Point getEndPos ( ) { return new Point ( ( int ) ( _center . x + Math . round ( Math . cos ( _sangle + _delta ) * _xradius ) ) , ( int ) ( _center . y + Math . round ( Math . sin ( _sangle + _delta ) * _yradius ) ) ) ; }
Returns the position of the end of the path .
138,637
public static Serializable loadConfig ( InputStream source ) throws IOException { try { ObjectInputStream oin = new ObjectInputStream ( source ) ; return ( Serializable ) oin . readObject ( ) ; } catch ( ClassNotFoundException cnfe ) { String errmsg = "Unknown config class" ; throw ( IOException ) new IOException ( err...
Unserializes a configuration object from the supplied input stream .
138,638
public static void saveConfig ( File target , Serializable config ) throws IOException { FileOutputStream fout = new FileOutputStream ( target ) ; ObjectOutputStream oout = new ObjectOutputStream ( fout ) ; oout . writeObject ( config ) ; oout . close ( ) ; }
Serializes the supplied configuration object to the specified file path .
138,639
public void historyUpdated ( int adjustment ) { if ( adjustment != 0 ) { for ( int ii = 0 , nn = _showingHistory . size ( ) ; ii < nn ; ii ++ ) { ChatGlyph cg = _showingHistory . get ( ii ) ; cg . histIndex -= adjustment ; } resetHistoryOffset ( ) ; } if ( isLaidOut ( ) && isHistoryMode ( ) ) { int val = _historyModel ...
from interface HistoryList . Observer
138,640
public boolean displayMessage ( ChatMessage message , boolean alreadyDisplayed ) { if ( ! isLaidOut ( ) ) { return false ; } Graphics2D gfx = getTargetGraphics ( ) ; if ( gfx != null ) { displayMessage ( message , gfx ) ; gfx . dispose ( ) ; return true ; } return false ; }
documentation inherited from superinterface ChatDisplay
138,641
protected void updateDimmed ( List < ? extends ChatGlyph > glyphs ) { for ( ChatGlyph glyph : glyphs ) { glyph . setDim ( _dimmed ) ; } }
Update the chat glyphs in the specified list to be set to the current dimmed setting .
138,642
protected void setHistoryEnabled ( boolean historyEnabled ) { if ( historyEnabled && _historyModel == null ) { _historyModel = _scrollbar . getModel ( ) ; _historyModel . addChangeListener ( this ) ; resetHistoryOffset ( ) ; clearGlyphs ( _subtitles ) ; updateHistBar ( _history . size ( ) - 1 ) ; figureCurrentHistory (...
Configures us for display of chat history or not .
138,643
protected void viewDidScroll ( List < ? extends ChatGlyph > glyphs , int dx , int dy ) { for ( ChatGlyph glyph : glyphs ) { glyph . viewDidScroll ( dx , dy ) ; } }
Helper function for informing glyphs of the scrolled view .
138,644
protected void updateHistBar ( int val ) { if ( ! _histOffsetFinal && _history . size ( ) > _histOffset ) { Graphics2D gfx = getTargetGraphics ( ) ; if ( gfx != null ) { figureHistoryOffset ( gfx ) ; gfx . dispose ( ) ; } } int oldval = Math . max ( _histOffset , val ) ; int newmaxval = Math . max ( 0 , _history . size...
Update the history scrollbar with the specified value .
138,645
protected void figureHistoryOffset ( Graphics2D gfx ) { if ( ! isLaidOut ( ) ) { return ; } int hei = _subtitleYSpacing ; int hsize = _history . size ( ) ; for ( int ii = 0 ; ii < hsize ; ii ++ ) { ChatGlyph rec = getHistorySubtitle ( ii , gfx ) ; Rectangle r = rec . getBounds ( ) ; hei += r . height ; if ( hei >= _sub...
Figure out how many of the first history elements fit in our bounds such that we can set the bounds on the scrollbar correctly such that the scrolling to the smallest value just barely puts the first element onscreen .
138,646
protected void figureCurrentHistory ( ) { int first = _historyModel . getValue ( ) ; int count = 0 ; Graphics2D gfx = null ; if ( isLaidOut ( ) && ! _history . isEmpty ( ) ) { gfx = getTargetGraphics ( ) ; if ( gfx == null ) { log . warning ( "Can't figure current history, no graphics." ) ; return ; } Rectangle vbounds...
Figure out which ChatMessages in the history should currently appear in the showing history .
138,647
protected ChatGlyph getHistorySubtitle ( int index , Graphics2D layoutGfx ) { for ( int ii = 0 , nn = _showingHistory . size ( ) ; ii < nn ; ii ++ ) { ChatGlyph cg = _showingHistory . get ( ii ) ; if ( cg . histIndex == index ) { return cg ; } } ChatGlyph cg = createHistorySubtitle ( index , layoutGfx ) ; cg . histInde...
Get the glyph for the specified history index creating if necessary .
138,648
protected ChatGlyph createHistorySubtitle ( int index , Graphics2D layoutGfx ) { ChatMessage message = _history . get ( index ) ; int type = getType ( message , true ) ; return createSubtitle ( message , type , layoutGfx , false ) ; }
Creates a subtitle for display in the history panel .
138,649
protected int getHistorySubtitleSpacing ( int index ) { ChatMessage message = _history . get ( index ) ; return _logic . getSubtitleSpacing ( getType ( message , true ) ) ; }
Determines the amount of spacing to put after a history subtitle .
138,650
protected void clearGlyphs ( List < ChatGlyph > glyphs ) { if ( _target != null ) { for ( int ii = 0 , nn = glyphs . size ( ) ; ii < nn ; ii ++ ) { ChatGlyph rec = glyphs . get ( ii ) ; _target . abortAnimation ( rec ) ; } } else if ( ! glyphs . isEmpty ( ) ) { log . warning ( "No target to abort chat animations" ) ; }...
Clears out the supplied list of chat glyphs .
138,651
protected void displayMessage ( ChatMessage message , Graphics2D gfx ) { int type = getType ( message , false ) ; if ( type != ChatLogic . IGNORECHAT ) { displayMessage ( message , type , gfx ) ; } }
Display the specified message now unless we are to ignore it .
138,652
protected void displayMessage ( ChatMessage message , int type , Graphics2D layoutGfx ) { if ( isHistoryMode ( ) ) { return ; } addSubtitle ( createSubtitle ( message , type , layoutGfx , true ) ) ; }
Display the message after we ve decided which type it is .
138,653
protected void addSubtitle ( ChatGlyph rec ) { Rectangle r = rec . getBounds ( ) ; scrollUpSubtitles ( - r . height - _logic . getSubtitleSpacing ( rec . getType ( ) ) ) ; Rectangle vbounds = _target . getViewBounds ( ) ; rec . setLocation ( vbounds . x + _subtitleXSpacing , vbounds . y + vbounds . height - _subtitleYS...
Add a subtitle for display now .
138,654
protected ChatGlyph createSubtitle ( ChatMessage message , int type , Graphics2D layoutGfx , boolean expires ) { String text = message . message ; Tuple < String , Boolean > finfo = _logic . decodeFormat ( type , message . getFormat ( ) ) ; String format = finfo . left ; boolean quotes = finfo . right ; if ( format != ...
Create a subtitle but don t do anything funny with it .
138,655
protected ChatGlyph createSubtitle ( Graphics2D gfx , int type , long timestamp , Icon icon , int indent , String text , boolean expires ) { Dimension is = new Dimension ( ) ; if ( icon != null ) { is . setSize ( icon . getIconWidth ( ) , icon . getIconHeight ( ) ) ; } Rectangle vbounds = _target . getViewBounds ( ) ; ...
Create a subtitle - a line of text that goes on the bottom .
138,656
protected long getChatExpire ( long timestamp , String text ) { long [ ] durations = _logic . getDisplayDurations ( getDisplayDurationOffset ( ) ) ; long start = Math . max ( timestamp , _lastExpire ) ; _lastExpire = start + Math . min ( text . length ( ) * durations [ 0 ] , durations [ 2 ] ) ; _lastExpire = Math . min...
Get the expire time for the specified chat .
138,657
protected void scrollUpSubtitles ( int dy ) { Rectangle vbounds = _target . getViewBounds ( ) ; int miny = vbounds . y + vbounds . height - _subtitleHeight ; for ( Iterator < ChatGlyph > iter = _subtitles . iterator ( ) ; iter . hasNext ( ) ; ) { ChatGlyph sub = iter . next ( ) ; sub . translate ( 0 , dy ) ; if ( sub ....
Scroll all the subtitles up by the specified amount .
138,658
private static ParsedLine extractCommandArguments ( final ParsedLine line ) { LinkedList < String > words = Lists . newLinkedList ( line . words ( ) ) ; String remove = words . pop ( ) ; String rawLine = line . line ( ) ; if ( remove . length ( ) > rawLine . length ( ) ) { return new DefaultParser . ArgumentList ( rawL...
Extract the command specific portions of the given line .
138,659
protected void convert ( ) { if ( _image == null ) { return ; } try { BufferedImage image ; if ( _tabs . getSelectedIndex ( ) == 0 ) { image = getAllRecolors ( _labelColors . isSelected ( ) ) ; if ( image == null ) { return ; } } else if ( _tabs . getSelectedIndex ( ) == 1 ) { ArrayList < Colorization > zations = Lists...
Performs colorizations .
138,660
public BufferedImage getAllRecolors ( boolean label ) { if ( _colRepo == null ) { return null ; } ColorPository . ClassRecord colClass = _colRepo . getClassRecord ( ( String ) _classList . getSelectedItem ( ) ) ; int classId = colClass . classId ; BufferedImage img = new BufferedImage ( _image . getWidth ( ) , _image ....
Gets an image with all recolorings of the selection colorization class .
138,661
public void setColorizeFile ( File path ) { try { if ( path . getName ( ) . endsWith ( "xml" ) ) { ColorPositoryParser parser = new ColorPositoryParser ( ) ; _colRepo = ( ColorPository ) ( parser . parseConfig ( path ) ) ; } else { _colRepo = ColorPository . loadColorPository ( new FileInputStream ( path ) ) ; } _class...
Loads up the colorization classes from the specified file .
138,662
public static String stripControlCharacters ( String rawValue ) { if ( rawValue == null ) { return null ; } String value = replaceEntities ( rawValue ) ; boolean hasControlChars = false ; for ( int i = value . length ( ) - 1 ; i >= 0 ; i -- ) { if ( Character . isISOControl ( value . charAt ( i ) ) ) { hasControlChars ...
Strip a String of it s ISO control characters .
138,663
public static void write ( BufferedImage image , OutputStream out ) throws IOException { DataOutputStream dout = new DataOutputStream ( out ) ; int width = image . getWidth ( ) , height = image . getHeight ( ) ; dout . writeInt ( width ) ; dout . writeInt ( height ) ; IndexColorModel cmodel = ( IndexColorModel ) image ...
Writes the supplied image to the supplied output stream .
138,664
public List < AmqpTableEntry > getEntries ( String key ) { if ( ( key == null ) || ( tableEntryArray == null ) ) { return null ; } List < AmqpTableEntry > entries = new ArrayList < AmqpTableEntry > ( ) ; for ( AmqpTableEntry entry : tableEntryArray ) { if ( entry . key . equals ( key ) ) { entries . add ( entry ) ; } }...
Returns a list of AmqpTableEntry objects that matches the specified key . If a null key is passed in then a null is returned . Also if the internal structure is null then a null is returned .
138,665
public void update ( long numProcessedDuringStep ) { if ( this . closed ) { throw new ETAPrinterException ( "You cannot update a closed ETAPrinter!" ) ; } DateTime now = DateTime . now ( ) ; ItemsDuration itemsDuration = null ; if ( numProcessedDuringStep > 0 ) { long stepDuration = new Duration ( this . lastStep , now...
Updates and prints the progress bar with the new values .
138,666
public static TagAttributeInfo getIdAttribute ( TagAttributeInfo a [ ] ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] . getName ( ) . equals ( ID ) ) { return a [ i ] ; } } return null ; }
Convenience static method that goes through an array of TagAttributeInfo objects and looks for id .
138,667
protected static < T > Class < T > firstKnownType ( T ... objects ) { for ( T obj : objects ) if ( obj != null ) return ( Class < T > ) obj . getClass ( ) ; return null ; }
Utility method to allow subclasses to extract type from known variables .
138,668
public ColorRecord [ ] enumerateColors ( String className ) { ClassRecord record = getClassRecord ( className ) ; if ( record == null ) { return null ; } ColorRecord [ ] crecs = new ColorRecord [ record . colors . size ( ) ] ; Iterator < ColorRecord > iter = record . colors . values ( ) . iterator ( ) ; for ( int ii = ...
Returns an array containing the records for the colors in the specified class .
138,669
public int [ ] enumerateColorIds ( String className ) { ClassRecord record = getClassRecord ( className ) ; if ( record == null ) { return null ; } int [ ] cids = new int [ record . colors . size ( ) ] ; Iterator < ColorRecord > crecs = record . colors . values ( ) . iterator ( ) ; for ( int ii = 0 ; crecs . hasNext ( ...
Returns an array containing the ids of the colors in the specified class .
138,670
public ColorRecord getRandomStartingColor ( String className , Random rand ) { ClassRecord record = getClassRecord ( className ) ; return ( record == null ) ? null : record . randomStartingColor ( rand ) ; }
Returns a random starting color from the specified color class .
138,671
public Colorization getColorization ( int classId , int colorId ) { ColorRecord color = getColorRecord ( classId , colorId ) ; return ( color == null ) ? null : color . getColorization ( ) ; }
Looks up a colorization by id .
138,672
public Colorization getColorization ( String className , int colorId ) { ClassRecord crec = getClassRecord ( className ) ; if ( crec != null ) { ColorRecord color = crec . colors . get ( colorId ) ; if ( color != null ) { return color . getColorization ( ) ; } } return null ; }
Looks up a colorization by name .
138,673
public Colorization getColorization ( String className , String colorName ) { ClassRecord crec = getClassRecord ( className ) ; if ( crec != null ) { int colorId = 0 ; try { colorId = crec . getColorId ( colorName ) ; } catch ( ParseException pe ) { log . info ( "Error getting colorization by name" , "error" , pe ) ; r...
Looks up a colorization by class and color names .
138,674
public ClassRecord getClassRecord ( String className ) { Iterator < ClassRecord > iter = _classes . values ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ClassRecord crec = iter . next ( ) ; if ( crec . name . equals ( className ) ) { return crec ; } } log . warning ( "No such color class" , "class" , className , ...
Loads up a colorization class by name and logs a warning if it doesn t exist .
138,675
public ColorRecord getColorRecord ( int classId , int colorId ) { ClassRecord record = getClassRecord ( classId ) ; if ( record == null ) { if ( classId != 0 ) { log . warning ( "Requested unknown color class" , "classId" , classId , "colorId" , colorId , new Exception ( ) ) ; } return null ; } return record . colors ....
Looks up the requested color record .
138,676
public ColorRecord getColorRecord ( String className , String colorName ) { ClassRecord record = getClassRecord ( className ) ; if ( record == null ) { log . warning ( "Requested unknown color class" , "className" , className , "colorName" , colorName , new Exception ( ) ) ; return null ; } int colorId = 0 ; try { colo...
Looks up the requested color record by class and color names .
138,677
public void addClass ( ClassRecord record ) { if ( record . classId > 255 ) { log . warning ( "Refusing to add class; classId > 255 " + record + "." ) ; } else { _classes . put ( record . classId , record ) ; } }
Adds a fully configured color class record to the pository . This is only called by the XML parsing code so pay it no mind .
138,678
public static void saveColorPository ( ColorPository posit , File root ) { File path = new File ( root , CONFIG_PATH ) ; try { CompiledConfig . saveConfig ( path , posit ) ; } catch ( IOException ioe ) { log . warning ( "Failure saving color pository" , "path" , path , "error" , ioe ) ; } }
Serializes and saves color pository to the supplied file .
138,679
public void init ( CharacterDescriptor descrip , CharacterManager charmgr ) { _descrip = descrip ; _charmgr = charmgr ; sanityCheckDescrip ( ) ; _orient = SOUTHWEST ; didInit ( ) ; }
Initializes this character sprite with the specified character descriptor and character manager . It will obtain animation data from the supplied character manager .
138,680
public void setActionSequence ( String action ) { if ( action == null ) { log . warning ( "Refusing to set null action sequence " + this + "." , new Exception ( ) ) ; return ; } if ( action . equals ( _action ) ) { return ; } _action = action ; updateActionFrames ( ) ; }
Sets the action sequence used when rendering the character from the set of available sequences .
138,681
protected void updateActionFrames ( ) { ActionSequence actseq = _charmgr . getActionSequence ( _action ) ; if ( actseq == null ) { String errmsg = "No such action '" + _action + "'." ; throw new IllegalArgumentException ( errmsg ) ; } try { _aframes = _charmgr . getActionFrames ( _descrip , _action ) ; _frames = null ;...
Rebuilds our action frames given our current character descriptor and action sequence . This is called when either of those two things changes .
138,682
protected void sanityCheckDescrip ( ) { if ( _descrip . getComponentIds ( ) == null || _descrip . getComponentIds ( ) . length == 0 ) { log . warning ( "Invalid character descriptor [sprite=" + this + ", descrip=" + _descrip + "]." , new Exception ( ) ) ; } }
Makes it easier to track down problems with bogus character descriptors .
138,683
protected void halt ( ) { if ( _animMode != NO_ANIMATION ) { setAnimationMode ( NO_ANIMATION ) ; String rest = getRestingAction ( ) ; if ( rest != null ) { setActionSequence ( rest ) ; } } }
Updates the sprite animation frame to reflect the cessation of movement and disables any further animation .
138,684
public static void unmask ( WrappedByteBuffer buf , int mask ) { byte b ; int remainder = buf . remaining ( ) % 4 ; int remaining = buf . remaining ( ) - remainder ; int end = remaining + buf . position ( ) ; while ( buf . position ( ) < end ) { int plaintext = buf . getIntAt ( buf . position ( ) ) ^ mask ; buf . putIn...
Performs an in - situ unmasking of the readable buf bytes . Preserves the position of the buffer whilst unmasking all the readable bytes such that the unmasked bytes will be readable after this invocation .
138,685
private static stream_response newTscStream ( Stream < TimeSeriesCollection > tsc , int fetch ) { final BufferedIterator < TimeSeriesCollection > iter = new BufferedIterator ( tsc . iterator ( ) , TSC_QUEUE_SIZE ) ; final long idx = TSC_ITERS_ALLOC . getAndIncrement ( ) ; final IteratorAndCookie < TimeSeriesCollection ...
Create a new TimeSeriesCollection iterator from the given stream .
138,686
private static evaluate_response newEvalStream ( Stream < Collection < CollectHistory . NamedEvaluation > > tsc , int fetch ) { final BufferedIterator < Collection < CollectHistory . NamedEvaluation > > iter = new BufferedIterator ( tsc . iterator ( ) , EVAL_QUEUE_SIZE ) ; final long idx = EVAL_ITERS_ALLOC . getAndIncr...
Create a new evaluation iterator from the given stream .
138,687
private static group_stream_response newGroupStream ( Stream < Map . Entry < DateTime , TimeSeriesValue > > tsc , int fetch ) { final BufferedIterator < Map . Entry < DateTime , TimeSeriesValue > > iter = new BufferedIterator < > ( tsc . iterator ( ) , GROUP_STREAM_QUEUE_SIZE ) ; final long idx = GROUP_STREAM_ITERS_ALL...
Create a new group iterator from the given stream .
138,688
private static < T > List < T > fetchFromIter ( BufferedIterator < T > iter , int fetch , int max_fetch ) { final long t0 = System . currentTimeMillis ( ) ; assert ( max_fetch >= 1 ) ; if ( fetch < 0 || fetch > max_fetch ) fetch = max_fetch ; final List < T > result = new ArrayList < > ( fetch ) ; for ( int i = 0 ; i <...
Fetch up to a given amount of items from the iterator .
138,689
public static Object loadObject ( ResourceBundle bundle , String path , boolean wipeOnFailure ) throws IOException , ClassNotFoundException { InputStream bin = null ; try { bin = bundle . getResource ( path ) ; if ( bin == null ) { return null ; } return new ObjectInputStream ( bin ) . readObject ( ) ; } catch ( Invali...
Attempts to load an object from the supplied resource bundle with the specified path .
138,690
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 .
138,691
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 .
138,692
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 , ...
Get the direction closest to the specified direction out of the directions in the possible list .
138,693
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 : ca...
Move the specified point in the specified screen direction adjusting by the specified adjustments . Fine directions are not supported .
138,694
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...
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 .
138,695
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 " + inv...
Validates the invalid components that have been queued up since the last frame tick .
138,696
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 .
138,697
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 .
138,698
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...
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 ex...
138,699
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 tr...
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 .