From: <aki...@us...> - 2007-09-09 08:50:13
|
Revision: 3013 http://gridarta.svn.sourceforge.net/gridarta/?rev=3013&view=rev Author: akirschbaum Date: 2007-09-09 01:50:14 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Refactor duplicated code into function. 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-09-08 23:12:32 UTC (rev 3012) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-09-09 08:50:14 UTC (rev 3013) @@ -90,12 +90,8 @@ public void mapSquaresChanged(final MapModelEvent<GameObject, MapArchObject, Archetype> e) { final MapSquare<GameObject, MapArchObject, Archetype>[] squares = e.getSquares(); if (squares != null) { - final Point point = new Point(); for (final MapSquare<GameObject, MapArchObject, Archetype> square : squares) { - point.x = square.getMapX(); - point.y = square.getMapY(); - updateTile(point); - repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); + paintSquare(square); } } } @@ -104,15 +100,11 @@ public void mapObjectsChanged(final MapModelEvent<GameObject, MapArchObject, Archetype> e) { final GameObject[] gameObjects = e.getGameObjects(); if (gameObjects != null) { - final Point point = new Point(); for (final GameObject gameObject : gameObjects) { if (!gameObject.isInContainer()) { final MapSquare<GameObject, MapArchObject, Archetype> square = gameObject.getMapSquare(); if (square != null) { - point.x = square.getMapX(); - point.y = square.getMapY(); - updateTile(point); - repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); + paintSquare(square); } } } @@ -239,6 +231,15 @@ } /** + * Paint one square. + * @param square The square to paint. + */ + private void paintSquare(@NotNull final MapSquare<GameObject, MapArchObject, Archetype> square) { + updateTile(new Point(square.getMapX(), square.getMapY())); + repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); + } + + /** * Paints this component. * @param grfx the graphics context to paint to * @param isSnapshot true when this drawing is for a "screenshot"-image, false for normal drawing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-09-09 09:00:13
|
Revision: 3014 http://gridarta.svn.sourceforge.net/gridarta/?rev=3014&view=rev Author: akirschbaum Date: 2007-09-09 02:00:16 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Replace pair of int variables with Point. 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-09-09 08:50:14 UTC (rev 3013) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-09-09 09:00:16 UTC (rev 3014) @@ -309,18 +309,19 @@ * @param grfx the graphics context to draw in */ private void paintMapSelection(final Graphics grfx) { - for (int y = 0; y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - if (grfx.hitClip(borderOffset.x + x * 32, borderOffset.y + y * 32, 32, 32)) { - final int gridFlags = mapGrid.getFlags(x, y); + final Point point = new Point(); + for (point.y = 0; point.y < mapSize.getHeight(); point.y++) { + for (point.x = 0; point.x < mapSize.getWidth(); point.x++) { + if (grfx.hitClip(borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, 32, 32)) { + final int gridFlags = mapGrid.getFlags(point.x, point.y); if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + x * 32, borderOffset.y + y * 32); + CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + x * 32, borderOffset.y + y * 32); + CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { - CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + x * 32, borderOffset.y + y * 32); + CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-09-09 09:03:52
|
Revision: 3016 http://gridarta.svn.sourceforge.net/gridarta/?rev=3016&view=rev Author: akirschbaum Date: 2007-09-09 02:03:55 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Properly repaint erroneous map tiles. 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-09-09 09:02:19 UTC (rev 3015) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-09-09 09:03:55 UTC (rev 3016) @@ -323,6 +323,9 @@ if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); } + if ((gridFlags & MapGrid.GRID_FLAG_ERROR) != 0) { + CMainControl.getWarningSquareIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-09-09 09:12:39
|
Revision: 3017 http://gridarta.svn.sourceforge.net/gridarta/?rev=3017&view=rev Author: akirschbaum Date: 2007-09-09 02:12:40 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Remove duplicated code. 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-09-09 09:03:55 UTC (rev 3016) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-09-09 09:12:40 UTC (rev 3017) @@ -313,19 +313,7 @@ for (point.y = 0; point.y < mapSize.getHeight(); point.y++) { for (point.x = 0; point.x < mapSize.getWidth(); point.x++) { if (grfx.hitClip(borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, 32, 32)) { - final int gridFlags = mapGrid.getFlags(point.x, point.y); - if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); - } - if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); - } - if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { - CMainControl.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); - } - if ((gridFlags & MapGrid.GRID_FLAG_ERROR) != 0) { - CMainControl.getWarningSquareIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); - } + paintTileSelection(grfx, point); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-31 22:08:23
|
Revision: 3791 http://gridarta.svn.sourceforge.net/gridarta/?rev=3791&view=rev Author: akirschbaum Date: 2008-03-31 15:08:09 -0700 (Mon, 31 Mar 2008) Log Message: ----------- Improve rendering performance. 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 2008-03-31 22:01:41 UTC (rev 3790) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-03-31 22:08:09 UTC (rev 3791) @@ -26,6 +26,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; +import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; @@ -79,6 +80,22 @@ /** The MapSquares that are known to contain errors. */ private Map<MapSquare<GameObject, MapArchObject, Archetype>, ValidationError<GameObject, MapArchObject, Archetype>> erroneousMapSquares; + private final Image selImg = SystemIcons.getMapSelIcon().getImage(); + + private final Image selImgNorth = SystemIcons.getMapSelIconNorth().getImage(); + + private final Image selImgEast = SystemIcons.getMapSelIconEast().getImage(); + + private final Image selImgSouth = SystemIcons.getMapSelIconSouth().getImage(); + + private final Image selImgWest = SystemIcons.getMapSelIconWest().getImage(); + + private final Image preSelImg = SystemIcons.getMapPreSelIcon().getImage(); + + private final Image cursorImg = SystemIcons.getMapCursorIcon().getImage(); + + private final Image warningSquareImg = SystemIcons.getWarningSquareIcon().getImage(); + /** * The map model listener to track changes in {@link #mapModel}. */ @@ -285,28 +302,28 @@ protected void paintTileSelection(final Graphics grfx, final Point point) { final int gridFlags = mapGrid.getFlags(point.x, point.y); if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - SystemIcons.getMapSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(selImg, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_NORTH) != 0) { - SystemIcons.getMapSelIconNorth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(selImgNorth, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_EAST) != 0) { - SystemIcons.getMapSelIconEast().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(selImgEast, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_SOUTH) != 0) { - SystemIcons.getMapSelIconSouth().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(selImgSouth, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTION_WEST) != 0) { - SystemIcons.getMapSelIconWest().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(selImgWest, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { - SystemIcons.getMapPreSelIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(preSelImg, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { - SystemIcons.getMapCursorIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(cursorImg, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } if ((gridFlags & MapGrid.GRID_FLAG_ERROR) != 0) { - SystemIcons.getWarningSquareIcon().paintIcon(this, grfx, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32); + grfx.drawImage(warningSquareImg, borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, this); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 13:29:52
|
Revision: 1110 http://svn.sourceforge.net/gridarta/?rev=1110&view=rev Author: akirschbaum Date: 2006-12-16 05:29:52 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Move code into separate functions. 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 2006-12-16 11:52:00 UTC (rev 1109) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 13:29:52 UTC (rev 1110) @@ -284,27 +284,10 @@ archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, node.getMapX() * 32 + borderOffset, node.getMapY() * 32 + borderOffset); } - // grid lines - if (mapViewBasic.isGridVisible() && !isSnapshot) { - for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { - grfx.drawLine( - x * 32 + borderOffset, - borderOffset, - x * 32 + borderOffset, - mapGrid.getSize().getHeight() * 32 + borderOffset); - } - for (int y = 0; y <= mapGrid.getSize().getHeight(); y++) { - grfx.drawLine( - borderOffset, - y * 32 + borderOffset, - mapGrid.getSize().getWidth() * 32 + borderOffset, - y * 32 + borderOffset); - } + if (!isSnapshot) { + paintGrid(grfx); + paintSelection(grfx); } - if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1 && !isSnapshot) { - // Highlight the selected area - paintHighlightArea(grfx); - } } /** @@ -470,6 +453,44 @@ } } + /** + * Paints the selection. + * It's recommended to paint the complete selection after the map itself, otherwise map elements actually might hide selections. + * @param grfx Graphics for painting + */ + private void paintSelection(final Graphics2D grfx) { + if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { + // Highlight the selected area + paintHighlightArea(grfx); + } + } + + /** + * Paints the grid if desired. + * The grid is not painted if <code><var>gridVisibility</var></code> is <code>false</code>. + * It's recommended to paint the complete grid after the map itself, otherwise map elements actually might hide parts of the grid. + * @param grfx Graphics for painting + */ + private void paintGrid(final Graphics grfx) { + // grid lines + if (mapViewBasic.isGridVisible()) { + for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { + grfx.drawLine( + x * 32 + borderOffset, + borderOffset, + x * 32 + borderOffset, + mapGrid.getSize().getHeight() * 32 + borderOffset); + } + for (int y = 0; y <= mapGrid.getSize().getHeight(); y++) { + grfx.drawLine( + borderOffset, + y * 32 + borderOffset, + mapGrid.getSize().getWidth() * 32 + borderOffset, + y * 32 + borderOffset); + } + } + } + /** {@inheritDoc} */ @Override @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <der...@us...> - 2006-12-17 10:22:01
|
Revision: 1124 http://svn.sourceforge.net/gridarta/?rev=1124&view=rev Author: derdanny Date: 2006-12-17 02:21:59 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Replaced x,y-pair with Point. 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 2006-12-17 00:53:47 UTC (rev 1123) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 10:21:59 UTC (rev 1124) @@ -246,35 +246,36 @@ // this vector contains all heads of multi-tiles with oversized images final Vector<GameObject> oversizedMultiHeads = new Vector<GameObject>(); final CFilterControl filter = mainControl.getFilterControl(); - for (int y = 0; y < mapGrid.getSize().getHeight(); y++) { - for (int x = 0; x < mapGrid.getSize().getWidth(); x++) { + final Point point = new Point(); + for (point.y = 0; point.y < mapGrid.getSize().getHeight(); point.y++) { + for (point.x = 0; point.x < mapGrid.getSize().getWidth(); point.x++) { filter.newSquare(); - if (!mapControl.getMapModel().containsArchObject(new Point(x, y))) { + if (!mapControl.getMapModel().containsArchObject(point)) { // empty square if (isPickmap) { - grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); + grfx.fillRect(point.x * 32 + borderOffset, point.y * 32 + borderOffset, 32, 32); } else { - CMainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } } else { - for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { + for (final GameObject node : mapControl.getMapModel().getMapSquare(point)) { filter.objectInSquare(node); if (!filter.canShow(node)) { continue; } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { if (node.getArchetypeName() == null) { - CMainControl.getNoarchTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getNoarchTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else if (node.getFaceFlag()) { - CMainControl.getNofaceTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getNofaceTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else { if (node.getFaceNr() == -1) { - CMainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else { // draw object face final ImageIcon img = archlist.getFace(node.getFaceNr()); if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else if (node.isHead()) { oversizedMultiHeads.addElement(node); // store oversized arches for later } @@ -290,7 +291,7 @@ final Color alpha = highLightMask[i]; final Color c = grfx.getColor(); grfx.setColor(alpha); - grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); + grfx.fillRect(point.x * 32 + borderOffset, point.y * 32 + borderOffset, 32, 32); grfx.setColor(c); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 16:06:36
|
Revision: 1150 http://svn.sourceforge.net/gridarta/?rev=1150&view=rev Author: akirschbaum Date: 2006-12-17 08:06:35 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Unify code. 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 2006-12-17 15:57:52 UTC (rev 1149) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 16:06:35 UTC (rev 1150) @@ -32,6 +32,7 @@ import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; +import cfeditor.map.MapModel; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; @@ -68,8 +69,6 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - private final MapControl mapControl; - private final CMapViewBasic mapViewBasic; // 32x32 Image and Icon for temprary storing tiles before drawing @@ -100,6 +99,8 @@ private final AffineTransform renderTransform; + private MapModel mapModel; + private Size2D mapSize = new Size2D(1, 1); private final MapGrid mapGrid; @@ -115,8 +116,8 @@ public DefaultLevelRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final boolean pickmap, final MapGrid mapGrid) { this.mapViewBasic = mapViewBasic; this.mainControl = mainControl; - this.mapControl = mapControl; - mapSize = mapControl.getMapModel().getMapSize(); + mapModel = mapControl.getMapModel(); + mapSize = mapModel.getMapSize(); this.mapGrid = mapGrid; final AttributeFilter af = new AttributeFilter(); @@ -169,7 +170,6 @@ /** {@inheritDoc} */ @Override public BufferedImage getFullImage() { - final Size2D mapSize = mapControl.getMapSize(); final int mapWidth = 32 * mapSize.getWidth(); final int mapHeight = 32 * mapSize.getHeight(); @@ -250,7 +250,7 @@ for (point.y = 0; point.y < mapGrid.getSize().getHeight(); point.y++) { for (point.x = 0; point.x < mapGrid.getSize().getWidth(); point.x++) { filter.newSquare(); - if (!mapControl.getMapModel().containsArchObject(point)) { + if (!mapModel.containsArchObject(point)) { // empty square if (isPickmap) { grfx.fillRect(point.x * 32 + borderOffset, point.y * 32 + borderOffset, 32, 32); @@ -258,7 +258,7 @@ CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } } else { - for (final GameObject node : mapControl.getMapModel().getMapSquare(point)) { + for (final GameObject node : mapModel.getMapSquare(point)) { filter.objectInSquare(node); if (!filter.canShow(node)) { continue; @@ -330,7 +330,7 @@ final CFilterControl filter = mainControl.getFilterControl(); filter.newSquare(); // first, draw the object's faces: - if (!mapControl.getMapModel().containsArchObject(point)) { + if (!mapModel.containsArchObject(point)) { // draw the empty-tile icon (direcly to the mapview) if (isPickmap) { grfx.setColor(IGUIConstants.BG_COLOR); @@ -341,7 +341,7 @@ } else { tmpGrfx.fillRect(0, 0, 32, 32); // loop through all arches on that square and draw em - for (final GameObject node : mapControl.getMapModel().getMapSquare(point)) { + for (final GameObject node : mapModel.getMapSquare(point)) { filter.objectInSquare(node); if (!filter.canShow(node)) { continue; @@ -379,7 +379,7 @@ } // We have been drawing to the tmp. buffer, now convert it to // an ImageIcon and paint it into the mapview: - if (mapControl.getMapModel().containsArchObject(point)) { + if (mapModel.containsArchObject(point)) { tmpIcon.setImage(tmpImage); tmpIcon.paintIcon(this, grfx, point.x * 32, point.y * 32); } @@ -481,7 +481,6 @@ } catch (final NoninvertibleTransformException e) { } - final Size2D mapSize = mapViewBasic.getMapControl().getMapSize(); final int xm, ym; if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { xm = point.x / 32; @@ -518,7 +517,6 @@ return false; } - final Size2D mapSize = mapControl.getMapSize(); final Dimension size = new Dimension(mapSize.getWidth() * 32, mapSize.getHeight() * 32); if (bufferedSize.equals(size)) { return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 19:10:12
|
Revision: 1166 http://svn.sourceforge.net/gridarta/?rev=1166&view=rev Author: akirschbaum Date: 2006-12-17 11:10:09 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove use of Graphics2D. 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 2006-12-17 18:34:18 UTC (rev 1165) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 19:10:09 UTC (rev 1166) @@ -36,14 +36,12 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionListener; -import java.awt.geom.AffineTransform; import java.awt.geom.NoninvertibleTransformException; import java.awt.image.BufferedImage; import java.util.Vector; @@ -95,8 +93,6 @@ /** Current size of {@link #backBuffer} image. */ private final Dimension bufferedSize = new Dimension(); - private final AffineTransform renderTransform; - private final MapModel mapModel; private final CMainControl mainControl; @@ -136,7 +132,6 @@ setFocusable(true); borderOffset.setLocation(pickmap ? 0 : 32, pickmap ? 0 : 32); - renderTransform = new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, borderOffset.x, borderOffset.y); highLightMask = new Color[]{ new Color(1.0f, 0.0f, 0.0f, 0.33f), new Color(0.0f, 1.0f, 0.0f, 0.33f), @@ -174,16 +169,16 @@ // paint the mapview into the image final Point storeOffset = new Point(borderOffset); borderOffset.setLocation(0, 0); - paintComponent((Graphics2D) bufGrfx, true); + paintComponent(bufGrfx, true); borderOffset.setLocation(storeOffset); return bufImage; } @Override public void paintComponent(final Graphics grfx) { if (isPickmap) { - paintComponent((Graphics2D) grfx, false); + paintComponent(grfx, false); } else { - ((Graphics2D) grfx).drawImage(backBuffer, renderTransform, null); + grfx.drawImage(backBuffer, borderOffset.x, borderOffset.y, null); } } @@ -196,7 +191,7 @@ log.debug("modelChanged(), we are in a backbuffered behaviour."); final Point storeOffset = new Point(borderOffset); borderOffset.setLocation(0, 0); - paintComponent((Graphics2D) backBuffer.getGraphics(), false); + paintComponent(backBuffer.getGraphics(), false); borderOffset.setLocation(storeOffset); repaint(); } @@ -223,7 +218,7 @@ * @param isSnapshot true when this drawing is for a * "screenshot"-image, false for normal drawing */ - public void paintComponent(final Graphics2D grfx, final boolean isSnapshot) { + public void paintComponent(final Graphics grfx, final boolean isSnapshot) { final ArchetypeSet archlist = mainControl.getArchetypeSet(); if (isPickmap) { @@ -420,7 +415,7 @@ * It's recommended to paint the complete selection after the map itself, otherwise map elements actually might hide selections. * @param grfx Graphics for painting */ - private void paintSelection(final Graphics2D grfx) { + private void paintSelection(final Graphics grfx) { for (int y = 0; y < mapSize.getHeight(); y++) { for (int x = 0; x < mapSize.getWidth(); x++) { if (grfx.hitClip(x * 32 + borderOffset.x, y * 32 + borderOffset.y, 32, 32)) { @@ -467,15 +462,10 @@ /** {@inheritDoc} */ @Override @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { - try { - renderTransform.inverseTransform(point, point); - } catch (final NoninvertibleTransformException e) { - } - final int xm, ym; - if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { - xm = point.x / 32; - ym = point.y / 32; + if (point.x >= borderOffset.x && point.x < mapSize.getWidth() * 32 + borderOffset.x && point.y >= borderOffset.y && point.y < mapSize.getHeight() * 32 + borderOffset.y) { + xm = (point.x - borderOffset.x) / 32; + ym = (point.y - borderOffset.y) / 32; } else { xm = -1; ym = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 21:30:19
|
Revision: 1176 http://svn.sourceforge.net/gridarta/?rev=1176&view=rev Author: akirschbaum Date: 2006-12-17 13:30:18 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Simplify code. 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 2006-12-17 21:24:26 UTC (rev 1175) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 21:30:18 UTC (rev 1176) @@ -190,18 +190,13 @@ } @Override public void modelChanged() { - if (isPickmap) { - //pickmaps don't have double buffers - //maybe later could have them share one single buffer ? - repaint(); - } else { - log.debug("modelChanged(), we are in a backbuffered behaviour."); + if (!isPickmap) { final Point storeOffset = new Point(borderOffset); borderOffset.setLocation(0, 0); paintComponent(backBuffer.getGraphics(), false); borderOffset.setLocation(storeOffset); - repaint(); } + repaint(); } private final Rectangle tmpRec = new Rectangle(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 01:08:55
|
Revision: 1471 http://svn.sourceforge.net/gridarta/?rev=1471&view=rev Author: akirschbaum Date: 2007-01-06 17:08:55 -0800 (Sat, 06 Jan 2007) Log Message: ----------- Fix some unchecked warnings. 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-07 01:04:55 UTC (rev 1470) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-07 01:08:55 UTC (rev 1471) @@ -377,7 +377,7 @@ } /** {@inheritDoc} */ - public void mapSquaresChanged(final MapModelEvent e) { + public void mapSquaresChanged(final MapModelEvent<GameObject, MapArchObject> e) { final MapSquare<GameObject, MapArchObject>[] squares = e.getSquares(); int minX = bufferedSize.width; int minY = bufferedSize.height; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-02-09 17:36:51
|
Revision: 1882 http://svn.sourceforge.net/gridarta/?rev=1882&view=rev Author: christianhujer Date: 2007-02-09 09:36:50 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Removed unneccessary qualifier for this. 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-02-09 17:35:51 UTC (rev 1881) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-02-09 17:36:50 UTC (rev 1882) @@ -448,7 +448,7 @@ if (isPickmap) { grfx.fillRect(point.x * 32, point.y * 32, 32, 32); } else { - CMainControl.getUnknownTileIcon().paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32, point.y * 32); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } } else { grfx.fillRect(point.x * 32, point.y * 32, 32, 32); @@ -470,7 +470,7 @@ offset.x = -32 * node.getMultiX(); offset.y = -32 * node.getMultiY(); } - img.paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32 + offset.x, point.y * 32 + offset.y); + img.paintIcon(this, grfx, point.x * 32 + offset.x, point.y * 32 + offset.y); } } for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-07-31 18:49:51
|
Revision: 2797 http://gridarta.svn.sourceforge.net/gridarta/?rev=2797&view=rev Author: akirschbaum Date: 2007-07-31 11:49:53 -0700 (Tue, 31 Jul 2007) Log Message: ----------- Reduce number of allocations when painting. 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-07-31 18:45:32 UTC (rev 2796) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-07-31 18:49:53 UTC (rev 2797) @@ -68,6 +68,9 @@ /** Set if the grid should be rendered. */ private boolean gridVisible = false; + /** Used to avoid creation millions of points. */ + private final Point tmpPoint = new Point(); + /** * The map model listener to track changes in {@link #mapModel}. */ @@ -262,11 +265,10 @@ * @param checkClip if set, omit tiles outside <code>grfx</code>'s clip area */ private void paintMap(final Graphics grfx, final boolean checkClip) { - final Point point = new Point(); - for (point.y = 0; point.y < mapGrid.getSize().getHeight(); point.y++) { - for (point.x = 0; point.x < mapGrid.getSize().getWidth(); point.x++) { - if (!checkClip || grfx.hitClip(borderOffset.x + point.x * 32, borderOffset.y + point.y * 32, 32, 32)) { - paintTile(grfx, point); + for (tmpPoint.y = 0; tmpPoint.y < mapGrid.getSize().getHeight(); tmpPoint.y++) { + for (tmpPoint.x = 0; tmpPoint.x < mapGrid.getSize().getWidth(); tmpPoint.x++) { + if (!checkClip || grfx.hitClip(borderOffset.x + tmpPoint.x * 32, borderOffset.y + tmpPoint.y * 32, 32, 32)) { + paintTile(grfx, tmpPoint); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-09-09 09:02:15
|
Revision: 3015 http://gridarta.svn.sourceforge.net/gridarta/?rev=3015&view=rev Author: akirschbaum Date: 2007-09-09 02:02:19 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Whitespace 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-09-09 09:00:16 UTC (rev 3014) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-09-09 09:02:19 UTC (rev 3015) @@ -235,8 +235,8 @@ * @param square The square to paint. */ private void paintSquare(@NotNull final MapSquare<GameObject, MapArchObject, Archetype> square) { - updateTile(new Point(square.getMapX(), square.getMapY())); - repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); + updateTile(new Point(square.getMapX(), square.getMapY())); + repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |