idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
15,100
public void relocateObject ( MisoSceneMetrics metrics , int tx , int ty ) { info . x = tx ; info . y = ty ; computeInfo ( metrics ) ; }
Updates this object s origin tile coordinate . Its bounds and other cached screen coordinate information are updated .
15,101
protected void computeInfo ( MisoSceneMetrics metrics ) { Point tpos = MisoUtil . tileToScreen ( metrics , info . x , info . y , new Point ( ) ) ; int tox = tile . getOriginX ( ) , toy = tile . getOriginY ( ) ; if ( tox == Integer . MIN_VALUE ) { tox = tile . getBaseWidth ( ) * metrics . tilehwid ; } if ( toy == Integer . MIN_VALUE ) { toy = tile . getHeight ( ) ; } bounds = new Rectangle ( tpos . x + metrics . tilehwid - tox , tpos . y + metrics . tilehei - toy , tile . getWidth ( ) , tile . getHeight ( ) ) ; _frect = new Rectangle ( info . x - tile . getBaseWidth ( ) + 1 , info . y - tile . getBaseHeight ( ) + 1 , tile . getBaseWidth ( ) , tile . getBaseHeight ( ) ) ; _footprint = MisoUtil . getFootprintPolygon ( metrics , _frect . x , _frect . y , _frect . width , _frect . height ) ; if ( tile . hasSpot ( ) ) { _fspot = MisoUtil . tilePlusFineToFull ( metrics , info . x , info . y , tile . getSpotX ( ) , tile . getSpotY ( ) , new Point ( ) ) ; _sspot = MisoUtil . fullToScreen ( metrics , _fspot . x , _fspot . y , new Point ( ) ) ; } }
Computes our screen bounds tile footprint and other useful cached metrics .
15,102
public void run ( ) { try { Thread . sleep ( 3000 ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } subjectRepository . getSubjectsCollection ( new SubjectRepository . SubjectListCallback ( ) { public void onSubjectListLoader ( final Collection < Subject > subjects ) { mainThread . post ( new Runnable ( ) { public void run ( ) { callback . onSubjectListLoaded ( subjects ) ; } } ) ; } public void onError ( final SubjectException exception ) { mainThread . post ( new Runnable ( ) { public void run ( ) { callback . onError ( exception ) ; Log . i ( getClass ( ) . toString ( ) , "Error!" ) ; } } ) ; } } ) ; }
Interactor User case
15,103
private void fixBacklog ( ) throws IOException { try { writers . values ( ) . parallelStream ( ) . forEach ( groupWriter -> { try { groupWriter . fixBacklog ( timestamps . size ( ) ) ; } catch ( IOException ex ) { throw new RuntimeIOException ( ex ) ; } } ) ; } catch ( RuntimeIOException ex ) { throw ex . getEx ( ) ; } }
Pad all groups with empty maps to ensure it s the same size as timestamps list .
15,104
public void setPaused ( boolean paused ) { if ( ( paused && ( _pauseTime != 0 ) ) || ( ! paused && ( _pauseTime == 0 ) ) ) { log . warning ( "Requested to pause when paused or vice-versa" , "paused" , paused ) ; return ; } _paused = paused ; if ( _paused ) { _pauseTime = _framemgr . getTimeStamp ( ) ; } else { long delta = _framemgr . getTimeStamp ( ) - _pauseTime ; _animmgr . fastForward ( delta ) ; _spritemgr . fastForward ( delta ) ; _pauseTime = 0 ; } }
Pauses the sprites and animations that are currently active on this media panel . Also stops listening to the frame tick while paused .
15,105
public void paintMedia ( Graphics2D gfx , int layer , Rectangle dirty ) { if ( layer == FRONT ) { _spritemgr . paint ( gfx , layer , dirty ) ; _animmgr . paint ( gfx , layer , dirty ) ; } else { _animmgr . paint ( gfx , layer , dirty ) ; _spritemgr . paint ( gfx , layer , dirty ) ; } }
Renders the sprites and animations that intersect the supplied dirty region in the specified layer .
15,106
public void paintPerf ( Graphics2D gfx ) { if ( _perfRect != null && FrameManager . _perfDebug . getValue ( ) ) { gfx . setClip ( null ) ; _perfLabel . render ( gfx , _perfRect . x , _perfRect . y ) ; } }
Renders our performance debugging information if enabled .
15,107
public void viewLocationDidChange ( int dx , int dy ) { if ( _perfRect != null ) { Rectangle sdirty = new Rectangle ( _perfRect ) ; sdirty . translate ( - dx , - dy ) ; _remgr . addDirtyRegion ( sdirty ) ; } _animmgr . viewLocationDidChange ( dx , dy ) ; _spritemgr . viewLocationDidChange ( dx , dy ) ; }
If our host supports scrolling around in a virtual view it should call this method when the view origin changes .
15,108
public void setImage ( Mirage image ) { if ( _mirage != null ) { _totalTileMemory -= _mirage . getEstimatedMemoryUsage ( ) ; } _mirage = image ; if ( _mirage != null ) { _totalTileMemory += _mirage . getEstimatedMemoryUsage ( ) ; } }
Configures this tile with its tile image .
15,109
public void paint ( Graphics2D gfx , int x , int y ) { _mirage . paint ( gfx , x , y ) ; }
Render the tile image at the specified position in the given graphics context .
15,110
public InputStream getSound ( String bundle , String path ) throws IOException { InputStream rsrc ; try { rsrc = _rmgr . getResource ( bundle , path ) ; } catch ( FileNotFoundException notFound ) { try { rsrc = _rmgr . getResource ( path ) ; } catch ( FileNotFoundException notFoundAgain ) { throw notFound ; } } return rsrc ; }
Attempts to load a sound stream from the given path from the given bundle and from the classpath . If nothing is found a FileNotFoundException is thrown .
15,111
protected Config getConfig ( String packagePath ) { Config c = _configs . get ( packagePath ) ; if ( c == null ) { Properties props = new Properties ( ) ; String propFilename = packagePath + Sounds . PROP_NAME + ".properties" ; try { props = ConfigUtil . loadInheritedProperties ( propFilename , _rmgr . getClassLoader ( ) ) ; } catch ( IOException ioe ) { log . warning ( "Failed to load sound properties" , "filename" , propFilename , ioe ) ; } c = new Config ( props ) ; _configs . put ( packagePath , c ) ; } return c ; }
Get the cached Config .
15,112
protected byte [ ] loadClipData ( String bundle , String path ) throws IOException { InputStream clipin = null ; try { clipin = getSound ( bundle , path ) ; } catch ( FileNotFoundException fnfe ) { if ( JavaSoundPlayer . _verbose . getValue ( ) ) { log . warning ( "Could not locate sound data" , "bundle" , bundle , "path" , path ) ; if ( _defaultClipPath != null ) { try { clipin = _rmgr . getResource ( _defaultClipBundle , _defaultClipPath ) ; } catch ( FileNotFoundException fnfe3 ) { try { clipin = _rmgr . getResource ( _defaultClipPath ) ; } catch ( FileNotFoundException fnfe4 ) { log . warning ( "Additionally, the default fallback sound could not be located" , "bundle" , _defaultClipBundle , "path" , _defaultClipPath ) ; } } } else { log . warning ( "No fallback default sound specified!" ) ; } } if ( clipin == null ) { throw fnfe ; } } return StreamUtil . toByteArray ( clipin ) ; }
Read the data from the resource manager .
15,113
protected void init ( long milliDivider , long microDivider ) { _milliDivider = milliDivider ; _microDivider = microDivider ; reset ( ) ; log . info ( "Using " + getClass ( ) + " timer" , "mfreq" , _milliDivider , "ufreq" , _microDivider , "start" , _startStamp ) ; }
Initializes this timer . Must be called before the timer is used .
15,114
protected void calibrate ( ) { long currentTimer = current ( ) ; long currentMillis = System . currentTimeMillis ( ) ; long elapsedTimer = currentTimer - _driftTimerStamp ; float elapsedMillis = currentMillis - _driftMilliStamp ; float drift = elapsedMillis / ( elapsedTimer / _milliDivider ) ; if ( _debugCalibrate . getValue ( ) ) { log . warning ( "Calibrating" , "timer" , elapsedTimer , "millis" , elapsedMillis , "drift" , drift , "timerstamp" , _driftTimerStamp , "millistamp" , _driftMilliStamp , "current" , currentTimer ) ; } if ( elapsedTimer < 0 ) { log . warning ( "The timer has decided to live in the past, resetting drift" , "previousTimer" , _driftTimerStamp , "currentTimer" , currentTimer , "previousMillis" , _driftMilliStamp , "currentMillis" , currentMillis ) ; _driftRatio = 1.0F ; } else if ( drift > MAX_ALLOWED_DRIFT_RATIO || drift < MIN_ALLOWED_DRIFT_RATIO ) { log . warning ( "Calibrating" , "drift" , drift ) ; if ( drift < 100 * MAX_ALLOWED_DRIFT_RATIO && drift > MIN_ALLOWED_DRIFT_RATIO / 100 ) { _driftRatio = drift ; } else { _driftRatio = 1.0F ; } if ( Math . abs ( drift - 1.0 ) > Math . abs ( _maxDriftRatio - 1.0 ) ) { _maxDriftRatio = drift ; } } else if ( _driftRatio != 1.0 ) { log . warning ( "Calibrating" , "drift" , drift ) ; _driftRatio = 1.0F ; } _driftMilliStamp = currentMillis ; _driftTimerStamp = currentTimer ; }
Calculates the drift factor from the time elapsed from the last calibrate call .
15,115
public void addRuleInstances ( Digester digester ) { digester . addObjectCreate ( _prefix + CLASS_PATH , ComponentClass . class . getName ( ) ) ; SetPropertyFieldsRule rule = new SetPropertyFieldsRule ( ) ; rule . addFieldParser ( "shadowColor" , new FieldParser ( ) { public Object parse ( String text ) { int [ ] values = StringUtil . parseIntArray ( text ) ; return new Color ( values [ 0 ] , values [ 1 ] , values [ 2 ] , values [ 3 ] ) ; } } ) ; digester . addRule ( _prefix + CLASS_PATH , rule ) ; String opath = _prefix + CLASS_PATH + "/override" ; digester . addObjectCreate ( opath , PriorityOverride . class . getName ( ) ) ; rule = new SetPropertyFieldsRule ( ) ; rule . addFieldParser ( "orients" , new FieldParser ( ) { public Object parse ( String text ) { String [ ] orients = StringUtil . parseStringArray ( text ) ; ArrayIntSet oset = new ArrayIntSet ( ) ; for ( String orient : orients ) { oset . add ( DirectionUtil . fromShortString ( orient ) ) ; } return oset ; } } ) ; digester . addRule ( opath , rule ) ; digester . addSetNext ( opath , "addPriorityOverride" , PriorityOverride . class . getName ( ) ) ; }
Adds the necessary rules to the digester to parse our classes .
15,116
public boolean insert ( ObjectInfo info ) { int ipos = indexOf ( info ) ; if ( ipos >= 0 ) { log . warning ( "Requested to add an object to a set that already " + "contains such an object [ninfo=" + info + ", oinfo=" + _objs [ ipos ] + "]." , new Exception ( ) ) ; return false ; } ipos = - ( ipos + 1 ) ; _objs = ListUtil . insert ( _objs , ipos , info ) ; _size ++ ; return true ; }
Inserts the supplied object into the set .
15,117
public boolean remove ( ObjectInfo info ) { int opos = indexOf ( info ) ; if ( opos >= 0 ) { remove ( opos ) ; return true ; } else { return false ; } }
Removes the specified object from the set .
15,118
public ObjectInfo [ ] toArray ( ) { ObjectInfo [ ] info = new ObjectInfo [ _size ] ; System . arraycopy ( _objs , 0 , info , 0 , _size ) ; return info ; }
Converts the contents of this object set to an array .
15,119
public BaseTile getBaseTile ( int tx , int ty ) { BaseTile tile = _base [ index ( tx , ty ) ] ; if ( tile == null && _defset != null ) { tile = ( BaseTile ) _defset . getTile ( TileUtil . getTileHash ( tx , ty ) % _defset . getTileCount ( ) ) ; } return tile ; }
Returns the base tile at the specified coordinates or null if there s no tile at said coordinates .
15,120
public void updateBaseTile ( int fqTileId , int tx , int ty ) { String errmsg = null ; int tidx = index ( tx , ty ) ; try { if ( fqTileId <= 0 ) { _base [ tidx ] = null ; } else { _base [ tidx ] = ( BaseTile ) _tileMgr . getTile ( fqTileId ) ; } _fringe [ tidx ] = null ; } catch ( ClassCastException cce ) { errmsg = "Scene contains non-base tile in base layer" ; } catch ( NoSuchTileSetException nste ) { errmsg = "Scene contains non-existent tileset" ; } if ( errmsg != null ) { log . warning ( errmsg + " [fqtid=" + fqTileId + ", x=" + tx + ", y=" + ty + "]." ) ; } }
Informs this scene block that the specified base tile has been changed .
15,121
public void updateFringe ( int tx , int ty ) { int tidx = index ( tx , ty ) ; if ( _base [ tidx ] != null ) { _fringe [ tidx ] = computeFringeTile ( tx , ty ) ; } }
Instructs this block to recompute its fringe at the specified location .
15,122
public void computeMemoryUsage ( Map < Tile . Key , BaseTile > bases , Set < BaseTile > fringes , Map < Tile . Key , ObjectTile > objects , long [ ] usage ) { for ( int yy = 0 ; yy < _bounds . height ; yy ++ ) { for ( int xx = 0 ; xx < _bounds . width ; xx ++ ) { int x = _bounds . x + xx , y = _bounds . y + yy ; int tidx = index ( x , y ) ; BaseTile base = _base [ tidx ] ; if ( base == null ) { continue ; } BaseTile sbase = bases . get ( base . key ) ; if ( sbase == null ) { bases . put ( base . key , base ) ; usage [ 0 ] += base . getEstimatedMemoryUsage ( ) ; } else if ( base != _base [ tidx ] ) { log . warning ( "Multiple instances of same base tile " + "[base=" + base + ", x=" + xx + ", y=" + yy + "]." ) ; usage [ 0 ] += base . getEstimatedMemoryUsage ( ) ; } if ( _fringe [ tidx ] == null ) { continue ; } else if ( ! fringes . contains ( _fringe [ tidx ] ) ) { fringes . add ( _fringe [ tidx ] ) ; usage [ 1 ] += _fringe [ tidx ] . getEstimatedMemoryUsage ( ) ; } } } int ocount = ( _objects == null ) ? 0 : _objects . length ; for ( int ii = 0 ; ii < ocount ; ii ++ ) { SceneObject scobj = _objects [ ii ] ; ObjectTile tile = objects . get ( scobj . tile . key ) ; if ( tile == null ) { objects . put ( scobj . tile . key , scobj . tile ) ; usage [ 2 ] += scobj . tile . getEstimatedMemoryUsage ( ) ; } else if ( tile != scobj . tile ) { log . warning ( "Multiple instances of same object tile: " + scobj . info + "." ) ; usage [ 2 ] += scobj . tile . getEstimatedMemoryUsage ( ) ; } } }
Computes the memory usage of the base and object tiles in this scene block ; registering counted tiles in the hash map so that other blocks can be sure not to double count them . Base tile usage is placed into the zeroth array element fringe tile usage into the first and object tile usage into the second .
15,123
protected final int index ( int tx , int ty ) { return ( ty - _bounds . y ) * _bounds . width + ( tx - _bounds . x ) ; }
Returns the index into our arrays of the specified tile .
15,124
protected void update ( Map < Integer , SceneBlock > blocks ) { boolean recover = false ; for ( int ii = 0 ; ii < DX . length ; ii ++ ) { SceneBlock neigh = blocks . get ( neighborKey ( DX [ ii ] , DY [ ii ] ) ) ; if ( neigh != _neighbors [ ii ] ) { _neighbors [ ii ] = neigh ; recover = recover || ( neigh != null ) ; } } if ( recover ) { for ( SceneObject _object : _objects ) { setCovered ( blocks , _object ) ; } } }
Links this block to its neighbors ; informs neighboring blocks of object coverage .
15,125
protected final int neighborKey ( int dx , int dy ) { int nx = MathUtil . floorDiv ( _bounds . x , _bounds . width ) + dx ; int ny = MathUtil . floorDiv ( _bounds . y , _bounds . height ) + dy ; return MisoScenePanel . compose ( nx , ny ) ; }
Computes the key of our neighbor .
15,126
protected final int blockKey ( int tx , int ty ) { int bx = MathUtil . floorDiv ( tx , _bounds . width ) ; int by = MathUtil . floorDiv ( ty , _bounds . height ) ; return MisoScenePanel . compose ( bx , by ) ; }
Computes the key for the block that holds the specified tile .
15,127
protected void setCovered ( Map < Integer , SceneBlock > blocks , SceneObject scobj ) { int endx = scobj . info . x - scobj . tile . getBaseWidth ( ) + 1 ; int endy = scobj . info . y - scobj . tile . getBaseHeight ( ) + 1 ; for ( int xx = scobj . info . x ; xx >= endx ; xx -- ) { for ( int yy = scobj . info . y ; yy >= endy ; yy -- ) { SceneBlock block = blocks . get ( blockKey ( xx , yy ) ) ; if ( block != null ) { block . setCovered ( xx , yy ) ; } } } }
Sets the footprint of this object tile
15,128
public static void clearEditText ( String editText ) throws Exception { Client . getInstance ( ) . map ( Constants . ROBOTIUM_SOLO , "clearEditText" , editText ) ; }
Clears edit text for the specified widget
15,129
public static int [ ] getLocationOnScreen ( String view ) throws Exception { int [ ] location = new int [ 2 ] ; JSONArray results = Client . getInstance ( ) . map ( Constants . ROBOTIUM_SOLO , "getLocationOnScreen" , view ) ; location [ 0 ] = results . getInt ( 0 ) ; location [ 1 ] = results . getInt ( 1 ) ; return location ; }
Get the location of a view on the screen
15,130
public void applyToTiles ( Rectangle region , TileOp op ) { Point tpos = MisoUtil . screenToTile ( _metrics , region . x , region . y , new Point ( ) ) ; Point spos = MisoUtil . tileToScreen ( _metrics , tpos . x , tpos . y , new Point ( ) ) ; boolean left = ( region . x - spos . x < _metrics . tilehwid ) ; boolean top = ( region . y - spos . y < _metrics . tilehhei ) ; int dx , dy ; if ( left ) { dx = 0 ; dy = 1 ; } else { dx = 1 ; dy = 0 ; } if ( top ) { if ( left ) { tpos . x -= 1 ; } else { tpos . y -= 1 ; } dx = 1 - dx ; dy = 1 - dy ; } int rightx = region . x + region . width , bottomy = region . y + region . height ; MisoUtil . tileToScreen ( _metrics , tpos . x , tpos . y , spos ) ; while ( spos . y < bottomy ) { int tx = tpos . x , ty = tpos . y ; _tbounds . x = spos . x ; _tbounds . y = spos . y ; while ( _tbounds . x < rightx ) { op . apply ( tx , ty , _tbounds ) ; tx += 1 ; ty -= 1 ; _tbounds . x += _metrics . tilewid ; } tpos . x += dx ; dx = 1 - dx ; tpos . y += dy ; dy = 1 - dy ; MisoUtil . tileToScreen ( _metrics , tpos . x , tpos . y , spos ) ; } }
Applies the supplied tile operation to all tiles that intersect the supplied screen rectangle .
15,131
public static final Tag findAncestorWithClass ( Tag from , Class klass ) { boolean isInterface = false ; if ( from == null || klass == null || ( ! Tag . class . isAssignableFrom ( klass ) && ! ( isInterface = klass . isInterface ( ) ) ) ) { return null ; } for ( ; ; ) { Tag tag = from . getParent ( ) ; if ( tag == null ) { return null ; } if ( ( isInterface && klass . isInstance ( tag ) ) || klass . isAssignableFrom ( tag . getClass ( ) ) ) return tag ; else from = tag ; } }
Find the instance of a given class type that is closest to a given instance . This method uses the getParent method from the Tag interface . This method is used for coordination among cooperating tags .
15,132
public void release ( ) { parent = null ; id = null ; if ( values != null ) { values . clear ( ) ; } values = null ; }
Release state .
15,133
public void setValue ( String k , Object o ) { if ( values == null ) { values = new Hashtable < String , Object > ( ) ; } values . put ( k , o ) ; }
Associate a value with a String key .
15,134
public Object getValue ( String k ) { if ( values == null ) { return null ; } else { return values . get ( k ) ; } }
Get a the value associated with a key .
15,135
public static int getDirection ( MisoSceneMetrics metrics , int ax , int ay , int bx , int by ) { Point afpos = new Point ( ) , bfpos = new Point ( ) ; screenToFull ( metrics , ax , ay , afpos ) ; screenToFull ( metrics , bx , by , bfpos ) ; int tax = fullToTile ( afpos . x ) ; int tay = fullToTile ( afpos . y ) ; int tbx = fullToTile ( bfpos . x ) ; int tby = fullToTile ( bfpos . y ) ; int dir = getIsoDirection ( tax , tay , tbx , tby ) ; if ( dir != DirectionCodes . NONE ) { return dir ; } int fax = afpos . x - ( tax * FULL_TILE_FACTOR ) ; int fay = afpos . y - ( tay * FULL_TILE_FACTOR ) ; int fbx = bfpos . x - ( tbx * FULL_TILE_FACTOR ) ; int fby = bfpos . y - ( tby * FULL_TILE_FACTOR ) ; dir = getIsoDirection ( fax , fay , fbx , fby ) ; return ( dir == - 1 ) ? SOUTHWEST : dir ; }
Given two points in screen pixel coordinates return the compass direction that point B lies in from point A from an isometric perspective .
15,136
public static int getProjectedIsoDirection ( int ax , int ay , int bx , int by ) { return toIsoDirection ( DirectionUtil . getDirection ( ax , ay , bx , by ) ) ; }
Given two points in screen coordinates return the isometrically projected compass direction that point B lies in from point A .
15,137
public static Point screenToTile ( MisoSceneMetrics metrics , int sx , int sy , Point tpos ) { int zx = ( int ) Math . floor ( ( float ) sx / metrics . tilewid ) ; int zy = ( int ) Math . floor ( ( float ) sy / metrics . tilehei ) ; int ox = ( zx * metrics . tilewid ) , oy = ( zy * metrics . tilehei ) ; tpos . x = zy + zx ; tpos . y = zy - zx ; int dx = sx - ox , dy = sy - oy ; if ( Math . round ( metrics . slopeY * dx + metrics . tilehei ) <= dy ) { tpos . x += 1 ; } if ( Math . round ( metrics . slopeX * dx ) > dy ) { tpos . y -= 1 ; } return tpos ; }
Convert the given screen - based pixel coordinates to their corresponding tile - based coordinates . Converted coordinates are placed in the given point object .
15,138
public static Point tileToScreen ( MisoSceneMetrics metrics , int x , int y , Point spos ) { spos . x = ( x - y - 1 ) * metrics . tilehwid ; spos . y = ( x + y ) * metrics . tilehhei ; return spos ; }
Convert the given tile - based coordinates to their corresponding screen - based pixel coordinates . The screen coordinate for a tile is the upper - left coordinate of the rectangle that bounds the tile polygon . Converted coordinates are placed in the given point object .
15,139
public static void fineToPixel ( MisoSceneMetrics metrics , int x , int y , Point ppos ) { ppos . x = metrics . tilehwid + ( ( x - y ) * metrics . finehwid ) ; ppos . y = ( x + y ) * metrics . finehhei ; }
Convert the given fine coordinates to pixel coordinates within the containing tile . Converted coordinates are placed in the given point object .
15,140
public static void pixelToFine ( MisoSceneMetrics metrics , int x , int y , Point fpos ) { float bY = y - ( metrics . fineSlopeY * x ) ; int crossx = ( int ) ( ( bY - metrics . fineBX ) / ( metrics . fineSlopeX - metrics . fineSlopeY ) ) ; int crossy = ( int ) ( ( metrics . fineSlopeY * crossx ) + bY ) ; float xdist = MathUtil . distance ( metrics . tilehwid , 0 , crossx , crossy ) ; fpos . x = ( int ) ( xdist / metrics . finelen ) ; float ydist = MathUtil . distance ( x , y , crossx , crossy ) ; fpos . y = ( int ) ( ydist / metrics . finelen ) ; }
Convert the given pixel coordinates whose origin is at the top - left of a tile s containing rectangle to fine coordinates within that tile . Converted coordinates are placed in the given point object .
15,141
public static Point screenToFull ( MisoSceneMetrics metrics , int sx , int sy , Point fpos ) { Point tpos = new Point ( ) ; screenToTile ( metrics , sx , sy , tpos ) ; Point spos = tileToScreen ( metrics , tpos . x , tpos . y , new Point ( ) ) ; pixelToFine ( metrics , sx - spos . x , sy - spos . y , fpos ) ; fpos . x += ( tpos . x * FULL_TILE_FACTOR ) ; fpos . y += ( tpos . y * FULL_TILE_FACTOR ) ; return fpos ; }
Convert the given screen - based pixel coordinates to full scene - based coordinates that include both the tile coordinates and the fine coordinates in each dimension . Converted coordinates are placed in the given point object .
15,142
public static Point fullToScreen ( MisoSceneMetrics metrics , int x , int y , Point spos ) { int tx = fullToTile ( x ) , ty = fullToTile ( y ) ; Point tspos = tileToScreen ( metrics , tx , ty , new Point ( ) ) ; Point ppos = new Point ( ) ; int fx = x - ( tx * FULL_TILE_FACTOR ) , fy = y - ( ty * FULL_TILE_FACTOR ) ; fineToPixel ( metrics , fx , fy , ppos ) ; spos . x = tspos . x + ppos . x ; spos . y = tspos . y + ppos . y ; return spos ; }
Convert the given full coordinates to screen - based pixel coordinates . Converted coordinates are placed in the given point object .
15,143
public static Polygon getTilePolygon ( MisoSceneMetrics metrics , int x , int y ) { return getFootprintPolygon ( metrics , x , y , 1 , 1 ) ; }
Return a polygon framing the specified tile .
15,144
public static Polygon getMultiTilePolygon ( MisoSceneMetrics metrics , Point sp1 , Point sp2 ) { int x = Math . min ( sp1 . x , sp2 . x ) , y = Math . min ( sp1 . y , sp2 . y ) ; int width = Math . abs ( sp1 . x - sp2 . x ) + 1 , height = Math . abs ( sp1 . y - sp2 . y ) + 1 ; return getFootprintPolygon ( metrics , x , y , width , height ) ; }
Return a screen - coordinates polygon framing the two specified tile - coordinate points .
15,145
public static Polygon getFootprintPolygon ( MisoSceneMetrics metrics , int x , int y , int width , int height ) { SmartPolygon footprint = new SmartPolygon ( ) ; Point tpos = MisoUtil . tileToScreen ( metrics , x , y , new Point ( ) ) ; int rx = tpos . x + metrics . tilehwid , ry = tpos . y ; footprint . addPoint ( rx , ry ) ; rx += width * metrics . tilehwid ; ry += width * metrics . tilehhei ; footprint . addPoint ( rx , ry ) ; rx -= height * metrics . tilehwid ; ry += height * metrics . tilehhei ; footprint . addPoint ( rx , ry ) ; rx -= width * metrics . tilehwid ; ry -= width * metrics . tilehhei ; footprint . addPoint ( rx , ry ) ; rx += height * metrics . tilehwid ; ry -= height * metrics . tilehhei ; footprint . addPoint ( rx , ry ) ; return footprint ; }
Returns a polygon framing the specified scene footprint .
15,146
public static Point tilePlusFineToFull ( MisoSceneMetrics metrics , int tileX , int tileY , int fineX , int fineY , Point full ) { int dtx = fineX / metrics . finegran ; int dty = fineY / metrics . finegran ; int fx = fineX - dtx * metrics . finegran ; if ( fx < 0 ) { dtx -- ; fx += metrics . finegran ; } int fy = fineY - dty * metrics . finegran ; if ( fy < 0 ) { dty -- ; fy += metrics . finegran ; } full . x = toFull ( tileX + dtx , fx ) ; full . y = toFull ( tileY + dty , fy ) ; return full ; }
Adds the supplied fine coordinates to the supplied tile coordinates to compute full coordinates .
15,147
public static Client getInstance ( ) { if ( instance == null ) { instance = new Client ( ) ; } instance . API_PORT = PortSingleton . getInstance ( ) . getPort ( ) ; return instance ; }
Gets a client instance on the roboremote port
15,148
protected void clearBubbles ( boolean all ) { for ( Iterator < BubbleGlyph > iter = _bubbles . iterator ( ) ; iter . hasNext ( ) ; ) { ChatGlyph rec = iter . next ( ) ; if ( all || isPlaceOrientedType ( rec . getType ( ) ) ) { _target . abortAnimation ( rec ) ; iter . remove ( ) ; } } }
Clear chat bubbles either all of them or just the place - oriented ones .
15,149
protected String splitNear ( String text , int pos ) { if ( pos >= text . length ( ) ) { return text ; } int forward = text . indexOf ( ' ' , pos ) ; int backward = text . lastIndexOf ( ' ' , pos ) ; int newpos = ( Math . abs ( pos - forward ) < Math . abs ( pos - backward ) ) ? forward : backward ; if ( newpos == - 1 ) { newpos = pos ; } else { newpos ++ ; } return text . substring ( 0 , newpos ) ; }
Split the text at the space nearest the specified location .
15,150
protected Point adjustLabel ( int type , Point labelpos ) { switch ( ChatLogic . modeOf ( type ) ) { case ChatLogic . SHOUT : case ChatLogic . EMOTE : case ChatLogic . THINK : labelpos . translate ( PAD * 2 , PAD * 2 ) ; break ; default : labelpos . translate ( PAD , PAD ) ; break ; } return labelpos ; }
Position the label based on the type .
15,151
protected Rectangle getRectWithOlds ( Rectangle r , List < BubbleGlyph > oldbubs ) { int n = oldbubs . size ( ) ; if ( n == 0 ) { return r ; } Rectangle bigR = null ; for ( int ii = 0 ; ii < n ; ii ++ ) { BubbleGlyph bub = oldbubs . get ( ii ) ; if ( ii == 0 ) { bigR = bub . getBubbleBounds ( ) ; } else { bigR = bigR . union ( bub . getBubbleBounds ( ) ) ; } } bigR . width = Math . max ( bigR . width , r . width ) ; bigR . height += r . height ; return bigR ; }
Get a rectangle based on the old bubbles but with room for the new one .
15,152
protected Shape getTail ( int type , Rectangle r , Point speaker ) { if ( ChatLogic . modeOf ( type ) == ChatLogic . EMOTE ) { return new Area ( ) ; } int midx = r . x + ( r . width / 2 ) ; int midy = r . y + ( r . height / 2 ) ; int xx = speaker . x - midx ; int yy = speaker . y - midy ; float dist = ( float ) Math . sqrt ( xx * xx + yy * yy ) ; float perc = ( dist - SPEAKER_DISTANCE ) / dist ; if ( ChatLogic . modeOf ( type ) == ChatLogic . THINK ) { int steps = Math . max ( ( int ) ( dist / SPEAKER_DISTANCE ) , 2 ) ; float step = perc / steps ; Area a = new Area ( ) ; for ( int ii = 0 ; ii < steps ; ii ++ , perc -= step ) { int radius = Math . min ( SPEAKER_DISTANCE / 2 - 1 , ii + 2 ) ; a . add ( new Area ( new Ellipse2D . Float ( ( int ) ( ( 1 - perc ) * midx + perc * speaker . x ) + perc * radius , ( int ) ( ( 1 - perc ) * midy + perc * speaker . y ) + perc * radius , radius * 2 , radius * 2 ) ) ) ; } return a ; } Polygon p = new Polygon ( ) ; p . addPoint ( ( int ) ( ( 1 - perc ) * midx + perc * speaker . x ) , ( int ) ( ( 1 - perc ) * midy + perc * speaker . y ) ) ; if ( Math . abs ( speaker . x - midx ) > Math . abs ( speaker . y - midy ) ) { int x ; if ( midx > speaker . x ) { x = r . x + PAD ; } else { x = r . x + r . width - PAD ; } p . addPoint ( x , midy - ( TAIL_WIDTH / 2 ) ) ; p . addPoint ( x , midy + ( TAIL_WIDTH / 2 ) ) ; } else { int y ; if ( midy > speaker . y ) { y = r . y + PAD ; } else { y = r . y + r . height - PAD ; } p . addPoint ( midx - ( TAIL_WIDTH / 2 ) , y ) ; p . addPoint ( midx + ( TAIL_WIDTH / 2 ) , y ) ; } return p ; }
Create a tail to the specified rectangular area from the speaker point .
15,153
protected List < BubbleGlyph > getAndExpireBubbles ( Name speaker ) { int num = _bubbles . size ( ) ; List < BubbleGlyph > oldbubs = Lists . newArrayList ( ) ; if ( speaker != null ) { for ( int ii = 0 ; ii < num ; ii ++ ) { BubbleGlyph bub = _bubbles . get ( ii ) ; if ( bub . isSpeaker ( speaker ) ) { oldbubs . add ( bub ) ; } } } if ( oldbubs . size ( ) >= MAX_BUBBLES_PER_USER ) { BubbleGlyph bub = oldbubs . remove ( 0 ) ; _bubbles . remove ( bub ) ; _target . abortAnimation ( bub ) ; } else if ( num >= MAX_BUBBLES ) { _target . abortAnimation ( _bubbles . remove ( 0 ) ) ; } return oldbubs ; }
Expire a bubble if necessary and return the old bubbles for the specified speaker .
15,154
protected Label layoutText ( Graphics2D gfx , Font font , String text ) { Label label = _logic . createLabel ( text ) ; label . setFont ( font ) ; Rectangle vbounds = _target . getViewBounds ( ) ; label . setTargetWidth ( vbounds . width - PAD * 2 ) ; label . layout ( gfx ) ; Dimension d = label . getSize ( ) ; if ( d . width > MINIMUM_SPLIT_WIDTH ) { int targetheight = getGoldenLabelHeight ( d ) ; if ( targetheight > 1 ) { label . setTargetHeight ( targetheight * d . height ) ; label . layout ( gfx ) ; } } return label ; }
Get a label formatted as close to the golden ratio as possible for the specified text and given the standard padding we use on all bubbles .
15,155
protected List < Shape > getAvoidList ( Name speaker ) { List < Shape > avoid = Lists . newArrayList ( ) ; if ( _provider == null ) { return avoid ; } _provider . getAvoidables ( speaker , avoid , null ) ; for ( BubbleGlyph bub : _bubbles ) { if ( ! bub . isSpeaker ( speaker ) ) { avoid . add ( bub . getBubbleTerritory ( ) ) ; } } return avoid ; }
Return a list of rectangular areas that we should avoid while laying out a bubble for the specified speaker .
15,156
public void queueFile ( File file , boolean loop ) { try { queueURL ( file . toURI ( ) . toURL ( ) , loop ) ; } catch ( MalformedURLException e ) { log . warning ( "Invalid file url." , "file" , file , e ) ; } }
Adds a file to the queue of files to play .
15,157
public ActionFrames getActionFrames ( CharacterDescriptor descrip , String action ) throws NoSuchComponentException { Tuple < CharacterDescriptor , String > key = new Tuple < CharacterDescriptor , String > ( descrip , action ) ; ActionFrames frames = _actionFrames . get ( key ) ; if ( frames == null ) { frames = createCompositeFrames ( descrip , action ) ; _actionFrames . put ( key , frames ) ; } if ( ! _cacheStatThrottle . throttleOp ( ) ) { long size = getEstimatedCacheMemoryUsage ( ) ; int [ ] eff = _frameCache . getTrackedEffectiveness ( ) ; log . debug ( "CharacterManager LRU [mem=" + ( size / 1024 ) + "k" + ", size=" + _frameCache . size ( ) + ", hits=" + eff [ 0 ] + ", misses=" + eff [ 1 ] + "]." ) ; } return frames ; }
Obtains the composited animation frames for the specified action for a character with the specified descriptor . The resulting composited animation will be cached .
15,158
public void resolveActionSequence ( CharacterDescriptor desc , String action ) { try { if ( getActionFrames ( desc , action ) == null ) { log . warning ( "Failed to resolve action sequence " + "[desc=" + desc + ", action=" + action + "]." ) ; } } catch ( NoSuchComponentException nsce ) { log . warning ( "Failed to resolve action sequence " + "[nsce=" + nsce + "]." ) ; } }
Informs the character manager that the action sequence for the given character descriptor is likely to be needed in the near future and so any efforts that can be made to load it into the action sequence cache in advance should be undertaken .
15,159
protected long getEstimatedCacheMemoryUsage ( ) { long size = 0 ; Iterator < CompositedMultiFrameImage > iter = _frameCache . values ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { size += iter . next ( ) . getEstimatedMemoryUsage ( ) ; } return size ; }
Returns the estimated memory usage in bytes for all images currently cached by the cached action frames .
15,160
public void processAuthorize ( WebSocketChannel channel , String authorizeToken ) { LOG . entering ( CLASS_NAME , "processAuthorize" ) ; WebSocketNativeChannel nativeChannel = ( WebSocketNativeChannel ) channel ; Proxy proxy = nativeChannel . getProxy ( ) ; proxy . processEvent ( XoaEventKind . AUTHORIZE , new String [ ] { authorizeToken } ) ; }
Set the authorize token for future requests for Basic authentication .
15,161
public static int byteArrayToInt ( byte [ ] b , int offset ) { int value = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { int shift = ( 4 - 1 - i ) * 8 ; value += ( b [ i + offset ] & 0x000000FF ) << shift ; } return value ; }
Convert the byte array to an int starting from the given offset .
15,162
public void setZations ( byte primary , byte secondary , byte tertiary , byte quaternary ) { zations = ( primary | ( secondary << 16 ) | ( tertiary << 24 ) | ( quaternary << 8 ) ) ; }
Sets the primary and secondary colorization assignments .
15,163
public < T extends View > ArrayList < T > getFilteredViews ( Class < T > classToFilterBy ) { ArrayList < T > filteredViews = new ArrayList < T > ( ) ; List < View > allViews = this . getViews ( ) ; for ( View view : allViews ) { if ( view != null && classToFilterBy . isAssignableFrom ( view . getClass ( ) ) ) { filteredViews . add ( classToFilterBy . cast ( view ) ) ; } } return filteredViews ; }
Filters through all views in current activity and gets those that inherit from a given class to filter by
15,164
public ArrayList < String > getVisibleText ( ) { ArrayList < TextView > textViews = getFilteredViews ( TextView . class ) ; ArrayList < String > allStrings = new ArrayList < String > ( ) ; for ( TextView v : textViews ) { if ( v . getVisibility ( ) == View . VISIBLE ) { String s = v . getText ( ) . toString ( ) ; allStrings . add ( s ) ; } } return allStrings ; }
Searches through all views and gets those containing text which are visible . Stips the text form each view and returns it as an arraylist .
15,165
public View getView ( int id , int timeout ) { View v = null ; int RETRY_PERIOD = 250 ; int retryNum = timeout / RETRY_PERIOD ; for ( int i = 0 ; i < retryNum ; i ++ ) { try { v = super . getView ( id ) ; } catch ( Exception e ) { } if ( v != null ) { break ; } this . sleep ( RETRY_PERIOD ) ; } return v ; }
Extend the normal robotium getView to retry every 250ms over 10s to get the view requested
15,166
public < T > boolean waitForResource ( int res , int timeout ) { int RETRY_PERIOD = 250 ; int retryNum = timeout / RETRY_PERIOD ; for ( int i = 0 ; i < retryNum ; i ++ ) { T View = ( T ) this . getView ( res ) ; if ( View != null ) { break ; } if ( i == retryNum - 1 ) { return false ; } this . sleep ( RETRY_PERIOD ) ; } return true ; }
Wait for a resource to become active
15,167
public ArrayList < View > getCustomViews ( String viewName ) { ArrayList < View > returnViews = new ArrayList < View > ( ) ; for ( View v : this . getViews ( ) ) { if ( v . getClass ( ) . getSimpleName ( ) . equals ( viewName ) ) returnViews . add ( v ) ; } return returnViews ; }
Gets views with a custom class name
15,168
public void waitForHintText ( String hintText , int timeout ) throws Exception { int RETRY_PERIOD = 250 ; int retryNum = timeout / RETRY_PERIOD ; for ( int i = 0 ; i < retryNum ; i ++ ) { ArrayList < View > imageViews = getCustomViews ( "EditText" ) ; for ( View v : imageViews ) { if ( ( ( EditText ) v ) . getHint ( ) == null ) continue ; if ( ( ( EditText ) v ) . getHint ( ) . equals ( hintText ) && v . getVisibility ( ) == View . VISIBLE ) return ; } this . sleep ( RETRY_PERIOD ) ; } throw new Exception ( String . format ( "Splash screen didn't disappear after %d ms" , timeout ) ) ; }
Waits for hint text to appear in an EditText
15,169
public void enterTextAndWait ( int fieldResource , String value ) { EditText textBox = ( EditText ) this . getView ( fieldResource ) ; this . enterText ( textBox , value ) ; this . waitForText ( value ) ; }
Enter text into a given field resource id
15,170
public String getLocalizedResource ( String namespace , String resourceId ) throws Exception { String resourceValue = "" ; Class r = Class . forName ( namespace + "$string" ) ; Field f = r . getField ( resourceId ) ; resourceValue = getCurrentActivity ( ) . getResources ( ) . getString ( f . getInt ( f ) ) ; return resourceValue ; }
Returns a string for a resourceId in the specified namespace
15,171
public String [ ] getLocalizedResourceArray ( String namespace , String resourceId ) throws Exception { Class r = Class . forName ( namespace + "$string" ) ; Field f = r . getField ( resourceId ) ; return getCurrentActivity ( ) . getResources ( ) . getStringArray ( f . getInt ( f ) ) ; }
Returns a string array for a specified string - array resourceId in the specified namespace
15,172
public void setPosition ( float x , float y , float z ) { if ( _px != x || _py != y || _pz != z ) { AL10 . alListener3f ( AL10 . AL_POSITION , _px = x , _py = y , _pz = z ) ; } }
Sets the position of the listener .
15,173
public void setVelocity ( float x , float y , float z ) { if ( _vx != x || _vy != y || _vz != z ) { AL10 . alListener3f ( AL10 . AL_VELOCITY , _vx = x , _vy = y , _vz = z ) ; } }
Sets the velocity of the listener .
15,174
public void setGain ( float gain ) { if ( _gain != gain ) { AL10 . alListenerf ( AL10 . AL_GAIN , _gain = gain ) ; } }
Sets the gain of the listener .
15,175
public boolean matches ( float [ ] hsv , int [ ] fhsv ) { if ( distance ( fhsv [ 0 ] , _fhsv [ 0 ] , Short . MAX_VALUE ) > range [ 0 ] * Short . MAX_VALUE ) { return false ; } if ( Math . abs ( _hsv [ 1 ] - hsv [ 1 ] ) > range [ 1 ] || Math . abs ( _hsv [ 2 ] - hsv [ 2 ] ) > range [ 2 ] ) { return false ; } return true ; }
Returns true if this colorization matches the supplied color false otherwise .
15,176
public static int [ ] toFixedHSV ( float [ ] hsv , int [ ] fhsv ) { if ( fhsv == null ) { fhsv = new int [ hsv . length ] ; } for ( int ii = 0 ; ii < hsv . length ; ii ++ ) { fhsv [ ii ] = ( int ) ( hsv [ ii ] * Short . MAX_VALUE ) ; } return fhsv ; }
Converts floating point HSV values to a fixed point integer representation .
15,177
public static int distance ( int a , int b , int N ) { return ( a > b ) ? Math . min ( a - b , b + N - a ) : Math . min ( b - a , a + N - b ) ; }
Returns the distance between the supplied to numbers modulo N .
15,178
public void setSceneModel ( MisoSceneModel model ) { _model = model ; clearScene ( ) ; centerOnTile ( 0 , 0 ) ; if ( isShowing ( ) ) { rethink ( ) ; _remgr . invalidateRegion ( _vbounds ) ; } }
Configures this display with a scene model which will immediately be resolved and displayed .
15,179
protected void clearScene ( ) { _blocks . clear ( ) ; _vizobjs . clear ( ) ; _fringes . clear ( ) ; _masks . clear ( ) ; if ( _dpanel != null ) { _dpanel . newScene ( ) ; } }
Clears out our old scene business .
15,180
public void centerOnTile ( int tx , int ty ) { Rectangle trect = MisoUtil . getTilePolygon ( _metrics , tx , ty ) . getBounds ( ) ; int nx = trect . x + trect . width / 2 - _vbounds . width / 2 ; int ny = trect . y + trect . height / 2 - _vbounds . height / 2 ; setViewLocation ( nx , ny ) ; }
Moves the scene such that the specified tile is in the center .
15,181
protected void showFlagsDidChange ( int oldflags ) { if ( ( oldflags & SHOW_TIPS ) != ( _showFlags & SHOW_TIPS ) ) { for ( SceneObjectIndicator indic : _indicators . values ( ) ) { dirtyIndicator ( indic ) ; } } }
Called when our show flags have changed .
15,182
public SceneBlock getBlock ( int tx , int ty ) { int bx = MathUtil . floorDiv ( tx , _metrics . blockwid ) ; int by = MathUtil . floorDiv ( ty , _metrics . blockhei ) ; return _blocks . get ( compose ( bx , by ) ) ; }
Returns the resolved block that contains the specified tile coordinate or null if no block is resolved for that coordinate .
15,183
public Path getPath ( Sprite sprite , int x , int y , boolean loose ) { if ( sprite == null ) { throw new IllegalArgumentException ( "Can't get path for null sprite [x=" + x + ", y=" + y + "." ) ; } Point src = MisoUtil . screenToTile ( _metrics , sprite . getX ( ) , sprite . getY ( ) , new Point ( ) ) ; Point dest = MisoUtil . screenToTile ( _metrics , x , y , new Point ( ) ) ; int longestPath = 3 * ( getWidth ( ) / _metrics . tilewid ) ; long start = System . currentTimeMillis ( ) ; List < Point > points = AStarPathUtil . getPath ( this , sprite , longestPath , src . x , src . y , dest . x , dest . y , loose ) ; long duration = System . currentTimeMillis ( ) - start ; if ( duration > 500L ) { int considered = AStarPathUtil . getConsidered ( ) ; log . warning ( "Considered " + considered + " nodes for path from " + StringUtil . toString ( src ) + " to " + StringUtil . toString ( dest ) + " [duration=" + duration + "]." ) ; } return ( points == null ) ? null : new TilePath ( _metrics , sprite , points , x , y ) ; }
Computes a path for the specified sprite to the specified tile coordinates .
15,184
public Point getScreenCoords ( int x , int y ) { return MisoUtil . fullToScreen ( _metrics , x , y , new Point ( ) ) ; }
Converts the supplied full coordinates to screen coordinates .
15,185
public Point getFullCoords ( int x , int y ) { return MisoUtil . screenToFull ( _metrics , x , y , new Point ( ) ) ; }
Converts the supplied screen coordinates to full coordinates .
15,186
public Point getTileCoords ( int x , int y ) { return MisoUtil . screenToTile ( _metrics , x , y , new Point ( ) ) ; }
Converts the supplied screen coordinates to tile coordinates .
15,187
public void reportMemoryUsage ( ) { Map < Tile . Key , BaseTile > base = Maps . newHashMap ( ) ; Set < BaseTile > fringe = Sets . newHashSet ( ) ; Map < Tile . Key , ObjectTile > object = Maps . newHashMap ( ) ; long [ ] usage = new long [ 3 ] ; for ( SceneBlock block : _blocks . values ( ) ) { block . computeMemoryUsage ( base , fringe , object , usage ) ; } log . info ( "Scene tile memory usage" , "scene" , StringUtil . shortClassName ( this ) , "base" , base . size ( ) + "->" + ( usage [ 0 ] / 1024 ) + "k" , "fringe" , fringe . size ( ) + "->" + ( usage [ 1 ] / 1024 ) + "k" , "obj" , object . size ( ) + "->" + ( usage [ 2 ] / 1024 ) + "k" ) ; }
Reports the memory usage of the resolved tiles in the current scene block .
15,188
protected void handleObjectPressed ( final SceneObject scobj , int mx , int my ) { String action = scobj . info . action ; final ObjectActionHandler handler = ObjectActionHandler . lookup ( action ) ; if ( handler == null ) { fireObjectAction ( null , scobj , new SceneObjectActionEvent ( this , 0 , action , 0 , scobj ) ) ; return ; } if ( ! handler . actionAllowed ( action ) ) { return ; } RadialMenu menu = handler . handlePressed ( scobj ) ; if ( menu == null ) { fireObjectAction ( handler , scobj , new SceneObjectActionEvent ( this , 0 , action , 0 , scobj ) ) ; return ; } Rectangle mbounds = getRadialMenuBounds ( scobj ) ; _activeMenu = menu ; _activeMenu . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { if ( e instanceof CommandEvent ) { fireObjectAction ( handler , scobj , e ) ; } else { SceneObjectActionEvent event = new SceneObjectActionEvent ( e . getSource ( ) , e . getID ( ) , e . getActionCommand ( ) , e . getModifiers ( ) , scobj ) ; fireObjectAction ( handler , scobj , event ) ; } } } ) ; _activeMenu . activate ( this , mbounds , scobj ) ; }
Called when the user presses the mouse button over an object .
15,189
protected void fireObjectAction ( ObjectActionHandler handler , SceneObject scobj , ActionEvent event ) { if ( handler == null ) { Controller . postAction ( event ) ; } else { handler . handleAction ( scobj , event ) ; } }
Called when an object or object menu item has been clicked .
15,190
protected void appendDirtySprite ( DirtyItemList list , Sprite sprite ) { MisoUtil . screenToTile ( _metrics , sprite . getX ( ) , sprite . getY ( ) , _tcoords ) ; list . appendDirtySprite ( sprite , _tcoords . x , _tcoords . y ) ; }
Computes the tile coordinates of the supplied sprite and appends it to the supplied dirty item list .
15,191
protected void blockAbandoned ( SceneBlock block ) { if ( _dpanel != null ) { _dpanel . blockCleared ( block ) ; } blockFinished ( block ) ; }
Called by the scene block if it has come up for resolution but is no longer influential .
15,192
protected void blockResolved ( SceneBlock block ) { if ( _dpanel != null ) { _dpanel . resolvedBlock ( block ) ; } Rectangle sbounds = block . getScreenBounds ( ) ; if ( ! _delayRepaint && sbounds != null && sbounds . intersects ( _vbounds ) ) { if ( _pendingBlocks > 1 ) { recomputeVisible ( ) ; _remgr . invalidateRegion ( sbounds ) ; } } blockFinished ( block ) ; }
Called by a scene block when it has completed its resolution process .
15,193
protected void blockFinished ( SceneBlock block ) { -- _pendingBlocks ; if ( _visiBlocks . remove ( block ) && _visiBlocks . size ( ) == 0 ) { allBlocksFinished ( ) ; } }
Called whenever a block is done resolving whether it was successfully resolved or if it was abandoned .
15,194
protected void allBlocksFinished ( ) { recomputeVisible ( ) ; log . info ( "Restoring repaint... " , "left" , _pendingBlocks , "view" , StringUtil . toString ( _vbounds ) ) ; _delayRepaint = false ; setVisible ( true ) ; _remgr . invalidateRegion ( _vbounds ) ; }
Called to handle the proceedings once our last resolving block has been finished .
15,195
protected void warnVisible ( SceneBlock block , Rectangle sbounds ) { log . warning ( "Block visible during resolution " + block + " sbounds:" + StringUtil . toString ( sbounds ) + " vbounds:" + StringUtil . toString ( _vbounds ) + "." ) ; }
Issues a warning to the error log that the specified block became visible prior to being resolved . Derived classes may wish to augment or inhibit this warning .
15,196
protected void recomputeVisible ( ) { _vizobjs . clear ( ) ; Rectangle vbounds = new Rectangle ( _vbounds . x - _metrics . tilewid , _vbounds . y - _metrics . tilehei , _vbounds . width + 2 * _metrics . tilewid , _vbounds . height + 2 * _metrics . tilehei ) ; for ( SceneBlock block : _blocks . values ( ) ) { if ( ! block . isResolved ( ) ) { continue ; } block . update ( _blocks ) ; SceneObject [ ] objs = block . getObjects ( ) ; for ( SceneObject obj : objs ) { if ( obj . bounds != null && vbounds . intersects ( obj . bounds ) ) { _vizobjs . add ( obj ) ; } } } computeIndicators ( ) ; }
Recomputes our set of visible objects and their indicators .
15,197
public void computeIndicators ( ) { Map < SceneObject , SceneObjectIndicator > _unupdated = Maps . newHashMap ( _indicators ) ; for ( int ii = 0 , nn = _vizobjs . size ( ) ; ii < nn ; ii ++ ) { SceneObject scobj = _vizobjs . get ( ii ) ; String action = scobj . info . action ; if ( StringUtil . isBlank ( action ) ) { continue ; } ObjectActionHandler oah = ObjectActionHandler . lookup ( action ) ; if ( oah != null && ! oah . isVisible ( action ) ) { continue ; } String tiptext = getTipText ( scobj , action ) ; if ( tiptext != null ) { Icon icon = getTipIcon ( scobj , action ) ; SceneObjectIndicator indic = _unupdated . remove ( scobj ) ; if ( indic == null ) { if ( oah != null ) { indic = oah . createIndicator ( this , tiptext , icon ) ; } else { indic = new SceneObjectTip ( tiptext , icon ) ; } _indicators . put ( scobj , indic ) ; } else { indic . update ( icon , tiptext ) ; } dirtyIndicator ( indic ) ; } } for ( SceneObject toremove : _unupdated . keySet ( ) ) { SceneObjectIndicator indic = _indicators . remove ( toremove ) ; indic . removed ( ) ; dirtyIndicator ( indic ) ; } _indicatorsLaidOut = false ; }
Compute the indicators for any objects in the scene .
15,198
protected String getTipText ( SceneObject scobj , String action ) { ObjectActionHandler oah = ObjectActionHandler . lookup ( action ) ; return ( oah == null ) ? action : oah . getTipText ( action ) ; }
Derived classes can provide human readable object tips via this method .
15,199
protected Icon getTipIcon ( SceneObject scobj , String action ) { ObjectActionHandler oah = ObjectActionHandler . lookup ( action ) ; return ( oah == null ) ? null : oah . getTipIcon ( action ) ; }
Provides an icon for this tooltip the default looks up an object action handler for the action and requests the icon from it .