src/gui/maptool/MapTool.java
private void loadHandler(ActionEvent event) {
        FileChooser fc = new FileChooser();
        File f = fc.showOpenDialog(null);
        if (f != null) {
            if (f.getName().endsWith(".jpeg")) {
                world = MapImage.loadWorldFromImage(f);
            } else if (f.getName().endsWith(".map")) {
                world = MapParser.parse(f);
            } else {
                System.err.println("Unknown map format.");
                return;
            }
            xDimension.setText(String.valueOf(world.xDimension));
            yDimension.setText(String.valueOf(world.yDimension));
            resetHandler(null);
            for (int x = 0; x < world.xDimension; x++) {
                for (int y = 0; y < world.yDimension; y++) {
                    cells[x][y].setValue(String.valueOf(world.grid[x][y].type.ordinal()));
                    cells[x][y].setLight(world.grid[x][y].light);
                }
            }
        }
    }
/**
     * Prompts the user for a file and loads it into
     * the editor.
     */
Prompts the user for a file and loads it into
the editor.
Prompts the user for a file and loads it into the editor .
private void loadHandler(ActionEvent event) {
        FileChooser fc = new FileChooser();
        File f = fc.showOpenDialog(null);
        if (f != null) {
            if (f.getName().endsWith(".jpeg")) {
                world = MapImage.loadWorldFromImage(f);
            } else if (f.getName().endsWith(".map")) {
                world = MapParser.parse(f);
            } else {
                System.err.println("Unknown map format.");
                return;
            }
            xDimension.setText(String.valueOf(world.xDimension));
            yDimension.setText(String.valueOf(world.yDimension));
            resetHandler(null);
            for (int x = 0; x < world.xDimension; x++) {
                for (int y = 0; y < world.yDimension; y++) {
                    cells[x][y].setValue(String.valueOf(world.grid[x][y].type.ordinal()));
                    cells[x][y].setLight(world.grid[x][y].light);
                }
            }
        }
    }
private void loadHandler ( ActionEvent event ) { FileChooser fc = new FileChooser ( ) ; File f = fc . showOpenDialog ( null ) ; if ( f != null ) { if ( f . getName ( ) . endsWith ( ".jpeg" ) ) { world = MapImage . loadWorldFromImage ( f ) ; } else if ( f . getName ( ) . endsWith ( ".map" ) ) { world = MapParser . parse ( f ) ; } else { System . err . println ( "Unknown map format." ) ; return ; } xDimension . setText ( String . valueOf ( world . xDimension ) ) ; yDimension . setText ( String . valueOf ( world . yDimension ) ) ; resetHandler ( null ) ; for ( int x = 0 ; x < world . xDimension ; x ++ ) { for ( int y = 0 ; y < world . yDimension ; y ++ ) { cells [ x ] [ y ] . setValue ( String . valueOf ( world . grid [ x ] [ y ] . type . ordinal ( ) ) ) ; cells [ x ] [ y ] . setLight ( world . grid [ x ] [ y ] . light ) ; } } } }
Prompts the user for a file and loads it into
 the editor.
Prompts the user for a file and loads it into the editor .