[tiled] r571 - in trunk/tiled: core io io/xml mapeditor mapeditor/brush mapeditor/dialogs mapeditor/util util view
svn@biggeruniverse.com
svn at biggeruniverse.com
Thu Feb 9 16:43:12 PST 2006
Author: bjorn
Date: 2006-02-09 18:43:11 -0600 (Thu, 09 Feb 2006)
New Revision: 571
Modified:
trunk/tiled/core/Map.java
trunk/tiled/io/ImageHelper.java
trunk/tiled/io/MapHelper.java
trunk/tiled/io/xml/XMLMapTransformer.java
trunk/tiled/io/xml/XMLMapWriter.java
trunk/tiled/io/xml/XMLWriter.java
trunk/tiled/mapeditor/MapEditor.java
trunk/tiled/mapeditor/brush/Brush.java
trunk/tiled/mapeditor/brush/CustomBrush.java
trunk/tiled/mapeditor/brush/RandomBrush.java
trunk/tiled/mapeditor/brush/ShapeBrush.java
trunk/tiled/mapeditor/dialogs/AboutDialog.java
trunk/tiled/mapeditor/dialogs/BrushDialog.java
trunk/tiled/mapeditor/dialogs/ConfigurationDialog.java
trunk/tiled/mapeditor/dialogs/ImageColorDialog.java
trunk/tiled/mapeditor/dialogs/NewMapDialog.java
trunk/tiled/mapeditor/dialogs/NewTilesetDialog.java
trunk/tiled/mapeditor/dialogs/PluginDialog.java
trunk/tiled/mapeditor/dialogs/PropertiesDialog.java
trunk/tiled/mapeditor/dialogs/ResizeDialog.java
trunk/tiled/mapeditor/dialogs/SearchDialog.java
trunk/tiled/mapeditor/dialogs/TileImageDialog.java
trunk/tiled/mapeditor/dialogs/TilePaletteDialog.java
trunk/tiled/mapeditor/dialogs/TilesetManager.java
trunk/tiled/mapeditor/util/LayerTableModel.java
trunk/tiled/mapeditor/util/TiledFileFilter.java
trunk/tiled/util/Base64.java
trunk/tiled/util/MersenneTwister.java
trunk/tiled/util/TileMergeHelper.java
trunk/tiled/util/TiledConfiguration.java
trunk/tiled/view/HexMapView.java
trunk/tiled/view/MapView.java
Log:
Merged most of the changes made in my branch last week to trunk.
Modified: trunk/tiled/core/Map.java
===================================================================
--- trunk/tiled/core/Map.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/core/Map.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -23,18 +23,20 @@
* The Map class is the focal point of the <code>tiled.core</code> package.
* This class also handles notifing listeners if there is a change to any layer
* or object contained by the map.
+ *
+ * @version $Id$
*/
public class Map extends MultilayerPlane
{
- /** orthogonal */
+ /** Orthogonal. */
public static final int MDO_ORTHO = 1;
- /** isometric */
+ /** Isometric. */
public static final int MDO_ISO = 2;
- /** oblique */
+ /** Oblique. */
public static final int MDO_OBLIQUE = 3;
- /** hexagonal */
+ /** Hexagonal. */
public static final int MDO_HEX = 4;
- /** shifted (used for iso and hex) */
+ /** Shifted (used for iso and hex). */
public static final int MDO_SHIFTED = 5;
private Vector specialLayers;
@@ -465,7 +467,4 @@
getTotalLayers() + "][" + tileWidth + "x" +
tileHeight + "]";
}
-
- /**
- */
}
Modified: trunk/tiled/io/ImageHelper.java
===================================================================
--- trunk/tiled/io/ImageHelper.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/io/ImageHelper.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -16,13 +16,17 @@
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
-import java.awt.image.*;
-import java.io.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.File;
import javax.imageio.ImageIO;
/**
* This class provides functions to help out with saving/loading images.
+ *
+ * @version $Id$
*/
public class ImageHelper
{
@@ -53,15 +57,15 @@
/**
* 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)
*/
static public Image bytesToImage(byte[] imageData) {
- Image img = Toolkit.getDefaultToolkit().createImage(imageData);
-
- MediaTracker mediaTracker = new MediaTracker(new Canvas());
+ Image img = Toolkit.getDefaultToolkit().createImage(imageData);
+
+ MediaTracker mediaTracker = new MediaTracker(new Canvas());
mediaTracker.addImage(img, 0);
try {
mediaTracker.waitForID(0);
@@ -69,20 +73,19 @@
catch (InterruptedException ie) {
}
mediaTracker.removeImage(img);
-
+
return img;
}
-
+
/**
* 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
*/
static public Image loadImageFile(File file) throws IOException {
- BufferedImage buffer = ImageIO.read(file);
- return buffer;
+ return ImageIO.read(file);
}
}
Modified: trunk/tiled/io/MapHelper.java
===================================================================
--- trunk/tiled/io/MapHelper.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/io/MapHelper.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -56,7 +56,7 @@
public static void saveMap(Map currentMap, String filename)
throws Exception
{
- MapWriter mw = null;
+ MapWriter mw;
if (filename.endsWith("tmx") || filename.endsWith("tmx.gz")) {
// Override, so people can't overtake our format
mw = new XMLMapWriter();
@@ -88,7 +88,7 @@
public static void saveTileset(TileSet set, String filename)
throws Exception
{
- MapWriter mw = null;
+ MapWriter mw;
if (filename.endsWith(".tsx")) {
// Override, so people can't overtake our format
mw = new XMLMapWriter();
@@ -120,7 +120,7 @@
public static Map loadMap(String file) throws Exception {
Map ret = null;
try {
- MapReader mr = null;
+ MapReader mr;
if (file.endsWith(".tmx") || file.endsWith(".tmx.gz")) {
// Override, so people can't overtake our format
mr = new XMLMapTransformer();
@@ -170,7 +170,7 @@
public static TileSet loadTileset(String file) throws Exception {
TileSet ret = null;
try {
- MapReader mr = null;
+ MapReader mr;
if (file.endsWith(".tsx")) {
// Override, so people can't overtake our format
mr = new XMLMapTransformer();
@@ -223,7 +223,7 @@
Iterator itr = s.iterator();
StringBuffer warnings = new StringBuffer();
while (itr.hasNext()) {
- warnings.append((String)itr.next() + "\n");
+ warnings.append(itr.next()).append("\n");
}
JOptionPane.showMessageDialog(null, warnings.toString(),
"Loading Messages",
Modified: trunk/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/tiled/io/xml/XMLMapTransformer.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/io/xml/XMLMapTransformer.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -39,7 +39,9 @@
import tiled.mapeditor.util.cutter.BasicTileCutter;
import tiled.util.*;
-
+/**
+ * @version $Id$
+ */
public class XMLMapTransformer implements MapReader
{
private Map map = null;
@@ -51,7 +53,7 @@
}
private String makeUrl(String filename) throws MalformedURLException {
- String url = "";
+ final String url;
if (filename.indexOf("://") > 0 || filename.startsWith("file:")) {
url = filename;
} else {
@@ -88,7 +90,7 @@
} else if (parameterTypes[i].getName().endsWith("String")) {
conformingArguments[i] = args[i];
} else if (parameterTypes[i].getName().equalsIgnoreCase("boolean")) {
- conformingArguments[i] = new Boolean(args[i]);
+ conformingArguments[i] = Boolean.valueOf(args[i]);
} else {
warnings.push("INFO: Unsupported argument type " +
parameterTypes[i].getName() +
@@ -184,7 +186,7 @@
Image img = null;
String source = getAttributeValue(t, "source");
-
+
if (source != null) {
if (Util.checkRoot(source)) {
source = makeUrl(source);
@@ -221,7 +223,7 @@
}
}
*/
-
+
return img;
}
@@ -237,34 +239,34 @@
DocumentBuilder builder = factory.newDocumentBuilder();
//builder.setErrorHandler(new XMLErrorHandler());
tsDoc = builder.parse(in, ".");
-
- String xmlPathSave = xmlPath;
- if (filename.indexOf(File.separatorChar) >= 0) {
- xmlPath = filename.substring(0,
- filename.lastIndexOf(File.separatorChar) + 1);
- }
-
- NodeList tsNodeList = tsDoc.getElementsByTagName("tileset");
-
- for (int itr = 0; (tsNode = tsNodeList.item(itr)) != null; itr++) {
- set = unmarshalTileset(tsNode);
- if (set.getSource() != null) {
- warnings.push(
- "WARN: Recursive external Tilesets are not supported.");
- }
- set.setSource(filename);
- // NOTE: This is a deliberate break. multiple tilesets per TSX are
- // not supported yet (maybe never)...
- break;
- }
- xmlPath = xmlPathSave;
+ String xmlPathSave = xmlPath;
+ if (filename.indexOf(File.separatorChar) >= 0) {
+ xmlPath = filename.substring(0,
+ filename.lastIndexOf(File.separatorChar) + 1);
+ }
+
+ NodeList tsNodeList = tsDoc.getElementsByTagName("tileset");
+
+ for (int itr = 0; (tsNode = tsNodeList.item(itr)) != null; itr++) {
+ set = unmarshalTileset(tsNode);
+ if (set.getSource() != null) {
+ warnings.push(
+ "WARN: Recursive external Tilesets are not supported.");
+ }
+ set.setSource(filename);
+ // NOTE: This is a deliberate break. multiple tilesets per TSX are
+ // not supported yet (maybe never)...
+ break;
+ }
+
+ xmlPath = xmlPathSave;
} catch (SAXException e) {
- warnings.push("ERROR: Failed while loading "+filename+": "+e.getMessage());
- //e.printStackTrace();
+ warnings.push("ERROR: Failed while loading "+filename+": "+e.getMessage());
+ //e.printStackTrace();
}
-
+
return set;
}
@@ -284,15 +286,15 @@
//if (Util.checkRoot(source)) {
// filename = makeUrl(source);
//}
-
+
TileSet ext = null;
try {
- //just a little check for tricky people...
- if(!source.substring(source.lastIndexOf('.')+1).toLowerCase().equals("tsx")) {
- warnings.push("WARN: tileset files should end in .tsx! ("+source+")");
- }
-
+ //just a little check for tricky people...
+ if(!source.substring(source.lastIndexOf('.')+1).toLowerCase().equals("tsx")) {
+ warnings.push("WARN: tileset files should end in .tsx! ("+source+")");
+ }
+
InputStream in = new URL(makeUrl(filename)).openStream();
ext = unmarshalTilesetFile(in, filename);
} catch (FileNotFoundException fnf) {
@@ -300,11 +302,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;
}
@@ -356,26 +358,26 @@
Integer.parseInt(transStr, 16));
Toolkit tk = Toolkit.getDefaultToolkit();
try {
- Image orig = ImageIO.read(new File(sourcePath));
- Image trans = tk.createImage(
- new FilteredImageSource(orig.getSource(),
- new TransparentImageFilter(
- color.getRGB())));
- BufferedImage img = new BufferedImage(
- trans.getWidth(null),
- trans.getHeight(null),
- BufferedImage.TYPE_INT_ARGB);
-
- img.getGraphics().drawImage(trans, 0, 0, null);
-
- set.importTileBitmap(img, new BasicTileCutter(
- tileWidth, tileHeight, tileSpacing, 0),
- !hasTileElements);
-
- set.setTransparentColor(color);
- set.setTilesetImageFilename(sourcePath);
+ Image orig = ImageIO.read(new File(sourcePath));
+ Image trans = tk.createImage(
+ new FilteredImageSource(orig.getSource(),
+ new TransparentImageFilter(
+ color.getRGB())));
+ BufferedImage img = new BufferedImage(
+ trans.getWidth(null),
+ trans.getHeight(null),
+ BufferedImage.TYPE_INT_ARGB);
+
+ img.getGraphics().drawImage(trans, 0, 0, null);
+
+ set.importTileBitmap(img, new BasicTileCutter(
+ tileWidth, tileHeight, tileSpacing, 0),
+ !hasTileElements);
+
+ set.setTransparentColor(color);
+ set.setTilesetImageFilename(sourcePath);
} catch(IIOException iioe) {
- warnings.push("ERROR: "+iioe.getMessage()+" ("+sourcePath+")");
+ warnings.push("ERROR: "+iioe.getMessage()+" ("+sourcePath+")");
}
} else {
set.importTileBitmap(sourcePath, new BasicTileCutter(
@@ -420,28 +422,28 @@
Tile tile = null;
NodeList children = t.getChildNodes();
boolean isAnimated = false;
-
+
for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeName().equalsIgnoreCase("animation")) {
- isAnimated = true;
- break;
- }
+ Node child = children.item(i);
+ if (child.getNodeName().equalsIgnoreCase("animation")) {
+ isAnimated = true;
+ break;
+ }
}
-
+
try {
- if(isAnimated) {
- tile = (Tile)unmarshalClass(AnimatedTile.class, t);
- } else {
- tile = (Tile)unmarshalClass(Tile.class, t);
- }
+ if(isAnimated) {
+ tile = (Tile)unmarshalClass(AnimatedTile.class, t);
+ } else {
+ tile = (Tile)unmarshalClass(Tile.class, t);
+ }
} catch (Exception e) {
e.printStackTrace();
}
tile.setTileSet(set);
Properties tileProps = tile.getProperties();
-
+
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeName().equalsIgnoreCase("image")) {
@@ -469,10 +471,10 @@
tileProps.setProperty(getAttributeValue(child, "name"),
getAttributeValue(child, "value"));
} else if (child.getNodeName().equalsIgnoreCase("animation")) {
- //TODO: fill this in once XMLMapWriter is complete
+ //TODO: fill this in once XMLMapWriter is complete
}
}
-
+
return tile;
}
@@ -483,7 +485,7 @@
} catch (Exception e) {
e.printStackTrace();
}
-
+
//Read all objects from the group, "...and in the darkness bind them."
NodeList children = t.getChildNodes();
@@ -493,7 +495,7 @@
og.bindObject(unmarshalObject(child));
}
}
-
+
return og;
}
@@ -514,7 +516,7 @@
ml.setOffset(offsetX, offsetY);
ml.setName(getAttributeValue(t, "name"));
ml.setVisible(visible == 1);
-
+
if (opacity != null) {
ml.setOpacity(Float.parseFloat(opacity));
}
@@ -701,7 +703,7 @@
public Map readMap(String filename) throws Exception {
xmlPath = filename.substring(0,
filename.lastIndexOf(File.separatorChar) + 1);
-
+
String xmlFile = makeUrl(filename);
//xmlPath = makeUrl(xmlPath);
@@ -715,26 +717,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);
@@ -746,7 +748,7 @@
// TODO: The MapReader interface should be changed...
return unmarshalTilesetFile(in, ".");
}
-
+
/**
* @see tiled.io.MapReader#getFilter()
*/
@@ -757,7 +759,7 @@
public String getPluginPackage() {
return "Tiled internal TMX reader/writer";
}
-
+
/**
* @see tiled.io.PluggableMapIO#getDescription()
*/
@@ -783,7 +785,7 @@
} catch (IOException e) {}
return false;
}
-
+
public void setErrorStack(Stack es) {
warnings = es;
}
Modified: trunk/tiled/io/xml/XMLMapWriter.java
===================================================================
--- trunk/tiled/io/xml/XMLMapWriter.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/io/xml/XMLMapWriter.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -28,7 +28,9 @@
import tiled.mapeditor.selection.SelectionLayer;
import tiled.util.*;
-
+/**
+ * @version $Id$
+ */
public class XMLMapWriter implements MapWriter
{
/**
@@ -52,7 +54,7 @@
writer.flush();
- if (filename.endsWith(".tmx.gz")) {
+ if (os instanceof GZIPOutputStream) {
((GZIPOutputStream)os).finish();
}
}
@@ -239,10 +241,10 @@
} else if (conf.keyHasValue("tmx.save.embedImages", "0")) {
String imgSource = conf.getValue(
"tmx.save.tileImagePrefix") + "set.png";
-
+
w.startElement("image");
w.writeAttribute("source", imgSource);
-
+
String tilesetFilename = (wp.substring(0,
wp.lastIndexOf(File.separatorChar) + 1)
+ imgSource);
@@ -251,10 +253,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
Iterator tileIterator = set.iterator();
boolean needWrite = !set.isOneForOne();
@@ -451,7 +453,7 @@
w.startElement("image");
w.writeAttribute("id", "" + tile.getImageId());
int orientation = tile.getImageOrientation();
- int rotation = 0;
+ int rotation;
boolean flipped =
(orientation & 1) == ((orientation & 2) >> 1);
if ((orientation & 4) == 4) {
@@ -477,11 +479,11 @@
w.endElement();
}
}
-
- if(tile instanceof AnimatedTile) {
- writeAnimation(((AnimatedTile)tile).getSprite(), w);
+
+ if (tile instanceof AnimatedTile) {
+ writeAnimation(((AnimatedTile)tile).getSprite(), w);
}
-
+
w.endElement();
} catch (XMLWriterException e) {
e.printStackTrace();
Modified: trunk/tiled/io/xml/XMLWriter.java
===================================================================
--- trunk/tiled/io/xml/XMLWriter.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/io/xml/XMLWriter.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -21,15 +21,17 @@
/**
* A simple helper class to write an XML file, based on
* http://www.xmlsoft.org/html/libxml-xmlwriter.html
+ *
+ * @version $Id$
*/
public class XMLWriter
{
private boolean bIndent = true;
private String indentString = " ";
private String newLine = "\n";
- private Writer w;
+ private final Writer w;
- private Stack openElements;
+ private final Stack openElements;
private boolean bStartTagOpen = false;
private boolean bDocumentOpen = false;
@@ -77,7 +79,7 @@
bStartTagOpen = true;
}
-
+
public void endDocument() throws IOException {
// End all open elements.
while (openElements.size() > 0) {
Modified: trunk/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/tiled/mapeditor/MapEditor.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/MapEditor.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -61,14 +61,14 @@
ListSelectionListener, ChangeListener, ComponentListener
{
// Constants and the like
- protected static final int PS_POINT = 0;
- protected static final int PS_PAINT = 1;
- protected static final int PS_ERASE = 2;
- protected static final int PS_POUR = 3;
- protected static final int PS_EYED = 4;
- protected static final int PS_MARQUEE = 5;
- protected static final int PS_MOVE = 6;
- protected static final int PS_MOVEOBJ = 7;
+ private static final int PS_POINT = 0;
+ private static final int PS_PAINT = 1;
+ private static final int PS_ERASE = 2;
+ private static final int PS_POUR = 3;
+ private static final int PS_EYED = 4;
+ private static final int PS_MARQUEE = 5;
+ private static final int PS_MOVE = 6;
+ private static final int PS_MOVEOBJ = 7;
private Cursor curDefault = null;
private Cursor curPaint = null;
@@ -82,11 +82,11 @@
private Map currentMap;
private MapView mapView;
- private UndoStack undoStack;
- private UndoableEditSupport undoSupport;
- private MapEventAdapter mapEventAdapter;
- private PluginClassLoader pluginLoader;
- private TiledConfiguration configuration;
+ private final UndoStack undoStack;
+ private final UndoableEditSupport undoSupport;
+ private final MapEventAdapter mapEventAdapter;
+ private final PluginClassLoader pluginLoader;
+ private final TiledConfiguration configuration;
int currentPointerState;
@@ -144,12 +144,12 @@
Brush eraserBrush;
// Actions
- Action zoomInAction, zoomOutAction, zoomNormalAction;
- Action undoAction, redoAction;
- Action rot90Action, rot180Action, rot270Action;
- Action flipHorAction, flipVerAction;
- Action copyAction, cutAction, pasteAction;
- Action selectAllAction, inverseAction, cancelSelectionAction;
+ final Action zoomInAction, zoomOutAction, zoomNormalAction;
+ final Action undoAction, redoAction;
+ final Action rot90Action, rot180Action, rot270Action;
+ final Action flipHorAction, flipVerAction;
+ final Action copyAction, cutAction, pasteAction;
+ final Action selectAllAction, inverseAction, cancelSelectionAction;
public MapEditor() {
// Get instance of configuration
@@ -243,6 +243,7 @@
mapScrollPane = new JScrollPane(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+ mapScrollPane.setBorder(null);
createToolbox();
createData();
@@ -1377,7 +1378,7 @@
}
private class LayerTransformAction extends AbstractAction {
- private int transform;
+ private final int transform;
public LayerTransformAction(int transform) {
this.transform = transform;
switch (transform) {
Modified: trunk/tiled/mapeditor/brush/Brush.java
===================================================================
--- trunk/tiled/mapeditor/brush/Brush.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/brush/Brush.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -74,7 +74,7 @@
* @param y The y-coord to draw the preview at
*/
public void drawPreview(Graphics2D g2d, int x, int y, MapView mv);
-
+
/**
* Draws a preview of the editing operation when applicable.
*
Modified: trunk/tiled/mapeditor/brush/CustomBrush.java
===================================================================
--- trunk/tiled/mapeditor/brush/CustomBrush.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/brush/CustomBrush.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -20,6 +20,9 @@
import tiled.core.TileLayer;
import tiled.view.MapView;
+/**
+ * @version $Id$
+ */
public class CustomBrush extends AbstractBrush
{
public CustomBrush() {
@@ -44,18 +47,17 @@
*/
public boolean equals(Brush b) {
if (b instanceof CustomBrush) {
- if(b == this) return true;
- else {
- //TODO: THIS
- }
+ if(b == this) return true;
+ else {
+ //TODO: THIS
+ }
}
return false;
}
- public void startPaint(MultilayerPlane mp, int x, int y, int button, int layer) {
- super.startPaint(mp, x, y, button, layer);
-
- }
+ public void startPaint(MultilayerPlane mp, int x, int y, int button, int layer) {
+ super.startPaint(mp, x, y, button, layer);
+ }
/**
* The custom brush will merge its internal layers onto the layers of the
@@ -67,13 +69,13 @@
*/
public Rectangle doPaint(int x, int y) throws Exception
{
- int layer = initLayer;
+ int layer = initLayer;
Rectangle bounds = getBounds();
- int centerx = (int)(x - (bounds.width / 2));
- int centery = (int)(y - (bounds.height / 2));
+ int centerx = x - (bounds.width / 2);
+ int centery = y - (bounds.height / 2);
super.doPaint(x, y);
-
+
ListIterator itr = getLayers();
while (itr.hasNext()) {
TileLayer tl = (TileLayer)itr.next();
@@ -86,8 +88,8 @@
return new Rectangle(centerx, centery, bounds.width, bounds.height);
}
-
- public void drawPreview(Graphics2D g2d, MapView mv) {
- mv.paintSubMap(this, g2d, 0.5f);
- }
+
+ public void drawPreview(Graphics2D g2d, MapView mv) {
+ mv.paintSubMap(this, g2d, 0.5f);
+ }
}
Modified: trunk/tiled/mapeditor/brush/RandomBrush.java
===================================================================
--- trunk/tiled/mapeditor/brush/RandomBrush.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/brush/RandomBrush.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -19,9 +19,12 @@
import tiled.core.TileLayer;
import tiled.util.MersenneTwister;
+/**
+ * @version $Id$
+ */
public class RandomBrush extends ShapeBrush
{
- private MersenneTwister mt;
+ private final MersenneTwister mt;
private double ratio = 0.5;
public RandomBrush() {
@@ -66,8 +69,8 @@
int initLayer)
{
Rectangle bounds = shape.getBounds();
- int centerx = (int)(x - (bounds.width / 2));
- int centery = (int)(y - (bounds.height / 2));
+ int centerx = x - (bounds.width / 2);
+ int centery = y - (bounds.height / 2);
for (int i = 0; i < numLayers; i++) {
TileLayer tl = (TileLayer)mp.getLayer(initLayer - i);
Modified: trunk/tiled/mapeditor/brush/ShapeBrush.java
===================================================================
--- trunk/tiled/mapeditor/brush/ShapeBrush.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/brush/ShapeBrush.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -15,16 +15,19 @@
import java.awt.*;
import java.awt.geom.*;
-import tiled.core.*;
+import tiled.core.Tile;
+import tiled.core.TileLayer;
+import tiled.core.MultilayerPlane;
import tiled.view.MapView;
-
+/**
+ * @version $Id$
+ */
public class ShapeBrush extends AbstractBrush
{
protected Area shape;
protected Tile paintTile;
-
-
+
public ShapeBrush() {
super();
}
@@ -54,7 +57,7 @@
/**
* Makes this brush a rectangular brush.
- *
+ *
* @param r a Rectangle to use as the shape of the brush
*/
public void makeQuadBrush(Rectangle r) {
@@ -90,9 +93,8 @@
public boolean isRectangular() {
return shape.isRectangular();
}
-
+
public void drawPreview(Graphics2D g2d, MapView mv) {
-
if (shape.isRectangular()) {
Rectangle bounds = shape.getBounds();
g2d.fillRect(sx, sy, bounds.width, bounds.height);
@@ -100,7 +102,6 @@
Rectangle bounds = shape.getBounds();
g2d.fillOval(sx, sy, bounds.width, bounds.height);
}
-
}
public boolean equals(Brush b) {
@@ -110,25 +111,25 @@
return false;
}
- public void startPaint(MultilayerPlane mp, int x, int y, int button, int layer) {
- super.startPaint(mp, x, y, button, layer);
- }
+ public void startPaint(MultilayerPlane mp, int x, int y, int button, int layer) {
+ super.startPaint(mp, x, y, button, layer);
+ }
- /**
+ /**
* Paints the entire area of the brush with the set tile. This brush can
- * affect several layers.
- * @throws Exception
- *
+ * affect several layers.
+ * @throws Exception
+ *
* @see tiled.mapeditor.brush.Brush#doPaint(int, int)
*/
public Rectangle doPaint(int x, int y) throws Exception
{
Rectangle bounds = shape.getBounds();
- int centerx = (int)(x - (bounds.width / 2));
- int centery = (int)(y - (bounds.height / 2));
+ int centerx = x - (bounds.width / 2);
+ int centery = y - (bounds.height / 2);
super.doPaint(x, y);
-
+
// FIXME: This loop does not take all edges into account
for(int l = 0; l < numLayers; l++) {
Modified: trunk/tiled/mapeditor/dialogs/AboutDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/AboutDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/AboutDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -21,10 +21,12 @@
/**
* The about dialog.
+ *
+ * @version $Id$
*/
public class AboutDialog extends JFrame
{
- JFrame parent;
+ final JFrame parent;
public AboutDialog(JFrame parent) {
super("Tiled v" + MapEditor.version);
Modified: trunk/tiled/mapeditor/dialogs/BrushDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/BrushDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/BrushDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -37,13 +37,15 @@
import tiled.mapeditor.widget.VerticalStaticJPanel;
import tiled.util.TiledConfiguration;
-
+/**
+ * @version $Id$
+ */
public class BrushDialog extends JDialog implements ActionListener,
ItemListener, ChangeListener, PropertyChangeListener,
ListSelectionListener
{
private AbstractBrush myBrush;
- private MapEditor editor;
+ private final MapEditor editor;
private JCheckBox cbRandomBrush;
private IntegerSpinner affectLayers, brushSize;
@@ -52,7 +54,7 @@
private BrushBrowser brushes;
private MiniMapViewer mmv;
private JTable layerTable;
-
+
public BrushDialog(MapEditor editor, JFrame parent,
AbstractBrush currentBrush)
{
@@ -140,12 +142,12 @@
private JPanel createCustomPanel() {
JPanel customPanel = new JPanel();
-
+
mmv = new MiniMapViewer();
if (myBrush instanceof CustomBrush) {
//mmv.setView(((CustomBrush)myBrush));
}
-
+
JScrollPane miniSp = new JScrollPane();
miniSp.getViewport().setView(mmv);
miniSp.setPreferredSize(new Dimension(100,100));
@@ -159,7 +161,7 @@
layerTable.getColumnModel().getColumn(0).setPreferredWidth(32);
layerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
layerTable.getSelectionModel().addListSelectionListener(this);
-
+
customPanel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.anchor = GridBagConstraints.NORTH;
@@ -173,7 +175,7 @@
customPanel.add(bLoad, c);
c.gridx=0; c.gridy=2;
customPanel.add(layerTable, c);
-
+
return customPanel;
}
@@ -192,7 +194,7 @@
JPanel buttons = new VerticalStaticJPanel();
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
buttons.add(Box.createGlue());
- buttons.add(bOk);
+ buttons.add(bOk);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(bApply);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
@@ -308,11 +310,11 @@
public void valueChanged(ListSelectionEvent e) {
// TODO Auto-generated method stub
}
-
+
private void openMap() throws Exception {
String startLocation = "";
TiledConfiguration configuration = TiledConfiguration.getInstance();
-
+
// Start at the location of the most recently loaded map file
if (configuration.hasOption("tiled.recent.1")) {
startLocation = configuration.getValue("tiled.recent.1");
@@ -337,7 +339,7 @@
ch.addChoosableFileFilter(
new TiledFileFilter(TiledFileFilter.FILTER_TMX));
-
+
int ret = ch.showOpenDialog(this);
if (ret == JFileChooser.APPROVE_OPTION) {
myBrush = new CustomBrush(
Modified: trunk/tiled/mapeditor/dialogs/ConfigurationDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/ConfigurationDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/ConfigurationDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -20,7 +20,8 @@
import javax.swing.event.ChangeEvent;
import tiled.util.TiledConfiguration;
-import tiled.mapeditor.widget.*;
+import tiled.mapeditor.widget.IntegerSpinner;
+import tiled.mapeditor.widget.VerticalStaticJPanel;
public class ConfigurationDialog extends JDialog implements ActionListener,
@@ -34,7 +35,7 @@
private JRadioButton rbEmbedInTiles, rbEmbedInSet;
private JCheckBox cbGridAA;
private JColorChooser gridColor;
- private TiledConfiguration configuration;
+ private final TiledConfiguration configuration;
public ConfigurationDialog(JFrame parent) {
super(parent, "Preferences", true);
@@ -120,7 +121,7 @@
c.gridy = 1;
c.gridx = 0;
generalOps.add(cbReportIOWarnings, c);
-
+
/* TILESET OPTIONS */
tilesetOps = new VerticalStaticJPanel();
tilesetOps.setLayout(new GridBagLayout());
@@ -135,7 +136,7 @@
tilesetOps.add(rbEmbedInTiles, c);
c.gridy = 2; c.insets = new Insets(0, 10, 0, 0);
tilesetOps.add(rbEmbedInSet, c);
-
+
/* GRID OPTIONS */
gridOps = new VerticalStaticJPanel();
gridOps.setLayout(new GridBagLayout());
@@ -156,7 +157,7 @@
JPanel buttons = new VerticalStaticJPanel();
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
buttons.add(Box.createGlue());
- buttons.add(bOk);
+ buttons.add(bOk);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
buttons.add(bApply);
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
@@ -168,7 +169,7 @@
saving.setLayout(new BoxLayout(saving, BoxLayout.Y_AXIS));
saving.add(layerOps);
saving.add(tilesetOps);
-
+
JPanel general = new JPanel();
general.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
general.setLayout(new BoxLayout(general, BoxLayout.Y_AXIS));
Modified: trunk/tiled/mapeditor/dialogs/ImageColorDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/ImageColorDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/ImageColorDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -12,101 +12,108 @@
package tiled.mapeditor.dialogs;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Image;
import java.awt.event.*;
import java.awt.image.PixelGrabber;
-
import javax.swing.*;
import tiled.mapeditor.widget.ImageViewPanel;
import tiled.mapeditor.widget.VerticalStaticJPanel;
+/**
+ * @version $Id$
+ */
+public class ImageColorDialog extends JDialog implements ActionListener,
+ MouseListener, MouseMotionListener
+{
+ private Image image;
+ private JButton bCancel;
+ private Color color;
+ private JPanel colorPanel;
+ private int pixels[];
-public class ImageColorDialog
- extends JDialog
- implements ActionListener, MouseListener, MouseMotionListener {
+ public ImageColorDialog() {
+ super();
+ }
- private Image image;
- private JButton bCancel;
- private Color color;
- private JPanel colorPanel;
- private int pixels[];
-
- public ImageColorDialog() {
- super();
- }
+ public ImageColorDialog(Image i) {
+ this();
+ image = i;
+ PixelGrabber pg = new PixelGrabber(i, 0, 0, -1, -1, true);
- public ImageColorDialog(Image i) {
- this();
- image = i;
- PixelGrabber pg = new PixelGrabber(i,0,0,-1,-1,true);
-
- try {
- pg.grabPixels();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- pixels = (int[])pg.getPixels();
-
- init();
- pack();
- setLocationRelativeTo(getOwner());
- setModal(true);
- }
+ try {
+ pg.grabPixels();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ pixels = (int[]) pg.getPixels();
+
+ init();
+ pack();
+ setLocationRelativeTo(getOwner());
+ setModal(true);
+ }
+
private void init() {
- ImageViewPanel imagePanel = new ImageViewPanel(image);
- imagePanel.addMouseListener(this);
- imagePanel.addMouseMotionListener(this);
-
- setTitle("Color Chooser");
-
- color = new Color(255, 103, 139); //Evil pink
- colorPanel = new JPanel();
- colorPanel.setPreferredSize(new Dimension(25, 25));
- colorPanel.setBackground(color);
-
- bCancel = new JButton("Cancel");
- bCancel.addActionListener(this);
-
- JScrollPane imageScrollPane = new JScrollPane(imagePanel);
- imageScrollPane.setAutoscrolls(true);
-
- VerticalStaticJPanel mainPanel = new VerticalStaticJPanel();
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
-
- mainPanel.add(imageScrollPane);
-
- JPanel buttonPanel = new JPanel(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.gridx = 0; c.gridy = 0; c.weightx = 1;
- c.fill = GridBagConstraints.HORIZONTAL;
- buttonPanel.add(colorPanel);
- c.gridx = 1;
- buttonPanel.add(Box.createRigidArea(new Dimension(25, 5)));
- c.gridx = 2;
- buttonPanel.add(bCancel);
-
- mainPanel.add(buttonPanel);
-
- setContentPane(mainPanel);
+ ImageViewPanel imagePanel = new ImageViewPanel(image);
+ imagePanel.addMouseListener(this);
+ imagePanel.addMouseMotionListener(this);
+
+ setTitle("Color Chooser");
+
+ color = new Color(255, 103, 139); //Evil pink
+ colorPanel = new JPanel();
+ colorPanel.setPreferredSize(new Dimension(25, 25));
+ colorPanel.setBackground(color);
+
+ bCancel = new JButton("Cancel");
+ bCancel.addActionListener(this);
+
+ JScrollPane imageScrollPane = new JScrollPane(imagePanel);
+ imageScrollPane.setAutoscrolls(true);
+
+ VerticalStaticJPanel mainPanel = new VerticalStaticJPanel();
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+
+ mainPanel.add(imageScrollPane);
+
+ JPanel buttonPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = 0;
+ c.gridy = 0;
+ c.weightx = 1;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ buttonPanel.add(colorPanel);
+ c.gridx = 1;
+ buttonPanel.add(Box.createRigidArea(new Dimension(25, 5)));
+ c.gridx = 2;
+ buttonPanel.add(bCancel);
+
+ mainPanel.add(buttonPanel);
+
+ setContentPane(mainPanel);
}
-
+
public Color showDialog() {
- setVisible(true);
- return color;
+ setVisible(true);
+ return color;
}
-
+
public void actionPerformed(ActionEvent e) {
- if(e.getSource() == bCancel) {
- color = null;
- dispose();
+ if (e.getSource() == bCancel) {
+ color = null;
+ dispose();
}
}
public void mouseClicked(MouseEvent e) {
- grabColor(e.getX(), e.getY());
+ grabColor(e.getX(), e.getY());
dispose();
}
@@ -117,7 +124,7 @@
}
public void mouseEntered(MouseEvent e) {
- }
+ }
public void mouseExited(MouseEvent e) {
}
@@ -130,16 +137,16 @@
grabColor(e.getX(), e.getY());
}
- private void grabColor(int x, int y) {
- int w = image.getWidth(null);
- int h = image.getHeight(null);
- if(pixels != null && (x < w && y < h)) {
- int r = (pixels[y * w + x] >> 16) & 0xff;
- int g = (pixels[y * w + x] >> 8) & 0xff;
- int b = (pixels[y * w + x] ) & 0xff;
-
- color = new Color(r,g,b);
- colorPanel.setBackground(color);
- }
- }
+ private void grabColor(int x, int y) {
+ int w = image.getWidth(null);
+ int h = image.getHeight(null);
+ if (pixels != null && (x < w && y < h)) {
+ int r = (pixels[y * w + x] >> 16) & 0xff;
+ int g = (pixels[y * w + x] >> 8) & 0xff;
+ int b = (pixels[y * w + x]) & 0xff;
+
+ color = new Color(r, g, b);
+ colorPanel.setBackground(color);
+ }
+ }
}
Modified: trunk/tiled/mapeditor/dialogs/NewMapDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/NewMapDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/NewMapDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -18,8 +18,9 @@
import java.io.*;
import tiled.core.*;
-import tiled.mapeditor.widget.*;
-import tiled.util.*;
+import tiled.util.TiledConfiguration;
+import tiled.mapeditor.widget.IntegerSpinner;
+import tiled.mapeditor.widget.VerticalStaticJPanel;
public class NewMapDialog extends JDialog implements ActionListener
{
@@ -38,16 +39,16 @@
private void init() {
- // Load dialog defaults
+ // Load dialog defaults
- TiledConfiguration conf = TiledConfiguration.getInstance();
+ TiledConfiguration conf = TiledConfiguration.getInstance();
- int defaultMapWidth = conf.getIntValue("tiled.newmapdialog.mapwidth", 64);
- int defaultMapHeight = conf.getIntValue("tiled.newmapdialog.mapheight", 64);
- int defaultTileWidth = conf.getIntValue("tiled.newmapdialog.tilewidth", 35);
- int defaultTileHeight = conf.getIntValue("tiled.newmapdialog.tileheight", 35);
+ int defaultMapWidth = conf.getIntValue("tiled.newmapdialog.mapwidth", 64);
+ int defaultMapHeight = conf.getIntValue("tiled.newmapdialog.mapheight", 64);
+ int defaultTileWidth = conf.getIntValue("tiled.newmapdialog.tilewidth", 35);
+ int defaultTileHeight = conf.getIntValue("tiled.newmapdialog.tileheight", 35);
- // Create the primitives
+ // Create the primitives
mapWidth = new IntegerSpinner(defaultMapWidth, 1);
mapHeight = new IntegerSpinner(defaultMapHeight, 1);
@@ -179,22 +180,16 @@
newMap.setTileHeight(theight);
newMap.setOrientation(orientation);
- // save dialog options
+ // Save dialog options
- TiledConfiguration conf = TiledConfiguration.getInstance();
+ TiledConfiguration conf = TiledConfiguration.getInstance();
+ conf.addConfigPair("tiled.newmapdialog.mapwidth", Integer.toString(mapWidth.intValue()));
+ conf.addConfigPair("tiled.newmapdialog.mapheight", Integer.toString(mapHeight.intValue()));
+ conf.addConfigPair("tiled.newmapdialog.tilewidth", Integer.toString(tileWidth.intValue()));
+ conf.addConfigPair("tiled.newmapdialog.tileheight", Integer.toString(tileHeight.intValue()));
- conf.addConfigPair("tiled.newmapdialog.mapwidth", Integer.toString(mapWidth.intValue()));
- conf.addConfigPair("tiled.newmapdialog.mapheight", Integer.toString(mapHeight.intValue()));
- conf.addConfigPair("tiled.newmapdialog.tilewidth", Integer.toString(tileWidth.intValue()));
- conf.addConfigPair("tiled.newmapdialog.tileheight", Integer.toString(tileHeight.intValue()));
-
- try { conf.write("tiled.conf"); }
- catch (IOException ex) {}
- catch (Exception ex) {}
-
- dispose();
- } else {
- dispose();
+ conf.flush();
}
+ dispose();
}
}
Modified: trunk/tiled/mapeditor/dialogs/NewTilesetDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -28,11 +28,15 @@
import tiled.mapeditor.util.cutter.BasicTileCutter;
import tiled.mapeditor.util.cutter.BorderTileCutter;
import tiled.mapeditor.util.cutter.TileCutter;
-import tiled.mapeditor.widget.*;
+import tiled.mapeditor.widget.IntegerSpinner;
+import tiled.mapeditor.widget.ColorButton;
+import tiled.mapeditor.widget.VerticalStaticJPanel;
/**
* A dialog for creating a new tileset.
+ *
+ * @version $Id$
*/
public class NewTilesetDialog extends JDialog implements ActionListener,
ChangeListener
@@ -93,7 +97,7 @@
tilebmpCheck.addChangeListener(this);
tileAutoCheck = new JCheckBox("Automatically create tiles from images",
- true);
+ true);
tileAutoCheck.setEnabled(false);
transCheck = new JCheckBox("Use transparent color");
@@ -277,8 +281,8 @@
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this,
- e.getMessage(), "Error while importing tileset",
- JOptionPane.ERROR_MESSAGE);
+ e.getMessage(), "Error while importing tileset",
+ JOptionPane.ERROR_MESSAGE);
newTileset = null;
}
}
@@ -303,9 +307,9 @@
}
} catch (IOException e) {
JOptionPane.showMessageDialog(getOwner(),
- "Error while loading image: " + e.getMessage(),
- "Error while choosing color",
- JOptionPane.ERROR_MESSAGE);
+ "Error while loading image: " + e.getMessage(),
+ "Error while choosing color",
+ JOptionPane.ERROR_MESSAGE);
}
} else if (source == propsButton) {
Modified: trunk/tiled/mapeditor/dialogs/PluginDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/PluginDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/PluginDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -26,11 +26,13 @@
import tiled.mapeditor.plugin.PluginClassLoader;
import tiled.mapeditor.widget.VerticalStaticJPanel;
-
+/**
+ * @version $Id$
+ */
public class PluginDialog extends JDialog implements ActionListener,
ListSelectionListener
{
- private PluginClassLoader pluginLoader;
+ private final PluginClassLoader pluginLoader;
private JList pluginList = null;
private JButton closeButton, infoButton, removeButton;
Modified: trunk/tiled/mapeditor/dialogs/PropertiesDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/PropertiesDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/PropertiesDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -31,8 +31,8 @@
{
private JTable tProperties;
private JButton bOk, bCancel, bDel;
- private Properties properties;
- private PropertiesTableModel tableModel;
+ private final Properties properties;
+ private final PropertiesTableModel tableModel = new PropertiesTableModel();
public PropertiesDialog(JFrame parent, Properties p) {
super(parent, "Properties", true);
@@ -43,7 +43,6 @@
}
private void init() {
- tableModel = new PropertiesTableModel();
tProperties = new JTable(tableModel);
tProperties.getSelectionModel().addListSelectionListener(this);
JScrollPane propScrollPane = new JScrollPane(tProperties);
Modified: trunk/tiled/mapeditor/dialogs/ResizeDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/ResizeDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/ResizeDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -25,10 +25,13 @@
import tiled.mapeditor.MapEditor;
import tiled.mapeditor.widget.*;
+/**
+ * @version $Id$
+ */
public class ResizeDialog extends JDialog implements ActionListener,
PropertyChangeListener, ChangeListener
{
- private Map currentMap;
+ private final Map currentMap;
private IntegerSpinner width, height, offsetX, offsetY;
private JButton bOk, bCancel;
private ResizePanel orient;
Modified: trunk/tiled/mapeditor/dialogs/SearchDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/SearchDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/SearchDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -14,19 +14,21 @@
import java.awt.*;
import java.awt.event.*;
-import java.util.*;
+import java.util.Vector;
+import java.util.Iterator;
import javax.swing.*;
import tiled.mapeditor.selection.SelectionLayer;
import tiled.mapeditor.util.MultisetListRenderer;
import tiled.mapeditor.widget.*;
import tiled.core.*;
-import tiled.core.Map;
-
+/**
+ * @version $Id$
+ */
public class SearchDialog extends JDialog implements ActionListener
{
- private Map myMap;
+ private final Map myMap;
private JComboBox searchCBox, replaceCBox;
private JButton bFind, bFindAll;
private JButton bReplace, bReplaceAll;
@@ -123,15 +125,14 @@
}
private void queryTiles(JComboBox b) {
- Vector sets = myMap.getTilesets();
- int curSlot = 0;
- Iterator itr = sets.iterator();
+ final Vector sets = myMap.getTilesets();
+ final Iterator itr = sets.iterator();
while (itr.hasNext()) {
TileSet ts = (TileSet)itr.next();
b.addItem(ts);
- Iterator tileIterator = ts.iterator();
+ final Iterator tileIterator = ts.iterator();
while (tileIterator.hasNext()) {
Tile tile = (Tile)tileIterator.next();
b.addItem(tile);
@@ -155,14 +156,14 @@
}
sl = new SelectionLayer(myMap.getWidth(), myMap.getHeight());
- ListIterator itr = myMap.getLayers();
+ final Iterator itr = myMap.getLayers();
while (itr.hasNext()) {
MapLayer layer = (MapLayer) itr.next();
if (layer instanceof TileLayer) {
Rectangle bounds = layer.getBounds();
for (int y = 0; y < bounds.height; y++) {
for (int x = 0; x < bounds.width; x++) {
- if (((TileLayer)layer).getTileAt(x,y) == (Tile) searchCBox.getSelectedItem()) {
+ if (((TileLayer)layer).getTileAt(x,y) == searchCBox.getSelectedItem()) {
sl.select(x,y);
}
}
@@ -183,11 +184,11 @@
// run through the layers, look for the first instance of the
// tile we need to replace
- ListIterator itr = myMap.getLayers();
+ final Iterator itr = myMap.getLayers();
while (itr.hasNext()) {
MapLayer layer = (MapLayer) itr.next();
if (layer instanceof TileLayer) {
- if (((TileLayer)layer).getTileAt(currentMatch.x,currentMatch.y) == (Tile) searchCBox.getSelectedItem()) {
+ if (((TileLayer)layer).getTileAt(currentMatch.x,currentMatch.y) == searchCBox.getSelectedItem()) {
((TileLayer)layer).setTileAt(currentMatch.x,currentMatch.y, (Tile) replaceCBox.getSelectedItem());
break;
}
@@ -202,9 +203,8 @@
}
private void replaceAll(Tile f, Tile r) {
- // TODO: Allow for "scopes" of one or more layers, rather than all
- // layers
- ListIterator itr = myMap.getLayers();
+ // TODO: Allow for "scopes" of one or more layers, rather than all layers
+ final Iterator itr = myMap.getLayers();
while (itr.hasNext()) {
MapLayer layer = (MapLayer) itr.next();
if (layer instanceof TileLayer) {
@@ -230,14 +230,14 @@
for (int y = starty; y < myMap.getHeight() && !bFound; y++) {
for (int x = startx; x < myMap.getWidth() && !bFound; x++) {
- ListIterator itr = myMap.getLayers();
+ final Iterator itr = myMap.getLayers();
while (itr.hasNext()) {
MapLayer layer = (MapLayer) itr.next();
if (layer instanceof TileLayer) {
Rectangle bounds = layer.getBounds();
- if (((TileLayer)layer).getTileAt(x,y) == (Tile) searchCBox.getSelectedItem()) {
+ if (((TileLayer)layer).getTileAt(x,y) == searchCBox.getSelectedItem()) {
if (currentMatch != null) {
if (currentMatch.equals(new Point(x,y))) {
continue;
Modified: trunk/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -28,7 +28,9 @@
import tiled.mapeditor.util.*;
import tiled.mapeditor.widget.*;
-
+/**
+ * @version $Id$
+ */
public class TileImageDialog extends JDialog
implements ActionListener, ListSelectionListener
{
@@ -36,7 +38,7 @@
private JButton bOk, bCancel;
private JCheckBox horizFlipCheck, vertFlipCheck, rotateCheck;
private int imageId, imageOrientation;
- private TileSet tileset;
+ private final TileSet tileset;
private JLabel imageLabel;
private int[] imageIds;
Modified: trunk/tiled/mapeditor/dialogs/TilePaletteDialog.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/TilePaletteDialog.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -28,7 +28,7 @@
public class TilePaletteDialog extends JDialog implements ActionListener,
TileSelectionListener, ListSelectionListener
{
- private MapEditor editor;
+ private final MapEditor editor;
private Map currentMap;
private TilePalettePanel pc;
private JList sets;
Modified: trunk/tiled/mapeditor/dialogs/TilesetManager.java
===================================================================
--- trunk/tiled/mapeditor/dialogs/TilesetManager.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/dialogs/TilesetManager.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -32,8 +32,7 @@
public class TilesetManager extends JDialog implements ActionListener,
ListSelectionListener
{
- private Map map;
- private Vector tileSets;
+ private final Map map;
private JButton saveAsButton, saveButton, embedButton;
private JButton removeButton, editButton, closeButton;
Modified: trunk/tiled/mapeditor/util/LayerTableModel.java
===================================================================
--- trunk/tiled/mapeditor/util/LayerTableModel.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/util/LayerTableModel.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -73,9 +73,9 @@
if (layer != null) {
if (col == 0) {
- return new Boolean(layer.getLocked() || !layer.isVisible());
+ return Boolean.valueOf(layer.getLocked() || !layer.isVisible());
} else if (col == 1) {
- return new Boolean(layer.isVisible());
+ return Boolean.valueOf(layer.isVisible());
} else if (col == 2) {
return layer.getName();
} else {
Modified: trunk/tiled/mapeditor/util/TiledFileFilter.java
===================================================================
--- trunk/tiled/mapeditor/util/TiledFileFilter.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/mapeditor/util/TiledFileFilter.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -29,24 +29,24 @@
private LinkedList exts;
public TiledFileFilter() {
- desc = new String("Tiled files");
+ desc = "Tiled files";
exts = new LinkedList();
- exts.add(new String("tmx"));
- exts.add(new String("tmx.gz"));
- exts.add(new String("tsx"));
+ exts.add("tmx");
+ exts.add("tmx.gz");
+ exts.add("tsx");
}
public TiledFileFilter(int filter) {
exts = new LinkedList();
desc = "";
if ((filter & FILTER_TMX) != 0) {
- desc = new String("Tiled Maps files ");
- exts.add(new String("tmx"));
- exts.add(new String("tmx.gz"));
+ desc = "Tiled Maps files ";
+ exts.add("tmx");
+ exts.add("tmx.gz");
}
if ((filter & FILTER_TSX) != 0) {
desc = desc + "Tiled Tileset files";
- exts.add(new String("tsx"));
+ exts.add("tsx");
}
}
Modified: trunk/tiled/util/Base64.java
===================================================================
--- trunk/tiled/util/Base64.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/util/Base64.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -76,7 +76,7 @@
val >>= 6;
out[index+1] = alphabet[val & 0x3F];
val >>= 6;
- out[index+0] = alphabet[val & 0x3F];
+ out[index] = alphabet[val & 0x3F];
}
return out;
}
@@ -228,7 +228,7 @@
{
InputStream fis = new FileInputStream(file);
InputStream is = new BufferedInputStream(fis);
- int count = 0;
+ int count;
byte[] buf = new byte[16384];
while ((count=is.read(buf)) != -1) {
if (count > 0) baos.write(buf, 0, count);
@@ -247,7 +247,7 @@
{
Reader fr = new FileReader(file);
Reader in = new BufferedReader(fr);
- int count = 0;
+ int count;
char[] buf = new char[16384];
while ((count=in.read(buf)) != -1) {
if (count > 0) caw.write(buf, 0, count);
Modified: trunk/tiled/util/MersenneTwister.java
===================================================================
--- trunk/tiled/util/MersenneTwister.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/util/MersenneTwister.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -71,7 +71,7 @@
/* initializes mt[N] with a seed */
public void initGenRand(long s)
{
- mt[0]= s & 0xffffffff;
+ mt[0]= s;
for (mti=1; mti<N; mti++) {
mt[mti] =
(1812433253 * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
Modified: trunk/tiled/util/TileMergeHelper.java
===================================================================
--- trunk/tiled/util/TileMergeHelper.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/util/TileMergeHelper.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -12,12 +12,22 @@
package tiled.util;
-import java.awt.*;
-import java.util.*;
+import java.util.Vector;
+import java.util.Iterator;
+import java.awt.GraphicsEnvironment;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Graphics;
-import tiled.core.*;
import tiled.core.Map;
+import tiled.core.TileSet;
+import tiled.core.TileLayer;
+import tiled.core.Tile;
+import tiled.core.MapLayer;
+/**
+ * @version $Id$
+ */
public class TileMergeHelper {
private Map myMap;
private TileSet myTs;
@@ -87,10 +97,10 @@
public Cell(Map map, int posx, int posy, int start, int len, boolean all) {
sandwich = new Vector();
for (int i = 0; i < len; i++) {
- MapLayer ml = (MapLayer)map.getLayer(start+i);
+ MapLayer ml = map.getLayer(start+i);
if (ml instanceof TileLayer) {
TileLayer l = (TileLayer)ml;
- if (l != null && (l.isVisible() || all)) {
+ if (l.isVisible() || all) {
sandwich.add(l.getTileAt(posx, posy));
} else {
sandwich.add(null);
Modified: trunk/tiled/util/TiledConfiguration.java
===================================================================
--- trunk/tiled/util/TiledConfiguration.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/util/TiledConfiguration.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -232,17 +232,27 @@
addConfigPair("tiled.grid.antialias", "1");
addConfigPair("tiled.grid.opacity", "255");
addConfigPair("tiled.plugins.dir", "plugins");
-
+
//animation prefs
-
+
addConfigPair("tiled.animation.safe", "0");
addConfigPair("tiled.animation.animate", "0");
-
+
// defaults for new map dialog...
-
+
addConfigPair("tiled.newmapdialog.mapwidth", "64");
addConfigPair("tiled.newmapdialog.mapheight", "64");
addConfigPair("tiled.newmapdialog.tilewidth", "35");
addConfigPair("tiled.newmapdialog.tileheight", "35");
}
+
+ /**
+ * Writes current the configuration to <code>tiled.conf</code>. Silently
+ * ignores any exception.
+ */
+ public void flush () {
+ try { write("tiled.conf"); }
+ catch (IOException ex) {}
+ catch (Exception ex) {}
+ }
}
Modified: trunk/tiled/view/HexMapView.java
===================================================================
--- trunk/tiled/view/HexMapView.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/view/HexMapView.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -48,10 +48,12 @@
* height of a hex (i.e. from the bottom edge to the top edge).
* This is equal to the distance between two adjacent hexes (in the same
* column)
+ *
+ * @version $Id$
*/
public class HexMapView extends MapView
{
- private static double HEX_SLOPE = Math.tan(Math.toRadians(60));
+ private static final double HEX_SLOPE = Math.tan(Math.toRadians(60));
public HexMapView(Map m) {
super(m);
@@ -84,7 +86,7 @@
int wbhc = (int)getWidthBetweenHexCentres();
return new Dimension(
- (int)(myMap.getWidth() * wbhc + border + wbhc),
+ myMap.getWidth() * wbhc + border + wbhc,
myMap.getHeight() * tsize.height + border +
tsize.height / 2);
}
@@ -95,16 +97,16 @@
int toffset = (((modeFlags & PF_GRIDMODE) != 0) ? 1 : 0);
Rectangle clipRect = g2d.getClipBounds();
- int startX = (int)clipRect.x / tsize.width;
- int startY = (int)clipRect.y / tsize.height - 1;
+ int startX = clipRect.x / tsize.width;
+ int startY = clipRect.y / tsize.height - 1;
int endX = (int)(((clipRect.x + clipRect.width) / tsize.width) * 1.5) + 2;
- int endY = (int)((clipRect.y + clipRect.height) / tsize.height) * 3 + 2;
+ int endY = ((clipRect.y + clipRect.height) / tsize.height) * 3 + 2;
- int gy = (int)(startY * tsize.height + toffset);
+ int gy = startY * tsize.height + toffset;
for (int y = startY; y < endY; y++) {
Polygon gridPoly = createGridPolygon(0, y, 1);
gridPoly.translate(0, -(int)(tsize.getHeight() / 2));
- int gx = (int)(startX * tsize.width + toffset);
+ int gx = startX * tsize.width + toffset;
for (int x = startX; x < endX; x++) {
Tile t = layer.getTileAt(x, y);
@@ -195,7 +197,6 @@
int adjustyhexes = 10;
-
// Note: We adjust my & mx so they are always positive.
// The algorithm returns incorrect values for negative my
// The value adjustyhexes is arbitrary.
@@ -234,9 +235,7 @@
ty -= adjustyhexes;
tx -= adjustyhexes;
- Point result = new Point(tx, ty);
-
- return result;
+ return new Point(tx, ty);
}
/**
Modified: trunk/tiled/view/MapView.java
===================================================================
--- trunk/tiled/view/MapView.java 2006-02-04 15:51:15 UTC (rev 570)
+++ trunk/tiled/view/MapView.java 2006-02-10 00:43:11 UTC (rev 571)
@@ -27,6 +27,8 @@
/**
* The base class for map views. This is meant to be extended for different
* tile map orientations, such as orthagonal and isometric.
+ *
+ * @version $Id$
*/
public abstract class MapView extends JPanel implements Scrollable
{
@@ -194,7 +196,7 @@
* layers.
*
* @param g the Graphics2D object to paint to
- * @see JComponent#paintComponent(java.awt.Graphics)
+ * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
* @see MapLayer
* @see SelectionLayer
*/
@@ -308,8 +310,8 @@
/**
* Draws a TileLayer. Implemented in a subclass.
*
- * @param tl the TileLayer to be drawn
- * @param zoom the zoom level to draw the layer on
+ * @param tileLayer the TileLayer to be drawn
+ * @param zoom the zoom level to draw the layer on
*/
protected abstract void paintLayer(Graphics2D g2d, TileLayer tileLayer,
double zoom);
@@ -419,8 +421,8 @@
class SmoothZoomer extends Thread
{
- private MapView mapView;
- private double zoomFrom, zoomTo;
+ private final MapView mapView;
+ private final double zoomFrom, zoomTo;
private boolean keepZooming;
public SmoothZoomer(MapView view, double from, double to) {
More information about the tiled-commit
mailing list