[tiled] r579 - in branches/bjorn/src/tiled: core mapeditor mapeditor/dialogs mapeditor/resources mapeditor/util

svn@biggeruniverse.com svn at biggeruniverse.com
Sat Feb 11 08:35:31 PST 2006


Author: bjorn
Date: 2006-02-11 10:35:31 -0600 (Sat, 11 Feb 2006)
New Revision: 579

Added:
   branches/bjorn/src/tiled/core/LayerLockedException.java
   branches/bjorn/src/tiled/mapeditor/Resources.java
   branches/bjorn/src/tiled/mapeditor/resources/gui.properties
   branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties
Modified:
   branches/bjorn/src/tiled/core/Map.java
   branches/bjorn/src/tiled/core/TileLayer.java
   branches/bjorn/src/tiled/mapeditor/MapEditor.java
   branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/TilesetManager.java
   branches/bjorn/src/tiled/mapeditor/util/MultisetListRenderer.java
Log:
Introduced Resources class for loading icons and internationalized strings. Also added LayerLockedException to be able to catch this error more specifically and fixed a small compile bug when using Java 1.4.

Added: branches/bjorn/src/tiled/core/LayerLockedException.java
===================================================================
--- branches/bjorn/src/tiled/core/LayerLockedException.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/core/LayerLockedException.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -0,0 +1,13 @@
+package tiled.core;
+
+/**
+ * This exception is thrown when an attempt is made to perform a modification
+ * on a locked layer.
+ *
+ * @version $Id$
+ */
+public class LayerLockedException extends Throwable {
+    public LayerLockedException(String s) {
+        super(s);
+    }
+}


Property changes on: branches/bjorn/src/tiled/core/LayerLockedException.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: branches/bjorn/src/tiled/core/Map.java
===================================================================
--- branches/bjorn/src/tiled/core/Map.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/core/Map.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -176,9 +176,9 @@
      * processing is complete.
      *
      * @param s TileSet to remove
-     * @throws Exception
+     * @throws LayerLockedException
      */
-    public void removeTileset(TileSet s) throws Exception{
+    public void removeTileset(TileSet s) throws LayerLockedException {
         // Sanity check
         if (tilesets.indexOf(s) == -1)
             return;

Modified: branches/bjorn/src/tiled/core/TileLayer.java
===================================================================
--- branches/bjorn/src/tiled/core/TileLayer.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/core/TileLayer.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -19,16 +19,17 @@
 /**
  * A TileLayer is a specialized MapLayer, used for tracking two dimensional
  * tile data.
+ *
+ * @version $Id$
  */
 public class TileLayer extends MapLayer
 {
-    protected Tile map[][];
+    protected Tile[][] map;
 
     /**
      * Default contructor
      */
     public TileLayer() {
-        super();
     }
 
     /**
@@ -148,9 +149,9 @@
         for (int y = 0; y < bounds.height; y++) {
             for (int x = 0; x < bounds.width; x++) {
                 if (dir == MIRROR_VERTICAL) {
-                    mirror[y][x] = map[(bounds.height - 1) - y][x];
+                    mirror[y][x] = map[bounds.height - 1 - y][x];
                 } else {
-                    mirror[y][x] = map[y][(bounds.width - 1) - x];
+                    mirror[y][x] = map[y][bounds.width - 1 - x];
                 }
             }
         }
@@ -232,11 +233,11 @@
      * is locked, an exception is thrown.
      *
      * @param tile the Tile to be removed
-     * @throws Exception
+     * @throws LayerLockedException
      */
-    public void removeTile(Tile tile) throws Exception {
+    public void removeTile(Tile tile) throws LayerLockedException {
         if (getLocked()) {
-            throw new Exception(
+            throw new LayerLockedException(
                     "Attempted to remove tile when this layer is locked.");
         }
 
@@ -410,7 +411,7 @@
      * @exception CloneNotSupportedException
      */
     public Object clone() throws CloneNotSupportedException {
-        TileLayer clone = null;
+        TileLayer clone;
         clone = (TileLayer)super.clone();
 
         // Clone the layer data

Modified: branches/bjorn/src/tiled/mapeditor/MapEditor.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/MapEditor.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/MapEditor.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -145,8 +145,7 @@
 
         /*
         try {
-            Image imgPaintCursor = loadImageResource(
-                    "resources/cursor-pencil.png");
+            Image imgPaintCursor = Resources.getImage("cursor-pencil.png");
 
             curPaint = Toolkit.getDefaultToolkit().createCustomCursor(
                     imgPaintCursor, new Point(0,0), "paint");
@@ -462,13 +461,13 @@
      *
      */
     private void createToolbox() {
-        Icon iconMove = loadIcon("resources/gimp-tool-move-22.png");
-        Icon iconPaint = loadIcon("resources/gimp-tool-pencil-22.png");
-        Icon iconErase = loadIcon("resources/gimp-tool-eraser-22.png");
-        Icon iconPour = loadIcon("resources/gimp-tool-bucket-fill-22.png");
-        Icon iconEyed = loadIcon("resources/gimp-tool-color-picker-22.png");
-        Icon iconMarquee = loadIcon("resources/gimp-tool-rect-select-22.png");
-        Icon iconMoveObject = loadIcon("resources/gimp-tool-object-move-22.png");
+        Icon iconMove = Resources.getIcon("gimp-tool-move-22.png");
+        Icon iconPaint = Resources.getIcon("gimp-tool-pencil-22.png");
+        Icon iconErase = Resources.getIcon("gimp-tool-eraser-22.png");
+        Icon iconPour = Resources.getIcon("gimp-tool-bucket-fill-22.png");
+        Icon iconEyed = Resources.getIcon("gimp-tool-color-picker-22.png");
+        Icon iconMarquee = Resources.getIcon("gimp-tool-rect-select-22.png");
+        Icon iconMoveObject = Resources.getIcon("gimp-tool-object-move-22.png");
 
         paintButton = createToggleButton(iconPaint, "paint", "Paint");
         eraseButton = createToggleButton(iconErase, "erase", "Erase");
@@ -519,11 +518,11 @@
         dataPanel = new JPanel(new BorderLayout());
 
         // Try to load the icons
-        Icon imgAdd = loadIcon("resources/gnome-new.png");
-        Icon imgDel = loadIcon("resources/gnome-delete.png");
-        Icon imgDup = loadIcon("resources/gimp-duplicate-16.png");
-        Icon imgUp = loadIcon("resources/gnome-up.png");
-        Icon imgDown = loadIcon("resources/gnome-down.png");
+        Icon imgAdd = Resources.getIcon("gnome-new.png");
+        Icon imgDel = Resources.getIcon("gnome-delete.png");
+        Icon imgDup = Resources.getIcon("gimp-duplicate-16.png");
+        Icon imgUp = Resources.getIcon("gnome-up.png");
+        Icon imgDown = Resources.getIcon("gnome-down.png");
 
         //navigation and tool options
         // TODO: the minimap is prohibitively slow, need to speed this up
@@ -1332,33 +1331,33 @@
                     putValue(SHORT_DESCRIPTION,
                             "Rotate layer 90 degrees clockwise");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-rotate-90-16.png"));
+                            Resources.getIcon("gimp-rotate-90-16.png"));
                     break;
                 case MapLayer.ROTATE_180:
                     putValue(NAME, "Rotate 180 degrees CW");
                     putValue(SHORT_DESCRIPTION,
                             "Rotate layer 180 degrees clockwise");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-rotate-180-16.png"));
+                            Resources.getIcon("gimp-rotate-180-16.png"));
                     break;
                 case MapLayer.ROTATE_270:
                     putValue(NAME, "Rotate 90 degrees CCW");
                     putValue(SHORT_DESCRIPTION,
                             "Rotate layer 90 degrees counterclockwise");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-rotate-270-16.png"));
+                            Resources.getIcon("gimp-rotate-270-16.png"));
                     break;
                 case MapLayer.MIRROR_VERTICAL:
                     putValue(NAME, "Flip vertically");
                     putValue(SHORT_DESCRIPTION, "Flip layer vertically");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-flip-vertical-16.png"));
+                            Resources.getIcon("gimp-flip-vertical-16.png"));
                     break;
                 case MapLayer.MIRROR_HORIZONTAL:
                     putValue(NAME, "Flip horizontally");
                     putValue(SHORT_DESCRIPTION, "Flip layer horizontally");
                     putValue(SMALL_ICON,
-                            loadIcon("resources/gimp-flip-horizontal-16.png"));
+                            Resources.getIcon("gimp-flip-horizontal-16.png"));
                     break;
             }
         }
@@ -1475,7 +1474,7 @@
             putValue(ACCELERATOR_KEY,
                     KeyStroke.getKeyStroke("control EQUALS"));
             putValue(SHORT_DESCRIPTION, "Zoom in one level");
-            putValue(SMALL_ICON, loadIcon("resources/gnome-zoom-in.png"));
+            putValue(SMALL_ICON, Resources.getIcon("gnome-zoom-in.png"));
         }
         public void actionPerformed(ActionEvent evt) {
             if (currentMap != null) {
@@ -1495,7 +1494,7 @@
             putValue(ACCELERATOR_KEY,
                     KeyStroke.getKeyStroke("control MINUS"));
             putValue(SHORT_DESCRIPTION, "Zoom out one level");
-            putValue(SMALL_ICON, loadIcon("resources/gnome-zoom-out.png"));
+            putValue(SMALL_ICON, Resources.getIcon("gnome-zoom-out.png"));
         }
         public void actionPerformed(ActionEvent evt) {
             if (currentMap != null) {
@@ -1711,8 +1710,8 @@
     }
 
     private boolean unsavedChanges() {
-        return (currentMap != null && undoStack.canUndo() &&
-                !undoStack.isAllSaved());
+        return currentMap != null && undoStack.canUndo() &&
+                !undoStack.isAllSaved();
     }
 
     /**
@@ -1770,7 +1769,7 @@
                 ch = new JFileChooser(filename);
             }
 
-            MapWriter writers[] = pluginLoader.getWriters();
+            MapWriter[] writers = pluginLoader.getWriters();
             for(int i = 0; i < writers.length; i++) {
                 try {
                     ch.addChoosableFileFilter(new TiledFileFilter(
@@ -1872,12 +1871,12 @@
         JFileChooser ch = new JFileChooser(startLocation);
 
         try {
-            MapReader readers[] = pluginLoader.getReaders();
+            MapReader[] readers = pluginLoader.getReaders();
             for(int i = 0; i < readers.length; i++) {
                 ch.addChoosableFileFilter(new TiledFileFilter(
                             readers[i].getFilter(), readers[i].getName()));
             }
-        } catch (Throwable e) {
+        } catch (Exception e) {
             JOptionPane.showMessageDialog(appFrame,
                     "Error while loading plugins: " + e.getMessage(),
                     "Error while loading map",
@@ -1902,7 +1901,7 @@
         }
     }
 
-    private MapLayer createLayerCopy(MapLayer layer) {
+    private static MapLayer createLayerCopy(MapLayer layer) {
         if (layer instanceof TileLayer) {
             return new TileLayer((TileLayer)layer);
         } else if (layer instanceof ObjectGroup) {
@@ -1957,7 +1956,7 @@
 
     private void setCurrentMap(Map newMap) {
         currentMap = newMap;
-        boolean mapLoaded = (currentMap != null);
+        boolean mapLoaded = currentMap != null;
 
         if (!mapLoaded) {
             mapEventAdapter.fireEvent(MapEventAdapter.ME_MAPINACTIVE);
@@ -2123,27 +2122,6 @@
     }
 
     /**
-     * Loads an image that is part of the distribution jar
-     * 
-     * @param fname
-     * @return A BufferedImage instance of the image
-     * @throws IOException
-     */
-    public static BufferedImage loadImageResource(String fname)
-        throws IOException {
-        return ImageIO.read(MapEditor.class.getResourceAsStream(fname));
-    }
-
-    private static ImageIcon loadIcon(String fname) {
-        try {
-            return new ImageIcon(loadImageResource(fname));
-        } catch (IOException e) {
-            System.out.println("Failed to load icon: " + fname);
-            return null;
-        }
-    }
-
-    /**
      * Starts Tiled.
      *
      * @param args the first argument may be a map file

Added: branches/bjorn/src/tiled/mapeditor/Resources.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/Resources.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/Resources.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -0,0 +1,82 @@
+/*
+ *  Tiled Map Editor, (c) 2004-2006
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  Adam Turk <aturk at biggeruniverse.com>
+ *  Bjorn Lindeijer <b.lindeijer at xs4all.nl>
+ */
+
+package tiled.mapeditor;
+
+import java.util.ResourceBundle;
+import java.awt.Image;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+/**
+ * This class implements static accessors to common editor resources. These
+ * currently include icons and internationalized strings.
+ *
+ * @version $Id$
+ */
+public class Resources {
+    // The resource bundle used by this class
+    private static final ResourceBundle resourceBundle =
+            ResourceBundle.getBundle(
+                    Resources.class.getPackage().getName() + ".resources.gui");
+
+    // Prevent instanciation
+    private Resources() {
+    }
+
+    /**
+     * Retrieves a string from the resource bundle in the default locale.
+     *
+     * @param key the key for the desired string
+     * @return the string for the given key
+     */
+    public static String getString(String key) {
+        return resourceBundle.getString(key);
+    }
+
+    /**
+     * Loads an image from the resources directory. This directory is part of
+     * the distribution jar.
+     *
+     * @param filename the filename relative from the resources directory
+     * @return A BufferedImage instance of the image
+     * @throws IOException if an error occurs during reading
+     * @throws IllegalArgumentException when the resource could not be found
+     */
+    private static Image getImage(String filename) throws IOException,
+            IllegalArgumentException {
+        return ImageIO.read(Resources.class.getResourceAsStream(
+                "resources/" + filename));
+    }
+
+    /**
+     * Loads the image using {@link #getImage(String)} and uses it to create
+     * a new {@link javax.swing.ImageIcon} instance.
+     *
+     * @param filename the filename of the image relative from the
+     *                 <code>resources</code> directory
+     * @return the loaded icon, or <code>null</code> when an error occured
+     *         while loading the image
+     */
+    public static Icon getIcon(String filename) {
+        try {
+            return new ImageIcon(getImage(filename));
+        } catch (IOException e) {
+            System.out.println("Failed to load as image: " + filename);
+        } catch (IllegalArgumentException e) {
+            System.out.println("Failed to load resource: " + filename);
+        }
+        return null;
+    }
+}


Property changes on: branches/bjorn/src/tiled/mapeditor/Resources.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -12,43 +12,42 @@
 
 package tiled.mapeditor.dialogs;
 
-import java.io.IOException;
-import javax.imageio.ImageIO;
-import javax.swing.*;
+import java.awt.event.MouseEvent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.BorderFactory;
+import javax.swing.JDialog;
+import javax.swing.event.MouseInputAdapter;
 
 import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 
-
 /**
  * The about dialog.
  *
  * @version $Id$
  */
-public class AboutDialog extends JFrame
+public class AboutDialog extends JDialog
 {
-    final JFrame parent;
+    private final JFrame parent;
 
     public AboutDialog(JFrame parent) {
-        super("Tiled v" + MapEditor.version);
+        super(parent, "Tiled v" + MapEditor.version);
 
         this.parent = parent;
-        ImageIcon icon;
 
-        try {
-            icon = new ImageIcon(ImageIO.read(MapEditor.class.
-                        getResourceAsStream("resources/logo.png")));
+        JLabel label = new JLabel(Resources.getIcon("logo.png"));
+        label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+        label.addMouseListener(new MouseInputAdapter() {
+            public void mouseClicked(MouseEvent mouseEvent) {
+                setVisible(false);
+            }
+        });
 
-            JPanel content = new JPanel();
-            JLabel label = new JLabel(icon);
-            content.add(label);
-
-            setContentPane(content);
-            setResizable(false);
-            setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
-            pack();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
+        setContentPane(label);
+        setResizable(false);
+        setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+        pack();
     }
 
     public void setVisible(boolean visible) {

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -15,16 +15,15 @@
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.io.IOException;
 import java.util.Enumeration;
 import java.util.Properties;
 import javax.swing.*;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 
-import tiled.mapeditor.MapEditor;
-import tiled.mapeditor.util.*;
-import tiled.mapeditor.widget.*;
+import tiled.mapeditor.Resources;
+import tiled.mapeditor.util.PropertiesTableModel;
+import tiled.mapeditor.widget.VerticalStaticJPanel;
 
 public class PropertiesDialog extends JDialog implements ActionListener,
        ListSelectionListener
@@ -50,12 +49,8 @@
 
         bOk = new JButton("OK");
         bCancel = new JButton("Cancel");
-        try {
-            bDel = new JButton(new ImageIcon(MapEditor.loadImageResource("resources/gnome-delete.png")));
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        
+        bDel = new JButton(Resources.getIcon("gnome-delete.png"));
+
         bOk.addActionListener(this);
         bCancel.addActionListener(this);
         bDel.addActionListener(this);

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/TilesetManager.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/TilesetManager.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/TilesetManager.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -25,9 +25,9 @@
 import tiled.core.*;
 import tiled.io.MapHelper;
 import tiled.io.MapWriter;
-import tiled.mapeditor.dialogs.TileDialog;
 import tiled.mapeditor.util.*;
 import tiled.mapeditor.plugin.PluginClassLoader;
+import tiled.mapeditor.Resources;
 
 public class TilesetManager extends JDialog implements ActionListener,
        ListSelectionListener
@@ -125,23 +125,23 @@
                     int ret = JOptionPane.showConfirmDialog(this,
                             "This tileset is currently in use. " +
                             "Are you sure you wish to remove it?",
-                            "Sure?", JOptionPane.YES_NO_CANCEL_OPTION);
-                    if (ret == JOptionPane.YES_OPTION) {
-                        map.removeTileset(set);
-                        updateTilesetTable();
+                            "Sure?", JOptionPane.YES_NO_OPTION);
+                    if (ret != JOptionPane.YES_OPTION) {
+                        return;
                     }
-                } else {
-                    map.removeTileset(set);
-                    updateTilesetTable();
                 }
-            } catch (ArrayIndexOutOfBoundsException a) {
-            } catch (Exception e) {
-                JOptionPane.showMessageDialog(this, e.getMessage());
+                map.removeTileset(set);
+                updateTilesetTable();
+            } catch (LayerLockedException e) {
+                JOptionPane.showMessageDialog(this,
+                        Resources.getString("action.tileset.remove.error.layer-locked.message"),
+                        Resources.getString("action.tileset.remove.error.title"),
+                        JOptionPane.ERROR_MESSAGE);
             }
         } else if (command.equals("Save as...")) {
             JFileChooser ch = new JFileChooser(map.getFilename());
 
-            MapWriter writers[] = PluginClassLoader.getInstance().getWriters();
+            MapWriter[] writers = PluginClassLoader.getInstance().getWriters();
             for (int i = 0; i < writers.length; i++) {
                 try {
                     ch.addChoosableFileFilter(new TiledFileFilter(
@@ -157,11 +157,9 @@
                 String filename = ch.getSelectedFile().getAbsolutePath();
                 File exist = new File(filename);
 
-                if ((exist.exists()
-                      && JOptionPane.showConfirmDialog(this,
-                        "The file already exists. Do you wish to overwrite it?"
-                        ) == JOptionPane.OK_OPTION)
-                    || !exist.exists()) {
+                if (exist.exists() && JOptionPane.showConfirmDialog(this,
+                        Resources.getString("general.file.exists.message")) ==
+                        JOptionPane.OK_OPTION || !exist.exists()) {
                     try {
                         MapHelper.saveTileset(set, filename);
                         set.setSource(filename);

Added: branches/bjorn/src/tiled/mapeditor/resources/gui.properties
===================================================================
--- branches/bjorn/src/tiled/mapeditor/resources/gui.properties	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/resources/gui.properties	2006-02-11 16:35:31 UTC (rev 579)
@@ -0,0 +1,4 @@
+action.tileset.remove.error.title=Error while removing tileset
+action.tileset.remove.error.layer-locked.message=A layer containing tiles used by this tileset is locked,\n\
+  it needs to be unlocked before the tileset can be completely removed.
+general.file.exists.message=The file already exists. Do you wish to overwrite it?
\ No newline at end of file

Added: branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties
===================================================================
--- branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties	2006-02-11 16:35:31 UTC (rev 579)
@@ -0,0 +1,4 @@
+action.tileset.remove.error.title=Fout tijdens verwijderen tileset
+action.tileset.remove.error.layer-locked.message=Een laag met tiles uit deze tileset is vergrendeld en moet worden\n\
+  ontgrendeld voordat de tileset helemaal kan worden verwijderd.
+general.file.exists.message=Een bestand met dezelfde naam bestaat al. Wil je deze overschrijven?
\ No newline at end of file

Modified: branches/bjorn/src/tiled/mapeditor/util/MultisetListRenderer.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/util/MultisetListRenderer.java	2006-02-11 14:10:30 UTC (rev 578)
+++ branches/bjorn/src/tiled/mapeditor/util/MultisetListRenderer.java	2006-02-11 16:35:31 UTC (rev 579)
@@ -19,7 +19,7 @@
 
 import tiled.core.Tile;
 import tiled.core.TileSet;
-import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 
 /**
  * This list renderer is used for rendering a list of tiles associated with a
@@ -30,10 +30,16 @@
  *
  * @version $Id$
  */
-public class MultisetListRenderer extends DefaultListCellRenderer {
-    private Icon setIcon;
+public class MultisetListRenderer extends DefaultListCellRenderer
+{
+    /** The icon to show for tilesets. */
+    private final Icon setIcon = Resources.getIcon("source.png");
+
+    /** The hash map used to match indexes to icons. */
+    private final HashMap tileImages = new HashMap();
+
+    /** The zoom level used for the tile image icons. */
     private final double zoom;
-    private final HashMap tileImages;
 
     /**
      * Creates the list renderer for rendering a list of tiles.
@@ -41,16 +47,7 @@
      * @param zoom the zoom level at which the tiles will be shown
      */
     public MultisetListRenderer(double zoom) {
-        tileImages = new HashMap();
         this.zoom = zoom;
-
-        try {
-            // Load the icon to show for tilesets
-            Image img = MapEditor.loadImageResource("resources/source.png");
-            setIcon = new ImageIcon(img);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
     }
 
     public Component getListCellRendererComponent(JList list, Object value,
@@ -65,7 +62,7 @@
             Tile tile = (Tile) value;
             if (!isSelected || zoom == 1) {
                 // Use cached ImageIcon instance
-                final Integer key = Integer.valueOf(index);
+                final Integer key = new Integer(index);
                 if (tileImages.containsKey(key)) {
                     setIcon((Icon) tileImages.get(key));
                 } else {




More information about the tiled-commit mailing list