[tiled] r665 - in trunk: . src/tiled/core src/tiled/mapeditor src/tiled/mapeditor/widget src/tiled/view
svn@biggeruniverse.com
svn at biggeruniverse.com
Sat Jun 10 12:57:26 PDT 2006
Author: bjorn
Date: 2006-06-10 14:57:26 -0500 (Sat, 10 Jun 2006)
New Revision: 665
Modified:
trunk/SUGGESTIONS
trunk/src/tiled/core/TileSet.java
trunk/src/tiled/mapeditor/MapEditor.java
trunk/src/tiled/mapeditor/widget/TilePalettePanel.java
trunk/src/tiled/view/HexMapView.java
trunk/src/tiled/view/IsoMapView.java
trunk/src/tiled/view/MapView.java
trunk/src/tiled/view/ObliqueMapView.java
trunk/src/tiled/view/OrthoMapView.java
trunk/src/tiled/view/ShiftedMapView.java
Log:
Zoom zoom zoom... useless zoom parameter is gone!
Also, stamp brush now resets when a new tile is selected.
Modified: trunk/SUGGESTIONS
===================================================================
--- trunk/SUGGESTIONS 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/SUGGESTIONS 2006-06-10 19:57:26 UTC (rev 665)
@@ -164,15 +164,8 @@
Date: 18/02/06
Summary: Removing of stupid features. (like this suggestion)
State: Discussed and partly in progress.
-Problems: * Get rid of #getNullTile in favour of actually using null. - DONE
- * Dump the whole tile image checksumming stuff in favour of
- straightforward code and behaviour. - DONE
- * Do not support embedding of tilesets or tile images and neither
+Problems: * Do not support embedding of tilesets or tile images and neither
multiple external individual tile images in a single tileset.
- * Remove option for XML-based layer data storage.
- * Do not support tile image rotation or flipping. - DONE
* Rename HexMapView to HexagonalMapView, IsoMapView to
IsometricMapView and OrthoMapView to OrthographicMapView.
- * Remove the zoom argument from all the MapView drawing methods
- and get rid of the SmoothZoomer.
* Get rid of reflection used for loading maps.
Modified: trunk/src/tiled/core/TileSet.java
===================================================================
--- trunk/src/tiled/core/TileSet.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/core/TileSet.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -287,13 +287,13 @@
* occur if a tile is removed from the middle of a set
* of tiles. (Maps tiles contiguously)
*
- * @return A java.util.Vector mapping ordered set location to the next non-null tile
+ * @return a {@link Vector} mapping ordered set location to the next non-null tile
*/
public Vector generateGaplessVector() {
Vector gapless = new Vector();
- for(int i=0;i<getMaxTileId();i++) {
- if(getTile(i) != null) gapless.add(getTile(i));
+ for (int i = 0; i < getMaxTileId(); i++) {
+ if (getTile(i) != null) gapless.add(getTile(i));
}
return gapless;
Modified: trunk/src/tiled/mapeditor/MapEditor.java
===================================================================
--- trunk/src/tiled/mapeditor/MapEditor.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/mapeditor/MapEditor.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -789,7 +789,7 @@
if (!bMouseIsDragging) {
Tile newTile = ((TileLayer)layer).getTileAt(tile.x, tile.y);
setCurrentTile(newTile);
- } else if(currentPointerState == PS_PAINT) {
+ } else if (currentPointerState == PS_PAINT) {
//in case we are dragging to create a custom brush, let the user
//know where we are creating it from
if (marqueeSelection == null) {
@@ -1668,7 +1668,7 @@
//FIXME: this is an in-elegant hack, but it gets the user out
// of custom brush mode
//(reset the brush if necessary)
- if(currentBrush instanceof CustomBrush) {
+ if (currentBrush instanceof CustomBrush) {
if (prefs.getBoolean("cursorhighlight", true)) {
Rectangle redraw = cursorHighlight.getBounds();
mapView.repaintRegion(redraw);
@@ -1960,10 +1960,12 @@
* @param tile the new tile to be selected
*/
public void setCurrentTile(Tile tile) {
+ resetBrush();
+
if (currentTile != tile) {
currentTile = tile;
if (!(currentBrush instanceof CustomBrush)) {
- ((ShapeBrush)currentBrush).setTile(tile);
+ ((ShapeBrush) currentBrush).setTile(tile);
}
tilePaletteButton.setTile(currentTile);
}
Modified: trunk/src/tiled/mapeditor/widget/TilePalettePanel.java
===================================================================
--- trunk/src/tiled/mapeditor/widget/TilePalettePanel.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/mapeditor/widget/TilePalettePanel.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -88,7 +88,7 @@
*/
public void setTileset(TileSet tileset) {
this.tileset = tileset;
- if(tileset!=null) tilesetMap = tileset.generateGaplessVector();
+ if (tileset != null) tilesetMap = tileset.generateGaplessVector();
revalidate();
repaint();
}
Modified: trunk/src/tiled/view/HexMapView.java
===================================================================
--- trunk/src/tiled/view/HexMapView.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/view/HexMapView.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -65,7 +65,7 @@
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return (visibleRect.height / tsize.height) * tsize.height;
@@ -76,7 +76,7 @@
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return tsize.height;
} else {
@@ -85,7 +85,7 @@
}
public Dimension getPreferredSize() {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
int border = showGrid ? 1 : 0;
int wbhc = (int) getWidthBetweenHexCentres();
@@ -95,9 +95,9 @@
tsize.height / 2);
}
- protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
+ protected void paintLayer(Graphics2D g2d, TileLayer layer) {
// Determine area to draw from clipping rectangle
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
int toffset = showGrid ? 1 : 0;
Rectangle clipRect = g2d.getClipBounds();
@@ -137,7 +137,7 @@
}
}
- protected void paintLayer(Graphics2D g2d, ObjectGroup og, double zoom) {
+ protected void paintLayer(Graphics2D g2d, ObjectGroup og) {
}
/**
@@ -148,15 +148,15 @@
return map.getTileWidth() * 3 / 4;
}
- private Dimension getTileSize(double zoom) {
+ private Dimension getTileSize() {
return new Dimension(
(int)(map.getTileWidth() * zoom),
(int)(map.getTileHeight() * zoom));
}
- protected void paintGrid(Graphics2D g2d, double zoom) {
+ protected void paintGrid(Graphics2D g2d) {
g2d.setColor(Color.black);
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
// Determine area to draw from clipping rectangle
Rectangle clipRect = g2d.getClipBounds();
Point topLeft = screenToTileCoords(
@@ -184,7 +184,7 @@
}
}
- protected void paintCoordinates(Graphics2D g2d, double zoom) {
+ protected void paintCoordinates(Graphics2D g2d) {
// TODO: Implement paintCoordinates for HexMapView
}
@@ -246,8 +246,8 @@
* Get the point at the top left corner of the bounding rectangle of this
* hex.
*/
- private Point2D getTopLeftCornerOfHex(int x, int y, double zoom) {
- Dimension tileSize = getTileSize(zoom);
+ private Point2D getTopLeftCornerOfHex(int x, int y) {
+ Dimension tileSize = getTileSize();
Point2D centre = tileToScreenCoords(x, y);
double leftX = centre.getX() - tileSize.getWidth() / 2;
double topY = centre.getY() - tileSize.getHeight() / 2;
@@ -276,7 +276,7 @@
protected Polygon createGridPolygon(int tx, int ty, int border) {
double centrex, centrey;
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
Polygon poly = new Polygon();
centrex = tx*tileSize.getWidth() + tileSize.getWidth() / 2;
Modified: trunk/src/tiled/view/IsoMapView.java
===================================================================
--- trunk/src/tiled/view/IsoMapView.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/view/IsoMapView.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -37,7 +37,7 @@
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return (visibleRect.height / tsize.height) * tsize.height;
} else {
@@ -47,7 +47,7 @@
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return tsize.height;
} else {
@@ -55,13 +55,13 @@
}
}
- protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
+ protected void paintLayer(Graphics2D g2d, TileLayer layer) {
// Turn anti alias on for selection drawing
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Rectangle clipRect = g2d.getClipBounds();
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
int tileStepY = tileSize.height / 2 == 0 ? 1 : tileSize.height / 2;
Polygon gridPoly = createGridPolygon(0, -tileSize.height, 0);
@@ -115,12 +115,12 @@
}
}
- protected void paintLayer(Graphics2D g2d, ObjectGroup og, double zoom) {
+ protected void paintLayer(Graphics2D g2d, ObjectGroup og) {
// TODO: Implement objectgroup painting for IsoMapView
}
- protected void paintGrid(Graphics2D g2d, double zoom) {
- Dimension tileSize = getTileSize(zoom);
+ protected void paintGrid(Graphics2D g2d) {
+ Dimension tileSize = getTileSize();
Rectangle clipRect = g2d.getClipBounds();
clipRect.x -= tileSize.width / 2;
@@ -148,12 +148,12 @@
}
}
- protected void paintCoordinates(Graphics2D g2d, double zoom) {
+ protected void paintCoordinates(Graphics2D g2d) {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
Rectangle clipRect = g2d.getClipBounds();
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
int tileStepY = tileSize.height / 2 == 0 ? 1 : tileSize.height / 2;
Font font = new Font("SansSerif", Font.PLAIN, tileSize.height / 4);
g2d.setFont(font);
@@ -205,7 +205,7 @@
}
public void repaintRegion(Rectangle region) {
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
int maxExtraHeight =
(int)(map.getTileHeightMax() * zoom) - tileSize.height;
@@ -223,7 +223,7 @@
}
public Dimension getPreferredSize() {
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
int border = showGrid ? 1 : 0;
int mapSides = map.getHeight() + map.getWidth();
@@ -236,7 +236,7 @@
* Returns the coordinates of the tile at the given screen coordinates.
*/
public Point screenToTileCoords(int x, int y) {
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
double r = getTileRatio();
// Translate origin to top-center
@@ -252,7 +252,7 @@
}
protected Polygon createGridPolygon(int tx, int ty, int border) {
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
tileSize.width -= border * 2;
tileSize.height -= border * 2;
@@ -265,7 +265,7 @@
return poly;
}
- protected Dimension getTileSize(double zoom) {
+ protected Dimension getTileSize() {
return new Dimension(
(int)(map.getTileWidth() * zoom),
(int)(map.getTileHeight() * zoom));
@@ -279,7 +279,7 @@
* Returns the location on the screen of the top corner of a tile.
*/
public Point tileToScreenCoords(double x, double y) {
- Dimension tileSize = getTileSize(zoom);
+ Dimension tileSize = getTileSize();
int originX = (map.getHeight() * tileSize.width) / 2;
return new Point(
(int)((x - y) * tileSize.width / 2) + originX,
Modified: trunk/src/tiled/view/MapView.java
===================================================================
--- trunk/src/tiled/view/MapView.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/view/MapView.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -225,7 +225,6 @@
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g.create();
- double currentZoom = zoom;
MapLayer layer;
Rectangle clip = g2d.getClipBounds();
@@ -255,7 +254,7 @@
g2d.setColor(
((SelectionLayer)layer).getHighlightColor());
}
- paintLayer(g2d, (TileLayer)layer, currentZoom);
+ paintLayer(g2d, (TileLayer)layer);
}
}
@@ -288,19 +287,18 @@
}
g2d.setStroke(new BasicStroke());
- paintGrid(g2d, currentZoom);
+ paintGrid(g2d);
}
if (getMode(PF_COORDINATES)) {
g2d.setComposite(AlphaComposite.SrcOver);
- paintCoordinates(g2d, zoom);
+ paintCoordinates(g2d);
}
}
public void paintSubMap(MultilayerPlane m, Graphics2D g2d, float mapOpacity) {
Iterator li = m.getLayers();
MapLayer layer;
- double currentZoom = zoom;
if (g2d == null) {
g2d = (Graphics2D)getGraphics().create();
@@ -319,9 +317,9 @@
}
if (layer instanceof TileLayer) {
- paintLayer(g2d, (TileLayer)layer, currentZoom);
+ paintLayer(g2d, (TileLayer)layer);
} else if (layer instanceof ObjectGroup) {
- paintLayer(g2d, (ObjectGroup)layer, currentZoom);
+ paintLayer(g2d, (ObjectGroup)layer);
}
}
}
@@ -332,19 +330,15 @@
* Draws a TileLayer. Implemented in a subclass.
*
* @param layer the TileLayer to be drawn
- * @param zoom the zoom level to draw the layer on
*/
- protected abstract void paintLayer(Graphics2D g2d, TileLayer layer,
- double zoom);
+ protected abstract void paintLayer(Graphics2D g2d, TileLayer layer);
/**
* Draws an ObjectGroup. Implemented in a subclass.
*
* @param og the ObjectGroup to be drawn
- * @param zoom the zoom level to draw the layer on
*/
- protected abstract void paintLayer(Graphics2D g2d, ObjectGroup og,
- double zoom);
+ protected abstract void paintLayer(Graphics2D g2d, ObjectGroup og);
protected void paintEdge(Graphics2D g2d, MapLayer layer, int x, int y) {
/*
@@ -416,12 +410,12 @@
/**
* Draws the map grid.
*/
- protected abstract void paintGrid(Graphics2D g2d, double zoom);
+ protected abstract void paintGrid(Graphics2D g2d);
/**
* Draws the coordinates on each tile.
*/
- protected abstract void paintCoordinates(Graphics2D g2d, double zoom);
+ protected abstract void paintCoordinates(Graphics2D g2d);
/**
* Returns a Polygon that matches the grid around the specified <b>Map</b>
Modified: trunk/src/tiled/view/ObliqueMapView.java
===================================================================
--- trunk/src/tiled/view/ObliqueMapView.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/view/ObliqueMapView.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -53,19 +53,19 @@
return new Dimension(0, 0);
}
- protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
+ protected void paintLayer(Graphics2D g2d, TileLayer layer) {
// TODO Auto-generated method stub
}
- protected void paintLayer(Graphics2D g2d, ObjectGroup og, double zoom) {
+ protected void paintLayer(Graphics2D g2d, ObjectGroup og) {
// TODO Auto-generated method stub
}
- protected void paintGrid(Graphics2D g2d, double zoom) {
+ protected void paintGrid(Graphics2D g2d) {
// TODO: Implement paintGrid for ObliqueMapView
}
- protected void paintCoordinates(Graphics2D g2d, double zoom) {
+ protected void paintCoordinates(Graphics2D g2d) {
// TODO: Implement paintCoordinates for ObliqueMapView
}
Modified: trunk/src/tiled/view/OrthoMapView.java
===================================================================
--- trunk/src/tiled/view/OrthoMapView.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/view/OrthoMapView.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -45,7 +45,7 @@
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return (visibleRect.height / tsize.height) * tsize.height;
@@ -56,7 +56,7 @@
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return tsize.height;
} else {
@@ -65,16 +65,16 @@
}
public Dimension getPreferredSize() {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
return new Dimension(
map.getWidth() * tsize.width,
map.getHeight() * tsize.height);
}
- protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
+ protected void paintLayer(Graphics2D g2d, TileLayer layer) {
// Determine tile size and offset
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (tsize.width <= 0 || tsize.height <= 0) return;
Polygon gridPoly = createGridPolygon(0, -tsize.height, 0);
@@ -107,7 +107,7 @@
}
}
- protected void paintLayer(Graphics2D g, ObjectGroup og, double zoom) {
+ protected void paintLayer(Graphics2D g, ObjectGroup og) {
Iterator itr = og.getObjects();
while (itr.hasNext()) {
@@ -124,9 +124,9 @@
}
}
- protected void paintGrid(Graphics2D g2d, double zoom) {
+ protected void paintGrid(Graphics2D g2d) {
// Determine tile size
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (tsize.width <= 0 || tsize.height <= 0) return;
// Determine lines to draw from clipping rectangle
@@ -144,8 +144,8 @@
}
}
- protected void paintCoordinates(Graphics2D g2d, double zoom) {
- Dimension tsize = getTileSize(zoom);
+ protected void paintCoordinates(Graphics2D g2d) {
+ Dimension tsize = getTileSize();
if (tsize.width <= 0 || tsize.height <= 0) return;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
@@ -182,7 +182,7 @@
}
public void repaintRegion(Rectangle region) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (tsize.width <= 0 || tsize.height <= 0) return;
int maxExtraHeight =
(int)(map.getTileHeightMax() * zoom - tsize.height);
@@ -200,18 +200,18 @@
}
public Point screenToTileCoords(int x, int y) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
return new Point(x / tsize.width, y / tsize.height);
}
- protected Dimension getTileSize(double zoom) {
+ protected Dimension getTileSize() {
return new Dimension(
(int)(map.getTileWidth() * zoom),
(int)(map.getTileHeight() * zoom));
}
protected Polygon createGridPolygon(int tx, int ty, int border) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
Polygon poly = new Polygon();
poly.addPoint(tx - border, ty - border);
@@ -223,7 +223,7 @@
}
public Point tileToScreenCoords(double x, double y) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
return new Point((int)x * tsize.width, (int)y * tsize.height);
}
}
Modified: trunk/src/tiled/view/ShiftedMapView.java
===================================================================
--- trunk/src/tiled/view/ShiftedMapView.java 2006-06-10 17:46:53 UTC (rev 664)
+++ trunk/src/tiled/view/ShiftedMapView.java 2006-06-10 19:57:26 UTC (rev 665)
@@ -53,7 +53,7 @@
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction) {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (orientation == SwingConstants.VERTICAL) {
return tsize.height - (tsize.height - (int) (verSide * zoom)) / 2;
} else {
@@ -62,7 +62,7 @@
}
public Dimension getPreferredSize() {
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
int border = showGrid ? 1 : 0;
int onceX = (tsize.width - (int)(horSide * zoom)) / 2;
int repeatX = tsize.width - onceX;
@@ -74,15 +74,15 @@
map.getHeight() * repeatY + onceY + border);
}
- protected void paintLayer(Graphics2D g2d, TileLayer layer, double zoom) {
+ protected void paintLayer(Graphics2D g2d, TileLayer layer) {
}
- protected void paintLayer(Graphics2D g2d, ObjectGroup layer, double zoom) {
+ protected void paintLayer(Graphics2D g2d, ObjectGroup og) {
}
- protected void paintGrid(Graphics2D g2d, double zoom) {
+ protected void paintGrid(Graphics2D g2d) {
// Determine tile size
- Dimension tsize = getTileSize(zoom);
+ Dimension tsize = getTileSize();
if (tsize.width <= 0 || tsize.height <= 0) return;
int onceX = (tsize.width - (int)(horSide * zoom)) / 2;
int repeatX = tsize.width - onceX;
@@ -99,7 +99,7 @@
int p = startY * repeatY;
// These are temp debug lines not the real grid, draw in light gray
- Color gridColor = g2d.getColor();
+ Color prevColor = g2d.getColor();
g2d.setColor(Color.gray);
for (int y = startY; y < endY; y++) {
@@ -112,10 +112,10 @@
p += repeatX;
}
- g2d.setColor(gridColor);
+ g2d.setColor(prevColor);
}
- protected void paintCoordinates(Graphics2D g2d, double zoom) {
+ protected void paintCoordinates(Graphics2D g2d) {
}
public void repaintRegion(Rectangle region) {
@@ -125,7 +125,7 @@
return new Point(0, 0);
}
- protected Dimension getTileSize(double zoom) {
+ protected Dimension getTileSize() {
return new Dimension(
(int)(map.getTileWidth() * zoom),
(int)(map.getTileHeight() * zoom));
More information about the tiled-commit
mailing list