From: <aki...@us...> - 2008-07-21 18:14:05
|
Revision: 4368 http://gridarta.svn.sourceforge.net/gridarta/?rev=4368&view=rev Author: akirschbaum Date: 2008-07-21 18:14:13 +0000 (Mon, 21 Jul 2008) Log Message: ----------- Make parameter @NotNull. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java 2008-07-21 18:09:30 UTC (rev 4367) +++ trunk/src/app/net/sf/gridarta/gui/DefaultObjectChooser.java 2008-07-21 18:14:13 UTC (rev 4368) @@ -158,7 +158,10 @@ // this is the arch that would get inserted from pickmap, but it also could // be a default arch (when pickmap has no selection) final G newarch = activePickmap == null ? null : activePickmap.getMapViewFrame().getSelectedGameObject(); - if (newarch == null || !newarch.isArchetype()) { + if (newarch == null) { + return null; + } + if (!newarch.isArchetype()) { return mapControl.getMapModel().addArchToPickmap(pos, allowMany, newarch); } } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-07-21 18:09:30 UTC (rev 4367) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-07-21 18:14:13 UTC (rev 4368) @@ -746,12 +746,7 @@ /** {@inheritDoc} */ @Nullable - public G addArchToPickmap(final Point pos, final boolean allowMany, final G newarch) { - // insert custom arch from the pickmap: - if (newarch == null) { - return null; - } - + public G addArchToPickmap(final Point pos, final boolean allowMany, @NotNull final G newarch) { if (!allowMany) { // check if there is already an arch of that kind for (final G t : getMapSquare(pos)) { Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-07-21 18:09:30 UTC (rev 4367) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-07-21 18:14:13 UTC (rev 4368) @@ -347,7 +347,7 @@ G addArchToMap(String archName, Point pos, boolean allowDouble, boolean join, boolean insertBelow); @Nullable - G addArchToPickmap(Point pos, boolean allowMany, G newarch); + G addArchToPickmap(Point pos, boolean allowMany, @NotNull G newarch); /** * Checks whether an GameObject (multi-arch) would still fit on this map. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-21 19:06:09
|
Revision: 4380 http://gridarta.svn.sourceforge.net/gridarta/?rev=4380&view=rev Author: akirschbaum Date: 2008-07-21 19:06:17 +0000 (Mon, 21 Jul 2008) Log Message: ----------- Clean up code for inserting objects into maps. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-07-21 18:52:54 UTC (rev 4379) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-07-21 19:06:17 UTC (rev 4380) @@ -364,7 +364,7 @@ // insert replacement object if (randomArch.isMulti()) { // multi's cannot be inserted properly, so we just put them ontop - mapControl.getMapModel().addArchToMap(randomArch.getArchetypeName(), new Point(square.getMapX(), square.getMapY()), false, false, false); + mapControl.getMapModel().insertArchetype(randomArch.getArchetypeName(), new Point(square.getMapX(), square.getMapY()), false, false, false); // TODO: if from pickmap it could have special attributes -> copy them } else { Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-07-21 18:52:54 UTC (rev 4379) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-07-21 19:06:17 UTC (rev 4380) @@ -348,7 +348,7 @@ */ @Nullable public G insertSelectedArchetype(final MapModel<G, A, R> mapModel, final Point pos, final boolean allowMany) { - return selectedArch == null ? null : mapModel.addArchToMap(selectedArch.getArchetypeName(), pos, allowMany, true, false); + return selectedArch == null ? null : mapModel.insertArchetype(selectedArch.getArchetypeName(), pos, allowMany, true, false); } } // class ArchetypeChooserControl Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-07-21 18:52:54 UTC (rev 4379) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-07-21 19:06:17 UTC (rev 4380) @@ -399,8 +399,8 @@ */ @Nullable public G insertSelectedObject(final MapModel<G, A, R> mapModel, final Point pos, final boolean allowMany) { - final G selectedArchetype = getSelection(); - return selectedArchetype == null ? null : mapModel.addArchToPickmap(pos, allowMany, selectedArchetype); + final G gameObject = getSelection(); + return gameObject == null ? null : mapModel.insertGameObject(gameObject, pos, allowMany); } } // class PickmapChooserControl Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-07-21 18:52:54 UTC (rev 4379) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-07-21 19:06:17 UTC (rev 4380) @@ -634,7 +634,7 @@ // put arch on the map if (newObject.isArchetype()) { - newGameObject = addArchToMap(newObject.getArchetypeName(), pos, true, join, false); + newGameObject = insertArchetype(newObject.getArchetypeName(), pos, true, join, false); if (newGameObject == null) { return null; } @@ -683,12 +683,12 @@ /** {@inheritDoc} */ @Nullable - public G addArchToMap(final String archName, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { - if (archName == null || archName.length() == 0 || !isPointValid(pos)) { + public G insertArchetype(@Nullable final String archetypeName, @NotNull final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { + if (archetypeName == null || archetypeName.length() == 0 || !isPointValid(pos)) { return null; } - R archetype = mainControl.getArchetypeSet().getArchetype(archName); + R archetype = mainControl.getArchetypeSet().getArchetype(archetypeName); if (archetype == null) { return null; } @@ -746,28 +746,28 @@ /** {@inheritDoc} */ @Nullable - public G addArchToPickmap(final Point pos, final boolean allowMany, @NotNull final G newarch) { + public G insertGameObject(@NotNull final G gameObject, @NotNull final Point pos, final boolean allowMany) { if (!allowMany) { // check if there is already an arch of that kind for (final G t : getMapSquare(pos)) { - if (t.hasSameArchetype(newarch) || t.getArchTypNr() == newarch.getArchTypNr()) { + if (t.hasSameArchetype(gameObject) || t.getArchTypNr() == gameObject.getArchTypNr()) { // there's a match - don't insert a second one return null; } } } - if (!newarch.isMulti()) { + if (!gameObject.isMulti()) { // insert single tile from pickmap - final G newObject = newarch.createClone(pos.x, pos.y); + final G newObject = gameObject.createClone(pos.x, pos.y); addGameObjectToMap(newObject, false); return newObject; } // insert multi tile from pickmap: - final G newarchHead = newarch.getHead(); + final G newarchHead = gameObject.getHead(); // first insert default arch from archlist - final G newObject = addArchToMap(newarchHead.getArchetypeName(), pos, allowMany, false, false); + final G newObject = insertArchetype(newarchHead.getArchetypeName(), pos, allowMany, false, false); if (newObject != null) { newObject.setObjectText(newarchHead.getObjectText()); newObject.setObjName(newarchHead.getObjName()); @@ -856,7 +856,7 @@ /** {@inheritDoc} */ public void addCopyToMap(final G gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { if (gameObject.isArchetype()) { - addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); + insertArchetype(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); } else { final G newGameObject = gameObject.createMultiClone(pos.x, pos.y); for (G tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-07-21 18:52:54 UTC (rev 4379) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-07-21 19:06:17 UTC (rev 4380) @@ -324,13 +324,12 @@ void setState(@NotNull MapState<G, A, R> mapState); /** - * Create a game object and add it to the map. This function allows only to - * choose from the default arches (->archName). This function also works for - * multi tile arches. - * @param archName Name of a default arch on the ArchetypeSet - * @param pos insert-location on this map - * @param allowDouble if set, only one arch of the same kind can be inserted - * per square + * Creates a game object and adds it to the map. + * @param archetypeName name of an archetype; does nothing if + * <code>null</code> or empty + * @param pos the insert-location on this map + * @param allowDouble if set, only one arch of the same kind can be + * inserted per square * @param join if set, auto-joining is supported; autojoining is only done * if enabled in the main control * @param insertBelow true: new arch is inserted on top, false: new arch is @@ -344,10 +343,18 @@ * than returning <code>null</code>. */ @Nullable - G addArchToMap(String archName, Point pos, boolean allowDouble, boolean join, boolean insertBelow); + G insertArchetype(@Nullable String archetypeName, @NotNull Point pos, boolean allowDouble, boolean join, boolean insertBelow); + /** + * Adds a {@link GameObject} to the map. + * @param gameObject the game object to insert + * @param pos the insert-location on this map + * @param allowMany whether duplicates are allowed + * @return the inserted game object or <code>null</code> if nothing was + * inserted + */ @Nullable - G addArchToPickmap(Point pos, boolean allowMany, @NotNull G newarch); + G insertGameObject(@NotNull G gameObject, @NotNull Point pos, boolean allowMany); /** * Checks whether an GameObject (multi-arch) would still fit on this map. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-25 07:49:28
|
Revision: 4419 http://gridarta.svn.sourceforge.net/gridarta/?rev=4419&view=rev Author: akirschbaum Date: 2008-07-25 07:49:37 +0000 (Fri, 25 Jul 2008) Log Message: ----------- Rename method name. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/map/MapSquare.java Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-07-24 19:58:51 UTC (rev 4418) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-07-25 07:49:37 UTC (rev 4419) @@ -1464,7 +1464,7 @@ /** Records that this game object has changed. */ protected void gameObjectChanged() { for (G part = getHead(); part != null; part = part.getMultiNext()) { - part.squareChanged(); + part.notifyChanged(); } } Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2008-07-24 19:58:51 UTC (rev 4418) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2008-07-25 07:49:37 UTC (rev 4419) @@ -123,7 +123,7 @@ // we can't simply invoke GameObjectContainer#remove(current) because that would result in a ConcurrentModificationException. delegate.remove(); current.setContainer(null); - squareChanged(); + notifyChanged(); } }; } @@ -195,7 +195,7 @@ throw new NotInsideContainerException(this, gameObject); } gameObject.setContainer(null); - squareChanged(); + notifyChanged(); } /** @@ -211,7 +211,7 @@ gameObject.setContainer(null); } contents.clear(); - squareChanged(); + notifyChanged(); } /** @@ -231,7 +231,7 @@ contents.get(0).propagateElevation(gameObject); } contents.add(gameObject); - squareChanged(); + notifyChanged(); } } @@ -252,7 +252,7 @@ contents.get(0).propagateElevation(gameObject); } contents.add(oldIndex + 1, gameObject); - squareChanged(); + notifyChanged(); } } @@ -273,7 +273,7 @@ gameObject.propagateElevation(contents.get(0)); } contents.add(oldIndex - 1, gameObject); - squareChanged(); + notifyChanged(); } } @@ -292,7 +292,7 @@ assert contents.size() >= 1; gameObject.propagateElevation(contents.get(0)); contents.add(0, gameObject); - squareChanged(); + notifyChanged(); } } @@ -321,7 +321,7 @@ } contents.add(gameObject); gameObject.setContainer(this); - squareChanged(); + notifyChanged(); } /** @@ -340,7 +340,7 @@ } contents.add(0, gameObject); gameObject.setContainer(this); - squareChanged(); + notifyChanged(); } /** @@ -361,7 +361,7 @@ } contents.add(insertIndex, newGameObject); newGameObject.setContainer(this); - squareChanged(); + notifyChanged(); } /** @@ -385,7 +385,7 @@ } contents.add(insertIndex + 1, newGameObject); newGameObject.setContainer(this); - squareChanged(); + notifyChanged(); } /** @@ -410,7 +410,7 @@ oldGameObject.setContainer(null); contents.add(insertIndex, newGameObject); newGameObject.setContainer(this); - squareChanged(); + notifyChanged(); } /** @@ -426,7 +426,7 @@ * Tell the model that this MapSquare has changed. This method must be * invoked by all other methods that change something. */ - protected final void squareChanged() { + protected final void notifyChanged() { final MapSquare<G, A, R> square = getMapSquare(); if (square != null) { square.getMapModel().squareChanged(square); Modified: trunk/src/app/net/sf/gridarta/map/MapSquare.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapSquare.java 2008-07-24 19:58:51 UTC (rev 4418) +++ trunk/src/app/net/sf/gridarta/map/MapSquare.java 2008-07-25 07:49:37 UTC (rev 4419) @@ -62,7 +62,7 @@ this.mapModel = mapModel; this.mapX = mapX; this.mapY = mapY; - squareChanged(); + notifyChanged(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-25 19:47:10
|
Revision: 4430 http://gridarta.svn.sourceforge.net/gridarta/?rev=4430&view=rev Author: akirschbaum Date: 2008-07-25 19:47:18 +0000 (Fri, 25 Jul 2008) Log Message: ----------- Remove MapControl.insertMapArchToPickmap(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-07-25 17:56:47 UTC (rev 4429) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-07-25 19:47:18 UTC (rev 4430) @@ -152,7 +152,10 @@ mapControl.getMapModel().beginTransaction("Insert Object"); @Nullable final G insertedObject; if (mapControl.isPickmap()) { - mapControl.insertMapArchToPickmap(p); + final G selectedGameObject = selectedSquareView.getSelectedGameObject(); + if (selectedGameObject != null) { + mapControl.getMapModel().insertMapArchToPickmap(p, selectedGameObject); + } insertedObject = null; } else { final int modeIndex = modeComboBox.getSelectedIndex(); Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-07-25 17:56:47 UTC (rev 4429) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-07-25 19:47:18 UTC (rev 4430) @@ -240,18 +240,6 @@ } /** {@inheritDoc} */ - public void insertMapArchToPickmap(@NotNull final Point pos) { - final MapControl<G, A, R, V> currentMap = mainControl.getMapManager().getCurrentMap(); - // insertion is only allowed for valid *empty* squares - if (currentMap != null && isPickmap()) { - final G newarch = selectedSquareView.getSelectedGameObject(); - if (newarch != null) { - mapModel.insertMapArchToPickmap(pos, newarch); - } - } - } - - /** {@inheritDoc} */ public boolean isPlainSaveEnabled() { return mapFile != null && !getMapFileName().equals(CommonConstants.DEF_MAPFNAME); } Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-07-25 17:56:47 UTC (rev 4429) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-07-25 19:47:18 UTC (rev 4430) @@ -214,11 +214,4 @@ @NotNull Point[] getViewPositions(); - /** - * This method is only called for pickmaps. Takes the currently highlighted - * arch on the map (if any) and insert it on this pickmap. - * @param pos tile-coordinates in pickmap - */ - void insertMapArchToPickmap(@NotNull Point pos); - } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-27 21:50:28
|
Revision: 4510 http://gridarta.svn.sourceforge.net/gridarta/?rev=4510&view=rev Author: akirschbaum Date: 2008-07-27 21:50:37 +0000 (Sun, 27 Jul 2008) Log Message: ----------- Remove unused method parameter. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSetListener.java trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2008-07-27 21:47:56 UTC (rev 4509) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2008-07-27 21:50:37 UTC (rev 4510) @@ -248,7 +248,7 @@ private void fireLoadedFromArchiveChangedEvent() { for (final ArchetypeSetListener<G, A, R> listener : listenerList.getListeners(ArchetypeSetListener.class)) { - listener.loadedFromArchiveChanged(this); + listener.loadedFromArchiveChanged(); } } Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSetListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSetListener.java 2008-07-27 21:47:56 UTC (rev 4509) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSetListener.java 2008-07-27 21:50:37 UTC (rev 4510) @@ -21,7 +21,6 @@ import java.util.EventListener; import net.sf.gridarta.map.MapArchObject; -import org.jetbrains.annotations.NotNull; /** * Interface for listeners listening to ArchetypeSet changes. @@ -32,8 +31,7 @@ /** * This event handler is called when the "loaded from archive" flag has * changed. - * @param archetypeSet the archetype set which has changed */ - void loadedFromArchiveChanged(@NotNull ArchetypeSet<G, A, R> archetypeSet); + void loadedFromArchiveChanged(); } // interface ArchetypeSetListener Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-07-27 21:47:56 UTC (rev 4509) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-07-27 21:50:37 UTC (rev 4510) @@ -272,7 +272,7 @@ private final ArchetypeSetListener<G, A, R> archetypeSetListener = new ArchetypeSetListener<G, A, R>() { /** {@inheritDoc} */ - public void loadedFromArchiveChanged(@NotNull final ArchetypeSet<G, A, R> archetypeSet) { + public void loadedFromArchiveChanged() { refreshMenus(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-27 22:14:19
|
Revision: 4514 http://gridarta.svn.sourceforge.net/gridarta/?rev=4514&view=rev Author: akirschbaum Date: 2008-07-27 22:14:28 +0000 (Sun, 27 Jul 2008) Log Message: ----------- Extract edit types into separate class. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/EditTypes.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-27 22:03:58 UTC (rev 4513) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-27 22:14:28 UTC (rev 4514) @@ -73,8 +73,8 @@ /** The Gridarta Objects Factory. */ private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; - /** Bit field of edit types to show only. */ - private int editType = 0; + /** The edit types instance. */ + private final EditTypes editTypes; /** Buffer managing copy data. */ private final CopyBuffer<G, A, R, V> copybuffer = new CopyBuffer<G, A, R, V>(this); @@ -101,6 +101,7 @@ */ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key) { mapManager = new DefaultMapManager<G, A, R, V>(this, key); + editTypes = new EditTypes(mapManager); this.gridartaObjectsFactory = gridartaObjectsFactory; setInstance(this); } @@ -129,44 +130,32 @@ /** {@inheritDoc} */ public int getEditType() { - return editType; + return editTypes.getEditType(); } /** {@inheritDoc} */ public void setEditType(final int editType) { - if ((this.editType & editType) == editType) { - return; - } - - this.editType |= editType; - - mapManager.addEditType(editType); + editTypes.setEditType(editType); } /** {@inheritDoc} */ public void unsetEditType(final int editType) { - if ((this.editType & editType) == 0) { - return; - } - - this.editType &= ~editType; - mapManager.refreshCurrentMap(); + editTypes.unsetEditType(editType); } /** {@inheritDoc} */ public boolean isEditType(final int editType) { - final int mask = editType != 0 ? editType : GUIConstants.EDIT_TYPE_NONE; - return (this.editType & mask) != 0; + return editTypes.isEditType(editType); } /** {@inheritDoc} */ public boolean isEditType(final G gameObject) { - return editType == 0 || isEditType(gameObject.getEditType()); + return editTypes.isEditType(gameObject); } /** {@inheritDoc} */ public boolean isEditTypeSet() { - return (editType & GUIConstants.EDIT_TYPE_NONE) == 0 && editType != 0; + return editTypes.isEditTypeSet(); } /** {@inheritDoc} */ Added: trunk/src/app/net/sf/gridarta/EditTypes.java =================================================================== --- trunk/src/app/net/sf/gridarta/EditTypes.java (rev 0) +++ trunk/src/app/net/sf/gridarta/EditTypes.java 2008-07-27 22:14:28 UTC (rev 4514) @@ -0,0 +1,109 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; + +public class EditTypes<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + /** The map manager. */ + private final MapManager<G, A, R, V> mapManager; + + /** Bit field of edit types to show only. */ + private int editType = 0; + + public EditTypes(@NotNull final MapManager<G, A, R, V> mapManager) { + this.mapManager = mapManager; + } + + /** + * Returns the currently set edit type. + * @return the currently set edit type. + */ + public int getEditType() { + return editType; + } + + /** + * Set the map view to show tiles of the given type. (If no edit type is + * set, everything is displayed) + * @param editType edit type bitmask of types to show + */ + public void setEditType(final int editType) { + if ((this.editType & editType) == editType) { + return; + } + + this.editType |= editType; + + mapManager.addEditType(editType); + } + + /** + * Set the map view to hide tiles of the given type. (If no edit type is + * set, everything is displayed) + * @param editType edit type bitmask of types to hide + */ + public void unsetEditType(final int editType) { + if ((this.editType & editType) == 0) { + return; + } + + this.editType &= ~editType; + mapManager.refreshCurrentMap(); + } + + /** + * Get information on the current state of edit type. Are tiles of type + * 'editType' displayed? + * @param editType are tiles of this type displayed? + * @return <code>true</code> if these tiles are currently displayed + */ + public boolean isEditType(final int editType) { + final int mask = editType != 0 ? editType : GUIConstants.EDIT_TYPE_NONE; + return (this.editType & mask) != 0; + } + + /** + * Get information whether the gameObject is edited. Are tiles of type 'v' + * displayed? + * @param gameObject are tiles of this type displayed? + * @return true if these tiles are currently displayed + */ + public boolean isEditType(final G gameObject) { + return editType == 0 || isEditType(gameObject.getEditType()); + } + + /** + * Returns whether a editType value is set so that not all tiles are + * displayed. + * @return <code>true</code> if a editType value is set, otherwise + * <code>false</code>. + */ + public boolean isEditTypeSet() { + return (editType & GUIConstants.EDIT_TYPE_NONE) == 0 && editType != 0; + } + +} // class EditTypes Property changes on: trunk/src/app/net/sf/gridarta/EditTypes.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-27 22:35:18
|
Revision: 4518 http://gridarta.svn.sourceforge.net/gridarta/?rev=4518&view=rev Author: akirschbaum Date: 2008-07-27 22:35:27 +0000 (Sun, 27 Jul 2008) Log Message: ----------- Remove calls to MainControl.getEditTypes(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/CopyBuffer.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-27 22:32:24 UTC (rev 4517) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-27 22:35:27 UTC (rev 4518) @@ -76,7 +76,7 @@ private final EditTypes editTypes; /** Buffer managing copy data. */ - private final CopyBuffer<G, A, R, V> copybuffer = new CopyBuffer<G, A, R, V>(this); + private final CopyBuffer<G, A, R, V> copybuffer; /** The cache for map images. */ private MapImageCache<G, A, R, V> mapImageCache = null; @@ -101,6 +101,7 @@ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key) { mapManager = new DefaultMapManager<G, A, R, V>(this, key); editTypes = new EditTypes(mapManager); + copybuffer = new CopyBuffer<G, A, R, V>(this, editTypes); this.gridartaObjectsFactory = gridartaObjectsFactory; setInstance(this); } Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-07-27 22:32:24 UTC (rev 4517) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-07-27 22:35:27 UTC (rev 4518) @@ -65,6 +65,10 @@ /** Reference to main control. */ private final MainControl<G, A, R, V> mainControl; + /** The edit types instance. */ + @NotNull + private final EditTypes<G, A, R, V> editTypes; + /** Internal map control to store the cut / copied arches. */ private MapControl<G, A, R, V> copyMapCtrl = null; @@ -72,8 +76,9 @@ * Create the copy buffer. * @param mainControl main control */ - public CopyBuffer(final MainControl<G, A, R, V> mainControl) { + public CopyBuffer(final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes) { this.mainControl = mainControl; // link main control in + this.editTypes = editTypes; } /** @@ -157,14 +162,14 @@ // store a clone of the gameObject in the CopyBuffer // (for multiparts, only the heads get copied into the buffer) // arches that don't match the view settings are ignored! - if ((copyMode == CopyMode.DO_CUT || copyMode == CopyMode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && mainControl.getEditTypes().isEditType(gameObject)) { + if ((copyMode == CopyMode.DO_CUT || copyMode == CopyMode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && editTypes.isEditType(gameObject)) { // copy this gameObject final G clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); mapModel.addGameObjectToMap(clone, InsertionMode.TOPMOST); } // delete the gameObject if we have a "cut" or "clear" command // again, arches that don't match the view settings are ignored - if ((copyMode == CopyMode.DO_CLEAR || copyMode == CopyMode.DO_CUT) && mainControl.getEditTypes().isEditType(gameObject)) { + if ((copyMode == CopyMode.DO_CLEAR || copyMode == CopyMode.DO_CUT) && editTypes.isEditType(gameObject)) { // delete gameObject (without redrawing the map) // For CUT we don't delete multi tails of multis which are left or // above the head (we would miss to copy them otherwise). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-27 23:33:16
|
Revision: 4528 http://gridarta.svn.sourceforge.net/gridarta/?rev=4528&view=rev Author: akirschbaum Date: 2008-07-27 23:33:25 +0000 (Sun, 27 Jul 2008) Log Message: ----------- Remove MainControl.getCopyBuffer(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-27 23:31:57 UTC (rev 4527) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-27 23:33:25 UTC (rev 4528) @@ -133,8 +133,11 @@ return editTypes; } - /** {@inheritDoc} */ - public CopyBuffer<G, A, R, V> getCopyBuffer() { + /** + * Return the {@link CopyBuffer} instance. + * @return The <code>CopyBuffer</code> instance. + */ + protected CopyBuffer<G, A, R, V> getCopyBuffer() { return copyBuffer; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-27 23:31:57 UTC (rev 4527) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-27 23:33:25 UTC (rev 4528) @@ -199,12 +199,6 @@ Spells<GameObjectSpell<G, A, R>> getGameObjectSpells(); /** - * Return the {@link CopyBuffer} instance. - * @return The <code>CopyBuffer</code> instance. - */ - CopyBuffer<G, A, R, V> getCopyBuffer(); - - /** * Return the cache for map images. * @return the cache for map images */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 08:01:26
|
Revision: 4532 http://gridarta.svn.sourceforge.net/gridarta/?rev=4532&view=rev Author: akirschbaum Date: 2008-07-28 08:01:34 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Remove MainControl.getImageCache(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-28 07:56:59 UTC (rev 4531) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-28 08:01:34 UTC (rev 4532) @@ -134,7 +134,7 @@ } /** {@inheritDoc} */ - public MapImageCache<G, A, R, V> getMapImageCache() { + protected MapImageCache<G, A, R, V> getMapImageCache() { return mapImageCache; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-28 07:56:59 UTC (rev 4531) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-28 08:01:34 UTC (rev 4532) @@ -198,12 +198,6 @@ */ Spells<GameObjectSpell<G, A, R>> getGameObjectSpells(); - /** - * Return the cache for map images. - * @return the cache for map images - */ - MapImageCache<G, A, R, V> getMapImageCache(); - /** Exits from the program. */ void doExit(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 08:27:51
|
Revision: 4537 http://gridarta.svn.sourceforge.net/gridarta/?rev=4537&view=rev Author: akirschbaum Date: 2008-07-28 08:27:58 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Remove MainControl.getMapPreviewAccessory(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-28 08:26:02 UTC (rev 4536) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-28 08:27:58 UTC (rev 4537) @@ -152,8 +152,11 @@ } - /** {@inheritDoc} */ - public MapPreviewAccessory getMapPreviewAccessory() { + /** + * Return the map preview accessory. + * @return the map preview accessory + */ + protected MapPreviewAccessory getMapPreviewAccessory() { return mapPreviewAccessory; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-28 08:26:02 UTC (rev 4536) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-28 08:27:58 UTC (rev 4537) @@ -31,7 +31,6 @@ import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.ObjectChooser; -import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; @@ -175,12 +174,6 @@ MapManager<G, A, R, V> getMapManager(); /** - * Return the map preview accessory. - * @return the map preview accessory - */ - MapPreviewAccessory getMapPreviewAccessory(); - - /** * Returns the list with the types for the Archetypes and GameObjects. * @return The list with the types for the Archetypes and GameObjects. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 17:45:23
|
Revision: 4544 http://gridarta.svn.sourceforge.net/gridarta/?rev=4544&view=rev Author: akirschbaum Date: 2008-07-28 17:45:30 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Extract random number code into RandomUtils. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/map/MapView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/utils/RandomUtils.java Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-07-28 17:43:39 UTC (rev 4543) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-07-28 17:45:30 UTC (rev 4544) @@ -35,6 +35,7 @@ import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.utils.RandomUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -251,10 +252,10 @@ mapView.getMapControl().getMapModel().beginTransaction("Fill"); // TODO; I18N/L10N for (final Point p : mapView.getMapViewBasic().getSelection()) { - if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { + if (density != -1 && density != 100 && density < RandomUtils.rnd.nextInt(100) + 1) { continue; } - final G gameObject = archList.get(MainControl.rnd.nextInt(archList.size())); + final G gameObject = archList.get(RandomUtils.rnd.nextInt(archList.size())); mapView.getMapControl().getMapModel().addCopyToMap(gameObject, p, false, insertionMode); } mapView.getMapControl().getMapModel().endTransaction(); Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-28 17:43:39 UTC (rev 4543) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-28 17:45:30 UTC (rev 4544) @@ -20,7 +20,6 @@ package net.sf.gridarta; import java.io.File; -import java.util.Random; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; @@ -53,9 +52,6 @@ /** Preferences key for language. */ String PREFS_LANGUAGE = "language"; - /** Global random number generator. */ - Random rnd = new Random(); - /** * Return the Gridarta Objects Factory. * @return The Gridarta Objects Factory. Modified: trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java =================================================================== --- trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java 2008-07-28 17:43:39 UTC (rev 4543) +++ trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java 2008-07-28 17:45:30 UTC (rev 4544) @@ -21,7 +21,6 @@ import java.awt.Point; import java.util.List; -import net.sf.gridarta.MainControl; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -29,6 +28,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.utils.RandomUtils; /** * Implements floodfilling. <p>Algorithmic notes: This algorithm replaces the @@ -86,7 +86,7 @@ border--; if (mapControl.getMapModel().isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { area[p.x][p.y] = WAS_EMPTY; - final G gameObject = archList.get(MainControl.rnd.nextInt(archList.size())); + final G gameObject = archList.get(RandomUtils.rnd.nextInt(archList.size())); mapControl.getMapModel().addCopyToMap(gameObject, p, false, InsertionMode.TOPMOST); try { if (area[p.x - 1][p.y] == NOT_LOOKED_AT) { Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-07-28 17:43:39 UTC (rev 4543) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-07-28 17:45:30 UTC (rev 4544) @@ -48,6 +48,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.utils.RandomUtils; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -337,7 +338,7 @@ objectsToReplace.clear(); for (final G node : square) { if (node.isHead() && ((matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString)) || (matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString)))) { - if (replaceDensity > MainControl.rnd.nextInt(100)) { + if (replaceDensity > RandomUtils.rnd.nextInt(100)) { objectsToReplace.add(node); } } @@ -367,7 +368,7 @@ if (replaceListSize == 1) { randomArch = replaceList.get(0); } else { - randomArch = replaceList.get(MainControl.rnd.nextInt(replaceList.size())); + randomArch = replaceList.get(RandomUtils.rnd.nextInt(replaceList.size())); } // insert replacement object if (randomArch.isMulti()) { Modified: trunk/src/app/net/sf/gridarta/gui/map/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapView.java 2008-07-28 17:43:39 UTC (rev 4543) +++ trunk/src/app/net/sf/gridarta/gui/map/MapView.java 2008-07-28 17:45:30 UTC (rev 4544) @@ -41,6 +41,7 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.utils.RandomUtils; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -194,7 +195,7 @@ if (objectSize == 1) { return objects.get(0); } - return objects.get(MainControl.rnd.nextInt(objects.size())); + return objects.get(RandomUtils.rnd.nextInt(objects.size())); } /** Added: trunk/src/app/net/sf/gridarta/utils/RandomUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/RandomUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/utils/RandomUtils.java 2008-07-28 17:45:30 UTC (rev 4544) @@ -0,0 +1,39 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.utils; + +import java.util.Random; + +/** + * Random number utilities. + * @author Andreas Kirschbaum + */ +public class RandomUtils { + + /** Global random number generator. */ + public static final Random rnd = new Random(); + + /** + * Private constructor to prevent instantiation. + */ + private RandomUtils() { + } + +} // class RandomUtils Property changes on: trunk/src/app/net/sf/gridarta/utils/RandomUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 19:12:47
|
Revision: 4545 http://gridarta.svn.sourceforge.net/gridarta/?rev=4545&view=rev Author: akirschbaum Date: 2008-07-28 19:12:54 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Use archetype parameter rather than archetype name in MapModel.insertArchetype(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-07-28 17:45:30 UTC (rev 4544) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-07-28 19:12:54 UTC (rev 4545) @@ -373,7 +373,7 @@ // insert replacement object if (randomArch.isMulti()) { // multi's cannot be inserted properly, so we just put them ontop - mapControl.getMapModel().insertArchetype(randomArch.getArchetypeName(), new Point(square.getMapX(), square.getMapY()), false, false, InsertionMode.TOPMOST); + mapControl.getMapModel().insertArchetype(randomArch.getArchetype(), new Point(square.getMapX(), square.getMapY()), false, false, InsertionMode.TOPMOST); // TODO: if from pickmap it could have special attributes -> copy them } else { Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-07-28 17:45:30 UTC (rev 4544) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2008-07-28 19:12:54 UTC (rev 4545) @@ -358,7 +358,7 @@ */ @Nullable public G insertSelectedArchetype(final MapModel<G, A, R> mapModel, final Point pos, final boolean allowMany, final InsertionMode insertionMode) { - return selectedArch == null ? null : mapModel.insertArchetype(selectedArch.getArchetypeName(), pos, allowMany, true, insertionMode); + return selectedArch == null ? null : mapModel.insertArchetype(selectedArch.getArchetype(), pos, allowMany, true, insertionMode); } } // class ArchetypeChooserControl Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-07-28 17:45:30 UTC (rev 4544) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-07-28 19:12:54 UTC (rev 4545) @@ -664,7 +664,7 @@ // put arch on the map if (templateGameObject.isArchetype()) { - newGameObject = insertArchetype(templateGameObject.getArchetypeName(), pos, true, join, InsertionMode.TOPMOST); + newGameObject = insertArchetype(templateGameObject.getArchetype(), pos, true, join, InsertionMode.TOPMOST); if (newGameObject == null) { return null; } @@ -713,16 +713,11 @@ /** {@inheritDoc} */ @Nullable - public G insertArchetype(@Nullable final String archetypeName, @NotNull final Point pos, final boolean allowDouble, final boolean join, @NotNull final InsertionMode insertionMode) { - if (archetypeName == null || archetypeName.length() == 0 || !isPointValid(pos)) { + public G insertArchetype(@NotNull R archetype, @NotNull final Point pos, final boolean allowDouble, final boolean join, @NotNull final InsertionMode insertionMode) { + if (!isPointValid(pos)) { return null; } - R archetype = mainControl.getArchetypeSet().getArchetype(archetypeName); - if (archetype == null) { - return null; - } - if (mapActions.isAutoJoin() && join && !archetype.isMulti()) { final AutojoinList<G, A, R> autojoinList = mainControl.getAutojoinLists().getAutojoinList(archetype); if (autojoinList != null) { @@ -793,7 +788,7 @@ // insert multi tile from pickmap: final G newarchHead = gameObject.getHead(); // first insert default arch from archlist - final G newObject = insertArchetype(newarchHead.getArchetypeName(), pos, allowMany, false, insertionMode); + final G newObject = insertArchetype(newarchHead.getArchetype(), pos, allowMany, false, insertionMode); if (newObject != null) { newObject.setObjectText(newarchHead.getObjectText()); newObject.setObjName(newarchHead.getObjName()); @@ -877,7 +872,7 @@ /** {@inheritDoc} */ public void addCopyToMap(@NotNull final G gameObject, @NotNull final Point pos, final boolean allowDouble, @NotNull final InsertionMode insertionMode) { if (gameObject.isArchetype()) { - insertArchetype(gameObject.getArchetypeName(), pos, allowDouble, false, insertionMode); + insertArchetype(gameObject.getArchetype(), pos, allowDouble, false, insertionMode); } else { final G newGameObject = gameObject.createMultiClone(pos.x, pos.y); for (G tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-07-28 17:45:30 UTC (rev 4544) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-07-28 19:12:54 UTC (rev 4545) @@ -325,9 +325,8 @@ void setState(@NotNull MapState<G, A, R> mapState); /** - * Creates a game object and adds it to the map. - * @param archetypeName name of an archetype; does nothing if - * <code>null</code> or empty + * Creates a game object from an archetype and adds it to the map. + * @param archetype the archetype to insert * @param pos the insert-location on this map * @param allowDouble if set, only one arch of the same kind can be * inserted per square @@ -343,7 +342,7 @@ * than returning <code>null</code>. */ @Nullable - G insertArchetype(@Nullable String archetypeName, @NotNull Point pos, boolean allowDouble, boolean join, @NotNull final InsertionMode insertionMode); + G insertArchetype(@NotNull R archetype, @NotNull Point pos, boolean allowDouble, boolean join, @NotNull final InsertionMode insertionMode); /** * Adds a {@link GameObject} to the map. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 21:13:10
|
Revision: 4552 http://gridarta.svn.sourceforge.net/gridarta/?rev=4552&view=rev Author: akirschbaum Date: 2008-07-28 21:13:16 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Remove dependency DefaultMapControl -> StatusBar. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/StatusBar.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-07-28 21:11:58 UTC (rev 4551) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-07-28 21:13:16 UTC (rev 4552) @@ -44,8 +44,10 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlListener; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -148,6 +150,31 @@ }; /** + * The {@link MapControlListener} used to detect saved maps. + */ + private final MapControlListener<G, A, R, V> mapControlListener = new MapControlListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void modifiedChanged(@NotNull final MapControl<G, A, R, V> mapControl) { + } + + /** {@inheritDoc} */ + public void mapFileNameChanged(@NotNull final MapControl<G, A, R, V> mapControl) { + } + + /** {@inheritDoc} */ + public void iconChanged(@NotNull final MapControl<G, A, R, V> mapControl) { + } + + /** {@inheritDoc} */ + public void saved(final DefaultMapControl<G, A, R, V> mapControl) { + final String mapType = mapControl.isPickmap() ? "map" : "pickmap"; + setStatusText("Saved " + mapType + " '" + mapControl.getMapFileName() + "'."); + } + + }; + + /** * The action listener which is registered to periodically update the status * bar. */ Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-07-28 21:11:58 UTC (rev 4551) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-07-28 21:13:16 UTC (rev 4552) @@ -420,11 +420,6 @@ /** {@inheritDoc} */ public void save() { - if (isPickmap) { - mainControl.getMainView().getStatusBar().setStatusText("Saving pickmap '" + mapFileName + "'..."); - } else { - mainControl.getMainView().getStatusBar().setStatusText("Saving map '" + mapFileName + "'..."); - } assert mapFile != null; if (modified) { mapModel.getMapArchObject().updateModifiedAttribute(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 21:31:42
|
Revision: 4555 http://gridarta.svn.sourceforge.net/gridarta/?rev=4555&view=rev Author: akirschbaum Date: 2008-07-28 21:31:49 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Rename class name. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/MapImageCache.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java Modified: trunk/src/app/net/sf/gridarta/MapImageCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-07-28 21:24:38 UTC (rev 4554) +++ trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-07-28 21:31:49 UTC (rev 4555) @@ -70,15 +70,15 @@ /** The map for the default images. */ @NotNull - private final Map<Type, ImageIcon> defaultImages = new EnumMap<Type, ImageIcon>(Type.class); + private final Map<ImageType, ImageIcon> defaultImages = new EnumMap<ImageType, ImageIcon>(ImageType.class); /** The map for the cached icons. */ @NotNull - private final Map<Type, Map<File, WeakReference<ImageIcon>>> cachedImages = new EnumMap<Type, Map<File, WeakReference<ImageIcon>>>(Type.class); + private final Map<ImageType, Map<File, WeakReference<ImageIcon>>> cachedImages = new EnumMap<ImageType, Map<File, WeakReference<ImageIcon>>>(ImageType.class); /** The map for the timestamps of the cached icons. */ @NotNull - private final Map<Type, Map<File, Long>> cachedTimestamps = new EnumMap<Type, Map<File, Long>>(Type.class); + private final Map<ImageType, Map<File, Long>> cachedTimestamps = new EnumMap<ImageType, Map<File, Long>>(ImageType.class); /** * Create a new instance. @@ -95,11 +95,11 @@ this.statusBar = statusBar; this.mapManager = mapManager; this.cacheDir = cacheDir; - defaultImages.put(Type.ICON, defaultIcon); - defaultImages.put(Type.PREVIEW, defaultPreview); - for (final Type type : Type.values()) { - cachedImages.put(type, new HashMap<File, WeakReference<ImageIcon>>()); - cachedTimestamps.put(type, new HashMap<File, Long>()); + defaultImages.put(ImageType.ICON, defaultIcon); + defaultImages.put(ImageType.PREVIEW, defaultPreview); + for (final ImageType imageType : ImageType.values()) { + cachedImages.put(imageType, new HashMap<File, WeakReference<ImageIcon>>()); + cachedTimestamps.put(imageType, new HashMap<File, Long>()); } if (cacheDir != null) { @@ -112,11 +112,11 @@ * @param mapFile the map file to process */ public void flush(@NotNull final File mapFile) { - for (final Type type : Type.values()) { - cachedImages.get(type).remove(mapFile); + for (final ImageType imageType : ImageType.values()) { + cachedImages.get(imageType).remove(mapFile); } - getImageFile(mapFile, Type.ICON).delete(); - getImageFile(mapFile, Type.PREVIEW).delete(); + getImageFile(mapFile, ImageType.ICON).delete(); + getImageFile(mapFile, ImageType.PREVIEW).delete(); } /** @@ -127,7 +127,7 @@ */ @Nullable public ImageIcon getIcon(@NotNull final File mapFile) { - return lookupCache(mapFile, Type.ICON); + return lookupCache(mapFile, ImageType.ICON); } /** @@ -138,12 +138,12 @@ */ @Nullable public ImageIcon getOrCreateIcon(@NotNull final File mapFile) { - final ImageIcon cachedIcon = lookupCache(mapFile, Type.ICON); + final ImageIcon cachedIcon = lookupCache(mapFile, ImageType.ICON); if (cachedIcon != null || mapFile.isDirectory()) { return cachedIcon; } - return updateCaches(mapFile, Type.ICON); + return updateCaches(mapFile, ImageType.ICON); } /** @@ -154,7 +154,7 @@ */ @Nullable public ImageIcon getIcon(@NotNull final MapControl<G, A, R, V> mapControl) { - return lookupCache(mapControl.getMapFile(), Type.ICON); + return lookupCache(mapControl.getMapFile(), ImageType.ICON); } /** @@ -166,15 +166,15 @@ @NotNull public ImageIcon getOrCreateIcon(@NotNull final MapControl<G, A, R, V> mapControl) { final File mapFile = mapControl.getMapFile(); - final ImageIcon cachedIcon = lookupCache(mapFile, Type.ICON); + final ImageIcon cachedIcon = lookupCache(mapFile, ImageType.ICON); if (cachedIcon != null) { return cachedIcon; } if (mapFile == null || mapFile.isDirectory()) { - return defaultImages.get(Type.ICON); + return defaultImages.get(ImageType.ICON); } - return updateCaches(mapFile, mapControl, Type.ICON); + return updateCaches(mapFile, mapControl, ImageType.ICON); } /** @@ -185,7 +185,7 @@ */ @Nullable public ImageIcon getPreview(@NotNull final File mapFile) { - return lookupCache(mapFile, Type.PREVIEW); + return lookupCache(mapFile, ImageType.PREVIEW); } /** @@ -196,12 +196,12 @@ */ @NotNull public ImageIcon getOrCreatePreview(@NotNull final File mapFile) { - final ImageIcon cachedPreview = lookupCache(mapFile, Type.PREVIEW); + final ImageIcon cachedPreview = lookupCache(mapFile, ImageType.PREVIEW); if (cachedPreview != null || mapFile.isDirectory()) { return cachedPreview; } - return updateCaches(mapFile, Type.PREVIEW); + return updateCaches(mapFile, ImageType.PREVIEW); } /** @@ -212,7 +212,7 @@ */ @Nullable public ImageIcon getPreview(@NotNull final MapControl<G, A, R, V> mapControl) { - return lookupCache(mapControl.getMapFile(), Type.PREVIEW); + return lookupCache(mapControl.getMapFile(), ImageType.PREVIEW); } /** @@ -224,31 +224,31 @@ @NotNull public ImageIcon getOrCreatePreview(@NotNull final MapControl<G, A, R, V> mapControl) { final File mapFile = mapControl.getMapFile(); - final ImageIcon cachedPreview = lookupCache(mapFile, Type.PREVIEW); + final ImageIcon cachedPreview = lookupCache(mapFile, ImageType.PREVIEW); if (cachedPreview != null || mapFile == null || mapFile.isDirectory()) { return cachedPreview; } - return updateCaches(mapFile, mapControl, Type.PREVIEW); + return updateCaches(mapFile, mapControl, ImageType.PREVIEW); } /** * Update the cached icon and preview images for one map file. * @param mapFile the map file to update; if <code>null</code>, return * <code>null</code> - * @param type Type of image to return + * @param imageType Type of image to return * @return the image, or <code>null</code> if the image cannot be created */ @NotNull - private ImageIcon updateCaches(@Nullable final File mapFile, final Type type) { + private ImageIcon updateCaches(@Nullable final File mapFile, final ImageType imageType) { if (mapFile == null) { - return defaultImages.get(type); + return defaultImages.get(imageType); } final MapControl<G, A, R, V> mapControl = mapManager.openMapFile(mapFile, false); if (mapControl != null) { try { - return updateCaches(mapFile, mapControl, type); + return updateCaches(mapFile, mapControl, imageType); } finally { if (mapControl.nViews() <= 0) { mapManager.closeLevel(mapControl); @@ -256,7 +256,7 @@ } } - return defaultImages.get(type); + return defaultImages.get(imageType); } /** @@ -265,31 +265,31 @@ * update the cache files * @param mapControl the map control instance corresponding to * <code>mapFile</code> - * @param type Type of image to return + * @param imageType Type of image to return * @return the image */ @NotNull - public ImageIcon updateCaches(@Nullable final File mapFile, @NotNull final MapControl<G, A, R, V> mapControl, final Type type) { + public ImageIcon updateCaches(@Nullable final File mapFile, @NotNull final MapControl<G, A, R, V> mapControl, final ImageType imageType) { final ImageIcon[] images = new ImageIcon[2]; try { createImages(mapControl.getRenderer().getFullImage(), images); } catch (final OutOfMemoryError ex) { - return defaultImages.get(type); + return defaultImages.get(imageType); } if (mapFile != null) { - cachedImages.get(Type.ICON).put(mapFile, new WeakReference<ImageIcon>(images[0])); - cachedTimestamps.get(Type.ICON).put(mapFile, mapFile.lastModified()); - saveImageFile(mapFile, images[0], Type.ICON); + cachedImages.get(ImageType.ICON).put(mapFile, new WeakReference<ImageIcon>(images[0])); + cachedTimestamps.get(ImageType.ICON).put(mapFile, mapFile.lastModified()); + saveImageFile(mapFile, images[0], ImageType.ICON); - cachedImages.get(Type.PREVIEW).put(mapFile, new WeakReference<ImageIcon>(images[1])); - cachedTimestamps.get(Type.PREVIEW).put(mapFile, mapFile.lastModified()); - saveImageFile(mapFile, images[1], Type.PREVIEW); + cachedImages.get(ImageType.PREVIEW).put(mapFile, new WeakReference<ImageIcon>(images[1])); + cachedTimestamps.get(ImageType.PREVIEW).put(mapFile, mapFile.lastModified()); + saveImageFile(mapFile, images[1], ImageType.PREVIEW); mapControl.fireIconChanged(); } - return images[type == Type.ICON ? 0 : 1]; + return images[imageType == ImageType.ICON ? 0 : 1]; } /** @@ -306,26 +306,26 @@ if (statusBar != null) { statusBar.setStatusText(ACTION_FACTORY.getString("mapImagesOutOfMemory")); } - result[0] = defaultImages.get(Type.ICON); - result[1] = defaultImages.get(Type.PREVIEW); + result[0] = defaultImages.get(ImageType.ICON); + result[1] = defaultImages.get(ImageType.PREVIEW); } } /** * Lookup an image from a cache. * @param mapFile the map file to look up - * @param type Type of image to return + * @param imageType Type of image to return * @return the image, or <code>null</code> if the cache does not contain an * entry for <code>mapFile</code> or the entry was outdated. */ @Nullable - private ImageIcon lookupCache(@Nullable final File mapFile, final Type type) { + private ImageIcon lookupCache(@Nullable final File mapFile, final ImageType imageType) { if (mapFile == null || mapFile.isDirectory()) { return null; } - final Map<File, WeakReference<ImageIcon>> cache = cachedImages.get(type); - final Map<File, Long> times = cachedTimestamps.get(type); + final Map<File, WeakReference<ImageIcon>> cache = cachedImages.get(imageType); + final Map<File, Long> times = cachedTimestamps.get(imageType); final WeakReference<ImageIcon> ref = cache.get(mapFile); if (ref != null) { @@ -337,7 +337,7 @@ cache.remove(mapFile); } - final ImageIcon image = loadImageFile(mapFile, type); + final ImageIcon image = loadImageFile(mapFile, imageType); if (image != null && mapFile.lastModified() <= times.get(mapFile)) { cache.put(mapFile, new WeakReference<ImageIcon>(image)); } @@ -348,12 +348,12 @@ * Load an image file from disk. If the file does not exists, cannot be * loaded, or is outdated, return <code>null</code>. * @param mapFile the map file name - * @param type the image type to load + * @param imageType the image type to load * @return the image file, or <code>null</code> */ @Nullable - ImageIcon loadImageFile(@NotNull final File mapFile, @NotNull final Type type) { - final File imageFile = getImageFile(mapFile, type); + ImageIcon loadImageFile(@NotNull final File mapFile, @NotNull final ImageType imageType) { + final File imageFile = getImageFile(mapFile, imageType); if (!imageFile.exists()) { // image file does not exist @@ -380,7 +380,7 @@ return null; } - cachedTimestamps.get(type).put(mapFile, imageFile.lastModified()); + cachedTimestamps.get(imageType).put(mapFile, imageFile.lastModified()); return imageIcon; } @@ -389,10 +389,10 @@ * {@link #cacheDir}. * @param mapFile the map file to save the image of * @param imageIcon the image to save - * @param type the image type to save + * @param imageType the image type to save */ - private void saveImageFile(@NotNull final File mapFile, @NotNull final ImageIcon imageIcon, @NotNull final Type type) { - final File imageFile = getImageFile(mapFile, type); + private void saveImageFile(@NotNull final File mapFile, @NotNull final ImageIcon imageIcon, @NotNull final ImageType imageType) { + final File imageFile = getImageFile(mapFile, imageType); final File imageDir = imageFile.getParentFile(); if (imageDir != null && !imageDir.exists()) { @@ -404,7 +404,7 @@ try { ImageIO.write(bufferedImage, "png", imageFile); - cachedTimestamps.get(type).put(mapFile, imageFile.lastModified()); + cachedTimestamps.get(imageType).put(mapFile, imageFile.lastModified()); } catch (final IOException e) { log.warn("Cannot create icon file " + imageFile + ": " + e.getMessage()); } @@ -413,13 +413,13 @@ /** * Return the file for an image file of a map file. * @param mapFile the map file - * @param type the file type + * @param imageType the file type * @return the file of the image file */ @NotNull - private File getImageFile(@NotNull final File mapFile, @NotNull final Type type) { + private File getImageFile(@NotNull final File mapFile, @NotNull final ImageType imageType) { if (cacheDir == null) { - return new File(new File(mapFile.getParent(), ".dedit"), mapFile.getName() + "." + type); + return new File(new File(mapFile.getParent(), ".dedit"), mapFile.getName() + "." + imageType); } final StringBuilder sb = new StringBuilder(); @@ -446,11 +446,11 @@ sb.insert(0, '!'); } sb.append(".png"); - return new File(new File(cacheDir, type.toString()), sb.toString()); + return new File(new File(cacheDir, imageType.toString()), sb.toString()); } /** The types of images that are cached. */ - public enum Type { + public enum ImageType { /** The icon is a small thumbnail useable as icon in file browsers. */ ICON, @@ -472,6 +472,6 @@ } } - } // enum Type + } // enum ImageType } // class MapImageCache Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-07-28 21:24:38 UTC (rev 4554) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-07-28 21:31:49 UTC (rev 4555) @@ -410,7 +410,7 @@ mapFileEncoder.close(); } - mapImageCache.updateCaches(file, this, MapImageCache.Type.ICON); + mapImageCache.updateCaches(file, this, MapImageCache.ImageType.ICON); } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "encodeMapFile", file, e.getMessage()); return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 21:54:11
|
Revision: 4560 http://gridarta.svn.sourceforge.net/gridarta/?rev=4560&view=rev Author: akirschbaum Date: 2008-07-28 21:54:19 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Remove dependency DefaultMapManager -> StatusBar. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/gui/StatusBar.java Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-07-28 21:50:42 UTC (rev 4559) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-07-28 21:54:19 UTC (rev 4560) @@ -89,7 +89,6 @@ /** {@inheritDoc} */ public MapView<G, A, R, V> newMapWithView(@Nullable final List<G> objects, @NotNull final A mapArchObject, @Nullable final Point viewPosition, @Nullable final File file, @NotNull final String mapFileName) { - mainControl.getMainView().getStatusBar().setStatusText("Creating new map " + mapArchObject.getMapDisplayName()); final MapControl<G, A, R, V> mapControl = newMap(objects, mapArchObject, file, mapFileName); levels.add(mapControl); Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-07-28 21:50:42 UTC (rev 4559) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2008-07-28 21:54:19 UTC (rev 4560) @@ -129,6 +129,7 @@ /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl<G, A, R, V> mapControl) { + setStatusText("Creating new map " + mapControl.getMapModel().getMapArchObject().getMapDisplayName() + "."); mapControl.addMapControlListener(mapControlListener); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 22:22:22
|
Revision: 4640 http://gridarta.svn.sourceforge.net/gridarta/?rev=4640&view=rev Author: akirschbaum Date: 2008-07-31 22:22:31 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove MainControl.getEditTypes(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-31 22:20:56 UTC (rev 4639) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-31 22:22:31 UTC (rev 4640) @@ -126,11 +126,6 @@ return gridartaObjectsFactory; } - /** {@inheritDoc} */ - public EditTypes<G, A, R, V> getEditTypes() { - return editTypes; - } - /** * Return the {@link CopyBuffer} instance. * @return The <code>CopyBuffer</code> instance. Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 22:20:56 UTC (rev 4639) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 22:22:31 UTC (rev 4640) @@ -20,7 +20,6 @@ package net.sf.gridarta; import java.io.File; -import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainActions; @@ -101,12 +100,6 @@ void exit(); /** - * Returns the edit types instance. - * @return the edit types instance. - */ - EditTypes<G, A, R, V> getEditTypes(); - - /** * Returns the configuration directory which is used to load configuration * information like types.xml. * @return The configuration directory. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-01 22:19:41
|
Revision: 4675 http://gridarta.svn.sourceforge.net/gridarta/?rev=4675&view=rev Author: akirschbaum Date: 2008-08-01 22:19:50 +0000 (Fri, 01 Aug 2008) Log Message: ----------- Remove calls to MainControl.getGridartaObjectsFactory(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/CopyBuffer.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-01 22:15:31 UTC (rev 4674) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-01 22:19:50 UTC (rev 4675) @@ -115,7 +115,7 @@ editTypes = new EditTypes(tmpMapManager); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; - copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes); + copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes, gridartaObjectsFactory); this.gridartaObjectsFactory = gridartaObjectsFactory; instance = this; } Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-01 22:15:31 UTC (rev 4674) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-01 22:19:50 UTC (rev 4675) @@ -70,16 +70,24 @@ @NotNull private final EditTypes<G, A, R, V> editTypes; + /** + * The gridarta objects factory instance. + */ + @NotNull + private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** Internal map control to store the cut / copied arches. */ private MapControl<G, A, R, V> copyMapCtrl = null; /** * Create the copy buffer. * @param mainControl main control + * @param gridartaObjectsFactory the gridarta objects factory instance */ - public CopyBuffer(final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes) { + public CopyBuffer(final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory) { this.mainControl = mainControl; // link main control in this.editTypes = editTypes; + this.gridartaObjectsFactory = gridartaObjectsFactory; } /** @@ -89,7 +97,7 @@ public void init(final A mapArch) { assert copyMapCtrl == null; mapArch.setMapName("cb"); - copyMapCtrl = mainControl.getGridartaObjectsFactory().newMapControl(null, mapArch, mainControl.getMainView()); + copyMapCtrl = gridartaObjectsFactory.newMapControl(null, mapArch, mainControl.getMainView()); copyMapCtrl.setMapFileName("cb"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-01 22:51:53
|
Revision: 4684 http://gridarta.svn.sourceforge.net/gridarta/?rev=4684&view=rev Author: akirschbaum Date: 2008-08-01 22:52:00 +0000 (Fri, 01 Aug 2008) Log Message: ----------- Remove MainControl.getGridartaObjectsFactory(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-01 22:50:55 UTC (rev 4683) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-01 22:52:00 UTC (rev 4684) @@ -120,12 +120,6 @@ instance = this; } - /** {@inheritDoc} */ - @NotNull - public GridartaObjectsFactory<G, A, R, V> getGridartaObjectsFactory() { - return gridartaObjectsFactory; - } - /** * Return the {@link CopyBuffer} instance. * @return The <code>CopyBuffer</code> instance. Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-01 22:50:55 UTC (rev 4683) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-01 22:52:00 UTC (rev 4684) @@ -48,13 +48,6 @@ String PREFS_LANGUAGE = "language"; /** - * Return the Gridarta Objects Factory. - * @return The Gridarta Objects Factory. - */ - @NotNull - GridartaObjectsFactory<G, A, R, V> getGridartaObjectsFactory(); - - /** * Returns the MainView of this MainControl. * @return The MainView of this MainControl. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-02 07:10:44
|
Revision: 4687 http://gridarta.svn.sourceforge.net/gridarta/?rev=4687&view=rev Author: akirschbaum Date: 2008-08-02 07:10:53 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Remove MainControl.getMapManager(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-02 07:08:09 UTC (rev 4686) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-02 07:10:53 UTC (rev 4687) @@ -171,12 +171,6 @@ } /** {@inheritDoc} */ - @NotNull - public MapManager<G, A, R, V> getMapManager() { - return mapManager; - } - - /** {@inheritDoc} */ public File getLocalMapDir() { final MapControl<G, A, R, V> mapControl = mapManager.getCurrentMap(); if (mapControl == null) { Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-02 07:08:09 UTC (rev 4686) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-02 07:10:53 UTC (rev 4687) @@ -102,13 +102,6 @@ String getCollectedDirectory(); /** - * Return the map manager. - * @return the map manager - */ - @NotNull - MapManager<G, A, R, V> getMapManager(); - - /** * Return the numbered spell objects. * @return The numbered spell objects. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-02 07:13:16
|
Revision: 4690 http://gridarta.svn.sourceforge.net/gridarta/?rev=4690&view=rev Author: akirschbaum Date: 2008-08-02 07:13:26 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Remove MainControl.getAutojoinLists(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-02 07:12:47 UTC (rev 4689) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-02 07:13:26 UTC (rev 4690) @@ -166,11 +166,6 @@ } /** {@inheritDoc} */ - public AutojoinLists<G, A, R> getAutojoinLists() { - return autojoinLists; - } - - /** {@inheritDoc} */ public File getLocalMapDir() { final MapControl<G, A, R, V> mapControl = mapManager.getCurrentMap(); if (mapControl == null) { Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-02 07:12:47 UTC (rev 4689) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-02 07:13:26 UTC (rev 4690) @@ -30,8 +30,6 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.spells.GameObjectSpell; -import net.sf.gridarta.spells.Spells; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -119,12 +117,6 @@ void reloadFaces(); /** - * Return the autojoin lists. - * @return The autojoin lists. - */ - AutojoinLists<G, A, R> getAutojoinLists(); - - /** * Return the insertion object chooser. * @return the insertion object chooser */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-02 07:36:59
|
Revision: 4692 http://gridarta.svn.sourceforge.net/gridarta/?rev=4692&view=rev Author: akirschbaum Date: 2008-08-02 07:37:06 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Remove call to MainControl.getObjectChooser(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-02 07:32:58 UTC (rev 4691) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-02 07:37:06 UTC (rev 4692) @@ -239,17 +239,10 @@ * Executing the Fill command. * @param mapView the map view to fill on * @param insertionMode the insertion mode to use - * @param seed map view of the random objects or <code>null</code> to use - * the currently selected Archetype. + * @param archList the game objects to fill with * @param density the fill density in percent; -1 to disable */ - public void fill(final MapView<G, A, R, V> mapView, final InsertionMode insertionMode, final MapView<G, A, R, V> seed, final int density) { - final List<G> archList; - if (seed == null) { - archList = mainControl.getObjectChooser().getObjectChooserSelection(); - } else { - archList = seed.getSelectedGameObjects(); - } + public void fill(@NotNull final MapView<G, A, R, V> mapView, @NotNull final InsertionMode insertionMode, @NotNull final List<G> archList, final int density) { if (archList.isEmpty()) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-02 07:32:58 UTC (rev 4691) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-02 07:37:06 UTC (rev 4692) @@ -488,7 +488,7 @@ * @param insertionMode the insertion mode to use */ private void fillWanted(@NotNull final MapView<G, A, R, V> mapView, final InsertionMode insertionMode) { - copyBuffer.fill(mapView, insertionMode, null, -1); + copyBuffer.fill(mapView, insertionMode, objectChooser.getObjectChooserSelection(), -1); } /** "Random fill above" was selected from the Edit menu. */ @@ -553,7 +553,7 @@ if (rand < 1 || rand > 100) { JOptionPane.showMessageDialog(mainControl.getMainView(), "The fill density must be between 1-100.", "Illegal Value.", JOptionPane.ERROR_MESSAGE); } else { - copyBuffer.fill(mapView, insertionMode, pickmap == null ? null : pickmap.getMapViewFrame(), rand); + copyBuffer.fill(mapView, insertionMode, pickmap == null ? objectChooser.getObjectChooserSelection() : pickmap.getMapViewFrame().getSelectedGameObjects(), rand); break; } } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-08-02 07:32:58 UTC (rev 4691) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-08-02 07:37:06 UTC (rev 4692) @@ -191,7 +191,7 @@ default: throw new AssertionError(); } - copyBuffer.fill(e.getMapView(), insertionMode, null, -1); + copyBuffer.fill(e.getMapView(), insertionMode, objectChooser.getObjectChooserSelection(), -1); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-02 07:38:48
|
Revision: 4693 http://gridarta.svn.sourceforge.net/gridarta/?rev=4693&view=rev Author: akirschbaum Date: 2008-08-02 07:38:57 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Remove call to MainControl.getObjectChooser(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/MainActions.java Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-02 07:37:06 UTC (rev 4692) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-02 07:38:57 UTC (rev 4693) @@ -265,8 +265,9 @@ /** * Floodfill the the map, starting at the cursor position. * @param mapView the map view to fill + * @param archList the game objects to fill with */ - public void floodfill(@NotNull final MapView<G, A, R, V> mapView) { + public void floodfill(@NotNull final MapView<G, A, R, V> mapView, @NotNull final List<G> archList) { final V mapViewBasic = mapView.getMapViewBasic(); final Point cursor = mapViewBasic.getMapCursor().getLocation(); if (cursor == null) { @@ -278,7 +279,6 @@ return; } - final List<G> archList = mainControl.getObjectChooser().getObjectChooserSelection(); if (archList.isEmpty()) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-02 07:37:06 UTC (rev 4692) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-08-02 07:38:57 UTC (rev 4693) @@ -563,7 +563,7 @@ public void floodfill() { final MapView<G, A, R, V> mapView = getFloodfillEnabled(); if (mapView != null) { - copyBuffer.floodfill(mapView); + copyBuffer.floodfill(mapView, objectChooser.getObjectChooserSelection()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-05 20:02:37
|
Revision: 4765 http://gridarta.svn.sourceforge.net/gridarta/?rev=4765&view=rev Author: akirschbaum Date: 2008-08-05 20:02:41 +0000 (Tue, 05 Aug 2008) Log Message: ----------- Move GameObjectAttributesPanel.isNonwhitespaceText() to StringUtils. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/utils/StringUtils.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-05 19:42:15 UTC (rev 4764) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesPanel.java 2008-08-05 20:02:41 UTC (rev 4765) @@ -72,6 +72,7 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -346,12 +347,6 @@ archTextArea.setLineWrap(true); } - // simple "white space test, to eliminate ' ' - // perhaps we should include here a real white space test - protected static boolean isNonwhitespaceText(final String text) { - return text.replaceAll("\\s+", "").length() > 0; - } - /** * Creates and returns the panel for displaying animation information. * @return The newly created animation information panel. @@ -444,7 +439,7 @@ // the msg TEXT!! ("msg ... endmsg") // if there is an entry in the archTextArea (msg window), this // overrules the default text (if any) - if (isNonwhitespaceText(archTextArea.getText())) { // there is something in the msg win + if (StringUtils.isNonwhitespaceText(archTextArea.getText())) { // there is something in the msg win if (archetype.getMsgText() != null) { // trim text from message window String newMsgText = archTextArea.getText(); @@ -741,7 +736,7 @@ // We update all panels: name, face, msg and archText (more to come...) // the obj name: - if (isNonwhitespaceText(archNameField.getText())) { // there is something in + if (StringUtils.isNonwhitespaceText(archNameField.getText())) { // there is something in // if this equal the default name... if (archetype.getObjName() != null) { if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { Modified: trunk/src/app/net/sf/gridarta/utils/StringUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2008-08-05 19:42:15 UTC (rev 4764) +++ trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2008-08-05 20:02:41 UTC (rev 4765) @@ -66,4 +66,14 @@ return str.endsWith("\n") ? str : str + "\n"; } + /** + * Simple "white space test, to eliminate ' '. + * @param text the string to check + * @return whener the string contains any non-whitespace character + * @todo perhaps we should include here a real white space test + */ + public static boolean isNonwhitespaceText(final String text) { + return text.replaceAll("\\s+", "").length() > 0; + } + } // class StringUtils This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-07 19:37:12
|
Revision: 4787 http://gridarta.svn.sourceforge.net/gridarta/?rev=4787&view=rev Author: akirschbaum Date: 2008-08-07 19:37:21 +0000 (Thu, 07 Aug 2008) Log Message: ----------- Remove overloaded use of ArchetypeAttribute.misc. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribDoubleList.java Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java 2008-08-07 19:32:27 UTC (rev 4786) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java 2008-08-07 19:37:21 UTC (rev 4787) @@ -33,17 +33,32 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribDoubleList; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class ArchetypeAttributeDoubleList<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + /** + * The first list name. + */ + @NotNull + private final String listName1; + + /** + * The second list name. + */ + @NotNull + private final String listName2; + private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; /** * Creates a new instance. + * @param listName1 the first list name + * @param listName2 the second list name */ - public ArchetypeAttributeDoubleList(@NotNull final String nameOld, @NotNull final String nameNew, @NotNull final String text, final int inputLength, @Nullable final String[] misc, final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { - super(nameOld, nameNew, text, inputLength, misc); + public ArchetypeAttributeDoubleList(@NotNull final String nameOld, @NotNull final String nameNew, @NotNull final String text, final int inputLength, @NotNull final String listName1, @NotNull final String listName2, final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + super(nameOld, nameNew, text, inputLength, null); + this.listName1 = listName1; + this.listName2 = listName2; this.archetypeTypeSet = archetypeTypeSet; } @@ -56,13 +71,13 @@ // create ComboBox with parsed selection final JComboBox[] inputs = new JComboBox[2]; final JComponent cComp; - if (getMisc() != null && archetypeTypeSet.getListTable().containsKey(getMisc()[0]) && archetypeTypeSet.getListTable().containsKey(getMisc()[1])) { + if (archetypeTypeSet.getListTable().containsKey(listName1) && archetypeTypeSet.getListTable().containsKey(listName2)) { // Hack to set preselected if available final int active = gameObject.getAttributeInt(nameOld); final int[] activepart = {active & 0x0F, active & 0xF0}; // build the lists from vector data for (int j = 0; j < 2; j++) { - final List<?> listData = archetypeTypeSet.getListTable().get(getMisc()[j]); + final List<?> listData = archetypeTypeSet.getListTable().get(j == 0 ? listName1 : listName2); inputs[j] = buildArrayBox(listData, gameObject); for (int k = 0; (double) k < listData.size() / 2.0; k++) { if ((Integer) listData.get(k * 2) == activepart[j]) { @@ -81,4 +96,22 @@ return new GuiInfo<G, A, R>(new DialogAttribDoubleList<G, A, R>(this, inputs, archetypeTypeSet), cLabel, cComp, null, null, false); } + /** + * Returns the first list name. + * @return the first list name + */ + @NotNull + public String getListName1() { + return listName1; + } + + /** + * Returns the second list name. + * @return the second list name + */ + @NotNull + public String getListName2() { + return listName1; + } + } // class ArchetypeAttributeDoubleList Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-08-07 19:32:27 UTC (rev 4786) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-08-07 19:37:21 UTC (rev 4787) @@ -308,10 +308,7 @@ log.error("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); return null; } - final String[] misc = new String[2]; - misc[0] = listName1; // store list name in misc[0] - misc[1] = listName2; // store list name in misc[1] - return new ArchetypeAttributeDoubleList<G, A, R>(nameOld, nameNew, text, inputLength, misc, archetypeTypeSet); + return new ArchetypeAttributeDoubleList<G, A, R>(nameOld, nameNew, text, inputLength, listName1, listName2, archetypeTypeSet); } else if (atype.equalsIgnoreCase("treasurelist")) { return new ArchetypeAttributeTreasure<G, A, R>(nameOld, nameNew, text, inputLength, null, treasureListTree); } else { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribDoubleList.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribDoubleList.java 2008-08-07 19:32:27 UTC (rev 4786) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribDoubleList.java 2008-08-07 19:37:21 UTC (rev 4787) @@ -25,6 +25,7 @@ import javax.swing.text.Document; import javax.swing.text.Style; import net.sf.gridarta.archtype.ArchetypeAttribute; +import net.sf.gridarta.archtype.ArchetypeAttributeDoubleList; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; @@ -53,8 +54,8 @@ /** {@inheritDoc} */ public String getText2(@NotNull final G gameObject, @NotNull final R archetype, final String[] newName, final String[] newFace, final String[] newMsg, final String[] newAnim, final ArchetypeType typeStruct, final Component parent) { - final int val1 = ((List<Integer>) archetypeTypeSet.getListTable().get(ref.getMisc()[0])).get(2 * getInput()[0].getSelectedIndex()); - final int val2 = ((List<Integer>) archetypeTypeSet.getListTable().get(ref.getMisc()[1])).get(2 * getInput()[1].getSelectedIndex()); + final int val1 = ((List<Integer>) archetypeTypeSet.getListTable().get(((ArchetypeAttributeDoubleList<G, A, R>) ref).getListName1())).get(2 * getInput()[0].getSelectedIndex()); + final int val2 = ((List<Integer>) archetypeTypeSet.getListTable().get(((ArchetypeAttributeDoubleList<G, A, R>) ref).getListName2())).get(2 * getInput()[1].getSelectedIndex()); final int combinedVal = val1 + val2; if (archetype.getAttributeInt(ref.getNameOld()) != combinedVal) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-07 19:46:23
|
Revision: 4790 http://gridarta.svn.sourceforge.net/gridarta/?rev=4790&view=rev Author: akirschbaum Date: 2008-08-07 19:46:31 +0000 (Thu, 07 Aug 2008) Log Message: ----------- Remove overloaded use of ArchetypeAttribute.misc. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBoolSpec.java Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java 2008-08-07 19:39:53 UTC (rev 4789) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java 2008-08-07 19:46:31 UTC (rev 4790) @@ -27,29 +27,59 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBoolSpec; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class ArchetypeAttributeBoolSpec<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { /** + * The true value. + */ + @NotNull + private final String trueValue; + + /** + * The false value. + */ + @NotNull + private final String falseValue; + + /** * Creates a new instance. */ - public ArchetypeAttributeBoolSpec(@NotNull final String nameOld, @NotNull final String nameNew, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { - super(nameOld, nameNew, text, inputLength, misc); + public ArchetypeAttributeBoolSpec(@NotNull final String nameOld, @NotNull final String nameNew, @NotNull final String text, final int inputLength, @NotNull final String trueValue, @NotNull final String falseValue) { + super(nameOld, nameNew, text, inputLength, null); + this.trueValue = trueValue; + this.falseValue = falseValue; } /** {@inheritDoc} */ @Override public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { final JCheckBox input; - final String trueVal = getMisc()[0]; - if (trueVal.equals("0")) { + if (trueValue.equals("0")) { final String attrString = gameObject.getAttributeString(nameOld); input = new JCheckBox(getNameNew(), attrString.length() == 0 || attrString.equals("0")); } else { - input = new JCheckBox(getNameNew(), gameObject.getAttributeString(nameOld).equals(trueVal)); + input = new JCheckBox(getNameNew(), gameObject.getAttributeString(nameOld).equals(trueValue)); } return new GuiInfo<G, A, R>(new DialogAttribBoolSpec<G, A, R>(this, input), null, input, null, null, false); } + /** + * Returns the true value. + * @return the true value + */ + @NotNull + public String getTrueValue() { + return trueValue; + } + + /** + * Returns the false value. + * @return the false value + */ + @NotNull + public String getFalseValue() { + return falseValue; + } + } // class ArchetypeAttributeBoolSpec Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-08-07 19:39:53 UTC (rev 4789) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-08-07 19:46:31 UTC (rev 4790) @@ -215,10 +215,9 @@ return null; } - final String[] misc = new String[2]; // 'misc' string contains the values - misc[0] = trueAttr.getValue().trim(); // string for true - misc[1] = falseAttr.getValue().trim(); // string for false - return new ArchetypeAttributeBoolSpec(nameOld, nameNew, text, inputLength, misc); + final String trueValue = trueAttr.getValue().trim(); + final String falseValue = falseAttr.getValue().trim(); + return new ArchetypeAttributeBoolSpec(nameOld, nameNew, text, inputLength, trueValue, falseValue); } else if (atype.equalsIgnoreCase("int")) { return new ArchetypeAttributeInt(nameOld, nameNew, text, inputLength, null); } else if (atype.equalsIgnoreCase("long")) { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBoolSpec.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBoolSpec.java 2008-08-07 19:39:53 UTC (rev 4789) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBoolSpec.java 2008-08-07 19:46:31 UTC (rev 4790) @@ -24,6 +24,7 @@ import javax.swing.text.Document; import javax.swing.text.Style; import net.sf.gridarta.archtype.ArchetypeAttribute; +import net.sf.gridarta.archtype.ArchetypeAttributeBoolSpec; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -46,9 +47,9 @@ public String getText2(@NotNull final G gameObject, @NotNull final R archetype, final String[] newName, final String[] newFace, final String[] newMsg, final String[] newAnim, final ArchetypeType typeStruct, final Component parent) { final String valString; // value-string to apply if (getInput().isSelected()) { - valString = ref.getMisc()[0]; // true string + valString = ((ArchetypeAttributeBoolSpec<G, A, R>) ref).getTrueValue(); } else { - valString = ref.getMisc()[1]; // false string + valString = ((ArchetypeAttributeBoolSpec<G, A, R>) ref).getFalseValue(); } // now see if we need to write it into the archtext or not if ((valString.equals("0") && !(archetype.getAttributeString(ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(ref.getNameOld()).equals(valString))) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |