[tiled] r586 - in trunk: . src/tiled/core src/tiled/io/xml src/tiled/mapeditor/dialogs src/tiled/mapeditor/plugin src/tiled/mapeditor/util src/tiled/mapeditor/widget src/tiled/util
svn@biggeruniverse.com
svn at biggeruniverse.com
Sat Feb 18 13:13:07 PST 2006
Author: aturk
Date: 2006-02-18 15:13:06 -0600 (Sat, 18 Feb 2006)
New Revision: 586
Removed:
trunk/src/tiled/core/ImageGroup.java
trunk/src/tiled/util/NumberedSetIterator.java
Modified:
trunk/CHANGES
trunk/src/tiled/core/Map.java
trunk/src/tiled/core/Tile.java
trunk/src/tiled/core/TileSet.java
trunk/src/tiled/io/xml/XMLMapTransformer.java
trunk/src/tiled/io/xml/XMLMapWriter.java
trunk/src/tiled/mapeditor/dialogs/TileDialog.java
trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
trunk/src/tiled/mapeditor/dialogs/TilesetManager.java
trunk/src/tiled/mapeditor/plugin/TiledPlugin.java
trunk/src/tiled/mapeditor/util/MultisetListRenderer.java
trunk/src/tiled/mapeditor/widget/TilePalettePanel.java
trunk/src/tiled/util/NumberedSet.java
trunk/src/tiled/util/Util.java
Log:
Trimmed down TileSet to the old-skool methods. No more checksumming or orientation code.
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/CHANGES 2006-02-18 21:13:06 UTC (rev 586)
@@ -1,33 +1,38 @@
0.6.0 - TBD (+ means planned change)
-* Made a start with internationalization/localization
-* Rewrote configuration based on the Preferences class, no more tiled.conf
++ Fixed memory problems when loading several maps with many tilesets in a row
* Fixed tileset dialog so that it is now possible to change the tile height to
something else than the tile height used by the map.
++ Fixed tile palette bug of displaying multiple tilesets over eachother
++ Rewrote main mapeditor code
+* Rewrote configuration based on the Preferences class, no more tiled.conf
+ Added a navigation minimap
+ Added full support for animated tiles
-+ Rewrote main mapeditor code
-+ Fixed memory problems when loading several maps with many tilesets in a row
-
-0.5.2 - TBD (+ means planned change)
-
+* Rearranged classes in packages
++ Moved actions out of MapEditor, and created a package for them
+* Cleaned up TileSet- removed checksumming and rotation/orienation code
+* Added internationalization/localization support
+ Added more useful visual feedback for some brushes
+ Added the Shifted view, which emulates several tiling configurations
+ Added "stamp" tool
-* For pencil, right-click, drag now creates a stamp for easy copying
+ Added ability to select multiple layers from layer table
+ Added the ability to merge tile images when layers are merged
-* Added core support for animated tiles
-* Added more error-checking to XMLMapTransformer, the default map reader
+ Added "global properties" for tilesets (properties set for all tiles)
-* Added support for "tile cutters"
+ Added preview of new tileset when creating a tileset
++ Added tile cutter GUI
+
+0.5.2 - TBD (+ means planned change)
+
* Fixed a bug when exporting a tileset with an external image
* Fixed two cases of hanging when using the fill tool
-+ Fixed tile palette bug of displaying multiple tilesets over eachother
* Fixed tile palette bug of not accounting for gaps in tile ids (old bug)
* Fixed bug of adding a new tile even if cancelling out of new tile dialog
* Fixed NPE when saving a map with no extension - default to .tmx
+* Added stamp function for pencil: right-click, drag now creates a stamp
+ for easy copying
+* Added core support for animated tiles
+* Added more error-checking to XMLMapTransformer, the default map reader
+* Added support for "tile cutters"
0.5.1 - June 15th, 2005
Deleted: trunk/src/tiled/core/ImageGroup.java
===================================================================
--- trunk/src/tiled/core/ImageGroup.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/core/ImageGroup.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -1,106 +0,0 @@
-/*
- * Tiled Map Editor, (c) 2004-2006
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Rainer Deyke <rainerd at eldwood.com>
- * Adam Turk <aturk at biggeruniverse.com>
- * Bjorn Lindeijer <b.lindeijer at xs4all.nl>
- */
-
-package tiled.core;
-
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.awt.image.PixelGrabber;
-
-/**
- * An ImageGroup store a base image and variations of that base image in a
- * single object.
- *
- * @version $Id$
- */
-public class ImageGroup {
- private Image[] images;
-
- /**
- * Constructs an ImageGroup from a base Image.
- */
- public ImageGroup(Image img) {
- images = new Image[8];
- images[0] = img;
- }
-
- /**
- * Retrieves the image with the specified orientation.
- *
- * @param orientation
- */
- public Image getImage(int orientation) {
- if (images[orientation] == null) {
- images[orientation] = orientImage(images[0], orientation);
- }
- return images[orientation];
- }
-
- /**
- * Generates a image that is identical to the source image except that it
- * is rotated and/or flipped.
- */
- public static Image orientImage(Image src, int orientation) {
- if (orientation == 0) {
- return src;
- } else {
- int w = src.getWidth(null), h = src.getHeight(null);
- int[] old_pixels = new int[w * h];
- int[] new_pixels = new int[w * h];
-
- PixelGrabber p = new PixelGrabber(src, 0, 0, w, h, old_pixels, 0, w);
- try {
- p.grabPixels();
- } catch (InterruptedException e) { }
-
-
- int dest_w = ((orientation & 4) != 0) ? h : w;
- int dest_h = ((orientation & 4) != 0) ? w : h;
- for (int dest_y = 0; dest_y < dest_h; ++dest_y) {
- for (int dest_x = 0; dest_x < dest_w; ++dest_x) {
- int src_x = dest_x, src_y = dest_y;
- if ((orientation & 4) != 0) {
- src_y = dest_w - dest_x - 1;
- src_x = dest_y;
- }
-
- if ((orientation & 1) != 0) {
- src_x = w - src_x - 1;
- }
- if ((orientation & 2) != 0) {
- src_y = h - src_y - 1;
- }
- new_pixels[dest_x + dest_y * dest_w] = old_pixels[src_x + src_y * w];
- }
- }
-
- BufferedImage new_img = new BufferedImage(dest_w, dest_h,
- BufferedImage.TYPE_INT_ARGB);
- new_img.setRGB(0, 0, dest_w, dest_h, new_pixels, 0, dest_w);
- return new_img;
- }
- }
-
- /**
- * Returns true if the other object is also an ImageGroup with the same
- * base image.
- */
- public boolean equals(Object o)
- {
- try {
- return this.images[0].equals(((ImageGroup)o).images[0]);
- } catch (java.lang.ClassCastException e) {
- return false;
- }
- }
-}
Modified: trunk/src/tiled/core/Map.java
===================================================================
--- trunk/src/tiled/core/Map.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/core/Map.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -166,7 +166,6 @@
}
tilesets.add(s);
- s.setMap(this);
fireMapChanged();
}
Modified: trunk/src/tiled/core/Tile.java
===================================================================
--- trunk/src/tiled/core/Tile.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/core/Tile.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -26,7 +26,7 @@
private Image internalImage, scaledImage;
private int id = -1;
protected int tileImageId = -1;
- private int groundHeight; // Height above/below ground
+ private int groundHeight; // Height above/below "ground"
private int tileOrientation;
private double myZoom = 1.0;
private Properties properties;
@@ -41,6 +41,11 @@
setTileSet(set);
}
+ /**
+ * Copy constructor
+ *
+ * @param t
+ */
public Tile(Tile t) {
properties = (Properties)t.properties.clone();
tileImageId = t.tileImageId;
@@ -70,7 +75,7 @@
*/
public void setImage(Image i) {
if (tileset != null) {
- tileset.overlayImage(String.valueOf(tileImageId), i);
+ tileset.overlayImage(tileImageId, i);
} else {
internalImage = i;
}
@@ -82,6 +87,11 @@
groundHeight = getHeight();
}
+ /**
+ *
+ * @deprecated
+ * @param orientation
+ */
public void setImageOrientation(int orientation) {
tileOrientation = orientation;
}
@@ -113,10 +123,22 @@
return properties;
}
+ /**
+ * Returns the tile id of this tile, relative to
+ * tileset.
+ *
+ * @return id
+ */
public int getId() {
return id;
}
+ /**
+ * Returns the global tile id by adding the
+ * tile id to the map-assigned
+ *
+ * @return id
+ */
public int getGid() {
if (tileset != null) {
return id + tileset.getFirstGid();
@@ -189,7 +211,7 @@
public int getWidth() {
if (tileset != null) {
Dimension d
- = tileset.getImageDimensions(String.valueOf(tileImageId), tileOrientation);
+ = tileset.getImageDimensions(tileImageId, tileOrientation);
return d.width;
} else if (internalImage != null){
return internalImage.getWidth(null);
@@ -200,7 +222,7 @@
public int getHeight() {
if (tileset != null) {
Dimension d
- = tileset.getImageDimensions(String.valueOf(tileImageId), tileOrientation);
+ = tileset.getImageDimensions(tileImageId, tileOrientation);
return d.height;
} else if (internalImage != null) {
return internalImage.getHeight(null);
@@ -212,6 +234,10 @@
return tileImageId;
}
+ /**
+ * @deprecated
+ * @return int
+ */
public int getImageOrientation() {
return tileOrientation;
}
@@ -223,8 +249,7 @@
*/
public Image getImage() {
if (tileset != null) {
- return tileset.getImageByIdAndOrientation(
- Integer.toString(tileImageId), tileOrientation);
+ return tileset.getImageById(tileImageId);
} else {
return internalImage;
}
@@ -232,6 +257,9 @@
/**
* Returns a scaled instance of the tile image.
+ *
+ * @param zoom
+ * @return Image
*/
public Image getScaledImage(double zoom) {
Image i = getImage();
@@ -247,6 +275,9 @@
return null;
}
+ /**
+ * @see java.lang.Object#toString()
+ */
public String toString() {
return "Tile " + id + " (" + getWidth() + "x" + getHeight() + ")";
}
Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/core/TileSet.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -14,44 +14,24 @@
import java.awt.*;
import java.awt.image.BufferedImage;
-import java.awt.image.PixelGrabber;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
-import java.util.zip.CRC32;
-import java.util.zip.Checksum;
import javax.imageio.ImageIO;
import tiled.mapeditor.util.cutter.TileCutter;
-import tiled.util.Util;
import tiled.util.NumberedSet;
-import tiled.core.ImageGroup;
-
/**
* <p>TileSet handles operations on tiles as a set, or group. It has several
* advanced internal functions aimed at reducing unnecessary data replication.
- * A 'tile' is represented internally as three distinct pieces of data. The
+ * A 'tile' is represented internally as two distinct pieces of data. The
* first and most important is a tiled.core.Tile object, and these are held in
- * a java.util.Vector.</p>
- *
- * <p>Tile objects contain an id that can be used to look up the second piece
- * of data, the tile image hash. The tile image hash is a unique CRC32
- * checksum. A checksum is generated for each image that is added to the set.
- * A java.util.Hashtable keeps the key-value pair of id and checksum. A second
- * java.util.Hashtable (the imageCache) maintains a key-value pair with the
- * checksum as key and the actual java.awt.Image as value.</p>
- *
- * <p>When a new image is added, a checksum is created and checked against the
- * checksums in the cache. If the checksum does not already exist, the image
- * is given an id, and is added to the cache. In this way, tile images are
- * never duplicated, and multiple tiles may reference the image by id.</p>
- *
- *
+ * a java.util.Vector.</p><br/>
+ * <p> The other is the tile image.</p>
+ *
* @version $Id$
*/
public class TileSet
@@ -59,11 +39,9 @@
private String base;
private NumberedSet tiles, images;
private int firstGid;
- private int tileHeight;
- private int tileWidth;
+ private Rectangle tileDimensions;
private String externalSource, tilebmpFile;
private String name;
- private Map map;
private Color transparentColor;
/**
@@ -72,6 +50,7 @@
public TileSet() {
tiles = new NumberedSet();
images = new NumberedSet();
+ tileDimensions = new Rectangle();
}
/**
@@ -119,8 +98,7 @@
throw new Exception("No cutter!");
}
- tileHeight = cutter.getDimensions().height;
- tileWidth = cutter.getDimensions().width;
+ tileDimensions = new Rectangle(cutter.getDimensions());
BufferedImage tile;
@@ -218,16 +196,6 @@
}
/**
- * Sets the map this tileset is part of.
- *
- * @param map
- * @deprecated
- */
- public void setMap(Map map) {
- this.map = map;
- }
-
- /**
* Sets the transparent color in the tileset image.
*
* @param color
@@ -248,12 +216,12 @@
t.setId(tiles.getMaxId());
}
- if (tileHeight < t.getHeight()) {
- tileHeight = t.getHeight();
+ if (tileDimensions.height < t.getHeight()) {
+ tileDimensions.height = t.getHeight();
}
- if (tileWidth < t.getWidth()) {
- tileWidth = t.getWidth();
+ if (tileDimensions.width < t.getWidth()) {
+ tileDimensions.width = t.getWidth();
}
tiles.put(t.getId(), t);
@@ -322,7 +290,7 @@
* @return int - The maximum tile width
*/
public int getTileWidth() {
- return tileWidth;
+ return tileDimensions.width;
}
/**
@@ -336,7 +304,7 @@
* @return int - The max height of the tiles in the set
*/
public int getTileHeight() {
- return tileHeight;
+ return tileDimensions.height;
}
/**
@@ -355,7 +323,10 @@
* tile exists with that id
*/
public Tile getTile(int i) {
- return (Tile)tiles.get(i);
+ try {
+ return (Tile)tiles.get(i);
+ } catch (ArrayIndexOutOfBoundsException a) {}
+ return null;
}
/**
@@ -419,15 +390,6 @@
}
/**
- * Returns the map this tileset is part of.
- * @deprecated
- * @return int
- */
- public Map getMap() {
- return map;
- }
-
- /**
* Returns the transparent color of the tileset image, or <code>null</code>
* if none is set.
*
@@ -445,50 +407,7 @@
}
- // TILE IMAGE CODE
-
/**
- * Provides a CRC32 checksum of the given image.
- *
- * @param i a preloaded Image object
- * @return a String containing the checksum value
- */
- private static String checksumImage(Image i) {
- PixelGrabber pg = new PixelGrabber(i, 0, 0, -1, -1, false);
- Checksum sum = new CRC32();
-
- try {
- pg.grabPixels();
- //ImageInputStream is;
-
- try {
- int psize = pg.getColorModel().getPixelSize();
- ByteArrayInputStream bais;
-
- // Handle different pixel sizes
- if (psize >= 15 ) {
- bais = new ByteArrayInputStream(
- Util.convertIntegersToBytes((int[])pg.getPixels()));
- } else {
- bais = new ByteArrayInputStream((byte[])pg.getPixels());
- }
- byte[] bytes = new byte[1024];
- int len;
-
- while ((len = bais.read(bytes)) >= 0) {
- sum.update(bytes, 0, len);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- return Long.toHexString(sum.getValue());
- }
-
- /**
* Returns the number of images in the set.
*
* @return the number of images in the set
@@ -508,6 +427,8 @@
return v.elements();
}
+ // TILE IMAGE CODE
+
/**
* This function uses the CRC32 checksums to find the cached version of the
* image supplied.
@@ -517,55 +438,56 @@
* the set
*/
public int getIdByImage(Image i) {
- return images.indexOf(new ImageGroup(i));
+ return images.indexOf(i);
}
/**
- * @param key a key identifying the image to get
+ * @param id
* @return the image identified by the key, or <code>null</code> when
* there is no such image
* @see TileSet#getImageByIdAndOrientation(Object, int)
*/
- public Image getImageById(Object key) {
- return getImageByIdAndOrientation(key, 0);
+ public Image getImageById(int id) {
+ return (Image) images.get(id);
}
/**
* Returns the image referred to by the given key, and automatically
* sets it to the given orientation.
*
+ * @deprecated
* @param key
* @param orientation
* @return Image
*/
public Image getImageByIdAndOrientation(Object key, int orientation) {
- int img_id = Integer.parseInt((String)key);
+ /*int img_id = Integer.parseInt((String)key);
ImageGroup img = (ImageGroup)images.get(img_id);
if (img == null) return null;
- return img.getImage(orientation);
+ return img.getImage(orientation);*/
+ return null;
}
/**
* Overlays the image in the set referred to by the given key.
*
- * @param key
+ * @param id
* @param i
*/
- public void overlayImage(Object key, Image i) {
- int img_id = Integer.parseInt((String)key);
- images.put(img_id, new ImageGroup(i));
+ public void overlayImage(int id, Image i) {
+ images.put(id, i);
}
/**
* Returns the dimensions of an image as specified by the id
* <code>key</code>.
*
- * @param key
+ * @param id
* @param orientation
* @return dimensions of image with referenced by given key
*/
- public Dimension getImageDimensions(Object key, int orientation) {
- Image i = getImageByIdAndOrientation(key, orientation);
+ public Dimension getImageDimensions(int id, int orientation) {
+ Image i = (Image) images.get(id);
if (i != null) {
return new Dimension(i.getWidth(null), i.getHeight(null));
} else {
@@ -574,36 +496,6 @@
}
/**
- * Attempt to retrieve an image matching the given image from the image
- * cache.
- *
- * @param image the image to match
- * @return a matching image from the cache if it exists, <code>null</code>
- * otherwise
- */
- public Image queryImage(Image image) {
- int id = images.indexOf(new ImageGroup(image));
- ImageGroup img = (ImageGroup)images.get(id);
- return img.getImage(0);
- }
-
- /*
- * Note: The following function only works for images in default
- * orientation.
- */
-
- /**
- * Find the id of the given image in the image cache.
- *
- * @param image the java.awt.Image to find the id for.
- * @return an java.lang.Object that represents the id of the image
- */
- public Object queryImageId(Image image) {
- ImageGroup img = new ImageGroup(image);
- return Integer.toString(images.indexOf(img));
- }
-
- /**
* Adds the specified image to the image cache. If the image already exists
* in the cache, returns the id of the existing image. If it does not exist,
* this function adds the image and returns the new id.
@@ -612,24 +504,21 @@
* @return the id as an <code>int</code> of the image in the cache
*/
public int addImage(Image image) {
- return images.findOrAdd(new ImageGroup(image));
+ return images.findOrAdd(image);
}
- public int addImage(Image image, Object key) {
- if (key == null) {
- return addImage(image);
- } else {
- int id = Integer.parseInt((String)key);
- images.put(id, new ImageGroup(image));
- return id;
- }
+ public int addImage(Image image, int id) {
+ return images.put(id, image);
}
-
- public void removeImage(Object key) {
- int id = Integer.parseInt((String)key);
+
+ public void removeImage(int id) {
images.remove(id);
}
+ /**
+ * @deprecated
+ * @return
+ */
public boolean usesSharedImages() {
// TODO: Currently only uses shared sets...
return true;
@@ -638,6 +527,7 @@
/**
* Checks whether each image has a one to one relationship with the tiles.
*
+ * @deprecated
* @return <code>true</code> if each image is associated with one and only
* one tile, <code>false</code> otherwise.
*/
Modified: trunk/src/tiled/io/xml/XMLMapTransformer.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapTransformer.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/io/xml/XMLMapTransformer.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -386,7 +386,7 @@
} else {
set.addImage(unmarshalImage(child, tilesetBaseDir),
- getAttributeValue(child, "id"));
+ Integer.parseInt(getAttributeValue(child, "id")));
}
}
}
Modified: trunk/src/tiled/io/xml/XMLMapWriter.java
===================================================================
--- trunk/src/tiled/io/xml/XMLMapWriter.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/io/xml/XMLMapWriter.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -240,7 +240,7 @@
w.writeAttribute("encoding", "base64");
w.writeCDATA(new String(Base64.encode(
ImageHelper.imageToPNG(
- set.getImageById(id)))));
+ set.getImageById(Integer.parseInt(id))))));
w.endElement();
w.endElement();
}
Modified: trunk/src/tiled/mapeditor/dialogs/TileDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/mapeditor/dialogs/TileDialog.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -37,6 +37,7 @@
{
private Tile currentTile;
private TileSet tileset;
+ private Map map;
private JList tileList, imageList;
private JTable tileProperties;
private JButton bOk, bNew, bDelete, bChangeI, bDuplicate;
@@ -49,10 +50,11 @@
private JTabbedPane tabs;
private int currentImageIndex = -1;
- public TileDialog(Dialog parent, TileSet s) {
+ public TileDialog(Dialog parent, TileSet s, Map m) {
super(parent, "Edit Tileset '" + s.getName() + "'", true);
location = "";
tileset = s; //unofficial
+ map = m; //also unofficial
init();
setTileset(s);
setCurrentTile(null);
@@ -282,8 +284,8 @@
// Find new tile images at the location of the tileset
if (tileset.getSource() != null) {
location = tileset.getSource();
- } else if (tileset.getMap() != null) {
- location = tileset.getMap().getFilename();
+ } else if (map != null) {
+ location = map.getFilename();
}
tilesetNameEntry.setText(tileset.getName());
//sharedImagesCheck.setSelected(tileset.usesSharedImages());
@@ -321,7 +323,7 @@
Enumeration ids = tileset.getImageIds();
while(ids.hasMoreElements()) {
- Image img = tileset.getImageById(ids.nextElement());
+ Image img = tileset.getImageById(Integer.parseInt((String) ids.nextElement()));
if(img != null)
listData.add(img);
}
@@ -500,7 +502,7 @@
JOptionPane.QUESTION_MESSAGE);
if (answer == JOptionPane.YES_OPTION) {
Image img = (Image)imageList.getSelectedValue();
- tileset.removeImage(Integer.toString(tileset.getIdByImage(img)));
+ tileset.removeImage(tileset.getIdByImage(img));
queryImages();
}
} else if (source == bDeleteAllUnusedImages) {
@@ -525,7 +527,7 @@
}
if (!image_used) {
- tileset.removeImage(Integer.toString(id));
+ tileset.removeImage(id);
}
}
Modified: trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/mapeditor/dialogs/TileImageDialog.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -22,7 +22,6 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
-import tiled.core.ImageGroup;
import tiled.core.TileSet;
import tiled.mapeditor.util.ImageCellRenderer;
import tiled.mapeditor.widget.VerticalStaticJPanel;
@@ -128,7 +127,7 @@
for (int i = 0; i < imageIds.length; ++i) {
if (imageIds[i] == imageId) initialIndex = i;
- Image img = tileset.getImageById(Integer.toString(imageIds[i]));
+ Image img = tileset.getImageById(imageIds[i]);
// assert img != null;
listData.add(img);
}
@@ -166,8 +165,7 @@
private void updateImageLabel() {
if (imageId >= 0) {
- Image img = tileset.getImageById(Integer.toString(imageId));
- img = ImageGroup.orientImage(img, imageOrientation);
+ Image img = tileset.getImageById(imageId);
imageLabel.setIcon(new ImageIcon(img));
}
}
Modified: trunk/src/tiled/mapeditor/dialogs/TilesetManager.java
===================================================================
--- trunk/src/tiled/mapeditor/dialogs/TilesetManager.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/mapeditor/dialogs/TilesetManager.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -116,7 +116,7 @@
dispose();
} else if (command.equals("Edit...")) {
if (map != null && selectedRow >= 0) {
- TileDialog tileDialog = new TileDialog(this, set);
+ TileDialog tileDialog = new TileDialog(this, set, map);
tileDialog.setVisible(true);
}
} else if (command.equals("Remove")) {
Modified: trunk/src/tiled/mapeditor/plugin/TiledPlugin.java
===================================================================
--- trunk/src/tiled/mapeditor/plugin/TiledPlugin.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/mapeditor/plugin/TiledPlugin.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -104,7 +104,6 @@
return null;
}
-
public boolean accept(File pathname) {
return reader != null && reader.accept(pathname) ||
writer != null && writer.accept(pathname);
Modified: trunk/src/tiled/mapeditor/util/MultisetListRenderer.java
===================================================================
--- trunk/src/tiled/mapeditor/util/MultisetListRenderer.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/mapeditor/util/MultisetListRenderer.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -50,6 +50,9 @@
this.zoom = zoom;
}
+ /**
+ * @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
+ */
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
boolean cellHasFocus) {
Modified: trunk/src/tiled/mapeditor/widget/TilePalettePanel.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TilePalettePanel.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/mapeditor/widget/TilePalettePanel.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -108,7 +108,7 @@
if (tileset != null) {
// Draw the tiles
- int maxHeight = tileset.getMaxTileHeight();
+ int maxHeight = tileset.getTileHeight();
int twidth = tileset.getTileWidth() + 1;
int theight = tileset.getTileHeight() + 1;
int tilesPerRow = Math.max(1, (getWidth() - 1) / twidth);
Modified: trunk/src/tiled/util/NumberedSet.java
===================================================================
--- trunk/src/tiled/util/NumberedSet.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/util/NumberedSet.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -1,12 +1,11 @@
/*
- * Tiled Map Editor, (c) 2005
+ * Tiled Map Editor, (c) 2004-2006
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * Rainer Deyke <rainerd at eldwood.com>
* Adam Turk <aturk at biggeruniverse.com>
* Bjorn Lindeijer <b.lindeijer at xs4all.nl>
*/
@@ -21,16 +20,18 @@
* id and element remains unaffected when elements are deleted. This means
* that the set of ids for a NumberedSet may not be contiguous. (A sparse
* array)
+ *
+ * @author rainerd
*/
public class NumberedSet {
- private Hashtable data;
+ private Vector data;
/**
* Constructs a new empty NumberedSet.
*/
public NumberedSet() {
- data = new Hashtable();
+ data = new Vector();
}
/**
@@ -38,25 +39,21 @@
* identify any element in this NumberedSet.
*
* @param id
+ * @return Object
*/
public Object get(int id) {
- return data.get(""+id);
+ try {
+ return data.get(id);
+ } catch (ArrayIndexOutOfBoundsException e) {}
+
+ return null;
}
-
- /**
- * This get() is mainly used by NumberedSetIterator
- *
- * @param key
- * @return
- */
- public Object get(Object key) {
- return data.get(key);
- }
/**
* Returns true if the NumberedSet contains an element for the specified id.
*
* @param id
+ * @return boolean
*/
public boolean containsId(int id) {
return get(id) != null;
@@ -69,29 +66,34 @@
*
* @param id
* @param o
+ * @return int
+ * @throws IllegalArgumentException
*/
- public void put(int id, Object o) {
+ public int put(int id, Object o) throws IllegalArgumentException {
if (id < 0) throw new IllegalArgumentException();
- data.put(""+id, o);
+ data.add(id, o);
+ return id;
}
/**
* Removes the element associated with the given id from the NumberedSet.
+ *
+ * @param id
*/
public void remove(int id) {
- data.remove(""+id);
+ data.remove(id);
}
/**
* Returns the last id in the NumberedSet that is associated with an element,
* or -1 if the NumberedSet is empty.
+ *
+ * @return int
*/
public int getMaxId() {
int id = -1;
- Iterator itr = data.keySet().iterator();
- while(itr.hasNext()) {
- int i = Integer.parseInt((String)itr.next());
- if(i>id) id = i;
+ for(int i=0;i<data.size();i++) {
+ if(data.get(i) != null) id = i;
}
return id+1;
@@ -100,14 +102,17 @@
/**
* Returns an iterator to iterate over the elements of the NumberedSet.
*
- * @return
+ * @return NumberedSetIterator
*/
- public NumberedSetIterator iterator() {
- return new NumberedSetIterator(this);
+ public Iterator iterator() {
+ return data.iterator();
}
/**
* Adds a new element to the NumberedSet and returns its id.
+ *
+ * @param o
+ * @return int
*/
public int add(Object o) {
int id = getMaxId();
@@ -122,16 +127,7 @@
* @param o
*/
public int indexOf(Object o) {
- if(contains(o)) {
- Iterator itr = data.keySet().iterator();
- while(itr.hasNext()) {
- String key = (String)itr.next();
- if(o.equals(data.get(key))) {
- return Integer.parseInt(key);
- }
- }
- }
- return -1;
+ return data.indexOf(o);
}
/**
@@ -139,7 +135,7 @@
* given object.
*/
public boolean contains(Object o) {
- return data.containsValue(o);
+ return data.contains(o);
}
/**
@@ -154,9 +150,9 @@
}
/**
- * Returns the number of actual elements in the NumberedSet. This operation
- * is unfortunately somewhat slow because it requires iterating over the
- * underlying Vector.
+ * Returns the number of actual elements in the NumberedSet.
+ *
+ * @return int
*/
public int size() {
return data.size();
Deleted: trunk/src/tiled/util/NumberedSetIterator.java
===================================================================
--- trunk/src/tiled/util/NumberedSetIterator.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/util/NumberedSetIterator.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -1,54 +0,0 @@
-/*
- * Tiled Map Editor, (c) 2004, 2005
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Adam Turk <aturk at biggeruniverse.com>
- * Bjorn Lindeijer <b.lindeijer at xs4all.nl>
- * Rainer Deyke <rainerd at eldwood.com>
- */
-
-package tiled.util;
-
-import java.lang.IllegalStateException;
-import java.lang.UnsupportedOperationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * This special iterator assures that access to the
- * NumberedSet data is correctly ordered, and that
- * empty sections of the sparce array are skipped
- * automatically.
- */
-public class NumberedSetIterator implements Iterator
-{
- private NumberedSet set;
- private int id;
-
- public NumberedSetIterator(NumberedSet set) {
- this.set = set;
- this.id = 0;
- }
-
- public boolean hasNext() {
- return this.id < this.set.getMaxId();
- }
-
- public Object next() throws NoSuchElementException {
- while (this.id < this.set.getMaxId()) {
- Object o = set.get(id++);
- if (o != null) return o;
- }
- throw new NoSuchElementException();
- }
-
- public void remove()
- throws UnsupportedOperationException, IllegalStateException
- {
- throw new UnsupportedOperationException();
- }
-}
Modified: trunk/src/tiled/util/Util.java
===================================================================
--- trunk/src/tiled/util/Util.java 2006-02-18 10:20:26 UTC (rev 585)
+++ trunk/src/tiled/util/Util.java 2006-02-18 21:13:06 UTC (rev 586)
@@ -16,6 +16,10 @@
import java.io.IOException;
+/**
+ * Various utility functions
+ *
+ */
public class Util
{
/**
More information about the tiled-commit
mailing list