Vector tilesets = currentMap.getTilesets(); if (!tilesets.isEmpty()) { TileSet first = (TileSet)tilesets.get(0); tilePalettePanel.setTileset(first); setCurrentTile(first.getFirstTile()); } else { tilePalettePanel.setTileset(null); setCurrentTile(null); }
tilePaletteDialog.setMap(currentMap);
    public void setCurrentMap(Map newMap) {        currentMap = newMap;        boolean mapLoaded = currentMap != null;        // Create a default brush (protect against a bug with custom brushes)        ShapeBrush sb = new ShapeBrush();        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));        setBrush(sb);        if (!mapLoaded) {            mapEventAdapter.fireEvent(MapEventAdapter.ME_MAPINACTIVE);            mapView = null;            mapScrollPane.setViewportView(Box.createRigidArea(                        new Dimension(0,0)));            setCurrentPointerState(PS_POINT);            tileCoordsLabel.setPreferredSize(null);            tileCoordsLabel.setText(" ");            zoomLabel.setText(" ");            tilePalettePanel.setTileset(null);            setCurrentTile(null);            System.gc();        } else {            mapEventAdapter.fireEvent(MapEventAdapter.ME_MAPACTIVE);            mapView = MapView.createViewforMap(currentMap);            mapView.addMouseListener(this);            mapView.addMouseMotionListener(this);            mapView.addComponentListener(this);            JViewport mapViewport = new JViewport();            mapViewport.setView(mapView);            mapViewport.addChangeListener(this);            mapScrollPane.setViewport(mapViewport);            setCurrentPointerState(PS_PAINT);            currentMap.addMapChangeListener(this);            gridMenuItem.setState(mapView.getMode(MapView.PF_GRIDMODE));            coordinatesMenuItem.setState(                    mapView.getMode(MapView.PF_COORDINATES));            Vector tilesets = currentMap.getTilesets();            if (!tilesets.isEmpty()) {                TileSet first = (TileSet)tilesets.get(0);                tilePalettePanel.setTileset(first);                setCurrentTile(first.getFirstTile());            } else {                tilePalettePanel.setTileset(null);                setCurrentTile(null);            }            tileCoordsLabel.setText(String.valueOf(currentMap.getWidth() - 1)                    + ", " + (currentMap.getHeight() - 1));            tileCoordsLabel.setPreferredSize(null);            Dimension size = tileCoordsLabel.getPreferredSize();            tileCoordsLabel.setText(" ");            tileCoordsLabel.setMinimumSize(size);            tileCoordsLabel.setPreferredSize(size);            zoomLabel.setText(                    String.valueOf((int) (mapView.getZoom() * 100)) + "%");        }        zoomInAction.setEnabled(mapLoaded);        zoomOutAction.setEnabled(mapLoaded);        zoomNormalAction.setEnabled(mapLoaded && mapView.getZoomLevel() !=                MapView.ZOOM_NORMALSIZE);        if (tilePaletteDialog != null) {            tilePaletteDialog.setMap(currentMap);        }        /*        if (miniMap != null && currentMap != null) {            miniMap.setView(MapView.createViewforMap(currentMap));        }        */        if (currentMap != null) {            currentMap.addLayerSpecial(cursorHighlight);        }        undoHandler.discardAllEdits();        updateLayerTable();        updateTitle();    }