idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
138,800
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 ...
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 .
138,801
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 (...
Get the cached Config .
138,802
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 , "pa...
Read the data from the resource manager .
138,803
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 .
138,804
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 . ge...
Calculates the drift factor from the time elapsed from the last calibrate call .
138,805
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 [ ] value...
Adds the necessary rules to the digester to parse our classes .
138,806
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 = ListUt...
Inserts the supplied object into the set .
138,807
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 .
138,808
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 .
138,809
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 .
138,810
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 = "S...
Informs this scene block that the specified base tile has been changed .
138,811
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 .
138,812
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 ti...
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 .
138,813
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 .
138,814
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 ) ; }...
Links this block to its neighbors ; informs neighboring blocks of object coverage .
138,815
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 .
138,816
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 .
138,817
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 >...
Sets the footprint of this object tile
138,818
public static void clearEditText ( String editText ) throws Exception { Client . getInstance ( ) . map ( Constants . ROBOTIUM_SOLO , "clearEditText" , editText ) ; }
Clears edit text for the specified widget
138,819
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 loc...
Get the location of a view on the screen
138,820
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...
Applies the supplied tile operation to all tiles that intersect the supplied screen rectangle .
138,821
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...
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 .
138,822
public void release ( ) { parent = null ; id = null ; if ( values != null ) { values . clear ( ) ; } values = null ; }
Release state .
138,823
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 .
138,824
public Object getValue ( String k ) { if ( values == null ) { return null ; } else { return values . get ( k ) ; } }
Get a the value associated with a key .
138,825
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 ...
Given two points in screen pixel coordinates return the compass direction that point B lies in from point A from an isometric perspective .
138,826
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 .
138,827
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 +...
Convert the given screen - based pixel coordinates to their corresponding tile - based coordinates . Converted coordinates are placed in the given point object .
138,828
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 .
138,829
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 .
138,830
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 = ...
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 .
138,831
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 ...
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 .
138,832
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 ) ; f...
Convert the given full coordinates to screen - based pixel coordinates . Converted coordinates are placed in the given point object .
138,833
public static Polygon getTilePolygon ( MisoSceneMetrics metrics , int x , int y ) { return getFootprintPolygon ( metrics , x , y , 1 , 1 ) ; }
Return a polygon framing the specified tile .
138,834
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 ,...
Return a screen - coordinates polygon framing the two specified tile - coordinate points .
138,835
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 ...
Returns a polygon framing the specified scene footprint .
138,836
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 = fine...
Adds the supplied fine coordinates to the supplied tile coordinates to compute full coordinates .
138,837
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
138,838
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 .
138,839
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 ...
Split the text at the space nearest the specified location .
138,840
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 .
138,841
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 ....
Get a rectangle based on the old bubbles but with room for the new one .
138,842
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 . ...
Create a tail to the specified rectangular area from the speaker point .
138,843
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 ( ...
Expire a bubble if necessary and return the old bubbles for the specified speaker .
138,844
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 ...
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 .
138,845
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 a list of rectangular areas that we should avoid while laying out a bubble for the specified speaker .
138,846
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 .
138,847
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 = create...
Obtains the composited animation frames for the specified action for a character with the specified descriptor . The resulting composited animation will be cached .
138,848
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 reso...
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 .
138,849
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 .
138,850
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 [...
Set the authorize token for future requests for Basic authentication .
138,851
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 .
138,852
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 .
138,853
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 ( ) ) ) { filtere...
Filters through all views in current activity and gets those that inherit from a given class to filter by
138,854
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 ( ) ; allSt...
Searches through all views and gets those containing text which are visible . Stips the text form each view and returns it as an arraylist .
138,855
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
138,856
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 ) ; ...
Wait for a resource to become active
138,857
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
138,858
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 ( ) ...
Waits for hint text to appear in an EditText
138,859
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
138,860
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 res...
Returns a string for a resourceId in the specified namespace
138,861
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
138,862
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 .
138,863
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 .
138,864
public void setGain ( float gain ) { if ( _gain != gain ) { AL10 . alListenerf ( AL10 . AL_GAIN , _gain = gain ) ; } }
Sets the gain of the listener .
138,865
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 .
138,866
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 .
138,867
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 .
138,868
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 .
138,869
protected void clearScene ( ) { _blocks . clear ( ) ; _vizobjs . clear ( ) ; _fringes . clear ( ) ; _masks . clear ( ) ; if ( _dpanel != null ) { _dpanel . newScene ( ) ; } }
Clears out our old scene business .
138,870
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 .
138,871
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 .
138,872
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 .
138,873
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 = M...
Computes a path for the specified sprite to the specified tile coordinates .
138,874
public Point getScreenCoords ( int x , int y ) { return MisoUtil . fullToScreen ( _metrics , x , y , new Point ( ) ) ; }
Converts the supplied full coordinates to screen coordinates .
138,875
public Point getFullCoords ( int x , int y ) { return MisoUtil . screenToFull ( _metrics , x , y , new Point ( ) ) ; }
Converts the supplied screen coordinates to full coordinates .
138,876
public Point getTileCoords ( int x , int y ) { return MisoUtil . screenToTile ( _metrics , x , y , new Point ( ) ) ; }
Converts the supplied screen coordinates to tile coordinates .
138,877
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 . computeMemoryUsa...
Reports the memory usage of the resolved tiles in the current scene block .
138,878
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 )...
Called when the user presses the mouse button over an object .
138,879
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 .
138,880
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 .
138,881
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 .
138,882
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 . invalidateRegi...
Called by a scene block when it has completed its resolution process .
138,883
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 .
138,884
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 .
138,885
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 .
138,886
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 ( ! blo...
Recomputes our set of visible objects and their indicators .
138,887
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 ) ) { c...
Compute the indicators for any objects in the scene .
138,888
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 .
138,889
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 .
138,890
protected void dirtyIndicator ( SceneObjectIndicator indic ) { if ( indic != null ) { Rectangle r = indic . getBounds ( ) ; if ( r != null ) { _remgr . invalidateRegion ( r ) ; } } }
Dirties the specified indicator .
138,891
protected void changeHoverObject ( Object newHover ) { if ( newHover == _hobject ) { return ; } Object oldHover = _hobject ; _hobject = newHover ; hoverObjectChanged ( oldHover , newHover ) ; }
Change the hover object to the new object .
138,892
protected void hoverObjectChanged ( Object oldHover , Object newHover ) { if ( oldHover instanceof SceneObject ) { SceneObject oldhov = ( SceneObject ) oldHover ; if ( oldhov . setHovered ( false ) ) { _remgr . invalidateRegion ( oldhov . bounds ) ; } } if ( newHover instanceof SceneObject ) { SceneObject newhov = ( Sc...
A place for subclasses to react to the hover object changing . One of the supplied arguments may be null .
138,893
protected void getHitObjects ( DirtyItemList list , int x , int y ) { for ( SceneObject scobj : _vizobjs ) { Rectangle pbounds = scobj . bounds ; if ( ! pbounds . contains ( x , y ) ) { continue ; } if ( skipHitObject ( scobj ) ) { continue ; } if ( ! scobj . tile . hitTest ( x - pbounds . x , y - pbounds . y ) ) { con...
Adds to the supplied dirty item list all of the object tiles that are hit by the specified point ( meaning the point is contained within their bounds and intersects a non - transparent pixel in the actual object image .
138,894
protected void paintBits ( Graphics2D gfx , int layer , Rectangle dirty ) { _animmgr . paint ( gfx , layer , dirty ) ; }
We don t want sprites rendered using the standard mechanism because we intersperse them with objects in our scene and need to manage their z - order .
138,895
protected void paintDirtyItems ( Graphics2D gfx , Rectangle clip ) { _dirtySprites . clear ( ) ; _spritemgr . getIntersectingSprites ( _dirtySprites , clip ) ; int size = _dirtySprites . size ( ) ; for ( int ii = 0 ; ii < size ; ii ++ ) { Sprite sprite = _dirtySprites . get ( ii ) ; Rectangle bounds = sprite . getBound...
Renders the dirty sprites and objects in the scene to the given graphics context .
138,896
protected void paintIndicators ( Graphics2D gfx , Rectangle clip ) { if ( ! _indicatorsLaidOut ) { for ( Map . Entry < SceneObject , SceneObjectIndicator > entry : _indicators . entrySet ( ) ) { SceneObjectIndicator indic = entry . getValue ( ) ; if ( ! indic . isLaidOut ( ) ) { indic . layout ( gfx , entry . getKey ( ...
Paint all the appropriate indicators for our scene objects .
138,897
protected void paintIndicator ( Graphics2D gfx , Rectangle clip , SceneObjectIndicator tip ) { if ( clip . intersects ( tip . getBounds ( ) ) ) { tip . paint ( gfx ) ; } }
Paint the specified indicator if it intersects the clipping rectangle .
138,898
protected void paintTiles ( Graphics2D gfx , Rectangle clip ) { _paintOp . setGraphics ( gfx ) ; _applicator . applyToTiles ( clip , _paintOp ) ; _paintOp . setGraphics ( null ) ; }
Renders the base and fringe layer tiles that intersect the specified clipping rectangle .
138,899
protected void fillTile ( Graphics2D gfx , int tx , int ty , Color color ) { Composite ocomp = gfx . getComposite ( ) ; gfx . setComposite ( ALPHA_FILL_TILE ) ; Polygon poly = MisoUtil . getTilePolygon ( _metrics , tx , ty ) ; gfx . setColor ( color ) ; gfx . fill ( poly ) ; gfx . setComposite ( ocomp ) ; }
Fills the specified tile with the given color at 50% alpha . Intended for debug - only tile highlighting purposes .