[tiled] r600 - in trunk/src/tiled: io mapeditor/dialogs mapeditor/util util view

svn@biggeruniverse.com svn at biggeruniverse.com
Sun Apr 9 04:49:53 PDT 2006


Author: bjorn
Date: 2006-04-09 06:49:52 -0500 (Sun, 09 Apr 2006)
New Revision: 600

Modified:
   trunk/src/tiled/io/ImageHelper.java
   trunk/src/tiled/io/MapWriter.java
   trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java
   trunk/src/tiled/mapeditor/dialogs/TileDialog.java
   trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
   trunk/src/tiled/mapeditor/util/MapChangeListener.java
   trunk/src/tiled/util/MersenneTwister.java
   trunk/src/tiled/view/HexMapView.java
   trunk/src/tiled/view/IsoMapView.java
   trunk/src/tiled/view/MapView.java
   trunk/src/tiled/view/ObliqueMapView.java
   trunk/src/tiled/view/OrthoMapView.java
   trunk/src/tiled/view/ShiftedMapView.java
Log:
Merged a bunch of small changes from branches/bjorn to trunk. Includes
internationalization of "Close" button in the configuration dialog, removal
of tile orientation from the tile image dialog and renaming myMap in MapView
to map.


Modified: trunk/src/tiled/io/ImageHelper.java
===================================================================
--- trunk/src/tiled/io/ImageHelper.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/io/ImageHelper.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -12,9 +12,7 @@
 
 package tiled.io;
 
-import java.awt.Canvas;
 import java.awt.Image;
-import java.awt.MediaTracker;
 import java.awt.Toolkit;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayOutputStream;
@@ -63,18 +61,7 @@
      * @see java.awt.Toolkit#createImage(byte[] imagedata)
      */
     static public Image bytesToImage(byte[] imageData) {
-        Image img = Toolkit.getDefaultToolkit().createImage(imageData);
-
-        MediaTracker mediaTracker = new MediaTracker(new Canvas());
-        mediaTracker.addImage(img, 0);
-        try {
-            mediaTracker.waitForID(0);
-        }
-        catch (InterruptedException ie) {
-        }
-        mediaTracker.removeImage(img);
-
-        return img;
+        return Toolkit.getDefaultToolkit().createImage(imageData);
     }
 
     /**

Modified: trunk/src/tiled/io/MapWriter.java
===================================================================
--- trunk/src/tiled/io/MapWriter.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/io/MapWriter.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -21,7 +21,9 @@
 /**
  * Used by Tiled to denote a plugin for writing maps. The map file
  * can have any format, as long as the MapWriter implementor accepts
- * instances of tiled.core.Map and tiled.core.TileSet.
+ * instances of {@link tiled.core.Map} and {@link TileSet}.
+ *
+ * $Id$
  */
 public interface MapWriter extends PluggableMapIO, FileFilter
 {

Modified: trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/mapeditor/dialogs/ConfigurationDialog.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -44,6 +44,7 @@
     private final Preferences ioPrefs = prefs.node("io");
 
     private static final String DIALOG_TITLE = Resources.getString("dialog.preferences.title");
+    private static final String CLOSE_BUTTON = Resources.getString("general.button.close");
 
     public ConfigurationDialog(JFrame parent) {
         super(parent, DIALOG_TITLE, true);
@@ -132,8 +133,8 @@
         //c.gridx = 1;
         //gridOps.add(gridColor, c);
 
-        JButton bClose = new JButton("Close");
-        bClose.addActionListener(new ActionListener() {
+        JButton closeButton = new JButton(CLOSE_BUTTON);
+        closeButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent actionEvent) {
                 dispose();
             }
@@ -143,7 +144,7 @@
         JPanel buttons = new VerticalStaticJPanel();
         buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
         buttons.add(Box.createGlue());
-        buttons.add(bClose);
+        buttons.add(closeButton);
 
         JPanel saving = new JPanel();
         saving.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
@@ -177,7 +178,7 @@
         mainPanel.add(buttons);
 
         getContentPane().add(mainPanel);
-        getRootPane().setDefaultButton(bClose);
+        getRootPane().setDefaultButton(closeButton);
         pack();
 
         // Associate listeners with the configuration widgets

Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -234,7 +234,7 @@
         }
         if (tileset.usesSharedImages()) {
             TileImageDialog d = new TileImageDialog(this, tileset,
-                currentTile.getImageId(), currentTile.getImageOrientation());
+                currentTile.getImageId());
             d.setVisible(true);
             if (d.getImageId() >= 0) {
                 currentTile.setImage(d.getImageId());

Modified: trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -5,7 +5,7 @@
  *  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>
  *  Rainer Deyke <rainerd at eldwood.com>
@@ -41,15 +41,13 @@
     private int[] imageIds;
 
     public TileImageDialog(Dialog parent, TileSet set) {
-        this(parent, set, 0, 0);
+        this(parent, set, 0);
     }
 
-    public TileImageDialog(Dialog parent, TileSet set, int id,
-        int orientation) {
+    public TileImageDialog(Dialog parent, TileSet set, int id) {
         super(parent, "Choose Tile Image", true);
         tileset = set;
         imageId = id;
-        imageOrientation = orientation;
 
         init();
         queryImages();

Modified: trunk/src/tiled/mapeditor/util/MapChangeListener.java
===================================================================
--- trunk/src/tiled/mapeditor/util/MapChangeListener.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/mapeditor/util/MapChangeListener.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -14,8 +14,9 @@
 
 import java.util.EventListener;
 
-
-
+/**
+ * @version $Id$
+ */
 public interface MapChangeListener extends EventListener
 {
     public void mapChanged(MapChangedEvent e);

Modified: trunk/src/tiled/util/MersenneTwister.java
===================================================================
--- trunk/src/tiled/util/MersenneTwister.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/util/MersenneTwister.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -23,8 +23,8 @@
         notice, this list of conditions and the following disclaimer in the
         documentation and/or other materials provided with the distribution.
 
-     3. The names of its contributors may not be used to endorse or promote 
-        products derived from this software without specific prior written 
+     3. The names of its contributors may not be used to endorse or promote
+        products derived from this software without specific prior written
         permission.
 
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -48,15 +48,13 @@
    @author Takuji Nishimura
 */
 public class MersenneTwister extends Random {
-	private static final long serialVersionUID = 1L;
-	
-	public static final int N = 624;
+    public static final int N = 624;
     public static final int M = 397;
     public static final int MATRIX_A = 0x9908b0df;   /* constant vector a */
     public static final int UPPER_MASK = 0x80000000; /* most significant w-r bits */
     public static final int LOWER_MASK = 0x7fffffff; /* least significant r bits */
 
-    private long mt[];
+    private long[] mt;
     private int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
 
     public MersenneTwister() {
@@ -88,7 +86,7 @@
     /* init_key is the array for initializing keys */
     /* key_length is its length */
     /* slight change for C++, 2004/2/26 */
-    public void initByArray(long init_key[], int key_length)
+    public void initByArray(long[] init_key, int key_length)
     {
         int i, j, k;
         initGenRand(19650218);
@@ -110,14 +108,14 @@
             if (i>=N) { mt[0] = mt[N-1]; i=1; }
         }
 
-        mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */ 
+        mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
     }
 
     /* generates a random number on [0,0xffffffff]-interval */
     public long genrand()
     {
         int y;
-        long mag01[]={0x0, MATRIX_A};
+        long[] mag01={0x0, MATRIX_A};
         /* mag01[x] = x * MATRIX_A  for x=0,1 */
 
         if (mti >= N) { /* generate N words at one time */
@@ -150,8 +148,8 @@
 
         return y;
     }
-    
- 	synchronized protected int next(int bits) {
-		return (int)genrand();
-	}
+
+    synchronized protected int next(int bits) {
+        return (int)genrand();
+    }
 }

Modified: trunk/src/tiled/view/HexMapView.java
===================================================================
--- trunk/src/tiled/view/HexMapView.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/view/HexMapView.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -90,8 +90,8 @@
         int wbhc = (int)getWidthBetweenHexCentres();
 
         return new Dimension(
-                myMap.getWidth() * wbhc + border + wbhc,
-                myMap.getHeight() * tsize.height + border +
+                map.getWidth() * wbhc + border + wbhc,
+                map.getHeight() * tsize.height + border +
                 tsize.height / 2);
     }
 
@@ -145,13 +145,13 @@
      * Hexes.
      */
     private double getWidthBetweenHexCentres() {
-        return myMap.getTileWidth() * 3 / 4;
+        return map.getTileWidth() * 3 / 4;
     }
 
     private Dimension getTileSize(double zoom) {
         return new Dimension(
-                (int)(myMap.getTileWidth() * zoom),
-                (int)(myMap.getTileHeight() * zoom));
+                (int)(map.getTileWidth() * zoom),
+                (int)(map.getTileHeight() * zoom));
     }
 
     protected void paintGrid(Graphics2D g2d, double zoom) {
@@ -194,7 +194,7 @@
         int x = (int)(screenX / zoom);
         int y = (int)(screenY / zoom);
         double hexWidth = getWidthBetweenHexCentres();
-        double hexHeight = myMap.getTileHeight();
+        double hexHeight = map.getTileHeight();
 
         double tw = hexWidth * 2 / 3;
         double cw = hexWidth / 3;
@@ -255,7 +255,7 @@
     }
 
     private double getTileHeight() {
-        return myMap.getTileHeight();
+        return map.getTileHeight();
     }
 
     public void repaintRegion(Rectangle region) {

Modified: trunk/src/tiled/view/IsoMapView.java
===================================================================
--- trunk/src/tiled/view/IsoMapView.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/view/IsoMapView.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -72,7 +72,7 @@
 
         // Determine area to draw from clipping rectangle
         int columns = clipRect.width / tileSize.width + 3;
-        int rows = (clipRect.height + (int)(myMap.getTileHeightMax() * zoom)) /
+        int rows = (clipRect.height + (int)(map.getTileHeightMax() * zoom)) /
             tileStepY + 4;
 
         // Draw this map layer
@@ -127,10 +127,10 @@
         int startX = Math.max(0, screenToTileCoords(clipRect.x, clipRect.y).x);
         int startY = Math.max(0, screenToTileCoords(
                     clipRect.x + clipRect.width, clipRect.y).y);
-        int endX = Math.min(myMap.getWidth(), screenToTileCoords(
+        int endX = Math.min(map.getWidth(), screenToTileCoords(
                     clipRect.x + clipRect.width,
                     clipRect.y + clipRect.height).x);
-        int endY = Math.min(myMap.getHeight(), screenToTileCoords(
+        int endY = Math.min(map.getHeight(), screenToTileCoords(
                     clipRect.x, clipRect.y + clipRect.height).y);
 
         for (int y = startY; y <= endY; y++) {
@@ -170,7 +170,7 @@
             Point columnItr = new Point(rowItr);
 
             for (int x = 0; x < columns; x++) {
-                if (myMap.contains(columnItr.x, columnItr.y)) {
+                if (map.contains(columnItr.x, columnItr.y)) {
                     String coords =
                         "(" + columnItr.x + "," + columnItr.y + ")";
                     Rectangle2D textSize =
@@ -204,7 +204,7 @@
     public void repaintRegion(Rectangle region) {
         Dimension tileSize = getTileSize(zoom);
         int maxExtraHeight =
-            (int)(myMap.getTileHeightMax() * zoom) - tileSize.height;
+            (int)(map.getTileHeightMax() * zoom) - tileSize.height;
 
         int mapX1 = region.x;
         int mapY1 = region.y;
@@ -222,7 +222,7 @@
     public Dimension getPreferredSize() {
         Dimension tileSize = getTileSize(zoom);
         int border = (modeFlags & PF_GRIDMODE) != 0 ? 1 : 0;
-        int mapSides = myMap.getHeight() + myMap.getWidth();
+        int mapSides = map.getHeight() + map.getWidth();
 
         return new Dimension(
                 (mapSides * tileSize.width) / 2 + border,
@@ -237,7 +237,7 @@
         double r = getTileRatio();
 
         // Translate origin to top-center
-        x -= myMap.getHeight() * (tileSize.width / 2);
+        x -= map.getHeight() * (tileSize.width / 2);
         int mx = y + (int)(x / r);
         int my = y - (int)(x / r);
 
@@ -264,12 +264,12 @@
 
     protected Dimension getTileSize(double zoom) {
         return new Dimension(
-                (int)(myMap.getTileWidth() * zoom),
-                (int)(myMap.getTileHeight() * zoom));
+                (int)(map.getTileWidth() * zoom),
+                (int)(map.getTileHeight() * zoom));
     }
 
     protected double getTileRatio() {
-        return (double)myMap.getTileWidth() / (double)myMap.getTileHeight();
+        return (double)map.getTileWidth() / (double)map.getTileHeight();
     }
 
     /**
@@ -277,7 +277,7 @@
      */
     public Point tileToScreenCoords(double x, double y) {
         Dimension tileSize = getTileSize(zoom);
-        int originX = (myMap.getHeight() * tileSize.width) / 2;
+        int originX = (map.getHeight() * tileSize.width) / 2;
         return new Point(
                 (int)((x - y) * tileSize.width / 2) + originX,
                 (int)((x + y) * tileSize.height / 2));

Modified: trunk/src/tiled/view/MapView.java
===================================================================
--- trunk/src/tiled/view/MapView.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/view/MapView.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -39,7 +39,7 @@
 
     public static int ZOOM_NORMALSIZE = 5;
 
-    protected Map myMap;
+    protected Map map;
     protected Brush currentBrush;
     protected int modeFlags;
     protected double zoom = 1.0;
@@ -59,7 +59,7 @@
      * @param map the map to be displayed by this map view
      */
     protected MapView(Map map) {
-        myMap = map;
+        this.map = map;
         setSize(getPreferredSize());
     }
 
@@ -227,10 +227,10 @@
 
         g2d.fillRect(clip.x, clip.y, clip.width, clip.height);
 
-        paintSubMap(myMap, g2d, 1.0f);
+        paintSubMap(map, g2d, 1.0f);
 
         if (!getMode(PF_NOSPECIAL)) {
-            Iterator li = myMap.getLayersSpecial();
+            Iterator li = map.getLayersSpecial();
 
             while (li.hasNext()) {
                 layer = (MapLayer) li.next();

Modified: trunk/src/tiled/view/ObliqueMapView.java
===================================================================
--- trunk/src/tiled/view/ObliqueMapView.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/view/ObliqueMapView.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -20,7 +20,9 @@
 
 import tiled.core.*;
 
-
+/**
+ * @version $Id$
+ */
 public class ObliqueMapView extends MapView
 {
     /**

Modified: trunk/src/tiled/view/OrthoMapView.java
===================================================================
--- trunk/src/tiled/view/OrthoMapView.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/view/OrthoMapView.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -69,8 +69,8 @@
         int border = (modeFlags & PF_GRIDMODE) != 0 ? 1 : 0;
 
         return new Dimension(
-                myMap.getWidth() * tsize.width + border,
-                myMap.getHeight() * tsize.height + border);
+                map.getWidth() * tsize.width + border,
+                map.getHeight() * tsize.height + border);
     }
 
     protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
@@ -108,8 +108,8 @@
         }
     }
 
-    protected void paintLayer(Graphics2D g, ObjectGroup layer, double zoom) {
-        Iterator itr = layer.getObjects();
+    protected void paintLayer(Graphics2D g, ObjectGroup og, double zoom) {
+        Iterator itr = og.getObjects();
 
         while (itr.hasNext()) {
             MapObject mo = (MapObject) itr.next();
@@ -192,7 +192,7 @@
         if (tsize.width <= 0 || tsize.height <= 0) return;
         int toffset = (modeFlags & PF_GRIDMODE) != 0 ? 1 : 0;
         int maxExtraHeight =
-            (int)((myMap.getTileHeightMax() * zoom + toffset) - tsize.height);
+            (int)((map.getTileHeightMax() * zoom + toffset) - tsize.height);
 
         // Calculate the visible corners of the region
         int startX = region.x * tsize.width + toffset;
@@ -215,8 +215,8 @@
         int grid = (modeFlags & PF_GRIDMODE) != 0 ? 1 : 0;
 
         return new Dimension(
-                (int)(myMap.getTileWidth() * zoom) + grid,
-                (int)(myMap.getTileHeight() * zoom) + grid);
+                (int)(map.getTileWidth() * zoom) + grid,
+                (int)(map.getTileHeight() * zoom) + grid);
     }
 
     protected Polygon createGridPolygon(int tx, int ty, int border) {
@@ -233,6 +233,6 @@
 
     public Point tileToScreenCoords(double x, double y) {
         Dimension tsize = getTileSize(zoom);
-        return new Point((int)x*tsize.width, (int)y*tsize.height);
+        return new Point((int)x * tsize.width, (int)y * tsize.height);
     }
 }

Modified: trunk/src/tiled/view/ShiftedMapView.java
===================================================================
--- trunk/src/tiled/view/ShiftedMapView.java	2006-04-09 11:35:02 UTC (rev 599)
+++ trunk/src/tiled/view/ShiftedMapView.java	2006-04-09 11:49:52 UTC (rev 600)
@@ -70,8 +70,8 @@
         int repeatY = tsize.height - onceY;
 
         return new Dimension(
-                myMap.getWidth() * repeatX + onceX + border,
-                myMap.getHeight() * repeatY + onceY + border);
+                map.getWidth() * repeatX + onceX + border,
+                map.getHeight() * repeatY + onceY + border);
     }
 
     protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
@@ -127,8 +127,8 @@
 
     protected Dimension getTileSize(double zoom) {
         return new Dimension(
-                (int)(myMap.getTileWidth() * zoom),
-                (int)(myMap.getTileHeight() * zoom));
+                (int)(map.getTileWidth() * zoom),
+                (int)(map.getTileHeight() * zoom));
     }
 
     protected Polygon createGridPolygon(int tx, int ty, int border) {




More information about the tiled-commit mailing list