[tiled] r569 - in branches/bjorn/src/tiled: core io io/xml mapeditor mapeditor/brush mapeditor/dialogs mapeditor/util util view
svn@biggeruniverse.com
svn at biggeruniverse.com
Sat Feb 4 07:44:05 PST 2006
Author: bjorn
Date: 2006-02-04 09:44:04 -0600 (Sat, 04 Feb 2006)
New Revision: 569
Modified:
branches/bjorn/src/tiled/core/Map.java
branches/bjorn/src/tiled/io/ImageHelper.java
branches/bjorn/src/tiled/io/MapHelper.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/BrushDialog.java
branches/bjorn/src/tiled/mapeditor/MapEditor.java
branches/bjorn/src/tiled/mapeditor/TilePaletteDialog.java
branches/bjorn/src/tiled/mapeditor/TilesetManager.java
branches/bjorn/src/tiled/mapeditor/brush/Brush.java
branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java
branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java
branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java
branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/ConfigurationDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/NewMapDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/SearchDialog.java
branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java
branches/bjorn/src/tiled/mapeditor/util/LayerTableModel.java
branches/bjorn/src/tiled/mapeditor/util/TiledFileFilter.java
branches/bjorn/src/tiled/util/Base64.java
branches/bjorn/src/tiled/util/MersenneTwister.java
branches/bjorn/src/tiled/util/TileMergeHelper.java
branches/bjorn/src/tiled/util/TiledConfiguration.java
branches/bjorn/src/tiled/view/HexMapView.java
branches/bjorn/src/tiled/view/MapView.java
Log:
A host of small changes throughout the code, which could probably be merged with trunk relatively easily. Also merged remembering new map defaults from trunk.
Modified: branches/bjorn/src/tiled/core/Map.java
===================================================================
--- branches/bjorn/src/tiled/core/Map.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/core/Map.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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;
Modified: branches/bjorn/src/tiled/io/ImageHelper.java
===================================================================
--- branches/bjorn/src/tiled/io/ImageHelper.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/io/ImageHelper.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -14,13 +14,17 @@
import java.awt.Image;
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
{
@@ -54,7 +58,7 @@
*
* @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)
+ * @see java.awt.Toolkit#createImage(byte[] imagedata)
*/
static public Image bytesToImage(byte[] imageData) {
return Toolkit.getDefaultToolkit().createImage(imageData);
@@ -69,7 +73,6 @@
* @throws IOException
*/
static public Image loadImageFile(File file) throws IOException {
- BufferedImage buffer = ImageIO.read(file);
- return buffer;
+ return ImageIO.read(file);
}
}
Modified: branches/bjorn/src/tiled/io/MapHelper.java
===================================================================
--- branches/bjorn/src/tiled/io/MapHelper.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/io/MapHelper.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/io/xml/XMLMapTransformer.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -38,7 +38,9 @@
import tiled.mapeditor.util.TransparentImageFilter;
import tiled.util.*;
-
+/**
+ * @version $Id$
+ */
public class XMLMapTransformer implements MapReader
{
private Map map = null;
@@ -50,7 +52,7 @@
}
private String makeUrl(String filename) throws MalformedURLException {
- String url = "";
+ final String url;
if (filename.indexOf("://") > 0 || filename.startsWith("file:")) {
url = filename;
} else {
@@ -87,7 +89,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() +
@@ -229,39 +231,40 @@
{
TileSet set = null;
Node tsNode;
- Document tsDoc = null;
+ final Document tsDoc;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
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;
} catch (FileNotFoundException fnf) {
// TODO: Have a popup and ask the user to browse to the file...
warnings.push("ERROR: Could not find external tileset file " +
filename);
}
-
- 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;
+
return set;
}
Modified: branches/bjorn/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLMapWriter.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/io/xml/XMLMapWriter.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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();
}
}
@@ -453,7 +455,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) {
Modified: branches/bjorn/src/tiled/io/xml/XMLWriter.java
===================================================================
--- branches/bjorn/src/tiled/io/xml/XMLWriter.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/io/xml/XMLWriter.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/BrushDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/BrushDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/BrushDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -42,7 +42,7 @@
ListSelectionListener
{
private AbstractBrush myBrush;
- private MapEditor editor;
+ private final MapEditor editor;
private JCheckBox cbRandomBrush;
private IntegerSpinner affectLayers, brushSize;
Modified: branches/bjorn/src/tiled/mapeditor/MapEditor.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/MapEditor.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/MapEditor.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -52,14 +52,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;
@@ -73,11 +73,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;
@@ -131,10 +131,10 @@
MapLayerEdit paintEdit;
// Actions
- Action zoomInAction, zoomOutAction, zoomNormalAction;
- Action rot90Action, rot180Action, rot270Action;
- Action flipHorAction, flipVerAction;
- Action selectAllAction, inverseAction, cancelSelectionAction;
+ final Action zoomInAction, zoomOutAction, zoomNormalAction;
+ final Action rot90Action, rot180Action, rot270Action;
+ final Action flipHorAction, flipVerAction;
+ final Action selectAllAction, inverseAction, cancelSelectionAction;
public MapEditor() {
// Get instance of configuration
@@ -219,6 +219,7 @@
mapScrollPane = new JScrollPane(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+ mapScrollPane.setBorder(null);
createToolbox();
createData();
@@ -1318,7 +1319,7 @@
}
private class LayerTransformAction extends AbstractAction {
- private int transform;
+ private final int transform;
public LayerTransformAction(int transform) {
this.transform = transform;
switch (transform) {
Modified: branches/bjorn/src/tiled/mapeditor/TilePaletteDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/TilePaletteDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/TilePaletteDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -27,7 +27,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: branches/bjorn/src/tiled/mapeditor/TilesetManager.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/TilesetManager.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/TilesetManager.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -33,8 +33,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: branches/bjorn/src/tiled/mapeditor/brush/Brush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/Brush.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/brush/Brush.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -34,9 +34,7 @@
public abstract void setAffectedLayers(int num);
public abstract int getAffectedLayers();
-
- public abstract Rectangle getBounds();
-
+
/**
* This is the main processing method for a Brush object. Painting starts
* on initLayer, and if the brush has more than one layer, then the brush
Modified: branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/brush/CustomBrush.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -19,6 +19,9 @@
import tiled.core.MultilayerPlane;
import tiled.core.TileLayer;
+/**
+ * @version $Id$
+ */
public class CustomBrush extends AbstractBrush
{
public CustomBrush() {
@@ -37,15 +40,11 @@
return getTotalLayers();
}
- public Rectangle getBounds() {
- return getBounds();
- }
-
/**
* The custom brush will merge its internal layers onto the layers of the
* specified MultilayerPlane.
*
- * @see TileLayer#mergeOnto(MapLayer)
+ * @see TileLayer#mergeOnto(tiled.core.MapLayer)
* @see Brush#commitPaint(MultilayerPlane, int, int, int)
* @param mp The MultilayerPlane to be affected
* @param x The x-coordinate where the user initiated the paint
@@ -57,8 +56,8 @@
int initLayer)
{
Rectangle bounds = this.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);
ListIterator itr = getLayers();
while (itr.hasNext()) {
Modified: branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/brush/RandomBrush.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/brush/ShapeBrush.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -12,17 +12,25 @@
package tiled.mapeditor.brush;
-import java.awt.*;
-import java.awt.geom.*;
+import java.awt.geom.Area;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.Graphics;
-import tiled.core.*;
+import tiled.core.Tile;
+import tiled.core.TileLayer;
+import tiled.core.MultilayerPlane;
-
+/**
+ * @version $Id$
+ */
public class ShapeBrush extends AbstractBrush
{
protected Area shape;
protected Tile paintTile;
-
+
public ShapeBrush() {
super();
}
@@ -31,7 +39,7 @@
super();
this.shape = shape;
}
-
+
public ShapeBrush(AbstractBrush sb) {
super(sb);
if (sb instanceof ShapeBrush) {
@@ -39,7 +47,7 @@
paintTile = ((ShapeBrush)sb).paintTile;
}
}
-
+
/**
* Makes this brush a circular brush.
*
@@ -61,9 +69,9 @@
}
public void makePolygonBrush(Polygon p) {
-
+
}
-
+
public void setSize(int s) {
if (shape.isRectangular()) {
makeQuadBrush(new Rectangle(0, 0, s, s));
@@ -73,12 +81,12 @@
// TODO: scale the polygon brush
}
}
-
+
/**
* Paints the entire area of the brush with the set tile. This brush can
* affect several layers.
*
- * @see Brush#commitPaint(MultilayerPlane, int, int, int)
+ * @see Brush#commitPaint(tiled.core.MultilayerPlane, int, int, int)
* @return a Rectangle of the bounds of the area that was modified
* @param mp The multilayer plane that will be modified
* @param x The x-coordinate where the click occurred.
@@ -86,8 +94,8 @@
*/
public Rectangle commitPaint(MultilayerPlane mp, int x, int y, 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);
// TODO: This loop does not take all edges into account
@@ -103,7 +111,7 @@
}
}
}
-
+
// Return affected area
return new Rectangle(centerx, centery, bounds.width, bounds.height);
}
@@ -115,7 +123,7 @@
public Tile getTile() {
return paintTile;
}
-
+
public Rectangle getBounds() {
return shape.getBounds();
}
@@ -123,7 +131,7 @@
public boolean isRectangular() {
return shape.isRectangular();
}
-
+
public void paint(Graphics g, int x, int y) {
if (shape.isRectangular()) {
Rectangle bounds = shape.getBounds();
Modified: branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/AboutDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/dialogs/ConfigurationDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/ConfigurationDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/ConfigurationDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/ImageColorDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -12,134 +12,141 @@
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();
+ }
- 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);
+ pixels = (int[]) pg.getPixels();
+
+ init();
+ pack();
+ setLocationRelativeTo(getOwner());
+ setModal(true);
}
-
- public Color showDialog() {
- setVisible(true);
- return color;
+
+ 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);
}
-
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == bCancel) {
- color = null;
- dispose();
+
+ public Color showDialog () {
+ setVisible(true);
+ return color;
+ }
+
+ public void actionPerformed (ActionEvent e) {
+ if (e.getSource() == bCancel) {
+ color = null;
+ dispose();
}
}
- public void mouseClicked(MouseEvent e) {
- grabColor(e.getX(), e.getY());
+ public void mouseClicked (MouseEvent e) {
+ grabColor(e.getX(), e.getY());
dispose();
}
- public void mousePressed(MouseEvent e) {
+ public void mousePressed (MouseEvent e) {
}
- public void mouseReleased(MouseEvent e) {
+ public void mouseReleased (MouseEvent e) {
}
- public void mouseEntered(MouseEvent e) {
- }
+ public void mouseEntered (MouseEvent e) {
+ }
- public void mouseExited(MouseEvent e) {
+ public void mouseExited (MouseEvent e) {
}
- public void mouseDragged(MouseEvent e) {
+ public void mouseDragged (MouseEvent e) {
grabColor(e.getX(), e.getY());
}
- public void mouseMoved(MouseEvent e) {
+ public void mouseMoved (MouseEvent e) {
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: branches/bjorn/src/tiled/mapeditor/dialogs/NewMapDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/NewMapDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/NewMapDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -17,9 +17,10 @@
import javax.swing.*;
import tiled.core.*;
-import tiled.mapeditor.widget.*;
+import tiled.util.TiledConfiguration;
+import tiled.mapeditor.widget.IntegerSpinner;
+import tiled.mapeditor.widget.VerticalStaticJPanel;
-
public class NewMapDialog extends JDialog implements ActionListener
{
private Map newMap;
@@ -36,14 +37,21 @@
}
private void init() {
+ // Load dialog defaults
+
+ 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);
+
// Create the primitives
- mapWidth = new IntegerSpinner(64, 1);
- mapHeight = new IntegerSpinner(64, 1);
- tileWidth = new IntegerSpinner(35, 1);
- tileHeight = new IntegerSpinner(35, 1);
+ mapWidth = new IntegerSpinner(defaultMapWidth, 1);
+ mapHeight = new IntegerSpinner(defaultMapHeight, 1);
+ tileWidth = new IntegerSpinner(defaultTileWidth, 1);
+ tileHeight = new IntegerSpinner(defaultTileHeight, 1);
-
// Map size fields
JPanel mapSize = new VerticalStaticJPanel();
@@ -169,9 +177,16 @@
newMap.setTileHeight(theight);
newMap.setOrientation(orientation);
- dispose();
- } else {
- dispose();
+ // Save dialog options
+
+ 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.flush();
}
+ dispose();
}
}
Modified: branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/NewTilesetDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -25,16 +25,20 @@
import tiled.core.*;
import tiled.mapeditor.util.TransparentImageFilter;
-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
{
- private Map map;
+ private final Map map;
private TileSet newTileset;
private JTextField tileWidth, tileHeight;
private IntegerSpinner tileSpacing;
@@ -83,7 +87,7 @@
tilebmpCheck.addChangeListener(this);
tileAutoCheck = new JCheckBox("Automatically create tiles from images",
- true);
+ true);
tileAutoCheck.setEnabled(false);
transCheck = new JCheckBox("Use transparent color");
@@ -215,17 +219,17 @@
try {
if (!transCheck.isSelected()) {
newTileset.importTileBitmap(file,
- map.getTileWidth(), map.getTileHeight(),
- spacing,
- tileAutoCheck.isSelected());
+ map.getTileWidth(), map.getTileHeight(),
+ spacing,
+ tileAutoCheck.isSelected());
} else {
try {
Toolkit tk = Toolkit.getDefaultToolkit();
Image orig = ImageIO.read(new File(file));
Image trans = tk.createImage(
new FilteredImageSource(orig.getSource(),
- new TransparentImageFilter(
- colorButton.getColor().getRGB())));
+ new TransparentImageFilter(
+ colorButton.getColor().getRGB())));
BufferedImage img = new BufferedImage(
trans.getWidth(null),
trans.getHeight(null),
@@ -234,10 +238,10 @@
img.getGraphics().drawImage(trans, 0, 0, null);
newTileset.importTileBitmap(img,
- map.getTileWidth(),
- map.getTileHeight(),
- spacing,
- tileAutoCheck.isSelected());
+ map.getTileWidth(),
+ map.getTileHeight(),
+ spacing,
+ tileAutoCheck.isSelected());
newTileset.setTransparentColor(
colorButton.getColor());
@@ -248,8 +252,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;
}
}
@@ -274,9 +278,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 {
dispose();
Modified: branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/PluginDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/PropertiesDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/ResizeDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/dialogs/SearchDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/SearchDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/SearchDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/util/LayerTableModel.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/util/LayerTableModel.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/util/LayerTableModel.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/mapeditor/util/TiledFileFilter.java
===================================================================
--- branches/bjorn/src/tiled/mapeditor/util/TiledFileFilter.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/mapeditor/util/TiledFileFilter.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/util/Base64.java
===================================================================
--- branches/bjorn/src/tiled/util/Base64.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/util/Base64.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/util/MersenneTwister.java
===================================================================
--- branches/bjorn/src/tiled/util/MersenneTwister.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/util/MersenneTwister.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -69,7 +69,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: branches/bjorn/src/tiled/util/TileMergeHelper.java
===================================================================
--- branches/bjorn/src/tiled/util/TileMergeHelper.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/util/TileMergeHelper.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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;
@@ -85,10 +95,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: branches/bjorn/src/tiled/util/TiledConfiguration.java
===================================================================
--- branches/bjorn/src/tiled/util/TiledConfiguration.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/util/TiledConfiguration.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -232,5 +232,20 @@
addConfigPair("tiled.grid.antialias", "1");
addConfigPair("tiled.grid.opacity", "255");
addConfigPair("tiled.plugins.dir", "plugins");
+
+ // 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: branches/bjorn/src/tiled/view/HexMapView.java
===================================================================
--- branches/bjorn/src/tiled/view/HexMapView.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/view/HexMapView.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -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: branches/bjorn/src/tiled/view/MapView.java
===================================================================
--- branches/bjorn/src/tiled/view/MapView.java 2006-02-04 14:02:21 UTC (rev 568)
+++ branches/bjorn/src/tiled/view/MapView.java 2006-02-04 15:44:04 UTC (rev 569)
@@ -26,6 +26,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
{
@@ -183,7 +185,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
*/
@@ -285,8 +287,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);
@@ -396,8 +398,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