[tiled] r583 - branches/bjorn branches/bjorn/src/tiled/core branches/bjorn/src/tiled/io branches/bjorn/src/tiled/io/xml branches/bjorn/src/tiled/mapeditor branches/bjorn/src/tiled/mapeditor/brush branches/bjorn/src/tiled/mapeditor/dialogs branches/bjorn/src/tiled/mapeditor/selection branches/bjorn/src/tiled/mapeditor/widget branches/bjorn/src/tiled/util trunk/src/tiled/core trunk/src/tiled/io trunk/src/tiled/io/xml trunk/src/tiled/mapeditor trunk/src/tiled/mapeditor/brush trunk/src/tiled/mapeditor/dialogs trunk/src/tiled/mapeditor/plugin trunk/src/tiled/mapeditor/selection trunk/src/tiled/plugins/tmw
svn@biggeruniverse.com
svn at biggeruniverse.com
Fri Feb 17 15:18:33 PST 2006
Author: bjorn
Date: 2006-02-17 17:18:32 -0600 (Fri, 17 Feb 2006)
New Revision: 583
Modified:
branches/bjorn/CHANGES
branches/bjorn/build.xml
branches/bjorn/src/tiled/core/Map.java
branches/bjorn/src/tiled/core/MultilayerPlane.java
branches/bjorn/src/tiled/core/Sprite.java
branches/bjorn/src/tiled/io/ImageHelper.java
branches/bjorn/src/tiled/io/MapWriter.java
branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java
branches/bjorn/src/tiled/io/xml/XMLMapWriter.java
branches/bjorn/src/tiled/io/xml/XMLWriter.java
branches/bjorn/src/tiled/mapeditor/MapEditor.java
branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java
branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
branches/bjorn/src/tiled/mapeditor/selection/SelectionLayer.java
branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java
branches/bjorn/src/tiled/util/TiledConfiguration.java
trunk/src/tiled/core/MultilayerPlane.java
trunk/src/tiled/core/Sprite.java
trunk/src/tiled/core/TileSet.java
trunk/src/tiled/io/MapWriter.java
trunk/src/tiled/io/xml/XMLMapTransformer.java
trunk/src/tiled/io/xml/XMLMapWriter.java
trunk/src/tiled/mapeditor/MapEditor.java
trunk/src/tiled/mapeditor/brush/ShapeBrush.java
trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java
trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
trunk/src/tiled/mapeditor/dialogs/TileDialog.java
trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
trunk/src/tiled/mapeditor/dialogs/TilesetManager.java
trunk/src/tiled/mapeditor/plugin/PluginClassLoader.java
trunk/src/tiled/mapeditor/selection/SelectionLayer.java
trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java
Log:
A host of small changes to reduce the differences between my branch and trunk.
Modified: branches/bjorn/CHANGES
===================================================================
--- branches/bjorn/CHANGES 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/CHANGES 2006-02-17 23:18:32 UTC (rev 583)
@@ -7,6 +7,7 @@
* 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.
+* Fixed saving a map with no extension (now defaults to .tmx)
Planned changes
+ Added the Shifted view, which emulates several tiling configurations
@@ -14,7 +15,6 @@
+ Added ability to select multiple layers from layer table
+ Added the ability to merge tile images when layers are merged
+ Fixed memory problems when loading several maps with many tilesets in a row
-+ Fixed NullPointerException when saving without specifying an extention
+ Localizations to Dutch and German
0.5.1 - June 15th, 2005
Modified: branches/bjorn/build.xml
===================================================================
--- branches/bjorn/build.xml 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/build.xml 2006-02-17 23:18:32 UTC (rev 583)
@@ -49,6 +49,7 @@
<copy todir="${build}/tiled/mapeditor/resources">
<fileset dir="./src/tiled/mapeditor/resources">
<include name="*.png" />
+ <include name="*.properties" />
<include name="map.dtd" />
</fileset>
</copy>
Modified: branches/bjorn/src/tiled/core/Map.java
===================================================================
--- branches/bjorn/src/tiled/core/Map.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/core/Map.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -470,16 +470,4 @@
getTotalLayers() + "][" + tileWidth + "x" +
tileHeight + "]";
}
-
- /**
- * Determines wether the point (x,y) falls within the map boundaries.
- *
- * @param x
- * @param y
- * @return <code>true</code> if the point is within the map boundaries,
- * <code>false</code> otherwise
- */
- public boolean inBounds(int x, int y) {
- return x >= 0 && y >= 0 && x < widthInTiles && y < heightInTiles;
- }
}
Modified: branches/bjorn/src/tiled/core/MultilayerPlane.java
===================================================================
--- branches/bjorn/src/tiled/core/MultilayerPlane.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/core/MultilayerPlane.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -53,7 +53,23 @@
return layers.size();
}
+ /**
+ * Changes the bounds of this plane to include all layers completely.
+ */
+ public void fitBoundsToLayers() {
+ int width = 0;
+ int height = 0;
+ for (int i = 0; i < layers.size(); i++) {
+ Rectangle layerBounds = getLayer(i).getBounds();
+ if (width < layerBounds.width) width = layerBounds.width;
+ if (height < layerBounds.height) height = layerBounds.height;
+ }
+
+ widthInTiles = width;
+ heightInTiles = height;
+ }
+
/**
* Returns a <code>Rectangle</code> representing the maximum bounds in
* tiles.
@@ -238,7 +254,15 @@
heightInTiles = height;
}
+ /**
+ * Determines wether the point (x,y) falls within the plane.
+ *
+ * @param x
+ * @param y
+ * @return <code>true</code> if the point is within the plane,
+ * <code>false</code> otherwise
+ */
public boolean inBounds(int x, int y) {
- return (x >= 0 && x <= widthInTiles) && (y >= 0 && y <= heightInTiles);
+ return x >= 0 && y >= 0 && x < widthInTiles && y < heightInTiles;
}
}
Modified: branches/bjorn/src/tiled/core/Sprite.java
===================================================================
--- branches/bjorn/src/tiled/core/Sprite.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/core/Sprite.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -19,16 +19,16 @@
public class Sprite {
private Vector keys;
- KeyFrame currentKey=null;
- private int totalFrames=0,
- borderWidth=0,
- fpl=0,
- totalKeys=-1,
- transparent=0;
+ KeyFrame currentKey = null;
+ private int totalFrames = 0;
+ private int borderWidth = 0;
+ private int fpl = 0;
+ private int totalKeys = -1;
+ private int transparent = 0;
private float currentFrame=0;
private Rectangle frameSize;
- private Image sprite=null;
+ private Image sprite = null;
private boolean bPlaying=true;
public Sprite() {
@@ -150,15 +150,15 @@
if (currentKey!=null) {
if (bPlaying) {
- currentFrame+=currentKey.getFrameRate();
+ currentFrame += currentKey.getFrameRate();
}
if ((int)currentFrame>currentKey.getFinishFrame()) {
- if ((currentKey.getFlags()&KeyFrame.KEY_LOOP)==KeyFrame.KEY_LOOP) {
+ if ((currentKey.getFlags()&KeyFrame.KEY_LOOP) == KeyFrame.KEY_LOOP) {
currentFrame=currentKey.getStartFrame();
- }else if ((currentKey.getFlags()&KeyFrame.KEY_REVERSE)==KeyFrame.KEY_REVERSE) {
+ } else if ((currentKey.getFlags()&KeyFrame.KEY_REVERSE) == KeyFrame.KEY_REVERSE) {
currentKey.setFrameRate(-currentKey.getFrameRate());
- }else if ((currentKey.getFlags()&KeyFrame.KEY_AUTO)==KeyFrame.KEY_AUTO) {
+ } else if ((currentKey.getFlags()&KeyFrame.KEY_AUTO) == KeyFrame.KEY_AUTO) {
//TODO: need to iterate to the next key
if (currentKey!=null) {
currentFrame = currentKey.getStartFrame();
@@ -167,13 +167,13 @@
currentFrame=currentKey.getFinishFrame();
bPlaying=false;
}
- }else if ((int)currentFrame<currentKey.getStartFrame()) {
- if ((currentKey.getFlags()&KeyFrame.KEY_LOOP)==KeyFrame.KEY_LOOP) {
+ } else if ((int)currentFrame<currentKey.getStartFrame()) {
+ if ((currentKey.getFlags()&KeyFrame.KEY_LOOP) == KeyFrame.KEY_LOOP) {
currentFrame=currentKey.getFinishFrame();
- }else if ((currentKey.getFlags()&KeyFrame.KEY_REVERSE)==KeyFrame.KEY_REVERSE) {
+ } else if ((currentKey.getFlags()&KeyFrame.KEY_REVERSE) == KeyFrame.KEY_REVERSE) {
currentKey.setFrameRate(-currentKey.getFrameRate());
} else {
- bPlaying=false;
+ bPlaying = false;
}
}
@@ -189,7 +189,7 @@
}
public void stop() {
- bPlaying=false;
+ bPlaying = false;
}
public void keyStepBack(int amt) {
@@ -210,9 +210,9 @@
public KeyFrame getKey(String keyName) {
Iterator itr = keys.iterator();
- while(itr.hasNext()) {
+ while (itr.hasNext()) {
KeyFrame k = (KeyFrame) itr.next();
- if(k.equalsIgnoreCase(keyName)) {
+ if (k.equalsIgnoreCase(keyName)) {
return k;
}
}
@@ -236,7 +236,7 @@
}
public void draw(Graphics g) {
- int x=0, y=0;
+ int x = 0, y = 0;
if(frameSize.height>0 && frameSize.width>0) {
y=(((int)currentFrame)/fpl)*(frameSize.height+borderWidth);
@@ -256,6 +256,5 @@
s = "Frame: ("+frameSize.width+"x"+frameSize.height+")\nBorder: "+borderWidth+"\nFPL: "+fpl+"\nTotal Frames: "+totalFrames+"\nTotal keys: "+totalKeys;
return s;
}
-
}
Modified: branches/bjorn/src/tiled/io/ImageHelper.java
===================================================================
--- branches/bjorn/src/tiled/io/ImageHelper.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/io/ImageHelper.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -55,7 +55,7 @@
/**
* Converts a byte array into an image. The byte array must include the image
* header, so that a decision about format can be made.
- *
+ *
* @param imageData The byte array of the data to convert.
* @return Image The image instance created from the byte array
* @see java.awt.Toolkit#createImage(byte[] imagedata)
@@ -63,11 +63,11 @@
static public Image bytesToImage(byte[] imageData) {
return Toolkit.getDefaultToolkit().createImage(imageData);
}
-
+
/**
* This function loads the image denoted by <code>file</code>. This supports
* PNG, GIF, JPG, and BMP (in 1.5).
- *
+ *
* @param file
* @return the (partially) loaded image
* @throws IOException
Modified: branches/bjorn/src/tiled/io/MapWriter.java
===================================================================
--- branches/bjorn/src/tiled/io/MapWriter.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/io/MapWriter.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -18,8 +18,12 @@
import tiled.core.Map;
import tiled.core.TileSet;
-
-public interface MapWriter extends PluggableMapIO, FileFilter
+/**
+ * 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.
+ */
+public interface MapWriter extends PluggableMapIO, FileFilter
{
/**
* Saves a map to a file.
@@ -49,5 +53,12 @@
*/
public void writeMap(Map map, OutputStream out) throws Exception;
+ /**
+ * Overload this to write a tileset to an open stream.
+ *
+ * @param set
+ * @param out
+ * @throws Exception
+ */
public void writeTileset(TileSet set, OutputStream out) throws Exception;
}
Modified: branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -185,7 +185,7 @@
Image img = null;
String source = getAttributeValue(t, "source");
-
+
if (source != null) {
if (Util.checkRoot(source)) {
source = makeUrl(source);
@@ -222,7 +222,7 @@
}
}
*/
-
+
return img;
}
@@ -264,7 +264,7 @@
warnings.push("ERROR: Could not find external tileset file " +
filename);
}
-
+
return set;
}
@@ -284,16 +284,16 @@
//if (Util.checkRoot(source)) {
// filename = makeUrl(source);
//}
-
+
TileSet ext = null;
try {
- //just a little check for tricky people...
+ //just a little check for tricky people...
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);
} catch (FileNotFoundException fnf) {
@@ -301,11 +301,11 @@
filename);
}
- if(ext == null) {
- warnings.push("ERROR: tileset "+source+" was not loaded correctly!");
- ext = new TileSet();
+ if (ext == null) {
+ warnings.push("ERROR: tileset "+source+" was not loaded correctly!");
+ ext = new TileSet();
}
-
+
ext.setFirstGid(firstGid);
return ext;
}
@@ -467,7 +467,7 @@
} catch (Exception e) {
e.printStackTrace();
}
-
+
//Read all objects from the group, "...and in the darkness bind them."
NodeList children = t.getChildNodes();
@@ -477,7 +477,7 @@
og.bindObject(unmarshalObject(child));
}
}
-
+
return og;
}
@@ -498,7 +498,7 @@
ml.setOffset(offsetX, offsetY);
ml.setName(getAttributeValue(t, "name"));
ml.setVisible(visible == 1);
-
+
if (opacity != null) {
ml.setOpacity(Float.parseFloat(opacity));
}
@@ -685,7 +685,7 @@
public Map readMap(String filename) throws Exception {
xmlPath = filename.substring(0,
filename.lastIndexOf(File.separatorChar) + 1);
-
+
String xmlFile = makeUrl(filename);
//xmlPath = makeUrl(xmlPath);
@@ -699,26 +699,26 @@
Map unmarshalledMap = unmarshal(is);
unmarshalledMap.setFilename(filename);
-
+
return unmarshalledMap;
}
public Map readMap(InputStream in) throws Exception {
xmlPath = makeUrl(".");
-
+
Map unmarshalledMap = unmarshal(in);
-
+
//unmarshalledMap.setFilename(xmlFile)
//
return unmarshalledMap;
}
-
+
public TileSet readTileset(String filename) throws Exception {
String xmlFile = filename;
-
+
xmlPath = filename.substring(0,
filename.lastIndexOf(File.separatorChar) + 1);
-
+
xmlFile = makeUrl(xmlFile);
xmlPath = makeUrl(xmlPath);
@@ -730,7 +730,7 @@
// TODO: The MapReader interface should be changed...
return unmarshalTilesetFile(in, ".");
}
-
+
/**
* @see tiled.io.MapReader#getFilter()
*/
@@ -741,7 +741,7 @@
public String getPluginPackage() {
return "Tiled internal TMX reader/writer";
}
-
+
/**
* @see tiled.io.PluggableMapIO#getDescription()
*/
@@ -767,7 +767,7 @@
} catch (IOException e) {}
return false;
}
-
+
public void setErrorStack(Stack es) {
warnings = es;
}
Modified: branches/bjorn/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLMapWriter.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/io/xml/XMLMapWriter.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -247,10 +247,10 @@
} else if (!embedImages) {
String imgSource =
prefs.get("tileImagePrefix", "tile") + "set.png";
-
+
w.startElement("image");
w.writeAttribute("source", imgSource);
-
+
String tilesetFilename = wp.substring(0,
wp.lastIndexOf(File.separatorChar) + 1) + imgSource;
FileOutputStream fw = new FileOutputStream(new File(
@@ -258,10 +258,10 @@
//byte[] data = ImageHelper.imageToPNG(setImage);
//fw.write(data, 0, data.length);
w.endElement();
-
+
fw.close();
}
-
+
// Check to see if there is a need to write tile elements
if (set.isOneForOne()) {
Iterator tileIterator = set.iterator();
Modified: branches/bjorn/src/tiled/io/xml/XMLWriter.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLWriter.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/io/xml/XMLWriter.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -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>
*/
@@ -29,7 +29,7 @@
private String indentString = " ";
private String newLine = "\n";
private final Writer w;
-
+
private final Stack openElements;
private boolean bStartTagOpen;
private boolean bDocumentOpen;
@@ -49,12 +49,12 @@
public void setIndentString(String indentString) {
this.indentString = indentString;
}
-
+
public void startDocument() throws IOException {
startDocument("1.0");
}
-
+
public void startDocument(String version) throws IOException {
w.write("<?xml version=\"" + version + "\"?>" + newLine);
bDocumentOpen = true;
@@ -73,7 +73,7 @@
writeIndent();
w.write("<" + name);
-
+
openElements.push(name);
bStartTagOpen = true;
}
Modified: branches/bjorn/src/tiled/mapeditor/MapEditor.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/MapEditor.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/mapeditor/MapEditor.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -814,7 +814,8 @@
}
} else if (command.equals("Merge All")) {
//TODO: put this back in for 0.5.2
- /*if( JOptionPane.showConfirmDialog(appFrame,
+ /*
+ if (JOptionPane.showConfirmDialog(appFrame,
"Do you wish to merge tile images, and create a new tile set?",
"Merge Tiles?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION ) {
TileMergeHelper tmh = new TileMergeHelper(currentMap);
@@ -824,7 +825,8 @@
currentMap.removeAllLayers();
currentMap.addLayer(newLayer);
currentMap.addTileset(tmh.getSet());
- } else {*/
+ } else {
+ */
while (currentMap.getTotalLayers() > 1) {
try {
currentMap.mergeLayerDown(
@@ -1130,7 +1132,7 @@
if (currentMap != null) {
JFileChooser ch = new JFileChooser(currentMap.getFilename());
MapReader[] readers = pluginLoader.getReaders();
- for(int i = 0; i < readers.length; i++) {
+ for (int i = 0; i < readers.length; i++) {
try {
ch.addChoosableFileFilter(new TiledFileFilter(
readers[i].getFilter(),
@@ -1776,6 +1778,13 @@
}
}
+ // Make sure that the file has an extension. If not, append .tmx
+ // NOTE: we can't know anything more than the filename has at least
+ // one '.' in it...
+ if (filename.lastIndexOf('.') == -1) {
+ filename = filename.concat(".tmx");
+ }
+
try {
// Check if file exists
File exist = new File(filename);
Modified: branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -41,14 +41,14 @@
public ShapeBrush(AbstractBrush sb) {
super(sb);
if (sb instanceof ShapeBrush) {
- shape = ((ShapeBrush)sb).shape;
- paintTile = ((ShapeBrush)sb).paintTile;
+ shape = ((ShapeBrush) sb).shape;
+ paintTile = ((ShapeBrush) sb).paintTile;
}
}
/**
* Makes this brush a circular brush.
- *
+ *
* @param rad the radius of the circular region
*/
public void makeCircleBrush(double rad) {
@@ -58,7 +58,7 @@
/**
* Makes this brush a rectangular brush.
- *
+ *
* @param r a Rectangle to use as the shape of the brush
*/
public void makeQuadBrush(Rectangle r) {
@@ -67,7 +67,6 @@
}
public void makePolygonBrush(Polygon p) {
-
}
public void setSize(int s) {
Modified: branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -50,6 +50,7 @@
tileset = set;
imageId = id;
imageOrientation = orientation;
+
init();
queryImages();
updateImageLabel();
@@ -66,7 +67,7 @@
JScrollPane sp = new JScrollPane();
sp.getViewport().setView(imageList);
sp.setPreferredSize(new Dimension(150, 150));
-
+
// image panel
JPanel image_panel = new JPanel();
image_panel.setLayout(new BoxLayout(image_panel, BoxLayout.Y_AXIS));
@@ -80,6 +81,7 @@
rotateCheck = new JCheckBox("Rotate",
(imageOrientation & 4) == 4);
rotateCheck.addActionListener(this);
+
image_panel.add(imageLabel);
image_panel.add(horizFlipCheck);
image_panel.add(vertFlipCheck);
@@ -113,7 +115,6 @@
public void queryImages() {
Vector listData = new Vector();
- int curSlot = 0;
int initialIndex = 0;
Enumeration ids = tileset.getImageIds();
@@ -176,7 +177,7 @@
updateEnabledState();
}
- int getImageId() {
+ public int getImageId() {
return imageId;
}
Modified: branches/bjorn/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -12,17 +12,22 @@
package tiled.mapeditor.dialogs;
-import java.awt.event.*;
-import java.awt.*;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import tiled.core.*;
-import tiled.mapeditor.util.*;
-import tiled.mapeditor.widget.*;
+import tiled.core.Map;
+import tiled.core.Tile;
import tiled.mapeditor.MapEditor;
+import tiled.mapeditor.util.TileSelectionEvent;
+import tiled.mapeditor.util.TileSelectionListener;
+import tiled.mapeditor.widget.TilePalettePanel;
public class TilePaletteDialog extends JDialog implements ActionListener,
TileSelectionListener, ListSelectionListener
Modified: branches/bjorn/src/tiled/mapeditor/selection/SelectionLayer.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/selection/SelectionLayer.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/mapeditor/selection/SelectionLayer.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -56,7 +56,7 @@
/**
* Returns the selected area.
- *
+ *
* @return the selected area
*/
public Area getSelectedArea() {
@@ -65,7 +65,7 @@
/**
* Returns the bounds of the selected area.
- *
+ *
* @return A Rectangle instance
* @see Area#getBounds()
*/
@@ -75,7 +75,7 @@
/**
* Adds the given area via a union
- *
+ *
* @param area The Area to union with the current selection
* @see Area#add(java.awt.geom.Area)
*/
@@ -83,7 +83,7 @@
selection.add(area);
fillRegion(selection, selTile);
}
-
+
/**
* Deselects the given area. This substracts the given area from the
* existing selected area.
@@ -95,19 +95,34 @@
selection.subtract(area);
}
+ /**
+ * Sets the selected area to the given Rectangle.
+ *
+ * @param region
+ */
public void selectRegion(Rectangle region) {
clearRegion(selection);
selection = new Area(region);
fillRegion(selection, selTile);
}
+ /**
+ * Selects only the given tile location (adds it to the selection
+ * if one exists)
+ *
+ * @param tx
+ * @param ty
+ */
public void select(int tx, int ty) {
setTileAt(tx, ty, selTile);
+
+ Area a = new Area(new Rectangle2D.Double(tx, ty, 1, 1));
+
if (selection == null) {
- selection = new Area(new Rectangle2D.Double(tx, ty, 1, 1));
+ selection = a;
} else {
if (!selection.contains(tx, ty)) {
- selection.add(new Area(new Rectangle2D.Double(tx, ty, 1, 1)));
+ selection.add(a);
}
}
}
@@ -123,7 +138,7 @@
/**
* Returns the highlight color.
- *
+ *
* @return A Color instance of the highlight color
*/
public Color getHighlightColor() {
Modified: branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/mapeditor/widget/BrushBrowser.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -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>
*/
Modified: branches/bjorn/src/tiled/util/TiledConfiguration.java
===================================================================
--- branches/bjorn/src/tiled/util/TiledConfiguration.java 2006-02-17 21:33:23 UTC (rev 582)
+++ branches/bjorn/src/tiled/util/TiledConfiguration.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -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>
*/
Modified: trunk/src/tiled/core/MultilayerPlane.java
===================================================================
--- trunk/src/tiled/core/MultilayerPlane.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/core/MultilayerPlane.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -263,6 +263,6 @@
* <code>false</code> otherwise
*/
public boolean inBounds(int x, int y) {
- return (x >= 0 && x <= widthInTiles) && (y >= 0 && y <= heightInTiles);
+ return x >= 0 && y >= 0 && x < widthInTiles && y < heightInTiles;
}
}
Modified: trunk/src/tiled/core/Sprite.java
===================================================================
--- trunk/src/tiled/core/Sprite.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/core/Sprite.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -19,9 +19,9 @@
public class Sprite {
private Vector keys;
- private int borderWidth=0,
- fpl=0,
- totalKeys=-1;
+ private int borderWidth = 0;
+ private int fpl = 0;
+ private int totalKeys = -1;
private float currentFrame=0;
private Rectangle frameSize;
@@ -29,7 +29,6 @@
public class KeyFrame
{
-
public static final int MASK_ANIMATION = 0x0000000F;
public static final int KEY_LOOP = 0x01;
@@ -128,7 +127,7 @@
keys = new Vector();
}
- public Sprite(Tile [] frames) {
+ public Sprite(Tile[] frames) {
setFrames(frames);
}
@@ -166,7 +165,7 @@
}
public void setCurrentFrame(float c) {
- if(c < 0) {
+ if (c < 0) {
switch(currentKey.flags & KeyFrame.MASK_ANIMATION) {
case KeyFrame.KEY_LOOP:
currentFrame = currentKey.getLastFrame();
@@ -184,7 +183,7 @@
currentFrame = 0;
break;
}
- } else if(c > currentKey.getLastFrame()) {
+ } else if (c > currentKey.getLastFrame()) {
switch(currentKey.flags & KeyFrame.MASK_ANIMATION) {
case KeyFrame.KEY_LOOP:
currentFrame = 0;
@@ -216,9 +215,9 @@
}
public int getTotalFrames() {
- int total=0;
+ int total = 0;
Iterator itr = keys.iterator();
- while(itr.hasNext()) {
+ while (itr.hasNext()) {
total += ((KeyFrame)itr.next()).getTotalFrames();
}
@@ -316,18 +315,18 @@
}
public void keyStepBack(int amt) {
- setCurrentFrame(currentFrame-amt);
+ setCurrentFrame(currentFrame-amt);
}
public void keyStepForward(int amt) {
- setCurrentFrame(currentFrame+amt);
+ setCurrentFrame(currentFrame+amt);
}
public KeyFrame getKey(String keyName) {
Iterator itr = keys.iterator();
- while(itr.hasNext()) {
+ while (itr.hasNext()) {
KeyFrame k = (KeyFrame) itr.next();
- if(k != null && k.equalsIgnoreCase(keyName)) {
+ if (k != null && k.equalsIgnoreCase(keyName)) {
return k;
}
}
@@ -343,7 +342,7 @@
}
public Rectangle getCurrentFrameRect() {
- int x=0, y=0;
+ int x = 0, y = 0;
if(frameSize.height>0 && frameSize.width>0) {
y=(((int)currentFrame)/fpl)*(frameSize.height+borderWidth);
@@ -361,7 +360,5 @@
s = "Frame: ("+frameSize.width+"x"+frameSize.height+")\nBorder: "+borderWidth+"\nFPL: "+fpl+"\nTotal Frames: "+getTotalFrames()+"\nTotal keys: "+totalKeys;
return s;
}
-
-
}
Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/core/TileSet.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -671,5 +671,4 @@
return true;
}
-
}
Modified: trunk/src/tiled/io/MapWriter.java
===================================================================
--- trunk/src/tiled/io/MapWriter.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/io/MapWriter.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -23,7 +23,7 @@
* can have any format, as long as the MapWriter implementor accepts
* instances of tiled.core.Map and tiled.core.TileSet.
*/
-public interface MapWriter extends PluggableMapIO, FileFilter
+public interface MapWriter extends PluggableMapIO, FileFilter
{
/**
* Saves a map to a file.
Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -240,7 +240,6 @@
//builder.setErrorHandler(new XMLErrorHandler());
tsDoc = builder.parse(in, ".");
-
String xmlPathSave = xmlPath;
if (filename.indexOf(File.separatorChar) >= 0) {
xmlPath = filename.substring(0,
Modified: trunk/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapWriter.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/io/xml/XMLMapWriter.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -415,9 +415,8 @@
e.printStackTrace();
}
}
-
+
private static void writeTile(Tile tile, XMLWriter w) throws IOException {
-
try {
w.startElement("tile");
Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/MapEditor.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -30,17 +30,7 @@
import tiled.core.*;
import tiled.view.*;
import tiled.mapeditor.brush.*;
-import tiled.mapeditor.dialogs.AboutDialog;
-import tiled.mapeditor.dialogs.BrushDialog;
-import tiled.mapeditor.dialogs.ConfigurationDialog;
-import tiled.mapeditor.dialogs.NewMapDialog;
-import tiled.mapeditor.dialogs.NewTilesetDialog;
-import tiled.mapeditor.dialogs.PluginDialog;
-import tiled.mapeditor.dialogs.PropertiesDialog;
-import tiled.mapeditor.dialogs.ResizeDialog;
-import tiled.mapeditor.dialogs.SearchDialog;
-import tiled.mapeditor.dialogs.TilePaletteDialog;
-import tiled.mapeditor.dialogs.TilesetManager;
+import tiled.mapeditor.dialogs.*;
import tiled.mapeditor.plugin.PluginClassLoader;
import tiled.mapeditor.selection.SelectionLayer;
import tiled.mapeditor.util.*;
@@ -55,6 +45,8 @@
/**
* The main class for the Tiled Map Editor.
+ *
+ * @version $Id$
*/
public class MapEditor implements ActionListener, MouseListener,
MouseMotionListener, MapChangeListener, ListSelectionListener,
@@ -837,7 +829,7 @@
}
}
} else if (command.equals("Merge All")) {
- if( JOptionPane.showConfirmDialog(appFrame,
+ if (JOptionPane.showConfirmDialog(appFrame,
"Do you wish to merge tile images, and create a new tile set?",
"Merge Tiles?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION ) {
TileMergeHelper tmh = new TileMergeHelper(currentMap);
@@ -1663,7 +1655,7 @@
Tile newTile, Tile oldTile) {
if (newTile == oldTile || layer.getLocked()) return;
- Rectangle area = null;
+ Rectangle area;
TileLayer before = new TileLayer(layer);
TileLayer after;
@@ -1838,7 +1830,7 @@
// Make sure that the file has an extension. If not, append .tmx
// NOTE: we can't know anything more than the filename has at least
// one '.' in it...
- if(filename.lastIndexOf('.') == -1) {
+ if (filename.lastIndexOf('.') == -1) {
filename = filename.concat(".tmx");
}
Modified: trunk/src/tiled/mapeditor/brush/ShapeBrush.java
===================================================================
--- trunk/src/tiled/mapeditor/brush/ShapeBrush.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/brush/ShapeBrush.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -38,8 +38,8 @@
public ShapeBrush(AbstractBrush sb) {
super(sb);
if (sb instanceof ShapeBrush) {
- shape = ((ShapeBrush)sb).shape;
- paintTile = ((ShapeBrush)sb).paintTile;
+ shape = ((ShapeBrush) sb).shape;
+ paintTile = ((ShapeBrush) sb).paintTile;
}
}
Modified: trunk/src/tiled/mapeditor/dialogs/BrushDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/BrushDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/dialogs/BrushDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -29,7 +29,6 @@
import tiled.core.Tile;
import tiled.io.MapHelper;
import tiled.io.MapReader;
-import tiled.mapeditor.MapEditor;
import tiled.mapeditor.brush.*;
import tiled.mapeditor.plugin.PluginClassLoader;
import tiled.mapeditor.util.LayerTableModel;
@@ -38,6 +37,7 @@
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;
Modified: trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/dialogs/NewMapDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -20,7 +20,6 @@
import java.awt.event.ActionListener;
import java.util.prefs.Preferences;
import javax.swing.*;
-import java.io.*;
import tiled.core.Map;
import tiled.mapeditor.widget.IntegerSpinner;
@@ -48,7 +47,6 @@
}
private void init() {
-
// Load dialog defaults
int defaultMapWidth = prefs.getInt("mapWidth", 64);
Modified: trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -40,7 +40,7 @@
*/
public class NewTilesetDialog extends JDialog implements ChangeListener
{
- private Map map;
+ private final Map map;
private TileSet newTileset;
private IntegerSpinner tileWidth, tileHeight;
private IntegerSpinner tileSpacing;
@@ -183,6 +183,7 @@
tilebmpPanel.add(cutterLabel, c);
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);
Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -512,7 +512,7 @@
if (answer == JOptionPane.YES_OPTION) {
Enumeration ids = tileset.getImageIds();
- while(ids.hasMoreElements()) {
+ while (ids.hasMoreElements()) {
int id = Integer.parseInt((String)ids.nextElement());
boolean image_used = false;
Iterator tileIterator = tileset.iterator();
Modified: trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -12,19 +12,23 @@
package tiled.mapeditor.dialogs;
-import java.awt.event.*;
-import java.awt.*;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import tiled.core.*;
+import tiled.core.Map;
+import tiled.core.Tile;
import tiled.mapeditor.MapEditor;
-import tiled.mapeditor.util.*;
-import tiled.mapeditor.widget.*;
+import tiled.mapeditor.util.TileSelectionEvent;
+import tiled.mapeditor.util.TileSelectionListener;
+import tiled.mapeditor.widget.TilePalettePanel;
-
public class TilePaletteDialog extends JDialog implements ActionListener,
TileSelectionListener, ListSelectionListener
{
Modified: trunk/src/tiled/mapeditor/dialogs/TilesetManager.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TilesetManager.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/dialogs/TilesetManager.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -29,7 +29,6 @@
import tiled.mapeditor.plugin.PluginClassLoader;
import tiled.mapeditor.Resources;
-
public class TilesetManager extends JDialog implements ActionListener,
ListSelectionListener
{
@@ -75,12 +74,15 @@
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridy = 0;
- c.gridwidth = 7; c.gridheight = 1;
- c.weightx = 1; c.weighty = 1;
+ c.gridwidth = 7;
+ c.gridheight = 1;
+ c.weightx = 1;
+ c.weighty = 1;
mainPanel.add(tilesetScrollPane, c);
c.insets = new Insets(5, 0, 0, 5);
c.gridy = 1;
- c.weighty = 0; c.weightx = 0;
+ c.weighty = 0;
+ c.weightx = 0;
c.gridwidth = 1;
mainPanel.add(saveButton, c);
mainPanel.add(saveAsButton, c);
Modified: trunk/src/tiled/mapeditor/plugin/PluginClassLoader.java
===================================================================
--- trunk/src/tiled/mapeditor/plugin/PluginClassLoader.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/plugin/PluginClassLoader.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -174,19 +174,11 @@
}
public MapReader[] getReaders() {
- MapReader[] result = new MapReader[readers.size()];
- for (int i = 0; i < readers.size(); ++i) {
- result[i] = (MapReader)(readers.elementAt(i));
- }
- return result;
+ return (MapReader[])readers.toArray(new MapReader[readers.size()]);
}
public MapWriter[] getWriters() {
- MapWriter[] result = new MapWriter[writers.size()];
- for (int i = 0; i < writers.size(); ++i) {
- result[i] = (MapWriter)(writers.elementAt(i));
- }
- return result;
+ return (MapWriter[])writers.toArray(new MapWriter[writers.size()]);
}
public Object getReaderFor(String file) throws Exception {
Modified: trunk/src/tiled/mapeditor/selection/SelectionLayer.java
===================================================================
--- trunk/src/tiled/mapeditor/selection/SelectionLayer.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/mapeditor/selection/SelectionLayer.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -96,7 +96,7 @@
}
/**
- * Sets the selected area to the given Rectangle
+ * Sets the selected area to the given Rectangle.
*
* @param region
*/
Modified: trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java
===================================================================
--- trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java 2006-02-17 21:33:23 UTC (rev 582)
+++ trunk/src/tiled/plugins/tmw/TMWServerMapWriter.java 2006-02-17 23:18:32 UTC (rev 583)
@@ -13,12 +13,9 @@
package tiled.plugins.tmw;
import java.io.*;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.Stack;
import tiled.io.MapWriter;
-import tiled.plugins.mappy.MappyMapReader.BlkStr;
import tiled.core.*;
/**
More information about the tiled-commit
mailing list