[tiled] r581 - in branches/bjorn: . src/tiled/core src/tiled/io src/tiled/io/xml src/tiled/mapeditor/brush src/tiled/mapeditor/dialogs src/tiled/mapeditor/resources src/tiled/mapeditor/undo src/tiled/mapeditor/widget

svn@biggeruniverse.com svn at biggeruniverse.com
Sun Feb 12 06:51:26 PST 2006


Author: bjorn
Date: 2006-02-12 08:51:25 -0600 (Sun, 12 Feb 2006)
New Revision: 581

Modified:
   branches/bjorn/CHANGES
   branches/bjorn/src/tiled/core/ObjectGroup.java
   branches/bjorn/src/tiled/io/MapHelper.java
   branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java
   branches/bjorn/src/tiled/mapeditor/brush/Brush.java
   branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java
   branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java
   branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java
   branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/ObjectDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java
   branches/bjorn/src/tiled/mapeditor/dialogs/TileDialog.java
   branches/bjorn/src/tiled/mapeditor/resources/gui.properties
   branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties
   branches/bjorn/src/tiled/mapeditor/undo/MapLayerStateEdit.java
   branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java
   branches/bjorn/src/tiled/mapeditor/widget/ImageViewPanel.java
   branches/bjorn/src/tiled/mapeditor/widget/IntegerSpinner.java
Log:
Internationalized and localized to Dutch the New Tileset and Resize Map dialogs. Also fixed the new tileset dialog to allow choosing a different tile height than used by the map and got rid of some remaining redundant "this." and "super()" references.

Modified: branches/bjorn/CHANGES
===================================================================
--- branches/bjorn/CHANGES	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/CHANGES	2006-02-12 14:51:25 UTC (rev 581)
@@ -5,6 +5,8 @@
 * Fixed a bug when exporting a tileset with an external image
 * Fixed two cases of hanging when using the fill tool
 * Fixed loading of layer visibility attribute
+* Fixed tileset dialog so that it is now possible to change the tile height to
+  something else than the tile height used by the map.
 
 Planned changes
 + Added the Shifted view, which emulates several tiling configurations

Modified: branches/bjorn/src/tiled/core/ObjectGroup.java
===================================================================
--- branches/bjorn/src/tiled/core/ObjectGroup.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/core/ObjectGroup.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -16,14 +16,15 @@
 import java.awt.geom.Area;
 import java.util.*;
 
-
+/**
+ * @version $Id$
+ */
 public class ObjectGroup extends MapLayer
 {
     
     private LinkedList boundObjects;
     
     public ObjectGroup() {
-    	super();
     	boundObjects = new LinkedList();
     }
     /**

Modified: branches/bjorn/src/tiled/io/MapHelper.java
===================================================================
--- branches/bjorn/src/tiled/io/MapHelper.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/io/MapHelper.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -28,6 +28,8 @@
 
 /**
  * A handler for saving and loading maps.
+ *
+ * @version $Id$
  */
 public class MapHelper {
     private static PluginClassLoader pluginLoader;

Modified: branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -289,9 +289,10 @@
 
             try {
             	//just a little check for tricky people...
-            	if(!source.substring(source.lastIndexOf('.')+1).toLowerCase().equals("tsx")) {
-            		warnings.push("WARN: tileset files should end in .tsx! ("+source+")");
-            	}
+                String extention = source.substring(source.lastIndexOf('.') + 1);
+                if (!extention.toLowerCase().equals("tsx")) {
+                    warnings.push("WARN: tileset files should end in .tsx! ("+source+")");
+                }
             	
                 InputStream in = new URL(makeUrl(filename)).openStream();
                 ext = unmarshalTilesetFile(in, filename);

Modified: branches/bjorn/src/tiled/mapeditor/brush/Brush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/Brush.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/brush/Brush.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -21,7 +21,6 @@
 public abstract class Brush extends MultilayerPlane
 {
     public Brush() {
-        super();
     }
 
     /**

Modified: branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -25,12 +25,11 @@
 public class CustomBrush extends AbstractBrush
 {
     public CustomBrush() {
-        super();
     }
 
     public CustomBrush(MultilayerPlane m) {
         this();
-        this.addAllLayers(m.getLayerVector());
+        addAllLayers(m.getLayerVector());
     }
 
     public void setAffectedLayers(int num) {
@@ -55,9 +54,9 @@
     public Rectangle commitPaint(MultilayerPlane mp, int x, int y,
             int initLayer)
     {
-        Rectangle bounds = this.getBounds();
-        int centerx = x - (bounds.width / 2);
-        int centery = y - (bounds.height / 2);
+        Rectangle bounds = getBounds();
+        int centerx = x - bounds.width / 2;
+        int centery = y - bounds.height / 2;
 
         ListIterator itr = getLayers();
         while (itr.hasNext()) {

Modified: branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -27,11 +27,6 @@
     private final MersenneTwister mt;
     private double ratio = 0.5;
 
-    public RandomBrush() {
-        super();
-        mt = new MersenneTwister(System.currentTimeMillis());
-    }
-
     public RandomBrush(Area shape) {
         super(shape);
         mt = new MersenneTwister(System.currentTimeMillis());
@@ -69,15 +64,15 @@
             int initLayer)
     {
         Rectangle bounds = shape.getBounds();
-        int centerx = x - (bounds.width / 2);
-        int centery = y - (bounds.height / 2);
+        int centerx = x - bounds.width / 2;
+        int centery = y - bounds.height / 2;
 
         for (int i = 0; i < numLayers; i++) {
             TileLayer tl = (TileLayer)mp.getLayer(initLayer - i);
             if (tl != null) {
                 for (int cy = 0; cy <= bounds.height; cy++) {
                     for (int cx = 0; cx < bounds.width; cx++) {
-                        if (shape.contains(cx, cy) && (mt.genrand() % 101) <= (100 * ratio)) {
+                        if (shape.contains(cx, cy) && mt.genrand() % 101 <= 100 * ratio) {
                             tl.setTileAt(
                                     cx + centerx, cy + centery, paintTile);
                         }

Modified: branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -32,11 +32,9 @@
     protected Tile paintTile;
 
     public ShapeBrush() {
-        super();
     }
 
     public ShapeBrush(Area shape) {
-        super();
         this.shape = shape;
     }
 
@@ -55,7 +53,7 @@
      */
     public void makeCircleBrush(double rad) {
         shape = new Area(new Ellipse2D.Double(0, 0, rad * 2, rad * 2));
-        this.resize((int)(rad * 2), (int)(rad * 2), 0, 0);
+        resize((int)(rad * 2), (int)(rad * 2), 0, 0);
     }
 
     /**
@@ -65,7 +63,7 @@
      */
     public void makeQuadBrush(Rectangle r) {
         shape = new Area(new Rectangle2D.Double(r.x, r.y, r.width, r.height));
-        this.resize(r.width, r.height, 0, 0);
+        resize(r.width, r.height, 0, 0);
     }
 
     public void makePolygonBrush(Polygon p) {
@@ -94,12 +92,12 @@
      */
     public Rectangle commitPaint(MultilayerPlane mp, int x, int y, int initLayer) {
         Rectangle bounds = shape.getBounds();
-        int centerx = x - (bounds.width / 2);
-        int centery = y - (bounds.height / 2);
+        int centerx = x - bounds.width / 2;
+        int centery = y - bounds.height / 2;
 
         // TODO: This loop does not take all edges into account
 
-        for(int l = 0; l < numLayers; l++) {
+        for (int l = 0; l < numLayers; l++) {
             TileLayer tl = (TileLayer)mp.getLayer(initLayer - l);
             if (tl != null) {
                 for (int i = 0; i <= bounds.height + 1; i++) {

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -34,14 +34,9 @@
     private JButton bCancel;
     private Color color;
     private JPanel colorPanel;
-    private int pixels[];
+    private int[] pixels;
 
-    public ImageColorDialog() {
-        super();
-    }
-
     public ImageColorDialog(Image i) {
-        this();
         image = i;
         PixelGrabber pg = new PixelGrabber(i, 0, 0, -1, -1, true);
 
@@ -141,9 +136,9 @@
         int w = image.getWidth(null);
         int h = image.getHeight(null);
         if (pixels != null && (x < w && y < h)) {
-            int r = (pixels[y * w + x] >> 16) & 0xff;
-            int g = (pixels[y * w + x] >> 8) & 0xff;
-            int b = (pixels[y * w + x]) & 0xff;
+            int r = pixels[y * w + x] >> 16 & 0xff;
+            int g = pixels[y * w + x] >> 8 & 0xff;
+            int b = pixels[y * w + x] & 0xff;
 
             color = new Color(r, g, b);
             colorPanel.setBackground(color);

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -28,33 +28,48 @@
 import tiled.mapeditor.widget.IntegerSpinner;
 import tiled.mapeditor.widget.ColorButton;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
+import tiled.mapeditor.Resources;
 
-
 /**
  * A dialog for creating a new tileset.
  *
  * @version $Id$
  */
-public class NewTilesetDialog extends JDialog implements ActionListener,
-       ChangeListener
+public class NewTilesetDialog extends JDialog implements ChangeListener
 {
     private final Map map;
     private TileSet newTileset;
-    private JTextField tileWidth, tileHeight;
+    private IntegerSpinner tileWidth, tileHeight;
     private IntegerSpinner tileSpacing;
     private JTextField tilesetName;
     private JTextField tilebmpFile;
-    private JLabel nameLabel, tileWidthLabel, tileHeightLabel, spacingLabel;
+    private JLabel spacingLabel;
     private JLabel tilebmpFileLabel;
     private JCheckBox tilebmpCheck, tileAutoCheck, transCheck;
-    private JRadioButton importRadio;
-    private JRadioButton referenceRadio;
-    private JButton okButton, cancelButton, browseButton;
+    private JButton browseButton;
     private ColorButton colorButton;
     private String path;
 
+    private static final String DIALOG_TITLE = Resources.getString("dialog.newtileset.title");
+    private static final String NAME_LABEL = Resources.getString("dialog.newtileset.name.label");
+    private static final String TILE_WIDTH_LABEL = Resources.getString("dialog.newtileset.tilewidth.label");
+    private static final String TILE_HEIGHT_LABEL = Resources.getString("dialog.newtileset.tileheight.label");
+    private static final String TILE_SPACING_LABEL = Resources.getString("dialog.newtileset.tilespacing.label");
+    private static final String IMAGE_LABEL = Resources.getString("dialog.newtileset.image.label");
+    private static final String UNTITLED_FILE = Resources.getString("general.file.untitled");
+    private static final String TILESET_IMG_LABEL = Resources.getString("dialog.newtileset.tilesetimgref.label");
+    private static final String AUTO_TILES_LABEL = Resources.getString("dialog.newtileset.autotiles.label");
+    private static final String USE_TRANS_COLOR_LABEL = Resources.getString("dialog.newtileset.usetransparentcolor.label");
+    private static final String OK_BUTTON = Resources.getString("general.button.ok");
+    private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+    private static final String BROWSE_BUTTON = Resources.getString("general.button.browse");
+    private static final String FROM_TILESET_IMG_TITLE = Resources.getString("dialog.newtileset.fromtilesetimg.title");
+    private static final String IMPORT_ERROR_MSG = Resources.getString("dialog.newtileset.import.error.message");
+    private static final String IMG_LOAD_ERROR = Resources.getString("dialog.newtileset.imgload.error.message");
+    private static final String COLOR_CHOOSE_ERROR_TITLE = Resources.getString("dialog.newtileset.colorchoose.error.title");
+
     public NewTilesetDialog(JFrame parent, Map map) {
-        super(parent, "New Tileset", true);
+        super(parent, DIALOG_TITLE, true);
         this.map = map;
         path = map.getFilename();
         init();
@@ -65,51 +80,53 @@
     private void init() {
         // Create the primitives
 
-        nameLabel = new JLabel("Tileset name: ");
-        tileWidthLabel = new JLabel("Tile width: ");
-        tileHeightLabel = new JLabel("Tile height: ");
-        spacingLabel = new JLabel("Tile spacing: ");
-        tilebmpFileLabel = new JLabel("Tile image: ");
+        JLabel nameLabel = new JLabel(NAME_LABEL);
+        JLabel tileWidthLabel = new JLabel(TILE_WIDTH_LABEL);
+        JLabel tileHeightLabel = new JLabel(TILE_HEIGHT_LABEL);
+        spacingLabel = new JLabel(TILE_SPACING_LABEL);
+        tilebmpFileLabel = new JLabel(IMAGE_LABEL);
 
-        tilesetName = new JTextField("Untitled");
-        tileWidth = new JTextField("" + map.getTileWidth(), 3);
-        tileHeight = new JTextField("" + map.getTileHeight(), 3);
+        tilesetName = new JTextField(UNTITLED_FILE);
+        tileWidth = new IntegerSpinner(map.getTileWidth(), 1, 1024);
+        tileHeight = new IntegerSpinner(map.getTileHeight(), 1, 1024);
         tileSpacing = new IntegerSpinner(0, 0);
         tilebmpFile = new JTextField(10);
         tilebmpFile.setEnabled(false);
 
+        nameLabel.setLabelFor(tilesetName);
+        tileWidthLabel.setLabelFor(tileWidth);
+        tileHeightLabel.setLabelFor(tileHeight);
+        spacingLabel.setLabelFor(tileSpacing);
+        tilebmpFileLabel.setLabelFor(tilebmpFile);
+
         tileWidthLabel.setEnabled(false);
-        tileHeightLabel.setEnabled(false);
         tileWidth.setEnabled(false);
-        tileHeight.setEnabled(false);
 
-        tilebmpCheck = new JCheckBox("Reference tileset image", false);
+        tilebmpCheck = new JCheckBox(TILESET_IMG_LABEL, false);
         tilebmpCheck.addChangeListener(this);
 
-        tileAutoCheck = new JCheckBox("Automatically create tiles from images",
-                                      true);
+        tileAutoCheck = new JCheckBox(AUTO_TILES_LABEL, true);
         tileAutoCheck.setEnabled(false);
 
-        transCheck = new JCheckBox("Use transparent color");
+        transCheck = new JCheckBox(USE_TRANS_COLOR_LABEL);
         transCheck.addChangeListener(this);
 
-        okButton = new JButton("OK");
-        cancelButton = new JButton("Cancel");
-        browseButton = new JButton("Browse...");
+        JButton okButton = new JButton(OK_BUTTON);
+        JButton cancelButton = new JButton(CANCEL_BUTTON);
+        browseButton = new JButton(BROWSE_BUTTON);
         colorButton = new ColorButton(new Color(255, 0, 255));
-        okButton.addActionListener(this);
-        cancelButton.addActionListener(this);
-        browseButton.addActionListener(this);
-        colorButton.addActionListener(this);
 
         // Combine browse button and tile bitmap path text field
 
         JPanel tilebmpPathPanel = new JPanel(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
-        c.gridx = 0; c.gridy = 0; c.weightx = 1;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 1;
         c.fill = GridBagConstraints.HORIZONTAL;
         tilebmpPathPanel.add(tilebmpFile, c);
-        c.gridx = 1; c.weightx = 0;
+        c.gridx = 1;
+        c.weightx = 0;
         c.fill = GridBagConstraints.NONE;
         c.insets = new Insets(0, 5, 0, 0);
         tilebmpPathPanel.add(browseButton, c);
@@ -118,7 +135,9 @@
 
         JPanel tileColorPanel = new JPanel(new GridBagLayout());
         c = new GridBagConstraints();
-        c.gridx = 0; c.gridy = 0; c.weightx = 1;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 1;
         c.fill = GridBagConstraints.HORIZONTAL;
         tileColorPanel.add(transCheck, c);
         c.gridx = 1;
@@ -129,9 +148,11 @@
         JPanel tilebmpPanel = new VerticalStaticJPanel();
         tilebmpPanel.setLayout(new GridBagLayout());
         tilebmpPanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("From tileset image"),
-                    BorderFactory.createEmptyBorder(0, 5, 5, 5)));
-        c.gridx = 0; c.gridy = 0; c.weightx = 0;
+                BorderFactory.createTitledBorder(FROM_TILESET_IMG_TITLE),
+                BorderFactory.createEmptyBorder(0, 5, 5, 5)));
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 0;
         c.insets = new Insets(5, 0, 0, 0);
         c.anchor = GridBagConstraints.EAST;
         c.fill = GridBagConstraints.HORIZONTAL;
@@ -139,19 +160,27 @@
         tilebmpPanel.add(tilebmpCheck, c);
         c.gridy = 1;
         tilebmpPanel.add(tileAutoCheck, c);
-        c.gridy = 2; c.gridwidth = 1;
+        c.gridy = 2;
+        c.gridwidth = 1;
+        c.insets = new Insets(5, 0, 0, 5);
         c.fill = GridBagConstraints.NONE;
         tilebmpPanel.add(tilebmpFileLabel, c);
         c.gridy = 3;
         tilebmpPanel.add(spacingLabel, c);
-        c.gridx = 1; c.gridy = 2; c.weightx = 1;
+        c.gridx = 1;
+        c.gridy = 2;
+        c.weightx = 1;
+        c.insets = new Insets(5, 0, 0, 0);
         c.fill = GridBagConstraints.HORIZONTAL;
         tilebmpPanel.add(tilebmpPathPanel, c);
         c.gridy = 3;
         tilebmpPanel.add(tileSpacing, c);
-        c.gridx = 0; c.gridy = 4; c.gridwidth = 2;
+        c.gridx = 0;
+        c.gridy = 4;
+        c.gridwidth = 2;
         tilebmpPanel.add(tileColorPanel, c);
-        c.gridx = 1; c.gridwidth = 1;
+        c.gridx = 1;
+        c.gridwidth = 1;
 
         // OK and Cancel buttons
 
@@ -162,22 +191,26 @@
         buttons.add(Box.createRigidArea(new Dimension(5, 0)));
         buttons.add(cancelButton);
 
-
         // Top part of form
 
         JPanel miscPropPanel = new VerticalStaticJPanel();
         miscPropPanel.setLayout(new GridBagLayout());
         miscPropPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
-        c.gridx = 0; c.gridy = 0; c.weightx = 0;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 0;
         c.fill = GridBagConstraints.NONE;
-        c.insets = new Insets(5, 0, 0, 0);
+        c.insets = new Insets(5, 0, 0, 5);
         miscPropPanel.add(nameLabel, c);
         c.gridy = 1;
         miscPropPanel.add(tileWidthLabel, c);
         c.gridy = 2;
         miscPropPanel.add(tileHeightLabel, c);
+        c.insets = new Insets(5, 0, 0, 0);
         c.fill = GridBagConstraints.HORIZONTAL;
-        c.gridx = 1; c.gridy = 0; c.weightx = 1;
+        c.gridx = 1;
+        c.gridy = 0;
+        c.weightx = 1;
         miscPropPanel.add(tilesetName, c);
         c.gridy = 1;
         miscPropPanel.add(tileWidth, c);
@@ -199,6 +232,38 @@
         getRootPane().setDefaultButton(okButton);
 
         setUseTileBitmap(tilebmpCheck.isSelected());
+
+        // Attach the behaviour
+
+        okButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                createSetAndDispose();
+            }
+        });
+
+        cancelButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                dispose();
+            }
+        });
+
+        browseButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                JFileChooser ch = new JFileChooser(path);
+
+                int ret = ch.showOpenDialog(NewTilesetDialog.this);
+                if (ret == JFileChooser.APPROVE_OPTION) {
+                    path = ch.getSelectedFile().getAbsolutePath();
+                    tilebmpFile.setText(path);
+                }
+            }
+        });
+
+        colorButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent actionEvent) {
+                chooseColorFromImage();
+            }
+        });
     }
 
     public TileSet create() {
@@ -206,84 +271,68 @@
         return newTileset;
     }
 
-    public void actionPerformed(ActionEvent event) {
-        Object source = event.getSource();
+    private void createSetAndDispose() {
+        newTileset = new TileSet();
+        newTileset.setName(tilesetName.getText());
 
-        if (source == okButton) {
-            newTileset = new TileSet();
-            newTileset.setName(tilesetName.getText());
+        if (tilebmpCheck.isSelected()) {
+            String file = tilebmpFile.getText();
+            int spacing = tileSpacing.intValue();
+            int width = tileWidth.intValue();
+            int height = tileHeight.intValue();
+            try {
+                if (!transCheck.isSelected()) {
+                    newTileset.importTileBitmap(file, width, height, spacing,
+                            tileAutoCheck.isSelected());
+                } else {
+                    try {
+                        Toolkit tk = Toolkit.getDefaultToolkit();
+                        Image orig = ImageIO.read(new File(file));
+                        Image trans = tk.createImage(
+                                new FilteredImageSource(orig.getSource(),
+                                        new TransparentImageFilter(
+                                                colorButton.getColor().getRGB())));
+                        BufferedImage img = new BufferedImage(
+                                trans.getWidth(null),
+                                trans.getHeight(null),
+                                BufferedImage.TYPE_INT_ARGB);
 
-            if (tilebmpCheck.isSelected()) {
-                String file = tilebmpFile.getText();
-                int spacing = tileSpacing.intValue();
-                try {
-                    if (!transCheck.isSelected()) {
-                        newTileset.importTileBitmap(file,
-                                                    map.getTileWidth(), map.getTileHeight(),
-                                                    spacing,
-                                                    tileAutoCheck.isSelected());
-                    } else {
-                        try {
-                            Toolkit tk = Toolkit.getDefaultToolkit();
-                            Image orig = ImageIO.read(new File(file));
-                            Image trans = tk.createImage(
-                                    new FilteredImageSource(orig.getSource(),
-                                                            new TransparentImageFilter(
-                                                                colorButton.getColor().getRGB())));
-                            BufferedImage img = new BufferedImage(
-                                    trans.getWidth(null),
-                                    trans.getHeight(null),
-                                    BufferedImage.TYPE_INT_ARGB);
+                        img.getGraphics().drawImage(trans, 0, 0, null);
 
-                            img.getGraphics().drawImage(trans, 0, 0, null);
+                        newTileset.importTileBitmap(img,
+                                width, height, spacing,
+                                tileAutoCheck.isSelected());
 
-                            newTileset.importTileBitmap(img,
-                                                        map.getTileWidth(),
-                                                        map.getTileHeight(),
-                                                        spacing,
-                                                        tileAutoCheck.isSelected());
+                        newTileset.setTransparentColor(
+                                colorButton.getColor());
 
-                            newTileset.setTransparentColor(
-                                    colorButton.getColor());
-
-                            newTileset.setTilesetImageFilename(file);
-                        } catch (Exception e) {
-                        }
+                        newTileset.setTilesetImageFilename(file);
+                    } catch (IOException e) {
                     }
-                } catch (Exception e) {
-                    JOptionPane.showMessageDialog(this,
-                                                  e.getMessage(), "Error while importing tileset",
-                                                  JOptionPane.ERROR_MESSAGE);
-                    newTileset = null;
                 }
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(this, e.getMessage(),
+                        IMPORT_ERROR_MSG, JOptionPane.ERROR_MESSAGE);
+                newTileset = null;
             }
+        }
 
-            dispose();
-        } else if (source == browseButton) {
-            JFileChooser ch = new JFileChooser(path);
+        dispose();
+    }
 
-            int ret = ch.showOpenDialog(this);
-            if (ret == JFileChooser.APPROVE_OPTION) {
-                path = ch.getSelectedFile().getAbsolutePath();
-                tilebmpFile.setText(path);
+    private void chooseColorFromImage() {
+        ImageColorDialog icd;
+        try {
+            icd = new ImageColorDialog(
+                    ImageIO.read(new File(tilebmpFile.getText())));
+            Color c = icd.showDialog();
+            if (c != null) {
+                colorButton.setColor(c);
             }
-        } else if (source == colorButton) {
-            ImageColorDialog icd;
-            try {
-                icd = new ImageColorDialog(
-                        ImageIO.read(new File(tilebmpFile.getText())));
-                Color c = icd.showDialog();
-                if (c != null) {
-                    colorButton.setColor(c);
-                }
-            } catch (IOException e) {
-                JOptionPane.showMessageDialog(getOwner(),
-                                              "Error while loading image: " + e.getMessage(),
-                                              "Error while choosing color",
-                                              JOptionPane.ERROR_MESSAGE);
-            }
-        } else {
-            dispose();
+        } catch (IOException e) {
+            JOptionPane.showMessageDialog(getOwner(),
+                    IMG_LOAD_ERROR + e.getMessage(),
+                    COLOR_CHOOSE_ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
         }
     }
 

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/ObjectDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/ObjectDialog.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/ObjectDialog.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -14,11 +14,12 @@
 
 import javax.swing.JDialog;
 
-
+/**
+ * @version $Id$
+ */
 public class ObjectDialog extends JDialog
 {
     ObjectDialog() {
-        super();
     }
 
     public void init() {

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -33,7 +33,7 @@
        ListSelectionListener
 {
     private final PluginClassLoader pluginLoader;
-    private JList pluginList = null;
+    private JList pluginList;
     private JButton closeButton, infoButton, removeButton;
 
     public PluginDialog(JFrame parent, PluginClassLoader pluginLoader) {
@@ -47,8 +47,8 @@
 
     private void init() {
         /* LIST PANEL */
-        MapReader readers[];
-        MapWriter writers[];
+        MapReader[] readers;
+        MapWriter[] writers;
 
         try {
             readers = pluginLoader.getReaders();
@@ -108,7 +108,7 @@
         Object source = event.getSource();
 
         if (source == closeButton) {
-            this.dispose();
+            dispose();
         } else if (source == removeButton) {
             // TODO: Implement plugin remove functionality
         } else if (source == infoButton) {

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -23,6 +23,7 @@
 
 import tiled.core.Map;
 import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 import tiled.mapeditor.widget.*;
 
 /**
@@ -36,8 +37,19 @@
     private JButton bOk, bCancel;
     private ResizePanel orient;
 
+    private static final String DIALOG_TITLE = Resources.getString("dialog.resizemap.title");
+    private static final String OK_BUTTON = Resources.getString("general.button.ok");
+    private static final String CANCEL_BUTTON = Resources.getString("general.button.cancel");
+    private static final String OFFSET_TITLE = Resources.getString("dialog.resizemap.offset.title");
+    private static final String X_LABEL = Resources.getString("dialog.resizemap.x.label");
+    private static final String Y_LABEL = Resources.getString("dialog.resizemap.y.label");
+    private static final String NEWSIZE_TITLE = Resources.getString("dialog.resizemap.newsize.title");
+    private static final String WIDTH_LABEL = Resources.getString("dialog.resizemap.width.label");
+    private static final String HEIGHT_LABEL = Resources.getString("dialog.resizemap.height.label");
+    private static final String CURRENT_SIZE_TITLE = Resources.getString("dialog.resizemap.currentsize.title");
+
     public ResizeDialog(JFrame parent, MapEditor m) {
-        super(parent, "Resize Map", true);
+        super(parent, DIALOG_TITLE, true);
         currentMap = m.getCurrentMap();
         init();
         setLocationRelativeTo(getOwner());
@@ -46,8 +58,8 @@
     private void init() {
         // Create the primitives
 
-        bOk = new JButton("OK");
-        bCancel = new JButton("Cancel");
+        bOk = new JButton(OK_BUTTON);
+        bCancel = new JButton(CANCEL_BUTTON);
 
         width = new IntegerSpinner(currentMap.getWidth(), 1);
         height = new IntegerSpinner(currentMap.getHeight(), 1);
@@ -63,16 +75,16 @@
         // Offset panel
         JPanel offsetPanel = new VerticalStaticJPanel();
         offsetPanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("Offset"),
+                    BorderFactory.createTitledBorder(OFFSET_TITLE),
                     BorderFactory.createEmptyBorder(0, 5, 5, 5)));
         offsetPanel.setLayout(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
         c.anchor = GridBagConstraints.WEST;
         c.fill = GridBagConstraints.BOTH; c.weighty = 1;
         c.insets = new Insets(5, 0, 0, 0);
-        offsetPanel.add(new JLabel("X: "), c);
+        offsetPanel.add(new JLabel(X_LABEL), c);
         c.gridy = 1;
-        offsetPanel.add(new JLabel("Y: "), c);
+        offsetPanel.add(new JLabel(Y_LABEL), c);
         c.gridx = 1; c.gridy = 0;
         offsetPanel.add(offsetX, c);
         c.gridy = 1;
@@ -85,15 +97,15 @@
         // New size panel
         JPanel newSizePanel = new VerticalStaticJPanel(new GridBagLayout());
         newSizePanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("New size"),
+                    BorderFactory.createTitledBorder(NEWSIZE_TITLE),
                     BorderFactory.createEmptyBorder(0, 5, 5, 5)));
         c = new GridBagConstraints();
         c.anchor = GridBagConstraints.WEST;
         c.fill = GridBagConstraints.BOTH; c.weighty = 1;
         c.insets = new Insets(5, 0, 0, 0);
-        newSizePanel.add(new JLabel("Width: "), c);
+        newSizePanel.add(new JLabel(WIDTH_LABEL), c);
         c.gridy = 1;
-        newSizePanel.add(new JLabel("Height: "), c);
+        newSizePanel.add(new JLabel(HEIGHT_LABEL), c);
         c.fill = GridBagConstraints.HORIZONTAL;
         c.gridx = 1; c.gridy = 0; c.weightx = 1;
         newSizePanel.add(width, c);
@@ -103,21 +115,21 @@
         // Original size panel
         JPanel origSizePanel = new VerticalStaticJPanel(new GridBagLayout());
         origSizePanel.setBorder(BorderFactory.createCompoundBorder(
-                    BorderFactory.createTitledBorder("Current size"),
+                    BorderFactory.createTitledBorder(CURRENT_SIZE_TITLE),
                     BorderFactory.createEmptyBorder(0, 5, 5, 5)));
         c = new GridBagConstraints();
         c.anchor = GridBagConstraints.EAST;
         c.fill = GridBagConstraints.BOTH; c.weighty = 1; c.weightx = 1;
         c.insets = new Insets(5, 0, 0, 0);
-        origSizePanel.add(new JLabel("Width: "), c);
+        origSizePanel.add(new JLabel(WIDTH_LABEL), c);
         c.gridy = 1;
-        origSizePanel.add(new JLabel("Height: "), c);
+        origSizePanel.add(new JLabel(HEIGHT_LABEL), c);
         c.anchor = GridBagConstraints.WEST;
         c.insets = new Insets(5, 10, 0, 0);
         c.gridx = 1; c.gridy = 0;
-        origSizePanel.add(new JLabel("" + currentMap.getWidth()), c);
+        origSizePanel.add(new JLabel(String.valueOf(currentMap.getWidth())), c);
         c.gridy = 1;
-        origSizePanel.add(new JLabel("" + currentMap.getHeight()), c);
+        origSizePanel.add(new JLabel(String.valueOf(currentMap.getHeight())), c);
 
         // Putting two size panels next to eachother
         JPanel sizePanels = new VerticalStaticJPanel(new GridBagLayout());

Modified: branches/bjorn/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/TileDialog.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/TileDialog.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -451,7 +451,7 @@
 
         if (source == bOk) {
             tileset.setName(tilesetNameEntry.getText());
-            this.dispose();
+            dispose();
         } else if (source == bDelete) {
             int answer = JOptionPane.showConfirmDialog(
                     this, "Delete tile?", "Are you sure?",

Modified: branches/bjorn/src/tiled/mapeditor/resources/gui.properties
===================================================================
--- branches/bjorn/src/tiled/mapeditor/resources/gui.properties	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/resources/gui.properties	2006-02-12 14:51:25 UTC (rev 581)
@@ -1,5 +1,30 @@
+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.
 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.
 dialog.brush.title=Brush Options
-general.file.exists.message=The file already exists. Do you wish to overwrite it?
\ No newline at end of file
+dialog.newtileset.autotiles.label=Automatically create tiles from images
+dialog.newtileset.colorchoose.error.title=Error while choosing color
+dialog.newtileset.fromtilesetimg.title=From tileset image
+dialog.newtileset.image.label=Tile image:
+dialog.newtileset.imgload.error.message=Error while loading image:
+dialog.newtileset.import.error.message=Error while importing tileset
+dialog.newtileset.import.error=
+dialog.newtileset.name.label=Tileset name:
+dialog.newtileset.tileheight.label=Tile height:
+dialog.newtileset.tilesetimgref.label=Reference tileset image
+dialog.newtileset.tilespacing.label=Tile spacing:
+dialog.newtileset.tilewidth.label=Tile width:
+dialog.newtileset.title=New Tileset
+dialog.newtileset.usetransparentcolor.label=Use transparent color
+dialog.resizemap.currentsize.title=Current size
+dialog.resizemap.height.label=Height:
+dialog.resizemap.newsize.title=New size
+dialog.resizemap.offset.title=Offset
+dialog.resizemap.title=Resize Map
+dialog.resizemap.width.label=Width:
+dialog.resizemap.x.label=X:
+dialog.resizemap.y.label=Y:
+general.button.browse=Browse...
+general.button.cancel=Cancel
+general.button.ok=OK
+general.file.exists.message=The file already exists. Do you wish to overwrite it?
+general.file.untitled=Untitled

Modified: branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties
===================================================================
--- branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/resources/gui_nl.properties	2006-02-12 14:51:25 UTC (rev 581)
@@ -1,4 +1,30 @@
+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.
 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
+dialog.brush.title=Penseel Opties
+dialog.newtileset.autotiles.label=Maak automatisch tiles van de plaatjes
+dialog.newtileset.colorchoose.error.title=Fout tijdens het kiezen van de kleur
+dialog.newtileset.fromtilesetimg.title=Tileset afbeelding
+dialog.newtileset.image.label=Afbeelding:
+dialog.newtileset.imgload.error.message=Fout tijdens het lezen van de afbeelding:
+dialog.newtileset.import.error.message=Fout tijdens het importeren van de tileset
+dialog.newtileset.import.error=
+dialog.newtileset.name.label=Tileset naam:
+dialog.newtileset.tileheight.label=Tile hoogte:
+dialog.newtileset.tilesetimgref.label=Refereer naar tileset afbeelding
+dialog.newtileset.tilespacing.label=Tile afstand:
+dialog.newtileset.tilewidth.label=Tile breedte:
+dialog.newtileset.title=Nieuwe Tileset
+dialog.newtileset.usetransparentcolor.label=Gebruik transparante kleur
+dialog.resizemap.currentsize.title=Huidig formaat
+dialog.resizemap.height.label=Hoogte:
+dialog.resizemap.newsize.title=Nieuw formaat
+dialog.resizemap.offset.title=Verschuiving
+dialog.resizemap.title=Map Formaat Veranderen
+dialog.resizemap.width.label=Breedte:
+dialog.resizemap.x.label=X:
+dialog.resizemap.y.label=Y:
+general.button.browse=Bladeren...
+general.button.cancel=Annuleren
+general.button.ok=OK
+general.file.exists.message=Een bestand met dezelfde naam bestaat al. Wil je deze overschrijven?
+general.file.untitled=Naamloos

Modified: branches/bjorn/src/tiled/mapeditor/undo/MapLayerStateEdit.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/undo/MapLayerStateEdit.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/undo/MapLayerStateEdit.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -26,9 +26,9 @@
     private String name;
 
     public MapLayerStateEdit(Map m, Vector before, Vector after, String name) {
-        this.map = m;
-        this.layersBefore = before;
-        this.layersAfter = after;
+        map = m;
+        layersBefore = before;
+        layersAfter = after;
         this.name = name;
     }
 

Modified: branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -18,26 +18,49 @@
 import java.util.LinkedList;
 
 import javax.swing.JPanel;
-import javax.swing.event.MouseInputListener;
+import javax.swing.event.MouseInputAdapter;
 
 import tiled.mapeditor.brush.Brush;
 import tiled.mapeditor.brush.ShapeBrush;
 
 /**
  * A panel that allows selecting a brush from a set of presets.
+ *
+ * @version $Id$
  */
-public class BrushBrowser extends JPanel implements MouseInputListener
+public class BrushBrowser extends JPanel
 {
     private int maxWidth = 25;
     private Brush selectedBrush;
-    private LinkedList brushes;
+    private final LinkedList brushes;
 
     public BrushBrowser() {
-        super();
         brushes = new LinkedList();
         initPresets();
-        addMouseListener(this);
-        addMouseMotionListener(this);
+
+        MouseInputAdapter listener = new MouseInputAdapter() {
+            public void mousePressed(MouseEvent e) {
+                int perLine = getWidth() / maxWidth;
+                int x = e.getX() / maxWidth;
+                int y = e.getY() / maxWidth;
+                int selectedIndex =
+                    y * perLine + (x > perLine - 1 ? perLine - 1 : x);
+
+                if (selectedIndex >= 0 && selectedIndex < brushes.size()) {
+                    Brush previousBrush = selectedBrush;
+                    selectedBrush = (Brush)brushes.get(selectedIndex);
+                    firePropertyChange("selectedbrush", previousBrush, selectedBrush);
+                    repaint();
+                }
+            }
+
+            public void mouseDragged(MouseEvent e) {
+                mousePressed(e);
+            }
+        };
+
+        addMouseListener(listener);
+        addMouseMotionListener(listener);
     }
 
     public Dimension getPreferredSize() {
@@ -82,8 +105,8 @@
             Brush b = (Brush)itr.next();
             Rectangle bb = b.getBounds();
             b.paint(g,
-                    x + ((maxWidth / 2) - bb.width / 2),
-                    y + ((maxWidth / 2) - bb.width / 2));
+                    x + (maxWidth / 2 - bb.width / 2),
+                    y + (maxWidth / 2 - bb.width / 2));
 
             if (b == selectedBrush) {
                 g.drawRect(x, y, maxWidth, maxWidth);
@@ -111,38 +134,4 @@
     public Brush getSelectedBrush() {
         return selectedBrush;
     }
-
-    public void mouseClicked(MouseEvent e) {
-        int perLine = getWidth() / maxWidth;
-        int x = e.getX() / maxWidth;
-        int y = e.getY() / maxWidth;
-        int selectedIndex =
-            y * perLine + ((x > (perLine - 1)) ? (perLine - 1) : x);
-
-        if (selectedIndex >= 0 && selectedIndex < brushes.size()) {
-            Brush previousBrush = selectedBrush;
-            selectedBrush = (Brush)brushes.get(selectedIndex);
-            firePropertyChange("selectedbrush", previousBrush, selectedBrush);
-            repaint();
-        }
-    }
-
-    public void mousePressed(MouseEvent e) {
-    }
-
-    public void mouseReleased(MouseEvent e) {
-    }
-
-    public void mouseEntered(MouseEvent e) {
-    }
-
-    public void mouseExited(MouseEvent e) {
-    }
-
-    public void mouseDragged(MouseEvent e) {
-        mouseClicked(e);
-    }
-
-    public void mouseMoved(MouseEvent e) {
-    }
 }

Modified: branches/bjorn/src/tiled/mapeditor/widget/ImageViewPanel.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/widget/ImageViewPanel.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/widget/ImageViewPanel.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -16,21 +16,19 @@
 
 import javax.swing.JPanel;
 
-public class ImageViewPanel extends JPanel {
+/**
+ * @version $Id$
+ */
+public class ImageViewPanel extends JPanel
+{
+	private final Image image;
+
+    public ImageViewPanel(Image i) {
+        image = i;
+    }
 	
-	private Image image;
-	
-	public ImageViewPanel() {
-		super();
-	}
-	
-	public ImageViewPanel(Image i) {
-		this();
-		image = i;
-	}
-	
 	public Dimension getPreferredSize() {
-		return new Dimension(150,150);
+		return new Dimension(150, 150);
 	}
 
 	public Dimension getPreferredScrollableViewportSize() {

Modified: branches/bjorn/src/tiled/mapeditor/widget/IntegerSpinner.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/widget/IntegerSpinner.java	2006-02-12 02:50:45 UTC (rev 580)
+++ branches/bjorn/src/tiled/mapeditor/widget/IntegerSpinner.java	2006-02-12 14:51:25 UTC (rev 581)
@@ -16,11 +16,12 @@
 import javax.swing.JSpinner;
 import javax.swing.SpinnerNumberModel;
 
-
 /**
  * The integer spinner is a variation on the JSpinner that is only to be used
  * for plain integer inputs. It offers some convenience constructors and
  * methods.
+ *
+ * @version $Id$
  */
 public class IntegerSpinner extends JSpinner
 {




More information about the tiled-commit mailing list