idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
3,600 | public static double clamp ( double value , double min , double max ) { final double fixed ; if ( value < min ) { fixed = min ; } else if ( value > max ) { fixed = max ; } else { fixed = value ; } return fixed ; } | Fix a value between an interval . |
3,601 | public static double curveValue ( double value , double dest , double speed ) { Check . different ( speed , 0.0 ) ; final double reciprocal = 1.0 / speed ; final double invReciprocal = 1.0 - reciprocal ; return value * invReciprocal + dest * reciprocal ; } | Apply progressive modifications to a value . |
3,602 | public static double getDistance ( double x1 , double y1 , double x2 , double y2 , int w2 , int h2 ) { final double maxX = x2 + w2 ; final double maxY = y2 + h2 ; double min = getDistance ( x1 , y1 , x2 , y2 ) ; for ( double x = x2 ; Double . compare ( x , maxX ) <= 0 ; x ++ ) { for ( double y = y2 ; Double . compare (... | Get distance from point to area . |
3,603 | public static int getRounded ( double value , int round ) { Check . different ( round , 0 ) ; return ( int ) Math . floor ( value / round ) * round ; } | Get the rounded value . |
3,604 | public static int getRoundedC ( double value , int round ) { Check . different ( round , 0 ) ; return ( int ) Math . ceil ( value / round ) * round ; } | Get the rounded value with ceil . |
3,605 | public static Map < Transition , Collection < TileRef > > imports ( Media config ) { final Xml root = new Xml ( config ) ; final Collection < Xml > nodesTransition = root . getChildren ( NODE_TRANSITION ) ; final Map < Transition , Collection < TileRef > > transitions = new HashMap < > ( nodesTransition . size ( ) ) ; ... | Import all transitions from configuration . |
3,606 | private static Collection < TileRef > importTiles ( Collection < Xml > nodesTileRef ) { final Collection < TileRef > tilesRef = new HashSet < > ( nodesTileRef . size ( ) ) ; for ( final Xml nodeTileRef : nodesTileRef ) { final TileRef tileRef = TileConfig . imports ( nodeTileRef ) ; tilesRef . add ( tileRef ) ; } retur... | Import all tiles from their nodes . |
3,607 | private static void exportTiles ( Xml nodeTransition , Collection < TileRef > tilesRef ) { for ( final TileRef tileRef : tilesRef ) { final Xml nodeTileRef = TileConfig . exports ( tileRef ) ; nodeTransition . add ( nodeTileRef ) ; } } | Export all tiles for the transition . |
3,608 | private void updateTile ( Tile tile , Tile neighbor , Circuit circuit ) { final Iterator < TileRef > iterator = getTiles ( circuit ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { final TileRef newTile = iterator . next ( ) ; if ( mapGroup . getGroup ( newTile ) . equals ( mapGroup . getGroup ( tile ) ) ) { map . ... | Update tile with new representation . |
3,609 | private Circuit getCircuitOverTransition ( Circuit circuit , Tile neighbor ) { final String group = getTransitiveGroup ( circuit , neighbor ) ; final Circuit newCircuit ; if ( TileGroupType . TRANSITION == mapGroup . getType ( circuit . getIn ( ) ) ) { newCircuit = new Circuit ( circuit . getType ( ) , group , circuit ... | Get the circuit supporting over existing transition . |
3,610 | private String getTransitiveGroup ( Circuit initialCircuit , Tile tile ) { final Set < Circuit > circuitSet = circuits . keySet ( ) ; final Collection < String > groups = new HashSet < > ( circuitSet . size ( ) ) ; final String groupIn = mapGroup . getGroup ( tile ) ; for ( final Circuit circuit : circuitSet ) { final ... | Get the transitive group by replacing the transition group name with the plain one . |
3,611 | private void computeRenderingPoint ( int width , int height ) { rx = ( int ) Math . floor ( origin . getX ( x , width ) ) ; ry = ( int ) Math . floor ( origin . getY ( y , height ) ) ; } | Compute the rendering point . |
3,612 | public void changeState ( Class < ? extends State > next ) { Check . notNull ( next ) ; final State from = current ; if ( current != null ) { last = current . getClass ( ) ; current . exit ( ) ; } if ( ! states . containsKey ( next ) ) { final State state = create ( next ) ; states . put ( next , state ) ; } current = ... | Change the current state . |
3,613 | public boolean isState ( Class < ? extends State > state ) { if ( current != null ) { return current . getClass ( ) . equals ( state ) ; } return false ; } | Check the current state . |
3,614 | @ SuppressWarnings ( "unchecked" ) private State create ( Class < ? extends State > state ) { try { if ( configurer . isPresent ( ) ) { final AnimationConfig configAnimations = AnimationConfig . imports ( configurer . get ( ) ) ; final String name = converter . apply ( state ) ; final Animation animation = configAnimat... | Create state from its type . |
3,615 | public void postUpdate ( ) { if ( current != null ) { final Class < ? extends State > next = current . checkTransitions ( last ) ; if ( next != null ) { changeState ( next ) ; } } } | Post update checking next transition if has . |
3,616 | private void clearMenus ( ) { for ( final Featurable menu : menus ) { menu . getFeature ( Identifiable . class ) . destroy ( ) ; handler . remove ( menu ) ; } menus . clear ( ) ; } | Clear current menus . |
3,617 | private void createMenus ( Collection < ActionRef > parents , Collection < ActionRef > actions ) { for ( final ActionRef action : actions ) { final Featurable menu = createMenu ( action ) ; if ( ! action . getRefs ( ) . isEmpty ( ) ) { generateSubMenu ( actions , action , menu ) ; } else if ( action . hasCancel ( ) ) {... | Create menus from actions . |
3,618 | private Featurable createMenu ( ActionRef action ) { final Featurable menu = factory . create ( Medias . create ( PATH . split ( action . getPath ( ) ) ) ) ; menus . add ( menu ) ; return menu ; } | Create menu from action and add to active menus . |
3,619 | private void generateSubMenu ( final Collection < ActionRef > parents , final ActionRef action , Featurable menu ) { menu . getFeature ( Actionable . class ) . setAction ( ( ) -> { clearMenus ( ) ; createMenus ( parents , action . getRefs ( ) ) ; } ) ; } | Generate sub menu creation if menu contains sub menu . |
3,620 | private void generateCancel ( final ActionRef action , Featurable menu ) { menu . getFeature ( Actionable . class ) . setAction ( ( ) -> { clearMenus ( ) ; final Collection < ActionRef > parents = previous . get ( action ) ; createMenus ( parents , parents ) ; } ) ; } | Generate cancel to go back . |
3,621 | private static void addFeatures ( Featurable featurable , Services services , Setup setup ) { final List < Feature > rawFeatures = FeaturableConfig . getFeatures ( services , setup ) ; final int length = rawFeatures . size ( ) ; for ( int i = 0 ; i < length ; i ++ ) { final Feature feature = rawFeatures . get ( i ) ; f... | Add all features declared in configuration . |
3,622 | public Setup getSetup ( Media media ) { Check . notNull ( media ) ; if ( ! setups . containsKey ( media ) ) { setups . put ( media , createSetup ( media ) ) ; } return setups . get ( media ) ; } | Get a setup reference from its media . |
3,623 | @ SuppressWarnings ( "unchecked" ) private Setup createSetup ( Media media ) { final Configurer configurer = new Configurer ( media ) ; try { final FeaturableConfig config = FeaturableConfig . imports ( configurer ) ; final String setup = config . getSetupName ( ) ; final Class < ? extends Setup > setupClass ; if ( set... | Create a setup from its media . |
3,624 | private < O extends Featurable > O createFeaturable ( Class < O > type , Setup setup ) throws NoSuchMethodException { final O featurable = UtilReflection . createReduce ( type , services , setup ) ; addFeatures ( featurable , services , setup ) ; for ( final Feature feature : featurable . getFeatures ( ) ) { featurable... | Create the featurable . |
3,625 | public static ImageHeader get ( Media media ) { Check . notNull ( media ) ; for ( final ImageHeaderReader reader : FORMATS ) { if ( reader . is ( media ) ) { return read ( media , reader ) ; } } throw new LionEngineException ( media , ERROR_READ ) ; } | Get the image info of the specified image media . |
3,626 | private static ImageHeader read ( Media media , ImageHeaderReader reader ) { Check . notNull ( media ) ; Check . notNull ( reader ) ; try ( InputStream input = media . getInputStream ( ) ) { return reader . readHeader ( input ) ; } catch ( final IOException exception ) { throw new LionEngineException ( exception , medi... | Read image header . |
3,627 | public static CollisionGroupConfig imports ( Xml root , MapTileCollision map ) { Check . notNull ( root ) ; Check . notNull ( map ) ; final Collection < Xml > childrenCollision = root . getChildren ( NODE_COLLISION ) ; final Map < String , CollisionGroup > groups = new HashMap < > ( childrenCollision . size ( ) ) ; for... | Create the collision group data from node . |
3,628 | public static void exports ( Xml root , CollisionGroup group ) { Check . notNull ( root ) ; Check . notNull ( group ) ; final Xml node = root . createChild ( NODE_COLLISION ) ; node . writeString ( ATT_GROUP , group . getName ( ) ) ; for ( final CollisionFormula formula : group . getFormulas ( ) ) { final Xml nodeFormu... | Export the collision group data as a node . |
3,629 | public static void remove ( Xml root , String group ) { Check . notNull ( root ) ; Check . notNull ( group ) ; for ( final Xml node : root . getChildren ( NODE_COLLISION ) ) { if ( node . readString ( ATT_GROUP ) . equals ( group ) ) { root . removeChild ( node ) ; } } } | Remove the group node . |
3,630 | public static boolean has ( Xml root , String group ) { Check . notNull ( root ) ; Check . notNull ( group ) ; for ( final Xml node : root . getChildren ( NODE_COLLISION ) ) { if ( node . readString ( ATT_GROUP ) . equals ( group ) ) { return true ; } } return false ; } | Check if node has group node . |
3,631 | public static TileSheetsConfig imports ( Media configSheets ) { final Xml nodeSheets = new Xml ( configSheets ) ; final Xml nodeTileSize = nodeSheets . getChild ( NODE_TILE_SIZE ) ; final int tileWidth = nodeTileSize . readInteger ( ATT_TILE_WIDTH ) ; final int tileHeight = nodeTileSize . readInteger ( ATT_TILE_HEIGHT ... | Import the sheets data from configuration . |
3,632 | public static void exports ( Media configSheets , int tileWidth , int tileHeight , Collection < String > sheets ) { Check . notNull ( configSheets ) ; Check . notNull ( sheets ) ; final Xml nodeSheets = new Xml ( NODE_TILE_SHEETS ) ; nodeSheets . writeString ( Constant . XML_HEADER , Constant . ENGINE_WEBSITE ) ; final... | Export the sheets configuration . |
3,633 | private static Collection < String > importSheets ( Xml nodeSheets ) { final Collection < Xml > children = nodeSheets . getChildren ( NODE_TILE_SHEET ) ; final Collection < String > sheets = new ArrayList < > ( children . size ( ) ) ; for ( final Xml nodeSheet : children ) { final String sheetFilename = nodeSheet . get... | Import the defined sheets . |
3,634 | private static void exportSheets ( Xml nodeSheets , Collection < String > sheets ) { for ( final String sheet : sheets ) { final Xml nodeSheet = nodeSheets . createChild ( NODE_TILE_SHEET ) ; nodeSheet . setText ( sheet ) ; } } | Export the defined sheets . |
3,635 | public static Force fromVector ( double ox , double oy , double x , double y ) { final double dh = x - ox ; final double dv = y - oy ; final double norm ; if ( dh > dv ) { norm = Math . abs ( dh ) ; } else { norm = Math . abs ( dv ) ; } final double sx ; final double sy ; if ( Double . compare ( norm , 0.0 ) == 0 ) { s... | Create a force from a vector movement . |
3,636 | public void addDirection ( double extrp , Direction direction ) { addDirection ( extrp , direction . getDirectionHorizontal ( ) , direction . getDirectionVertical ( ) ) ; } | Increase direction with input value . |
3,637 | public void addDirection ( double extrp , double fh , double fv ) { fhLast = fh ; fvLast = fv ; this . fh += fh * extrp ; this . fv += fv * extrp ; fixForce ( ) ; } | Increase forces with input value . |
3,638 | public void setDirection ( double fh , double fv ) { fhLast = fh ; fvLast = fv ; this . fh = fh ; this . fv = fv ; fixForce ( ) ; } | Set directions . |
3,639 | private void updateLastForce ( ) { if ( Double . compare ( fhLast , fhDest ) != 0 ) { fhLast = fhDest ; arrivedH = false ; } if ( Double . compare ( fvLast , fvDest ) != 0 ) { fvLast = fvDest ; arrivedV = false ; } } | Update the last direction . |
3,640 | private void updateNotArrivedH ( double extrp ) { if ( fh < fhDest ) { fh += velocity * extrp ; if ( fh > fhDest - sensibility ) { fh = fhDest ; arrivedH = true ; } } else if ( fh > fhDest ) { fh -= velocity * extrp ; if ( fh < fhDest + sensibility ) { fh = fhDest ; arrivedH = true ; } } } | Update the force if still not reached on horizontal axis . |
3,641 | private void updateNotArrivedV ( double extrp ) { if ( fv < fvDest ) { fv += velocity * extrp ; if ( fv > fvDest - sensibility ) { fv = fvDest ; arrivedV = true ; } } else if ( fv > fvDest ) { fv -= velocity * extrp ; if ( fv < fvDest + sensibility ) { fv = fvDest ; arrivedV = true ; } } } | Update the force if still not reached on vertical axis . |
3,642 | private void fixForce ( ) { final double minH ; final double minV ; final double maxH ; final double maxV ; if ( directionMin == null ) { minH = fh ; minV = fv ; } else { minH = directionMin . getDirectionHorizontal ( ) ; minV = directionMin . getDirectionVertical ( ) ; } if ( directionMax == null ) { maxH = fh ; maxV ... | Fix the force to its limited range . |
3,643 | public void loadCollisions ( MapTileCollision mapCollision , Media collisionFormulas , Media collisionGroups ) { if ( collisionFormulas . exists ( ) ) { loadCollisionFormulas ( collisionFormulas ) ; } if ( collisionGroups . exists ( ) ) { loadCollisionGroups ( mapCollision , collisionGroups ) ; } loadTilesCollisions ( ... | Load map collision from an external file . |
3,644 | public void loadCollisions ( MapTileCollision mapCollision , CollisionFormulaConfig formulasConfig , CollisionGroupConfig groupsConfig ) { loadCollisionFormulas ( formulasConfig ) ; loadCollisionGroups ( groupsConfig ) ; loadTilesCollisions ( mapCollision ) ; applyConstraints ( ) ; } | Load map collision with default files . |
3,645 | public CollisionFormula getCollisionFormula ( String name ) { if ( formulas . containsKey ( name ) ) { return formulas . get ( name ) ; } throw new LionEngineException ( ERROR_FORMULA + name ) ; } | Get the collision formula from its name . |
3,646 | public CollisionGroup getCollisionGroup ( String name ) { if ( groups . containsKey ( name ) ) { return groups . get ( name ) ; } throw new LionEngineException ( ERROR_FORMULA + name ) ; } | Get the collision group from its name . |
3,647 | private void loadCollisionFormulas ( Media formulasConfig ) { Verbose . info ( INFO_LOAD_FORMULAS , formulasConfig . getFile ( ) . getPath ( ) ) ; this . formulasConfig = formulasConfig ; final CollisionFormulaConfig config = CollisionFormulaConfig . imports ( formulasConfig ) ; loadCollisionFormulas ( config ) ; } | Load the collision formula . All previous collisions will be cleared . |
3,648 | private void loadCollisionGroups ( MapTileCollision mapCollision , Media groupsConfig ) { Verbose . info ( INFO_LOAD_GROUPS , groupsConfig . getFile ( ) . getPath ( ) ) ; this . groupsConfig = groupsConfig ; final Xml nodeGroups = new Xml ( groupsConfig ) ; final CollisionGroupConfig config = CollisionGroupConfig . imp... | Load the collision groups . All previous groups will be cleared . |
3,649 | private void loadTilesCollisions ( MapTileCollision mapCollision ) { for ( int v = 0 ; v < map . getInTileHeight ( ) ; v ++ ) { for ( int h = 0 ; h < map . getInTileWidth ( ) ; h ++ ) { final Tile tile = map . getTile ( h , v ) ; if ( tile != null ) { loadTileCollisions ( mapCollision , tile ) ; } } } } | Load collisions for each tile . Previous collisions will be removed . |
3,650 | private void loadTileCollisions ( MapTileCollision mapCollision , Tile tile ) { final TileCollision tileCollision ; if ( ! tile . hasFeature ( TileCollision . class ) ) { tileCollision = new TileCollisionModel ( tile ) ; tile . addFeature ( tileCollision ) ; } else { tileCollision = tile . getFeature ( TileCollision . ... | Load the tile collisions . |
3,651 | private void addTileCollisions ( MapTileCollision mapCollision , TileCollision tileCollision , Tile tile ) { final TileRef ref = new TileRef ( tile ) ; for ( final CollisionGroup collision : mapCollision . getCollisionGroups ( ) ) { final Collection < TileRef > group = mapGroup . getGroup ( collision . getName ( ) ) ; ... | Add the tile collisions from loaded configuration . |
3,652 | private void applyConstraints ( ) { final Map < Tile , Collection < CollisionFormula > > toRemove = new HashMap < > ( ) ; for ( int v = 0 ; v < map . getInTileHeight ( ) ; v ++ ) { for ( int h = 0 ; h < map . getInTileWidth ( ) ; h ++ ) { final Tile tile = map . getTile ( h , v ) ; if ( tile != null ) { final TileColli... | Apply tile constraints depending of their adjacent collisions . |
3,653 | private Collection < CollisionFormula > checkConstraints ( TileCollision tile , int h , int v ) { final Tile top = map . getTile ( h , v + 1 ) ; final Tile bottom = map . getTile ( h , v - 1 ) ; final Tile left = map . getTile ( h - 1 , v ) ; final Tile right = map . getTile ( h + 1 , v ) ; final Collection < Collision... | Check the tile constraints and get the removable formulas . |
3,654 | private boolean checkConstraint ( Collection < String > constraints , Tile tile ) { return tile != null && constraints . contains ( mapGroup . getGroup ( tile ) ) && ! tile . getFeature ( TileCollision . class ) . getCollisionFormulas ( ) . isEmpty ( ) ; } | Check the constraint with the specified tile . |
3,655 | public void addPoint ( double x , double y ) { if ( npoints >= xpoints . length ) { final int newLength = npoints * 2 ; xpoints = Arrays . copyOf ( xpoints , newLength ) ; ypoints = Arrays . copyOf ( ypoints , newLength ) ; } xpoints [ npoints ] = x ; ypoints [ npoints ] = y ; npoints ++ ; updateBounds ( ) ; } | Add a point to the polygon . |
3,656 | public Collection < Line > getPoints ( ) { final Collection < Line > list = new ArrayList < > ( npoints ) ; for ( int i = 0 ; i < npoints / 2 ; i ++ ) { list . add ( new Line ( xpoints [ i ] , ypoints [ i ] , xpoints [ i + npoints / 2 ] , ypoints [ i + npoints / 2 ] ) ) ; } return list ; } | Get the points . |
3,657 | private void updateBounds ( ) { if ( npoints >= MIN_POINTS ) { double boundsMinX = Double . MAX_VALUE ; double boundsMinY = Double . MAX_VALUE ; double boundsMaxX = - Double . MAX_VALUE ; double boundsMaxY = - Double . MAX_VALUE ; for ( int i = 0 ; i < npoints ; i ++ ) { final double x = xpoints [ i ] ; boundsMinX = Ma... | Update the bounds . |
3,658 | public Resolution getScaled ( double factorX , double factorY ) { Check . superiorStrict ( factorX , 0 ) ; Check . superiorStrict ( factorY , 0 ) ; return new Resolution ( ( int ) ( width * factorX ) , ( int ) ( height * factorY ) , rate ) ; } | Get scaled resolution . |
3,659 | public static TileRef imports ( Xml nodeTile ) { Check . notNull ( nodeTile ) ; final int sheet = nodeTile . readInteger ( ATT_TILE_SHEET ) ; final int number = nodeTile . readInteger ( ATT_TILE_NUMBER ) ; return new TileRef ( sheet , number ) ; } | Create the tile data from node . |
3,660 | public static Xml exports ( TileRef tileRef ) { Check . notNull ( tileRef ) ; final Xml node = new Xml ( NODE_TILE ) ; node . writeInteger ( ATT_TILE_SHEET , tileRef . getSheet ( ) . intValue ( ) ) ; node . writeInteger ( ATT_TILE_NUMBER , tileRef . getNumber ( ) ) ; return node ; } | Export the tile as a node . |
3,661 | public static SurfaceConfig imports ( Configurer configurer ) { Check . notNull ( configurer ) ; return imports ( configurer . getRoot ( ) ) ; } | Create the surface data from configurer . |
3,662 | private static boolean checkPixel ( MapTile map , ImageBuffer tileRef , int progressTileX , int progressTileY ) { final int x = progressTileX * map . getTileWidth ( ) ; final int y = progressTileY * map . getTileHeight ( ) ; final int pixel = tileRef . getRgb ( x , y ) ; if ( TilesExtractor . IGNORED_COLOR_VALUE != pix... | Check the pixel by searching tile on sheet . |
3,663 | private static Tile searchForTile ( MapTile map , ImageBuffer tileSprite , int x , int y ) { for ( final Integer sheet : map . getSheets ( ) ) { final Tile tile = checkTile ( map , tileSprite , sheet , x , y ) ; if ( tile != null ) { return tile ; } } return null ; } | Search current tile of image map by checking all surfaces . |
3,664 | private static Tile checkTile ( MapTile map , ImageBuffer tileSprite , Integer sheet , int x , int y ) { final int tw = map . getTileWidth ( ) ; final int th = map . getTileHeight ( ) ; final SpriteTiled tileSheet = map . getSheet ( sheet ) ; final ImageBuffer sheetImage = tileSheet . getSurface ( ) ; final int tilesIn... | Check tile of sheet . |
3,665 | private static StateUpdater createCheck ( Cursor cursor , SelectorModel model , AtomicReference < StateUpdater > start ) { return ( extrp , current ) -> { if ( model . isEnabled ( ) && cursor . getClick ( ) == 0 ) { return start . get ( ) ; } return current ; } ; } | Create check action . |
3,666 | private StateUpdater createStart ( Cursor cursor , SelectorModel model , StateUpdater check , StateUpdater select ) { return ( extrp , current ) -> { StateUpdater next = current ; if ( ! model . isEnabled ( ) ) { next = check ; } else if ( model . getSelectionClick ( ) == cursor . getClick ( ) ) { checkBeginSelection (... | Create start action . |
3,667 | private void checkBeginSelection ( Cursor cursor , SelectorModel model ) { final boolean canClick = ! model . getClickableArea ( ) . contains ( cursor . getScreenX ( ) , cursor . getScreenY ( ) ) ; if ( ! model . isSelecting ( ) && ! canClick ) { model . setSelecting ( true ) ; startX = cursor . getX ( ) ; startY = cur... | Check if can begin selection . Notify listeners if started . |
3,668 | private void computeSelection ( Viewer viewer , Cursor cursor , SelectorModel model ) { final double viewX = viewer . getX ( ) + viewer . getViewX ( ) ; final double viewY = viewer . getY ( ) - viewer . getViewY ( ) ; final double currentX = UtilMath . clamp ( cursor . getX ( ) , viewX , viewX + viewer . getWidth ( ) )... | Compute the selection from cursor location . |
3,669 | public static Map < Circuit , Collection < TileRef > > imports ( Media circuitsConfig ) { Check . notNull ( circuitsConfig ) ; final Xml root = new Xml ( circuitsConfig ) ; final Collection < Xml > nodesCircuit = root . getChildren ( NODE_CIRCUIT ) ; final Map < Circuit , Collection < TileRef > > circuits = new HashMap... | Import all circuits from configuration . |
3,670 | private List < SpriteTiled > getRasters ( Integer sheet ) { return rasterSheets . computeIfAbsent ( sheet , s -> { final List < SpriteTiled > rasters = new ArrayList < > ( RasterImage . MAX_RASTERS ) ; rasterSheets . put ( s , rasters ) ; return rasters ; } ) ; } | Get the associated raster sheets for a sheet number . Create it if needed . |
3,671 | public void terminate ( ) { try { in . close ( ) ; } catch ( final IOException exception ) { Verbose . exception ( exception ) ; } try { out . close ( ) ; } catch ( final IOException exception ) { Verbose . exception ( exception ) ; } try { socket . close ( ) ; } catch ( final IOException exception ) { Verbose . except... | Terminate client . |
3,672 | public byte [ ] receiveMessages ( ) { try { final byte [ ] data ; final int size = in . available ( ) ; if ( size <= 0 ) { data = null ; } else { data = new byte [ size ] ; in . readFully ( data ) ; } return data ; } catch ( final IOException exception ) { Verbose . exception ( exception ) ; return new byte [ 0 ] ; } } | Receive messages data from the client . |
3,673 | private static Integer getLayer ( Featurable featurable ) { if ( featurable . hasFeature ( Layerable . class ) ) { final Layerable layerable = featurable . getFeature ( Layerable . class ) ; return layerable . getLayerDisplay ( ) ; } return LAYER_DEFAULT ; } | Get the featurable layer . |
3,674 | private void remove ( Integer layer , Displayable displayable ) { final Collection < Displayable > displayables = getLayer ( layer ) ; displayables . remove ( displayable ) ; if ( displayables . isEmpty ( ) ) { indexs . remove ( layer ) ; } } | Remove displayable and its layer . |
3,675 | public void reset ( ) { for ( final Tile tile : revealed ) { final Tile reset = new TileGame ( tile . getSheet ( ) , FOG , tile . getX ( ) , tile . getY ( ) , tile . getWidth ( ) , tile . getHeight ( ) ) ; map . setTile ( reset ) ; } revealed . clear ( ) ; } | Reset the revealed tiles to fogged . |
3,676 | private void actionWillProduce ( ) { if ( checker . checkProduction ( current ) ) { startProduction ( current ) ; state = ProducerState . PRODUCING ; } else { for ( final ProducerListener listener : listeners ) { listener . notifyCanNotProduce ( current ) ; } } } | Action called from update production in will produce state . |
3,677 | private void actionProducing ( double extrp ) { for ( final ProducerListener listener : listeners ) { listener . notifyProducing ( currentObject ) ; } for ( final ProducibleListener listener : current . getFeature ( Producible . class ) . getListeners ( ) ) { listener . notifyProductionProgress ( this ) ; } progress +=... | Action called from update production in producing state . |
3,678 | private void actionProduced ( ) { for ( final ProducerListener listener : listeners ) { listener . notifyProduced ( currentObject ) ; } for ( final ProducibleListener listener : current . getFeature ( Producible . class ) . getListeners ( ) ) { listener . notifyProductionEnded ( this ) ; } currentObject = null ; progre... | Action called from update production in produced state . |
3,679 | private void startProduction ( Featurable featurable ) { final Transformable transformable = featurable . getFeature ( Transformable . class ) ; final Producible producible = featurable . getFeature ( Producible . class ) ; transformable . setLocation ( producible . getX ( ) , producible . getY ( ) ) ; handler . add ( ... | Start production of this element . Get its corresponding instance and add it to the handler . Featurable will be removed from handler if production is cancelled . |
3,680 | public static FramesConfig imports ( Configurer configurer ) { Check . notNull ( configurer ) ; return imports ( configurer . getRoot ( ) ) ; } | Imports the frames config from configurer . |
3,681 | public static FramesConfig imports ( Xml root ) { Check . notNull ( root ) ; final Xml node = root . getChild ( NODE_FRAMES ) ; final int horizontals = node . readInteger ( ATT_HORIZONTAL ) ; final int verticals = node . readInteger ( ATT_VERTICAL ) ; final int offsetX = node . readInteger ( 0 , ATT_OFFSET_X ) ; final ... | Imports the frames config from node . |
3,682 | public static Xml exports ( FramesConfig config ) { Check . notNull ( config ) ; final Xml node = new Xml ( NODE_FRAMES ) ; node . writeInteger ( ATT_HORIZONTAL , config . getHorizontal ( ) ) ; node . writeInteger ( ATT_VERTICAL , config . getVertical ( ) ) ; node . writeInteger ( ATT_OFFSET_X , config . getOffsetX ( )... | Exports the frames node from config . |
3,683 | public static Integer imports ( Configurer configurer ) { Check . notNull ( configurer ) ; if ( configurer . hasNode ( NODE_GROUP ) ) { final String group = configurer . getText ( NODE_GROUP ) ; try { return Integer . valueOf ( group ) ; } catch ( final NumberFormatException exception ) { throw new LionEngineException ... | Create the collidable data from node . |
3,684 | public static void exports ( Xml root , Collidable collidable ) { Check . notNull ( root ) ; Check . notNull ( collidable ) ; final Xml node = root . createChild ( NODE_GROUP ) ; node . setText ( collidable . getGroup ( ) . toString ( ) ) ; } | Create an XML node from a collidable . |
3,685 | public static boolean compareTile ( int tw , int th , ImageBuffer a , int xa , int ya , ImageBuffer b , int xb , int yb ) { for ( int x = 0 ; x < tw ; x ++ ) { for ( int y = 0 ; y < th ; y ++ ) { final int colorA = a . getRgb ( x + xa , y + ya ) ; final int colorB = b . getRgb ( x + xb , y + yb ) ; if ( colorA != color... | Compare two tiles by checking all pixels . |
3,686 | private static boolean isExtracted ( SpriteTiled level , int x , int y , Collection < ImageBuffer > tiles ) { final int tw = level . getTileWidth ( ) ; final int th = level . getTileHeight ( ) ; final ImageBuffer surface = level . getSurface ( ) ; for ( final ImageBuffer tile : tiles ) { if ( compareTile ( tw , th , su... | Check if tile has already been extracted regarding the current tile on level rip . |
3,687 | private static ImageBuffer extract ( SpriteTiled level , int number ) { final ColorRgba transparency = level . getSurface ( ) . getTransparentColor ( ) ; final ImageBuffer tile = Graphics . createImageBuffer ( level . getTileWidth ( ) , level . getTileHeight ( ) , transparency ) ; final Graphic g = tile . createGraphic... | Extract the tile from level . |
3,688 | private static int getTilesNumber ( int tileWidth , int tileHeight , Collection < Media > levelRips ) { int tiles = 0 ; for ( final Media levelRip : levelRips ) { final ImageHeader info = ImageInfo . get ( levelRip ) ; final int horizontalTiles = info . getWidth ( ) / tileWidth ; final int verticalTiles = info . getHei... | Get the total number of tiles . |
3,689 | private int extract ( Canceler canceler , SpriteTiled level , int tilesNumber , Collection < ImageBuffer > tiles , int checkedTiles ) { final int horizontalTiles = level . getTilesHorizontal ( ) ; final int verticalTiles = level . getTilesVertical ( ) ; final ImageBuffer surface = level . getSurface ( ) ; final int tw ... | Proceed the specified level rip . |
3,690 | private int updateProgress ( int checkedTiles , int tilesNumber , int oldPercent , Collection < ImageBuffer > tiles ) { final int percent = getProgressPercent ( checkedTiles , tilesNumber ) ; if ( percent != oldPercent ) { for ( final ProgressListener listener : listeners ) { listener . notifyProgress ( percent , tiles... | Update progress and notify if needed . |
3,691 | public void rotate ( double angle ) { final double x2 = x + width ; final double y2 = y ; final double x3 = x2 ; final double y3 = y + height ; final double x4 = x ; final double y4 = y3 ; final double cx = x + width / 2.0 ; final double cy = y + height / 2.0 ; final double a = UtilMath . wrapDouble ( angle , 0 , 360 )... | Rotate rectangle with specific angle . |
3,692 | public void set ( double x , double y , double w , double h ) { this . x = x ; this . y = y ; width = w ; height = h ; } | Sets the location and size . |
3,693 | public static Raster load ( Media media ) { Check . notNull ( media ) ; final Xml root = new Xml ( media ) ; final RasterData dataRed = RasterData . load ( root , CHANNEL_RED ) ; final RasterData dataGreen = RasterData . load ( root , CHANNEL_GREEN ) ; final RasterData dataBlue = RasterData . load ( root , CHANNEL_BLUE... | Load raster from media . |
3,694 | public static Collection < PathCategory > imports ( Media configPathfinding ) { Check . notNull ( configPathfinding ) ; final Xml nodeCategories = new Xml ( configPathfinding ) ; final Collection < Xml > childrenTile = nodeCategories . getChildren ( TILE_PATH ) ; final Collection < PathCategory > categories = new HashS... | Import the category data from configuration . |
3,695 | private void addBorderLabels ( ) { borderLabels = new JLabel [ 6 ] [ 6 ] ; int [ ] labelLocations_X_forColumn = new int [ ] { 0 , 1 , 2 , 3 , 4 , 11 } ; int [ ] labelLocations_Y_forRow = new int [ ] { 0 , 1 , 2 , 5 , 6 , 12 } ; int [ ] labelWidthsInCells_forColumn = new int [ ] { 0 , 1 , 1 , 1 , 7 , 1 } ; int [ ] label... | addBorderLabels This adds the border labels to the calendar panel and to the two dimensional border labels array . |
3,696 | private void addDateLabels ( ) { dateLabels = new ArrayList < JLabel > ( ) ; for ( int i = 0 ; i < 42 ; ++ i ) { int dateLabelColumnX = ( ( i % 7 ) ) + constantFirstDateLabelCell . x ; int dateLabelRowY = ( ( i / 7 ) + constantFirstDateLabelCell . y ) ; JLabel dateLabel = new JLabel ( ) ; dateLabel . setHorizontalAlign... | addDateLabels This adds a set of 42 date labels to the calendar and ties each of those labels to a mouse click event handler . The date labels are reused any time that the calendar is redrawn . |
3,697 | private void addWeekNumberLabels ( ) { weekNumberLabels = new ArrayList < JLabel > ( ) ; int weekNumberLabelColumnX = constantFirstWeekNumberLabelCell . x ; int weekNumberLabelWidthInCells = 1 ; int weekNumberLabelHeightInCells = 1 ; for ( int i = 0 ; i < 6 ; ++ i ) { int weekNumberLabelRowY = ( i + constantFirstWeekNu... | addWeekNumberLabels This adds a set of 6 week number labels to the calendar panel . The text of these labels is set with locale sensitive week numbers each time that the calendar is redrawn . |
3,698 | private void addWeekdayLabels ( ) { weekdayLabels = new ArrayList < JLabel > ( ) ; int weekdayLabelRowY = constantFirstWeekdayLabelCell . y ; int weekdayLabelWidthInCells = 1 ; int weekdayLabelHeightInCells = 3 ; for ( int i = 0 ; i < 7 ; ++ i ) { int weekdayLabelColumnX = ( i + constantFirstWeekdayLabelCell . x ) ; JL... | addWeekdayLabels This adds a set of 7 weekday labels to the calendar panel . The text of these labels is set with locale sensitive weekday names each time that the calendar is redrawn . |
3,699 | private void addTopLeftLabel ( ) { topLeftLabel = new JLabel ( ) ; topLeftLabel . setOpaque ( true ) ; topLeftLabel . setVisible ( false ) ; centerPanel . add ( topLeftLabel , CC . xywh ( constantTopLeftLabelCell . x , constantTopLeftLabelCell . y , 1 , 3 ) ) ; } | addTopLeftLabel This adds the top left label to the center panel . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.