[tiled] r714 - in trunk: . src/tiled/core src/tiled/io src/tiled/io/xml src/tiled/mapeditor src/tiled/mapeditor/actions src/tiled/mapeditor/dialogs src/tiled/mapeditor/selection src/tiled/mapeditor/widget src/tiled/view

tiled-svn at biggeruniverse.com tiled-svn at biggeruniverse.com
Sun Jan 7 09:47:20 PST 2007


Author: bjorn
Date: 2007-01-07 11:47:19 -0600 (Sun, 07 Jan 2007)
New Revision: 714

Removed:
   trunk/src/tiled/mapeditor/widget/TilePaletteQuickPanel.java
Modified:
   trunk/CHANGES
   trunk/INSTALL
   trunk/README
   trunk/SUGGESTIONS
   trunk/build.xml
   trunk/src/tiled/core/Map.java
   trunk/src/tiled/core/Sprite.java
   trunk/src/tiled/core/TileLayer.java
   trunk/src/tiled/core/TileSet.java
   trunk/src/tiled/io/MapHelper.java
   trunk/src/tiled/io/xml/XMLMapTransformer.java
   trunk/src/tiled/mapeditor/MapEditor.java
   trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java
   trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
   trunk/src/tiled/mapeditor/dialogs/TileDialog.java
   trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
   trunk/src/tiled/mapeditor/selection/SelectionLayer.java
   trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java
   trunk/src/tiled/view/HexMapView.java
   trunk/src/tiled/view/IsoMapView.java
   trunk/src/tiled/view/MapView.java
   trunk/src/tiled/view/OrthoMapView.java
   trunk/src/tiled/view/ShiftedMapView.java
Log:
Reverted some of the recent changes. In particular the partial support for different tile sizes per layer, changes to the tile palette and brush history.

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/CHANGES	2007-01-07 17:47:19 UTC (rev 714)
@@ -4,13 +4,11 @@
 * Added ability to create stamp brushes from the tile palette
 * Added import/export of configuration
 * Added option to automatically open the last map on startup (by Pedro Miller)
-* Added brush memory, so that going to another tool and coming back does not reset the brush
 * Embedded the tile palette
 * Report out of memory error when saving map as image
 * Properties table now displays the properties in alphabetical order
 * Fixed properties dialog to also save values that were still being edited
 * Fixed automatically adding the file extension when not given
-* Fixed default tabbed tilesets panel height
 * Worked around an issue with the open file dialog on GNU classpath
 * Worked around an issue with setting a null cursor on GNU classpath
 

Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/INSTALL	2007-01-07 17:47:19 UTC (rev 714)
@@ -7,34 +7,22 @@
 
 Take the following steps to build Tiled from source:
 
-- Install j2sdk       (http://java.sun.com/)
+- Install the JDK     (http://java.sun.com/)
 - Install apache-ant  (http://ant.apache.org/)
-- Run: 'ant dist' in the directory where you placed Tiled
-  This will create a new subdirectory dist/
+- Run ant in the directory where you placed Tiled
 
 ---------------
  RUNNING TILED
 ---------------
 
-~ Getting the JVM ~
+- Install the Java Runtime Environment (JRE)     (http://java.sun.com/)
 
-  Install JRE 1.4 or 5.0 from http://java.sun.com/ . Either will work, though 
-  in the future we aim toward 5.0. If you already have the J2SDK, then you can
-  safely skip this step.
-
-~ Running ~
 - From the command line, you can run the following from the directory where you
   placed Tiled:
 
-  (*nix)    java -jar dist/tiled.jar
-  
-  (Windows) java -jar dist\tiled.jet
-  
-~ Notes ~
+  java -jar dist/tiled.jar
 
 - You can also use the Java webstart link on the website, see "Start Now!"
 
-- Windows users that have JRE 5.0 installed should be able to double click the
+- Windows users that have the JRE installed should be able to double click the
   tiled.jar file to run it.
-
-- Make sure java binaries are in your path.
\ No newline at end of file

Modified: trunk/README
===================================================================
--- trunk/README	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/README	2007-01-07 17:47:19 UTC (rev 714)
@@ -54,7 +54,7 @@
 - Rickard Isaksson for an improved image loader
 - Kevin Kelley for the base64 encoder/decoder we use
 - GNOME and GIMP for their magnificent icons
-- Nephilim for suggesting layer opacity (our first suggestion)
+- Nephilim for suggesting layer opacity
 - Rainer Deyke for useful suggestions and many code contributions
-- Jerome Blouin for some meticulous testing
-- Hendrik Brummermann for some clean up
+- Jerome Blouin for some meticulous performance testing
+- Hendrik Brummermann for improving error reporting on map loading
\ No newline at end of file

Modified: trunk/SUGGESTIONS
===================================================================
--- trunk/SUGGESTIONS	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/SUGGESTIONS	2007-01-07 17:47:19 UTC (rev 714)
@@ -97,16 +97,6 @@
             random locations, not a brush that picks a random tile to draw. The
             latter is probably what Rainer Deyke meant here)
 
-- 19 --------------------------------------------------------------------------
-Suggestor:  Rainer Deyke <root at rainerdeyke.com>
-Date:       24/09/04
-Summary:    A block tool that lets me draw blocks of tiles with a single mouse
-            drag. I can fake this with select-and-pour, but a block tool would
-            be much more convenient.
-State:      Implemented
-            (Why is this marked as implemented? As far as I know we do not have
-            the block tool described here)
-
 - 20 --------------------------------------------------------------------------
 Suggestor:  Rainer Deyke <root at rainerdeyke.com>
 Date:       24/09/04

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/build.xml	2007-01-07 17:47:19 UTC (rev 714)
@@ -52,10 +52,10 @@
   </target>
 
   <target name="compile_dep" depends="init" description="Compile the source">
-    <javac source="1.4" target="1.4" srcdir="${src}" destdir="${build}" 
-	deprecation="on"/>
+    <javac source="1.4" target="1.4" srcdir="${src}" destdir="${build}"
+      deprecation="on"/>
     <copy todir="${build}/tiled/mapeditor/resources">
-      <fileset dir="./tiled/mapeditor/resources">
+      <fileset dir="./src/tiled/mapeditor/resources">
         <include name="*.png" />
         <include name="map.dtd" />
       </fileset>

Modified: trunk/src/tiled/core/Map.java
===================================================================
--- trunk/src/tiled/core/Map.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/core/Map.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -411,7 +411,7 @@
 
     /**
      * Returns default tile width for this map.
-     * 
+     *
      * @return the default tile width
      */
     public int getTileWidth() {
@@ -420,7 +420,7 @@
 
     /**
      * Returns default tile height for this map.
-     * 
+     *
      * @return the default tile height
      */
     public int getTileHeight() {

Modified: trunk/src/tiled/core/Sprite.java
===================================================================
--- trunk/src/tiled/core/Sprite.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/core/Sprite.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -147,10 +147,6 @@
         createKey("", frames, KeyFrame.KEY_LOOP);
     }
 
-    public Sprite(TileSet set) {
-        
-    }
-    
     public void setFrames(Tile[] frames) {
         frameSize = new Rectangle(0, 0, frames[0].getWidth(), frames[0].getHeight());
 

Modified: trunk/src/tiled/core/TileLayer.java
===================================================================
--- trunk/src/tiled/core/TileLayer.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/core/TileLayer.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -12,12 +12,11 @@
 
 package tiled.core;
 
-import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.geom.Area;
-import java.util.Properties;
 import java.util.HashMap;
+import java.util.Properties;
 
 /**
  * A TileLayer is a specialized MapLayer, used for tracking two dimensional
@@ -29,8 +28,7 @@
 {
     protected Tile[][] map;
     protected HashMap tileInstanceProperties = new HashMap();
-    protected Dimension tileDimensions;
-    
+
     public Properties getTileInstancePropertiesAt(int x, int y) {
         if (!bounds.contains(x, y)) {
             return null;
@@ -50,7 +48,6 @@
      * Default contructor.
      */
     public TileLayer() {
-        tileDimensions = new Dimension(0, 0);
     }
 
     /**
@@ -77,7 +74,6 @@
      */
     TileLayer(Map m) {
         super(m);
-        tileDimensions = new Dimension(m.getTileWidth(), m.getTileHeight());
     }
 
     /**
@@ -90,16 +86,6 @@
         setMap(m);
     }
 
-    public void setMap(Map m) {
-        super.setMap(m);
-        if(m != null)
-            tileDimensions = new Dimension(m.getTileWidth(), m.getTileHeight());
-    }
-    
-    public Dimension getTileSize() {
-        return new Dimension(tileDimensions);
-    }
-    
     /**
      * Rotates the layer by the given Euler angle.
      *
@@ -293,13 +279,8 @@
      * @param ti the tile object to place
      */
     public void setTileAt(int tx, int ty, Tile ti) {
-        if(!bounds.contains(tx, ty)) return; //quicker than a trap
-        try {
-            if (canEdit()) {
-                map[ty - bounds.y][tx - bounds.x] = ti;
-            }
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // Silently ignore out of bounds exception
+        if (bounds.contains(tx, ty) && canEdit()) {
+            map[ty - bounds.y][tx - bounds.x] = ti;
         }
     }
 
@@ -312,14 +293,8 @@
      *         outside this layer
      */
     public Tile getTileAt(int tx, int ty) {
-        if(!bounds.contains(tx, ty))
-            return null;
-        
-        try {
-            return map[ty - bounds.y][tx - bounds.x];
-        } catch (ArrayIndexOutOfBoundsException e) {
-            return null;
-        }
+        return (bounds.contains(tx, ty)) ?
+                map[ty - bounds.y][tx - bounds.x] : null;
     }
 
     /**

Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/core/TileSet.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -78,16 +78,17 @@
     {
         setTilesetImageFilename(imgFilename);
 
-        //some checks on the file before we try to read it
+        // Some checks on the file before we try to read it
+        // TODO: What about catching exceptions instead?
         File imageFile = new File(imgFilename);
         if (!imageFile.exists()) {
             throw new IOException(Resources.getString("general.file.notexists.message") + " (" + tilebmpFile + ")");
         }
-        
+
         if (!imageFile.canRead()) {
             throw new IOException(Resources.getString("general.file.cant.read") + " (" + tilebmpFile + ")");
         }
-        
+
         Image image = ImageIO.read(imageFile);
         if (image == null) {
             throw new IOException("Failed to load (" + tilebmpFile + ")");

Modified: trunk/src/tiled/io/MapHelper.java
===================================================================
--- trunk/src/tiled/io/MapHelper.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/io/MapHelper.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -13,10 +13,7 @@
 package tiled.io;
 
 import java.io.IOException;
-import java.util.Iterator;
-import java.util.Stack;
 import java.util.prefs.Preferences;
-
 import javax.swing.JOptionPane;
 
 import tiled.core.Map;
@@ -38,7 +35,7 @@
 
     public static final String ERROR_LOAD_MAP = Resources.getString("general.file.noload.map");
     public static final String ERROR_LOAD_TILESET = Resources.getString("general.file.noload.tileset");
-    
+
     /**
      * Called to tell the MapHelper which {@link PluginClassLoader} to use when
      * finding a suitable plugin for a filename.

Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -137,19 +137,6 @@
         }
     }
 
-    private static Node findChild(Node node, String childName) {
-        NodeList children = node.getChildNodes();
-
-        for (int i = 0; i < children.getLength(); i++) {
-            Node child = children.item(i);
-            if (child.getNodeName().equalsIgnoreCase(childName)) {
-                return child;
-            }
-        }
-
-        return null;
-    }
-
     private Object unmarshalClass(Class reflector, Node node)
         throws InstantiationException, IllegalAccessException,
                InvocationTargetException {
@@ -281,7 +268,8 @@
 
             xmlPath = xmlPathSave;
         } catch (SAXException e) {
-            logger.error("Failed while loading "+filename+": "+e.getLocalizedMessage());
+            logger.error("Failed while loading " + filename + ": "
+                    + e.getLocalizedMessage());
             //e.printStackTrace();
         }
 
@@ -743,7 +731,7 @@
         unmarshalledMap.setFilename(filename);
 
         map = null;
-        
+
         return unmarshalledMap;
     }
 

Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/MapEditor.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -18,7 +18,6 @@
 import java.awt.image.BufferedImage;
 import java.io.File;
 import java.io.IOException;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Stack;
 import java.util.Vector;
@@ -38,6 +37,7 @@
 import tiled.io.MapReader;
 import tiled.mapeditor.actions.*;
 import tiled.mapeditor.brush.AbstractBrush;
+import tiled.mapeditor.brush.Brush;
 import tiled.mapeditor.brush.CustomBrush;
 import tiled.mapeditor.brush.ShapeBrush;
 import tiled.mapeditor.dialogs.*;
@@ -114,8 +114,7 @@
     private JTable      layerTable;
     private JList       editHistoryList;
     private MiniMapViewer miniMap;
-    private JSplitPane  paletteSplit;
-    
+
     private TileButton  tilePaletteButton;
     private JFrame      appFrame;
     private JSlider     opacitySlider;
@@ -134,7 +133,8 @@
     private JButton tileInstancePropertiesButton;
 
     /** Available brushes */
-    private Hashtable brushes = new Hashtable();
+    private Vector brushes = new Vector();
+    private Brush eraserBrush;
 
     // Actions
     private final SaveAction saveAction;
@@ -150,17 +150,14 @@
 
     private static final String IMPORT_ERROR_MSG = Resources.getString("dialog.newtileset.import.error.message");
 
-    public static final String TOOL_PAINT = Resources.getString("tool.paint.name");
-    public static final String TOOL_ERASE = Resources.getString("tool.erase.name");
-    public static final String TOOL_FILL = Resources.getString("tool.fill.name");
-    public static final String TOOL_EYE_DROPPER = Resources.getString("tool.eyedropper.name");
-    public static final String TOOL_SELECT = Resources.getString("tool.select.name");
-    public static final String TOOL_MOVE_LAYER = Resources.getString("tool.movelayer.name");
-    public static final String TOOL_MOVE_OBJECT = Resources.getString("tool.moveobject.name");
-    public static final String TOOL_POINTER = "__pointer"; //used internally for brushes
+    private static final String TOOL_PAINT = Resources.getString("tool.paint.name");
+    private static final String TOOL_ERASE = Resources.getString("tool.erase.name");
+    private static final String TOOL_FILL = Resources.getString("tool.fill.name");
+    private static final String TOOL_EYE_DROPPER = Resources.getString("tool.eyedropper.name");
+    private static final String TOOL_SELECT = Resources.getString("tool.select.name");
+    private static final String TOOL_MOVE_LAYER = Resources.getString("tool.movelayer.name");
+    private static final String TOOL_MOVE_OBJECT = Resources.getString("tool.moveobject.name");
 
-    private String currentTool = TOOL_POINTER;
-    
     public MapEditor() {
         /*
         eraserBrush = new Eraser();
@@ -304,10 +301,9 @@
         mainSplit.setBorder(null);
 
         tabbedTilesetsPane = new TabbedTilesetsPane(this);
-        paletteSplit = new JSplitPane(
+        JSplitPane paletteSplit = new JSplitPane(
                 JSplitPane.VERTICAL_SPLIT, true, mainSplit,
                 tabbedTilesetsPane);
-        
         paletteSplit.setOneTouchExpandable(true);
         paletteSplit.setResizeWeight(1.0);
 
@@ -1072,8 +1068,7 @@
                         Resources.getString("dialog.selection.empty"),
                         JOptionPane.WARNING_MESSAGE);
             } else {
-                setBrush(TOOL_PAINT, new CustomBrush(brushLayer));
-                setCurrentBrush(TOOL_PAINT);
+                setBrush(new CustomBrush(brushLayer));
             }
 
             //get rid of any visible marquee
@@ -1158,28 +1153,28 @@
 
         if ("paint".equals(command)) {
             setCurrentPointerState(PS_PAINT);
-            currentTool = TOOL_PAINT;
+            resetBrush();
         } else if ("erase".equals(command)) {
             setCurrentPointerState(PS_ERASE);
-            currentTool = TOOL_ERASE;
+            resetBrush();
         } else if ("point".equals(command)) {
             setCurrentPointerState(PS_POINT);
-            currentTool = TOOL_POINTER;
+            resetBrush();
         } else if ("pour".equals(command)) {
             setCurrentPointerState(PS_POUR);
-            currentTool = TOOL_FILL;
+            resetBrush();
         } else if ("eyed".equals(command)) {
             setCurrentPointerState(PS_EYED);
-            currentTool = TOOL_EYE_DROPPER;
+            resetBrush();
         } else if ("marquee".equals(command)) {
             setCurrentPointerState(PS_MARQUEE);
-            currentTool = TOOL_SELECT;
+            resetBrush();
         } else if ("move".equals(command)) {
             setCurrentPointerState(PS_MOVE);
-            currentTool = TOOL_MOVE_LAYER;
+            resetBrush();
         } else if ("moveobject".equals(command)) {
             setCurrentPointerState(PS_MOVEOBJ);
-            currentTool = TOOL_MOVE_OBJECT;
+            resetBrush();
         } else if ("palette".equals(command)) {
             if (currentMap != null) {
                 if (tilePaletteDialog == null) {
@@ -1195,8 +1190,6 @@
         } else {
             handleEvent(event);
         }
-        
-        setCurrentBrush(currentTool);
     }
 
     // TODO: Most if not all of the below should be moved into action objects,
@@ -1785,70 +1778,39 @@
         undoSupport.postEdit(mle);
     }
 
-    public void resetBrushes() {
-        ShapeBrush sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        sb.setTile(currentTile);
-        setBrush(TOOL_PAINT, sb);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_ERASE, sb);
-        sb.setTile(null);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_EYE_DROPPER, sb);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_FILL, sb);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_SELECT, sb);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_MOVE_OBJECT, sb);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_MOVE_LAYER, sb);
-        sb = new ShapeBrush();
-        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-        setBrush(TOOL_POINTER, sb);
+    public void resetBrush() {
+        //FIXME: this is an in-elegant hack, but it gets the user out
+        //       of custom brush mode
+        //(reset the brush if necessary)
+        if (currentBrush instanceof CustomBrush) {
+            if (prefs.getBoolean("cursorhighlight", true)) {
+                Rectangle redraw = cursorHighlight.getBounds();
+                mapView.repaintRegion(redraw);
+            }
+            ShapeBrush sb = new ShapeBrush();
+            sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
+            sb.setTile(currentTile);
+            setBrush(sb);
+        }
     }
 
-    public void setCurrentBrush(String brush) {
-        
-        if (prefs.getBoolean("cursorhighlight", true) && mapView != null) {
-            Rectangle redraw = cursorHighlight.getBounds();
-            mapView.repaintRegion(redraw);
-        }
-        
-        //is it wrong that Tiled thinks in languages? ;)
-        currentBrush = (AbstractBrush) brushes.get(brush);
-        
+    public void setBrush(AbstractBrush brush) {
+        currentBrush = brush;
+
         Rectangle brushRedraw = currentBrush.getBounds();
 
-        //Make sure it's clean
-        cursorHighlight.unselectAll();
-        
+        // Make sure it's clean
         cursorHighlight.setOffset(0, 0);
 
         // Resize and select the region
         cursorHighlight.resize(brushRedraw.width, brushRedraw.height, 0, 0);
         cursorHighlight.selectRegion(currentBrush.getShape());
-        
-        if(!(currentBrush instanceof CustomBrush)) {
-            ((ShapeBrush)currentBrush).setTile(currentTile);
-        }
-        
         /*if (currentBrush instanceof CustomBrush) {
             cursorHighlight.setVisible(false);
         } else {
             cursorHighlight.setVisible(true);
         }*/
     }
-    
-    public void setBrush(String tool, AbstractBrush brush) {
-        brushes.put(tool, brush);
-    }
 
     public void updateTitle() {
         String title = Resources.getString("dialog.main.title");
@@ -1871,7 +1833,7 @@
 
     /**
      * Checks to see if the undo stack is empty
-     * 
+     *
      * @return <code>true</code> if there is an undo history, <code>false</code> otherwise.
      */
     public boolean unsavedChanges() {
@@ -2012,9 +1974,10 @@
         boolean mapLoaded = currentMap != null;
 
         // Create a default brush (protect against a bug with custom brushes)
-        resetBrushes();
-        setCurrentBrush(TOOL_PAINT);
-        
+        ShapeBrush sb = new ShapeBrush();
+        sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
+        setBrush(sb);
+
         if (tilePaletteDialog != null) {
             tilePaletteDialog.setMap(currentMap);
         }
@@ -2030,7 +1993,6 @@
             tileCoordsLabel.setText(" ");
             zoomLabel.setText(" ");
             setCurrentTile(null);
-            paletteSplit.setDividerLocation(1.0f);
         } else {
             final Preferences display = prefs.node("display");
             mapEventAdapter.fireEvent(MapEventAdapter.ME_MAPACTIVE);
@@ -2072,20 +2034,13 @@
             Tile firstTile = null;
             if (!tilesets.isEmpty()) {
                 Iterator it = tilesets.iterator();
-                while (it.hasNext()) {
-                    if( firstTile == null )
-                        firstTile = ((TileSet) it.next()).getFirstTile();
-                    
+                while (it.hasNext() && firstTile == null) {
+                    firstTile = ((TileSet) it.next()).getFirstTile();
                 }
             }
             setCurrentTile(firstTile);
 
             currentMap.addLayerSpecial(cursorHighlight);
-            
-            Dimension d = paletteSplit.getSize();
-            //Doesn't this look icky? Still, proportional is better.
-            //FIXME: the constant is an expedient fudge factor- should be tileset max height + scrollbar height + tab height
-            paletteSplit.setDividerLocation(1.0 - ((currentMap.getTileHeightMax() + 45) / d.getHeight()));
         }
 
         zoomInAction.setEnabled(mapLoaded);
@@ -2129,9 +2084,6 @@
                 layerTable.changeSelection(totalLayers - currentLayer - 1, 0,
                         false, false);
             }
-            
-            mapView.revalidate();
-            mapView.repaint();
         }
     }
 
@@ -2141,19 +2093,12 @@
      * @param tile the new tile to be selected
      */
     public void setCurrentTile(Tile tile) {
+        resetBrush();
 
         if (currentTile != tile) {
             currentTile = tile;
             if (!(currentBrush instanceof CustomBrush)) {
                 ((ShapeBrush) currentBrush).setTile(tile);
-            } else {
-            	//if setCurrentTile() is called directly, we reset the brush
-            	//to get out of custom brush mode
-                ShapeBrush sb = new ShapeBrush();
-                sb.makeQuadBrush(new Rectangle(0, 0, 1, 1));
-                sb.setTile(currentTile);
-                setBrush(currentTool, sb);
-                setCurrentBrush(currentTool);
             }
             tilePaletteButton.setTile(currentTile);
         }

Modified: trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java
===================================================================
--- trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/actions/MergeAllLayersAction.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -14,11 +14,11 @@
 
 import javax.swing.JOptionPane;
 
+import tiled.core.Map;
+import tiled.core.TileLayer;
 import tiled.mapeditor.MapEditor;
 import tiled.mapeditor.Resources;
 import tiled.util.TileMergeHelper;
-import tiled.core.TileLayer;
-import tiled.core.Map;
 
 /**
  * Merges all layers of the map. Optionally it will create a new tileset with
@@ -40,8 +40,8 @@
         int ret = JOptionPane.showConfirmDialog(editor.getAppFrame(),
                 "Do you wish to merge tile images, and create a new tile set?",
                 "Merge Tiles?", JOptionPane.YES_NO_CANCEL_OPTION);
-        
-        if ( ret == JOptionPane.YES_OPTION ) {
+
+        if (ret == JOptionPane.YES_OPTION) {
             TileMergeHelper tmh = new TileMergeHelper(map);
             int len = map.getTotalLayers();
             //TODO: Add a dialog option: "Yes, visible only"
@@ -51,7 +51,8 @@
             newLayer.setName("Merged Layer");
             map.addTileset(tmh.getSet());
             editor.setCurrentLayer(0);
-        } else if ( ret == JOptionPane.NO_OPTION ) {
+        }
+        else if (ret == JOptionPane.NO_OPTION) {
             while (map.getTotalLayers() > 1) {
                 map.mergeLayerDown(editor.getCurrentLayerIndex());
             }

Modified: trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/dialogs/BrushDialog.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -29,6 +29,8 @@
 import tiled.core.Tile;
 import tiled.io.MapHelper;
 import tiled.io.MapReader;
+import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.Resources;
 import tiled.mapeditor.brush.*;
 import tiled.mapeditor.plugin.PluginClassLoader;
 import tiled.mapeditor.util.LayerTableModel;
@@ -37,8 +39,6 @@
 import tiled.mapeditor.widget.IntegerSpinner;
 import tiled.mapeditor.widget.MiniMapViewer;
 import tiled.mapeditor.widget.VerticalStaticJPanel;
-import tiled.mapeditor.MapEditor;
-import tiled.mapeditor.Resources;
 import tiled.util.TiledConfiguration;
 
 /**
@@ -278,14 +278,12 @@
 
         if (source == okButton) {
             createFromOptions();
-            editor.setBrush(MapEditor.TOOL_PAINT, myBrush);
-            editor.setCurrentBrush(MapEditor.TOOL_PAINT);
+            editor.setBrush(myBrush);
             dispose();
         }
         else if (source == bApply) {
             createFromOptions();
-            editor.setBrush(MapEditor.TOOL_PAINT, myBrush);
-            editor.setCurrentBrush(MapEditor.TOOL_PAINT);
+            editor.setBrush(myBrush);
             bApply.setEnabled(false);
         }
         else if (source == bCancel) {

Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -161,7 +161,7 @@
         imageList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
         imageList.addListSelectionListener(this);
         JScrollPane sp = new JScrollPane(imageList);
-        sp.setPreferredSize(new Dimension(250, 150));
+        sp.setPreferredSize(new Dimension(150, 150));
 
         // Buttons
         createTileButton = new JButton(CREATE_BUTTON);

Modified: trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -117,8 +117,7 @@
     }
 
     public void tileRegionSelected(TileRegionSelectionEvent e) {
-        editor.setBrush(MapEditor.TOOL_PAINT, new CustomBrush(e.getTileRegion()));
-        editor.setCurrentBrush(MapEditor.TOOL_PAINT);
+        editor.setBrush(new CustomBrush(e.getTileRegion()));
     }
 
     public void valueChanged(ListSelectionEvent e) {

Modified: trunk/src/tiled/mapeditor/selection/SelectionLayer.java
===================================================================
--- trunk/src/tiled/mapeditor/selection/SelectionLayer.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/selection/SelectionLayer.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -97,14 +97,6 @@
     }
 
     /**
-     * Clears the entire selection
-     *
-     */
-    public void unselectAll() {
-        clearRegion(selection);
-    }
-    
-    /**
      * Sets the selected area to the given Shape.
      *
      * @param region
@@ -159,9 +151,9 @@
         for (int i = bounded.y; i < bounded.y + bounded.height; i++) {
             for (int j = bounded.x; j < bounded.x + bounded.width; j++) {
                 if (region.contains(j, i)) {
-                    setTileAt(j+bounds.x, i+bounds.y, fill);
+                    setTileAt(j + bounds.x, i + bounds.y, fill);
                 } else {
-                    setTileAt(j+bounds.x, i+bounds.y, null);
+                    setTileAt(j + bounds.x, i + bounds.y, null);
                 }
             }
         }

Modified: trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/widget/TabbedTilesetsPane.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -15,7 +15,6 @@
 
 package tiled.mapeditor.widget;
 
-import java.awt.Dimension;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -68,27 +67,13 @@
         this.map = map;
     }
 
-    public Dimension getPreferredSize() {
-        Dimension d = new Dimension(0,0);
-        for (Iterator it = tilePanels.iterator(); it.hasNext();) {
-            TilePaletteQuickPanel panel = (TilePaletteQuickPanel) it.next();
-            Dimension e = panel.getPreferredSize();
-            if(d.width < e.width)
-                d.width = e.width;
-            if(d.height < e.height)
-                d.height = e.height;
-        }
-        
-        return d;
-    }
-    
     /**
      * Creates the panels for the tilesets.
      */
     private void recreateTabs(List tilesets) {
         // Stop listening to the tile palette panels
         for (Iterator it = tilePanels.iterator(); it.hasNext();) {
-            TilePaletteQuickPanel panel = (TilePaletteQuickPanel) it.next();
+            TilePalettePanel panel = (TilePalettePanel) it.next();
             panel.removeTileSelectionListener(this);
         }
         tilePanels.clear();
@@ -114,11 +99,11 @@
      * @param tileset the given tileset
      */
     private void addTabForTileset(TileSet tileset) {
-        TilePaletteQuickPanel tilePanel = new TilePaletteQuickPanel();
+        TilePalettePanel tilePanel = new TilePalettePanel();
         tilePanel.setTileset(tileset);
         tilePanel.addTileSelectionListener(this);
         JScrollPane paletteScrollPane = new JScrollPane(tilePanel,
-                JScrollPane.VERTICAL_SCROLLBAR_NEVER,
+                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         addTab(tileset.getName(), paletteScrollPane);
     }
@@ -135,8 +120,7 @@
      * current brush.
      */
     public void tileRegionSelected(TileRegionSelectionEvent e) {
-        mapEditor.setBrush(MapEditor.TOOL_PAINT, new CustomBrush(e.getTileRegion()));
-        mapEditor.setCurrentBrush(MapEditor.TOOL_PAINT);
+        mapEditor.setBrush(new CustomBrush(e.getTileRegion()));
     }
 
     private class MyMapChangeListener implements MapChangeListener

Deleted: trunk/src/tiled/mapeditor/widget/TilePaletteQuickPanel.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TilePaletteQuickPanel.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/mapeditor/widget/TilePaletteQuickPanel.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -1,256 +0,0 @@
-/*
- *  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.widget;
-
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Vector;
-import javax.swing.JPanel;
-import javax.swing.Scrollable;
-import javax.swing.event.MouseInputAdapter;
-
-import tiled.core.*;
-import tiled.mapeditor.util.TileSelectionEvent;
-import tiled.mapeditor.util.TileSelectionListener;
-
-/**
- * Works very much like TilePalettePanel, but is more specialized, in that it 
- * always displays all tiles in one row, and stamps cannot be made from it.
- *
- * @version $Id: TilePaletteQuickPanel.java 701 2006-10-14 20:23:44Z bjorn $
- */
-public class TilePaletteQuickPanel extends JPanel implements Scrollable,
-       TilesetChangeListener
-{
-    private TileSet tileset;
-    private List tileSelectionListeners;
-    private Vector tilesetMap;
-    
-    public TilePaletteQuickPanel() {
-        tileSelectionListeners = new LinkedList();
-
-        MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() {
-            private Point origin;
-
-            public void mousePressed(MouseEvent e) {
-                origin = new Point(e.getX() / (tileset.getTileWidth() + 1), 0);
-                Tile clickedTile = getTileAt(origin.x, origin.y);
-                if (clickedTile != null) {
-                    fireTileSelectionEvent(clickedTile);
-                }
-            }
-        };
-        addMouseListener(mouseInputAdapter);
-        addMouseMotionListener(mouseInputAdapter);
-    }
-    
-    /**
-     * Adds tile selection listener. The listener will be notified when the
-     * user selects a tile.
-     *
-     * @param listener the listener to add
-     */
-    public void addTileSelectionListener(TileSelectionListener listener) {
-        tileSelectionListeners.add(listener);
-    }
-
-    /**
-     * Removes tile selection listener.
-     *
-     * @param listener the listener to remove
-     */
-    public void removeTileSelectionListener(TileSelectionListener listener) {
-        tileSelectionListeners.remove(listener);
-    }
-
-    private void fireTileSelectionEvent(Tile selectedTile) {
-        TileSelectionEvent event = new TileSelectionEvent(this, selectedTile);
-        Iterator iterator = tileSelectionListeners.iterator();
-
-        while (iterator.hasNext()) {
-            ((TileSelectionListener) iterator.next()).tileSelected(event);
-        }
-    }
-    
-    /**
-     * Draws checkerboard background.
-     *
-     * @param g the {@link Graphics} instance to draw on
-     */
-    private static void paintBackground(Graphics g) {
-        Rectangle clip = g.getClipBounds();
-        int side = 10;
-
-        int startX = clip.x / side;
-        int startY = clip.y / side;
-        int endX = (clip.x + clip.width) / side + 1;
-        int endY = (clip.y + clip.height) / side + 1;
-
-        // Fill with white background
-        g.setColor(Color.WHITE);
-        g.fillRect(clip.x, clip.y, clip.width, clip.height);
-
-        // Draw darker squares
-        g.setColor(Color.LIGHT_GRAY);
-        for (int y = startY; y < endY; y++) {
-            for (int x = startX; x < endX; x++) {
-                if ((y + x) % 2 == 1) {
-                    g.fillRect(x * side, y * side, side, side);
-                }
-            }
-        }
-    }
-
-    public Dimension getPreferredSize() {
-        if (tileset == null) {
-            return new Dimension(0, 0);
-        }
-        else {
-            int twidth = tileset.getTileWidth() + 1;
-            int theight = tileset.getTileHeight() + 1;
-            int tileCount = tilesetMap.size();
-
-            return new Dimension(tileCount * (twidth + 1), theight + 1);
-        }
-    }
-
-
-    // Scrollable interface
-
-    public Dimension getPreferredScrollableViewportSize() {
-        if (tileset != null) {
-            int twidth = tileset.getTileWidth() + 1;
-            int theight = tileset.getTileHeight() + 1;
-            int tileCount = tilesetMap.size();
-
-            return new Dimension(Math.max(1, (getWidth() - 1)), theight);
-        } else {
-            return new Dimension(0, 0);
-        }
-    }
-
-    public int getScrollableUnitIncrement(Rectangle visibleRect,
-            int orientation, int direction) {
-        if (tileset != null) {
-            return tileset.getTileWidth();
-        } else {
-            return 0;
-        }
-    }
-
-    public int getScrollableBlockIncrement(Rectangle visibleRect,
-            int orientation, int direction) {
-        if (tileset != null) {
-            return tileset.getTileWidth();
-        } else {
-            return 0;
-        }
-    }
-
-    public boolean getScrollableTracksViewportWidth() {
-        // todo: Update when this has become an option
-        return false;
-    }
-
-    public boolean getScrollableTracksViewportHeight() {
-        return tileset == null || tileset.getTilesPerRow() == 0;
-    }
-
-    public void paint(Graphics g) {
-        Rectangle clip = g.getClipBounds();
-
-        paintBackground(g);
-
-        if (tileset != null) {
-            // Draw the tiles
-            int twidth = tileset.getTileWidth() + 1;
-            int theight = tileset.getTileHeight() + 1;
-            int tilesPerRow = Math.max(1, (getWidth() - 1) / twidth);
-
-            int startY = clip.y / theight;
-            int endY = (clip.y + clip.height) / theight + 1;
-            int tileAt = tilesPerRow * startY;
-            int gx;
-            int gy = startY * theight;
-
-            for (int y = startY; y < endY; y++) {
-                gx = 1;
-
-                for (int x = 0;
-                     x < tilesPerRow && tileAt < tilesetMap.size();
-                     x++, tileAt++)
-                {
-                    Tile tile = (Tile) tilesetMap.get(tileAt);
-
-                    if (tile != null) {
-                        tile.drawRaw(g, gx, gy + theight, 1.0);
-                    }
-                    gx += twidth;
-                }
-                gy += theight;
-            }
-        }
-    }
-    
-    /**
-     * Retrieves the tile at the given tile coordinates. It assumes the tile
-     * coordinates are adjusted to the number of tiles per row.
-     *
-     * @param x x tile coordinate
-     * @param y y tile coordinate
-     * @return the tile at the given tile coordinates, or <code>null</code>
-     *         if the index is out of range
-     */
-    private Tile getTileAt(int x, int y) {
-        //we don't care about y, but it's here for convention
-
-        if (x >= tilesetMap.size()) {
-            return null;
-        } else {
-            return (Tile) tilesetMap.get(x);
-        }
-    }
-    
-    /**
-     * Change the tileset displayed by this palette panel.
-     *
-     * @param tileset the tileset to be displayed by this palette panel
-     */
-    public void setTileset(TileSet tileset) {
-        // Remove any existing listener
-        if (this.tileset != null) {
-            this.tileset.removeTilesetChangeListener(this);
-        }
-
-        this.tileset = tileset;
-
-        // Listen to changes in the new tileset
-        if (this.tileset != null) {
-            this.tileset.addTilesetChangeListener(this);
-        }
-
-        if (tileset != null) tilesetMap = tileset.generateGaplessVector();
-        revalidate();
-        repaint();
-    }
-
-    public void tilesetChanged(TilesetChangedEvent event) {
-        tilesetMap = tileset.generateGaplessVector();
-        revalidate();
-        repaint();
-    }
-
-}

Modified: trunk/src/tiled/view/HexMapView.java
===================================================================
--- trunk/src/tiled/view/HexMapView.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/view/HexMapView.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -13,12 +13,13 @@
 package tiled.view;
 
 import java.awt.*;
-import java.awt.geom.*;
-
+import java.awt.geom.Point2D;
 import javax.swing.SwingConstants;
 
-import tiled.core.*;
-import tiled.mapeditor.MapEditor;
+import tiled.core.Map;
+import tiled.core.ObjectGroup;
+import tiled.core.Tile;
+import tiled.core.TileLayer;
 import tiled.mapeditor.selection.SelectionLayer;
 
 /**
@@ -64,10 +65,6 @@
         super(map, null);
     }
 
-    public HexMapView(Map map, MapEditor editor) {
-        super(map, editor);
-    }
-    
     public int getScrollableBlockIncrement(Rectangle visibleRect,
             int orientation, int direction) {
         Dimension tsize = getTileSize();
@@ -154,21 +151,14 @@
     }
 
     private Dimension getTileSize() {
-        if(currentLayer instanceof TileLayer) {
-            Dimension d = ((TileLayer)currentLayer).getTileSize();
-            d.height *= zoom;
-            d.width *= zoom;
-            return d;
-        } else {
-            return new Dimension(
+        return new Dimension(
                 (int)(map.getTileWidth() * zoom),
                 (int)(map.getTileHeight() * zoom));
-        }
     }
 
-    protected void paintGrid(Graphics2D g2d, TileLayer layer) {
+    protected void paintGrid(Graphics2D g2d) {
         g2d.setColor(Color.black);
-        Dimension tileSize = layer.getTileSize();
+        Dimension tileSize = getTileSize();
         // Determine area to draw from clipping rectangle
         Rectangle clipRect = g2d.getClipBounds();
         Point topLeft = screenToTileCoords(
@@ -196,7 +186,7 @@
         }
     }
 
-    protected void paintCoordinates(Graphics2D g2d, TileLayer layer) {
+    protected void paintCoordinates(Graphics2D g2d) {
         // TODO: Implement paintCoordinates for HexMapView
     }
 
@@ -264,7 +254,7 @@
      */
     private Point2D getTopLeftCornerOfHex(int x, int y) {
         Dimension tileSize = getTileSize();
-        Point2D centre = tileToScreenCoords(tileSize, x, y);
+        Point2D centre = tileToScreenCoords(x, y);
         double leftX = centre.getX() - tileSize.getWidth() / 2;
         double topY = centre.getY() - tileSize.getHeight() / 2;
         return new Point2D.Double(leftX, topY);
@@ -326,7 +316,7 @@
      *
      * @return The point at the centre of the Hex.
      */
-    public Point tileToScreenCoords(Dimension tileSize, double x, double y) {
+    public Point tileToScreenCoords(double x, double y) {
         double xx = getWidthBetweenHexCentres() * x;
         double yy = getTileHeight() * y;
         if (x % 2 == 0) {

Modified: trunk/src/tiled/view/IsoMapView.java
===================================================================
--- trunk/src/tiled/view/IsoMapView.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/view/IsoMapView.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -15,16 +15,15 @@
 import java.awt.*;
 import java.awt.font.FontRenderContext;
 import java.awt.geom.Rectangle2D;
-
 import javax.swing.SwingConstants;
 
-import tiled.core.*;
-import tiled.mapeditor.MapEditor;
+import tiled.core.Map;
+import tiled.core.ObjectGroup;
+import tiled.core.Tile;
+import tiled.core.TileLayer;
 import tiled.mapeditor.selection.SelectionLayer;
 
 /**
- * Renderer for Isometric maps
- * 
  * @version $Id$
  */
 public class IsoMapView extends MapView
@@ -38,10 +37,6 @@
         super(map, null);
     }
 
-    public IsoMapView(Map map, MapEditor editor) {
-        super(map, editor);
-    }
-    
     public int getScrollableBlockIncrement(Rectangle visibleRect,
             int orientation, int direction) {
         Dimension tsize = getTileSize();
@@ -63,9 +58,6 @@
     }
 
     protected void paintLayer(Graphics2D g2d, TileLayer layer) {
-        
-        currentLayer = layer;
-        
         // Turn anti alias on for selection drawing
         g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                 RenderingHints.VALUE_ANTIALIAS_ON);
@@ -77,7 +69,7 @@
 
         Point rowItr = screenToTileCoords(clipRect.x, clipRect.y);
         rowItr.x--;
-        Point drawLoc = tileToScreenCoords(tileSize, rowItr.x, rowItr.y);
+        Point drawLoc = tileToScreenCoords(rowItr.x, rowItr.y);
         drawLoc.x -= tileSize.width / 2;
         drawLoc.y += tileSize.height;
 
@@ -127,10 +119,9 @@
 
     protected void paintObjectGroup(Graphics2D g2d, ObjectGroup og) {
         // TODO: Implement objectgroup painting for IsoMapView
-        currentLayer = og;
     }
 
-    protected void paintGrid(Graphics2D g2d, TileLayer layer) {
+    protected void paintGrid(Graphics2D g2d) {
         Dimension tileSize = getTileSize();
         Rectangle clipRect = g2d.getClipBounds();
 
@@ -148,25 +139,23 @@
                     clipRect.x, clipRect.y + clipRect.height).y);
 
         for (int y = startY; y <= endY; y++) {
-            Point start = tileToScreenCoords(tileSize, startX, y);
-            Point end = tileToScreenCoords(tileSize, endX, y);
+            Point start = tileToScreenCoords(startX, y);
+            Point end = tileToScreenCoords(endX, y);
             g2d.drawLine(start.x, start.y, end.x, end.y);
         }
         for (int x = startX; x <= endX; x++) {
-            Point start = tileToScreenCoords(tileSize, x, startY);
-            Point end = tileToScreenCoords(tileSize, x, endY);
+            Point start = tileToScreenCoords(x, startY);
+            Point end = tileToScreenCoords(x, endY);
             g2d.drawLine(start.x, start.y, end.x, end.y);
         }
     }
 
-    protected void paintCoordinates(Graphics2D g2d, TileLayer layer) {
+    protected void paintCoordinates(Graphics2D g2d) {
         g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
 
         Rectangle clipRect = g2d.getClipBounds();
-        Dimension tileSize = layer.getTileSize();
-        tileSize.width *= zoom;
-        tileSize.height *= zoom;
+        Dimension tileSize = getTileSize();
         int tileStepY = tileSize.height / 2 == 0 ? 1 : tileSize.height / 2;
         Font font = new Font("SansSerif", Font.PLAIN, tileSize.height / 4);
         g2d.setFont(font);
@@ -174,7 +163,7 @@
 
         Point rowItr = screenToTileCoords(clipRect.x, clipRect.y);
         rowItr.x--;
-        Point drawLoc = tileToScreenCoords(tileSize, rowItr.x, rowItr.y);
+        Point drawLoc = tileToScreenCoords(rowItr.x, rowItr.y);
         drawLoc.y += tileSize.height / 2;
 
         // Determine area to draw from clipping rectangle
@@ -218,19 +207,7 @@
     }
 
     protected void paintPropertyFlags(Graphics2D g2d, TileLayer layer) {
-        Dimension tsize = getTileSize();
-        if (tsize.width <= 0 || tsize.height <= 0) {
-            return;
-        }
-        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
-
-        // Determine tile size and offset
-        Font font = new Font("SansSerif", Font.PLAIN, tsize.height / 4);
-        g2d.setFont(font);
-        FontRenderContext fontRenderContext = g2d.getFontRenderContext();
-        
-        //TODO: finish this
+        throw new RuntimeException("Not yet implemented");    // todo
     }
 
     public void repaintRegion(Rectangle region) {
@@ -242,12 +219,12 @@
         int mapY1 = region.y;
         int mapX2 = mapX1 + region.width;
         int mapY2 = mapY1 + region.height;
-        
-        int x1 = tileToScreenCoords(tileSize, mapX1, mapY2).x;
-        int y1 = tileToScreenCoords(tileSize, mapX1, mapY1).y - maxExtraHeight;
-        int x2 = tileToScreenCoords(tileSize, mapX2, mapY1).x;
-        int y2 = tileToScreenCoords(tileSize, mapX2, mapY2).y;
 
+        int x1 = tileToScreenCoords(mapX1, mapY2).x;
+        int y1 = tileToScreenCoords(mapX1, mapY1).y - maxExtraHeight;
+        int x2 = tileToScreenCoords(mapX2, mapY1).x;
+        int y2 = tileToScreenCoords(mapX2, mapY2).y;
+
         repaint(new Rectangle(x1, y1, x2 - x1, y2 - y1));
     }
 
@@ -295,31 +272,20 @@
     }
 
     protected Dimension getTileSize() {
-        if(currentLayer instanceof TileLayer) {
-            Dimension d = ((TileLayer)currentLayer).getTileSize();
-            d.height *= zoom;
-            d.width *= zoom;
-            return d;
-        } else {
-            return new Dimension(
+        return new Dimension(
                 (int)(map.getTileWidth() * zoom),
                 (int)(map.getTileHeight() * zoom));
-        }
     }
 
     protected double getTileRatio() {
-        if(currentLayer instanceof TileLayer) {
-            Dimension d = ((TileLayer)currentLayer).getTileSize();
-            return (double)d.width / (double)d.height;
-        } else {
-            return (double)map.getTileWidth() / (double)map.getTileHeight();
-        }
+        return (double)map.getTileWidth() / (double)map.getTileHeight();
     }
 
     /**
-     * @see tiled.view.MapView#tileToScreenCoords(Dimension, double, double)
+     * Returns the location on the screen of the top corner of a tile.
      */
-    public Point tileToScreenCoords(Dimension tileSize, double x, double y) {
+    public Point tileToScreenCoords(double x, double y) {
+        Dimension tileSize = getTileSize();
         int originX = (map.getHeight() * tileSize.width) / 2;
         return new Point(
                 (int)((x - y) * tileSize.width / 2) + originX,

Modified: trunk/src/tiled/view/MapView.java
===================================================================
--- trunk/src/tiled/view/MapView.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/view/MapView.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -38,7 +38,6 @@
     public static int ZOOM_NORMALSIZE = 5;
 
     protected Map map;
-    protected MapLayer currentLayer;
     protected Brush currentBrush;
     protected int modeFlags;
     protected double zoom = 1.0;
@@ -221,16 +220,16 @@
         int orientation = p.getOrientation();
 
         if (orientation == Map.MDO_ISO) {
-            mapView = new IsoMapView(p, editor);
+            mapView = new IsoMapView(p);
         }
         else if (orientation == Map.MDO_ORTHO) {
             mapView = new OrthoMapView(p, editor); // FIXME
         }
         else if (orientation == Map.MDO_HEX) {
-            mapView = new HexMapView(p, editor);
+            mapView = new HexMapView(p);
         }
         else if (orientation == Map.MDO_SHIFTED) {
-            mapView = new ShiftedMapView(p, editor);
+            mapView = new ShiftedMapView(p);
         }
 
         return mapView;
@@ -257,7 +256,7 @@
         g2d.setStroke(new BasicStroke(2.0f));
 
         // Do an initial fill with the background color
-        // TODO: make background color configurable
+        // todo: make background color configurable
         //try {
         //    String colorString = displayPrefs.get("backgroundColor", "");
         //    g2d.setColor(Color.decode(colorString));
@@ -292,24 +291,7 @@
 
         // Grid color (also used for coordinates)
         g2d.setColor(gridColor);
-        
-        //----- everything after this point requires a valid TileLayer
-        //we don't show grid on object layers anyway...
-        TileLayer tl = null;
-        if (editor != null && !(editor.getCurrentLayer() instanceof TileLayer)) {
-            // I guess we shouldn't assume the bottom layer is a tile layer...
-            for(int i=0;i<map.getTotalLayers();i++) {
-                if(map.getLayer(i) instanceof TileLayer) {
-                    tl = (TileLayer)map.getLayer(i);
-                }
-            }
-        } else if (editor != null) {
-            tl = (TileLayer) editor.getCurrentLayer();
-        }
-        
-        if(tl == null)
-            return;
-        
+
         if (showGrid) {
             // Grid opacity
             if (gridOpacity < 255) {
@@ -332,21 +314,24 @@
             }
 
             g2d.setStroke(new BasicStroke());
-            paintGrid(g2d, tl);
+            paintGrid(g2d);
         }
 
         if (getMode(PF_COORDINATES)) {
             g2d.setComposite(AlphaComposite.SrcOver);
-            paintCoordinates(g2d, tl);
+            paintCoordinates(g2d);
         }
 
-        g2d.setComposite(AlphaComposite.SrcOver);
+        if (editor != null && editor.getCurrentLayer() instanceof TileLayer) {
+            g2d.setComposite(AlphaComposite.SrcOver);
 
-        if (tl.isVisible()) {
-            paintPropertyFlags(g2d, tl);
+            TileLayer tl = (TileLayer) editor.getCurrentLayer();
+            if (tl != null && tl.isVisible()) {
+                paintPropertyFlags(g2d, tl);
+            }
         }
     }
-    
+
     public void paintSubMap(MultilayerPlane m, Graphics2D g2d,
                             float mapOpacity) {
         Iterator li = m.getLayers();
@@ -376,12 +361,6 @@
         }
     }
 
-    protected Dimension getDefaultTileSize() {
-        return new Dimension(
-                (int)(map.getTileWidth() * zoom),
-                (int)(map.getTileHeight() * zoom));
-    }
-    
     /**
      * Draws a TileLayer. Implemented in a subclass.
      *
@@ -470,14 +449,14 @@
      *
      * @param g2d the graphics context to draw the grid onto
      */
-    protected abstract void paintGrid(Graphics2D g2d, TileLayer currentLayer);
+    protected abstract void paintGrid(Graphics2D g2d);
 
     /**
      * Draws the coordinates on each tile.
      *
      * @param g2d the graphics context to draw the coordinates onto
      */
-    protected abstract void paintCoordinates(Graphics2D g2d, TileLayer layer);
+    protected abstract void paintCoordinates(Graphics2D g2d);
 
     protected abstract void paintPropertyFlags(Graphics2D g2d, TileLayer layer);
 
@@ -497,11 +476,10 @@
 
     /**
      * Returns the location on the screen of the top corner of a tile.
-     * 
-     * @param tileSize 
-     * @param x 
-     * @param y 
+     *
+     * @param x
+     * @param y
      * @return Point
      */
-    public abstract Point tileToScreenCoords(Dimension tileSize, double x, double y);
+    public abstract Point tileToScreenCoords(double x, double y);
 }

Modified: trunk/src/tiled/view/OrthoMapView.java
===================================================================
--- trunk/src/tiled/view/OrthoMapView.java	2006-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/view/OrthoMapView.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -69,9 +69,6 @@
     }
 
     protected void paintLayer(Graphics2D g2d, TileLayer layer) {
-        
-        currentLayer = layer;
-        
         // Determine tile size and offset
         Dimension tsize = getTileSize();
         if (tsize.width <= 0 || tsize.height <= 0) {
@@ -111,9 +108,7 @@
 
     protected void paintObjectGroup(Graphics2D g, ObjectGroup og) {
         Iterator itr = og.getObjects();
-        currentLayer = og;
-        
-        
+
         while (itr.hasNext()) {
             MapObject mo = (MapObject) itr.next();
             double ox = mo.getX() * zoom;
@@ -129,11 +124,9 @@
         }
     }
 
-    protected void paintGrid(Graphics2D g2d, TileLayer layer) {
+    protected void paintGrid(Graphics2D g2d) {
         // Determine tile size
-        Dimension tsize = layer.getTileSize();
-        tsize.width *= zoom;
-        tsize.height *= zoom;
+        Dimension tsize = getTileSize();
         if (tsize.width <= 0 || tsize.height <= 0) {
             return;
         }
@@ -153,10 +146,8 @@
         }
     }
 
-    protected void paintCoordinates(Graphics2D g2d, TileLayer layer) {
-        Dimension tsize = layer.getTileSize();
-        tsize.width *= zoom;
-        tsize.height *= zoom;
+    protected void paintCoordinates(Graphics2D g2d) {
+        Dimension tsize = getTileSize();
         if (tsize.width <= 0 || tsize.height <= 0) {
             return;
         }
@@ -267,16 +258,9 @@
     }
 
     protected Dimension getTileSize() {
-        if(currentLayer instanceof TileLayer) {
-            Dimension d = ((TileLayer)currentLayer).getTileSize();
-            d.height *= zoom;
-            d.width *= zoom;
-            return d;
-        } else {
-            return new Dimension(
-                (int)(map.getTileWidth() * zoom),
-                (int)(map.getTileHeight() * zoom));
-        }
+        return new Dimension(
+                (int) (map.getTileWidth() * zoom),
+                (int) (map.getTileHeight() * zoom));
     }
 
     protected Polygon createGridPolygon(int tx, int ty, int border) {
@@ -291,7 +275,8 @@
         return poly;
     }
 
-    public Point tileToScreenCoords(Dimension tsize, double x, double y) {
+    public Point tileToScreenCoords(double x, double y) {
+        Dimension tsize = getTileSize();
         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-12-27 15:28:41 UTC (rev 713)
+++ trunk/src/tiled/view/ShiftedMapView.java	2007-01-07 17:47:19 UTC (rev 714)
@@ -13,13 +13,11 @@
 package tiled.view;
 
 import java.awt.*;
-
 import javax.swing.SwingConstants;
 
 import tiled.core.Map;
 import tiled.core.ObjectGroup;
 import tiled.core.TileLayer;
-import tiled.mapeditor.MapEditor;
 
 /**
  * @version $Id$
@@ -41,13 +39,6 @@
         verSide = 0;
     }
 
-    public ShiftedMapView(Map map, MapEditor editor) {
-        super(map, editor);
-
-        horSide = 16;
-        verSide = 0;
-    }
-    
     public int getScrollableBlockIncrement(Rectangle visibleRect,
             int orientation, int direction) {
         int unit =
@@ -89,9 +80,9 @@
     protected void paintObjectGroup(Graphics2D g2d, ObjectGroup og) {
     }
 
-    protected void paintGrid(Graphics2D g2d, TileLayer layer) {
+    protected void paintGrid(Graphics2D g2d) {
         // Determine tile size
-        Dimension tsize = layer.getTileSize();
+        Dimension tsize = getTileSize();
         if (tsize.width <= 0 || tsize.height <= 0) return;
         int onceX = (tsize.width - (int)(horSide * zoom)) / 2;
         int repeatX = tsize.width - onceX;
@@ -124,7 +115,7 @@
         g2d.setColor(prevColor);
     }
 
-    protected void paintCoordinates(Graphics2D g2d, TileLayer layer) {
+    protected void paintCoordinates(Graphics2D g2d) {
     }
 
     protected void paintPropertyFlags(Graphics2D g2d, TileLayer layer) {
@@ -139,23 +130,16 @@
     }
 
     protected Dimension getTileSize() {
-        if(currentLayer instanceof TileLayer) {
-            Dimension d = ((TileLayer)currentLayer).getTileSize();
-            d.height *= zoom;
-            d.width *= zoom;
-            return d;
-        } else {
-            return new Dimension(
+        return new Dimension(
                 (int)(map.getTileWidth() * zoom),
                 (int)(map.getTileHeight() * zoom));
-        }
     }
 
     protected Polygon createGridPolygon(int tx, int ty, int border) {
         return new Polygon();
     }
 
-    public Point tileToScreenCoords(Dimension tileSize, double x, double y) {
+    public Point tileToScreenCoords(double x, double y) {
         return new Point(0, 0);
     }
 }




More information about the tiled-commit mailing list