if (tilesets == null || tilesets.isEmpty()) {
if (tileset == null) {
    public Dimension getPreferredSize() {        if (tilesets == null || tilesets.isEmpty()) {            return new Dimension(0, 0);        }        else {            TileSet tileset = (TileSet)tilesets.get(0);            int twidth = tileset.getTileWidth() + 1;            int theight = tileset.getTileHeight() + 1;            int tileCount = tileset.size();            int tilesPerRow = Math.max(1, (getWidth() - 1) / twidth);            int rows = tileCount / tilesPerRow +                    (tileCount % tilesPerRow > 0 ? 1 : 0);            return new Dimension(tilesPerRow * twidth + 1, rows * theight + 1);        }    }