idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
3,300 | public static Animation createAnimation ( XmlReader node ) { Check . notNull ( node ) ; final String name = node . readString ( ANIMATION_NAME ) ; final int start = node . readInteger ( ANIMATION_START ) ; final int end = node . readInteger ( ANIMATION_END ) ; final double speed = node . readDouble ( ANIMATION_SPEED ) ... | Create animation data from node . |
3,301 | public static void exports ( Xml root , Animation animation ) { Check . notNull ( root ) ; Check . notNull ( animation ) ; final Xml node = root . createChild ( ANIMATION ) ; node . writeString ( ANIMATION_NAME , animation . getName ( ) ) ; node . writeInteger ( ANIMATION_START , animation . getFirst ( ) ) ; node . wri... | Create an XML node from an animation . |
3,302 | public Animation getAnimation ( String name ) { final Animation animation = animations . get ( name ) ; if ( animation == null ) { throw new LionEngineException ( ERROR_NOT_FOUND + name ) ; } return animation ; } | Get an animation data from its name . |
3,303 | public void update ( Viewer viewer ) { x = ( int ) viewer . getX ( ) ; y = ( int ) viewer . getY ( ) - viewer . getViewY ( ) ; height = viewer . getHeight ( ) ; } | Update game text to store current location view . |
3,304 | public static final synchronized void terminate ( ) { if ( started ) { engine . close ( ) ; started = false ; Verbose . info ( ENGINE_TERMINATED ) ; engine . postClose ( ) ; engine = null ; } } | Terminate the engine . It is necessary to call this function only if the engine need to be started again during the same JVM execution . Does nothing if engine is not started . |
3,305 | private static void appendDate ( StringBuilder message ) { final String date = DATE_TIME_FORMAT . format ( Calendar . getInstance ( ) . getTime ( ) ) ; message . append ( date ) ; message . append ( Constant . SPACE ) ; } | Append date . |
3,306 | private static void appendLevel ( StringBuilder message , LogRecord event ) { final String logLevel = event . getLevel ( ) . getName ( ) ; for ( int i = logLevel . length ( ) ; i < LOG_LEVEL_LENGTH ; i ++ ) { message . append ( Constant . SPACE ) ; } message . append ( logLevel ) . append ( Constant . DOUBLE_DOT ) ; } | Append log level . |
3,307 | private static void appendFunction ( StringBuilder message , LogRecord event ) { final String clazz = event . getSourceClassName ( ) ; if ( clazz != null ) { message . append ( IN ) . append ( clazz ) ; } final String function = event . getSourceMethodName ( ) ; if ( function != null ) { message . append ( AT ) . appen... | Append function location . |
3,308 | private static void appendThrown ( StringBuilder message , LogRecord event ) { final Throwable thrown = event . getThrown ( ) ; if ( thrown != null ) { final StringWriter sw = new StringWriter ( ) ; thrown . printStackTrace ( new PrintWriter ( sw ) ) ; message . append ( sw ) ; } } | Append thrown exception trace . |
3,309 | public static Optional < Coord > intersection ( Line l1 , Line l2 ) { Check . notNull ( l1 ) ; Check . notNull ( l2 ) ; final double x1 = l1 . getX1 ( ) ; final double x2 = l1 . getX2 ( ) ; final double y1 = l1 . getY1 ( ) ; final double y2 = l1 . getY2 ( ) ; final double x3 = l2 . getX1 ( ) ; final double x4 = l2 . ge... | Get the intersection point of two lines . |
3,310 | public static Area createArea ( double x , double y , double width , double height ) { return new AreaImpl ( x , y , width , height ) ; } | Create an area . |
3,311 | public static boolean same ( Localizable a , Localizable b ) { return Double . compare ( a . getX ( ) , b . getX ( ) ) == 0 && Double . compare ( a . getY ( ) , b . getY ( ) ) == 0 ; } | Check if two localizable are at the same location . |
3,312 | private static List < Field > getServiceFields ( Object object ) { final List < Field > toInject = new ArrayList < > ( ) ; Class < ? > clazz = object . getClass ( ) ; while ( clazz != null ) { final Field [ ] fields = clazz . getDeclaredFields ( ) ; final int length = fields . length ; for ( int i = 0 ; i < length ; i ... | Get all with that require an injected service . |
3,313 | private void fillServices ( Object object ) { final List < Field > fields = getServiceFields ( object ) ; final int length = fields . size ( ) ; for ( int i = 0 ; i < length ; i ++ ) { final Field field = fields . get ( i ) ; UtilReflection . setAccessible ( field , true ) ; final Class < ? > type = field . getType ( )... | Fill services fields with their right instance . |
3,314 | public static String normalizeExtension ( String file , String extension ) { Check . notNull ( file ) ; Check . notNull ( extension ) ; final int length = file . length ( ) + Constant . DOT . length ( ) + extension . length ( ) ; final StringBuilder builder = new StringBuilder ( length ) . append ( removeExtension ( fi... | Normalize the file extension by ensuring it has the required one . |
3,315 | public static String getExtension ( File file ) { Check . notNull ( file ) ; return getExtension ( file . getName ( ) ) ; } | Get a file extension . |
3,316 | public static List < File > getFiles ( File directory ) { Check . notNull ( directory ) ; if ( directory . isDirectory ( ) ) { final File [ ] files = directory . listFiles ( ) ; if ( files != null ) { return Arrays . asList ( files ) ; } } throw new LionEngineException ( ERROR_DIRECTORY + directory . getPath ( ) ) ; } | Get the files list from directory . |
3,317 | public static boolean isType ( File file , String extension ) { Check . notNull ( extension ) ; if ( file != null && file . isFile ( ) ) { final String current = getExtension ( file ) ; return current . equals ( extension . replace ( Constant . DOT , Constant . EMPTY_STRING ) ) ; } return false ; } | Check if the following type is the expected type . |
3,318 | private void renderTile ( Graphic g , int tx , int ty , double viewX , double viewY ) { final Tile tile = map . getTile ( tx , ty ) ; if ( tile != null ) { final int x = ( int ) Math . floor ( tile . getX ( ) - viewX ) ; final int y = ( int ) Math . floor ( - tile . getY ( ) + viewY - tile . getHeight ( ) ) ; for ( fin... | Render the tile from location . |
3,319 | private void renderHorizontal ( Graphic g , int ty , double viewY ) { final int inTileWidth = ( int ) Math . ceil ( viewer . getWidth ( ) / ( double ) map . getTileWidth ( ) ) ; final int sx = ( int ) Math . floor ( ( viewer . getX ( ) + viewer . getViewX ( ) ) / map . getTileWidth ( ) ) ; final double viewX = viewer .... | Render horizontal tiles . |
3,320 | public synchronized void start ( ) { if ( started . get ( ) ) { throw new LionEngineException ( ERROR_STARTED ) ; } started . set ( true ) ; thread . start ( ) ; } | Start to load resources in a separate thread . |
3,321 | public static Map < TileRef , ColorRgba > imports ( Media configMinimap ) { Check . notNull ( configMinimap ) ; final Map < TileRef , ColorRgba > colors = new HashMap < > ( ) ; final Xml nodeMinimap = new Xml ( configMinimap ) ; for ( final Xml nodeColor : nodeMinimap . getChildren ( NODE_COLOR ) ) { final ColorRgba co... | Create the minimap data from node . |
3,322 | public static void exports ( Media configMinimap , Map < TileRef , ColorRgba > tiles ) { Check . notNull ( configMinimap ) ; Check . notNull ( tiles ) ; final Map < ColorRgba , Collection < TileRef > > colors = convertToColorKey ( tiles ) ; final Xml nodeMinimap = new Xml ( NODE_MINIMAP ) ; for ( final Map . Entry < Co... | Export tiles colors data to configuration media . |
3,323 | private static Map < ColorRgba , Collection < TileRef > > convertToColorKey ( Map < TileRef , ColorRgba > tiles ) { final Map < ColorRgba , Collection < TileRef > > colors = new HashMap < > ( ) ; for ( final Map . Entry < TileRef , ColorRgba > entry : tiles . entrySet ( ) ) { final Collection < TileRef > tilesRef = get... | Convert map associating color per tile to tiles per color . |
3,324 | private static Collection < TileRef > getTiles ( Map < ColorRgba , Collection < TileRef > > colors , ColorRgba color ) { if ( ! colors . containsKey ( color ) ) { colors . put ( color , new HashSet < TileRef > ( ) ) ; } return colors . get ( color ) ; } | Get the tiles corresponding to the color . Create empty list if new color . |
3,325 | private int getCharWidth ( String text , Align align ) { final int width ; if ( align == Align . RIGHT ) { width = getTextWidth ( text ) ; } else if ( align == Align . CENTER ) { width = getTextWidth ( text ) / 2 ; } else { width = 0 ; } return width ; } | Get character width depending of alignment . |
3,326 | public static FeaturableConfig imports ( Configurer configurer ) { Check . notNull ( configurer ) ; return imports ( configurer . getRoot ( ) ) ; } | Import the featurable data from configurer . |
3,327 | public static FeaturableConfig imports ( Xml root ) { Check . notNull ( root ) ; final String clazz ; if ( root . hasChild ( ATT_CLASS ) ) { clazz = root . getChild ( ATT_CLASS ) . getText ( ) ; } else { clazz = DEFAULT_CLASS_NAME ; } final String setup ; if ( root . hasChild ( ATT_SETUP ) ) { setup = root . getChild (... | Import the featurable data from node . |
3,328 | public static Xml exportClass ( String clazz ) { Check . notNull ( clazz ) ; final Xml node = new Xml ( ATT_CLASS ) ; node . setText ( clazz ) ; return node ; } | Export the featurable node from class data . |
3,329 | public static Xml exportSetup ( String setup ) { Check . notNull ( setup ) ; final Xml node = new Xml ( ATT_SETUP ) ; node . setText ( setup ) ; return node ; } | Export the featurable node from setup data . |
3,330 | @ SuppressWarnings ( "unchecked" ) private static < T > Class < T > getClass ( String className ) { if ( CLASS_CACHE . containsKey ( className ) ) { return ( Class < T > ) CLASS_CACHE . get ( className ) ; } try { final Class < ? > clazz = LOADER . loadClass ( className ) ; CLASS_CACHE . put ( className , clazz ) ; ret... | Get the class reference from its name using cache . |
3,331 | public boolean contains ( Integer sheet , int number ) { for ( final TileRef current : tiles ) { if ( current . getSheet ( ) . equals ( sheet ) && current . getNumber ( ) == number ) { return true ; } } return false ; } | Check if tile is contained by the group . |
3,332 | public static CollisionFunction imports ( Xml parent ) { Check . notNull ( parent ) ; final Xml node = parent . getChild ( FUNCTION ) ; final String name = node . readString ( TYPE ) ; try { final CollisionFunctionType type = CollisionFunctionType . valueOf ( name ) ; switch ( type ) { case LINEAR : return new Collisio... | Create the collision function from node . |
3,333 | public static void exports ( Xml root , CollisionFunction function ) { Check . notNull ( root ) ; Check . notNull ( function ) ; final Xml node = root . createChild ( FUNCTION ) ; if ( function instanceof CollisionFunctionLinear ) { final CollisionFunctionLinear linear = ( CollisionFunctionLinear ) function ; node . wr... | Export the collision function data as a node . |
3,334 | public void update ( double screenX , double screenY ) { for ( final Image current : surfaces . values ( ) ) { current . setLocation ( screenX + offsetX , screenY + offsetY ) ; } if ( nextSurface != null ) { surface = nextSurface ; nextSurface = null ; } } | Update renderer location and surface ID . |
3,335 | final void resize ( int newWidth , int newHeight ) { final int oldWidth = widthInTile ; final int oldheight = heightInTile ; for ( int v = 0 ; v < newHeight - oldheight ; v ++ ) { tiles . add ( new ArrayList < Tile > ( newWidth ) ) ; } for ( int v = 0 ; v < newHeight ; v ++ ) { final int width ; if ( v < oldheight ) { ... | Resize map with new size . |
3,336 | public static PathFinder createPathFinder ( MapTile map , int maxSearchDistance , Heuristic heuristic ) { return new PathFinderImpl ( map , maxSearchDistance , heuristic ) ; } | Create a path finder . |
3,337 | private static void writeIdAndName ( ClientSocket client , int id , String name ) throws IOException { client . getOut ( ) . writeByte ( id ) ; final byte [ ] data = name . getBytes ( NetworkMessage . CHARSET ) ; client . getOut ( ) . writeByte ( data . length ) ; client . getOut ( ) . write ( data ) ; } | Send the id and the name to the client . |
3,338 | private static boolean checkValidity ( ClientSocket client , byte from , StateConnection expected ) { return from >= 0 && client . getState ( ) == expected ; } | Check if the client is in a valid state . |
3,339 | void notifyNewClientConnected ( Socket socket ) { try { int secure = 0 ; while ( clients . containsKey ( Byte . valueOf ( lastId ) ) ) { lastId ++ ; secure ++ ; final int max = 127 ; if ( secure > max ) { break ; } } final ClientSocket client = new ClientSocket ( lastId , socket ) ; client . setState ( StateConnection ... | Add a client . |
3,340 | void removeClient ( ClientSocket client ) { if ( client != null ) { toRemove . add ( client ) ; client . terminate ( ) ; clientsNumber -- ; willRemove = true ; Verbose . info ( SERVER , client . getName ( ) , " disconnected" ) ; } } | Remove a client from the server . |
3,341 | private void errorNewClientConnected ( Exception exception ) { Verbose . warning ( Server . class , "addClient" , "Error on adding client: " , exception . getMessage ( ) ) ; if ( clients . remove ( Byte . valueOf ( lastId ) ) != null ) { clientsNumber -- ; } } | Error on new client connection . |
3,342 | private void receiveConnecting ( ClientSocket client , DataInputStream buffer , byte from , StateConnection expected ) throws IOException { if ( ServerImpl . checkValidity ( client , from , expected ) ) { final byte [ ] name = new byte [ buffer . readByte ( ) ] ; if ( buffer . read ( name ) == - 1 ) { throw new IOExcep... | Update the receive connecting state . |
3,343 | private void receiveConnected ( ClientSocket client , byte from , StateConnection expected ) throws IOException { if ( ServerImpl . checkValidity ( client , from , expected ) ) { Verbose . info ( SERVER , client . getName ( ) , " connected" ) ; for ( final ClientListener listener : listeners ) { listener . notifyClient... | Update the receive connected state . |
3,344 | private void receiveDisconnected ( ClientSocket client , byte from , StateConnection expected ) throws IOException { if ( ServerImpl . checkValidity ( client , from , expected ) ) { client . setState ( StateConnection . DISCONNECTED ) ; for ( final ClientListener listener : listeners ) { listener . notifyClientDisconne... | Update the receive disconnected state . |
3,345 | private void receiveRenamed ( ClientSocket client , DataInputStream buffer , byte from , StateConnection expected ) throws IOException { if ( ServerImpl . checkValidity ( client , from , expected ) ) { final byte [ ] name = new byte [ buffer . readByte ( ) ] ; if ( buffer . read ( name ) == - 1 ) { throw new IOExceptio... | Update the receive renamed state . |
3,346 | private void receiveMessage ( ClientSocket client , DataInputStream buffer , byte from , StateConnection expected ) throws IOException { if ( ServerImpl . checkValidity ( client , from , expected ) ) { final byte dest = buffer . readByte ( ) ; final byte type = buffer . readByte ( ) ; final int size = buffer . readInt ... | Update the receive standard message state . |
3,347 | private void updateMessage ( ClientSocket client , DataInputStream buffer , byte messageSystemId , byte from ) throws IOException { switch ( messageSystemId ) { case NetworkMessageSystemId . CONNECTING : receiveConnecting ( client , buffer , from , StateConnection . CONNECTING ) ; break ; case NetworkMessageSystemId . ... | Update the message depending of its ID . |
3,348 | private JFrame initMainFrame ( ) { final String title = getTitle ( ) ; final JFrame jframe = new JFrame ( title , conf ) ; jframe . setDefaultCloseOperation ( WindowConstants . DO_NOTHING_ON_CLOSE ) ; jframe . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent event ) { listeners . forE... | Initialize the main frame . |
3,349 | private static String getTitle ( ) { final StringBuilder builder = new StringBuilder ( Constant . BYTE_4 ) ; if ( Engine . isStarted ( ) ) { builder . append ( Engine . getProgramName ( ) ) . append ( Constant . SPACE ) . append ( Engine . getProgramVersion ( ) ) ; } else { builder . append ( Constant . ENGINE_NAME ) .... | Get screen title . |
3,350 | private static Collision collide ( Origin origin , FeatureProvider provider , Transformable transformable , Collidable other , Collision collision , Rectangle rectangle ) { final Mirror mirror = getMirror ( provider , collision ) ; final int offsetX = getOffsetX ( collision , mirror ) ; final int offsetY = getOffsetY (... | Check if other collides with collision and its rectangle area . |
3,351 | private static boolean checkCollide ( Area area , Collidable other ) { final List < Rectangle > others = other . getCollisionBounds ( ) ; final int size = others . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { final Area current = others . get ( i ) ; if ( area . intersects ( current ) ) { return true ; } } return f... | Check if current area collides other collidable area . |
3,352 | private static Mirror getMirror ( FeatureProvider provider , Collision collision ) { if ( collision . hasMirror ( ) && provider . hasFeature ( Mirrorable . class ) ) { return provider . getFeature ( Mirrorable . class ) . getMirror ( ) ; } return Mirror . NONE ; } | Get the collision mirror . |
3,353 | private static int getOffsetX ( Collision collision , Mirror mirror ) { if ( mirror == Mirror . HORIZONTAL ) { return - collision . getOffsetX ( ) ; } return collision . getOffsetX ( ) ; } | Get the horizontal offset . |
3,354 | private static int getOffsetY ( Collision collision , Mirror mirror ) { if ( mirror == Mirror . VERTICAL ) { return - collision . getOffsetY ( ) ; } return collision . getOffsetY ( ) ; } | Get the vertical offset . |
3,355 | private void update ( Collision collision , double x , double y , int width , int height , Map < Collision , Rectangle > cacheRectRender ) { if ( boxs . containsKey ( collision ) ) { final Rectangle rectangle = boxs . get ( collision ) ; rectangle . set ( x , y , width , height ) ; cacheRectRender . get ( collision ) .... | Update the collision box . |
3,356 | public List < Collision > collide ( Origin origin , FeatureProvider provider , Transformable transformable , Collidable other , Collection < Integer > accepted ) { final List < Collision > collisions = new ArrayList < > ( ) ; if ( enabled && other . isEnabled ( ) && accepted . contains ( other . getGroup ( ) ) ) { fina... | Check if the collidable entered in collision with another one . |
3,357 | public static LaunchableConfig imports ( Xml node ) { Check . notNull ( node ) ; final String media = node . readString ( ATT_MEDIA ) ; final int delay = node . readInteger ( ATT_DELAY ) ; final int ox = node . readInteger ( 0 , ATT_OFFSET_X ) ; final int oy = node . readInteger ( 0 , ATT_OFFSET_Y ) ; return new Launch... | Import the launchable data from node . |
3,358 | public static Xml exports ( LaunchableConfig config ) { Check . notNull ( config ) ; final Xml node = new Xml ( NODE_LAUNCHABLE ) ; node . writeString ( ATT_MEDIA , config . getMedia ( ) ) ; node . writeInteger ( ATT_DELAY , config . getDelay ( ) ) ; node . writeInteger ( ATT_OFFSET_X , config . getOffsetX ( ) ) ; node... | Export the launchable node from data . |
3,359 | public void mouseReleased ( MouseEvent event ) { lastClick = 0 ; final int button = event . getClick ( ) ; clicks [ button ] = false ; clicked [ button ] = false ; } | Called on mouse released . |
3,360 | public static Collection < ZipEntry > getEntriesByExtension ( File jar , String path , String extension ) { Check . notNull ( jar ) ; Check . notNull ( path ) ; Check . notNull ( extension ) ; try ( ZipFile zip = new ZipFile ( jar ) ) { return checkEntries ( zip , path , extension ) ; } catch ( final IOException except... | Get all entries existing in the path considering the extension . |
3,361 | private static Collection < ZipEntry > checkEntries ( ZipFile zip , String path , String extension ) { final Collection < ZipEntry > entries = new ArrayList < > ( ) ; final Enumeration < ? extends ZipEntry > zipEntries = zip . entries ( ) ; while ( zipEntries . hasMoreElements ( ) ) { final ZipEntry entry = zipEntries ... | Check all entries existing in the ZIP considering the extension . |
3,362 | public static AudioFormat getFailsafe ( ) { try { return new Sc68Format ( ) ; } catch ( final LionEngineException exception ) { Verbose . exception ( exception , ERROR_LOAD_LIBRARY ) ; return new AudioVoidFormat ( FORMATS ) ; } } | Get the library or void format if not found . |
3,363 | private static Sc68Binding loadLibrary ( ) { try { Verbose . info ( "Load library: " , LIBRARY_NAME ) ; final Sc68Binding binding = Native . loadLibrary ( LIBRARY_NAME , Sc68Binding . class ) ; Verbose . info ( "Library " , LIBRARY_NAME , " loaded" ) ; return binding ; } catch ( final LinkageError exception ) { throw n... | Load the library . |
3,364 | public void add ( Featurable featurable ) { featurables . put ( featurable . getFeature ( Identifiable . class ) . getId ( ) , featurable ) ; for ( final Class < ? > type : featurable . getClass ( ) . getInterfaces ( ) ) { addType ( type , featurable ) ; } for ( final Class < ? extends Feature > feature : featurable . ... | Add a featurable . |
3,365 | public void remove ( Featurable featurable , Integer id ) { for ( final Class < ? > type : featurable . getClass ( ) . getInterfaces ( ) ) { remove ( type , featurable ) ; } for ( final Class < ? extends Feature > feature : featurable . getFeaturesType ( ) ) { final Feature object = featurable . getFeature ( feature ) ... | Remove the featurable and all its references . |
3,366 | private void addType ( Class < ? > type , Object object ) { if ( ! items . containsKey ( type ) ) { items . put ( type , new HashSet < > ( ) ) ; } items . get ( type ) . add ( object ) ; } | Add a type from its interface . |
3,367 | private void addSuperClass ( Object object , Class < ? > type ) { for ( final Class < ? > types : type . getInterfaces ( ) ) { addType ( types , object ) ; } final Class < ? > parent = type . getSuperclass ( ) ; if ( parent != null ) { addSuperClass ( object , parent ) ; } } | Add object parent super type . |
3,368 | private void removeSuperClass ( Object object , Class < ? > type ) { for ( final Class < ? > types : type . getInterfaces ( ) ) { remove ( types , object ) ; } final Class < ? > parent = type . getSuperclass ( ) ; if ( parent != null ) { removeSuperClass ( object , parent ) ; } } | Remove object parent super type . |
3,369 | private void remove ( Class < ? > type , Object object ) { final Set < ? > set = items . get ( type ) ; if ( set != null ) { set . remove ( object ) ; } } | Remove the object from its type list . |
3,370 | public static Map < String , PathData > imports ( Configurer configurer ) { Check . notNull ( configurer ) ; final Xml root = configurer . getRoot ( ) ; if ( ! root . hasChild ( NODE_PATHFINDABLE ) ) { return Collections . emptyMap ( ) ; } final Map < String , PathData > categories = new HashMap < > ( 0 ) ; final Xml n... | Import the pathfindable data from node . |
3,371 | public static Xml exports ( Map < String , PathData > pathData ) { Check . notNull ( pathData ) ; final Xml node = new Xml ( NODE_PATHFINDABLE ) ; for ( final PathData data : pathData . values ( ) ) { node . add ( exportPathData ( data ) ) ; } return node ; } | Export the pathfindable data to node . |
3,372 | private static Collection < MovementTile > importAllowedMovements ( Xml node ) { if ( ! node . hasChild ( NODE_MOVEMENT ) ) { return Collections . emptySet ( ) ; } final Collection < MovementTile > movements = EnumSet . noneOf ( MovementTile . class ) ; for ( final Xml movementNode : node . getChildren ( NODE_MOVEMENT ... | Import the allowed movements . |
3,373 | private static void exportAllowedMovements ( Xml root , Collection < MovementTile > movements ) { for ( final MovementTile movement : movements ) { final Xml node = root . createChild ( NODE_MOVEMENT ) ; node . setText ( movement . name ( ) ) ; } } | Export the allowed movements . |
3,374 | private static TransitionType getTransition ( TransitionType a , TransitionType b , int ox , int oy ) { final TransitionType type = getTransitionHorizontalVertical ( a , b , ox , oy ) ; if ( type != null ) { return type ; } return getTransitionDiagonals ( a , b , ox , oy ) ; } | Get the new transition type from two transitions . |
3,375 | private static TransitionType getTransitionHorizontalVertical ( TransitionType a , TransitionType b , int ox , int oy ) { final TransitionType type ; if ( ox == - 1 && oy == 0 ) { type = TransitionType . from ( ! b . getDownRight ( ) , a . getDownLeft ( ) , ! b . getUpRight ( ) , a . getUpLeft ( ) ) ; } else if ( ox ==... | Get the new transition type from two transitions on horizontal and vertical axis . |
3,376 | private void resolve ( Collection < Tile > resolved , Collection < Tile > toResolve , Tile tile ) { updateTile ( resolved , toResolve , tile , - 1 , 0 ) ; updateTile ( resolved , toResolve , tile , 1 , 0 ) ; updateTile ( resolved , toResolve , tile , 0 , 1 ) ; updateTile ( resolved , toResolve , tile , 0 , - 1 ) ; upda... | Resolve current tile and add to resolve list extra tiles . |
3,377 | private void updateTransition ( Collection < Tile > resolved , Collection < Tile > toResolve , Tile tile , Tile neighbor , String neighborGroup , Transition newTransition ) { if ( ! neighborGroup . equals ( newTransition . getIn ( ) ) ) { updateTile ( resolved , toResolve , tile , neighbor , newTransition ) ; } } | Update transition . |
3,378 | private void checkTransitives ( Collection < Tile > resolved , Tile tile ) { boolean isTransitive = false ; for ( final Tile neighbor : map . getNeighbors ( tile ) ) { final String group = mapGroup . getGroup ( tile ) ; final String neighborGroup = mapGroup . getGroup ( neighbor ) ; final Collection < GroupTransition >... | Check tile transitive groups . |
3,379 | private void updateTransitive ( Collection < Tile > resolved , Tile tile , Tile neighbor , GroupTransition transitive ) { final String transitiveOut = transitive . getOut ( ) ; final Transition transition = new Transition ( TransitionType . CENTER , transitiveOut , transitiveOut ) ; final Collection < TileRef > refs = ... | Update the transitive between tile and its neighbor . |
3,380 | private boolean isCenter ( Tile tile ) { for ( final Transition transition : tiles . get ( new TileRef ( tile ) ) ) { if ( TransitionType . CENTER == transition . getType ( ) ) { return true ; } } return false ; } | Check if tile is a center . |
3,381 | private static void compute ( Kernel kernel , int [ ] in , int [ ] out , int width , int height , boolean alpha , int edge ) { final float [ ] matrix = kernel . getMatrix ( ) ; final int cols = kernel . getWidth ( ) ; final int cols2 = cols / 2 ; for ( int y = 0 ; y < height ; y ++ ) { int index = y ; final int ioffset... | Compute blur . |
3,382 | private static void compute ( float [ ] matrix , int [ ] in , int [ ] out , int x , int index , int ioffset , int cols2 , int width , boolean alpha , int edge ) { float r = 0 ; float g = 0 ; float b = 0 ; float a = 0 ; final int moffset = cols2 ; for ( int col = - cols2 ; col <= cols2 ; col ++ ) { final float f = matri... | Compute blur point . |
3,383 | private static int checkEdge ( int width , int x , int col , int edge ) { int ix = x + col ; if ( ix < 0 ) { if ( edge == CLAMP_EDGES ) { ix = 0 ; } else { ix = ( x + width ) % width ; } } else if ( ix >= width ) { if ( edge == CLAMP_EDGES ) { ix = width - 1 ; } else { ix = ( x + width ) % width ; } } return ix ; } | Check the edge value . |
3,384 | private static Kernel createKernel ( float radius , int width , int height ) { final int r = ( int ) Math . ceil ( radius ) ; final int rows = r * 2 + 1 ; final float [ ] matrix = new float [ rows ] ; final float sigma = radius / 3 ; final float sigma22 = 2 * sigma * sigma ; final float sigmaPi2 = ( float ) ( 2 * Math ... | Create a blur kernel . |
3,385 | protected void setResolution ( Resolution output ) { Check . notNull ( output ) ; width = output . getWidth ( ) ; height = output . getHeight ( ) ; } | Set the screen config . Initialize the display . |
3,386 | public static Sequencable create ( Class < ? extends Sequencable > nextSequence , Context context , Object ... arguments ) { Check . notNull ( nextSequence ) ; Check . notNull ( context ) ; Check . notNull ( arguments ) ; try { final Class < ? > [ ] params = getParamTypes ( context , arguments ) ; return UtilReflection... | Create a sequence from its class . |
3,387 | public static void pause ( long delay ) { try { Thread . sleep ( delay ) ; } catch ( @ SuppressWarnings ( "unused" ) final InterruptedException exception ) { Thread . currentThread ( ) . interrupt ( ) ; } } | Pause time . |
3,388 | private static Object [ ] getParams ( Context context , Object ... arguments ) { final Collection < Object > params = new ArrayList < > ( 1 ) ; params . add ( context ) ; params . addAll ( Arrays . asList ( arguments ) ) ; return params . toArray ( ) ; } | Get the parameter as array . |
3,389 | private void assignObjectId ( int dtx , int dty ) { final int tw = transformable . getWidth ( ) / map . getTileWidth ( ) ; final int th = transformable . getHeight ( ) / map . getTileHeight ( ) ; for ( int tx = dtx ; tx < dtx + tw ; tx ++ ) { for ( int ty = dty ; ty < dty + th ; ty ++ ) { mapPath . addObjectId ( tx , t... | Assign the map object id of the pathfindable . |
3,390 | private void removeObjectId ( int dtx , int dty ) { final int tw = transformable . getWidth ( ) / map . getTileWidth ( ) ; final int th = transformable . getHeight ( ) / map . getTileHeight ( ) ; for ( int tx = dtx ; tx < dtx + tw ; tx ++ ) { for ( int ty = dty ; ty < dty + th ; ty ++ ) { if ( mapPath . getObjectsId ( ... | Remove the map object id of the pathfindable . |
3,391 | private void updateObjectId ( int lastStep , int nextStep ) { final int max = getMaxStep ( ) ; if ( nextStep < max ) { if ( checkObjectId ( path . getX ( nextStep ) , path . getY ( nextStep ) ) ) { takeNextStep ( lastStep , nextStep ) ; } else { avoidObstacle ( nextStep , max ) ; } } } | Update reference by updating map object Id . |
3,392 | private void takeNextStep ( int lastStep , int nextStep ) { if ( ! pathStoppedRequested ) { removeObjectId ( path . getX ( lastStep ) , path . getY ( lastStep ) ) ; assignObjectId ( path . getX ( nextStep ) , path . getY ( nextStep ) ) ; } } | Update the next step has it is free . |
3,393 | private void avoidObstacle ( int nextStep , int max ) { if ( nextStep >= max - 1 ) { pathStoppedRequested = true ; } final Collection < Integer > cid = mapPath . getObjectsId ( path . getX ( nextStep ) , path . getY ( nextStep ) ) ; if ( sharedPathIds . containsAll ( cid ) ) { setDestination ( destX , destY ) ; } else ... | Update to avoid obstacle because next step is not free . |
3,394 | private void renderPath ( Graphic g ) { final int tw = map . getTileWidth ( ) ; final int th = map . getTileHeight ( ) ; for ( int i = 0 ; i < path . getLength ( ) ; i ++ ) { final int x = ( int ) viewer . getViewpointX ( path . getX ( i ) * ( double ) tw ) ; final int y = ( int ) viewer . getViewpointY ( path . getY (... | Render the current path . |
3,395 | private void prepareDestination ( int dtx , int dty ) { pathStopped = false ; pathStoppedRequested = false ; destX = dtx ; destY = dty ; destinationReached = false ; } | Prepare the destination store its location and reset states . |
3,396 | private void moveTo ( double extrp , int dx , int dy ) { final Force force = getMovementForce ( transformable . getX ( ) , transformable . getY ( ) , dx , dy ) ; final double sx = force . getDirectionHorizontal ( ) ; final double sy = force . getDirectionVertical ( ) ; moveX = sx ; moveY = sy ; transformable . moveLoca... | Move to destination . |
3,397 | private boolean checkArrivedX ( double extrp , double sx , double dx ) { final double x = transformable . getX ( ) ; if ( sx < 0 && x <= dx || sx >= 0 && x >= dx ) { transformable . moveLocation ( extrp , dx - x , 0 ) ; return true ; } return false ; } | Check if the pathfindable is horizontally arrived . |
3,398 | private boolean checkArrivedY ( double extrp , double sy , double dy ) { final double y = transformable . getY ( ) ; if ( sy < 0 && y <= dy || sy >= 0 && y >= dy ) { transformable . moveLocation ( extrp , 0 , dy - y ) ; return true ; } return false ; } | Check if the pathfindable is vertically arrived . |
3,399 | private void checkPathfinderChanges ( ) { if ( pathFoundChanged ) { if ( currentStep < getMaxStep ( ) ) { removeObjectId ( path . getX ( currentStep ) , path . getY ( currentStep ) ) ; } if ( path != null ) { path . clear ( ) ; } path = pathfinder . findPath ( this , destX , destY , false ) ; pathFoundChanged = false ;... | Check if pathfinder changed . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.