From: <aki...@us...> - 2007-01-23 22:46:34
|
Revision: 1690 http://svn.sourceforge.net/gridarta/?rev=1690&view=rev Author: akirschbaum Date: 2007-01-23 14:46:35 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Prevent overwriting of foreground windows. Minimize area to redraw after changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 22:17:15 UTC (rev 1689) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 22:46:35 UTC (rev 1690) @@ -98,46 +98,45 @@ private final MapModelListener<GameObject, MapArchObject> mapModelListener = new MapModelListener<GameObject, MapArchObject>() { /** {@inheritDoc} */ - public void mapSizeChanged(final MapModelEvent e) { + public void mapSizeChanged(final MapModelEvent<GameObject, MapArchObject> e) { // ignore: will trigger an mapGridChanged() callback } /** {@inheritDoc} */ public void mapSquaresChanged(final MapModelEvent<GameObject, MapArchObject> e) { final MapSquare<GameObject, MapArchObject>[] squares = e.getSquares(); - int minX = bufferedSize.width; - int minY = bufferedSize.height; - int maxX = 0; - int maxY = 0; if (squares != null) { + final Point point = new Point(); for (final MapSquare square : squares) { - final int x = square.getMapX(); - final int y = square.getMapY(); - paintTile(new Point(x, y)); - - if (minX > x) { - minX = x; + if (!isPickmap) { + point.x = square.getMapX(); + point.y = square.getMapY(); + paintTile(point); } - if (minY > y) { - minY = y; - } - if (maxX < x) { - maxX = x; - } - if (maxY < y) { - maxY = y; - } + repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); } } - - if (!isPickmap && minX <= maxX && minY <= maxY) { - repaint(0, borderOffset.x + minX * 32, borderOffset.y + minY * 32, (maxX + 1 - minX) * 32, (maxY + 1 - minY) * 32); - } } /** {@inheritDoc} */ - public void mapObjectsChanged(final MapModelEvent e) { - modelChanged(); + public void mapObjectsChanged(final MapModelEvent<GameObject, MapArchObject> e) { + final GameObject[] gameObjects = e.getGameObjects(); + if (gameObjects != null) { + final Point point = new Point(); + for (final GameObject gameObject : gameObjects) { + if (!gameObject.isInContainer()) { + final MapSquare square = gameObject.getMapSquare(); + if (square != null) { + if (!isPickmap) { + point.x = square.getMapX(); + point.y = square.getMapY(); + paintTile(point); + } + repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); + } + } + } + } } /** {@inheritDoc} */ @@ -155,15 +154,15 @@ /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { final Rectangle recChange = mapGrid.getRecChange(); - for (int x = recChange.x; x < recChange.x + recChange.width; x++) { - for (int y = recChange.y; y < recChange.y + recChange.height; y++) { - paintTile(new Point(x, y)); + if (!isPickmap) { + final Point point = new Point(); + for (point.x = recChange.x; point.x < recChange.x + recChange.width; point.x++) { + for (point.y = recChange.y; point.y < recChange.y + recChange.height; point.y++) { + paintTile(point); + } } } - - if (!isPickmap) { - repaint(0, borderOffset.x + recChange.x * 32, borderOffset.y + recChange.y * 32, recChange.width * 32, recChange.height * 32); - } + repaint(0, borderOffset.x + recChange.x * 32, borderOffset.y + recChange.y * 32, recChange.width * 32, recChange.height * 32); } /** {@inheritDoc} */ @@ -310,13 +309,8 @@ * @param point Map coordinates for the tile to draw */ private void paintTile(final Point point) { - final Graphics grfx; - if (isPickmap) { - grfx = getGraphics(); // graphics context for drawing in the mapview - } else { - grfx = backBuffer.getGraphics(); - } - + assert !isPickmap; + final Graphics grfx = backBuffer.getGraphics(); paintTile(grfx, point); // if grid is active, draw grid lines (right and bottom) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |