From: <aki...@us...> - 2007-01-23 23:03:57
|
Revision: 1691 http://svn.sourceforge.net/gridarta/?rev=1691&view=rev Author: akirschbaum Date: 2007-01-23 15:03:58 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Cleanup code. No functional 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:46:35 UTC (rev 1690) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 23:03:58 UTC (rev 1691) @@ -276,62 +276,52 @@ /** * 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 - * @param checkClip if set, omit tiles outside <code>grfx</code>'s clip - * area + * @param isSnapshot true when this drawing is for a "screenshot"-image, false for normal drawing + * @param checkClip if set, omit tiles outside <code>grfx</code>'s clip area */ private void paintComponent(final Graphics grfx, final boolean isSnapshot, final boolean checkClip) { setColor(grfx); grfx.fillRect(0, 0, getWidth(), getHeight()); - 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(point.x * 32, point.y * 32, 32, 32)) { - paintTile(grfx, point); - } - } - } - + paintMap(grfx, checkClip); if (!isSnapshot) { - paintGrid(grfx); - paintSelection(grfx); + paintMapGrid(grfx); + paintMapSelection(grfx); } } /** - * Paints only one tile of the map. This is an incredible time-saver - * for insert/select/delete tile actions. - * <p/> - * Important: This method currently works only for standard - * (rectangular) view. Iso has overlapping tiles which makes this a lot - * more difficult. :( - * @param point Map coordinates for the tile to draw + * Paint one square of the map. + * @param point the map coordinates of the square to draw */ private void paintTile(final Point point) { assert !isPickmap; final Graphics grfx = backBuffer.getGraphics(); paintTile(grfx, point); + paintTileGrid(grfx, point); + paintTileSelection(grfx, point); + } - // if grid is active, draw grid lines (right and bottom) + /** + * Paint the grid for one square. The grid is not painted if it is + * disabled. + * @param grfx the graphics context to draw in + * @param point the map coordinates of the square to draw + */ + private void paintTileGrid(final Graphics grfx, final Point point) { if (mapViewBasic.isGridVisible()) { // horizontal: grfx.drawLine(point.x * 32, point.y * 32, point.x * 32, point.y * 32 + 32); // vertical: grfx.drawLine(point.x * 32, point.y * 32, point.x * 32 + 32, point.y * 32); } - - // if tile is highlighted, draw the highlight icon - paintHighlightTile(grfx, point); } /** - * If the given map-square is highlighted, the highligh-icon is drawn - * on that square. - * @param point Map coordinates of the square to highlight - * @param grfx graphics context to draw in + * Paint the selection for one square. + * @param grfx the graphics context to draw in + * @param point map coordinates of the square to highlight */ - private void paintHighlightTile(final Graphics grfx, final Point point) { + private void paintTileSelection(final Graphics grfx, final Point point) { final int gridFlags = mapGrid.getFlags(point.x, point.y); if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); @@ -345,11 +335,26 @@ } /** - * 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 + * Paint the whole map. + * @param grfx the graphics context to draw in + * @param checkClip if set, omit tiles outside <code>grfx</code>'s clip area */ - private void paintSelection(final Graphics grfx) { + 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(point.x * 32, point.y * 32, 32, 32)) { + paintTile(grfx, point); + } + } + } + } + + /** + * Paint the selection for the whole map. + * @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(x * 32, y * 32, 32, 32)) { @@ -369,12 +374,11 @@ } /** - * 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 + * Paint the grid of the whole map. The grid is not painted if it is + * disabled. + * @param grfx the graphics context to draw in */ - private void paintGrid(final Graphics grfx) { + private void paintMapGrid(final Graphics grfx) { // grid lines if (mapViewBasic.isGridVisible()) { for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { @@ -444,7 +448,6 @@ } private void paintTile(final Graphics grfx, final Point point) { - // ---------- draw tile for rectangular view (non-iso) -------------- filter.newSquare(); setColor(grfx); if (!mapModel.containsArchObject(point)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |