From: <chr...@us...> - 2006-05-26 11:01:31
|
Revision: 27 Author: christianhujer Date: 2006-05-26 03:55:45 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=27&view=rev Log Message: ----------- Applied automatic code formatting. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/BshThread.java trunk/crossfire/src/cfeditor/CArchPanel.java trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CArchQuickView.java trunk/crossfire/src/cfeditor/CAttribBitmask.java trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CDialogBase.java trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/crossfire/src/cfeditor/CFArchType.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/CFHelp.java trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CFancyButton.java trunk/crossfire/src/cfeditor/CFileInputStream.java trunk/crossfire/src/cfeditor/CFileReader.java trunk/crossfire/src/cfeditor/CFilterControl.java trunk/crossfire/src/cfeditor/CGUIUtils.java trunk/crossfire/src/cfeditor/CGridderException.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java trunk/crossfire/src/cfeditor/CMainStatusbar.java trunk/crossfire/src/cfeditor/CMainToolbar.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapControl.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/crossfire/src/cfeditor/CMapModel.java trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CMapViewIFrame.java trunk/crossfire/src/cfeditor/CMapViewInterface.java trunk/crossfire/src/cfeditor/CNewMapDialog.java trunk/crossfire/src/cfeditor/COptionDialog.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/CResourceLoader.java trunk/crossfire/src/cfeditor/CScriptController.java trunk/crossfire/src/cfeditor/CScriptModel.java trunk/crossfire/src/cfeditor/CScriptView.java trunk/crossfire/src/cfeditor/CSettings.java trunk/crossfire/src/cfeditor/CStartupScreen.java trunk/crossfire/src/cfeditor/CUndoStack.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/ExitTypes.java trunk/crossfire/src/cfeditor/FaceObject.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/IUndoable.java trunk/crossfire/src/cfeditor/IdGenerator.java trunk/crossfire/src/cfeditor/JFontChooser.java trunk/crossfire/src/cfeditor/JarResources.java trunk/crossfire/src/cfeditor/MapArchObject.java trunk/crossfire/src/cfeditor/MultiArchData.java trunk/crossfire/src/cfeditor/MultiPositionData.java trunk/crossfire/src/cfeditor/PluginParameter.java trunk/crossfire/src/cfeditor/PluginParameterFactory.java trunk/crossfire/src/cfeditor/PluginParameterView.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/ScriptArchData.java trunk/crossfire/src/cfeditor/TrackedBufferedInputStream.java trunk/crossfire/src/cfeditor/arch/ArchObject.java trunk/crossfire/src/cfeditor/arch/ArchObjectIterator.java trunk/crossfire/src/cfeditor/arch/ArchObjectIteratorDeleteArchMapObject.java trunk/crossfire/src/cfeditor/arch/ArchObjectIteratorDeleteMapArch.java trunk/crossfire/src/cfeditor/arch/ArchObjectParser.java trunk/crossfire/src/cfeditor/arch/ArchObjectStack.java trunk/crossfire/src/cfeditor/arch/anim/AnimationObjects.java trunk/crossfire/src/cfeditor/filter/AttributeFilter.java trunk/crossfire/src/cfeditor/filter/BasicFilterConfig.java trunk/crossfire/src/cfeditor/filter/ConfigEvent.java trunk/crossfire/src/cfeditor/filter/ConfigListener.java trunk/crossfire/src/cfeditor/filter/Filter.java trunk/crossfire/src/cfeditor/filter/FilterConfig.java trunk/crossfire/src/cfeditor/filter/NamedFilterConfig.java trunk/crossfire/src/cfeditor/filter/NamedFilterEvent.java trunk/crossfire/src/cfeditor/filter/NamedFilterList.java trunk/crossfire/src/cfeditor/filter/NamedFilterListener.java trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java trunk/crossfire/src/cfeditor/gui/ScriptEditor.java trunk/crossfire/src/cfeditor/gui/ScriptManager.java trunk/crossfire/src/cfeditor/gui/StackLayout.java trunk/crossfire/src/cfeditor/menu/AggregateMenuLocation.java trunk/crossfire/src/cfeditor/menu/BasicAction.java trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java trunk/crossfire/src/cfeditor/menu/CheckBoxMenuEntry.java trunk/crossfire/src/cfeditor/menu/FilterCheckBoxEntry.java trunk/crossfire/src/cfeditor/menu/LocationMenuEntry.java trunk/crossfire/src/cfeditor/menu/MenuChangeEvent.java trunk/crossfire/src/cfeditor/menu/MenuEntry.java trunk/crossfire/src/cfeditor/menu/MenuGroup.java trunk/crossfire/src/cfeditor/menu/MenuHelper.java trunk/crossfire/src/cfeditor/menu/MenuListener.java trunk/crossfire/src/cfeditor/menu/MenuLocation.java trunk/crossfire/src/cfeditor/menu/MenuManager.java trunk/crossfire/src/cfeditor/menu/SeparatorMenuEntry.java trunk/crossfire/src/cfeditor/menu/SimpleMenuEntry.java trunk/crossfire/src/cfeditor/menu/SimpleMenuLocation.java trunk/crossfire/src/cfeditor/menu/SwitchedMenuEntry.java trunk/crossfire/src/cfeditor/parameter/ArchParameter.java trunk/crossfire/src/cfeditor/parameter/ArchParameterView.java trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java trunk/crossfire/src/cfeditor/parameter/BooleanParameterView.java trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java trunk/crossfire/src/cfeditor/parameter/FilterParameter.java trunk/crossfire/src/cfeditor/parameter/FilterParameterView.java trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java trunk/crossfire/src/cfeditor/parameter/MapParameter.java trunk/crossfire/src/cfeditor/parameter/MapParameterView.java trunk/crossfire/src/cfeditor/parameter/ParameterDescriptionEditor.java trunk/crossfire/src/cfeditor/parameter/ParameterNameEditor.java trunk/crossfire/src/cfeditor/parameter/ParameterTypeEditor.java trunk/crossfire/src/cfeditor/parameter/StringParameter.java trunk/crossfire/src/cfeditor/parameter/StringParameterView.java trunk/crossfire/src/cfeditor/textedit/scripteditor/CFPythonPopup.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditControl.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditMenuBar.java trunk/crossfire/src/cfeditor/textedit/scripteditor/ScriptEditView.java trunk/crossfire/src/cfeditor/textedit/textarea/CTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/DefaultInputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/HTMLTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/InputHandler.java trunk/crossfire/src/cfeditor/textedit/textarea/JEditTextArea.java trunk/crossfire/src/cfeditor/textedit/textarea/JavaScriptTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/KeywordMap.java trunk/crossfire/src/cfeditor/textedit/textarea/PythonTokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxDocument.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxStyle.java trunk/crossfire/src/cfeditor/textedit/textarea/SyntaxUtilities.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaDefaults.java trunk/crossfire/src/cfeditor/textedit/textarea/TextAreaPainter.java trunk/crossfire/src/cfeditor/textedit/textarea/TextUtilities.java trunk/crossfire/src/cfeditor/textedit/textarea/Token.java trunk/crossfire/src/cfeditor/textedit/textarea/TokenMarker.java trunk/crossfire/src/cfeditor/textedit/textarea/XMLTokenMarker.java trunk/daimonin/src/daieditor/ArchUpdater.java trunk/daimonin/src/daieditor/CArchPanel.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CArchQuickView.java trunk/daimonin/src/daieditor/CAttribBitmask.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CFArchAttrib.java trunk/daimonin/src/daieditor/CFArchType.java trunk/daimonin/src/daieditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CFJavaEditor.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CFileInputStream.java trunk/daimonin/src/daieditor/CFileReader.java trunk/daimonin/src/daieditor/CGUIUtils.java trunk/daimonin/src/daieditor/CGridderException.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainStatusbar.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CMapFileEncode.java trunk/daimonin/src/daieditor/CMapTileList.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CMapViewIFrame.java trunk/daimonin/src/daieditor/CNewMapDialog.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CPreview.java trunk/daimonin/src/daieditor/CUndoStack.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/IGUIConstants.java trunk/daimonin/src/daieditor/IUndoable.java trunk/daimonin/src/daieditor/MapTilePane.java trunk/daimonin/src/daieditor/MultiArchData.java trunk/daimonin/src/daieditor/MultiPositionData.java trunk/daimonin/src/daieditor/PathManager.java trunk/daimonin/src/daieditor/ProcessRunner.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/ResourceFileManager.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/Spells.java trunk/daimonin/src/daieditor/SplashScreen.java trunk/daimonin/src/daieditor/Updater.java trunk/daimonin/src/daieditor/arch/ArchAttribType.java trunk/daimonin/src/daieditor/arch/ArchObject.java trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java trunk/daimonin/src/daieditor/arch/ArchObjectIterator.java trunk/daimonin/src/daieditor/arch/ArchObjectParser.java trunk/daimonin/src/daieditor/arch/ArchObjectStack.java trunk/daimonin/src/daieditor/arch/DuplicateArchException.java trunk/daimonin/src/daieditor/arch/NamedObject.java trunk/daimonin/src/daieditor/arch/NamedObjects.java trunk/daimonin/src/daieditor/arch/NamedTreeNode.java trunk/daimonin/src/daieditor/arch/RecursiveArchObjectIterator.java trunk/daimonin/src/daieditor/arch/anim/AnimationObject.java trunk/daimonin/src/daieditor/arch/anim/AnimationObjects.java trunk/daimonin/src/daieditor/arch/anim/AnimationParseException.java trunk/daimonin/src/daieditor/arch/anim/DuplicateAnimationException.java trunk/daimonin/src/daieditor/arch/face/DuplicateFaceException.java trunk/daimonin/src/daieditor/arch/face/FaceFacade.java trunk/daimonin/src/daieditor/arch/face/FaceObject.java trunk/daimonin/src/daieditor/arch/face/FaceObjects.java trunk/daimonin/src/daieditor/arch/match/AndArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/ArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/ArchObjectMatchers.java trunk/daimonin/src/daieditor/arch/match/AttribArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/MutableNameArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/MutableOrArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/NamedArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/NotArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/OrArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/TypeNrsArchObjectMatcher.java trunk/daimonin/src/daieditor/arch/match/ViewArchObjectMatcherManager.java trunk/daimonin/src/daieditor/gui/AboutDialog.java trunk/daimonin/src/daieditor/gui/ConnectionView.java trunk/daimonin/src/daieditor/gui/DirectionLayout.java trunk/daimonin/src/daieditor/gui/ErrorListView.java trunk/daimonin/src/daieditor/gui/HideFileFilterProxy.java trunk/daimonin/src/daieditor/gui/MapFileFilter.java trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java trunk/daimonin/src/daieditor/gui/map/MapCursor.java trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java trunk/daimonin/src/daieditor/gui/map/MapCursorEvent.java trunk/daimonin/src/daieditor/gui/map/MapCursorListener.java trunk/daimonin/src/daieditor/gui/map/MapGrid.java trunk/daimonin/src/daieditor/gui/map/MapGridEvent.java trunk/daimonin/src/daieditor/gui/map/MapGridListener.java trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/gui/map/MapUserListener.java trunk/daimonin/src/daieditor/gui/map/MapViewSettings.java trunk/daimonin/src/daieditor/gui/map/MapViewSettingsEvent.java trunk/daimonin/src/daieditor/gui/map/MapViewSettingsListener.java trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java trunk/daimonin/src/daieditor/gui/prefs/DevPrefs.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/daimonin/src/daieditor/gui/prefs/MapValidatorPrefs.java trunk/daimonin/src/daieditor/gui/prefs/MiscPrefs.java trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java trunk/daimonin/src/daieditor/help/DHelp.java trunk/daimonin/src/daieditor/icons/AbstractFaceProvider.java trunk/daimonin/src/daieditor/icons/ArchFaceProvider.java trunk/daimonin/src/daieditor/icons/DaimoninFaceProvider.java trunk/daimonin/src/daieditor/icons/FaceProvider.java trunk/daimonin/src/daieditor/icons/FilterFaceProvider.java trunk/daimonin/src/daieditor/map/ArchOutOfMapBoundsException.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapEvent.java trunk/daimonin/src/daieditor/map/MapListener.java trunk/daimonin/src/daieditor/map/MapModel.java trunk/daimonin/src/daieditor/map/MapModelEvent.java trunk/daimonin/src/daieditor/map/MapModelListener.java trunk/daimonin/src/daieditor/map/MapSquare.java trunk/daimonin/src/daieditor/map/validation/AbstractValidator.java trunk/daimonin/src/daieditor/map/validation/ArchValidationError.java trunk/daimonin/src/daieditor/map/validation/ArchValidator.java trunk/daimonin/src/daieditor/map/validation/ArchesValidationError.java trunk/daimonin/src/daieditor/map/validation/CorrectableError.java trunk/daimonin/src/daieditor/map/validation/DefaultErrorCollector.java trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java trunk/daimonin/src/daieditor/map/validation/ErrorCollector.java trunk/daimonin/src/daieditor/map/validation/ErrorHandler.java trunk/daimonin/src/daieditor/map/validation/MapValidationError.java trunk/daimonin/src/daieditor/map/validation/MapValidator.java trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java trunk/daimonin/src/daieditor/map/validation/SquareValidator.java trunk/daimonin/src/daieditor/map/validation/ValidationError.java trunk/daimonin/src/daieditor/map/validation/Validator.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleArchError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ExitError.java trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java trunk/daimonin/src/daieditor/map/validation/checks/TilePathsChecker.java trunk/daimonin/src/daieditor/map/validation/checks/TilePathsError.java trunk/daimonin/src/daieditor/swing/DSplitPane.java trunk/daimonin/src/daieditor/textedit/scripteditor/CFPythonPopup.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditControl.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditMenuBar.java trunk/daimonin/src/daieditor/textedit/scripteditor/ScriptEditView.java trunk/daimonin/src/daieditor/textedit/textarea/CTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/DefaultInputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/HTMLTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/InputHandler.java trunk/daimonin/src/daieditor/textedit/textarea/JEditTextArea.java trunk/daimonin/src/daieditor/textedit/textarea/JavaScriptTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/KeywordMap.java trunk/daimonin/src/daieditor/textedit/textarea/LuaTokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxDocument.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxStyle.java trunk/daimonin/src/daieditor/textedit/textarea/SyntaxUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaDefaults.java trunk/daimonin/src/daieditor/textedit/textarea/TextAreaPainter.java trunk/daimonin/src/daieditor/textedit/textarea/TextUtilities.java trunk/daimonin/src/daieditor/textedit/textarea/Token.java trunk/daimonin/src/daieditor/textedit/textarea/TokenMarker.java trunk/daimonin/src/daieditor/textedit/textarea/XMLTokenMarker.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-05-26 10:55:45 UTC (rev 27) @@ -34,18 +34,21 @@ /** * The <code>AutojoinList</code> class contains a list of (typically wall-)arches which * do autojoining. - * * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ public class AutojoinList { + private static final Logger log = Logger.getLogger(AutojoinList.class); private static final String filename = "autojoin.txt"; // file with autojoin lists // bitmask constants for nodenr index private static final int NORTH = 1; + private static final int EAST = 2; + private static final int SOUTH = 4; + private static final int WEST = 8; private ArchObjectStack stack; // reference to the stack of default arches @@ -58,10 +61,8 @@ // (0 = no connection, N = north, E = east, S = south, W = west) private int[] nodenr; - /** - * Konstructor - */ - public AutojoinList () { + /** Konstructor */ + public AutojoinList() { stack = null; // pointer to stack of default arches next = null; // pointer to next element nodenr = null; // this array gets initialized in loadList (when needed) @@ -73,11 +74,10 @@ * to the (head) instance which it is called from. * The links from the default arches to their appropriate * AutojoinLists also get set here. - * + * <p/> * Note that this method takes only split seconds to execute, * as it uses the arch hashtable to look up the default arches. :-) - * - * @param archstack the stack of default arches + * @param archstack the stack of default arches * @return true if at least one autojoin list was successfully loaded */ public boolean loadList(ArchObjectStack archstack) { @@ -89,10 +89,10 @@ int[] nbuf = new int[16]; // buffer for nodenumbers of 16 arches int count = 0; // counter index AutojoinList jlist = this; // index of the linked list of AutojoinLists - // (starting at 'this') + // (starting at 'this') // open the resource file - String baseDir = (IGUIConstants.isoView ? CMainControl.getInstance().getArchDefaultFolder()+File.separator+IGUIConstants.CONFIG_DIR : IGUIConstants.CONFIG_DIR); + String baseDir = (IGUIConstants.isoView ? CMainControl.getInstance().getArchDefaultFolder() + File.separator + IGUIConstants.CONFIG_DIR : IGUIConstants.CONFIG_DIR); CFileReader stream = new CFileReader(baseDir, filename); // read the file @@ -123,15 +123,15 @@ jlist.nodenr[i] = nbuf[i]; // store nodenr. in the list archstack.getArch(nbuf[i]).setJoinList(jlist); // set the link in the def. arch if (log.isDebugEnabled()) { - log.debug("("+i+") arch: '"+archstack.getArch(nbuf[i]).getArchName()+"' -> nr: ("+nbuf[i]+")"); + log.debug("(" + i + ") arch: '" + archstack.getArch(nbuf[i]).getArchName() + "' -> nr: (" + nbuf[i] + ")"); } } success = true; // we did it! } else if (count > 16) { - log.warn("In file "+filename+": List with more than 16 valid entries!"); + log.warn("In file " + filename + ": List with more than 16 valid entries!"); } else if (archstack.getArchCount() >= 1) { - log.warn("In file "+filename+": List with less than 16 valid entries!"); + log.warn("In file " + filename + ": List with less than 16 valid entries!"); } section_flag = false; } else if (count < 16) { @@ -147,17 +147,17 @@ if (!archstack.getArch(nbuf[count]).isMulti()) { count++; // no multipart, this one's okay } else { - log.warn("In file "+filename+": Arch '"+line+"' is a multipart."); + log.warn("In file " + filename + ": Arch '" + line + "' is a multipart."); } } else { // (If no arches exist at all, errormessages are suppressed here) if (archstack.getArchCount() >= 1) { - log.warn("In file "+filename+": Arch '"+line+"' not found."); + log.warn("In file " + filename + ": Arch '" + line + "' not found."); } } } catch (NumberFormatException e) { // parsing failed (should not happen) - log.error("ArchObjectStack Hashtable entry '"+entry.toString()+"' not parseable as int!", e); + log.error("ArchObjectStack Hashtable entry '" + entry.toString() + "' not parseable as int!", e); } } else { count++; // too many arches @@ -170,11 +170,11 @@ stream.close(); } catch (FileNotFoundException e) { if (log.isInfoEnabled()) { - log.info("Autojoin definitions file '"+filename+"' not found."); + log.info("Autojoin definitions file '" + filename + "' not found."); } return false; } catch (IOException e) { - log.warn("Read error in file '"+filename+"'."); + log.warn("Read error in file '" + filename + "'."); return false; } @@ -191,11 +191,9 @@ * node_nr of the correct arch to be inserted is returned. * This method must be called from the appropriate element of the * AutojoinList, best use the link from the default arch. - * - * @param x Location of the insert point on the map - * @param y Location of the insert point on the map - * @param map Data model of the map - * + * @param x Location of the insert point on the map + * @param y Location of the insert point on the map + * @param map Data model of the map * @return node_nr of the (def.) arch to be inserted at x, y * -1 if there's already an arch of this list on x, y */ @@ -209,29 +207,29 @@ } // now do the joining in all four directions: - if (map.pointValid(x, y-1)) { - if ((arch = findArchOfJoinlist(map, x, y-1)) != null) { + if (map.pointValid(x, y - 1)) { + if ((arch = findArchOfJoinlist(map, x, y - 1)) != null) { new_index = add_dir(new_index, NORTH); connectArch(arch, nodenr[add_dir(get_index(arch.getNodeNr()), SOUTH)]); } } - if (map.pointValid(x+1, y)) { - if ((arch = findArchOfJoinlist(map, x+1, y)) != null) { + if (map.pointValid(x + 1, y)) { + if ((arch = findArchOfJoinlist(map, x + 1, y)) != null) { new_index = add_dir(new_index, EAST); connectArch(arch, nodenr[add_dir(get_index(arch.getNodeNr()), WEST)]); } } - if (map.pointValid(x, y+1)) { - if ((arch = findArchOfJoinlist(map, x, y+1)) != null) { + if (map.pointValid(x, y + 1)) { + if ((arch = findArchOfJoinlist(map, x, y + 1)) != null) { new_index = add_dir(new_index, SOUTH); connectArch(arch, nodenr[add_dir(get_index(arch.getNodeNr()), NORTH)]); } } - if (map.pointValid(x-1, y)) { - if ((arch = findArchOfJoinlist(map, x-1, y)) != null) { + if (map.pointValid(x - 1, y)) { + if ((arch = findArchOfJoinlist(map, x - 1, y)) != null) { new_index = add_dir(new_index, WEST); connectArch(arch, nodenr[add_dir(get_index(arch.getNodeNr()), EAST)]); } @@ -245,35 +243,34 @@ * All arches around the insert point get adjusted. * This method must be called from the appropriate element of the * AutojoinList, best use the link from the default arch. - * - * @param x Location of the insert point on the map - * @param y Location of the insert point on the map - * @param map Data model of the map + * @param x Location of the insert point on the map + * @param y Location of the insert point on the map + * @param map Data model of the map */ public void join_delete(CMapModel map, int x, int y) { ArchObject arch = null; // temp. arch // do the joining in all four directions: - if (map.pointValid(x, y-1)) { - if ((arch = findArchOfJoinlist(map, x, y-1)) != null) { + if (map.pointValid(x, y - 1)) { + if ((arch = findArchOfJoinlist(map, x, y - 1)) != null) { connectArch(arch, nodenr[remove_dir(get_index(arch.getNodeNr()), SOUTH)]); } } - if (map.pointValid(x+1, y)) { - if ((arch = findArchOfJoinlist(map, x+1, y)) != null) { + if (map.pointValid(x + 1, y)) { + if ((arch = findArchOfJoinlist(map, x + 1, y)) != null) { connectArch(arch, nodenr[remove_dir(get_index(arch.getNodeNr()), WEST)]); } } - if (map.pointValid(x, y+1)) { - if ((arch = findArchOfJoinlist(map, x, y+1)) != null) { + if (map.pointValid(x, y + 1)) { + if ((arch = findArchOfJoinlist(map, x, y + 1)) != null) { connectArch(arch, nodenr[remove_dir(get_index(arch.getNodeNr()), NORTH)]); } } - if (map.pointValid(x-1, y)) { - if ((arch = findArchOfJoinlist(map, x-1, y)) != null) { + if (map.pointValid(x - 1, y)) { + if ((arch = findArchOfJoinlist(map, x - 1, y)) != null) { connectArch(arch, nodenr[remove_dir(get_index(arch.getNodeNr()), EAST)]); } } @@ -281,14 +278,15 @@ /** * Looking up the given node in the nodenr-array of this class. - * - * @param node node to lookup + * @param node node to lookup * @return index of the node in the array. */ private int get_index(int node) { int i; - for (i = 0; i < 16 && node != nodenr[i]; i++); + for (i = 0; i < 16 && node != nodenr[i]; i++) { + ; + } if (node != nodenr[i]) { log.warn("Error in AutojoinList.get_index: index not found"); @@ -298,34 +296,27 @@ return i; } - /** - * Checks if the index (=bitmask) contains the following direction - */ + /** Checks if the index (=bitmask) contains the following direction */ private boolean has_dir(int index, int direction) { - return (index&direction) != 0; + return (index & direction) != 0; } - /** - * add direction to the index - */ + /** add direction to the index */ private int add_dir(int index, int direction) { - return index|direction; + return index | direction; } - /** - * remove direction from the index - */ + /** remove direction from the index */ private int remove_dir(int index, int direction) { - return index&~direction; + return index & ~direction; } /** * Looks for an arch at map-position (x, y) which is part * of this AutojoinList. - * - * @param map the data model of the map - * @param x location to search - * @param y location to search + * @param map the data model of the map + * @param x location to search + * @param y location to search * @return arch which is part of this joinlist, null if no such arch exists */ private ArchObject findArchOfJoinlist(CMapModel map, int x, int y) { Modified: trunk/crossfire/src/cfeditor/BshThread.java =================================================================== --- trunk/crossfire/src/cfeditor/BshThread.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/BshThread.java 2006-05-26 10:55:45 UTC (rev 27) @@ -4,6 +4,7 @@ * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ + package cfeditor; import bsh.EvalError; @@ -11,14 +12,16 @@ /** * @author tchize - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments + * <p/> + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments */ public class BshThread extends Thread { private CScriptModel script; + private Interpreter interpreter; + /** * */ @@ -26,9 +29,7 @@ super(); } - /** - * @param name - */ + /** @param name */ public BshThread(String name) { super(name); } @@ -41,7 +42,7 @@ super(group, name); } - public void setInterpreter (Interpreter interpreter) { + public void setInterpreter(Interpreter interpreter) { this.interpreter = interpreter; } Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-05-26 10:55:45 UTC (rev 27) @@ -38,23 +38,32 @@ /** * The <code>CArchPanel</code> holds the tile palette. - * * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ public class CArchPanel extends JPanel { + private static final String ARCHPANEL_LOCATION_KEY = "MainWindowArchPanel.dividerLocation"; + /** Controller of this subview. */ private final CMainControl m_control; + /** The "Import..." button. */ private int selectedArch; + private final JTabbedPane m_archAndPickPane; // panel holding both archlist and pickmaps + private final CSplitPane m_splitPane; // our split pane + private final JTabbedPane m_tabDesktop; // the tab panel with arch lists + private final CArchQuickView archQuickPanel; // data/view of selected objects in tab panel + private static PanelNode panelNodeStart; // list of arch panels + private PanelNode panelNodeLast; + private CArchPanelPan m_selectedPanel; // the active panel private static final long serialVersionUID = 6634110300452920361L; @@ -87,7 +96,7 @@ // calculate default value in case there is no settings file Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - int divLocation = Integer.parseInt(settings.getProperty(ARCHPANEL_LOCATION_KEY, ""+(int)(0.77*0.9*screen.getHeight()))); + int divLocation = Integer.parseInt(settings.getProperty(ARCHPANEL_LOCATION_KEY, "" + (int) (0.77 * 0.9 * screen.getHeight()))); m_splitPane.setDividerLocation(divLocation); m_splitPane.setDividerSize(5); @@ -96,7 +105,7 @@ // we must set the list of the selected list depend on combo selection m_tabDesktop.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { - JTabbedPane tp = (JTabbedPane)e.getSource(); + JTabbedPane tp = (JTabbedPane) e.getSource(); // This is weird: we need to compare against SelectedComponent, // and *not* SelectedIndex. The index seemed to get all messed up during @@ -119,9 +128,7 @@ return panelNodeStart; } - /** - * Move the pickmap panel in front of the default-archpanel - */ + /** Move the pickmap panel in front of the default-archpanel */ public void movePickmapPanelToFront() { if (m_archAndPickPane != null && m_archAndPickPane.getTabCount() > 1) { m_archAndPickPane.setSelectedIndex(1); @@ -177,7 +184,9 @@ // insert new panels in alphabetical order int i; - for (i = 0; i < m_tabDesktop.getTabCount() && name.compareToIgnoreCase(m_tabDesktop.getTitleAt(i)) < 0; i++); + for (i = 0; i < m_tabDesktop.getTabCount() && name.compareToIgnoreCase(m_tabDesktop.getTitleAt(i)) < 0; i++) { + ; + } this.m_tabDesktop.insertTab(name, null, newnode.data.getPanel(), null, i); // careful: during the build proccess we are setting 'm_selectedPanel' @@ -205,7 +214,7 @@ void appExitNotify() { CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - settings.setProperty(ARCHPANEL_LOCATION_KEY, ""+m_splitPane.getDividerLocation()); + settings.setProperty(ARCHPANEL_LOCATION_KEY, "" + m_splitPane.getDividerLocation()); } public int getPanelArch() { @@ -227,8 +236,11 @@ } public class PanelNode { + public CArchPanelPan data; + public PanelNode next; // next node + String title; // title of this PanelNode public PanelNode(CArchPanelPan data, String title) { @@ -242,10 +254,9 @@ } } - /** - * Splitpane class that keeps its size even upon L'n'F change. - */ + /** Splitpane class that keeps its size even upon L'n'F change. */ public class CSplitPane extends JSplitPane { + private static final long serialVersionUID = -2537906454141191712L; public CSplitPane(int newOrientation, Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-05-26 10:55:45 UTC (rev 27) @@ -43,17 +43,26 @@ import org.apache.log4j.Logger; public class CArchPanelPan extends JPanel { + private static final Logger log = Logger.getLogger(CArchPanel.class); + /** Controller of this subview. */ private final CMainControl m_control; private final JList m_list; + private final DefaultListModel model; + private final JPanel m_panelDesktop; + private final JComboBox jbox; + private final StringBuffer list; + private int listcounter; + private int combo_counter; + private final CArchPanel m_panel; private static final long serialVersionUID = 8690200410771201444L; @@ -103,7 +112,7 @@ // In JDK 1.4 it is required to transfer focus back to mapview after // every click in the panel, otherwise the menu-shortcuts stop working if (m_control.getCurrentMap() != null && - m_control.getCurrentMap().getMapView() != null) { + m_control.getCurrentMap().getMapView() != null) { m_control.getCurrentMap().getMapView().requestFocus(); // focus to mapview } } @@ -134,7 +143,8 @@ This happens in JDK 1.4 when you select an arch in panel A, then select Panel B, then Panel A again. (why??) */ - } catch (NumberFormatException e) {} + } catch (NumberFormatException e) { + } } m_control.showArchPanelQuickObject(arch); // send it to quick view } @@ -145,11 +155,11 @@ String def = "00000"; String num = Integer.toString(archnr); - this.list.append(def.substring(0, 5-num.length())); + this.list.append(def.substring(0, 5 - num.length())); this.list.append(num); num = Integer.toString(index); - this.list.append(def.substring(0, 5-num.length())); + this.list.append(def.substring(0, 5 - num.length())); this.list.append(num); this.listcounter++; @@ -180,10 +190,10 @@ * @return an array of nodenumbers from all arches in this panel */ public int[] getListNodeNrArray() { - int[] numList = new int[(int)(list.length()/10.)]; + int[] numList = new int[(int) (list.length() / 10.)]; - for (int i = 0; i < (int)(list.length()/10.); i++) { - numList[i] = Integer.parseInt(list.substring(0+10*i, 5+10*i)); + for (int i = 0; i < (int) (list.length() / 10.); i++) { + numList[i] = Integer.parseInt(list.substring(0 + 10 * i, 5 + 10 * i)); //log.debug(CMainControl.getInstance().getArchObjectStack().getArch(numList[i]).getArchName()); } @@ -197,12 +207,12 @@ * note that the same indices are used for same arches in 'getListNodeNrArray()' */ public String[] getListCathegoryArray() { - String[] cathList = new String[(int)(list.length()/10.)]; + String[] cathList = new String[(int) (list.length() / 10.)]; int index; - for (int i = 0; i < (int)(list.length()/10.); i++) { + for (int i = 0; i < (int) (list.length() / 10.); i++) { try { - index = Integer.parseInt(list.substring(5+10*i, 10+10*i)); + index = Integer.parseInt(list.substring(5 + 10 * i, 10 + 10 * i)); cathList[i] = jbox.getItemAt(index).toString().trim(); } catch (NullPointerException e) { log.warn("Nullpointer in getListCathegoryArray()!", e); @@ -226,10 +236,10 @@ if (index >= 0) { if (index == 0) { // this.model.addElement(this.list.substring(offset, offset+5)+" I:"+this.list.substring(offset+5, offset+10)); - this.model.addElement(this.list.substring(offset, offset+5)); + this.model.addElement(this.list.substring(offset, offset + 5)); } else { - if (index == Integer.parseInt(this.list.substring(offset+5, offset+10))) { - this.model.addElement(this.list.substring(offset, offset+5)); + if (index == Integer.parseInt(this.list.substring(offset + 5, offset + 10))) { + this.model.addElement(this.list.substring(offset, offset + 5)); } } } @@ -261,7 +271,7 @@ ArchObject arch = m_control.getArchObjectStack().getArch(Integer.parseInt(value.toString())); if (iss) { m_panel.setPanelArch(Integer.parseInt(value.toString())); - m_control.setStatusText(" "+value.toString()+" "); + m_control.setStatusText(" " + value.toString() + " "); } m_control.setPlainFont(this); setText(arch.getArchName()); Modified: trunk/crossfire/src/cfeditor/CArchQuickView.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-05-26 10:55:45 UTC (rev 27) @@ -36,15 +36,19 @@ /** * The <code>CArchQuickView</code> holds the tile palette. - * * @author <a href="mailto:mic...@no...">Michael Toennies</a> */ public class CArchQuickView extends JPanel { + /** Controller of this subview. */ private final CMainControl m_control; + private final JLabel archArchNameText = new JLabel(); + private final JLabel archObjNameText = new JLabel(); + private final JLabel archTypeText = new JLabel(); + private final JLabel archTileText = new JLabel(); private static final long serialVersionUID = -5176382751320643475L; @@ -115,33 +119,33 @@ return; } - archArchNameText.setText("<html><font color=black>Arch: "+arch.getArchName()+"</font></html>"); + archArchNameText.setText("<html><font color=black>Arch: " + arch.getArchName() + "</font></html>"); if (arch.getObjName() == null || arch.getObjName().length() <= 0) { ArchObject def = arch.getDefaultArch(); if (def == null || def == arch) { archObjNameText.setText("<html><font color=black>Name: -none- </font></html>"); } else if (def.getObjName() != null && def.getObjName().length() > 0) { - archObjNameText.setText("<html><font color=black>Name: "+def.getObjName()+"</font></html>"); + archObjNameText.setText("<html><font color=black>Name: " + def.getObjName() + "</font></html>"); } else if (def.getArchName() != null && def.getArchName().length() > 0) { - archObjNameText.setText("<html><font color=black>Name: "+def.getArchName()+"</font></html>"); + archObjNameText.setText("<html><font color=black>Name: " + def.getArchName() + "</font></html>"); } else { archObjNameText.setText("<html><font color=black>Name: -none- </font></html>"); } } else { - archObjNameText.setText("<html><font color=black>Name: "+arch.getObjName()+"</font></html>"); + archObjNameText.setText("<html><font color=black>Name: " + arch.getObjName() + "</font></html>"); } - archTypeText.setText("<html><font color=black>Type: "+ - m_control.getArchObjectParser().getArchTypeName(arch.getArchTypNr()) - +" ("+arch.getArchTypNr()+") </font></html>"); + archTypeText.setText("<html><font color=black>Type: " + + m_control.getArchObjectParser().getArchTypeName(arch.getArchTypNr()) + + " (" + arch.getArchTypNr() + ") </font></html>"); if (arch.getRefCount() > 0) { - archTileText.setText("<html><font color=black>Tile: </font><font color=green> multi</font><font color=black> ("+ - +(arch.getRefCount()+1)+" parts) ("+(arch.getRefMaxX()-arch.getRefMaxMX()+1)+","+(arch.getRefMaxY()-arch.getRefMaxMY()+1) - +")</font></html>"); + archTileText.setText("<html><font color=black>Tile: </font><font color=green> multi</font><font color=black> (" + + +(arch.getRefCount() + 1) + " parts) (" + (arch.getRefMaxX() - arch.getRefMaxMX() + 1) + "," + (arch.getRefMaxY() - arch.getRefMaxMY() + 1) + + ")</font></html>"); } else { archTileText.setText("<html><font color=black>Tile: single" - +"</font></html>"); + + "</font></html>"); } // notify ReplaceDialog Modified: trunk/crossfire/src/cfeditor/CAttribBitmask.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribBitmask.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/CAttribBitmask.java 2006-05-26 10:55:45 UTC (rev 27) @@ -47,11 +47,12 @@ * arch attributes. Attacktype, spellpath and material are such * bitmasks. They are disguised for the user, with the help of * the attribute dialog. - * * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ public class CAttribBitmask { + private static final Logger log = Logger.getLogger(CAttribBitmask.class); + // maximum number of characters in a line before linebreak (see getText()) //private static final int MAX_CHARS_PER_LINE = 50; private static final int MAX_CHARS_PER_LINE = 35; @@ -59,15 +60,16 @@ private final String[] bit_name; // array of the names of bitmask-entries private final int maxvalue; // max. possible value + private final int number; // number of bitmask entrys (not counting zero) /** * Konstructor of a bitmask (DEPRECATED!) - * @param name array of names for the bit-entries + * @param name array of names for the bit-entries */ public CAttribBitmask(String[] name) { // initialize arrays - bit_name = new String[name.length+1]; + bit_name = new String[name.length + 1]; //bit_value = new int[name.length+1]; // the zero-bit is always <none> @@ -76,17 +78,17 @@ for (int i = 0; i < name.length; i++) { // fill array and assign 2^i values - bit_name[i+1] = name[i]; + bit_name[i + 1] = name[i]; //bit_value[i+1] = (int)(Math.pow(2., (double)(i-1))); } - number = bit_name.length-1; - maxvalue = ((int)Math.pow(2., (double)(bit_name.length+1)))-1; + number = bit_name.length - 1; + maxvalue = ((int) Math.pow(2., (double) (bit_name.length + 1))) - 1; } /** * Konstructor of a bitmask from XML element - * @param root xml bitmask element + * @param root xml bitmask element */ public CAttribBitmask(Element root) { int i; @@ -99,7 +101,7 @@ // find highest bit number int max_bit = 0; for (i = 0; entries != null && i < entries.size(); i++) { - elem = (Element)entries.get(i); + elem = (Element) entries.get(i); if ((a = elem.getAttribute("bit")) == null || elem.getAttribute("name") == null) { log.warn("Parse error: Found bitmask entry without 'bit' or 'name'."); elem.detach(); // remove element from DOM tree @@ -110,7 +112,7 @@ max_bit = bit; // this is the highest bit so far } } catch (DataConversionException e) { - log.warn("Parse error: Bitmask bit '"+a.getValue()+"' ("+elem.getAttribute("name").getValue()+") is not an integer."); + log.warn("Parse error: Bitmask bit '" + a.getValue() + "' (" + elem.getAttribute("name").getValue() + ") is not an integer."); elem.detach(); // remove element from DOM tree } } @@ -118,34 +120,35 @@ entries = root.getChildren("entry"); // retake list, in case we detached some elements // initialize array - bit_name = new String[max_bit+2]; + bit_name = new String[max_bit + 2]; // initialize names array - the zero-bit always stays <none> - for (i = 0; i < max_bit+2; i++) { + for (i = 0; i < max_bit + 2; i++) { bit_name[i] = "<none>"; } for (i = 0; entries != null && i < entries.size(); i++) { - elem = (Element)entries.get(i); + elem = (Element) entries.get(i); // fill array and assign 2^i values try { - bit_name[elem.getAttribute("bit").getIntValue()+1] = elem.getAttribute("name").getValue(); - } catch (DataConversionException e) {} + bit_name[elem.getAttribute("bit").getIntValue() + 1] = elem.getAttribute("name").getValue(); + } catch (DataConversionException e) { + } } if (log.isDebugEnabled()) { - String s = "bitmask '"+root.getAttribute("name")+"':"; + String s = "bitmask '" + root.getAttribute("name") + "':"; for (i = 0; i < bit_name.length; i++) { - s = s+" "+i+" = "+bit_name[i]; + s = s + " " + i + " = " + bit_name[i]; } log.debug(s); } - number = bit_name.length-1; - maxvalue = ((int)Math.pow(2., (double)(bit_name.length+1)))-1; + number = bit_name.length - 1; + maxvalue = ((int) Math.pow(2., (double) (bit_name.length + 1))) - 1; } else { // Error: this is an "empty" bitmask - log.warn("Error in \""+IGUIConstants.TYPEDEF_FILE+"\": Found a bitmask without content!"); + log.warn("Error in \"" + IGUIConstants.TYPEDEF_FILE + "\": Found a bitmask without content!"); bit_name = new String[1]; bit_name[0] = "<none>"; number = 0; @@ -155,21 +158,20 @@ /** * check wether the given bit-index is an active bit in the bitmask - * @param index index of the bit to check (range from 1-'number') - * @param mask bitmask to check against + * @param index index of the bit to check (range from 1-'number') + * @param mask bitmask to check against * @return true if the bit-index is an active bit */ private boolean is_active(int index, int mask) { - return ((int)(Math.pow(2., (double)(index-1)))&mask) != 0; + return ((int) (Math.pow(2., (double) (index - 1))) & mask) != 0; } /** * Display the appropriate text for a given bitmask value. * The text is put into a non-editable textarea. - * - * @param value bitmask value - * @param textf if non-null, this textarea is used for drawing, - * if null, a new textarea is created and returned + * @param value bitmask value + * @param textf if non-null, this textarea is used for drawing, + * if null, a new textarea is created and returned * @return <code>JTextArea</code> with all entries belonging to the bitmask * and proper dimensions */ @@ -185,7 +187,7 @@ } else { // value too big? if (value > maxvalue) { - log.warn("bitmask value "+value+" is too big."); + log.warn("bitmask value " + value + " is too big."); } boolean linebreak = false; @@ -195,7 +197,7 @@ if (is_active(i, value)) { // is a linebreak required? linelength = text.indexOf("\n") >= 0 ? text.substring(text.lastIndexOf("\n")).length() : text.length(); - if (linelength+bit_name[i].length()+2 > MAX_CHARS_PER_LINE) { + if (linelength + bit_name[i].length() + 2 > MAX_CHARS_PER_LINE) { text += ", \n "; linebreak = true; rows++; @@ -204,7 +206,7 @@ } // append text - text += ((text.length() <= 1 || linebreak) ? "" : ", ")+bit_name[i]; + text += ((text.length() <= 1 || linebreak) ? "" : ", ") + bit_name[i]; linelength = text.indexOf("\n") >= 0 ? text.substring(text.lastIndexOf("\n")).length() : text.length(); if (linelength > columns) { @@ -216,7 +218,7 @@ // create JTextArea (setting columns results in textarea being too wide) if (textf == null) { - textf = new JTextArea(text+" ", rows, 18); + textf = new JTextArea(text + " ", rows, 18); // set colors, border and stuff textf.setForeground(Color.black); @@ -225,7 +227,7 @@ textf.setBorder(BorderFactory.createLineBorder(Color.gray)); } else { // textarea already exists, so change it - textf.setText(text+" "); + textf.setText(text + " "); textf.setRows(rows); textf.setColumns(18); } @@ -233,11 +235,9 @@ return textf; } - /** - * Open a popup frame to select bitmask-entries via chooseboxes. - */ + /** Open a popup frame to select bitmask-entries via chooseboxes. */ public void popup_frame(CAttribDialog attrDialog, CAttribDialog.BitmaskAttrib gui_attr) { - String title = "Choose "+gui_attr.ref.getNameNew().substring(0, 1).toUpperCase()+gui_attr.ref.getNameNew().substring(1); + String title = "Choose " + gui_attr.ref.getNameNew().substring(0, 1).toUpperCase() + gui_attr.ref.getNameNew().substring(1); JDialog frame = new JDialog(attrDialog, title, true); frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); @@ -245,7 +245,7 @@ JPanel main_panel = new JPanel(); main_panel.setLayout(new BoxLayout(main_panel, BoxLayout.Y_AXIS)); JPanel grid_panel = new JPanel(new GridLayout(1, 2)); - JPanel left_list = new JPanel(); // left column of checkboxes + JPanel left_list = new JPanel(); // left column of checkboxes left_list.setLayout(new BoxLayout(left_list, BoxLayout.Y_AXIS)); JPanel right_list = new JPanel(); // right column of checkboxes right_list.setLayout(new BoxLayout(right_list, BoxLayout.Y_AXIS)); @@ -254,9 +254,9 @@ // create checkboxes JCheckBox[] checkbox = new JCheckBox[number]; for (int i = 0; i < number; i++) { - checkbox[i] = new JCheckBox(" "+bit_name[i+1]); - checkbox[i].setSelected(is_active(i+1, gui_attr.getValue())); - if (i%2 == 0) { + checkbox[i] = new JCheckBox(" " + bit_name[i + 1]); + checkbox[i].setSelected(is_active(i + 1, gui_attr.getValue())); + if (i % 2 == 0) { left_list.add(checkbox[i]); } else { right_list.add(checkbox[i]); @@ -291,19 +291,24 @@ * where changes to the bitmask can be selected. */ private class PopupFrameAL implements ActionListener { + CAttribBitmask bitmask; // reference to this CAttribBitmask instance + JDialog frame; // reference to the popup dialog frame + CAttribDialog.BitmaskAttrib gui_attr; // gui attribute instance + JCheckBox[] checkbox; // array of checkboxes on the frame + CAttribDialog attrDialog; // instance of attribute dialog (parent frame) /** * Contructor - * @param new_frame thepopup dialog frame - * @param new_gui_attr gui attribute instance - * @param new_mask this CAttribBitmask instance - * @param boxarray array of checkboxes in the popup frame - * @param new_attrD attribute dialog frame + * @param new_frame thepopup dialog frame + * @param new_gui_attr gui attribute instance + * @param new_mask this CAttribBitmask instance + * @param boxarray array of checkboxes in the popup frame + * @param new_attrD attribute dialog frame */ public PopupFrameAL(JDialog new_frame, CAttribDialog.BitmaskAttrib new_gui_attr, CAttribBitmask new_mask, JCheckBox[] boxarray, CAttribDialog new_attrD) { @@ -316,17 +321,17 @@ /** * a button was pressed - * @param event the occured <code>ActionEvent</code> (button pressed) + * @param event the occured <code>ActionEvent</code> (button pressed) */ public void actionPerformed(ActionEvent event) { if (event.getSource() instanceof JButton) { // check if the okay button was pressed - if (((JButton)event.getSource()).getText().equalsIgnoreCase("Ok")) { + if (((JButton) event.getSource()).getText().equalsIgnoreCase("Ok")) { // calculate the new bitmask value: int new_value = 0; for (int i = 0; i < bitmask.number; i++) { if (checkbox[i].isSelected()) { - new_value |= (int)(Math.pow(2., (double)i)); + new_value |= (int) (Math.pow(2., (double) i)); } } Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-05-26 10:23:05 UTC (rev 26) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-05-26 10:55:45 UTC (rev 27) @@ -68,20 +68,25 @@ /** * CAttribDialog poses the GUI... [truncated message content] |
From: <chr...@us...> - 2006-05-26 23:46:50
|
Revision: 39 Author: christianhujer Date: 2006-05-26 15:59:26 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=39&view=rev Log Message: ----------- Removed unused help directory constant. Modified Paths: -------------- trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/daimonin/src/daieditor/IGUIConstants.java Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-05-26 22:55:57 UTC (rev 38) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-05-26 22:59:26 UTC (rev 39) @@ -133,9 +133,6 @@ /** The directory that contains the system icons. */ String SYSTEM_DIR = "resource" + File.separator + "system"; - /** The directory that contains all (html) helpfiles. */ - String HELP_DIR = "resource" + File.separator + "HelpFiles"; - /** The directory that contains all pickmaps. */ String PICKMAP_DIR = "resource" + File.separator + "pickmaps"; Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2006-05-26 22:55:57 UTC (rev 38) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2006-05-26 22:59:26 UTC (rev 39) @@ -128,9 +128,6 @@ // The directory that contains the system icons. String SYSTEM_DIR = "resource" + File.separator + "system"; - // The directory that contains all (html) helpfiles. - String HELP_DIR = "resource" + File.separator + "HelpFiles"; - // The directory that contains all pickmaps. // public static final String PICKMAP_DIR = "resource"+File.separator+"pickmaps"; String PICKMAP_DIR = "dev" + File.separator + "editor" + File.separator + "pickmaps"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <der...@us...> - 2006-05-27 09:18:18
|
Revision: 41 Author: derdanny Date: 2006-05-27 02:17:54 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=41&view=rev Log Message: ----------- Added support for multiple views. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainStatusbar.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CMapViewIFrame.java trunk/daimonin/src/daieditor/action.properties trunk/daimonin/src/daieditor/gui/map/MapUserListener.java trunk/daimonin/src/daieditor/map/MapControl.java Added Paths: ----------- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-05-27 09:17:54 UTC (rev 41) @@ -496,7 +496,9 @@ public void checkMap(final MapModel map) { final ErrorCollector errorCollector = new DefaultErrorCollector(); validators.validateAll(map, errorCollector); - map.getMapControl().getMapViewFrame().view.setErrors(errorCollector); + for (final CMapViewIFrame mapViewIFrame : map.getMapControl().getMapViewFrames()) { + mapViewIFrame.view.setErrors(errorCollector); + } mainView.setErrors(errorCollector); } @@ -916,6 +918,18 @@ } /** + * Invoked when the user wants to close the current view. + * If there is only 1 view left the level will be closed. + * @param mapViewIFrame View to close + */ + public void closeView(final CMapViewIFrame mapViewIFrame) { + final MapControl mapControl = mapViewIFrame.getMapControl(); + mapControl.closeView(mapViewIFrame); + if (mapControl.nViews() == 0) { + closeLevel(mapControl); + } + } + /** * Invoked when the user wants to close all levels. * @return <code>true</code> if all levels closed, <code>false</code> if user cancelled */ @@ -1012,15 +1026,16 @@ // Notify the level about the closing mainView.setMapTileList(null, null); level.levelCloseNotify(); - if (level.getMapViewFrame() != null) { - mainView.removeLevelView(level.getMapViewFrame()); + while (level.getMapViewFrame() != null) { + level.closeView(level.getMapViewFrame()); } levels.remove(level); - currentMap = null; if (levels.size() > 0) { // get next open map we can find and set it to m_currentMap currentMap = levels.get(levels.size() - 1); + } else { + currentMap = null; } } refreshMenusAndToolbars(); @@ -1182,7 +1197,7 @@ if (levelFile != null && can.equals(levelFile.getCanonicalFile())) { lastOpenedMap = level; if (view) { - level.initView(); + level.createView(); setCurrentLevel(level); setCurrentLevelView(level.getMapViewFrame()); } Modified: trunk/daimonin/src/daieditor/CMainStatusbar.java =================================================================== --- trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-05-27 09:17:54 UTC (rev 41) @@ -25,7 +25,7 @@ package daieditor; -import daieditor.gui.map.LevelRenderer; +import daieditor.gui.map.DefaultLevelRenderer; import daieditor.gui.map.MapCursor; import daieditor.gui.map.MapCursorEvent; import daieditor.gui.map.MapCursorListener; @@ -213,7 +213,7 @@ final Point mousePos = e.getPoint(); final int mouseX = mousePos.x; final int mouseY = mousePos.y; - final LevelRenderer renderer = (LevelRenderer) e.getSource(); + final DefaultLevelRenderer renderer = (DefaultLevelRenderer) e.getSource(); final Point mouseMap = renderer.getTileLocationAt(mousePos, mouseMapTmp); if (mouseMap != null) { final int mouseMapX = mouseMap.x; Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-05-27 09:17:54 UTC (rev 41) @@ -27,7 +27,6 @@ import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectStack; import daieditor.gui.AboutDialog; -import net.sf.gridarta.help.Help; import daieditor.map.MapControl; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; @@ -61,6 +60,7 @@ import javax.swing.SwingConstants; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; +import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.ThrowableHandler; import org.jetbrains.annotations.Nullable; @@ -469,13 +469,10 @@ * Removes (closes) the level view. * @param mapView the map view to be removed (closed). */ - void removeLevelView(final CMapViewIFrame mapView) { - if (!mapViews.contains(mapView)) { - return; - } + public void removeLevelView(final CMapViewIFrame mapView) { + assert mapViews.contains(mapView); mapViews.remove(mapView); - mapView.closeNotify(); mapDesktop.remove(mapView); mapView.dispose(); mapDesktop.repaint(); @@ -608,7 +605,8 @@ public void levelViewFocusGainedNotify(final CMapViewIFrame view) { mapViews.remove(view); mapViews.add(0, view); - final MapControl level = view.getLevel(); + final MapControl level = view.getMapControl(); + level.setFocus(view); mainControl.setCurrentLevel(level); // m_statusbar.setLevelInfo( level ); @@ -620,7 +618,7 @@ /** {@inheritDoc} */ public void internalFrameClosing(final InternalFrameEvent event) { - mainControl.close(); + mainControl.closeView((CMapViewIFrame) event.getInternalFrame()); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-05-27 09:17:54 UTC (rev 41) @@ -25,7 +25,7 @@ package daieditor; import daieditor.arch.ArchObject; -import daieditor.gui.map.LevelRenderer; +import daieditor.gui.map.DefaultLevelRenderer; import daieditor.gui.map.MapCursor; import daieditor.gui.map.MapCursorEvent; import daieditor.gui.map.MapCursorListener; @@ -89,8 +89,7 @@ private final CMainControl mainControl; /** The tile palette renderer. */ - private final LevelRenderer renderer; - + private final DefaultLevelRenderer renderer; private MapCursor mapCursor; private MapGrid mapGrid; @@ -104,8 +103,7 @@ private Map<MapSquare, ValidationError> erraneousMapSquares = new HashMap<MapSquare, ValidationError>(); /** The ArchObjects that are known to contain errors. */ - private Map<ArchObject, ValidationError> erraneousArchObjects = new HashMap<ArchObject, ValidationError>(); - //MapUserListener mapUserListener; + private Map<ArchObject,ValidationError> erraneousArchObjects = new HashMap<ArchObject,ValidationError>(); /** * Constructs a level view. @@ -116,15 +114,20 @@ super(VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); mapControl = control; mapModel = mapControl.getMapModel(); - mapGrid = mapControl.getMapGrid(); - mapCursor = mapControl.getMapCursor(); + mapGrid = new MapGrid(mapModel.getMapSize()); + mapCursor = new MapCursor(mapGrid); + mapCursor.addMapCursorListener(this); + if (!mapControl.isPickmap()) { + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); + mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); + } this.mainControl = mainControl; frameInterface = fi; if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); } - renderer = mapControl.getRenderer(); + renderer = new DefaultLevelRenderer(mainControl, mapControl, mapControl.isPickmap(), mapGrid); setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); @@ -148,6 +151,20 @@ setFocusable(true); } + /** Get MapGrid of this view. + * @return MapGrid of this view. + */ + public MapGrid getMapGrid() { + return mapGrid; + } + + /** Get MapCursor of this view. + * @return MapCursor of this view. + */ + public MapCursor getMapCursor() { + return mapCursor; + } + public boolean isChanged() { return changed; } @@ -201,11 +218,6 @@ renderer.setGridVisibility(gridVisibility); } - /** Notifies that this level view is about to be closed. */ - void closeNotify() { - mapControl.viewCloseNotify(); - } - /** * Returns the controller of this view. * @return The controller of this view. @@ -287,8 +299,8 @@ * Get the selected squares. * @return selected squares */ - public ArrayList<MapSquare> getSelectedSquares() { - final ArrayList<MapSquare> selection = new ArrayList<MapSquare>(); + public List<MapSquare> getSelectedSquares() { + final List<MapSquare> selection = new ArrayList<MapSquare>(); final Dimension mapSize = mapModel.getMapSize(); final Point pos = new Point(); for (pos.x = 0; pos.x < mapSize.width; pos.x++) { @@ -307,7 +319,7 @@ */ public Iterable<MapSquare> getAllSquares() { final Dimension mapSize = mapModel.getMapSize(); - final ArrayList<MapSquare> selection = new ArrayList<MapSquare>(mapSize.width * mapSize.height); + final List<MapSquare> selection = new ArrayList<MapSquare>(mapSize.width * mapSize.height); final Point pos = new Point(); for (pos.x = 0; pos.x < mapSize.width; pos.x++) { for (pos.y = 0; pos.y < mapSize.height; pos.y++) { @@ -402,7 +414,7 @@ renderer.setPaintOnlyMap(b); } - public LevelRenderer getRenderer() { + public DefaultLevelRenderer getRenderer() { return renderer; } Modified: trunk/daimonin/src/daieditor/CMapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewIFrame.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/CMapViewIFrame.java 2006-05-27 09:17:54 UTC (rev 41) @@ -60,16 +60,21 @@ public final CMapViewBasic view; // the underlying mapview object + /** Number of this view. */ + private final int viewNumber; + /** * Constructs a level view. * @param mainControl the main controller * @param control the controller of this view + * @param number Each view of a level will get a number */ - public CMapViewIFrame(final CMainControl mainControl, final MapControl control) { + public CMapViewIFrame(final CMainControl mainControl, final MapControl control, final int number) { // set title - super(control.getMapFileName() + " [ " + control.getMapArch().getMapNameWithoutMusic() + " ]", true, true, true, true); + super(control.getMapFileName() + " [ " + control.getMapArch().getMapNameWithoutMusic() + " ] ("+ number + ')', true, true, true, true); mapControl = control; this.mainControl = mainControl; + viewNumber = number; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); @@ -101,7 +106,8 @@ } final StringBuilder strTitle = new StringBuilder(); - strTitle.append(mapControl.getMapFileName()).append(" [ ").append(mapControl.getMapArch().getMapNameWithoutMusic()).append(" ]"); + strTitle.append(mapControl.getMapFileName()).append(" [ ").append(mapControl.getMapArch().getMapNameWithoutMusic()).append(" ] ("); + strTitle.append(viewNumber).append(')'); if (view.isChanged()) { strTitle.append('*'); // * map has changed @@ -110,19 +116,8 @@ setTitle(strTitle.toString()); // display new title } - /** - * Returns the controller of this view. - * @return The controller of this view. - */ - public MapControl getLevel() { - return mapControl; - } - // following a bunch of wrapper methods which just pass access // to the basic mapview object 'view': - public Point getMapMouseRightPos() { - return view.getMapMouseRightPos(); - } public boolean isHighlight() { return view.isHighlight(); @@ -140,10 +135,6 @@ return mapControl; } - public void closeNotify() { - view.closeNotify(); - } - public void setHotspot(final Point pos) { view.setHotspot(pos); } Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/action.properties 2006-05-27 09:17:54 UTC (rev 41) @@ -1,7 +1,7 @@ # Warning: This file MUST be ISO-8859-1 # See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#encoding -ActionFactory.additionalBundles=cfeditor.messages +ActionFactory.additionalBundles=daieditor.messages # Extend this if you add a new locale. The order is irrelevant. availableLocales=en de fr sv Copied: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java (from rev 24, trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java) =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-05-27 09:17:54 UTC (rev 41) @@ -0,0 +1,508 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gui.map; + +import daieditor.CMainControl; +import daieditor.IGUIConstants; +import daieditor.MultiPositionData; +import daieditor.arch.ArchObject; +import daieditor.map.MapControl; +import daieditor.map.MapModel; +import daieditor.map.MapSquare; +import daieditor.map.validation.ValidationError; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import java.util.Map; +import javax.swing.ImageIcon; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * This is the default renderer of a map. It visualizes selections and validation errors. + */ +public class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** + * Declares this CLevelRenderer as a renderer for a Pickmap. + * Pickmaps have a special behaviour that's different from normal maps. + * Value: <code>true</code> if pickmap, otherwise <code>false</code>. + */ + private final boolean isPickmap; + + /** offset to map borders (32 for std. rect. maps, 0 for pickmaps). */ + private Point borderOffset = new Point(); + + /** Time of last selection painting. */ + private transient long lastSelectionPaint; + + /** Time of last core painting (includes selection painting). */ + private transient long lastCorePaint; + + /** Time of last overall painting (includes core and thus selection). */ + private transient long lastPaint; + + /** The origin is the point in the north-west corner */ + private Point origin = new Point(); + + private MapModel mapModel; + + private CMainControl mainControl; + + private final Dimension mapSize = new Dimension(); + + private final MapGrid mapGrid; + + /** The MapSquares that are known to contain errors. */ + private Map<MapSquare,ValidationError> erraneousMapSquares; + + /** The ArchObjects that are known to contain errors. */ + private Map<ArchObject,ValidationError> erraneousArchObjects; + + private boolean gridVisibility; + + /** Used to avoid creation millions of points */ + private final Point tmpPoint = new Point(); + + /** If true selection and grid will not be painted */ + private boolean paintOnlyMap; + + /** + * Constructor + */ + public DefaultLevelRenderer(final CMainControl mainControl, final MapControl mapControl, final boolean pickmap, final MapGrid mapGrid) { + this.mainControl = mainControl; + checkDouble = mainControl.isUseDouble(); + mapModel = mapControl.getMapModel(); + mapSize.setSize(mapModel.getMapSize()); + this.mapGrid = mapGrid; + isPickmap = pickmap; + if (isPickmap) { + setBorderOffset(0, IGUIConstants.TILE_ISO_YLEN); + setBackground(IGUIConstants.BG_COLOR); + } else { + setBorderOffset(IGUIConstants.TILE_ISO_XLEN, 2 * IGUIConstants.TILE_ISO_YLEN); + } + setToolTipText("dummy"); + setFocusable(true); + } + + /** + * The origin which is located in the NW-corner of the map is calculated. + * On non-pickmaps there is an extra border. + */ + private void calculateOrigin() { + if (isPickmap) { + origin.setLocation(borderOffset.x + 4 * IGUIConstants.TILE_ISO_XLEN2, borderOffset.y); + } else { + origin.setLocation(borderOffset.x + mapSize.height * IGUIConstants.TILE_ISO_XLEN2, borderOffset.y); + } + } + + /** + * Returns offset to map borders (32 for std. rect. maps, 0 for pickmaps). + * @return offset to map borders (32 for std. rect. maps, 0 for pickmaps) + */ + public final Point getBorderOffset() { + return new Point(borderOffset); + } + + /** Sets offset to map borders (32 for std. rect. maps, 0 for pickmaps). + * @param offset offset to map borders (32 for std. rect. maps, 0 for pickmaps) + */ + public void setBorderOffset(final Point offset) { + borderOffset.setLocation(offset); + calculateOrigin(); + } + + /** Sets offset to map borders (32 for std. rect. maps, 0 for pickmaps). + * @param x x offset to map borders (32 for std. rect. maps, 0 for pickmaps) + * @param y y offset to map borders (32 for std. rect. maps, 0 for pickmaps) + */ + public void setBorderOffset(final int x, final int y) { + borderOffset.setLocation(x, y); + calculateOrigin(); + } + + /** {@inheritDoc} */ + @Nullable @Override public String getToolTipText(final MouseEvent event) { + final Point mapLocation = getTileLocationAt(event.getPoint(), tmpPoint); + if (mapLocation == null) { + return null; + } + if (mapGrid.hasError(mapLocation)){ + final MapSquare mapSquare = mapModel.getMapSquare(mapLocation); + + if (erraneousMapSquares.containsKey(mapSquare)) { + final ValidationError error = erraneousMapSquares.get(mapSquare); + return error.getMessage(); + } else { + return null; + } + } else { + return null; + } + } + + /** + * @return whether rendered map is a pickmap + */ + public boolean isPickmap() { + return isPickmap; + } + + /** + * @return an image of the entire mapview + */ + @Override public BufferedImage getFullImage() { + // set map dimensions for iso view + final int sum = mapSize.width + mapSize.height; + final int viewWidth = sum * IGUIConstants.TILE_ISO_XLEN2; + final int viewHeight = sum * IGUIConstants.TILE_ISO_YLEN2; + + // first create a storing place for the image + final BufferedImage bufImage = new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB); + final Graphics2D bufGrfx = bufImage.createGraphics(); + bufGrfx.setColor(new Color(255, 255, 255, 0)); + bufGrfx.fillRect(0, 0, viewWidth, viewHeight); + + // paint the mapview into the image + final Point storeOffset = new Point(borderOffset); + setBorderOffset(0, 0); + paintComponent2(bufGrfx); + setBorderOffset(storeOffset); + return bufImage; + } + + @Override public void paintComponent(final Graphics grfx) { + final long start = System.currentTimeMillis(); + paintComponent2((Graphics2D) grfx); + lastPaint = System.currentTimeMillis() - start; + mainControl.setStatusText("Sel: " + lastSelectionPaint + " Core: " + lastCorePaint + " All: " + lastPaint); + } + + /** Whether to check for double arches. */ + private transient boolean checkDouble; + + private final ImageIcon unknownTileIcon = CMainControl.unknownTileIcon; + private final ImageIcon warningSquareIcon = CMainControl.warningSquareIcon; + + private final Rectangle tmpRec = new Rectangle(); + + /** + * Get coordinates, length and width of map position + * @param p Map coordinates + * @return Boundary rectangle of tile + */ + public Rectangle getBounds(final Point p) { + tmpRec.x = origin.x - (p.y + 1) * IGUIConstants.TILE_ISO_XLEN2 + p.x * IGUIConstants.TILE_ISO_XLEN2; + tmpRec.y = origin.y + p.y * IGUIConstants.TILE_ISO_YLEN2 + p.x * IGUIConstants.TILE_ISO_YLEN2; + tmpRec.width = IGUIConstants.TILE_ISO_XLEN; + tmpRec.height = IGUIConstants.TILE_ISO_YLEN; + return tmpRec; + } + + /** + * Paints this component. + * @param grfx The graphics context to paint to. + */ + private void paintComponent2(final Graphics2D grfx) { + final long start = System.currentTimeMillis(); + checkDouble = mainControl.isUseDouble(); + //ImageIcon selIcon = mainControl.mapSelIcon; + + if (isPickmap) { + grfx.setColor(getBackground()); + grfx.fillRect(0, 0, getWidth(), getHeight()); + } + final Rectangle rec = getRepaintRec(getVisibleRect()); + final Point pos = new Point(); + final Point endPos = rec.getLocation(); + endPos.translate(rec.width, rec.height); + for (pos.y = rec.y; pos.y < endPos.y; pos.y++) { + int xstart = origin.x - (pos.y - rec.x + 1) * IGUIConstants.TILE_ISO_XLEN2; + int ystart = origin.y + (pos.y + rec.x) * IGUIConstants.TILE_ISO_YLEN2; + for (pos.x = rec.x; pos.x < endPos.x; pos.x++) { + if (grfx.hitClip(xstart, ystart - (IGUIConstants.TILE_ISO_YLEN << 2), IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN * 5)) { + final MapSquare square = mapModel.getMapSquare(pos); + if (square.isEmpty()) { + // empty square: Draw unknown tile icon if not a pickmap + if (!isPickmap) { + unknownTileIcon.paintIcon(this, grfx, xstart, ystart); + //grfx.drawImage(unknownTile, xstart, ystart, this); + } + } else { + // normal square + for (final ArchObject node : square) { + paint(grfx, xstart, ystart, node); + } + } + } + xstart += IGUIConstants.TILE_ISO_XLEN2; + ystart += IGUIConstants.TILE_ISO_YLEN2; + } + } + + if (!paintOnlyMap) { + paintGrid(grfx); + paintSelection(grfx); + } + + lastCorePaint = System.currentTimeMillis() - start; + } + + /** + * Get smallest Rectangle on map that needs to be repaint. + * @param visRec visible Rectangle. + * @return rectangle on the map. + */ + private Rectangle getRepaintRec(final Rectangle visRec) { + // This Rectangle will be returned + final Rectangle rec = new Rectangle(); + // Upper left corner of viewport + final Point posUL = visRec.getLocation(); + // Dimension of viewport + final Dimension visDim = visRec.getSize(); + // Other positions of viewport corners + final Point posUR = new Point(posUL.x + visDim.width, posUL.y); + final Point posDL = new Point(posUL.x , posUL.y + visDim.height); + final Point posDR = new Point(posUR.x , posDL.y); + // Calculate map positions of corners and from them properties of Rectangle + final Point mapPosUL = getTileLocationAt(posUL, tmpPoint); + rec.x = mapPosUL == null ? 0 : mapPosUL.x; + final Point mapPosUR = getTileLocationAt(posUR, tmpPoint); + rec.y = mapPosUR == null ? 0 : mapPosUR.y; + final Point mapPosDL = getTileLocationAt(posDL, tmpPoint); + rec.height = mapPosDL == null ? mapSize.height - rec.y : mapPosDL.y - rec.y + 1; + final Point mapPosDR = getTileLocationAt(posDR, tmpPoint); + rec.width = mapPosDR == null ? mapSize.width - rec.x : mapPosDR.x - rec.x + 1; + return rec; + } + + /** + * Paints a single ArchObject. + * @param grfx Graphics to paint to + * @param xstart x offset for painting + * @param ystart y offset for painting + * @param node ArchObject to paint + */ + private void paint(final Graphics2D grfx, final int xstart, final int ystart, ArchObject node) { + ArchObject tmpNode = null; + if (node.isMulti() && node.getMapMultiHead() != null) { + // this is a multipart tail: + tmpNode = node; // save old node + node = node.getMapMultiHead(); // go to multipart head + } + if (mainControl.isTileEdit(node) || isPickmap) { + final ImageIcon img = "trans.101".equals(node.getFaceObjName()) ? unknownTileIcon : + mainControl.isAlphaType(node.getEditType()) ? node.getTransparentImage() : node.getNormalImage(); + int yoff = 0; + if (img.getIconHeight() > IGUIConstants.TILE_ISO_YLEN) { + yoff = img.getIconHeight() - IGUIConstants.TILE_ISO_YLEN; + } + if (node.isMulti() && node.getMultiRefCount() > 0) { + // multipart images have to be painted with correct offset + // TODO: This should be improved, especially regarding multi arch mobs inside spawn points. + if (tmpNode != null && tmpNode.isLowestPart() || node.isLowestPart()) { + img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); + } else if (node.isInContainer() && ((ArchObject) node.getContainer()).getArchTypNr() == 81) { + img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); + } + } else { + int xoff = 0; + if (img.getIconWidth() > IGUIConstants.TILE_ISO_XLEN) { + xoff = img.getIconWidth() - IGUIConstants.TILE_ISO_XLEN >> 1; + } + img.paintIcon(this, grfx, xstart - xoff, ystart - yoff); + if (checkDouble && mainControl.getFaceObjects().get(node.getFaceObjName()).isDouble()) { + img.paintIcon(this, grfx, xstart - xoff, ystart - yoff - 22); + } + } + // Paint first object (most likely a mob) in spawn points. + if (node.getArchTypNr() == 81) { + final ArchObject mob = node.getFirst(); + if (mob != null) { + paint(grfx, xstart, ystart, mob); + } + } + } + } + + /** + * Paints the selection. + * It's recommended to paint the complete selection after the map itself, otherwise map elements actually might hide selections. + * @param grfx Graphics for painting + */ + private void paintSelection(final Graphics2D grfx) { + if (mapGrid == null) { + return; + } + final long start = System.currentTimeMillis(); + final Image selImg = CMainControl.mapSelIcon.getImage(); + final Image preSelImg = CMainControl.mapPreSelIcon.getImage(); + final Image cursorImg = CMainControl.mapCursorIcon.getImage(); + for (int y = 0; y < mapSize.height; y++) { + int xstart = origin.x - (y + 1) * IGUIConstants.TILE_ISO_XLEN2; + int ystart = origin.y + y * IGUIConstants.TILE_ISO_YLEN2; + for (int x = 0; x < mapSize.width; x++) { + if (grfx.hitClip(xstart, ystart, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN)) { + final int gridFlags = mapGrid.getFlags(x, y); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { + grfx.drawImage(selImg, xstart, ystart, this); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + grfx.drawImage(preSelImg, xstart, ystart, this); + } + if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { + grfx.drawImage(cursorImg, xstart, ystart, this); + } + if ((gridFlags & MapGrid.GRID_FLAG_ERROR) != 0) { + warningSquareIcon.paintIcon(this, grfx, xstart, ystart); + } + } else { + /* DO NOTHING if outside clip region. + * DO NOT use continue. xstart and ystart are recalculated at the end of the loop. + */ + } + xstart += IGUIConstants.TILE_ISO_XLEN2; + ystart += IGUIConstants.TILE_ISO_YLEN2; + } + } + lastSelectionPaint = System.currentTimeMillis() - start; + } + + /** + * Paints the grid if desired. + * The grid is not painted if <code><var>gridVisibility</var></code> is <code>false</code>. + * It's recommended to paint the complete grid after the map itself, otherwise map elements actually might hide parts of the grid. + * @param grfx Graphics for painting + */ + private void paintGrid(final Graphics grfx) { + if (gridVisibility) { + // draw iso grid + grfx.setColor(Color.black); + + for (int x = 0; x <= mapSize.width; x++) { + grfx.drawLine(origin.x + x * IGUIConstants.TILE_ISO_XLEN2 - 1, + origin.y + x * IGUIConstants.TILE_ISO_YLEN2 - 1, + origin.x - (mapSize.width - x) * IGUIConstants.TILE_ISO_XLEN2 - 1, + origin.y + (mapSize.width + x) * IGUIConstants.TILE_ISO_YLEN2 - 1); + } + + for (int y = 0; y <= mapSize.height; y++) { + grfx.drawLine(origin.x - y * IGUIConstants.TILE_ISO_XLEN2 - 1, + origin.y + y * IGUIConstants.TILE_ISO_YLEN2 - 1, + origin.x + (mapSize.height - y) * IGUIConstants.TILE_ISO_XLEN2 - 1, + origin.y + (mapSize.height + y) * IGUIConstants.TILE_ISO_YLEN2 - 1); + } + } + } + + /** + * Returns the map location at the given point or null if no map location + * is at the point. + * @param point The coordinates in the renderer view. + * @param retPoint if <cod>(retPoint != null)</code> this point will be returned otherwise a new point will be created + * @return The map location. + */ + @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { + + final int x0 = point.x - origin.x; + final int y0 = point.y - origin.y; + final int yt = 2 * y0 - x0 >> 1; + final int xt = yt + x0; + final int xm = xt / IGUIConstants.TILE_ISO_XLEN2; + final int ym = yt / (IGUIConstants.TILE_ISO_YLEN2 << 1); + if (xm < 0 || xm >= mapSize.width || ym < 0 || ym >= mapSize.height) { + return null; + } + if (retPoint != null) { + retPoint.setLocation(xm, ym); + return retPoint; + } + + return new Point(xm, ym); + } + + /** {@inheritDoc} */ + public void mapGridChanged(final MapGridEvent e) { + repaint(); + } + + /** {@inheritDoc} */ + public void mapGridResized(final MapGridEvent e) { + mapSize.setSize(e.getSource().getSize()); + calculateOrigin(); + repaint(); + } + + public boolean isGridVisible() { + return gridVisibility; + } + + public void setGridVisibility(final boolean gridVisibility) { + if (this.gridVisibility != gridVisibility) { + this.gridVisibility = gridVisibility; + repaint(); + } + } + + /** + * Set draw mode + * @param paintOnlyMap <code>true</code>: grid and selections will not be painted + * @note This is only a fast hack. Don't look too much at it. + */ + public void setPaintOnlyMap(final boolean paintOnlyMap) { + this.paintOnlyMap = paintOnlyMap; + } + + /** + * Sets the ArchObjects that are known to contain errors. + * @param erraneousArchObjects the ArchObjects that are known to contain errors. + */ + public void setErraneousArchObjects(final Map<ArchObject, ValidationError> erraneousArchObjects) { + this.erraneousArchObjects = erraneousArchObjects; + } + + /** + * Sets the MapSquares that are known to contain errors. + * @param erraneousMapSquares the MapSquares that are known to contain errors. + */ + public void setErraneousMapSquares(final Map<MapSquare, ValidationError> erraneousMapSquares) { + this.erraneousMapSquares = erraneousMapSquares; + } + +} // class CLevelRenderer + Deleted: trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-05-27 09:17:54 UTC (rev 41) @@ -1,499 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2006 Daniel Viegas - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.gui.map; - -import daieditor.CMainControl; -import daieditor.IGUIConstants; -import daieditor.MultiPositionData; -import daieditor.arch.ArchObject; -import daieditor.map.MapControl; -import daieditor.map.MapModel; -import daieditor.map.MapSquare; -import daieditor.map.validation.ValidationError; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; -import java.util.Map; -import javax.swing.ImageIcon; -import javax.swing.JComponent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class LevelRenderer extends JComponent implements MapGridListener { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** - * Declares this CLevelRenderer as a renderer for a Pickmap. - * Pickmaps have a special behaviour that's different from normal maps. - * Value: <code>true</code> if pickmap, otherwise <code>false</code>. - */ - private final boolean isPickmap; - - /** offset to map borders (32 for std. rect. maps, 0 for pickmaps). */ - private Point borderOffset = new Point(); - - /** Time of last selection painting. */ - private transient long lastSelectionPaint; - - /** Time of last core painting (includes selection painting). */ - private transient long lastCorePaint; - - /** Time of last overall painting (includes core and thus selection). */ - private transient long lastPaint; - - /** The origin is the point in the north-west corner */ - private Point origin = new Point(); - - private MapModel mapModel; - - private CMainControl mainControl; - - private final Dimension mapSize = new Dimension(); - - private final MapGrid mapGrid; - - /** The MapSquares that are known to contain errors. */ - private Map<MapSquare, ValidationError> erraneousMapSquares; - - /** The ArchObjects that are known to contain errors. */ - private Map<ArchObject, ValidationError> erraneousArchObjects; - - private boolean gridVisibility; - - /** Used to avoid creation millions of points */ - private final Point tmpPoint = new Point(); - - /** If true selection and grid will not be painted */ - private boolean paintOnlyMap; - - /** Constructor */ - public LevelRenderer(final CMainControl mainControl, final MapControl mapControl, final boolean pickmap) { - this.mainControl = mainControl; - checkDouble = mainControl.isUseDouble(); - mapModel = mapControl.getMapModel(); - mapSize.setSize(mapModel.getMapSize()); - mapGrid = mapControl.getMapGrid(); - isPickmap = pickmap; - if (isPickmap) { - setBorderOffset(0, IGUIConstants.TILE_ISO_YLEN); - setBackground(IGUIConstants.BG_COLOR); - } else { - setBorderOffset(IGUIConstants.TILE_ISO_XLEN, 2 * IGUIConstants.TILE_ISO_YLEN); - } - setToolTipText("dummy"); - setFocusable(true); - } - - private void calculateOrigin() { - if (isPickmap) { - origin.setLocation(borderOffset.x + 4 * IGUIConstants.TILE_ISO_XLEN2, borderOffset.y); - } else { - origin.setLocation(borderOffset.x + mapSize.height * IGUIConstants.TILE_ISO_XLEN2, borderOffset.y); - } - } - - /** - * Returns offset to map borders (32 for std. rect. maps, 0 for pickmaps). - * @return offset to map borders (32 for std. rect. maps, 0 for pickmaps) - */ - public final Point getBorderOffset() { - return new Point(borderOffset); - } - - /** - * Sets offset to map borders (32 for std. rect. maps, 0 for pickmaps). - * @param offset offset to map borders (32 for std. rect. maps, 0 for pickmaps) - */ - public void setBorderOffset(final Point offset) { - borderOffset.setLocation(offset); - calculateOrigin(); - } - - /** - * Sets offset to map borders (32 for std. rect. maps, 0 for pickmaps). - * @param x x offset to map borders (32 for std. rect. maps, 0 for pickmaps) - * @param y y offset to map borders (32 for std. rect. maps, 0 for pickmaps) - */ - public void setBorderOffset(final int x, final int y) { - borderOffset.setLocation(x, y); - calculateOrigin(); - } - - /** {@inheritDoc} */ - @Nullable @Override public String getToolTipText(final MouseEvent event) { - final Point mapLocation = getTileLocationAt(event.getPoint(), tmpPoint); - if (mapLocation == null) { - return null; - } - if (mapGrid.hasError(mapLocation)) { - final MapSquare mapSquare = mapModel.getMapSquare(mapLocation); - - if (erraneousMapSquares.containsKey(mapSquare)) { - final ValidationError error = erraneousMapSquares.get(mapSquare); - return error.getMessage(); - } else { - return null; - } - } else { - return null; - } - } - - /** @return whether rendered map is a pickmap */ - public boolean isPickmap() { - return isPickmap; - } - - /** @return an image of the entire mapview */ - public BufferedImage getFullImage() { - // set map dimensions for iso view - final int sum = mapSize.width + mapSize.height; - final int viewWidth = sum * IGUIConstants.TILE_ISO_XLEN2; - final int viewHeight = sum * IGUIConstants.TILE_ISO_YLEN2; - - // first create a storing place for the image - final BufferedImage bufImage = new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB); - final Graphics2D bufGrfx = bufImage.createGraphics(); - bufGrfx.setColor(new Color(255, 255, 255, 0)); - bufGrfx.fillRect(0, 0, viewWidth, viewHeight); - - // paint the mapview into the image - final Point storeOffset = new Point(borderOffset); - setBorderOffset(0, 0); - paintComponent2(bufGrfx); - setBorderOffset(storeOffset); - return bufImage; - } - - @Override public void paintComponent(final Graphics grfx) { - final long start = System.currentTimeMillis(); - paintComponent2((Graphics2D) grfx); - lastPaint = System.currentTimeMillis() - start; - mainControl.setStatusText("Sel: " + lastSelectionPaint + " Core: " + lastCorePaint + " All: " + lastPaint); - } - - /** Whether to check for double arches. */ - private transient boolean checkDouble; - - private final ImageIcon unknownTileIcon = CMainControl.unknownTileIcon; - - private final ImageIcon warningSquareIcon = CMainControl.warningSquareIcon; - - private final Rectangle tmpRec = new Rectangle(); - - /** - * Get coordinates, length and width of map position - * @param p Map coordinates - * @return Boundary rectangle of tile - */ - public Rectangle getBounds(final Point p) { - tmpRec.x = origin.x - (p.y + 1) * IGUIConstants.TILE_ISO_XLEN2 + p.x * IGUIConstants.TILE_ISO_XLEN2; - tmpRec.y = origin.y + p.y * IGUIConstants.TILE_ISO_YLEN2 + p.x * IGUIConstants.TILE_ISO_YLEN2; - tmpRec.width = IGUIConstants.TILE_ISO_XLEN; - tmpRec.height = IGUIConstants.TILE_ISO_YLEN; - return tmpRec; - } - - /** - * Paints this component. - * @param grfx The graphics context to paint to. - */ - private void paintComponent2(final Graphics2D grfx) { - final long start = System.currentTimeMillis(); - checkDouble = mainControl.isUseDouble(); - //ImageIcon selIcon = mainControl.mapSelIcon; - - if (isPickmap) { - grfx.setColor(getBackground()); - grfx.fillRect(0, 0, getWidth(), getHeight()); - } - final Rectangle rec = getRepaintRec(getVisibleRect()); - final Point pos = new Point(); - final Point endPos = rec.getLocation(); - endPos.translate(rec.width, rec.height); - for (pos.y = rec.y; pos.y < endPos.y; pos.y++) { - int xstart = origin.x - (pos.y - rec.x + 1) * IGUIConstants.TILE_ISO_XLEN2; - int ystart = origin.y + (pos.y + rec.x) * IGUIConstants.TILE_ISO_YLEN2; - for (pos.x = rec.x; pos.x < endPos.x; pos.x++) { - if (grfx.hitClip(xstart, ystart - (IGUIConstants.TILE_ISO_YLEN << 2), IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN * 5)) { - final MapSquare square = mapModel.getMapSquare(pos); - if (square.isEmpty()) { - // empty square: Draw unknown tile icon if not a pickmap - if (!isPickmap) { - unknownTileIcon.paintIcon(this, grfx, xstart, ystart); - //grfx.drawImage(unknownTile, xstart, ystart, this); - } - } else { - // normal square - for (final ArchObject node : square) { - paint(grfx, xstart, ystart, node); - } - } - } - xstart += IGUIConstants.TILE_ISO_XLEN2; - ystart += IGUIConstants.TILE_ISO_YLEN2; - } - } - - if (!paintOnlyMap) { - paintGrid(grfx); - paintSelection(grfx); - } - - lastCorePaint = System.currentTimeMillis() - start; - } - - /** - * Get smallest Rectangle on map that needs to be repaint. - * @param visRec visible Rectangle. - * @return rectangle on the map. - */ - private Rectangle getRepaintRec(final Rectangle visRec) { - // This Rectangle will be returned - final Rectangle rec = new Rectangle(); - // Upper left corner of viewport - final Point posUL = visRec.getLocation(); - // Dimension of viewport - final Dimension visDim = visRec.getSize(); - // Other positions of viewport corners - final Point posUR = new Point(posUL.x + visDim.width, posUL.y); - final Point posDL = new Point(posUL.x, posUL.y + visDim.height); - final Point posDR = new Point(posUR.x, posDL.y); - // Calculate map positions of corners and from them properties of Rectangle - final Point mapPosUL = getTileLocationAt(posUL, tmpPoint); - rec.x = mapPosUL == null ? 0 : mapPosUL.x; - final Point mapPosUR = getTileLocationAt(posUR, tmpPoint); - rec.y = mapPosUR == null ? 0 : mapPosUR.y; - final Point mapPosDL = getTileLocationAt(posDL, tmpPoint); - rec.height = mapPosDL == null ? mapSize.height - rec.y : mapPosDL.y - rec.y + 1; - final Point mapPosDR = getTileLocationAt(posDR, tmpPoint); - rec.width = mapPosDR == null ? mapSize.width - rec.x : mapPosDR.x - rec.x + 1; - return rec; - } - - /** - * Paints a single ArchObject. - * @param grfx Graphics to paint to - * @param xstart x offset for painting - * @param ystart y offset for painting - * @param node ArchObject to paint - */ - private void paint(final Graphics2D grfx, final int xstart, final int ystart, ArchObject node) { - ArchObject tmpNode = null; - if (node.isMulti() && node.getMapMultiHead() != null) { - // this is a multipart tail: - tmpNode = node; // save old node - node = node.getMapMultiHead(); // go to multipart head - } - if (mainControl.isTileEdit(node) || isPickmap) { - final ImageIcon img = "trans.101".equals(node.getFaceObjName()) ? unknownTileIcon : - mainControl.isAlphaType(node.getEditType()) ? node.getTransparentImage() : node.getNormalImage(); - int yoff = 0; - if (img.getIconHeight() > IGUIConstants.TILE_ISO_YLEN) { - yoff = img.getIconHeight() - IGUIConstants.TILE_ISO_YLEN; - } - if (node.isMulti() && node.getMultiRefCount() > 0) { - // multipart images have to be painted with correct offset - // TODO: This should be improved, especially regarding multi arch mobs inside spawn points. - if (tmpNode != null && tmpNode.isLowestPart() || node.isLowestPart()) { - img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); - } else if (node.isInContainer() && ((ArchObject) node.getContainer()).getArchTypNr() == 81) { - img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); - } - } else { - int xoff = 0; - if (img.getIconWidth() > IGUIConstants.TILE_ISO_XLEN) { - xoff = img.getIconWidth() - IGUIConstants.TILE_ISO_XLEN >> 1; - } - img.paintIcon(this, grfx, xstart - xoff, ystart - yoff); - if (checkDouble && mainControl.getFaceObjects().get(node.getFaceObjName()).isDouble()) { - img.paintIcon(this, grfx, xstart - xoff, ystart - yoff - 22); - } - } - // Paint first object (most likely a mob) in spawn points. - if (node.getArchTypNr() == 81) { - final ArchObject mob = node.getFirst(); - if (mob != null) { - paint(grfx, xstart, ystart, mob); - } - } - } - } - - /** - * Paints the selection. - * It's recommended to paint the complete selection after the map itself, otherwise map elements actually might hide selections. - * @param grfx Graphics for painting - */ - private void paintSelection(final Graphics2D grfx) { - if (mapGrid == null) { - return; - } - final long start = System.currentTimeMillis(); - final Image selImg = CMainControl.mapSelIcon.getImage(); - final Image preSelImg = CMainControl.mapPreSelIcon.getImage(); - final Image cursorImg = CMainControl.mapCursorIcon.getImage(); - for (int y = 0; y < mapSize.height; y++) { - int xstart = origin.x - (y + 1) * IGUIConstants.TILE_ISO_XLEN2; - int ystart = origin.y + y * IGUIConstants.TILE_ISO_YLEN2; - for (int x = 0; x < mapSize.width; x++) { - if (grfx.hitClip(xstart, ystart, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN)) { - final int gridFlags = mapGrid.getFlags(x, y); - if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - grfx.drawImage(selImg, xstart, ystart, this); - } - if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { - grfx.drawImage(preSelImg, xstart, ystart, this); - } - if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { - grfx.drawImage(cursorImg, xstart, ystart, this); - } - if ((gridFlags & MapGrid.GRID_FLAG_ERROR) != 0) { - warningSquareIcon.paintIcon(this, grfx, xstart, ystart); - } - } else { - /* DO NOTHING if outside clip region. - * DO NOT use continue. xstart and ystart are recalculated at the end of the loop. - */ - } - xstart += IGUIConstants.TILE_ISO_XLEN2; - ystart += IGUIConstants.TILE_ISO_YLEN2; - } - } - lastSelectionPaint = System.currentTimeMillis() - start; - } - - /** - * Paints the grid if desired. - * The grid is not painted if <code><var>gridVisibility</var></code> is <code>false</code>. - * It's recommended to paint the complete grid after the map itself, otherwise map elements actually might hide parts of the grid. - * @param grfx Graphics for painting - */ - private void paintGrid(final Graphics grfx) { - if (gridVisibility) { - // draw iso grid - grfx.setColor(Color.black); - - for (int x = 0; x <= mapSize.width; x++) { - grfx.drawLine(origin.x + x * IGUIConstants.TILE_ISO_XLEN2 - 1, - origin.y + x * IGUIConstants.TILE_ISO_YLEN2 - 1, - origin.x - (mapSize.width - x) * IGUIConstants.TILE_ISO_XLEN2 - 1, - origin.y + (mapSize.width + x) * IGUIConstants.TILE_ISO_YLEN2 - 1); - } - - for (int y = 0; y <= mapSize.height; y++) { - grfx.drawLine(origin.x - y * IGUIConstants.TILE_ISO_XLEN2 - 1, - origin.y + y * IGUIConstants.TILE_ISO_YLEN2 - 1, - origin.x + (mapSize.height - y) * IGUIConstants.TILE_ISO_XLEN2 - 1, - origin.y + (mapSize.height + y) * IGUIConstants.TILE_ISO_YLEN2 - 1); - } - } - } - - /** - * Returns the map location at the given point or null if no map location - * is at the point. - * @param point The coordinates in the renderer view. - * @param retPoint if <cod>(retPoint != null)</code> this point will be returned otherwise a new point will be created - * @return The map location. - */ - @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { - - final int x0 = point.x - origin.x; - final int y0 = point.y - origin.y; - final int yt = 2 * y0 - x0 >> 1; - final int xt = yt + x0; - final int xm = xt / IGUIConstants.TILE_ISO_XLEN2; - final int ym = yt / (IGUIConstants.TILE_ISO_YLEN2 << 1); - if (xm < 0 || xm >= mapSize.width || ym < 0 || ym >= mapSize.height) { - return null; - } - if (retPoint != null) { - retPoint.setLocation(xm, ym); - return retPoint; - } - - return new Point(xm, ym); - } - - /** {@inheritDoc} */ - public void mapGridChanged(final MapGridEvent e) { - repaint(); - } - - /** {@inheritDoc} */ - public void mapGridResized(final MapGridEvent e) { - mapSize.setSize(e.getSource().getSize()); - calculateOrigin(); - repaint(); - } - - public boolean isGridVisible() { - return gridVisibility; - } - - public void setGridVisibility(final boolean gridVisibility) { - if (this.gridVisibility != gridVisibility) { - this.gridVisibility = gridVisibility; - repaint(); - } - } - - /** - * Set draw mode - * @param paintOnlyMap <code>true</code>: grid and selections will not be painted - * @note This is only a fast hack. Don't look too much at it. - */ - public void setPaintOnlyMap(final boolean paintOnlyMap) { - this.paintOnlyMap = paintOnlyMap; - } - - /** - * Sets the ArchObjects that are known to contain errors. - * @param erraneousArchObjects the ArchObjects that are known to contain errors. - */ - public void setErraneousArchObjects(final Map<ArchObject, ValidationError> erraneousArchObjects) { - this.erraneousArchObjects = erraneousArchObjects; - } - - /** - * Sets the MapSquares that are known to contain errors. - * @param erraneousMapSquares the MapSquares that are known to contain errors. - */ - public void setErraneousMapSquares(final Map<MapSquare, ValidationError> erraneousMapSquares) { - this.erraneousMapSquares = erraneousMapSquares; - } - -} // class CLevelRenderer - Added: trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-05-27 09:17:54 UTC (rev 41) @@ -0,0 +1,29 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gui.map; + +import java.awt.image.BufferedImage; +import javax.swing.JComponent; + +public abstract class LevelRenderer extends JComponent { + public abstract BufferedImage getFullImage(); +} // class LevelRenderer Property changes on: trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gui/map/MapUserListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2006-05-27 00:42:33 UTC (rev 40) +++ trunk/daimonin/src/daieditor/gui/map/MapUserListener.java 2006-05-27 09:17:54 UTC (rev 41) @@ -55,9 +55,8 @@ }; private MapCursor mapCursor; + private DefaultLevelRenderer renderer; - private LevelRenderer renderer; - private MapControl mapControl; private CMainControl mainControl; @@ -69,7 +68,7 @@ public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView) { this.mainControl = mainControl; this.mapControl = mapControl; - mapCursor = mapControl.getMapCursor(); + mapCursor = mapView.getMapCursor(); renderer = mapView.getRenderer(); } Added: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2006-05-27 09:17:54 UTC (rev 41) @@ -0,0 +1,176 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) +... [truncated message content] |
From: <chr...@us...> - 2006-05-27 16:18:26
|
Revision: 48 Author: christianhujer Date: 2006-05-27 09:18:05 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=48&view=rev Log Message: ----------- Changed cfeditor to daieditor in html parts of javadoc. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/package.html trunk/daimonin/src/daieditor/map/validation/checks/package.html trunk/daimonin/src/daieditor/overview.html Modified: trunk/daimonin/src/daieditor/gui/map/package.html =================================================================== --- trunk/daimonin/src/daieditor/gui/map/package.html 2006-05-27 16:17:29 UTC (rev 47) +++ trunk/daimonin/src/daieditor/gui/map/package.html 2006-05-27 16:18:05 UTC (rev 48) @@ -7,8 +7,8 @@ </head> <body> <p> - The package <code>cfeditor.gui.map</code> is about displaying and rendering maps. - Note that the management of maps is in a different package: {@link cfeditor.map}. + The package <code>daieditor.gui.map</code> is about displaying and rendering maps. + Note that the management of maps is in a different package: {@link daieditor.map}. </p> </body> </html> Modified: trunk/daimonin/src/daieditor/map/validation/checks/package.html =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/package.html 2006-05-27 16:17:29 UTC (rev 47) +++ trunk/daimonin/src/daieditor/map/validation/checks/package.html 2006-05-27 16:18:05 UTC (rev 48) @@ -12,21 +12,21 @@ <h3>How to create your own checks</h3> <p>The easiest way to create your own checks is this:</p> <ol> - <li>Extend {@link cfeditor.map.validation.AbstractValidator} by a class named like cfeditor.map.validation.checks.MyMapChecker that additionally implements one of the {@link cfeditor.map.validation.Validator} subinterfaces</li> - <li>Extend {@link cfeditor.map.validation.ValidationError} or one of its subclasses by a class named like cfeditor.map.validation.checks.MyError</li> + <li>Extend {@link daieditor.map.validation.AbstractValidator} by a class named like daieditor.map.validation.checks.MyMapChecker that additionally implements one of the {@link daieditor.map.validation.Validator} subinterfaces</li> + <li>Extend {@link daieditor.map.validation.ValidationError} or one of its subclasses by a class named like daieditor.map.validation.checks.MyError</li> </ol> <p> Note: To use the automatic localization feature, the error class and validator class must match name like the existing checkers. </p> <h3>Caveats</h3> <p> - If you extend {@link cfeditor.map.validation.AbstractValidator} without actually really implementing one of the {@link cfeditor.map.validation.Validator}, your validator will be a valid and compilable validator but also a disfunctional stub. + If you extend {@link daieditor.map.validation.AbstractValidator} without actually really implementing one of the {@link daieditor.map.validation.Validator}, your validator will be a valid and compilable validator but also a disfunctional stub. So don't forget to extend the corresponding subinterface. </p> <h3>FAQ</h3> <dl> - <dt>Do I really have to always extend {@link cfeditor.map.validation.ValidationError} for my validator's errors?</dt> - <dd>Well not really. But the automatic localization of ValidationErrors depends on separate error class names. Also, {@link cfeditor.map.validation.CorrectableError} depends on separate error classes.</dd> + <dt>Do I really have to always extend {@link daieditor.map.validation.ValidationError} for my validator's errors?</dt> + <dd>Well not really. But the automatic localization of ValidationErrors depends on separate error class names. Also, {@link daieditor.map.validation.CorrectableError} depends on separate error classes.</dd> </dl> </body> </html> Modified: trunk/daimonin/src/daieditor/overview.html =================================================================== --- trunk/daimonin/src/daieditor/overview.html 2006-05-27 16:17:29 UTC (rev 47) +++ trunk/daimonin/src/daieditor/overview.html 2006-05-27 16:18:05 UTC (rev 48) @@ -12,17 +12,17 @@ </p> <h3>UI Classes</h3> <p> - The most important UI class is {@link cfeditor.CMainView}. + The most important UI class is {@link daieditor.CMainView}. It is the main window, creates the main layout and holds all actions. - Most actions are delegated to {@link cfeditor.CMainControl} upon performation. + Most actions are delegated to {@link daieditor.CMainControl} upon performation. </p> <p> - Map Visualisation is done by {@link cfeditor.CMapViewBasic}, which renders the map, and {@link cfeditor.CMapViewIFrame}, which is + Map Visualisation is done by {@link daieditor.CMapViewBasic}, which renders the map, and {@link daieditor.CMapViewIFrame}, which is a JInternalFrame wrapping CMapViewBasic. </p> <h3>Data Model</h3> <p> - Each archetype is an instance of {@link cfeditor.arch.ArchObject}. + Each archetype is an instance of {@link daieditor.arch.ArchObject}. </p> <h3>Daimonin Editor Terminology Glossary</h3> <dl> @@ -45,7 +45,7 @@ An animation can be anonymously defined inside a default arch; such animations inherit the name from the defining arch. Or an animation can be defined in a separate file in the <code>arch/</code> folder. <p /> - Animations are NamedObjects, override Faces, they are implemented by {@link cfeditor.arch.anim.AnimationObject} and {@link cfeditor.arch.anim.AnimationObjects}. + Animations are NamedObjects, override Faces, they are implemented by {@link daieditor.arch.anim.AnimationObject} and {@link daieditor.arch.anim.AnimationObjects}. <p /> </dd> <dt id="Archetype">Archetype</dt> @@ -63,9 +63,9 @@ After the migration is finished, Artifacts are special "appliable" Archetypes. You'd select an ArchObject and apply an Artifact on it, which would copy all Artifact attributes over the ArchObject attributes. <p /> - The class that implements Archetypes is {@link cfeditor.arch.ArchObject}. - The class that parses text for modifying ArchObjects is {@link cfeditor.arch.ArchObjectParser}. - The class that holds all Default Archetypes, including those for Default Artifacts, is {@link cfeditor.arch.ArchObjectStack}. + The class that implements Archetypes is {@link daieditor.arch.ArchObject}. + The class that parses text for modifying ArchObjects is {@link daieditor.arch.ArchObjectParser}. + The class that holds all Default Archetypes, including those for Default Artifacts, is {@link daieditor.arch.ArchObjectStack}. <p /> </dd> <dt id="Artifact">Artifact</dt> @@ -78,7 +78,7 @@ The Face is the appearance of an Archetype. A Face is defined by a String that uniquely defines the appearance and is used to reference a corresponding graphic image, usually a PNG file. - The {@link cfeditor.arch.ArchObjectStack} contains a collection of all available faces. + The {@link daieditor.arch.ArchObjectStack} contains a collection of all available faces. <p /> Animations override Faces. <p /> @@ -90,7 +90,7 @@ At those grid positions, Map Squares with Arch Objects can be found and make up the world, its surface, obstacles, items etc.. <p /> The Map itself is defined by a Map Arch. - The class storing the Map is {@link cfeditor.map.MapModel}. + The class storing the Map is {@link daieditor.map.MapModel}. <p /> </dd> <dt id="MapSquare">(Map )Square</dt> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-05-27 23:54:59
|
Revision: 55 Author: christianhujer Date: 2006-05-27 16:54:44 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=55&view=rev Log Message: ----------- Fixed bogus behaviour regarding map tile pane preferences. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-05-27 22:48:31 UTC (rev 54) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-05-27 23:54:44 UTC (rev 55) @@ -25,6 +25,8 @@ package daieditor; +import static daieditor.CMainView.MAP_TILE_LIST_BOTTOM_KEY; +import static daieditor.CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT; import static daieditor.IGUIConstants.TILE_EDIT_NONE; import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectParser; @@ -704,7 +706,7 @@ loadFromArchive = prefs.getBoolean(LOAD_ARCH_COLL, true); - mainView.setMapTileListBottom(prefs.getBoolean(CMainView.MAPTILE_BOTTOM_KEY, true)); + mainView.setMapTileListBottom(prefs.getBoolean(MAP_TILE_LIST_BOTTOM_KEY, MAP_TILE_LIST_BOTTOM_DEFAULT)); pickmapsLocked = prefs.getBoolean(PICKMAPS_LOCKED, false); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-05-27 22:48:31 UTC (rev 54) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-05-27 23:54:44 UTC (rev 55) @@ -111,9 +111,12 @@ /** The key used to store the main windows divider location to the preferences. */ private static final String DIVIDER_LOCATION_KEY3 = "MainWindow.dividerLocation3"; - /** key for info weither map-tile panel is seperate or at bottom. */ - public static final String MAPTILE_BOTTOM_KEY = "MapTileBottom"; + /** Key for info whether map-tile panel is seperate or at bottom. */ + public static final String MAP_TILE_LIST_BOTTOM_KEY = "MapTileBottom"; + /** Default value for {@link MAP_TILE_LIST_BOTTOM_KEY}. */ + public static final boolean MAP_TILE_LIST_BOTTOM_DEFAULT = true; + /** The controller of this view. */ private static final CMainControl mainControl = CMainControl.getInstance(); @@ -151,7 +154,7 @@ private boolean pickmapActive; /** <code>true</code> when archpanel is merged into the bottom panel. */ - private boolean maptileBottom = true; + private boolean mapTileListBottom = true; /** Constructs the main view and registers the given main controller. */ CMainView() { @@ -215,7 +218,7 @@ mapDesktop = new JDesktopPane(); mapArchPanel = new CMapArchPanel(mainControl, this); - if (!maptileBottom) { + if (!mapTileListBottom) { splitRightPane = new DSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileList); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new DSplitPane(VERTICAL_SPLIT, splitRightPane, mapArchPanel); @@ -389,14 +392,20 @@ statusBar.setStatusText(statusText); } - // is the map tile list in the bottom panel + /** + * Returns <code>true</code> when archpanel is merged into the bottom panel. + * @return <code>true</code> when archpanel is merged into the bottom panel. + */ public boolean isMapTileListBottom() { - return maptileBottom; + return mapTileListBottom; } - // is the map tile list in the bottom panel - public void setMapTileListBottom(final boolean state) { - maptileBottom = state; + /** + * Sets <code>true</code> when archpanel is merged into the bottom panel. + * @param mapTileListBottom <code>true</code> when archpanel is merged into the bottom panel + */ + public void setMapTileListBottom(final boolean mapTileListBottom) { + this.mapTileListBottom = mapTileListBottom; } /** Notifies that the application is about to exit. */ Modified: trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2006-05-27 22:48:31 UTC (rev 54) +++ trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2006-05-27 23:54:44 UTC (rev 55) @@ -23,7 +23,8 @@ import daieditor.CMainControl; import static daieditor.CMainControl.PREFS_LANGUAGE; -import static daieditor.CMainView.MAPTILE_BOTTOM_KEY; +import static daieditor.CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT; +import static daieditor.CMainView.MAP_TILE_LIST_BOTTOM_KEY; import static daieditor.IGUIConstants.DIALOG_BORDER; import java.awt.Component; import static java.util.Arrays.binarySearch; @@ -57,14 +58,11 @@ private static final long serialVersionUID = 1L; /** Action Facotry. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); - /** Main Control. */ - private final CMainControl mainControl; - /** ComboBox for choosing the locale. */ private JComboBox localeBox; @@ -82,9 +80,8 @@ * @param mainControl The controller of this dialog. */ public GUIPrefs(final CMainControl mainControl) { - setListLabelText(actionFactory.getString("prefsGUI.title")); - setListLabelIcon(actionFactory.getIcon("prefsGUI.icon")); - this.mainControl = mainControl; + setListLabelText(ACTION_FACTORY.getString("prefsGUI.title")); + setListLabelIcon(ACTION_FACTORY.getIcon("prefsGUI.icon")); add(createGlobalPanel()); add(createLayoutPanel()); @@ -97,31 +94,31 @@ * @return titled border */ private static Border createTitledBorder(final String titleKey) { - return new CompoundBorder(new TitledBorder(actionFactory.getString(titleKey)), DIALOG_BORDER); + return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), DIALOG_BORDER); } /** {@inheritDoc} */ public void apply() { final Locale loc = (Locale) localeBox.getSelectedItem(); if (loc != null) { - prefs.put(PREFS_LANGUAGE, loc.getLanguage()); + PREFS.put(PREFS_LANGUAGE, loc.getLanguage()); } else { - prefs.remove(PREFS_LANGUAGE); + PREFS.remove(PREFS_LANGUAGE); } - prefs.putBoolean(MAPTILE_BOTTOM_KEY, !mapPanelBottom.isSelected()); + PREFS.putBoolean(MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); } /** {@inheritDoc} */ public void revert() { final String current = userNodeForPackage(CMainControl.class).get(PREFS_LANGUAGE, null); localeBox.setSelectedIndex(binarySearch(locales, current != null ? new Locale(current) : null, comp)); - mapPanelBottom.setSelected(!mainControl.getMainView().isMapTileListBottom()); + mapPanelBottom.setSelected(PREFS.getBoolean(MAP_TILE_LIST_BOTTOM_KEY, MAP_TILE_LIST_BOTTOM_DEFAULT)); } /** {@inheritDoc} */ public void defaults() { localeBox.setSelectedIndex(binarySearch(locales, null, comp)); - mapPanelBottom.setSelected(true); + mapPanelBottom.setSelected(MAP_TILE_LIST_BOTTOM_DEFAULT); } /** {@inheritDoc} */ @@ -131,7 +128,7 @@ final Locale current = currentName != null ? new Locale(currentName) : null; return !( (loc == null ? loc == current : loc.equals(current)) - && mapPanelBottom.isSelected() != mainControl.getMainView().isMapTileListBottom() + && mapPanelBottom.isSelected() == PREFS.getBoolean(MAP_TILE_LIST_BOTTOM_KEY, MAP_TILE_LIST_BOTTOM_DEFAULT) ); } @@ -142,7 +139,7 @@ private Component buildLocaleBox() { final Box lineLayout = createHorizontalBox(); - final String[] locNames = actionFactory.getString("availableLocales").split("\\s+"); + final String[] locNames = ACTION_FACTORY.getString("availableLocales").split("\\s+"); locales = new Locale[locNames.length + 1]; // locales[0] is intentionally null. It will be displayed as default and always get sorted to the top. for (int i = 0; i < locNames.length; i++) { @@ -150,7 +147,7 @@ } sort(locales, comp); - lineLayout.add(new JLabel(actionFactory.getString("optionsLanguage"))); // create label + lineLayout.add(new JLabel(ACTION_FACTORY.getString("optionsLanguage"))); // create label localeBox = new JComboBox(locales); // set "content" localeBox.setRenderer(new LocaleListCellRenderer()); @@ -183,8 +180,8 @@ final Box layoutPanel = createVerticalBox(); layoutPanel.setBorder(createTitledBorder("optionsLayout")); - mapPanelBottom = new JCheckBox(actionFactory.createAction(false, "optionsSepMapTile")); - mapPanelBottom.setSelected(!mainControl.getMainView().isMapTileListBottom()); + mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); + mapPanelBottom.setSelected(PREFS.getBoolean(MAP_TILE_LIST_BOTTOM_KEY, MAP_TILE_LIST_BOTTOM_DEFAULT)); layoutPanel.add(mapPanelBottom); return layoutPanel; } Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2006-05-27 22:48:31 UTC (rev 54) +++ trunk/daimonin/src/daieditor/messages.properties 2006-05-27 23:54:44 UTC (rev 55) @@ -284,8 +284,8 @@ optionsLanguage=Language optionsLayout=Layout Settings optionsUpdate=Automatic Update -optionsSepMapTile.text=Separate Map-Tile Panel -optionsSepMapTile.shortdescription=Checking this moves the Map-Tile Panel to the right side of the screen instead of the bottom right corner. +optionsSepMapTile.text=Display Map-Tile Panel at the bottom +optionsSepMapTile.shortdescription=Unchecking this moves the Map-Tile Panel to the right side of the screen instead of the bottom right corner. optionsLoadArchColl.text=Load Arches from Collection optionsGlobal=Global optionsResPaths=Resource Paths Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2006-05-27 22:48:31 UTC (rev 54) +++ trunk/daimonin/src/daieditor/messages_de.properties 2006-05-27 23:54:44 UTC (rev 55) @@ -119,7 +119,7 @@ optionsTitle=Optionen optionsLanguage=Sprache optionsLayout=Layout-Einstellungen -optionsSepMapTile=Getrenntes Map-Tile-Panel +optionsSepMapTile.title=Map-Tile-Panel unten anzeigen optionsLoadArchColl.text=Vorbereitete Archetypen laden optionsGlobal=Global optionsResPaths=Pfade This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-05-28 19:23:18
|
Revision: 59 Author: christianhujer Date: 2006-05-28 12:22:32 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=59&view=rev Log Message: ----------- Unified ActionFactory usage. Modified Paths: -------------- trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CFJavaEditor.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainStatusbar.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMapTileList.java trunk/daimonin/src/daieditor/CNewMapDialog.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CPreview.java trunk/daimonin/src/daieditor/MapTilePane.java trunk/daimonin/src/daieditor/ProcessRunner.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/Spells.java trunk/daimonin/src/daieditor/Updater.java trunk/daimonin/src/daieditor/arch/ArchObjectStack.java trunk/daimonin/src/daieditor/arch/NamedObjects.java trunk/daimonin/src/daieditor/arch/face/FaceObjects.java trunk/daimonin/src/daieditor/gui/AboutDialog.java trunk/daimonin/src/daieditor/gui/MapFileFilter.java trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java trunk/daimonin/src/daieditor/gui/prefs/DevPrefs.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/daimonin/src/daieditor/gui/prefs/MapValidatorPrefs.java trunk/daimonin/src/daieditor/gui/prefs/MiscPrefs.java trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/validation/AbstractValidator.java trunk/daimonin/src/daieditor/map/validation/ValidationError.java Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-05-28 19:22:32 UTC (rev 59) @@ -24,6 +24,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectStack; import java.awt.BorderLayout; @@ -55,7 +56,7 @@ private static final long serialVersionUID = 1L; /** ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Controller of this subview. */ private final CMainControl mainControl; @@ -139,7 +140,7 @@ private JPopupMenu createListPopupMenu() { final JPopupMenu menu = new JPopupMenu(); - menu.add(actionFactory.createAction(false, "editPopup", this)); + menu.add(ACTION_FACTORY.createAction(false, "editPopup", this)); return menu; } Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-05-28 19:22:32 UTC (rev 59) @@ -123,7 +123,7 @@ private static final long serialVersionUID = 1L; /** Action Factory. */ - private static final ActionFactory actionFactory = getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); // store width of input-textfields, then JChooseBoxes are set to this width too public static final int TEXTFIELD_COLUMNS = 18; // number of columns for textfields @@ -155,10 +155,10 @@ private final CardLayout cardLayout = new CardLayout(); /** The Action for switching to the summary. */ - private Action summaryAction = actionFactory.createAction(false, "attribSummary", this); + private Action summaryAction = ACTION_FACTORY.createAction(false, "attribSummary", this); /** The Action for switching to the edit. */ - private Action editAction = actionFactory.createAction(false, "attribEdit", this); + private Action editAction = ACTION_FACTORY.createAction(false, "attribEdit", this); /** The Button for toggling the summary. */ private JButton summaryEditButton; @@ -857,12 +857,12 @@ */ private Object[] buildOptions() { return new Object[]{ - new JButton(actionFactory.createAction(false, "attribHelp", this)), + new JButton(ACTION_FACTORY.createAction(false, "attribHelp", this)), summaryEditButton = new JButton(summaryAction), Box.createHorizontalStrut(32), - okButton = new JButton(actionFactory.createAction(false, "attribOk", this)), - new JButton(actionFactory.createAction(false, "attribApply", this)), - cancelButton = new JButton(actionFactory.createAction(false, "attribCancel", this)), + okButton = new JButton(ACTION_FACTORY.createAction(false, "attribOk", this)), + new JButton(ACTION_FACTORY.createAction(false, "attribApply", this)), + cancelButton = new JButton(ACTION_FACTORY.createAction(false, "attribCancel", this)), }; } Modified: trunk/daimonin/src/daieditor/CFJavaEditor.java =================================================================== --- trunk/daimonin/src/daieditor/CFJavaEditor.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CFJavaEditor.java 2006-05-28 19:22:32 UTC (rev 59) @@ -33,7 +33,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import static java.util.prefs.Preferences.userNodeForPackage; -import net.sf.japi.swing.ActionFactory; +import static net.sf.japi.swing.ActionFactory.getFactory; /** * Main Class, launches the level editor application. @@ -64,7 +64,7 @@ Locale.setDefault(new Locale(locName)); } // Now add prefs to the ActionFactory. - ActionFactory.getFactory("daieditor").addPref(CMainControl.class); + getFactory("daieditor").addPref(CMainControl.class); final SplashScreen splashScreen = new SplashScreen(); splashScreen.show(); final List<String> infiles = new ArrayList<String>(); // map file names to open initially Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-05-28 19:22:32 UTC (rev 59) @@ -25,6 +25,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import static daieditor.CMainView.MAP_TILE_LIST_BOTTOM_KEY; import static daieditor.CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT; import static daieditor.IGUIConstants.TILE_EDIT_NONE; @@ -131,7 +132,7 @@ public final class CMainControl implements ThrowableHandler, MapModelListener { /** ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Logger. */ private static final Logger logger = Logger.getLogger("daieditor"); @@ -429,8 +430,8 @@ ArchObject.setMControl(this); // our global object parser archObjectParser = new ArchObjectParser(this); - animationObjects = new AnimationObjects(actionFactory.getString("nameOfAnimationObject")); - faceObjects = new FaceObjects(actionFactory.getString("nameOfFaceObject")); + animationObjects = new AnimationObjects(ACTION_FACTORY.getString("nameOfAnimationObject")); + faceObjects = new FaceObjects(ACTION_FACTORY.getString("nameOfFaceObject")); // read in the type & type field definitions //loadTypeDef(); @@ -445,7 +446,7 @@ // Delete the old settings file. Remove me after a while. File settings = new File(new File(System.getProperty("user.home"), IGUIConstants.APP_SETTINGS_DIR), IGUIConstants.APP_NAME); - if (settings.exists() && actionFactory.showOnetimeConfirmDialog(mainView, YES_NO_OPTION, INFORMATION_MESSAGE, "oldSettingsFound", settings.toString()) == YES_OPTION) + if (settings.exists() && ACTION_FACTORY.showOnetimeConfirmDialog(mainView, YES_NO_OPTION, INFORMATION_MESSAGE, "oldSettingsFound", settings.toString()) == YES_OPTION) { settings.delete(); } @@ -457,11 +458,11 @@ // Delete libraries. final File libs = new File(System.getProperty("user.dir"), "lib"); - final String libsString = actionFactory.getString("oldLibs.okayLibs"); + final String libsString = ACTION_FACTORY.getString("oldLibs.okayLibs"); assert libsString != null; final String[] patterns = libsString.split("\\s+"); final File[] libFiles = libs.listFiles(Factory.not(new GlobFileFilter(patterns))); - if (libFiles != null && libFiles.length > 0 && actionFactory.showOnetimeConfirmDialog(mainView, YES_NO_OPTION, INFORMATION_MESSAGE, "oldLibsFound", libs.toString()) == YES_OPTION) + if (libFiles != null && libFiles.length > 0 && ACTION_FACTORY.showOnetimeConfirmDialog(mainView, YES_NO_OPTION, INFORMATION_MESSAGE, "oldLibsFound", libs.toString()) == YES_OPTION) { for (final File libFile : libFiles) { libFile.delete(); @@ -477,7 +478,7 @@ public void controlServer() { if (controlServer == null) { controlServer = new ProcessRunner("controlServer", prefs.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT)); - actionFactory.showOnetimeMessageDialog(mainView, WARNING_MESSAGE, "controlServerWarning"); + ACTION_FACTORY.showOnetimeMessageDialog(mainView, WARNING_MESSAGE, "controlServerWarning"); } else { controlServer.setCommand(prefs.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT)); } @@ -735,16 +736,16 @@ public static final FileFilter mapFileFilter = new HideFileFilterProxy(MapFileFilter.getInstance()); /** Swing FileFilter for Lua scripts. */ - public static final FileFilter luaFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, actionFactory.getString("fileDialog.filter.lua"), ".lua")); + public static final FileFilter luaFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.lua"), ".lua")); /** Swing FileFilter for png graphics. */ - public static final FileFilter pngFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, actionFactory.getString("fileDialog.filter.png"), ".png")); + public static final FileFilter pngFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.png"), ".png")); /** Swing FileFilter for .arc files. */ - public static final FileFilter arcFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, actionFactory.getString("fileDialog.filter.arc"), ".arc")); + public static final FileFilter arcFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.arc"), ".arc")); /** Swing FileFilter for .anim files. */ - public static final FileFilter animFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, actionFactory.getString("fileDialog.filter.anim"), ".anim")); + public static final FileFilter animFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.anim"), ".anim")); public String getMapDefaultFolder() { return strMapDir; @@ -956,24 +957,24 @@ /** Invoked when the user wants to close the active pickmap */ public void closePickmap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { - actionFactory.showMessageDialog(mainView, "closePickmapNotLoaded"); + ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNotLoaded"); } else { if (!mainView.isPickmapActive()) { - actionFactory.showMessageDialog(mainView, "closePickmapHidden"); + ACTION_FACTORY.showMessageDialog(mainView, "closePickmapHidden"); } else { final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { - actionFactory.showMessageDialog(mainView, "closePickmapNoPickmaps"); + ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNoPickmaps"); } else { // if pickmap was modified, ask for confirmation: - if (!activePickmap.isLevelChanged() || actionFactory.showQuestionDialog(mainView, "confirmClosePickmap", activePickmap.getMapFileName())) + if (!activePickmap.isLevelChanged() || ACTION_FACTORY.showQuestionDialog(mainView, "confirmClosePickmap", activePickmap.getMapFileName())) { final File pickmapFile = activePickmap.getMapFile(); // close pickmap closeLevel(activePickmap, true); // also delete pickmap file? - if (actionFactory.showQuestionDialog(mainView, "confirmDeletePickmap", activePickmap.getMapFileName(), activePickmap.getMapFileName())) + if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmDeletePickmap", activePickmap.getMapFileName(), activePickmap.getMapFileName())) { pickmapFile.delete(); } @@ -1001,12 +1002,12 @@ public boolean closeLevel(final MapControl level, final boolean forced) { if (level == null) { - actionFactory.showMessageDialog(mainView, "closeLevelNullLevel", levels.size(), currentMap); + ACTION_FACTORY.showMessageDialog(mainView, "closeLevelNullLevel", levels.size(), currentMap); return false; } if (!forced && level.isLevelChanged()) { - final int result = actionFactory.showConfirmDialog(mainView, YES_NO_CANCEL_OPTION, WARNING_MESSAGE, "confirmSaveChanges", level.getMapArch().getMapNameWithoutMusic()); + final int result = ACTION_FACTORY.showConfirmDialog(mainView, YES_NO_CANCEL_OPTION, WARNING_MESSAGE, "confirmSaveChanges", level.getMapArch().getMapNameWithoutMusic()); if (result == YES_OPTION) { if (level.isPlainSaveEnabled()) { level.save(); @@ -1047,19 +1048,19 @@ /** Open active pickmap as normal map for extensive editing */ public void openPickmapMap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { - actionFactory.showMessageDialog(mainView, "openPickmapMapNotLoaded"); + ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapNotLoaded"); } else { if (!mainView.isPickmapActive()) { - actionFactory.showMessageDialog(mainView, "openPickmapMapHidden"); + ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapHidden"); } else { final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { - actionFactory.showMessageDialog(mainView, "openPickmapNoPickmaps"); + ACTION_FACTORY.showMessageDialog(mainView, "openPickmapNoPickmaps"); } else { // open pickmap as map final File pickmapFile = activePickmap.getMapFile(); if (!pickmapFile.exists()) { - if (actionFactory.showQuestionDialog(mainView, "confirmCreatePickmap", activePickmap.getMapFileName())) { + if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmCreatePickmap", activePickmap.getMapFileName())) { savePickmap(); openFile(pickmapFile); } @@ -1080,7 +1081,7 @@ /** Create the JFileChooser for opening a file. */ private void createFileChooser() { fileChooser = new JFileChooser(); - fileChooser.setDialogTitle(actionFactory.getString("fileDialog.title")); + fileChooser.setDialogTitle(ACTION_FACTORY.getString("fileDialog.title")); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(true); fileChooser.addChoosableFileFilter(luaFileFilter); @@ -1114,7 +1115,7 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { if (ArchObjectStack.getLoadStatus() == ArchObjectStack.IS_EMPTY) { // ArchStack is empty -> abort! - actionFactory.showMessageDialog(mainView, "openFileWantedNoArches"); + ACTION_FACTORY.showMessageDialog(mainView, "openFileWantedNoArches"); } else { hasChangedDir = true; // user has chosen an active dir openFiles(fileChooser.getCurrentDirectory(), fileChooser.getSelectedFiles()); @@ -1217,17 +1218,17 @@ objects = mapFileDecoder.decodeMapFile(file, mapDir.getAbsolutePath()); // parse mapfile maparch = mapFileDecoder.getMapArch(); // get map arch } catch (final FileNotFoundException e) { - actionFactory.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); + ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); return false; } catch (final IOException e) { - actionFactory.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); + ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); return false; } catch (final CGridderException e) { - actionFactory.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); + ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); return false; } catch (final OutOfMemoryError ignore) { // out of memory!! - display error - actionFactory.showMessageDialog(mainView, "mapOutOfMemory"); + ACTION_FACTORY.showMessageDialog(mainView, "mapOutOfMemory"); return false; } @@ -1263,11 +1264,11 @@ public void openAttrDialog(final ArchObject arch) { if (typeList.isEmpty()) { // types.txt is missing! - actionFactory.showMessageDialog(mainView, "openAttrDialogNoTypes"); + ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (arch != null && arch.hasDefaultArch()) { CAttribDialog.showAttribDialog(typeList, arch, this); } else { - actionFactory.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); + ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } } @@ -1280,9 +1281,9 @@ try { mapFileEncoder.encodeMapFile(file, mapModel); } catch (final FileNotFoundException e) { - actionFactory.showMessageDialog(mainView, "encodeMapFile", file); + ACTION_FACTORY.showMessageDialog(mainView, "encodeMapFile", file); } catch (final IOException e) { - actionFactory.showMessageDialog(mainView, "encodeMapFile", file); + ACTION_FACTORY.showMessageDialog(mainView, "encodeMapFile", file); } } @@ -1319,7 +1320,7 @@ objects.add(tail); } if (noarchcount > 0) { - actionFactory.showMessageDialog(mainView, "collectTemplistAutodelete", file.getName(), noarchcount, noarch); + ACTION_FACTORY.showMessageDialog(mainView, "collectTemplistAutodelete", file.getName(), noarchcount, noarch); } return true; } @@ -1337,17 +1338,17 @@ public void savePickmap() { if (CPickmapPanel.getInstance().isLoadComplete()) { if (!mainView.isPickmapActive()) { - actionFactory.showMessageDialog(mainView, "savePickmapHidden"); + ACTION_FACTORY.showMessageDialog(mainView, "savePickmapHidden"); } else { final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { - actionFactory.showMessageDialog(mainView, "savePickmapNoPickmaps"); + ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNoPickmaps"); } else { activePickmap.save(); } } } else { - actionFactory.showMessageDialog(mainView, "savePickmapNotLoaded"); + ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNotLoaded"); } } @@ -1391,7 +1392,7 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { hasChangedDir = true; // user has chosen an active dir final File file = fileChooser.getSelectedFile(); - if (!file.exists() || actionFactory.showConfirmDialog(mainView, WARNING_MESSAGE, OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == OK_OPTION) + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, WARNING_MESSAGE, OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == OK_OPTION) { level.saveAs(file); level.setMapFileName(file.getName()); // window title and file name @@ -1417,7 +1418,7 @@ if (mc == null) { // there is no map open (should not happen due to disabled menus) - actionFactory.showMessageDialog(mainView, "createImgNoMap"); + ACTION_FACTORY.showMessageDialog(mainView, "createImgNoMap"); } else { String filename = null; try { @@ -1442,13 +1443,13 @@ if (!filename.endsWith(".png")) { filename += ".png"; } - if (!new File(filename).exists() || actionFactory.showConfirmDialog(mainView, YES_NO_OPTION, WARNING_MESSAGE, "overwriteOtherFile", filename) == YES_OPTION) + if (!new File(filename).exists() || ACTION_FACTORY.showConfirmDialog(mainView, YES_NO_OPTION, WARNING_MESSAGE, "overwriteOtherFile", filename) == YES_OPTION) { mc.getMapViewFrame().printFullImage(filename); } } } catch (final IOException e) { - actionFactory.showMessageDialog(mainView, "createImgIOException", filename); + ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", filename); } } } @@ -1464,7 +1465,7 @@ if (mapc == null) { // there is no map open (should not happen due to disabled menus) - actionFactory.showMessageDialog(mainView, "createImgNoMap"); + ACTION_FACTORY.showMessageDialog(mainView, "createImgNoMap"); } else { try { if (!filename.endsWith(".png")) { @@ -1473,7 +1474,7 @@ mapc.getMapViewFrame().printFullImage(filename); logger.log(Level.INFO, "imageCreated", new Object[]{filename, mapc.getMapFileName()}); } catch (final IOException e) { - actionFactory.showMessageDialog(mainView, "createImgIOException", filename); + ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", filename); } } } @@ -1564,7 +1565,7 @@ } if (exit == null) { // no exit found - actionFactory.showMessageDialog(mainView, "enterExitNoExit"); + ACTION_FACTORY.showMessageDialog(mainView, "enterExitNoExit"); return; } final Point d = new Point(); @@ -1573,7 +1574,7 @@ final String path = exit.getAttributeString("slaying", true); // exit path if (path == null || path.length() == 0) { - actionFactory.showMessageDialog(mainView, "enterExitNoExit"); + ACTION_FACTORY.showMessageDialog(mainView, "enterExitNoExit"); return; } @@ -1630,7 +1631,7 @@ final String path = currentMap.getMapArch().getTilePath(direction); if (path == null || path.length() == 0) { // tile direction not set (due to disabled menus this should normally not happen) - actionFactory.showMessageDialog(mainView, "enterTileNoTile"); + ACTION_FACTORY.showMessageDialog(mainView, "enterTileNoTile"); return; } enterMapWanted(new Point(), path); @@ -1659,17 +1660,17 @@ if (d != null && (path.length() == 0 || currentMap.getMapFile() != null && newfile != null && newfile.equals(currentMap.getMapFile()))) { // path points to the same map if (d.x == 0 && d.y == 0) { - actionFactory.showMessageDialog(mainView, "enterExitNowhere"); + ACTION_FACTORY.showMessageDialog(mainView, "enterExitNowhere"); } else if (currentMap.isPointValid(d)) { currentMap.getMapViewFrame().setHotspot(d); } else { - actionFactory.showMessageDialog(mainView, "enterExitOutside"); + ACTION_FACTORY.showMessageDialog(mainView, "enterExitOutside"); } return; } if (!newfile.exists() || newfile.isDirectory()) { // The path is wrong - actionFactory.showMessageDialog(mainView, "enterExitInvalidPath", newfile.getAbsolutePath()); + ACTION_FACTORY.showMessageDialog(mainView, "enterExitInvalidPath", newfile.getAbsolutePath()); return; } // its important to force the canonical file here or the @@ -1681,7 +1682,7 @@ try { newFileOpened = openFile(newfile.getCanonicalFile()); } catch (final IOException e) { - actionFactory.showMessageDialog(mainView, "enterTileIOException", newfile.getAbsolutePath()); + ACTION_FACTORY.showMessageDialog(mainView, "enterTileIOException", newfile.getAbsolutePath()); return; } if (d.x == 0 && d.y == 0) { @@ -1690,7 +1691,7 @@ d.y = currentMap.getMapModel().getMapArch().getEnterY(); } currentMap.getMapViewFrame().setHotspot(d); // set hotspot TODO set cursor instead - if (newFileOpened && YES_OPTION == actionFactory.showOnetimeConfirmDialog(mainView, YES_NO_OPTION, QUESTION_MESSAGE, "enterExitClose")) { + if (newFileOpened && YES_OPTION == ACTION_FACTORY.showOnetimeConfirmDialog(mainView, YES_NO_OPTION, QUESTION_MESSAGE, "enterExitClose")) { // only close current level if a new file was opened and user wants to close it closeLevel(oldmap); // close the old map } @@ -1721,7 +1722,7 @@ /** Invoked when user wants to revert the current map to previously saved state */ public void revert() { final MapControl modmap = currentMap; // "modified map" to be reverted - if (actionFactory.showQuestionDialog(mainView, "confirmRevertMap", modmap.getMapFileName())) { + if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", modmap.getMapFileName())) { final File mfile = modmap.getMapFile(); // store file closeLevel(modmap, true); // close the old map openFile(mfile); // open the new map @@ -1734,21 +1735,21 @@ /** Invoked when user wants to revert the current map to previously saved state */ public void revertPickmap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { - actionFactory.showMessageDialog(mainView, "revertPickmapNotLoaded"); + ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNotLoaded"); } else { if (!mainView.isPickmapActive()) { - actionFactory.showMessageDialog(mainView, "revertPickmapHidden"); + ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapHidden"); } else { final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { - actionFactory.showMessageDialog(mainView, "revertPickmapNoPickmaps"); + ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNoPickmaps"); } else { // ask for confirmation - if (!activePickmap.isLevelChanged() || actionFactory.showQuestionDialog(mainView, "confirmRevertPickmap", activePickmap.getMapFileName())) + if (!activePickmap.isLevelChanged() || ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertPickmap", activePickmap.getMapFileName())) { final File mfile = activePickmap.getMapFile(); // store file if (!mfile.exists()) { - actionFactory.showMessageDialog(mainView, "pickmapRevertGone", activePickmap.getMapFileName()); + ACTION_FACTORY.showMessageDialog(mainView, "pickmapRevertGone", activePickmap.getMapFileName()); return; } @@ -2057,7 +2058,7 @@ /** Update wanted. */ public void update() { if (levels.size() > 0) { - actionFactory.showMessageDialog(mainView, "updateCloseMaps"); + ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); } else { Updater.update(mainView); } @@ -2192,7 +2193,7 @@ super(title); this.filename = filename; this.title = title; - putValue(SHORT_DESCRIPTION, actionFactory.format("recentItem.shortdescriptionformat", title, getShortFileName())); + putValue(SHORT_DESCRIPTION, ACTION_FACTORY.format("recentItem.shortdescriptionformat", title, getShortFileName())); putValue(SMALL_ICON, getIcon()); } @@ -2203,7 +2204,7 @@ Recent(final int index) { title = prefs.get("recentTitle[" + Integer.toString(index - 1) + ']', null); filename = prefs.get("recentFilename[" + Integer.toString(index - 1) + ']', null); - putValue(SHORT_DESCRIPTION, actionFactory.format("recentItem.shortdescriptionformat", title, getShortFileName())); + putValue(SHORT_DESCRIPTION, ACTION_FACTORY.format("recentItem.shortdescriptionformat", title, getShortFileName())); putValue(SMALL_ICON, getIcon()); setIndex(index); } Modified: trunk/daimonin/src/daieditor/CMainStatusbar.java =================================================================== --- trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CMainStatusbar.java 2006-05-28 19:22:32 UTC (rev 59) @@ -25,6 +25,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.gui.map.DefaultLevelRenderer; import daieditor.gui.map.MapCursor; import daieditor.gui.map.MapCursorEvent; @@ -59,7 +60,7 @@ private static final long serialVersionUID = 1L; /** The ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Controller of this statusbar view. */ private final CMainControl mainControl; @@ -130,7 +131,7 @@ final long totMem = runtime.totalMemory(); final long usedMem = totMem - freeMem; - memory.setText(actionFactory.format("memory", + memory.setText(ACTION_FACTORY.format("memory", mainControl.getArchObjectStack().getArchObjCount(), mainControl.getArchObjectStack().getArchCount(), mainControl.getFaceObjects().size(), @@ -187,12 +188,12 @@ assert offset != null; final int offsetX = Math.abs(offset.width) + 1; final int offsetY = Math.abs(offset.height) + 1; - formatCursor = actionFactory.format("statusSelect", cursorX, cursorY, offsetX, offsetY); + formatCursor = ACTION_FACTORY.format("statusSelect", cursorX, cursorY, offsetX, offsetY); } else { - formatCursor = actionFactory.format("statusNormal", cursorX, cursorY); + formatCursor = ACTION_FACTORY.format("statusNormal", cursorX, cursorY); } } else { - formatCursor = actionFactory.format("statusCursorOff"); + formatCursor = ACTION_FACTORY.format("statusCursorOff"); } cursor.setText(formatCursor); } @@ -218,9 +219,9 @@ if (mouseMap != null) { final int mouseMapX = mouseMap.x; final int mouseMapY = mouseMap.y; - mouse.setText(actionFactory.format("statusMouseOn", mouseX, mouseY, mouseMapX, mouseMapY)); + mouse.setText(ACTION_FACTORY.format("statusMouseOn", mouseX, mouseY, mouseMapX, mouseMapY)); } else { - mouse.setText(actionFactory.format("statusMouseOff", mouseX, mouseY)); + mouse.setText(ACTION_FACTORY.format("statusMouseOff", mouseX, mouseY)); } } } // class CMainStatusbar Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-05-28 19:22:32 UTC (rev 59) @@ -24,6 +24,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectStack; import daieditor.gui.AboutDialog; @@ -76,7 +77,7 @@ public final class CMainView extends JFrame implements ErrorHandler, InternalFrameListener, ThrowableHandler, WindowListener { /** Action Factory to create Actions. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -177,8 +178,8 @@ final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); - setJMenuBar(actionFactory.createMenuBar(true, "main")); - add(actionFactory.createToolBar("main"), BorderLayout.NORTH); + setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); + add(ACTION_FACTORY.createToolBar("main"), BorderLayout.NORTH); add(createCenterPanel(prefs, defwidth, defheight), BorderLayout.CENTER); // set bounds (location and size) of the main frame @@ -208,7 +209,7 @@ final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); pickmapPanel = new JTabbedPane(SwingConstants.TOP); - pickmapPanel.setComponentPopupMenu(actionFactory.createPopupMenu(true, "pickmaps")); + pickmapPanel.setComponentPopupMenu(ACTION_FACTORY.createPopupMenu(true, "pickmaps")); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); CPickmapPanel.getInstance().addPickmapSelectionListener(pickmapPanel); @@ -432,7 +433,7 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - mapTileList.refresh(); + //mapTileList.refresh(); mapArchPanel.refresh(); statusBar.refresh(); @@ -659,7 +660,7 @@ * @param recents Current recents. */ public void updateRecent(final List<CMainControl.Recent> recents) { - final JMenu recentMenu = (JMenu) actionFactory.find(getJMenuBar(), "recent"); + final JMenu recentMenu = (JMenu) ACTION_FACTORY.find(getJMenuBar(), "recent"); recentMenu.removeAll(); for (final CMainControl.Recent recent : recents) { recentMenu.add(recent); @@ -668,7 +669,7 @@ /** Rebuilds the window menu. */ private void rebuildWindowMenu() { - final JMenu menuWindow = (JMenu) actionFactory.find(getJMenuBar(), "window"); + final JMenu menuWindow = (JMenu) ACTION_FACTORY.find(getJMenuBar(), "window"); menuWindow.removeAll(); menuWindow.add(aCloseAll); if (mapViews.size() != 0) { @@ -713,74 +714,74 @@ private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; private void initActions() { - actionFactory.createActions(true, mainControl, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "checkMap", "zoom", "gc", "prevWindow", "nextWindow", "onlineHelp", "tod", "about", "update"); - actionFactory.createActions(true, mainControl, directionsMap); - actionFactory.createActions(true, mainControl.getMapCursorControl(), directionsGo); - actionFactory.createActions(true, mainControl.getMapCursorControl(), "selectTile", "startStopDrag", "addToSelection", "subFromSelection", "releaseDrag"); - actionFactory.createActions(true, mainControl.getMapCursorControl(), "insertArch", "deleteArch"); - actionFactory.createActions(true, mainControl.getMapCursorControl(), "selectArchAbove", "selectArchBelow"); - actionFactory.createAction(true, "archAttributes", mainControl.getMapCursorControl()); - actionFactory.createToggles(true, mainControl, "useDouble", "gridVisible"); - actionFactory.createToggles(true, this, "lockAllPickmaps"); + ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "checkMap", "zoom", "gc", "prevWindow", "nextWindow", "onlineHelp", "tod", "about", "update"); + ACTION_FACTORY.createActions(true, mainControl, directionsMap); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), directionsGo); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectTile", "startStopDrag", "addToSelection", "subFromSelection", "releaseDrag"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "insertArch", "deleteArch"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectArchAbove", "selectArchBelow"); + ACTION_FACTORY.createAction(true, "archAttributes", mainControl.getMapCursorControl()); + ACTION_FACTORY.createToggles(true, mainControl, "useDouble", "gridVisible"); + ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); } - private final Action aClose = actionFactory.createAction(true, "close", mainControl); + private final Action aClose = ACTION_FACTORY.createAction(true, "close", mainControl); - private final Action aRevert = actionFactory.createAction(true, "revert", mainControl); + private final Action aRevert = ACTION_FACTORY.createAction(true, "revert", mainControl); - private final Action aSave = actionFactory.createAction(true, "save", mainControl); + private final Action aSave = ACTION_FACTORY.createAction(true, "save", mainControl); - private final Action aSaveAs = actionFactory.createAction(true, "saveAs", mainControl); + private final Action aSaveAs = ACTION_FACTORY.createAction(true, "saveAs", mainControl); - private final Action aCreateImg = actionFactory.createAction(true, "createImg", mainControl); + private final Action aCreateImg = ACTION_FACTORY.createAction(true, "createImg", mainControl); - private final Action aUndo = actionFactory.createAction(true, "undo", mainControl); + private final Action aUndo = ACTION_FACTORY.createAction(true, "undo", mainControl); - private final Action aRedo = actionFactory.createAction(true, "redo", mainControl); + private final Action aRedo = ACTION_FACTORY.createAction(true, "redo", mainControl); - private final Action aClear = actionFactory.createAction(true, "clear", mainControl); + private final Action aClear = ACTION_FACTORY.createAction(true, "clear", mainControl); - private final Action aCut = actionFactory.createAction(true, "cut", mainControl); + private final Action aCut = ACTION_FACTORY.createAction(true, "cut", mainControl); - private final Action aCopy = actionFactory.createAction(true, "copy", mainControl); + private final Action aCopy = ACTION_FACTORY.createAction(true, "copy", mainControl); - private final Action aPaste = actionFactory.createAction(true, "paste", mainControl); + private final Action aPaste = ACTION_FACTORY.createAction(true, "paste", mainControl); - private final Action aReplace = actionFactory.createAction(true, "replace", mainControl); + private final Action aReplace = ACTION_FACTORY.createAction(true, "replace", mainControl); - private final Action aFillAbove = actionFactory.createAction(true, "fillAbove", mainControl); + private final Action aFillAbove = ACTION_FACTORY.createAction(true, "fillAbove", mainControl); - private final Action aFillBelow = actionFactory.createAction(true, "fillBelow", mainControl); + private final Action aFillBelow = ACTION_FACTORY.createAction(true, "fillBelow", mainControl); - private final Action aRandFillAbove = actionFactory.createAction(true, "randFillAbove", mainControl); + private final Action aRandFillAbove = ACTION_FACTORY.createAction(true, "randFillAbove", mainControl); - private final Action aRandFillBelow = actionFactory.createAction(true, "randFillBelow", mainControl); + private final Action aRandFillBelow = ACTION_FACTORY.createAction(true, "randFillBelow", mainControl); - private final Action aSelectAll = actionFactory.createAction(true, "selectAll", mainControl); + private final Action aSelectAll = ACTION_FACTORY.createAction(true, "selectAll", mainControl); - private final Action aEnterExit = actionFactory.createAction(true, "enterExit", mainControl); + private final Action aEnterExit = ACTION_FACTORY.createAction(true, "enterExit", mainControl); - private final Action aMapProperties = actionFactory.createAction(true, "mapProperties", mainControl); + private final Action aMapProperties = ACTION_FACTORY.createAction(true, "mapProperties", mainControl); - private final Action aAddNewPickmap = actionFactory.createAction(true, "addNewPickmap", mainControl); + private final Action aAddNewPickmap = ACTION_FACTORY.createAction(true, "addNewPickmap", mainControl); - private final Action aClosePickmap = actionFactory.createAction(true, "closePickmap", mainControl); + private final Action aClosePickmap = ACTION_FACTORY.createAction(true, "closePickmap", mainControl); - private final Action aOpenPickmap = actionFactory.createAction(true, "openPickmapMap", mainControl); + private final Action aOpenPickmap = ACTION_FACTORY.createAction(true, "openPickmapMap", mainControl); - private final Action aSavePickmap = actionFactory.createAction(true, "savePickmap", mainControl); + private final Action aSavePickmap = ACTION_FACTORY.createAction(true, "savePickmap", mainControl); - private final Action aRevertPickmap = actionFactory.createAction(true, "revertPickmap", mainControl); + private final Action aRevertPickmap = ACTION_FACTORY.createAction(true, "revertPickmap", mainControl); - private final Action aCollectArches = actionFactory.createAction(true, "collectArches", mainControl); + private final Action aCollectArches = ACTION_FACTORY.createAction(true, "collectArches", mainControl); - private final Action aReloadFaces = actionFactory.createAction(true, "reloadFaces", mainControl); + private final Action aReloadFaces = ACTION_FACTORY.createAction(true, "reloadFaces", mainControl); - private final Action aCollectSpells = actionFactory.createAction(true, "collectSpells", mainControl); + private final Action aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", mainControl); - private final Action aViewTreasurelists = actionFactory.createAction(true, "viewTreasurelists", mainControl); + private final Action aViewTreasurelists = ACTION_FACTORY.createAction(true, "viewTreasurelists", mainControl); - private final Action aCloseAll = actionFactory.createAction(true, "closeAll", mainControl); + private final Action aCloseAll = ACTION_FACTORY.createAction(true, "closeAll", mainControl); /** * Refresh actions from toolbar. @@ -830,8 +831,8 @@ aSelectAll.setEnabled(mapState); for (int direction = 0; direction < 8; direction++) { final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; - actionFactory.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); - actionFactory.getAction(directionsGo[direction]).setEnabled(selState); + ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); + ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(selState); } aClear.setEnabled(selState); aCut.setEnabled(selState); Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-05-28 19:22:32 UTC (rev 59) @@ -24,6 +24,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectParser; import daieditor.gui.ConnectionView; @@ -84,7 +85,7 @@ private static final long serialVersionUID = 1L; /** The ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); // constants for the 'task' parameter in editScriptWanted() public static final int SCRIPT_OPEN = 0; @@ -173,20 +174,20 @@ // private JLabel archTileText = new JLabel(); private final JPanel mapArchPanel = new JPanel(); - private final Action aSubmitChange = actionFactory.createAction(false, "mapArchApply", this); + private final Action aSubmitChange = ACTION_FACTORY.createAction(false, "mapArchApply", this); - private final Action aInvChange = actionFactory.createAction(false, "mapArchAddInv", this); + private final Action aInvChange = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); - private final Action aAttrWin = actionFactory.createAction(false, "mapArchAttrib", this); + private final Action aAttrWin = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); // stuff for scripting tab - private final Action aNew = actionFactory.createAction(false, "scriptAddNew", this); + private final Action aNew = ACTION_FACTORY.createAction(false, "scriptAddNew", this); - private final Action aPath = actionFactory.createAction(false, "scriptEditData", this); + private final Action aPath = ACTION_FACTORY.createAction(false, "scriptEditData", this); - private final Action aModify = actionFactory.createAction(false, "scriptEdit", this); + private final Action aModify = ACTION_FACTORY.createAction(false, "scriptEdit", this); - private final Action aRemove = actionFactory.createAction(false, "scriptRemove", this); + private final Action aRemove = ACTION_FACTORY.createAction(false, "scriptRemove", this); private JList eventList; @@ -647,7 +648,7 @@ * @param y y position of button */ private void createButton(final int direction, final JPanel panel, final GridBagConstraints gbc, final int x, final int y) { - final JToggleButton button = new JToggleButton(actionFactory.createAction(true, "direction" + direction, this)); + final JToggleButton button = new JToggleButton(ACTION_FACTORY.createAction(true, "direction" + direction, this)); directionButtonGroup.add(button); button.setFocusable(false); button.setEnabled(false); Modified: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-05-28 19:22:32 UTC (rev 59) @@ -25,6 +25,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.arch.ArchObject; import daieditor.gui.map.MapCursorEvent; import daieditor.gui.map.MapCursorListener; @@ -60,6 +61,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:Chr...@it...">Christian Hujer</a> + * @todo turn this into a tree */ public final class CMapTileList extends JPanel implements ListSelectionListener, MouseListener, MapCursorListener { @@ -67,7 +69,7 @@ private static final long serialVersionUID = 1L; /** ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Controller of this subview. */ private final CMainControl mainControl; @@ -106,8 +108,8 @@ } else { add(arrows, BorderLayout.SOUTH); // put up/down buttons south } - arrows.add(new JButton(actionFactory.createAction(true, "moveTileUp", this))); - arrows.add(new JButton(actionFactory.createAction(true, "moveTileDown", this))); + arrows.add(new JButton(ACTION_FACTORY.createAction(true, "moveTileUp", this))); + arrows.add(new JButton(ACTION_FACTORY.createAction(true, "moveTileDown", this))); final JPanel compass = new JPanel(); compass.add(new JLabel(CGUIUtils.getSysIcon(IGUIConstants.TILE_NORTH))); @@ -363,11 +365,7 @@ return selListCounter; } - /** - * This is called when position of mapCursor changes or - * when it appeares or disappears. - * @param e Event that contains the MapCursor - */ + /** {@inheritDoc} */ public void mapCursorChangedPos(final MapCursorEvent e) { if (e.getSource().isActive()) { // Position changed @@ -378,6 +376,7 @@ } } + /** {@inheritDoc} */ public void mapCursorChangedMode(final MapCursorEvent e) { // A mode change can be ignored } Modified: trunk/daimonin/src/daieditor/CNewMapDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CNewMapDialog.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CNewMapDialog.java 2006-05-28 19:22:32 UTC (rev 59) @@ -25,6 +25,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import static daieditor.CMainControl.PREFS_USERNAME; import static daieditor.CMainControl.PREFS_USERNAME_DEFAULT; import daieditor.map.MapArchObject; @@ -63,7 +64,7 @@ private static final long serialVersionUID = 1L; /** ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Map types. */ public enum MapType { @@ -100,10 +101,10 @@ private final JFormattedTextField mapHeightField = new JFormattedTextField(); /** JButton for ok. */ - private final JButton okButton = new JButton(actionFactory.createAction(false, "mapOkay", this)); + private final JButton okButton = new JButton(ACTION_FACTORY.createAction(false, "mapOkay", this)); /** JButton for cancel. */ - private final JButton cancelButton = new JButton(actionFactory.createAction(false, "mapCancel", this)); + private final JButton cancelButton = new JButton(ACTION_FACTORY.createAction(false, "mapCancel", this)); /** * Constructs a new level dialog. Builds the dialog UI. @@ -204,7 +205,7 @@ maparch.setWidth((Integer) mapWidthField.getValue()); } catch (final IllegalArgumentException e) { final String key = e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"; - actionFactory.showMessageDialog(this, key); + ACTION_FACTORY.showMessageDialog(this, key); mapWidthField.requestFocus(); return false; } @@ -214,7 +215,7 @@ maparch.setHeight((Integer) mapHeightField.getValue()); } catch (final IllegalArgumentException e) { final String key = e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"; - actionFactory.showMessageDialog(this, key); + ACTION_FACTORY.showMessageDialog(this, key); mapHeightField.requestFocus(); return false; } @@ -222,7 +223,7 @@ // the mapmaker must enter a mapname to create a new map final String mapName = mapNameField.getText(); if (mapType == MapType.GAMEMAP && (mapName == null || mapName.length() <= 0)) { - actionFactory.showMessageDialog(this, "newMapNoName"); + ACTION_FACTORY.showMessageDialog(this, "newMapNoName"); mapNameField.requestFocus(); return false; } @@ -268,7 +269,7 @@ */ public static void showNewMapDialog(final CMainControl mainControl, final Component parentComponent, final String filename, final MapType mapType) { final CNewMapDialog pane = new CNewMapDialog(mainControl, filename, mapType); - final JDialog dialog = pane.createDialog(parentComponent, actionFactory.getString(mapType == MapType.PICKMAP ? "newPickmap.title" : "newMap.title")); + final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.getString(mapType == MapType.PICKMAP ? "newPickmap.title" : "newMap.title")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setModal(false); Modified: trunk/daimonin/src/daieditor/CPickmapPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-05-28 19:22:32 UTC (rev 59) @@ -24,6 +24,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectParser; import daieditor.map.MapArchObject; @@ -46,7 +47,7 @@ public final class CPickmapPanel { /** ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** static instance of this class */ private static CPickmapPanel instance; @@ -186,7 +187,7 @@ final File mapFile = new File(new File(CMainControl.getInstance().getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), maparch.getFileName()); if (mapFile.exists()) { - actionFactory.showMessageDialog(tabpane, "pickmapExists", mapFile); + ACTION_FACTORY.showMessageDialog(tabpane, "pickmapExists", mapFile); return false; } if (!mapFile.getParentFile().exists()) { Modified: trunk/daimonin/src/daieditor/CPreview.java =================================================================== --- trunk/daimonin/src/daieditor/CPreview.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/CPreview.java 2006-05-28 19:22:32 UTC (rev 59) @@ -26,6 +26,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; @@ -60,7 +61,7 @@ private static final long serialVersionUID = 1L; /** Action Factory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Original image. */ private final Image original; @@ -101,7 +102,7 @@ //if (icon != null) { // frame.setIconImage(icon.getImage()); //} - frame.setJMenuBar(actionFactory.createMenuBar(false, "zoomBar", this)); + frame.setJMenuBar(ACTION_FACTORY.createMenuBar(false, "zoomBar", this)); final JScrollPane scroll = new JScrollPane(this); scroll.setFocusable(true); frame.add(scroll); @@ -199,7 +200,7 @@ chooser.setFileFilter(CMainControl.pngFileFilter); if (chooser.showSaveDialog(frame) == JFileChooser.APPROVE_OPTION) { final File file = chooser.getSelectedFile(); - if (!file.exists() || actionFactory.showQuestionDialog(this, "overwriteOtherFile", file)) { + if (!file.exists() || ACTION_FACTORY.showQuestionDialog(this, "overwriteOtherFile", file)) { try { final RenderedImage img; if (image instanceof RenderedImage) { @@ -211,9 +212,9 @@ } ImageIO.write(img, "png", file); } catch (final Exception e) { - actionFactory.showMessageDialog(this, "zoomSaveException", e); + ACTION_FACTORY.showMessageDialog(this, "zoomSaveException", e); } catch (final OutOfMemoryError e) { - actionFactory.showMessageDialog(this, "zoomSaveOutOfMem"); + ACTION_FACTORY.showMessageDialog(this, "zoomSaveOutOfMem"); } } } @@ -304,7 +305,7 @@ image = null; image = original.getScaledInstance(width, height, algorithm); } catch (final OutOfMemoryError e) { - actionFactory.showMessageDialog(this, "zoomOutOfMem"); + ACTION_FACTORY.showMessageDialog(this, "zoomOutOfMem"); image = original; width = image.getWidth(this); height = image.getHeight(this); Modified: trunk/daimonin/src/daieditor/MapTilePane.java =================================================================== --- trunk/daimonin/src/daieditor/MapTilePane.java 2006-05-28 16:15:18 UTC (rev 58) +++ trunk/daimonin/src/daieditor/MapTilePane.java 2006-05-28 19:22:32 UTC (rev 59) @@ -23,6 +23,7 @@ package daieditor; +import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.gui.DirectionLayout; import daieditor.map.MapArchObject; import daieditor.map.MapControl; @@ -70,7 +71,7 @@ private static final long serialVersionUID = 1L; /** ActionFactory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("daieditor"); + private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** The mainControl to use. */ private final CMainControl mainControl; @@ -83,14 +84,14 @@ /** The tile link names for the labels / borders. */ private static final String[] tile_link_name = { - actionFactory.getString("mapNorth"), - actionFactory.getString("mapEast"), - actionFactory.getString("mapSouth"), - action... [truncated message content] |
From: <chr...@us...> - 2006-05-28 22:05:22
|
Revision: 65 Author: christianhujer Date: 2006-05-28 15:05:07 -0700 (Sun, 28 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=65&view=rev Log Message: ----------- Unified preferences classes: removal of unused serialVersionUID (@serial exclude), renamed prefs to PREFS. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java trunk/daimonin/src/daieditor/gui/prefs/DevPrefs.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/daimonin/src/daieditor/gui/prefs/MapValidatorPrefs.java trunk/daimonin/src/daieditor/gui/prefs/MiscPrefs.java trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-05-28 22:05:07 UTC (rev 65) @@ -1511,7 +1511,7 @@ new ResPrefs(this), new AppPrefs(), new NetPrefs(), - new GUIPrefs(this), + new GUIPrefs(), new MiscPrefs(), new DevPrefs(), new UpdatePrefs(), Modified: trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -56,14 +56,11 @@ */ public final class AppPrefs extends AbstractPrefs { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Action Facotry. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); /** TextField for server executable. */ private JTextField serverField; @@ -94,16 +91,16 @@ /** {@inheritDoc} */ public void apply() { - prefs.put(PREFS_APP_SERVER, path(serverField.getText())); - prefs.put(PREFS_APP_CLIENT, path(clientField.getText())); - prefs.put(PREFS_APP_EDITOR, path(editorField.getText())); + PREFS.put(PREFS_APP_SERVER, path(serverField.getText())); + PREFS.put(PREFS_APP_CLIENT, path(clientField.getText())); + PREFS.put(PREFS_APP_EDITOR, path(editorField.getText())); } /** {@inheritDoc} */ public void revert() { - serverField.setText(prefs.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT)); - clientField.setText(prefs.get(PREFS_APP_CLIENT, PREFS_APP_CLIENT_DEFAULT)); - editorField.setText(prefs.get(PREFS_APP_EDITOR, PREFS_APP_EDITOR_DEFAULT)); + serverField.setText(PREFS.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT)); + clientField.setText(PREFS.get(PREFS_APP_CLIENT, PREFS_APP_CLIENT_DEFAULT)); + editorField.setText(PREFS.get(PREFS_APP_EDITOR, PREFS_APP_EDITOR_DEFAULT)); } /** {@inheritDoc} */ @@ -116,9 +113,9 @@ /** {@inheritDoc} */ public boolean isChanged() { return !( - serverField.getText().equals(prefs.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT)) - && clientField.getText().equals(prefs.get(PREFS_APP_CLIENT, PREFS_APP_CLIENT_DEFAULT)) - && editorField.getText().equals(prefs.get(PREFS_APP_EDITOR, PREFS_APP_EDITOR_DEFAULT)) + serverField.getText().equals(PREFS.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT)) + && clientField.getText().equals(PREFS.get(PREFS_APP_CLIENT, PREFS_APP_CLIENT_DEFAULT)) + && editorField.getText().equals(PREFS.get(PREFS_APP_EDITOR, PREFS_APP_EDITOR_DEFAULT)) ); } @@ -130,9 +127,9 @@ final Box appPanel = createVerticalBox(); appPanel.setBorder(createTitledBorder("optionsApps")); - serverField = createFileField(appPanel, "optionsAppServer", prefs.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT), FILES_ONLY); - clientField = createFileField(appPanel, "optionsAppClient", prefs.get(PREFS_APP_CLIENT, PREFS_APP_CLIENT_DEFAULT), FILES_ONLY); - editorField = createFileField(appPanel, "optionsAppEditor", prefs.get(PREFS_APP_EDITOR, PREFS_APP_EDITOR_DEFAULT), FILES_ONLY); + serverField = createFileField(appPanel, "optionsAppServer", PREFS.get(PREFS_APP_SERVER, PREFS_APP_SERVER_DEFAULT), FILES_ONLY); + clientField = createFileField(appPanel, "optionsAppClient", PREFS.get(PREFS_APP_CLIENT, PREFS_APP_CLIENT_DEFAULT), FILES_ONLY); + editorField = createFileField(appPanel, "optionsAppEditor", PREFS.get(PREFS_APP_EDITOR, PREFS_APP_EDITOR_DEFAULT), FILES_ONLY); return appPanel; } Modified: trunk/daimonin/src/daieditor/gui/prefs/DevPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/DevPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/DevPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -46,14 +46,11 @@ */ public final class DevPrefs extends AbstractPrefs { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Action Facotry. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); /** Use Systme.exit() for exiting the program. */ private JCheckBox systemExit; @@ -78,12 +75,12 @@ /** {@inheritDoc} */ public void apply() { - prefs.putBoolean(PREFS_SYSTEM_EXIT, systemExit.isSelected()); + PREFS.putBoolean(PREFS_SYSTEM_EXIT, systemExit.isSelected()); } /** {@inheritDoc} */ public void revert() { - systemExit.setSelected(prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)); + systemExit.setSelected(PREFS.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)); } /** {@inheritDoc} */ @@ -94,7 +91,7 @@ /** {@inheritDoc} */ public boolean isChanged() { return !( - systemExit.isSelected() == prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT) + systemExit.isSelected() == PREFS.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT) ); } @@ -107,7 +104,7 @@ miscPanel.setBorder(createTitledBorder("optionsMisc")); systemExit = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSystemExit")); - systemExit.setSelected(prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)); + systemExit.setSelected(PREFS.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)); miscPanel.add(systemExit); return miscPanel; } Modified: trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -55,9 +55,6 @@ */ public final class GUIPrefs extends AbstractPrefs { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Action Facotry. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); @@ -78,9 +75,8 @@ /** * Create a GUIPrefs pane. - * @param mainControl The controller of this dialog. */ - public GUIPrefs(final CMainControl mainControl) { + public GUIPrefs() { setListLabelText(ACTION_FACTORY.getString("prefsGUI.title")); setListLabelIcon(ACTION_FACTORY.getIcon("prefsGUI.icon")); Modified: trunk/daimonin/src/daieditor/gui/prefs/MapValidatorPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/MapValidatorPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/MapValidatorPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -54,7 +54,7 @@ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); /** The delegating validator that contains all the validators. */ private final DelegatingMapValidator validators; @@ -70,7 +70,7 @@ * @param mapValidators the delegating map validator that contains all the validators */ public MapValidatorPrefs(final DelegatingMapValidator mapValidators) { - this.validators = mapValidators; + validators = mapValidators; setListLabelText(ACTION_FACTORY.getString("prefsMapValidator.title")); setListLabelIcon(ACTION_FACTORY.getIcon("prefsMapValidator.icon")); @@ -93,7 +93,7 @@ for (final Map.Entry<Validator, JCheckBox> entry : checkBoxes.entrySet()) { entry.getKey().setEnabled(entry.getValue().isSelected()); } - prefs.putBoolean(PREFS_VALIDATOR_AUTO, autoValidate.isSelected()); + PREFS.putBoolean(PREFS_VALIDATOR_AUTO, autoValidate.isSelected()); } /** {@inheritDoc} */ @@ -101,7 +101,7 @@ for (final Map.Entry<Validator, JCheckBox> entry : checkBoxes.entrySet()) { entry.getValue().setSelected(entry.getKey().isEnabled()); } - autoValidate.setSelected(prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)); + autoValidate.setSelected(PREFS.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)); } /** {@inheritDoc} */ @@ -119,7 +119,7 @@ return true; } } - return autoValidate.isSelected() != prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT); + return autoValidate.isSelected() != PREFS.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT); } /** @@ -129,7 +129,7 @@ private Component createValidationPanel() { final Box panel = createVerticalBox(); panel.setBorder(createTitledBorder("optionsValidation")); - autoValidate = new JCheckBox(ACTION_FACTORY.getString("autoValidate.text"), prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)); + autoValidate = new JCheckBox(ACTION_FACTORY.getString("autoValidate.text"), PREFS.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)); panel.add(autoValidate); return panel; } Modified: trunk/daimonin/src/daieditor/gui/prefs/MiscPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/MiscPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/MiscPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -48,14 +48,11 @@ */ public final class MiscPrefs extends AbstractPrefs { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Action Facotry. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); /** TextField for user / artist name. */ private JTextField userField; @@ -84,13 +81,13 @@ /** {@inheritDoc} */ public void apply() { - prefs.put(PREFS_USERNAME, userField.getText()); + PREFS.put(PREFS_USERNAME, userField.getText()); MapFileFilter.setPerformingRealChecks(checkMaps.isSelected()); } /** {@inheritDoc} */ public void revert() { - userField.setText(prefs.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT)); + userField.setText(PREFS.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT)); checkMaps.setSelected(MapFileFilter.isPerformingRealChecks()); } @@ -103,7 +100,7 @@ /** {@inheritDoc} */ public boolean isChanged() { return !( - userField.getText().equals(prefs.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT)) + userField.getText().equals(PREFS.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT)) && checkMaps.isSelected() == MapFileFilter.isPerformingRealChecks() ); } @@ -115,7 +112,7 @@ private Component createUserPanel() { final Box userPanel = createVerticalBox(); userPanel.setBorder(createTitledBorder("optionsUser")); - userField = new JTextField(prefs.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT)); + userField = new JTextField(PREFS.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT)); userPanel.add(userField); return userPanel; } Modified: trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -53,9 +53,6 @@ */ public class NetPrefs extends AbstractPrefs implements ItemListener { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** The preferences key for the type. */ private static final String NET_PREFS_KEY_TYPE = "daieditor.proxy.type"; @@ -69,16 +66,16 @@ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); /** JComboBox for selecting the proxy type. */ private JComboBox proxyType = createProxyType(); /** TextField for server executable. */ - private JTextField proxyHost = new JTextField(prefs.get(NET_PREFS_KEY_HOST, "")); + private JTextField proxyHost = new JTextField(PREFS.get(NET_PREFS_KEY_HOST, "")); /** TextField for client executable. */ - private JSpinner proxyPort = new JSpinner(new SpinnerNumberModel(prefs.getInt(NET_PREFS_KEY_PORT, 3128), 1, 65535, 1)); + private JSpinner proxyPort = new JSpinner(new SpinnerNumberModel(PREFS.getInt(NET_PREFS_KEY_PORT, 3128), 1, 65535, 1)); /** Create a NetPrefs pane. */ public NetPrefs() { @@ -103,37 +100,37 @@ /** {@inheritDoc} */ public boolean isChanged() { return !( - (Proxy.Type) proxyType.getSelectedItem() == Proxy.Type.valueOf(prefs.get(NET_PREFS_KEY_TYPE, "DIRECT")) - && prefs.get(NET_PREFS_KEY_HOST, "").equals(proxyHost.getText()) - && prefs.getInt(NET_PREFS_KEY_PORT, 3128) == (Integer) proxyPort.getValue() + (Proxy.Type) proxyType.getSelectedItem() == Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")) + && PREFS.get(NET_PREFS_KEY_HOST, "").equals(proxyHost.getText()) + && PREFS.getInt(NET_PREFS_KEY_PORT, 3128) == (Integer) proxyPort.getValue() ); } /** {@inheritDoc} */ public void defaults() { - prefs.remove(NET_PREFS_KEY_TYPE); - prefs.remove(NET_PREFS_KEY_HOST); - prefs.remove(NET_PREFS_KEY_PORT); + PREFS.remove(NET_PREFS_KEY_TYPE); + PREFS.remove(NET_PREFS_KEY_HOST); + PREFS.remove(NET_PREFS_KEY_PORT); revert(); } /** {@inheritDoc} */ public void revert() { - final Proxy.Type proxyType = Proxy.Type.valueOf(prefs.get(NET_PREFS_KEY_TYPE, "DIRECT")); + final Proxy.Type proxyType = Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")); this.proxyType.setSelectedIndex(proxyType.ordinal()); final boolean enableProxy = proxyType != DIRECT; proxyHost.setEnabled(enableProxy); proxyPort.setEnabled(enableProxy); - proxyHost.setText(prefs.get(NET_PREFS_KEY_HOST, "")); - proxyPort.setValue(prefs.getInt(NET_PREFS_KEY_PORT, 3128)); + proxyHost.setText(PREFS.get(NET_PREFS_KEY_HOST, "")); + proxyPort.setValue(PREFS.getInt(NET_PREFS_KEY_PORT, 3128)); } /** {@inheritDoc} */ public void apply() { - prefs.put(NET_PREFS_KEY_TYPE, ((Enum<Proxy.Type>) proxyType.getSelectedItem()).name()); - prefs.put(NET_PREFS_KEY_HOST, proxyHost.getText()); - prefs.putInt(NET_PREFS_KEY_PORT, (Integer) proxyPort.getValue()); + PREFS.put(NET_PREFS_KEY_TYPE, ((Enum<Proxy.Type>) proxyType.getSelectedItem()).name()); + PREFS.put(NET_PREFS_KEY_HOST, proxyHost.getText()); + PREFS.putInt(NET_PREFS_KEY_PORT, (Integer) proxyPort.getValue()); } /** @@ -153,7 +150,7 @@ * Create the JComboBox for selecting the proxy type. * @return JComboBox for selecting the proxy type */ - private JComboBox createProxyType() { + private static JComboBox createProxyType() { final JComboBox proxyType = new JComboBox(EnumSet.allOf(Proxy.Type.class).toArray()); return proxyType; } @@ -163,11 +160,11 @@ * @return currently preferred proxy */ public static Proxy getProxy() { - final Proxy.Type proxyType = Proxy.Type.valueOf(prefs.get(NET_PREFS_KEY_TYPE, "DIRECT")); + final Proxy.Type proxyType = Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")); if (proxyType == DIRECT) { return NO_PROXY; } - return new Proxy(proxyType, new InetSocketAddress(prefs.get(NET_PREFS_KEY_HOST, "proxy"), prefs.getInt(NET_PREFS_KEY_PORT, 3128))); + return new Proxy(proxyType, new InetSocketAddress(PREFS.get(NET_PREFS_KEY_HOST, "proxy"), PREFS.getInt(NET_PREFS_KEY_PORT, 3128))); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -53,9 +53,6 @@ */ public final class ResPrefs extends AbstractPrefs { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Action Facotry. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); Modified: trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2006-05-28 22:04:50 UTC (rev 64) +++ trunk/daimonin/src/daieditor/gui/prefs/UpdatePrefs.java 2006-05-28 22:05:07 UTC (rev 65) @@ -46,14 +46,11 @@ */ public final class UpdatePrefs extends AbstractPrefs { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Action Facotry. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Preferences. */ - private static final Preferences prefs = userNodeForPackage(CMainControl.class); + private static final Preferences PREFS = userNodeForPackage(CMainControl.class); /** Checkbox whether to automatically check for updates on startup. */ private JCheckBox autoUpdate; @@ -81,14 +78,14 @@ /** {@inheritDoc} */ public void apply() { - prefs.putBoolean(Updater.AUTO_CHECK_KEY, autoUpdate.isSelected()); - prefs.putInt(Updater.INTERVAL_KEY, interval.getSelectedIndex()); + PREFS.putBoolean(Updater.AUTO_CHECK_KEY, autoUpdate.isSelected()); + PREFS.putInt(Updater.INTERVAL_KEY, interval.getSelectedIndex()); } /** {@inheritDoc} */ public void revert() { - autoUpdate.setSelected(prefs.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); - interval.setSelectedIndex(prefs.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT)); + autoUpdate.setSelected(PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); + interval.setSelectedIndex(PREFS.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT)); } /** {@inheritDoc} */ @@ -100,8 +97,8 @@ /** {@inheritDoc} */ public boolean isChanged() { return !( - autoUpdate.isSelected() == prefs.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT) - && interval.getSelectedIndex() == prefs.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT) + autoUpdate.isSelected() == PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT) + && interval.getSelectedIndex() == PREFS.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT) ); } @@ -113,7 +110,7 @@ final Box updatePanel = createVerticalBox(); updatePanel.setBorder(createTitledBorder("optionsUpdate")); autoUpdate = new JCheckBox(ACTION_FACTORY.createToggle(false, "autoUpdate", this)); - autoUpdate.setSelected(prefs.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); + autoUpdate.setSelected(PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); updatePanel.add(autoUpdate); updatePanel.add(createComboBox()); return updatePanel; @@ -148,8 +145,8 @@ }; interval = new JComboBox(items); interval.setEditable(false); - interval.setSelectedIndex(prefs.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT)); - interval.setEnabled(prefs.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); + interval.setSelectedIndex(PREFS.getInt(Updater.INTERVAL_KEY, Updater.INTERVAL_DEFAULT)); + interval.setEnabled(PREFS.getBoolean(Updater.AUTO_CHECK_KEY, Updater.AUTO_CHECK_DEFAULT)); return interval; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-06-02 20:34:38
|
Revision: 109 Author: christianhujer Date: 2006-06-02 13:34:17 -0700 (Fri, 02 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=109&view=rev Log Message: ----------- Unified C/DSplitPane into Gridarta. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanel.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapArchPanel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/DSplitPane.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/DSplitPane.java trunk/daimonin/src/daieditor/swing/DSplitPane.java Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-06-02 20:24:44 UTC (rev 108) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-06-02 20:34:17 UTC (rev 109) @@ -37,6 +37,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.jetbrains.annotations.Nullable; +import net.sf.gridarta.gui.DSplitPane; /** * The <code>CArchPanel</code> holds the tile palette. Deleted: trunk/crossfire/src/cfeditor/DSplitPane.java =================================================================== --- trunk/crossfire/src/cfeditor/DSplitPane.java 2006-06-02 20:24:44 UTC (rev 108) +++ trunk/crossfire/src/cfeditor/DSplitPane.java 2006-06-02 20:34:17 UTC (rev 109) @@ -1,38 +0,0 @@ -package cfeditor; - -import java.awt.Component; -import javax.swing.JSplitPane; - -/** - * Splitpane subclass that keeps its size even upon L'n'F change. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DSplitPane extends JSplitPane { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** - * Create a new DSplitPane. - * @param newOrientation {@link JSplitPane#HORIZONTAL_SPLIT} or {@link JSplitPane.VERTICAL_SPLIT}. - * @param newLeftComponent the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane - * @param newRightComponent the Component that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane - */ - public DSplitPane(final int newOrientation, final Component newLeftComponent, final Component newRightComponent) { - super(newOrientation, newLeftComponent, newRightComponent); - setOneTouchExpandable(true); - } - - /** {@inheritDoc} */ - // Overridden to store and restore the divider location upon UI change. - @Override public void updateUI() { - final int dividerLocationBackup = getDividerLocation(); - final int dividerSizeBackup = getDividerSize(); - super.updateUI(); - setDividerLocation(dividerLocationBackup); - setDividerSize(dividerSizeBackup); - } - -} // class DSplitPane Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-06-02 20:24:44 UTC (rev 108) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-06-02 20:34:17 UTC (rev 109) @@ -31,7 +31,7 @@ import daieditor.map.MapControl; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; -import daieditor.swing.DSplitPane; +import net.sf.gridarta.gui.DSplitPane; import java.awt.BorderLayout; import java.awt.Point; import java.awt.Rectangle; Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-06-02 20:24:44 UTC (rev 108) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-06-02 20:34:17 UTC (rev 109) @@ -24,14 +24,12 @@ package daieditor; -import static net.sf.japi.swing.ActionFactory.getFactory; import daieditor.arch.ArchObject; import daieditor.arch.ArchObjectParser; import daieditor.gui.ConnectionView; import daieditor.gui.ErrorListView; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; -import daieditor.swing.DSplitPane; import java.awt.BorderLayout; import static java.awt.Color.black; import static java.awt.Color.blue; @@ -70,7 +68,9 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.gui.DSplitPane; import net.sf.japi.swing.ActionFactory; +import static net.sf.japi.swing.ActionFactory.getFactory; /** * <code>CMapArchPanel</code> implements the panel that holds information Deleted: trunk/daimonin/src/daieditor/swing/DSplitPane.java =================================================================== --- trunk/daimonin/src/daieditor/swing/DSplitPane.java 2006-06-02 20:24:44 UTC (rev 108) +++ trunk/daimonin/src/daieditor/swing/DSplitPane.java 2006-06-02 20:34:17 UTC (rev 109) @@ -1,63 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 Christian Hujer - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.swing; - -import java.awt.Component; -import javax.swing.JSplitPane; - -/** - * Splitpane subclass that keeps its size even upon L'n'F change. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DSplitPane extends JSplitPane { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** - * Create a new DSplitPane. - * @param newOrientation {@link JSplitPane#HORIZONTAL_SPLIT} or {@link JSplitPane.VERTICAL_SPLIT}. - * @param newLeftComponent the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane - * @param newRightComponent the Component that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane - */ - public DSplitPane(final int newOrientation, final Component newLeftComponent, final Component newRightComponent) { - super(newOrientation, newLeftComponent, newRightComponent); - setOneTouchExpandable(true); - } - - /** {@inheritDoc} */ - // Overridden to store and restore the divider location upon UI change. - @Override public void updateUI() { - final int dividerLocationBackup = getDividerLocation(); - final int dividerSizeBackup = getDividerSize(); - super.updateUI(); - setDividerLocation(dividerLocationBackup); - setDividerSize(dividerSizeBackup); - } - -} // class DSplitPane Copied: trunk/src/app/net/sf/gridarta/gui/DSplitPane.java (from rev 108, trunk/daimonin/src/daieditor/swing/DSplitPane.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/DSplitPane.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/DSplitPane.java 2006-06-02 20:34:17 UTC (rev 109) @@ -0,0 +1,64 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package net.sf.gridarta.gui; + +import java.awt.Component; +import javax.swing.JSplitPane; + +/** + * Splitpane subclass that keeps its size even upon L'n'F change. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DSplitPane extends JSplitPane { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** + * Create a new DSplitPane. + * @param newOrientation {@link JSplitPane#HORIZONTAL_SPLIT} or {@link JSplitPane.VERTICAL_SPLIT}. + * @param newLeftComponent the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane + * @param newRightComponent the Component that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane + */ + public DSplitPane(final int newOrientation, final Component newLeftComponent, final Component newRightComponent) { + super(newOrientation, newLeftComponent, newRightComponent); + setOneTouchExpandable(true); + } + + /** {@inheritDoc} */ + // Overridden to store and restore the divider location upon UI change. + @Override public void updateUI() { + final int dividerLocationBackup = getDividerLocation(); + final int dividerSizeBackup = getDividerSize(); + super.updateUI(); + setDividerLocation(dividerLocationBackup); + setDividerSize(dividerSizeBackup); + } + +} // class DSplitPane This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-06-08 21:25:08
|
Revision: 140 Author: akirschbaum Date: 2006-06-08 14:24:32 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=140&view=rev Log Message: ----------- Add final modifier where possible. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapControl.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/crossfire/src/cfeditor/CMapModel.java trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CMapTileList.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-06-08 21:24:32 UTC (rev 140) @@ -55,7 +55,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CMainView extends JFrame implements InternalFrameListener { +public final class CMainView extends JFrame implements InternalFrameListener { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -141,7 +141,7 @@ super(IGUIConstants.APP_NAME + " - " + IGUIConstants.APP_WINDOW_TITLE); this.mainControl = mainControl; - ImageIcon icon = CGUIUtils.getIcon(IGUIConstants.APP_ICON); + final ImageIcon icon = CGUIUtils.getIcon(IGUIConstants.APP_ICON); if (icon != null) { setIconImage(icon.getImage()); } @@ -149,7 +149,7 @@ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { - @Override public void windowClosing(WindowEvent event) { + @Override public void windowClosing(final WindowEvent event) { mainControl.exitWanted(); } }); @@ -158,28 +158,28 @@ /** * Initialises (builds) this view. */ - void init(boolean doShow) { - CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); + void init(final boolean doShow) { + final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); // set look and feel - String strSelectedLNFName = settings.getProperty(CMainView.SELECTED_LNF_KEY, UIManager.getCrossPlatformLookAndFeelClassName()); + final String strSelectedLNFName = settings.getProperty(CMainView.SELECTED_LNF_KEY, UIManager.getCrossPlatformLookAndFeelClassName()); mainControl.setLookNFeel(strSelectedLNFName); // calculate some default values in case there is no settings file - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - int defwidth = (int) (0.9 * screen.getWidth()); - int defheight = (int) (0.9 * screen.getHeight()); + final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + final int defwidth = (int) (0.9 * screen.getWidth()); + final int defheight = (int) (0.9 * screen.getHeight()); // define divider locations - int divLocationRight = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY3, "" + (int) (defwidth * 0.62))); - int divLocationDown = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY2, "" + (int) (defheight * 0.76))); - int divLocation = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY, "" + (int) (defwidth * 0.17))); + final int divLocationRight = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY3, "" + (int) (defwidth * 0.62))); + final int divLocationDown = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY2, "" + (int) (defheight * 0.76))); + final int divLocation = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY, "" + (int) (defwidth * 0.17))); // get the old location and size - int x = Integer.parseInt(settings.getProperty(WINDOW_X, "" + (int) ((screen.getWidth() - defwidth) / 2.))); - int y = Integer.parseInt(settings.getProperty(WINDOW_Y, "" + (int) ((screen.getHeight() - defheight) / 2.))); - int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, "" + defwidth)); - int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, "" + defheight)); + final int x = Integer.parseInt(settings.getProperty(WINDOW_X, "" + (int) ((screen.getWidth() - defwidth) / 2.))); + final int y = Integer.parseInt(settings.getProperty(WINDOW_Y, "" + (int) ((screen.getHeight() - defheight) / 2.))); + final int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, "" + defwidth)); + final int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, "" + defheight)); // Add all the subviews getContentPane().setLayout(new BorderLayout()); @@ -266,7 +266,7 @@ new Help(this, null).setVisible(true); } - public void setPickmapActive(boolean state) { + public void setPickmapActive(final boolean state) { pickmapActive = state; menu.setActivePickmapsEnabled(state); } @@ -298,7 +298,7 @@ && CPickmapPanel.getInstance().isLoadComplete() && CPickmapPanel.getInstance().getCurrentPickmap() != null) { // get the active pickmap - CMapControl pmap = CPickmapPanel.getInstance().getCurrentPickmap(); + final CMapControl pmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (pmap != null && pmap.getMapView().isHighlight()) { // now try to get the topmost object @@ -318,7 +318,7 @@ return archPanel.getArchPanelSelection(); } - public void showArchPanelQuickObject(ArchObject arch) { + public void showArchPanelQuickObject(final ArchObject arch) { archPanel.showArchPanelQuickObject(arch); } @@ -328,7 +328,7 @@ } // show a arch in the arch map panel - public void setMapArchPanelObject(ArchObject arch) { + public void setMapArchPanelObject(final ArchObject arch) { mapArchPanel.setMapArchPanelObject(arch); } @@ -338,7 +338,7 @@ } // access mape tile list ... - public void setMapTileList(CMapControl map, int archid) { + public void setMapTileList(final CMapControl map, final int archid) { mapTileList.setMapTileList(map, archid); } @@ -350,7 +350,7 @@ return mapTileList.getMapTileSelection(); } - public void addArchPanel(String name) { + public void addArchPanel(final String name) { archPanel.addPanel(name); } @@ -363,11 +363,11 @@ archPanel.enableTabPane(); } - public int addArchPanelCombo(String name) { + public int addArchPanelCombo(final String name) { return archPanel.addArchPanelCombo(name); } - public void addArchPanelArch(int archnr, int index) { + public void addArchPanelArch(final int archnr, final int index) { archPanel.addArchPanelArch(archnr, index); } @@ -376,7 +376,7 @@ return archPanel.getPanelArch(); } - public void setStatusText(String string) { + public void setStatusText(final String string) { statusBar.setStatusText(string); } @@ -386,7 +386,7 @@ } // is the map tile list in the bottom panel - public void setMapTileListBottom(boolean state) { + public void setMapTileListBottom(final boolean state) { mapTileListBottom = state; } @@ -394,8 +394,8 @@ void appExitNotify() { // Store the location and size - CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - Rectangle bounds = getBounds(); + final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); + final Rectangle bounds = getBounds(); settings.setProperty(WINDOW_X, "" + bounds.x); settings.setProperty(WINDOW_Y, "" + bounds.y); settings.setProperty(WINDOW_WIDTH, "" + bounds.width); @@ -449,7 +449,7 @@ archPanel.updateFont(); } - void setRevertMenuEnabled(boolean state) { + void setRevertMenuEnabled(final boolean state) { menu.setRevertEnabled(state); } @@ -489,7 +489,7 @@ * Adds the level view. * @param mapView the map view to add */ - public void addLevelView(CMapViewIFrame mapView) { + public void addLevelView(final CMapViewIFrame mapView) { mapViews.add(mapView); mapView.addInternalFrameListener(this); mapDesktop.add(mapView); @@ -509,7 +509,7 @@ * Removes (closes) the level view. * @param mapView the map view to be removed (closed). */ - void removeLevelView(CMapViewIFrame mapView) { + void removeLevelView(final CMapViewIFrame mapView) { if (!mapViews.contains(mapView)) { return; } @@ -539,7 +539,7 @@ * Shows the given error in the UI. * @param error The error to be shown. */ - void showError(GridderException error) { + void showError(final GridderException error) { JOptionPane.showConfirmDialog(this, error.getMessage(), IGUIConstants.APP_NAME, JOptionPane.OK_OPTION, JOptionPane.WARNING_MESSAGE); } @@ -549,11 +549,11 @@ * @param strMessage The message to be shown. * @param messageType Type of message (see JOptionPane constants), defines icon used */ - public void showMessage(String strTitle, String strMessage, int messageType) { + public void showMessage(final String strTitle, final String strMessage, final int messageType) { JOptionPane.showMessageDialog(this, strMessage, strTitle, messageType); } - public void showMessage(String strTitle, String strMessage) { + public void showMessage(final String strTitle, final String strMessage) { JOptionPane.showMessageDialog(this, strMessage, strTitle, JOptionPane.INFORMATION_MESSAGE); } @@ -564,7 +564,7 @@ * @param strMessage The message to be shown. * @return Ture if the user agrees, false if user disagrees. */ - public boolean askConfirm(String strTitle, String strMessage) { + public boolean askConfirm(final String strTitle, final String strMessage) { return JOptionPane.showConfirmDialog(this, strMessage, strTitle, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION; } @@ -573,11 +573,11 @@ * @param fCareAboutIconification True if the focus update should ignore * all windows iconified by the user. */ - void updateFocus(boolean fCareAboutIconification) { + void updateFocus(final boolean fCareAboutIconification) { // Show the next level (if such exists) for (Enumeration enu = mapViews.elements(); enu.hasMoreElements();) { - CMapViewIFrame view = (CMapViewIFrame) enu.nextElement(); + final CMapViewIFrame view = (CMapViewIFrame) enu.nextElement(); if (view.isIcon()) { if (!fCareAboutIconification) { @@ -587,7 +587,7 @@ view.moveToFront(); view.show(); return; - } catch (PropertyVetoException cantUniconify) { + } catch (final PropertyVetoException cantUniconify) { } } } else { @@ -606,7 +606,7 @@ public void previousWindowWanted() { if (mapViews.size() > 1) { - Object view = mapViews.firstElement(); + final Object view = mapViews.firstElement(); mapViews.removeElement(view); mapViews.addElement(view); } @@ -617,7 +617,7 @@ public void nextWindowWanted() { if (mapViews.size() > 1) { - Object view = mapViews.lastElement(); + final Object view = mapViews.lastElement(); mapViews.removeElement(view); mapViews.insertElementAt(view, 0); } @@ -629,7 +629,7 @@ * Sets the given level view as the current one. * @param view The new current level view. */ - public void setCurrentLevelView(CMapViewIFrame view) { + public void setCurrentLevelView(final CMapViewIFrame view) { mapViews.removeElement(view); mapViews.insertElementAt(view, 0); @@ -639,7 +639,7 @@ view.setIcon(false); view.show(); return; - } catch (PropertyVetoException cantUniconify) { + } catch (final PropertyVetoException cantUniconify) { } } updateFocus(true); @@ -651,7 +651,7 @@ * @param view The level view who lost the focus. */ - public void levelViewFocusLostNotify(CMapViewIFrame view) { + public void levelViewFocusLostNotify(final CMapViewIFrame view) { if (mapViews.size() > 1) { mapViews.removeElement(view); mapViews.addElement(view); @@ -664,10 +664,10 @@ * @param view The new current level view. */ - public void levelViewFocusGainedNotify(CMapViewIFrame view) { + public void levelViewFocusGainedNotify(final CMapViewIFrame view) { mapViews.removeElement(view); mapViews.insertElementAt(view, 0); - CMapControl level = view.getLevel(); + final CMapControl level = view.getLevel(); mainControl.setCurrentLevel(level); //statusBar.setLevelInfo(level); @@ -677,16 +677,16 @@ * Invoked when the internal frame view is opened. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameOpened(InternalFrameEvent event) { + public void internalFrameOpened(final InternalFrameEvent event) { } /** * Invoked when the internal frame view is closing. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameClosing(InternalFrameEvent event) { + public void internalFrameClosing(final InternalFrameEvent event) { - CMapViewIFrame view = (CMapViewIFrame) event.getSource(); + final CMapViewIFrame view = (CMapViewIFrame) event.getSource(); removeLevelView(view); } @@ -695,15 +695,15 @@ * Invoked when the internal frame view is closed. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameClosed(InternalFrameEvent event) { + public void internalFrameClosed(final InternalFrameEvent event) { } /** * Invoked when the internal frame view is iconified. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameIconified(InternalFrameEvent event) { - CMapViewIFrame view = (CMapViewIFrame) event.getSource(); + public void internalFrameIconified(final InternalFrameEvent event) { + final CMapViewIFrame view = (CMapViewIFrame) event.getSource(); levelViewFocusLostNotify(view); } @@ -711,15 +711,15 @@ * Invoked when the internal frame view is deiconified. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameDeiconified(InternalFrameEvent event) { + public void internalFrameDeiconified(final InternalFrameEvent event) { } /** * Invoked when the internal frame view is activated. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameActivated(InternalFrameEvent event) { - CMapViewIFrame view = (CMapViewIFrame) event.getSource(); + public void internalFrameActivated(final InternalFrameEvent event) { + final CMapViewIFrame view = (CMapViewIFrame) event.getSource(); levelViewFocusGainedNotify(view); } @@ -727,7 +727,7 @@ * Invoked when the internal frame view is deactivated. * @param event the occurred <code>InternalFrameEvent</code> */ - public void internalFrameDeactivated(InternalFrameEvent event) { + public void internalFrameDeactivated(final InternalFrameEvent event) { } /** Splitpane class that keeps its size even upon L'n'F change. */ @@ -736,7 +736,7 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - public CSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent) { + public CSplitPane(final int newOrientation, final Component newLeftComponent, final Component newRightComponent) { super(newOrientation, newLeftComponent, newRightComponent); } @@ -745,8 +745,8 @@ * UI change. */ @Override public void updateUI() { - int dividerLocation = getDividerLocation(); - int dividerSize = getDividerSize(); + final int dividerLocation = getDividerLocation(); + final int dividerSize = getDividerSize(); super.updateUI(); setDividerLocation(dividerLocation); setDividerSize(dividerSize); Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-06-08 21:24:32 UTC (rev 140) @@ -63,7 +63,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CMapArchPanel extends JPanel { +public final class CMapArchPanel extends JPanel { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -79,7 +79,7 @@ // without overruling getScrollableTracksViewportWidth(), // is JTextPanel not scrolling horizontal // i searched hours for the reason... the net is full of broken examples - private JTextPane archEdit = new JTextPane() { + private final JTextPane archEdit = new JTextPane() { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -88,7 +88,7 @@ return getSize().width < getParent().getSize().width; } - @Override public void setSize(Dimension d) { + @Override public void setSize(final Dimension d) { if (d.width < getParent().getSize().width) { d.width = getParent().getSize().width; } @@ -104,18 +104,18 @@ private final CMainView mainView; - private CSplitPane splitPane; + private final CSplitPane splitPane; - private JTabbedPane panelDesktop; + private final JTabbedPane panelDesktop; private Style currentAttributes; - private Document doc; + private final Document doc; - private JScrollPane scrollArchPane = new JScrollPane(); + private final JScrollPane scrollArchPane = new JScrollPane(); /** panel with name/face etc */ - private JPanel archPanel; + private final JPanel archPanel; /** panel with message text */ private JPanel textPanel; @@ -123,33 +123,33 @@ private JPanel scriptPanel; /** arch text field */ - private JTextArea archTextArea = new JTextArea(4, 25); + private final JTextArea archTextArea = new JTextArea(4, 25); /** arch name field */ - private JTextField archNameField = new JTextField(14); + private final JTextField archNameField = new JTextField(14); /** arch face field */ - private JTextField archFaceField = new JTextField(14); + private final JTextField archFaceField = new JTextField(14); private JLabel archInvCount = new JLabel(); private JLabel archMapPos = new JLabel(); - private JLabel archTypeText = new JLabel(); + private final JLabel archTypeText = new JLabel(); - private JLabel archTileText = new JLabel(); + private final JLabel archTileText = new JLabel(); - private JPanel mapArchPanel = new JPanel(); + private final JPanel mapArchPanel = new JPanel(); - private JButton submitChange; + private final JButton submitChange; - private JButton submitMultiChange; + private final JButton submitMultiChange; private JButton jumpChange; - private JButton invChange; + private final JButton invChange; - private JButton attrWin; + private final JButton attrWin; // stuff for scripting tab private JButton s_new; @@ -165,21 +165,21 @@ private ArchObject selectedObject; /* Build Panel */ - CMapArchPanel(final CMainControl mainControl, CMainView view) { + CMapArchPanel(final CMainControl mainControl, final CMainView view) { this.mainControl = mainControl; mainView = view; - CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); + final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); setLayout(new BorderLayout()); // scrollPane2 contains the document for archtext editing - JScrollPane scrollPane2 = new JScrollPane(archEdit); + final JScrollPane scrollPane2 = new JScrollPane(archEdit); scrollPane2.getViewport().add(archEdit); add(scrollPane2, BorderLayout.EAST); scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane2.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - JScrollPane scrollPane3 = new JScrollPane(mapArchPanel); + final JScrollPane scrollPane3 = new JScrollPane(mapArchPanel); scrollPane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollPane3.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); @@ -191,7 +191,7 @@ scrollPane3, scrollPane2); - JPanel buttonPanel = new JPanel(); + final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(0, 1)); mapArchPanel.add(buttonPanel, BorderLayout.WEST); @@ -214,8 +214,8 @@ // setup our plain archPanel - we need to add later field to it // depending on the arch typ selected archPanel = new JPanel(); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints c = new GridBagConstraints(); archPanel.setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.NORTHWEST; @@ -231,13 +231,13 @@ panelDesktop.add(scriptPanel, "Scripts"); - JPanel animationPanel = new JPanel(); + final JPanel animationPanel = new JPanel(); panelDesktop.add(animationPanel, "Animation"); // calculate default value in case there is no settings file - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - int divLocation = Integer.parseInt(settings.getProperty( + final int divLocation = Integer.parseInt(settings.getProperty( MAPARCHPANEL_LOCATION_KEY, "" + (int) (0.49 * screen.getWidth()))); splitPane.setDividerLocation(divLocation); @@ -247,19 +247,19 @@ doc = archEdit.getDocument(); submitChange.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { applyArchPanelChanges(mainView.getMapTileSelection()); } }); attrWin.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { openAttrDialog(mainView.getMapTileSelection()); } }); invChange.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { ArchObject arch = mainControl.getArchPanelSelection(); if (arch == null) { // nothing selected? return; @@ -280,7 +280,7 @@ inv = inv.getMapMultiHead(); } - ArchObject invnew; + final ArchObject invnew; if (arch.isDefaultArch()) { // create a new copy of a defautl arch invnew = mainControl.getArchObjectStack().newArchObjectInstance(arch.getNodeNr()); @@ -302,10 +302,10 @@ * is pressed, this function updates the active arch object. * @param activeArch the currently selected arch */ - public void applyArchPanelChanges(ArchObject activeArch) { - ArchObject arch; // ArchObject that gets modified - String oldArchText; // the old ArchText - String oldMsg; // old arch msg + public void applyArchPanelChanges(final ArchObject activeArch) { + final ArchObject arch; // ArchObject that gets modified + final String oldArchText; // the old ArchText + final String oldMsg; // old arch msg boolean needRedraw = false; // do we need a map-redraw? true/false if (activeArch == null) { @@ -320,7 +320,7 @@ arch = activeArch; } - ArchObject defarch = mainControl.getArch(arch.getNodeNr()); + final ArchObject defarch = mainControl.getArch(arch.getNodeNr()); if (defarch == null) { // hm, this should NOT happen return; } @@ -353,7 +353,7 @@ if (testForText(archFaceField.getText())) { // there is something in // check if we need a map redraw if (defarch.getFaceName() != null) { - String facename; + final String facename; if (arch.getFaceName() != null) { facename = arch.getFaceName(); } else { @@ -456,7 +456,7 @@ // simple "white space test, to eliminate ' ' // perhaps we should include here a real white space test - public boolean testForText(String text) { + public boolean testForText(final String text) { for (int i = 0; i < text.length(); i++) { if (text.charAt(i) != ' ') { return true; @@ -468,8 +468,8 @@ /** set up the arch panel entry of the lower window */ private void setupArchPanel() { - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints c = new GridBagConstraints(); //archPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); archPanel.setLayout(gridbag); c.fill = GridBagConstraints.BOTH; @@ -529,7 +529,7 @@ * Open an attribute dialog window for the currently selected arch * @param arch currently selected arch */ - private void openAttrDialog(ArchObject arch) { + private void openAttrDialog(final ArchObject arch) { mainControl.openAttrDialog(arch); } @@ -541,7 +541,7 @@ archTextArea.setForeground(Color.blue); // create ScrollPane for text scrolling - JScrollPane sta = new JScrollPane(archTextArea); + final JScrollPane sta = new JScrollPane(archTextArea); sta.setBorder(new EtchedBorder()); sta.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); sta.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); @@ -559,18 +559,18 @@ mainControl.setPlainFont(eventList); // create ScrollPane for jlist scrolling - JScrollPane ssa = new JScrollPane(eventList); + final JScrollPane ssa = new JScrollPane(eventList); ssa.setBorder(new EtchedBorder()); ssa.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); ssa.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); ssa.setPreferredSize(new Dimension(80, 40)); // create buttons - JPanel grid = new JPanel(new GridLayout(2, 2)); + final JPanel grid = new JPanel(new GridLayout(2, 2)); s_new = new JButton("Create New"); s_new.setMargin(new Insets(3, 3, 3, 3)); s_new.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { addNewScriptWanted(); } }); @@ -579,7 +579,7 @@ s_path = new JButton("Edit Params"); s_path.setMargin(new Insets(3, 3, 3, 3)); s_path.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { editScriptWanted(CMapArchPanel.SCRIPT_EDIT_PATH); } }); @@ -588,7 +588,7 @@ s_modify = new JButton("Edit Script"); s_modify.setMargin(new Insets(3, 3, 3, 3)); s_modify.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { editScriptWanted(CMapArchPanel.SCRIPT_OPEN); } }); @@ -597,7 +597,7 @@ s_remove = new JButton("Remove"); s_remove.setMargin(new Insets(3, 3, 3, 3)); s_remove.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { editScriptWanted(CMapArchPanel.SCRIPT_REMOVE); } }); @@ -618,7 +618,7 @@ } void appExitNotify() { - CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); + final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); settings.setProperty(MAPARCHPANEL_LOCATION_KEY, "" + splitPane.getDividerLocation()); @@ -633,7 +633,7 @@ * update the map arch panel to display the custom font * @param refresh if true, the window is redrawn after setting the fonts */ - public void updateFont(boolean refresh) { + public void updateFont(final boolean refresh) { mainControl.setPlainFont(archTextArea); mainControl.setPlainFont(archFaceField); mainControl.setPlainFont(archNameField); @@ -676,10 +676,10 @@ * updated. * @param activeArch the selected arch */ - public void setMapArchPanelObject(ArchObject activeArch) { - ArchObject arch; // reference to the displayed archobject + public void setMapArchPanelObject(final ArchObject activeArch) { + final ArchObject arch; // reference to the displayed archobject boolean hasMessage = false; // true when arch has a message text - int i; // tmp. variable + final int i; // tmp. variable selectedObject = activeArch; // archObjNameText.setText("<html><font color=black>Name:</font></html>"); @@ -821,7 +821,7 @@ if (arch.getArchText() != null && mainControl.getArchObjectStack().getArch(arch.getNodeNr()) != null) { doc.insertString(doc.getLength(), arch.diffArchText(mainControl.getArchObjectStack().getArch(arch.getNodeNr()).getArchText(), true), currentAttributes); } - } catch (BadLocationException e) { + } catch (final BadLocationException e) { } archEdit.setCaretPosition(0); @@ -849,7 +849,7 @@ * valid selection in the event list, the appropriate action for this * script is triggered. */ - public void editScriptWanted(int task) { + public void editScriptWanted(final int task) { ArchObject arch = mainControl.getMainView().getMapTileSelection(); // get selected arch if (arch != null && arch.isMulti() && arch.getMapMultiHead() != null) { arch = arch.getMapMultiHead(); // if it's a multi, always take the head @@ -885,8 +885,8 @@ * @param pathButton * @param removeButton */ - public void setScriptPanelButtonState(boolean newButton, boolean modifyButton, - boolean pathButton, boolean removeButton) { + public void setScriptPanelButtonState(final boolean newButton, final boolean modifyButton, + final boolean pathButton, final boolean removeButton) { s_new.setEnabled(newButton); s_modify.setEnabled(modifyButton); s_path.setEnabled(pathButton); @@ -899,9 +899,9 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - public CSplitPane(int newOrientation, - Component newLeftComponent, - Component newRightComponent) { + public CSplitPane(final int newOrientation, + final Component newLeftComponent, + final Component newRightComponent) { super(newOrientation, newLeftComponent, newRightComponent); } @@ -910,8 +910,8 @@ * UI change. */ @Override public void updateUI() { - int dividerLocation = getDividerLocation(); - int dividerSize = getDividerSize(); + final int dividerLocation = getDividerLocation(); + final int dividerSize = getDividerSize(); super.updateUI(); setDividerLocation(dividerLocation); setDividerSize(dividerSize); Modified: trunk/crossfire/src/cfeditor/CMapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapControl.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMapControl.java 2006-06-08 21:24:32 UTC (rev 140) @@ -38,7 +38,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CMapControl { +public final class CMapControl { /** The main controller of this subcontroller. */ private final CMainControl mainControl; @@ -61,7 +61,7 @@ private boolean levelClosing = false; /** Flag that indicates whether this is a pickmap or not. */ - private boolean isPickmap; + private final boolean isPickmap; /** * Flag that indicates whether the tile maps surrounding current one @@ -88,9 +88,9 @@ * @param isPick true if this is a pickmap * @param initial the view position to show initially */ - CMapControl(CMainControl mainControl, ArchObject startObj, - MapArchObject maparch, boolean isPick, - Point initial) { + CMapControl(final CMainControl mainControl, final ArchObject startObj, + final MapArchObject maparch, final boolean isPick, + final Point initial) { this.mainControl = mainControl; activeEditType = 0; // start with no edit types (saves time) isPickmap = isPick; // is this a pickmap? @@ -185,7 +185,7 @@ * Notifies that a view has been closed. * @param view The view that was closed. */ - void viewCloseNotify(CMapViewBasic view) { + void viewCloseNotify(final CMapViewBasic view) { if (!levelClosing) { mainControl.closeLevel(this, false); } @@ -205,7 +205,7 @@ * Handles the given error. * @param error a generic error */ - public void handleErrors(GridderException error) { + public void handleErrors(final GridderException error) { mainControl.handleErrors(error); } @@ -214,7 +214,7 @@ * @param strTitle The title of the message. * @param strMessage The message to be shown. */ - protected void showMessage(String strTitle, String strMessage) { + protected void showMessage(final String strTitle, final String strMessage) { mainControl.showMessage(strTitle, strMessage); } @@ -471,10 +471,10 @@ showTiles = show; if (show) { /*Do the tile maps loading :)*/ - String north = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_NORTH); - String west = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_WEST); - String east = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_EAST); - String south = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_SOUTH); + final String north = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_NORTH); + final String west = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_WEST); + final String east = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_EAST); + final String south = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_SOUTH); /*tileModel = new CMapModel[8]; CMapFileDecode loader; CMapControl tmp; @@ -525,7 +525,7 @@ * Sets the level name. * @param strName The level name. */ - public void setMapName(String strName) { + public void setMapName(final String strName) { mapModel.setMapName(strName); } @@ -533,16 +533,16 @@ return mapModel.getFileName(); } - public void setMapFileName(String fname) { + public void setMapFileName(final String fname) { mapView.setTitle("Map [" + fname + "]"); mapModel.setFileName(fname); } - public void setNewMapText(String str) { + public void setNewMapText(final String str) { mapModel.setNewMapText(str); } - public void setNewLoreText(String str) { + public void setNewLoreText(final String str) { mapModel.getMapArchObject().setLore(str); } @@ -566,14 +566,14 @@ * Saves the file with the given file name. * @param file The file to be saved to. */ - void saveAs(File file) { + void saveAs(final File file) { CMainStatusbar.getInstance().setText("Saving the map to a file..."); mainControl.encodeMapFile(file, mapModel); mapModel.resetLevelChangedFlag(); mapView.changedFlagNotify(); } - void setMapFile(File file) { + void setMapFile(final File file) { mapFile = file; } Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-06-08 21:24:32 UTC (rev 140) @@ -39,7 +39,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CMapFileDecode { +public final class CMapFileDecode { private static final Logger log = Logger.getLogger(CMapFileDecode.class); @@ -74,8 +74,8 @@ public ArchObject decodeMapFile(final File file) throws GridderException { try { - FileReader fr = new FileReader(file); - BufferedReader myInput = new BufferedReader(fr); + final FileReader fr = new FileReader(file); + final BufferedReader myInput = new BufferedReader(fr); maxxlen = maxylen = 0; start = previous = null; @@ -97,7 +97,7 @@ } myInput.close(); fr.close(); - } catch (IOException e) { + } catch (final IOException e) { log.debug("Error Loading file " + file.getName(), e); for (ArchObject tarch = start, temparch; tarch != null;) { @@ -137,12 +137,12 @@ * @return the new parsed <code>ArchObject</code> * @throws IOException when an I/O-error occured during file reading */ - @Nullable public ArchObject readArch(BufferedReader myInput, String thisLine, ArchObject container) + @Nullable public ArchObject readArch(final BufferedReader myInput, String thisLine, final ArchObject container) throws IOException { ArchObject arch; String thisLine2; boolean archflag, archmore, msgflag, animflag, scriptflag; - int x, y, temp; + final int y; archflag = false; archmore = false; @@ -169,6 +169,7 @@ } else if (thisLine.regionMatches(0, "arch ", 0, 5)) { // kill white spaces afer arch... // (hm, no command for this in java?) + int x; for (x = 5; x < thisLine.length(); x++) { if (thisLine.charAt(x) != ' ') { break; @@ -247,24 +248,24 @@ animflag = true; } else if (thisLine.startsWith("event_")) { // here's something about a scripted event - int i = thisLine.indexOf("_plugin"); - int k = thisLine.indexOf("_options"); - int space = thisLine.indexOf(" "); + final int i = thisLine.indexOf("_plugin"); + final int k = thisLine.indexOf("_options"); + final int space = thisLine.indexOf(" "); if (space > 0) { if (i > 0) { // expecting: "event_type_plugin Name" - String type = thisLine.substring(6, i); - String plname = thisLine.substring(space + 1).trim(); + final String type = thisLine.substring(6, i); + final String plname = thisLine.substring(space + 1).trim(); arch.addEventPlugin(type, plname); } else if (k > 0) { // expecting: "event_type_options Name" - String type = thisLine.substring(6, k); - String eventopt = thisLine.substring(space + 1).trim(); + final String type = thisLine.substring(6, k); + final String eventopt = thisLine.substring(space + 1).trim(); arch.addEventOptions(type, eventopt); } else { // expecting: "event_type filepath" - String type = thisLine.substring(6, space); - String path = thisLine.substring(space + 1).trim(); + final String type = thisLine.substring(6, space); + final String path = thisLine.substring(space + 1).trim(); arch.addEventScript(type, path); } } else { @@ -272,13 +273,13 @@ arch.addArchText(thisLine + "\n"); // keep line, it might have a meaning after all } } else if (thisLine.regionMatches(0, "x ", 0, 2)) { - temp = Integer.parseInt(thisLine.substring(2)); + final int temp = Integer.parseInt(thisLine.substring(2)); if (temp > maxxlen) { maxxlen = temp; } arch.setMapX(temp); } else if (thisLine.regionMatches(0, "y ", 0, 2)) { - temp = Integer.parseInt(thisLine.substring(2)); + final int temp = Integer.parseInt(thisLine.substring(2)); if (temp > maxylen) { maxylen = temp; } @@ -288,6 +289,7 @@ arch.setArchTypNr(Integer.parseInt(thisLine.substring(5))); // don't load it into the archtext! } else if (thisLine.regionMatches(0, "face ", 0, 5)) { + int x; for (x = 4; x < thisLine.length(); x++) { if (thisLine.charAt(x) != ' ') { break; @@ -308,7 +310,7 @@ } thisLine2 = myInput.readLine(); } - } catch (IOException e) { + } catch (final IOException e) { log.error("Read Error while trying to load map: " + maparch.getFileName(), e); throw e; // we simply pass this exception to the calling function } Modified: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-06-08 21:24:32 UTC (rev 140) @@ -45,7 +45,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CMapFileEncode { +public final class CMapFileEncode { private static final Logger log = Logger.getLogger(CMapFileEncode.class); @@ -66,8 +66,8 @@ * @param file mapfile * @param mapModel the MapModel to encode */ - public void encodeMapFile(File file, CMapModel mapModel) { - MapArchObject map = mapModel.getMapArchObject(); + public void encodeMapFile(File file, final CMapModel mapModel) { + final MapArchObject map = mapModel.getMapArchObject(); try { if (file == null) { @@ -133,9 +133,9 @@ bufferedWriter.close(); fileWriter.close(); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { mainControl.showMessage("Error Save Map", "Error writing file " + fname + "\n"); - } catch (IOException e) { + } catch (final IOException e) { mainControl.showMessage("Error Save Map", "Error writing file " + fname + "\n"); } } @@ -145,11 +145,11 @@ * @param start the container arch whose inventory is to be written * @return true if all writing actions successful */ - public boolean browseInvObjects(ArchObject start) { + public boolean browseInvObjects(final ArchObject start) { // cycle throught the whole inventory list: - Iterator it = start.getInventory(); + final Iterator it = start.getInventory(); while (it.hasNext()) { - ArchObject arch = (ArchObject) it.next(); + final ArchObject arch = (ArchObject) it.next(); // write the inventory arch (recursion possible here) if (!writeMapArch(arch, true)) { return false; @@ -165,28 +165,28 @@ * @param isInventory is 'arch' inside a container? true/false * @return true if arch was written successfully */ - boolean writeMapArch(ArchObject arch, boolean isInventory) { - ArchObject defarch = arch.getDefaultArch(); + boolean writeMapArch(final ArchObject arch, final boolean isInventory) { + final ArchObject defarch = arch.getDefaultArch(); // Collect all fields to write. - HashMap fields = new HashMap(); // String key -> String value + final HashMap fields = new HashMap(); // String key -> String value - String name = arch.getObjName(); + final String name = arch.getObjName(); if (name != null) { fields.put("name", name); } - String face = arch.getFaceName(); + final String face = arch.getFaceName(); if (face != null) { fields.put("face", face); } if (arch.isScripted()) { - String events = arch.getMapArchEventData(); + final String events = arch.getMapArchEventData(); if (!events.equals("")) { - String[] tmp = events.split("\n"); + final String[] tmp = events.split("\n"); for (int i = 0; i < tmp. length; i++) { - String[] line = tmp[i].split(" +", 2); + final String[] line = tmp[i].split(" +", 2); if (line.length != 2) { log.warn("writeMapArch: ignoring invalid event line: " + tmp[i]); } else { @@ -214,8 +214,8 @@ // is conflicting. remove the type from the archtext // open a reading stream for the archText - StringReader sread = new StringReader(arch.getArchText().toString()); - BufferedReader sstream = new BufferedReader(sread); + final StringReader sread = new StringReader(arch.getArchText().toString()); + final BufferedReader sstream = new BufferedReader(sread); String newArchtext = ""; try { @@ -244,7 +244,7 @@ } else { arch.setArchText(newArchtext.trim() + "\n"); } - } catch (IOException e) { + } catch (final IOException e) { log.error("getSyntaxErrors: Cannot close StringReader"); } } @@ -253,11 +253,11 @@ fields.put("type", Integer.toString(arch.getArchTypNr())); } - String text = arch.getArchText(); + final String text = arch.getArchText(); if (!text.equals("")) { - String[] tmp = text.split("\n"); + final String[] tmp = text.split("\n"); for (int i = 0; i < tmp. length; i++) { - String[] line = tmp[i].split(" +", 2); + final String[] line = tmp[i].split(" +", 2); if (line.length != 2) { log.warn("writeMapArch: ignoring invalid arch line: " + tmp[i]); } else { @@ -268,28 +268,28 @@ if (!isInventory) { // map coordinates only belong into map arches (not inventory arches) - int x = arch.getMapX(); + final int x = arch.getMapX(); if (x != 0) { fields.put("x", Integer.toString(x)); } - int y = arch.getMapY(); + final int y = arch.getMapY(); if (y != 0) { fields.put("y", Integer.toString(y)); } } // Sort fields to match server/crossedit order. - String[] keys = (String[]) fields.keySet().toArray(new String[0]); + final String[] keys = (String[]) fields.keySet().toArray(new String[0]); Arrays.sort(keys, keyOrderComparator); // Actually write the fields. try { bufferedWriter.write("arch " + arch.getArchName() + "\n"); for (int i = 0; i < keys.length; i++) { - String value = (String) fields.get(keys[i]); + final String value = (String) fields.get(keys[i]); if (value != null) { - String key = keys[i]; + final String key = keys[i]; if (key.equals("msg") || key.equals("lore")) { bufferedWriter.write(key + "\n" + value + "\n"); } else { @@ -301,7 +301,7 @@ browseInvObjects(arch); // write his inventory inside this arch bufferedWriter.write("end\n"); - } catch (IOException e) { + } catch (final IOException e) { mainControl.showMessage("Error Save Map", "Error writing file " + fname + "\n"); return false; } @@ -313,13 +313,13 @@ * in the order in which they should be written to disk. */ private final Comparator keyOrderComparator = new Comparator() { - public int compare(Object o1, Object o2) { - String s1 = (String) o1; - String s2 = (String) o2; - Integer i1 = (Integer) keys.get(s1); - Integer i2 = (Integer) keys.get(s2); - int v1 = i1 == null ? 10000 : i1.intValue(); - int v2 = i2 == null ? 10000 : i2.intValue(); + public int compare(final Object o1, final Object o2) { + final String s1 = (String) o1; + final String s2 = (String) o2; + final Integer i1 = (Integer) keys.get(s1); + final Integer i2 = (Integer) keys.get(s2); + final int v1 = i1 == null ? 10000 : i1.intValue(); + final int v2 = i2 == null ? 10000 : i2.intValue(); if (v1 < v2) { return -1; } @@ -579,7 +579,7 @@ * Add a new key to {@link #keys}. The order in which the keys are added is * the order in which the objects fields are written out. */ - private static void addKey(String key) { + private static void addKey(final String key) { keys.put(key, new Integer(idKey++)); } } Modified: trunk/crossfire/src/cfeditor/CMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapModel.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMapModel.java 2006-06-08 21:24:32 UTC (rev 140) @@ -43,7 +43,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CMapModel { +public final class CMapModel { private static final Logger log = Logger.getLogger(CMapModel.class); @@ -338,9 +338,11 @@ return false; } - int temp = -1; + final int temp; if (intern != -1) { // we use this different - only one object temp = archnr + c; // of one type on a map position when dragged + } else { + temp = -1; } // run through map parts and test for intern counter @@ -529,7 +531,7 @@ return true; } - @Deprecated public boolean insertArchToMap(ArchObject newarch, int archnr, final ArchObject next, final int mapx, final int mapy, final boolean join) { + @Deprecated public boolean insertArchToMap(final ArchObject newarch, final int archnr, final ArchObject next, final int mapx, final int mapy, final boolean join) { return insertArchToMap(newarch, archnr, next, new Point(mapx, mapy), join); } /** @@ -595,7 +597,7 @@ } } else { // insert the new arch into the inventory of a map arch - ArchObject invnew; // new arch to be inserted + final ArchObject invnew; // new arch to be inserted if (newarch == null || newarch.isDefaultArch()) { if (newarch != null && newarch.isDefaultArch()) { archnr = newarch.getNodeNr(); @@ -1121,7 +1123,7 @@ * @param y square location (y coordinate) * @return whether a match was found */ - public boolean filterSquare(NamedFilterConfig config, int x, int y) { + public boolean filterSquare(final NamedFilterConfig config, final int x, final int y) { return filterSquare(NamedFilterList.getDefaultList(), config, x, y); } @@ -1134,7 +1136,7 @@ * @param y square location (y coordinate) * @return whether a match was found */ - public boolean filterSquare(Filter filter, FilterConfig config, int x, int y) { + public boolean filterSquare(final Filter filter, final FilterConfig config, final int x, final int y) { if (x < 0 || y < 0 || x >= mapSize.width || y >= mapSize.height) { return false; } @@ -1171,7 +1173,7 @@ * @param levelFile The level file that is used as the data source. */ /* - void setLevelCellData(int x, int y, int data) { + void setLevelCellData(final int x, final int y, final int data) { // Clear data bits m_levelGrid[x][y] &= m_flagMask; @@ -1192,7 +1194,7 @@ */ /* int[] getRawData() { - int[] aData = new int[m_levelWidth*m_levelHeight]; + final int[] aData = new int[m_levelWidth*m_levelHeight]; int idx = 0; for (int y = 0; y < m_levelHeight; y++) { for (int x = 0; x < m_levelWidth; x++) { @@ -1208,7 +1210,7 @@ * Sets the level data. */ /* - void setRawData(int[] aData) { + void setRawData(final int[] aData) { m_levelGrid = new int[m_levelWidth][m_levelHeight]; int idx = 0; for (int y = 0; y < m_levelHeight; y++) { Modified: trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java 2006-06-06 21:54:36 UTC (rev 139) +++ trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java 2006-06-08 21:24:32 UTC (rev 140) @@ -58,7 +58,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:mic...@no...">Michael Toennies</a> */ -public class CMapPropertiesDialog extends CDialogBase { +public final class CMapPropertiesDialog extends CDialogBase { public static final String CENTER_MAP_KEY = "MapProperties.centerMapOnResize"; @@ -154,7 +154,7 @@ CMapPropertiesDialog(final CMainControl mainControl, final Frame parentFrame, final CMapControl level) { // set title super(parentFrame, "" + level.getMapNameWithoutMusic() + " - Map Properties"); - MapArchObject map = level.getMapModel().getMapArchObject(); // map arch object + final MapArchObject map = level.getMapModel().getMapArchObject(); // map arch object this.mainControl = mainControl; // main control m_level = level; // map control @@ -162,9 +162,9 @@ getContentPane().setLayout(new BorderLayout()); // main panel (gridbag) - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); - JPanel mainPanel = new JPanel(gridbag); + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints c = new GridBagConstraints(); + final JPanel mainPanel = new JPanel(gridbag); //mainPanel.setLayout(new CardLayout()); mainPanel.setBorder(new EmptyBorder( IGUIConstants.DIALOG_INSETS, @@ -173,7 +173,7 @@ IGUIConstants.DIALOG_INSETS)); // 1. map panel: - JPanel mapPanel = new JPanel(new GridLayout(0, 1)); + final JPanel mapPanel = new JPanel(new GridLayout(0, 1)); mapPanel.setBorder( new CompoundBorder( new TitledBorder(new EtchedBorder(), "Map"), @@ -201,7 +201,7 @@ mainPanel.add(mapPanel); // 2. options panel: - JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP); + final JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP); tabPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 0)); JPanel optionPanel = new JPanel(new GridLayout(1, 1)); @@ -215,9 +215,9 @@ IGUIConstants.DIALOG_INSETS, IGUIConstants.DIALOG_INSETS))); } - JPanel optionPanel2 = new JPanel(); + final JPanel optionPanel2 = new JPanel(); optionPanel2.setLayout(new BoxLayout(optionPanel2, BoxLayout.Y_AXIS)); - ... [truncated message content] |
From: <aki...@us...> - 2006-06-11 15:21:47
|
Revision: 143 Author: akirschbaum Date: 2006-06-11 08:20:57 -0700 (Sun, 11 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=143&view=rev Log Message: ----------- Refactor map related classes to package cfeditor.map; rename classes CMapXxx to MapXxxx. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CFilterControl.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CMapViewIFrame.java trunk/crossfire/src/cfeditor/CNewMapDialog.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/CUndoStack.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/arch/ArchObjectIteratorDeleteArchMapObject.java trunk/crossfire/src/cfeditor/arch/ArchObjectIteratorDeleteMapArch.java trunk/crossfire/src/cfeditor/parameter/MapParameter.java trunk/crossfire/src/cfeditor/parameter/MapParameterView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/MapTilePane.java trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/map/ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMapControl.java trunk/crossfire/src/cfeditor/CMapModel.java trunk/crossfire/src/cfeditor/MapArchObject.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-06-11 15:20:57 UTC (rev 143) @@ -26,6 +26,7 @@ import cfeditor.arch.ArchObject; import cfeditor.arch.ArchObjectStack; +import cfeditor.map.MapModel; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -189,7 +190,7 @@ * @return node_nr of the (def.) arch to be inserted at x, y * -1 if there's already an arch of this list on x, y */ - public int joinInsert(final CMapModel map, final int x, final int y) { + public int joinInsert(final MapModel map, final int x, final int y) { int newIndex = 0; // return value, see above // if there already is an arch of this list at x, y -> abort @@ -239,7 +240,7 @@ * @param y Location of the insert point on the map * @param map Data model of the map */ - public void joinDelete(final CMapModel map, final int x, final int y) { + public void joinDelete(final MapModel map, final int x, final int y) { ArchObject arch; // temp. arch // do the joining in all four directions: @@ -311,7 +312,7 @@ * @param y location to search * @return arch which is part of this joinlist, null if no such arch exists */ - @Nullable private ArchObject findArchOfJoinlist(final CMapModel map, final int x, final int y) { + @Nullable private ArchObject findArchOfJoinlist(final MapModel map, final int x, final int y) { ArchObject tmpArch = map.getTopArchObject(x, y); // we look through the arches at the given location (top to bottom): for (; tmpArch != null; tmpArch = tmpArch.getPrevArch()) { Modified: trunk/crossfire/src/cfeditor/CFilterControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CFilterControl.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CFilterControl.java 2006-06-11 15:20:57 UTC (rev 143) @@ -15,6 +15,7 @@ import cfeditor.filter.NamedFilterEvent; import cfeditor.filter.NamedFilterList; import cfeditor.filter.NamedFilterListener; +import cfeditor.map.MapControl; import cfeditor.menu.BasicMenuEntry; import javax.swing.JComponent; import javax.swing.JMenu; @@ -54,7 +55,7 @@ private final boolean highLightResult[]; - private final CMapControl map; + private final MapControl map; private static final CFilterControl defaultFilter = new CFilterControl(null); @@ -62,7 +63,7 @@ * Create a new FilterControl. * Do not highlight anything and does not filterOut anything */ - public CFilterControl(final CMapControl map) { + public CFilterControl(final MapControl map) { highLight = new boolean[]{false, false, false,}; filterOutConfig = (NamedFilterConfig) filterList.createConfig(); highLightConfig = new NamedFilterConfig[]{ @@ -135,7 +136,7 @@ if (map != null) { map.repaint(); } else { - final CMapControl[] maps = CMainControl.getInstance().getOpenedMaps(); + final MapControl[] maps = CMainControl.getInstance().getOpenedMaps(); for (int i = 0; i < maps.length; i++) { maps[i].repaint(); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-06-11 15:20:57 UTC (rev 143) @@ -29,6 +29,9 @@ import cfeditor.arch.ArchObjectParser; import cfeditor.arch.ArchObjectStack; import cfeditor.arch.anim.AnimationObjects; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapControl; +import cfeditor.map.MapModel; import cfeditor.textedit.scripteditor.ScriptEditControl; import java.awt.Font; import java.awt.Point; @@ -134,7 +137,7 @@ private final Vector levels = new Vector(1, 2); /** The current top map we are working with */ - private CMapControl currentMap; + private MapControl currentMap; /** The current script controller */ private final CScriptController scriptControl; @@ -359,7 +362,7 @@ void selectEditType(final int newType) { // calculate the new type for all opened maps: for (Enumeration enu = levels.elements(); enu.hasMoreElements();) { - final CMapControl level = (CMapControl) enu.nextElement(); + final MapControl level = (MapControl) enu.nextElement(); level.addEditType(newType); // calculate new type } @@ -529,7 +532,7 @@ } /** refresh the active map view, if there is one */ - void refreshCurrentMap() { + public void refreshCurrentMap() { mainView.refreshMapTileList(); // update tile window if (currentMap != null) { currentMap.repaint(); // update map view (if there is one) @@ -647,7 +650,7 @@ // update the look and feel for all open map views if (levels.size() > 0) { for (final Enumeration enu = levels.elements(); enu.hasMoreElements();) { - final CMapControl level = (CMapControl) enu.nextElement(); + final MapControl level = (MapControl) enu.nextElement(); level.getMapView().updateLookAndFeel(); if (log.isDebugEnabled()) { log.debug("map " + level.getMapName()); @@ -707,7 +710,7 @@ * left corner * @return map control of new map */ - public CMapControl newLevel(final ArchObject start, final MapArchObject maparch, final Point initial) { + public MapControl newLevel(final ArchObject start, final MapArchObject maparch, final Point initial) { return newLevel(start, maparch, true, initial); } @@ -722,11 +725,11 @@ * left corner * @return map control of new map */ - public CMapControl newLevel(final ArchObject start, final MapArchObject maparch, final boolean show, final Point initial) { + public MapControl newLevel(final ArchObject start, final MapArchObject maparch, final boolean show, final Point initial) { // Create a new level control and set the level view from that CMainStatusbar.getInstance().setText(" Creating new map " + maparch.getMapName()); - final CMapControl map = new CMapControl(this, start, maparch, false, initial); + final MapControl map = new MapControl(this, start, maparch, false, initial); if (show) { mainView.addLevelView(map.getMapView()); // one view... map.getMapView().setAutoscrolls(true); @@ -770,7 +773,7 @@ showMessage("Cannot close Pickmap", "Pickmaps are currently hidden.\n" + "Please select a pickmap before activating this command."); } else { - final CMapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); + final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { showMessage("Cannot close Pickmap", "There are no pickmaps."); } else { @@ -796,7 +799,7 @@ * @param forced when true, user does not get asked and changes do not get saved * @return true if closing successful */ - public boolean closeLevel(final CMapControl level, final boolean forced) { + public boolean closeLevel(final MapControl level, final boolean forced) { if (level == null) { showMessage("CLOSE LEVEL", "FIND NULL LEVEL : " + levels.size() + " our map: " + currentMap); @@ -828,7 +831,7 @@ if (levels.size() > 0) { // get next open map we can find and set it to currentMap for (final Enumeration enu = levels.elements(); enu.hasMoreElements();) { - currentMap = (CMapControl) enu.nextElement(); + currentMap = (MapControl) enu.nextElement(); } } } @@ -847,7 +850,7 @@ showMessage("Cannot open Pickmap", "Pickmaps are currently hidden.\n" + "Please select a pickmap before activating this command."); } else { - final CMapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); + final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { showMessage("Cannot open Pickmap", "There are no pickmaps."); } else { @@ -928,7 +931,7 @@ * @param file mapfile. * @return The map controller to manipulate this map. */ - public CMapControl openFile(final File file) { + public MapControl openFile(final File file) { return openFile(file, true, null); } @@ -938,7 +941,7 @@ * @param show set to true to show the map in main view. * @return The map controller to manipulate this map. */ - public CMapControl openFile(final File file, final boolean show) { + public MapControl openFile(final File file, final boolean show) { return openFile(file, show, null); } @@ -949,7 +952,7 @@ * @param initial the view position to show initially * @return The map controller to manipulate this map. */ - @Nullable public CMapControl openFile(final File file, final boolean show, final Point initial) { + @Nullable public MapControl openFile(final File file, final boolean show, final Point initial) { final ArchObject start; final MapArchObject maparch; try { @@ -969,7 +972,7 @@ // ok, we have it all!! - final CMapControl control; + final MapControl control; if (start == null) { // The map is totally empty control = newLevel(start, maparch, show, initial); // init the map @@ -1009,7 +1012,7 @@ } // save map! - public void encodeMapFile(final File file, final CMapModel mapModel) { + public void encodeMapFile(final File file, final MapModel mapModel) { mapFileEncoder.encodeMapFile(file, mapModel); } @@ -1107,7 +1110,7 @@ showMessage("Cannot save Pickmap", "Pickmaps are currently hidden.\n" + "Please select a pickmap before activating this command."); } else { - final CMapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); + final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { showMessage("Cannot save Pickmap", "There are no pickmaps."); } else { @@ -1126,7 +1129,7 @@ * Invoked when user wants to save a level to certain file. * @param level map control of the map to be saved */ - public void saveLevelAsWanted(final CMapControl level) { + public void saveLevelAsWanted(final MapControl level) { if (level == null) { return; } @@ -1170,7 +1173,7 @@ * an output file name/path for the png image. */ public void createImageWanted() { - final CMapControl mc = currentMap; // control of current map + final MapControl mc = currentMap; // control of current map if (mc == null) { // there is no map open (should not happen due to disabled menus) @@ -1233,7 +1236,7 @@ * @param filename Name of the png image file to create. * @param mapc The controller of map to save. */ - public void createImageWanted(final CMapControl mapc, String filename) { + public void createImageWanted(final MapControl mapc, String filename) { if (mapc == null) { // there is no map open (should not happen due to disabled menus) @@ -1264,7 +1267,7 @@ * Shows the given levels properties. * @param level The level whose properties we want. */ - void showMapProperties(final CMapControl level) { + void showMapProperties(final MapControl level) { if (level != null) { final CMapPropertiesDialog dialog = new CMapPropertiesDialog(this, mainView, level); } @@ -1293,7 +1296,7 @@ * @param strMapTitle map name * @param mapSize size of map */ - void setLevelProperties(final CMapControl level, final String archText, final String loreText, final String strMapTitle, final Dimension mapSize) { + void setLevelProperties(final MapControl level, final String archText, final String loreText, final String strMapTitle, final Dimension mapSize) { if (level != null) { level.setProperties(archText, loreText, strMapTitle, mapSize); refreshMenusAndToolbars(); @@ -1308,7 +1311,7 @@ void exitWanted() { if (levels.size() > 0) { for (final Enumeration enu = levels.elements(); enu.hasMoreElements();) { - final CMapControl level = (CMapControl) enu.nextElement(); + final MapControl level = (MapControl) enu.nextElement(); closeLevel(level, false); } } @@ -1366,7 +1369,7 @@ return; } - final CMapControl oldmap = currentMap; // store old map control + final MapControl oldmap = currentMap; // store old map control openFile(newfile); // open the new map if (exitPos.x == 0 && exitPos.y == 0) { @@ -1413,7 +1416,7 @@ return; } - final CMapControl oldmap = currentMap; // store old map control + final MapControl oldmap = currentMap; // store old map control openFile(newfile); // open the new map // set viewport view on the new map @@ -1469,10 +1472,10 @@ /** * Sets the given level view as the current one. - * @param map <code>CMapControl</code> of the new current map. + * @param map <code>MapControl</code> of the new current map. */ - public void setCurrentLevel(final CMapControl map) { + public void setCurrentLevel(final MapControl map) { currentMap = map; refreshMenusAndToolbars(); //CMainStatusbar.getInstance().setLevelInfo(level); @@ -1480,7 +1483,7 @@ /** Invoked when user wants to revert the current map to previously saved state */ public void revertCurrentLevelWanted() { - final CMapControl modmap = this.currentMap; // "modified map" to be reverted + final MapControl modmap = this.currentMap; // "modified map" to be reverted // ask for confirmation if (askConfirm("Revert " + modmap.getMapFileName() + "?", "If you revert the map '" + modmap.getMapFileName() + "' to it's last saved state, all\nrecent changes will be lost. Do you really want to revert this map?")) { @@ -1505,7 +1508,7 @@ if (!getMainView().isPickmapActive()) { showMessage("Cannot revert Pickmap", "Pickmaps are currently hidden.\nPlease select a pickmap before activating this command."); } else { - final CMapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); + final MapControl activePickmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (activePickmap == null) { showMessage("Cannot revert Pickmap", "There are no pickmaps."); } else { @@ -1835,11 +1838,11 @@ return IGUIConstants.isoView ? nofaceTileIcon : nofaceTileIconX; } - public CMapControl[] getOpenedMaps() { - return (CMapControl[]) levels.toArray(new CMapControl[levels.size()]); + public MapControl[] getOpenedMaps() { + return (MapControl[]) levels.toArray(new MapControl[levels.size()]); } - public CMapControl getCurrentMap() { + public MapControl getCurrentMap() { return currentMap; } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-06-11 15:20:57 UTC (rev 143) @@ -25,6 +25,7 @@ package cfeditor; import cfeditor.arch.ArchObject; +import cfeditor.map.MapControl; import net.sf.gridarta.help.Help; import net.sf.gridarta.GridderException; import java.awt.BorderLayout; @@ -298,7 +299,7 @@ && CPickmapPanel.getInstance().isLoadComplete() && CPickmapPanel.getInstance().getCurrentPickmap() != null) { // get the active pickmap - final CMapControl pmap = CPickmapPanel.getInstance().getCurrentPickmap(); + final MapControl pmap = CPickmapPanel.getInstance().getCurrentPickmap(); if (pmap != null && pmap.getMapView().isHighlight()) { // now try to get the topmost object @@ -338,7 +339,7 @@ } // access mape tile list ... - public void setMapTileList(final CMapControl map, final int archid) { + public void setMapTileList(final MapControl map, final int archid) { mapTileList.setMapTileList(map, archid); } @@ -449,7 +450,7 @@ archPanel.updateFont(); } - void setRevertMenuEnabled(final boolean state) { + public void setRevertMenuEnabled(final boolean state) { menu.setRevertEnabled(state); } @@ -667,7 +668,7 @@ public void levelViewFocusGainedNotify(final CMapViewIFrame view) { mapViews.removeElement(view); mapViews.insertElementAt(view, 0); - final CMapControl level = view.getLevel(); + final MapControl level = view.getLevel(); mainControl.setCurrentLevel(level); //statusBar.setLevelInfo(level); Deleted: trunk/crossfire/src/cfeditor/CMapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapControl.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CMapControl.java 2006-06-11 15:20:57 UTC (rev 143) @@ -1,591 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import cfeditor.arch.ArchObject; -import cfeditor.arch.ArchObjectIterator; -import cfeditor.arch.ArchObjectIteratorDeleteMapArch; -import java.awt.Dimension; -import java.awt.Point; -import java.io.File; -import java.util.Iterator; -import net.sf.gridarta.GridderException; - -/** - * The <code>CMapControl</code> - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMapControl { - - /** The main controller of this subcontroller. */ - private final CMainControl mainControl; - - /** model (= map data of this level) */ - private final CMapModel mapModel; - - /** the view of the map */ - private final CMapViewIFrame mapView; - - private File mapFile; - - /** - * contains the edit types that have already been (requested and) - * calculated (edit types get calculated only when needed to save time) - */ - private int activeEditType; - - /** Flag that indicates whether the level is closing or not. */ - private boolean levelClosing = false; - - /** Flag that indicates whether this is a pickmap or not. */ - private final boolean isPickmap; - - /** - * Flag that indicates whether the tile maps surrounding current one - * must be displayed. - */ - private boolean showTiles = false; - - /** - * surrounding tiles. - * In order: north-west, north, north-east, west, east, south-west, south, south-east - */ - private CMapModel tileModel[]; - - private int northHeight, southHeight; - - private int westWidth, eastWidth; - - /** - * Constructs a new Map. - * @param mainControl the controller of this map - * @param maparch the <code>MapArchObject</code> of the map - * @param startObj chained list of Objects (ArchObjects) which should be - * filled in map - * @param isPick true if this is a pickmap - * @param initial the view position to show initially - */ - CMapControl(final CMainControl mainControl, final ArchObject startObj, - final MapArchObject maparch, final boolean isPick, - final Point initial) { - this.mainControl = mainControl; - activeEditType = 0; // start with no edit types (saves time) - isPickmap = isPick; // is this a pickmap? - // we create model (= data) - mapModel = new CMapModel(mainControl, this, maparch); - mapModel.addArchListToMap(startObj); - // and create a view (= window) - mapView = new CMapViewIFrame(mainControl, this, initial); - } - - /** Notifies that the application is about to exit. */ - void appExitNotify() { - mapView.appExitNotify(); // drop the view - mapModel.appExitNotify(); // and then the model - } - - /** - * Returns flag that indicates whether this is a pickmap or not. - * @return flag that indicates whether this is a pickmap or not. - */ - public boolean isPickmap() { - return isPickmap; - } - - public boolean isGridVisible() { - return mapView.isGridVisible(); - } - - public void setGridVisibility(final boolean fVisible) { - mapView.setGridVisibility(fVisible); - } - - /** - * Returns contains the edit types that have already been (requested and) - * calculated (edit types get calculated only when needed to save time) - * @return contains the edit types that have already been (requested and) - */ - public int getActiveEditType() { - return activeEditType; - } - - /** - * Sets contains the edit types that have already been (requested and) - * calculated (edit types get calculated only when needed to save time) - * @param newType contains the edit types that have already been (requested and) - */ - public void setActiveEditType(final int newType) { - activeEditType = newType; - } - - /** - * Checks if the given edit type is active or not - * @param checkType edit type - * @return true if this edit type is active - */ - public boolean hasEditType(final int checkType) { - return (activeEditType & checkType) != 0; - } - - /** - * Add edit type to the bitmask of active types. If this is a new type, it - * gets calculated for every arch on the map. Once it is calculated, we - * save that state in 'activeEditType' so we don't need to do it again. - * @param newType new edit type - */ - public void addEditType(final int newType) { - // calculate only if needed - final Dimension size = mapModel.getMapSize(); - final Point pos = new Point(); - if (!hasEditType(newType)) { - for (pos.x = 0; pos.x < size.width; pos.x++) { - for (pos.y = 0; pos.y < size.height; pos.y++) { - final Iterator<ArchObject> it = mapModel.getArchObjects(pos); - while (it.hasNext()) { - final ArchObject arch = it.next(); - // calculate the new edit type - if (arch.getRefFlag() && arch.getMapMultiHead() != null) { - // multi tails get the value from their head - arch.setEditType(arch.getMapMultiHead().calculateEditType(newType)); - } else { - arch.calculateEditType(newType); - } - } - } - } - // from now on we have this type, so we don't have to calculate it again - activeEditType |= newType; - } - } - - /** - * Notifies that a view has been closed. - * @param view The view that was closed. - */ - void viewCloseNotify(final CMapViewBasic view) { - if (!levelClosing) { - mainControl.closeLevel(this, false); - } - } - - // text of map arch object! - public String getMapText() { - return mapModel.getMapText(); - } - - // text of map arch object! - public String getMapLore() { - return mapModel.getMapArchObject().getLore(); - } - - /** - * Handles the given error. - * @param error a generic error - */ - public void handleErrors(final GridderException error) { - mainControl.handleErrors(error); - } - - /** - * Shows the given message in the UI. - * @param strTitle The title of the message. - * @param strMessage The message to be shown. - */ - protected void showMessage(final String strTitle, final String strMessage) { - mainControl.showMessage(strTitle, strMessage); - } - - /** Refreshes the state of menu items and toolbar buttons. */ - void refreshMenusAndToolbars() { - mainControl.refreshMenusAndToolbars(); - } - - void levelCloseNotify() { - levelClosing = true; - mapModel.levelCloseNotify(); - } - - /** @return true when this map has been closed */ - public boolean isClosing() { - return levelClosing; - } - - void freeMapArchObject() { - mapModel.freeMapArchObject(); - } - - boolean addArchToMap(final int archnr, final Point pos, final int intern, final boolean join, final boolean insertBelow) { - return mapModel.addArchToMap(archnr, pos, intern, join, insertBelow); - } - - /** wrapper method for addArchToMap, always inserting new arches on top */ - public boolean addArchToMap(final int archnr, final Point pos, final int intern, final boolean join) { - return addArchToMap(archnr, pos, intern, join, false); - } - - /** wrapper method for addArchToMap, always inserting new arches on top. - * @param archnr - * @param xx - * @param yy - * @param intern - * @param join - * @return <code>true</code> if insertion is successful, <code>false</code> if not - * @deprecated use {@link #addArchToMap(int, Point, int, boolean)} instead - */ - @Deprecated public boolean addArchToMap(final int archnr, final int xx, final int yy, final int intern, final boolean join) { - return addArchToMap(archnr, new Point(xx, yy), intern, join, false); - } - - public boolean insertArchToMap(final ArchObject newarch, final int archnr, final ArchObject next, final Point pos, final boolean join) { - return mapModel.insertArchToMap(newarch, archnr, next, pos, join); - } - - public void addArchObjectToMap(final ArchObject arch, final boolean insertBelow) { - mapModel.addArchObjectToMap(arch, insertBelow); - } - - public void addArchObjectToMap(final ArchObject arch) { - mapModel.addArchObjectToMap(arch, false); - } - - public void deleteMapArch(final int index, final Point pos, final boolean refreshMap, final boolean join) { - mapModel.deleteMapArch(index, pos, refreshMap, join); - } - - public ArchObject getMapArch(final int index, final Point pos) { - return mapModel.getMapArch(index, pos); - } - - public String getMapTilePath(final int direction) { - return mapModel.getMapArchObject().getTilePath(direction); - } - - public ArchObjectIterator getArchObjects(final Point pos) { - return mapModel.getArchObjects(pos); - } - - public ArchObjectIteratorDeleteMapArch getArchObjectsDeleteMapArch(final Point pos, final boolean refreshMap, final boolean join) { - return mapModel.getArchObjectsDeleteMapArch(pos, refreshMap, join); - } - - public boolean containsArchObject(final Point pos) { - return mapModel.containsArchObject(pos); - } - - @Deprecated public boolean containsArchObject(final int x, final int y) { - return containsArchObject(new Point(x, y)); - } - - public ArchObject getBottomArchObject(final Point pos) { - return mapModel.getBottomArchObject(pos); - } - - public ArchObject getTopArchObject(final Point pos) { - return mapModel.getTopArchObject(pos); - } - - public void setArchObject(final Point pos, final ArchObject arch) { - mapModel.setArchObject(pos, arch); - } - - /** - * Returns whether the level has changed since it was last saved or not. - * @return True if level has changed, false if not. - */ - boolean isLevelChanged() { - return mapModel.isLevelChanged(); - } - - /** - * Returns whether the level can be just saved (true) or does it need - * to be saved as (false). - * @return True if level can be just saved, false if not. - */ - boolean isPlainSaveEnabled() { - return mainControl.getCurrentMap().getMapFileName() != null && - mainControl.getCurrentMap().getMapFileName().compareTo(IGUIConstants.DEF_MAPFNAME) != 0; - } - - /** - * Set the properties (name, maptext and size) of this map. - * @param archText map text - * @param loreText lore text - * @param strMapTitle map name - * @param newSize size of map - */ - protected void setProperties(final String archText, final String loreText, String strMapTitle, final Dimension newSize) { - // resize this map - if (!newSize.equals(getMapSize())) { - resizeMap(newSize); - } - - setNewMapText(archText); // change map text - setNewLoreText(loreText); // change lore text - - // change map name (does not change the filename anymore) - strMapTitle = strMapTitle.trim(); - setMapName(strMapTitle); - - notifyViews(); // update - } - - /** Undoes a change in the level. */ - void undo() { - CUndoStack.getInstance(this).undo(); - } - - /** Redoes a change in the level. */ - void redo() { - CUndoStack.getInstance(this).redo(); - } - - /** - * Returns the name of the undo operation. - * @return Name of the undo operation. - */ - public String getUndoName() { - return CUndoStack.getInstance(this).getUndoName(); - } - - /** - * Returns the name of the redo operation. - * @return Name of the redo operation. - */ - public String getRedoName() { - return CUndoStack.getInstance(this).getRedoName(); - } - - /** - * Returns whether undo is possible or not. - * @return True if undo is possible, false if not possible. - */ - boolean isUndoPossible() { - return CUndoStack.getInstance(this).canUndo(); - } - - /** - * Returns whether redo is possible or not. - * @return True if redo is possible, false if not possible. - */ - boolean isRedoPossible() { - return CUndoStack.getInstance(this).canRedo(); - } - - /** Repaints the view. */ - void repaint() { - mapView.modelChanged(); - } - - /** Notifies the view that data has changed in the model. */ - void notifyViews() { - mapView.refreshDataFromModel(); - } - - /** - * Returns the map size of the mapModel. - * @return map size - */ - public Dimension getMapSize() { - return mapModel.getMapSize(); - } - - /** - * Returns the width of the level. - * @return map width - * @deprecated use {@link #getMapSize()} instead. - */ - @Deprecated public int getMapWidth() { - return getMapSize().width; - } - - /** - * Returns the height of the level. - * @return map height - * @deprecated use {@link #getMapSize()} instead. - */ - @Deprecated public int getMapHeight() { - return getMapSize().height; - } - - /** - * Return the current view position. - * @return the current view position - */ - public Point getViewPosition() { - return mapView.getViewPosition(); - } - - /** - * Returns the width of the level + neighbors tile maps if any. - * @return global width - */ - // TODO implement this - int getDisplayMapWidth() { - if (showTiles) { - return mapModel.getMapSize().width + eastWidth + westWidth; - } else { - return mapModel.getMapSize().width; - } - } - - /** - * Returns the height of the level + neighbors tile maps if any. - * @return global height - */ - int getDisplayMapHeight() { - if (showTiles) { - return mapModel.getMapSize().height + northHeight + southHeight; - } else { - return mapModel.getMapSize().height; - } - } - - boolean isTileShow() { - return showTiles; - } - - void setTileShow(final boolean show) { - showTiles = show; - if (show) { - /*Do the tile maps loading :)*/ - final String north = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_NORTH); - final String west = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_WEST); - final String east = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_EAST); - final String south = mapModel.getMapArchObject().getTilePath(MapArchObject.TILE_SOUTH); - /*tileModel = new CMapModel[8]; - CMapFileDecode loader; - CMapControl tmp; - loader = new CMapFileDecode(); - loader.decodeMapFile() - tmp = new CMapControl() - tileModel[1] = new CMapModel()*/ - } - } - - @Deprecated public boolean pointValid(final int posx, final int posy) { - return pointValid(new Point(posx, posy)); - } - - /** - * Check if the coordinates posx, posy are valid (located within the - * borders of the map). - * @param pos coordinate to check - * @return true if this point is located within the map boundaries - */ - public boolean pointValid(final Point pos) { - return mapModel.pointValid(pos); - } - - public boolean checkResizeMap(final Dimension dim) { - return mapModel.checkResizeMap(dim); - } - - /** - * Resize the map. - * @param size the new level size. - */ - void resizeMap(final Dimension size) { - mapModel.resizeMap(size); - } - - /** @return The level name. */ - public String getMapName() { - return mapModel.getMapName(); - } - - /** @return The level name without attached music string */ - public String getMapNameWithoutMusic() { - return mapModel.getMapNameWithoutMusic(); - } - - /** - * Sets the level name. - * @param strName The level name. - */ - public void setMapName(final String strName) { - mapModel.setMapName(strName); - } - - public String getMapFileName() { - return mapModel.getFileName(); - } - - public void setMapFileName(final String fname) { - mapView.setTitle("Map [" + fname + "]"); - mapModel.setFileName(fname); - } - - public void setNewMapText(final String str) { - mapModel.setNewMapText(str); - } - - public void setNewLoreText(final String str) { - mapModel.getMapArchObject().setLore(str); - } - - public void setLevelChangedFlag() { - mapModel.setLevelChangedFlag(); - } - - /** Saves the level to a file. */ - public void save() { - if (isPickmap()) { - CMainStatusbar.getInstance().setText("Saving pickmap '" + getMapFileName() + "'..."); - } else { - CMainStatusbar.getInstance().setText("Saving map '" + getMapFileName() + "'..."); - } - mainControl.encodeMapFile(mapFile, mapModel); - mapModel.resetLevelChangedFlag(); - mapView.changedFlagNotify(); - } - - /** - * Saves the file with the given file name. - * @param file The file to be saved to. - */ - void saveAs(final File file) { - CMainStatusbar.getInstance().setText("Saving the map to a file..."); - mainControl.encodeMapFile(file, mapModel); - mapModel.resetLevelChangedFlag(); - mapView.changedFlagNotify(); - } - - void setMapFile(final File file) { - mapFile = file; - } - - public CMapModel getMapModel() { - return mapModel; - } - - public CMapViewIFrame getMapView() { - return mapView; - } - - public File getMapFile() { - return mapFile; - } -} Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-06-11 15:20:57 UTC (rev 143) @@ -25,6 +25,7 @@ package cfeditor; import cfeditor.arch.ArchObject; +import cfeditor.map.MapArchObject; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; Modified: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-06-11 15:20:57 UTC (rev 143) @@ -25,6 +25,8 @@ package cfeditor; import cfeditor.arch.ArchObject; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapModel; import java.awt.Dimension; import java.awt.Point; import java.io.BufferedReader; @@ -66,7 +68,7 @@ * @param file mapfile * @param mapModel the MapModel to encode */ - public void encodeMapFile(File file, final CMapModel mapModel) { + public void encodeMapFile(File file, final MapModel mapModel) { final MapArchObject map = mapModel.getMapArchObject(); try { Deleted: trunk/crossfire/src/cfeditor/CMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapModel.java 2006-06-11 14:21:34 UTC (rev 142) +++ trunk/crossfire/src/cfeditor/CMapModel.java 2006-06-11 15:20:57 UTC (rev 143) @@ -1,1228 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import cfeditor.arch.ArchObject; -import cfeditor.arch.ArchObjectIterator; -import cfeditor.arch.ArchObjectIteratorDeleteArchMapObject; -import cfeditor.arch.ArchObjectIteratorDeleteMapArch; -import cfeditor.filter.Filter; -import cfeditor.filter.FilterConfig; -import cfeditor.filter.NamedFilterConfig; -import cfeditor.filter.NamedFilterList; -import java.awt.Point; -import java.awt.Dimension; -import java.util.Iterator; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.Nullable; - -/** - * The level model that represents a level. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMapModel { - - private static final Logger log = Logger.getLogger(CMapModel.class); - - /** Enable autojoin when inserting objects. */ - public static final boolean JOIN_ENABLE = true; - - /** Disable autojoin when inserting objects. */ - public static final boolean JOIN_DISABLE = false; - - /** The MapArchObject; it contains global map attributes. */ - private MapArchObject m_mapArch = null; - - /** - * Level grid data. Contains all arches grid-wise. Its size is - * m_mapGrid[m_mapWidth][m_mapHeight]. Can never be null. - */ - private ArchObject[][] m_mapGrid; - - /** Size of this map. */ - private final Dimension mapSize = new Dimension(); - - /** Flag that indicates if the level has been changed since last save. */ - private boolean m_fLevelChanged = false; - - /** The main controller. Is never null. */ - private final CMainControl mainControl; - - /** The controller of this view. Is never null. */ - private final CMapControl mapControl; - - /** - * Constructs a level model. - * @param mainControl main controller - * @param control the controller of this view - * @param map the map header - */ - public CMapModel(final CMainControl mainControl, final CMapControl control, final MapArchObject map) { - this.mainControl = mainControl; - mapControl = control; - mapSize.setSize(map.getMapSize()); - - m_mapGrid = initMap(); - - m_mapArch = map; - - m_mapArch.setMapSize(mapSize); - } - - /** - * Return the first object (last in the object list) to display in the - * map-tiles panel. - * @return the ArchObject to show; the object(s) must not be modified - */ - @Nullable public ArchObject getMouseRightPosObject() { - final Point pos = mapControl.getMapView().getMapMouseRightPos(); - - if (pos.x == -1 || pos.y == -1 || !pointValid(pos)) { - return null; - } - - return m_mapGrid[pos.x][pos.y]; - } - - /** - * Update the map description text. - * @param str the new description text - */ - public void setNewMapText(final String str) { - m_mapArch.resetText(); - m_mapArch.addText(str); - } - - /** - * Return the map description text. - * @return the map description text - */ - public String getMapText() { - return m_mapArch.getText(); - } - - /** - * Place a list of arches onto the map. - * @param arch the head of the arches list; may be null to insert nothing - */ - public void addArchListToMap(ArchObject arch) { - while (arch != null) { - if (arch.getContainer() == null) { // only map arches.... - addArchObjectToMap(arch, false); - } - - arch = arch.getTemp(); - } - } - - /** Notifies that the application is about to exit. */ - public void appExitNotify() { - } - - /** Notifies that the level is about to be closed. */ - public void levelCloseNotify() { - freeMapArchObject(); - } - - /** Reset the level changed flag to false. */ - public void resetLevelChangedFlag() { - if (!m_fLevelChanged) { - return; - } - - // change status and update title bar - m_fLevelChanged = false; - if (mapControl.getMapView() != null) { - mapControl.getMapView().changedFlagNotify(); - } - } - - /** Set the level changed flag to true. */ - public void setLevelChangedFlag() { - if (m_fLevelChanged) { - return; - } - - // change status and update title bar - m_fLevelChanged = true; - if (mapControl.getMapView() != null) { - mapControl.getMapView().changedFlagNotify(); - } - - // enable menu file->revert to revert the map - if (mainControl.getCurrentMap() == mapControl) { - mainControl.getMainView().setRevertMenuEnabled(true); - } - } - - /** - * Return whether the level has changed since it was last saved. - * @return true=level has changed - */ - public boolean isLevelChanged() { - return m_fLevelChanged; - } - - /** - * Return the width of the level. - * @return the width of the level - */ - @Deprecated public int getMapWidth() { - return mapSize.width; - } - - /** - * Returns the height of the level. - * @return The height of the level. - */ - @Deprecated public int getMapHeight() { - return mapSize.height; - } - - /** Return the map size of this level. - * @return Map size of this level. - */ - public Dimension getMapSize() { - return mapSize; - } - - /** - * Return the bottom {@link ArchObject} in the given location. - * @return the ArchObject, or null if no object is present - */ - @Deprecated @Nullable public ArchObject getBottomArchObject(final int x, final int y) { - return getBottomArchObject(new Point(x, y)); - } - - /** - * Return the bottom {@link ArchObject} in the given location. - * @return the ArchObject, or null if no object is present - */ - @Nullable public ArchObject getBottomArchObject(final Point pos) { - if (!pointValid(pos)) { - return null; - } - - return m_mapGrid[pos.x][pos.y]; - } - - @Deprecated public ArchObject getTopArchObject(final int x, final int y) { - return getTopArchObject(new Point(x, y)); - } - - /** - * Return the topmost {@link ArchObject} in the given location. - * @return the ArchObject, or null if no object is present - */ - public ArchObject getTopArchObject(final Point pos) { - ArchObject result = getBottomArchObject(pos); - while (result != null && result.getNextArch() != null) { - result = result.getNextArch(); - } - return result; - } - - @Deprecated public void setArchObject(final int x, final int y, final ArchObject arch) { - setArchObject(new Point(x, y), arch); - } - - /** Save a map square to the given ArchObject. */ - public void setArchObject(final Point pos, final ArchObject arch) { - if (!pointValid(pos)) { - throw new IllegalArgumentException(); - } - if (arch == null) { - throw new IllegalArgumentException(); - } - - m_mapGrid[pos.x][pos.y] = arch; - } - - /** - * Return an Iterator of all ArchObjects in the given location. The - * Iterator supports deleting objects. - */ - @Deprecated public ArchObjectIteratorDeleteMapArch getArchObjectsDeleteMapArch(final int x, final int y, final boolean refreshMap, final boolean join) { - return getArchObjectsDeleteMapArch(new Point(x, y), refreshMap, join); - } - - /** - * Return an Iterator of all ArchObjects in the given location. The - * Iterator supports deleting objects. - */ - public ArchObjectIteratorDeleteMapArch getArchObjectsDeleteMapArch(final Point pos, final boolean refreshMap, final boolean join) { - return new ArchObjectIteratorDeleteMapArch(this, getBottomArchObject(pos), pos.x, pos.y, refreshMap, join); - } - - /** - * Return an Iterator of all ArchObjects in the given location. The - * Iterator supports deleting objects. - */ - public ArchObjectIteratorDeleteArchMapObject getArchObjectsDeleteArchMapObject(final Point pos) { - return new ArchObjectIteratorDeleteArchMapObject(this, getBottomArchObject(pos)); - } - - /** Return an Iterator of all ArchObjects in the given location. */ - @Deprecated public ArchObjectIterator getArchObjects(final int x, final int y) { - return getArchObjects(new Point(x, y)); - } - /** Return an Iterator of all ArchObjects in the given location. */ - public ArchObjectIterator getArchObjects(final Point pos) { - return new ArchObjectIterator(getBottomArchObject(pos)); - } - - /** Check whether a given location contains at least one ArchObject. */ - @Deprecated public boolean containsArchObject(final int x, final int y) { - return containsArchObject(new Point(x, y)); - } - - /** Check whether a given location contains at least one ArchObject. */ - public boolean containsArchObject(final Point pos) { - return pointValid(pos) && m_mapGrid[pos.x][pos.y] != null; - } - - /** - * Create an empty map grid. - * @return the empty map grid - */ - private ArchObject[][] initMap() { - final ArchObject[][] map = new ArchObject[mapSize.width][mapSize.height]; - for (int y = 0; y < mapSize.height; y++) { - for (int x = 0; x < mapSize.width; x++) { - map[x][y] = null; - } - } - - return map; - } - - /** - * Check if a given archetype fits within map bounds. Multi tiles can't be - * set if going out of borders. - * @param archnr the archetype to check - * @param xx the x-coordinate to place archnr - * @param yy the y-coordinate to place archnr - * @param intern ??? - */ - private boolean testArchToMap(final int archnr, final int xx, final int yy, final int intern) { - final int count = mainControl.getArchObjectStack().getArch(archnr).getRefCount(); // count of multi tile. 0= single tile - - for (int c = 0; c <= count; c++) { - final int mapx = xx + mainControl.getArchObjectStack().getArch(archnr + c).getRefX(); - final int mapy = yy + mainControl.getArchObjectStack().getArch(archnr + c).getRefY(); - if (mapx < 0 || mapy < 0 || mapx >= mapSize.width|| mapy >= mapSize.height) { - // outside map - return false; - } - - final int temp; - if (intern != -1) { // we use this different - only one object - temp = archnr + c; // of one type on a map position when dragged - } else { - temp = -1; - } - - // run through map parts and test for intern counter - // if == intern, this is painted from this action - final Iterator it = getArchObjects(mapx, mapy); - while (it.hasNext()) { - final ArchObject node = (ArchObject) it.next(); - if (node.getNodeNr() == temp) { - return false; - } - } - } - - return true; - } - - /** - * Move the given arch up on the map. (Note that this actually means moving - * "down" in the linked list). - * @param prev arch to be moved - * @param refresh if true, map and panel get refreshed - */ - public void moveTileUp(final ArchObject prev, final boolean refresh) { - if (prev == null) { - return; - } - - if (prev.getContainer() != null) { - return; - } - - final ArchObject arch = prev.getNextArch(); - if (arch == null) { - return; - } - - prev.setNextArch(arch.getNextArch()); - arch.setPrevArch(prev.getPrevArch()); - arch.setNextArch(prev); - prev.setPrevArch(arch); - if (prev.getNextArch() != null) { - prev.getNextArch().setPrevArch(prev); - } - if (arch.getPrevArch() != null) { - arch.getPrevArch().setNextArch(arch); - } else { - m_mapGrid[arch.getMapX()][arch.getMapY()] = arch; - } - - arch.propagateElevation(prev); - - if (refresh) { - mainControl.refreshCurrentMap(); - } - } - - /** - * Move the given arch down on the map. (Note that this actually means - * moving "up" in the linked list) - * @param arch arch to be moved - * @param refresh if true, map and panel get refreshed - */ - public void moveTileDown(final ArchObject arch, final boolean refresh) { - if (arch == null) { - return; - } - - if (arch.getContainer() != null) { - return; - } - - final ArchObject prev = arch.getPrevArch(); - if (prev == null) { - return; - } - - prev.setNextArch(arch.getNextArch()); - arch.setPrevArch(prev.getPrevArch()); - arch.setNextArch(prev); - prev.setPrevArch(arch); - if (prev.getNextArch() != null) { - prev.getNextArch().setPrevArch(prev); - } - if (arch.getPrevArch() != null) { - arch.getPrevArch().setNextArch(arch); - } else { - m_mapGrid[arch.getMapX()][arch.getMapY()] = arch; - } - - arch.propagateElevation(prev); - - if (refresh) { - mainControl.refreshCurrentMap(); - } - } - - @Deprecated public boolean addArchToMap(final int archnr, final int xx, final int yy, final int intern, final boolean join, final boolean insert_below) { - return addArchToMap(archnr, new Point(xx, yy), intern, join, insert_below); - } - - /** - * Add a new arch to the map. Including multi tile arches. This function - * allows only to choose from the default arches (->archnr). - * @param archnr ID from a default arch on the ArchObjectStack - * @param pos insert-location on this map - * @param intern if NOT '-1': only one arch of the same kind can be - * inserted per square - * @param join if set to JOIN_ENABLE auto-joining is supported; autojoining - * is only done if enabled in the main control - * @param insert_below true: new arch is inserted on top, false: new arch is - * inserted below - * @return true if insertion successful, false if not - */ - public boolean addArchToMap(int archnr, final Point pos, final int intern, final boolean join, final boolean insert_below) { - ArchObject newarch, oldarch, startarch; // our new suckers (copys, not ref ptrs) - - if (archnr < 0 || archnr >= mainControl.getArchObjectStack().getArchCount() - || pos.x == -1 || pos.y == -1 || pos.x >= mapSize.width|| pos.y >= mapSize.height) { - // invalid parameter - return false; - } - if (!testArchToMap(archnr, pos.x, pos.y, intern)) { - // does not fit on map - return false; - } - - newarch = mainControl.getArchObjectStack().getArch(archnr); // temp. store this arch - if (mainControl.getAutojoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null - && newarch.getJoinList() != null && !newarch.isMulti()) { - // do autojoining if enabled - archnr = newarch.getJoinList().joinInsert(this, pos.x, pos.y); - if (archnr == -1) { - return false; // only one autojoin type per square allowed - } - } - - final int count = mainControl.getArchObjectStack().getArch(archnr).getRefCount(); // count of multi tile. 0= single tile - - oldarch = null; - startarch = null; - for (int c = 0; c <= count; c++) { - final int mapx = pos.x + mainControl.getArchObjectStack().getArch(archnr + c).getRefX(); - final int mapy = pos.y + mainControl.getArchObjectStack().getArch(archnr + c).getRefY(); - newarch = mainControl.getArchObjectStack().newArchObjectInstance(archnr + c); - if (oldarch != null) { - newarch.setMapMultiHead(startarch); - oldarch.setMapMultiNext(newarch); - } else { - startarch = newarch; - } - oldarch = newarch; - - // insert ít in map or add to arch in map - ArchObject node = m_mapGrid[mapx][mapy]; - if (node == null) { - m_mapGrid[mapx][mapy] = newarch; - m_mapGrid[mapx][mapy].setMapX(mapx); - m_mapGrid[mapx][mapy].setMapY(mapy); - } else { - if (!insert_below) { - // if we want to insert on top, we need to get last node element - for (int i = 0; node.getNextArch() != null; i++) { - node = node.getNextArch(); - } - - node.setNextArch(newarch); - node.getNextArch().setPrevArch(node); - node.getNextArch().setMapX(mapx); - node.getNextArch().setMapY(mapy); - } else { - //ArchObject tmp = node; - node.setPrevArch(newarch); - newarch.setNextArch(node); - m_mapGrid[mapx][mapy] = newarch; - newarch.setMapX(mapx); - newarch.setMapY(mapy); - newarch.propagateElevation(node); - } - } - - mainControl.getArchObjectParser().postParseMapArch(newarch, mapControl.getActiveEditType()); - } - - // Level data has changed - setLevelChangedFlag(); - return true; - } - - @Deprecated public boolean insertArchToMap(final ArchObject newarch, final int archnr, final ArchObject next, final int mapx, final int mapy, fin... [truncated message content] |
From: <der...@us...> - 2006-06-17 10:13:03
|
Revision: 161 Author: derdanny Date: 2006-06-17 03:12:54 -0700 (Sat, 17 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=161&view=rev Log Message: ----------- Moved selection related code from MouseOpAdapter to SelectionTool. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-06-17 08:54:15 UTC (rev 160) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-06-17 10:12:54 UTC (rev 161) @@ -224,14 +224,14 @@ mapDesktop = new JDesktopPane(); mapArchPanel = new CMapArchPanel(mainControl, this); - if (!mapTileListBottom) { + if (mapTileListBottom) { + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileList); + splitRightPane.setDividerLocation(divLocationRight); + splitDownPane = new GSplitPane(VERTICAL_SPLIT, mapDesktop, splitRightPane); + } else { splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileList); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, splitRightPane, mapArchPanel); - } else { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileList); - splitRightPane.setDividerLocation(divLocationRight); - splitDownPane = new GSplitPane(VERTICAL_SPLIT, mapDesktop, splitRightPane); } splitDownPane.setDividerLocation(divLocationDown); splitPane = new GSplitPane(HORIZONTAL_SPLIT, archPanel, splitDownPane); @@ -276,7 +276,7 @@ */ @Nullable public ArchObject getArchPanelHighlight() { - if ((isPickmapActive() || archPanel.getArchPanelSelection() == null) + if ((pickmapActive || archPanel.getArchPanelSelection() == null) && CPickmapPanel.getInstance().isLoadComplete() && CPickmapPanel.getInstance().getCurrentPickmap() != null) { // get the active pickmap Modified: trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2006-06-17 08:54:15 UTC (rev 160) +++ trunk/daimonin/src/daieditor/gui/map/event/MouseOpAdapter.java 2006-06-17 10:12:54 UTC (rev 161) @@ -8,6 +8,7 @@ * Event Listener Adapater for {@link MouseOpListener}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ +@SuppressWarnings({"NoopMethodInAbstractClass"}) public abstract class MouseOpAdapter implements MouseOpListener { /** {@inheritDoc} */ @@ -32,21 +33,6 @@ /** {@inheritDoc} */ public void released(final MouseOpEvent e) { - final MapCursor mapCursor = e.getMapCursor(); - final int modifiers = e.getModifiers(); - if (mapCursor.isOnGrid(e.getMapLocation())) { - if ((modifiers & InputEvent.SHIFT_MASK) != 0) { - if ((modifiers & InputEvent.CTRL_MASK) != 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.ADD); - } else { - mapCursor.dragSelect(MapGrid.SelectionMode.SUB); - } - } else { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); - } - } else { - mapCursor.dragRelease(); - } } } // class MouseOpAdapter Modified: trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2006-06-17 08:54:15 UTC (rev 160) +++ trunk/daimonin/src/daieditor/gui/map/tools/SelectionTool.java 2006-06-17 10:12:54 UTC (rev 161) @@ -6,6 +6,7 @@ import java.awt.Point; import java.awt.event.InputEvent; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; /** MouseOpListener for selection */ public class SelectionTool extends BasicAbstractTool { @@ -46,4 +47,23 @@ e.getMapCursor().dragTo(e.getMapLocation()); } + /** {@inheritDoc} */ + @Override public void released(final MouseOpEvent e) { + final MapCursor mapCursor = e.getMapCursor(); + final int modifiers = e.getModifiers(); + if (mapCursor.isOnGrid(e.getMapLocation())) { + if ((modifiers & InputEvent.SHIFT_MASK) == 0) { + mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + } else { + if ((modifiers & InputEvent.CTRL_MASK) == 0) { + mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } + } + } else { + mapCursor.dragRelease(); + } + } + } // class SelectionTool Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2006-06-17 08:54:15 UTC (rev 160) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2006-06-17 10:12:54 UTC (rev 161) @@ -43,7 +43,7 @@ /** Create a ToolSelector component. */ public ToolSelector() { createUI(); - final Tool voidTool = new VoidTool(); + @NotNull final Tool voidTool = new VoidTool(); selectedTool = voidTool; add(voidTool, true); setSelectedTool(voidTool); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-06-25 13:26:27
|
Revision: 187 Author: akirschbaum Date: 2006-06-25 06:25:39 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=187&view=rev Log Message: ----------- Store map size in a Size2D instance; remove deprecated functions; unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CNewMapDialog.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CMapFileEncode.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CNewMapDialog.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapModel.java trunk/src/app/net/sf/gridarta/gui/map/MapGrid.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/Size2D.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import static net.sf.japi.swing.ActionFactory.getFactory; import cfeditor.arch.ArchObject; import cfeditor.arch.ArchObjectParser; @@ -37,7 +38,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; -import java.awt.Dimension; import java.io.File; import java.io.IOException; import java.util.Enumeration; @@ -1306,7 +1306,7 @@ * @param strMapTitle map name * @param mapSize size of map */ - void setLevelProperties(final MapControl level, final String archText, final String loreText, final String strMapTitle, final Dimension mapSize) { + void setLevelProperties(final MapControl level, final String archText, final String loreText, final String strMapTitle, final Size2D mapSize) { if (level != null) { level.setProperties(archText, loreText, strMapTitle, mapSize); refreshMenusAndToolbars(); Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-06-25 13:25:39 UTC (rev 187) @@ -115,12 +115,7 @@ // finally... here we go // last action: if the map is bigger than the specified size in // the maparch, we set the true size: the maxxlen/maxylen counters. - if (maparch.getWidth() < maxxlen + 1) { - maparch.setWidth(maxxlen + 1); - } - if (maparch.getHeight() < maxylen + 1) { - maparch.setHeight(maxylen + 1); - } + maparch.ensureMapSize(maxxlen + 1, maxylen + 1); return start; // return first arch of the list } Modified: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.map.MapArchObject; import cfeditor.map.MapModel; @@ -87,10 +88,10 @@ map.writeMapArch(bufferedWriter); // first, write all one tile parts - final Dimension size = map.getMapSize(); + final Size2D mapSize = map.getMapSize(); final Point pos = new Point(); - for (pos.x = 0; pos.x < size.width; pos.x++) { - for (pos.y = 0; pos.y < size.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { final Iterator it = mapModel.getArchObjects(pos); while (it.hasNext()) { final ArchObject node = (ArchObject) it.next(); @@ -105,8 +106,8 @@ } // x // second, we drop the multi part suckers out - for (pos.x = 0; pos.x < size.width; pos.x++) { - for (pos.y = 0; pos.y < size.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { final Iterator it = mapModel.getArchObjects(pos); while (it.hasNext()) { final ArchObject node = (ArchObject) it.next(); Modified: trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import java.awt.BorderLayout; @@ -187,9 +188,9 @@ createPanelLine(mapPanel, m_nameField, 16, m_level.getMapName(), "Name: "); createPanelLine(mapPanel, m_regionField, 16, map.getMapRegion(), "Region: "); - final Dimension mapSize = m_level.getMapSize(); - createPanelLine(mapPanel, m_levelWidthField, 10, String.valueOf(mapSize.width), "Width: "); - createPanelLine(mapPanel, m_levelHeightField, 10, String.valueOf(mapSize.height), "Height: "); + final Size2D mapSize = m_level.getMapSize(); + createPanelLine(mapPanel, m_levelWidthField, 10, String.valueOf(mapSize.getWidth()), "Width: "); + createPanelLine(mapPanel, m_levelHeightField, 10, String.valueOf(mapSize.getHeight()), "Height: "); createPanelCBox(mapPanel, m_unique, map.isUnique(), " Unique Map"); createPanelCBox(mapPanel, m_outdoor, map.isOutdoor(), " Outdoor Map"); createPanelCBox(mapPanel, m_fixedReset, map.isFixedReset(), " Fixed Reset"); @@ -452,7 +453,7 @@ boolean modifyTilepaths = false; // true when map tile-paths were modified // tmp variables for parsing - final Dimension size = new Dimension(); + final int width, height; final int t_enter_x, t_enter_y; final int t_reset_timeout, t_swap_time; final int t_difficulty, t_darkness; @@ -466,8 +467,8 @@ // first check if the entries are all okay try { // try to parse everything - size.width = parseProperty(m_levelWidthField.getText(), "Width"); - size.height = parseProperty(m_levelHeightField.getText(), "Height"); + width = parseProperty(m_levelWidthField.getText(), "Width"); + height = parseProperty(m_levelHeightField.getText(), "Height"); t_enter_x = parseProperty(m_enterX.getText(), "Enter X"); t_enter_y = parseProperty(m_enterY.getText(), "Enter Y"); t_swap_time = parseProperty(m_swapTime.getText(), "Swap Time"); @@ -503,7 +504,7 @@ } // Now do some sanity checks: - if (size.width < 1 || size.height < 1) { + if (width < 1 || height < 1) { mainControl.showMessage( "Illegal Value", "Level dimensions must be greater than zero."); @@ -527,10 +528,11 @@ } // if the mapsize has been modified, see if we should ask for a confirm + Size2D size = new Size2D(width, height); if (m_level.checkResizeMap(size)) { if (!askConfirmResize(size)) { // resizing has been cancelled - size.setSize(m_level.getMapSize()); + size = m_level.getMapSize(); } } @@ -666,9 +668,9 @@ m_loreArea.setText(m_level.getMapLore()); m_nameField.setText(m_level.getMapName()); m_regionField.setText("" + map.getMapRegion()); - final Dimension mapSize = map.getMapSize(); - m_levelWidthField.setText(String.valueOf(mapSize.width)); - m_levelHeightField.setText(String.valueOf(mapSize.height)); + final Size2D mapSize = map.getMapSize(); + m_levelWidthField.setText(String.valueOf(mapSize.getWidth())); + m_levelHeightField.setText(String.valueOf(mapSize.getHeight())); m_enterX.setText("" + map.getEnterX()); m_enterY.setText("" + map.getEnterY()); m_swapTime.setText("" + map.getSwapTime()); @@ -715,9 +717,9 @@ * popup dialog disables all other windows (and threads). * @return true if user confirmed, false if user cancelled resize */ - private boolean askConfirmResize(final Dimension size) { + private boolean askConfirmResize(final Size2D size) { return JOptionPane.showConfirmDialog(this, - "You selected a new map size of " + size.width + "x" + size.height + ". If the map was\n" + + "You selected a new map size of " + size.getWidth() + "x" + size.getHeight() + ". If the map was\n" + "resized in this way, some objects would get cut off and deleted.\n" + "Are you really sure you want this?", "Confirm", Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.arch.ArchObjectStack; import cfeditor.filter.AttributeFilter; @@ -88,7 +89,7 @@ private final CMainControl mainControl; /** Size of the map. */ - private final Dimension mapSize = new Dimension(); + private Size2D mapSize = new Size2D(1, 1); /** The tile palette renderer. */ private final CLevelRenderer renderer; @@ -369,16 +370,16 @@ void refreshDataFromModel() { final Dimension forcedSize; - mapSize.setSize(mapControl.getMapSize()); + mapSize = mapControl.getMapSize(); log.debug("refreshDataFromModel"); // define how much drawing space we need for the map if (IGUIConstants.isoView) { forcedSize = new Dimension( - (isPickmap() ? 3 + 2 * IGUIConstants.TILE_ISO_YLEN : mapSize.height * IGUIConstants.TILE_ISO_YLEN) + mapSize.width * IGUIConstants.TILE_ISO_YLEN + IGUIConstants.TILE_ISO_XLEN, - ((isPickmap() ? Math.max(mapSize.height - 2, 0) : mapSize.height) * IGUIConstants.TILE_ISO_YLEN + (mapSize.width - mapSize.height) * IGUIConstants.TILE_ISO_YLEN2) + 1 + IGUIConstants.TILE_ISO_XLEN); + (isPickmap() ? 3 + 2 * IGUIConstants.TILE_ISO_YLEN : mapSize.getHeight() * IGUIConstants.TILE_ISO_YLEN) + mapSize.getWidth() * IGUIConstants.TILE_ISO_YLEN + IGUIConstants.TILE_ISO_XLEN, + ((isPickmap() ? Math.max(mapSize.getHeight() - 2, 0) : mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN + (mapSize.getWidth() - mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN2) + 1 + IGUIConstants.TILE_ISO_XLEN); } else { - forcedSize = new Dimension(mapSize.width * 32 + (isPickmap() ? 0 : 64), mapSize.height * 32 + (isPickmap() ? 0 : 64)); + forcedSize = new Dimension(mapSize.getWidth() * 32 + (isPickmap() ? 0 : 64), mapSize.getHeight() * 32 + (isPickmap() ? 0 : 64)); } ((JComponent) renderer).setPreferredSize(forcedSize); ((JComponent) renderer).setMinimumSize(forcedSize); @@ -678,8 +679,9 @@ public Image getFullImage() { final int storeOffset; // tmp. storage to save map offset - final int mapWidth = 32 * getMapControl().getMapWidth(); // map width for standard view - final int mapHeight = 32 * getMapControl().getMapHeight(); // map height for standard view + final Size2D mapSize = getMapControl().getMapSize(); + final int mapWidth = 32 * mapSize.getWidth(); + final int mapHeight = 32 * mapSize.getHeight(); // first create a storing place for the image final Image bufImage = new BufferedImage(mapWidth, mapHeight, BufferedImage.TYPE_INT_ARGB); @@ -741,8 +743,8 @@ // this vector contains all heads of multi-tiles with oversized images final Vector oversizedMultiHeads = new Vector(); final CFilterControl filter = mainControl.getFilterControl(); - for (int y = 0; y < mapSize.height; y++) { - for (int x = 0; x < mapSize.width; x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { filter.newSquare(); if (!_model.containsArchObject(x, y)) { // empty square @@ -800,18 +802,18 @@ // grid lines if (showMapGrid && !isSnapshot) { - for (int x = 0; x <= mapSize.width; x++) { + for (int x = 0; x <= mapSize.getWidth(); x++) { grfx.drawLine( x * 32 + bOffset, 0 + bOffset, x * 32 + bOffset, - mapSize.height * 32 + bOffset); + mapSize.getHeight() * 32 + bOffset); } - for (int y = 0; y <= mapSize.height; y++) { + for (int y = 0; y <= mapSize.getHeight(); y++) { grfx.drawLine( 0 + bOffset, y * 32 + bOffset, - mapSize.width * 32 + bOffset, + mapSize.getWidth() * 32 + bOffset, y * 32 + bOffset); } } @@ -1019,7 +1021,7 @@ final Point mpoint = new Point(); mpoint.x = mapMousePos.x; mpoint.y = mapMousePos.y; - if (point.x >= 0 && point.x < mapSize.width * 32 && point.y >= 0 && point.y < mapSize.height * 32) { + if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { mapMousePos.x = point.x / 32; mapMousePos.y = point.y / 32; @@ -1037,9 +1039,8 @@ return false; } - final Dimension size = new Dimension(getMapControl().getMapSize()); - size.width *= 32; - size.height *= 32; + final Size2D mapSize = getMapControl().getMapSize(); + final Dimension size = new Dimension(mapSize.getWidth() * 32, mapSize.getHeight() * 32); if (bufferedSize.equals(size)) { return true; } @@ -1154,10 +1155,11 @@ public Image getFullImage() { final int storeOffset; // tmp. storage to save map offset - final int mapWidth = getMapControl().getMapHeight() * IGUIConstants.TILE_ISO_YLEN - + getMapControl().getMapWidth() * IGUIConstants.TILE_ISO_YLEN + IGUIConstants.TILE_ISO_XLEN; - final int mapHeight = (getMapControl().getMapHeight() * IGUIConstants.TILE_ISO_YLEN + (getMapControl().getMapWidth() - - getMapControl().getMapHeight()) * IGUIConstants.TILE_ISO_YLEN2) + 1 + IGUIConstants.TILE_ISO_XLEN; + final Size2D mapSize = getMapControl().getMapSize(); + final int mapWidth = mapSize.getHeight() * IGUIConstants.TILE_ISO_YLEN + + mapSize.getWidth() * IGUIConstants.TILE_ISO_YLEN + IGUIConstants.TILE_ISO_XLEN; + final int mapHeight = (mapSize.getHeight() * IGUIConstants.TILE_ISO_YLEN + (mapSize.getWidth() + - mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN2) + 1 + IGUIConstants.TILE_ISO_XLEN; // first create a storing place for the image final Image bufImage = new BufferedImage(mapWidth, mapHeight, BufferedImage.TYPE_INT_ARGB); @@ -1171,7 +1173,7 @@ bOffset = 0; paintComponent(bufGrfx, true); bOffset = storeOffset; - //return bufImage.getScaledInstance(16*getMapControl().getMapWidth(), 16*getMapControl().getMapHeight(), Image.SCALE_SMOOTH); + //return bufImage.getScaledInstance(16 * mapSize.getWidth(), 16 * mapSize.getHeight(), Image.SCALE_SMOOTH); return bufImage; } @@ -1197,14 +1199,14 @@ } // ---------- draw iso map -------------- - for (int y = 0; y < mapSize.height; y++) { + for (int y = 0; y < mapSize.getHeight(); y++) { if (!isPickmap) { - xstart = (mapSize.height) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2; + xstart = (mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2; } else { xstart = 3 + 2 * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2; } ystart = y * IGUIConstants.TILE_ISO_YLEN2 + (isPickmap ? 0 : IGUIConstants.TILE_ISO_YLEN); - for (int x = 0; x < mapSize.width; x++) { + for (int x = 0; x < mapSize.getWidth(); x++) { if (!mapModel.containsArchObject(x, y)) { // empty square if (!isPickmap) { @@ -1264,23 +1266,23 @@ // draw iso grid grfx.setColor(Color.black); - for (int x = 0; x <= mapSize.width; x++) { - grfx.drawLine((mapSize.height) * IGUIConstants.TILE_ISO_YLEN + (x + 1) * IGUIConstants.TILE_ISO_XLEN2 - 1, + for (int x = 0; x <= mapSize.getWidth(); x++) { + grfx.drawLine((mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN + (x + 1) * IGUIConstants.TILE_ISO_XLEN2 - 1, IGUIConstants.TILE_ISO_YLEN + x * IGUIConstants.TILE_ISO_YLEN2 - 1, - (mapSize.height) * IGUIConstants.TILE_ISO_YLEN - (mapSize.height) * IGUIConstants.TILE_ISO_XLEN2 + (mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN - (mapSize.getHeight()) * IGUIConstants.TILE_ISO_XLEN2 + (x + 1) * IGUIConstants.TILE_ISO_XLEN2, - (mapSize.height) * IGUIConstants.TILE_ISO_YLEN2 + IGUIConstants.TILE_ISO_YLEN + (mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN2 + IGUIConstants.TILE_ISO_YLEN + x * IGUIConstants.TILE_ISO_YLEN2 - 1); } - for (int y = 0; y <= mapSize.height; y++) { - grfx.drawLine((mapSize.height) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2 + for (int y = 0; y <= mapSize.getHeight(); y++) { + grfx.drawLine((mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2 + IGUIConstants.TILE_ISO_XLEN2 - 1, y * IGUIConstants.TILE_ISO_YLEN2 + IGUIConstants.TILE_ISO_YLEN - 1, - (mapSize.height) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2 - + (mapSize.width + 1) * IGUIConstants.TILE_ISO_XLEN2, + (mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2 + + (mapSize.getWidth() + 1) * IGUIConstants.TILE_ISO_XLEN2, y * IGUIConstants.TILE_ISO_YLEN2 + IGUIConstants.TILE_ISO_YLEN - + (mapSize.width) * IGUIConstants.TILE_ISO_YLEN2 - 1); + + (mapSize.getWidth()) * IGUIConstants.TILE_ISO_YLEN2 - 1); } } if (highlightOn && mapMouseRightPos.y != -1 && mapMouseRightPos.x != -1) { @@ -1377,7 +1379,7 @@ // in Iso-View mainControl.getMapSelIconF().paintIcon(this, grfx, (isPickmap ? 3 + 2 * IGUIConstants.TILE_ISO_YLEN - posy * IGUIConstants.TILE_ISO_XLEN2 - : (mapSize.height) * IGUIConstants.TILE_ISO_YLEN - posy * IGUIConstants.TILE_ISO_XLEN2) + : (mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN - posy * IGUIConstants.TILE_ISO_XLEN2) + posx * IGUIConstants.TILE_ISO_XLEN2, posy * IGUIConstants.TILE_ISO_YLEN2 + (isPickmap ? 0 : IGUIConstants.TILE_ISO_YLEN) + posx * IGUIConstants.TILE_ISO_YLEN2); @@ -1417,14 +1419,14 @@ // most lame way to find the map point // but i can't remember the algorithm way for iso on the fly // i had done it before, but i forget - for (int y = 0; y < mapSize.height; y++) { + for (int y = 0; y < mapSize.getHeight(); y++) { if (!isPickmap) { - xstart = (mapSize.height) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2; + xstart = (mapSize.getHeight()) * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2; } else { xstart = 3 + 2 * IGUIConstants.TILE_ISO_YLEN - y * IGUIConstants.TILE_ISO_XLEN2; } ystart = y * IGUIConstants.TILE_ISO_YLEN2 + (isPickmap ? 0 : IGUIConstants.TILE_ISO_YLEN); - for (int x = 0; x < mapSize.width; x++) { + for (int x = 0; x < mapSize.getWidth(); x++) { if (point.x >= xstart && point.x < xstart + IGUIConstants.TILE_ISO_XLEN && point.y >= ystart && point.y < ystart + IGUIConstants.TILE_ISO_YLEN) { // get the offsets in the rectangle @@ -1438,8 +1440,8 @@ mapMousePos.y = y + gridMapOffset[temp][1]; // ok, now check map borders and set to -1/-1 when not in map - if (mapMousePos.x < 0 || mapMousePos.x >= mapSize.width - || mapMousePos.y < 0 || mapMousePos.y >= mapSize.height) { + if (mapMousePos.x < 0 || mapMousePos.x >= mapSize.getWidth() + || mapMousePos.y < 0 || mapMousePos.y >= mapSize.getHeight()) { mapMousePos.x = -1; mapMousePos.y = -1; mapMousePosOff.x = -1; Modified: trunk/crossfire/src/cfeditor/CNewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CNewMapDialog.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CNewMapDialog.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObjectStack; import cfeditor.map.MapArchObject; import java.awt.BorderLayout; @@ -219,29 +220,26 @@ // Create a new level from scratch final MapArchObject maparch = new MapArchObject(); - final Dimension mapSize = new Dimension(IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE); - maparch.setMapSize(mapSize); // Get and validate the level size + final int width, height; try { // get size - mapSize.width = Integer.parseInt(mapWidthField.getText()); - mapSize.height = Integer.parseInt(mapHeightField.getText()); - maparch.setMapSize(mapSize); - - if (mapSize.width < 1 || mapSize.height < 1) { - mainControl.showMessage("Illegal Value", - "Map dimensions must be in range [1, " + - Integer.MAX_VALUE + "]."); - return false; - } + width = Integer.parseInt(mapWidthField.getText()); + height = Integer.parseInt(mapHeightField.getText()); } catch (final NumberFormatException illegalNumbers) { mainControl.showMessage( "Illegal Value", "Map dimensions must be numerical integer values!"); return false; } + if (width < 1 || height < 1) { + mainControl.showMessage("Illegal Value", "Map dimensions must be in range [1, " + Integer.MAX_VALUE + "]."); + return false; + } + maparch.setMapSize(new Size2D(width, height)); + // the mapmaker must enter a mapname to create a new map if (mapType == TYPE_CFMAP && (mapNameField.getText() == null || mapNameField.getText().length() <= 0)) { mainControl.showMessage("Map Name is Missing", @@ -261,8 +259,8 @@ if (mapType == TYPE_CFMAP) { final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - settings.setProperty(DEFAULT_LEVEL_WIDTH_KEY, String.valueOf(mapSize.width)); - settings.setProperty(DEFAULT_LEVEL_HEIGHT_KEY, String.valueOf(mapSize.height)); + settings.setProperty(DEFAULT_LEVEL_WIDTH_KEY, String.valueOf(width)); + settings.setProperty(DEFAULT_LEVEL_HEIGHT_KEY, String.valueOf(height)); } // set file name Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.map.DefaultMapModel; import cfeditor.map.MapArchObject; @@ -75,10 +76,9 @@ this.mainControl = mainControl; // link main control in mapArch = new MapArchObject(); - bufWidth = 0; - bufHeight = 0; - mapArch.setWidth(bufWidth); - mapArch.setHeight(bufHeight); + bufWidth = 1; + bufHeight = 1; + mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); mapArch.setFileName("cb"); mapArch.setMapName("cb"); @@ -153,8 +153,7 @@ mapData.freeMapArchObject(); // free old map (/buffer) object bufWidth = Math.abs(offset.x) + 1; // new width bufHeight = Math.abs(offset.y) + 1; // new height - mapArch.setWidth(bufWidth); - mapArch.setHeight(bufHeight); + mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); mapData = null; // free objects (at least that is the plan and theory) buffCtrl = null; mapData = new DefaultMapModel(mainControl, buffCtrl, mapArch); // new MapModel Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.map.MapControl; import java.awt.Color; @@ -302,8 +303,8 @@ final Point offset; if (entireMap) { startp = new Point(0, 0); - final Dimension mapSize = mapControl.getMapSize(); - offset = new Point(mapSize.width - 1, mapSize.height - 1); + final Size2D mapSize = mapControl.getMapSize(); + offset = new Point(mapSize.getWidth() - 1, mapSize.getHeight() - 1); } else { startp = mapControl.getMapView().getHighlightStart(); // start of highlighted rect offset = mapControl.getMapView().getHighlightOffset(); // offset of rect from startp Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor.map; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.arch.ArchObjectIterator; import cfeditor.arch.ArchObjectIteratorDeleteArchMapObject; @@ -36,7 +37,6 @@ import cfeditor.filter.NamedFilterList; import cfeditor.IGUIConstants; import java.awt.Point; -import java.awt.Dimension; import java.util.Iterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -60,7 +60,7 @@ private ArchObject[][] mapGrid; /** Size of this map. */ - private final Dimension mapSize = new Dimension(); + private Size2D mapSize; /** Flag that indicates if the level has been changed since last save. */ private boolean levelChanged = false; @@ -81,11 +81,9 @@ this.mapArch = mapArch; this.mainControl = mainControl; mapControl = control; - mapSize.setSize(mapArch.getMapSize()); + mapSize = mapArch.getMapSize(); mapGrid = initMap(); - - mapArch.setMapSize(mapSize); } /** @@ -175,33 +173,19 @@ } /** - * Return whether the level has changed since it was last saved. - * @return true=level has changed + * Return whether the level has changed since it was last saved or not. + * @return <code>true</code> if level has changed, <code>false</code> if + * not. */ public boolean isLevelChanged() { return levelChanged; } /** - * Return the width of the level. - * @return the width of the level - */ - @Deprecated public int getMapWidth() { - return mapSize.width; - } - - /** - * Returns the height of the level. - * @return the height of the level - */ - @Deprecated public int getMapHeight() { - return mapSize.height; - } - - /** Return the map size of this level. + * Return the map size of this level. * @return map size of this level */ - public Dimension getMapSize() { + public Size2D getMapSize() { return mapSize; } @@ -305,9 +289,9 @@ * @return the empty map grid */ private ArchObject[][] initMap() { - final ArchObject[][] map = new ArchObject[mapSize.width][mapSize.height]; - for (int y = 0; y < mapSize.height; y++) { - for (int x = 0; x < mapSize.width; x++) { + final ArchObject[][] map = new ArchObject[mapSize.getWidth()][mapSize.getHeight()]; + for (int y = 0; y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { map[x][y] = null; } } @@ -329,7 +313,7 @@ for (int c = 0; c <= count; c++) { final int mapx = xx + mainControl.getArchObjectStack().getArch(archnr + c).getRefX(); final int mapy = yy + mainControl.getArchObjectStack().getArch(archnr + c).getRefY(); - if (mapx < 0 || mapy < 0 || mapx >= mapSize.width|| mapy >= mapSize.height) { + if (mapx < 0 || mapy < 0 || mapx >= mapSize.getWidth()|| mapy >= mapSize.getHeight()) { // outside map return false; } @@ -456,7 +440,7 @@ ArchObject newarch, oldarch, startarch; // our new suckers (copys, not ref ptrs) if (archnr < 0 || archnr >= mainControl.getArchObjectStack().getArchCount() - || pos.x == -1 || pos.y == -1 || pos.x >= mapSize.width|| pos.y >= mapSize.height) { + || pos.x == -1 || pos.y == -1 || pos.x >= mapSize.getWidth() || pos.y >= mapSize.getHeight()) { // invalid parameter return false; } @@ -702,7 +686,7 @@ @Nullable public ArchObject getMapArch(final int id, final Point pos) { ArchObject node; - if (mapGrid == null || pos.x < 0 || pos.x >= mapSize.width || pos.y < 0 || pos.y >= mapSize.height) { + if (mapGrid == null || pos.x < 0 || pos.x >= mapSize.getWidth() || pos.y < 0 || pos.y >= mapSize.getHeight()) { return null; } @@ -882,8 +866,8 @@ * every single ArchObject of the map... */ public void freeMapArchObject() { - for (int x = 0; x < mapSize.width; x++) { - for (int y = 0; y < mapSize.height; y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { while (mapGrid[x][y] != null) { deleteArchMapObject(mapGrid[x][y]); } @@ -946,7 +930,7 @@ * @return true=the given coordinates are within map bounds */ public boolean pointValid(final Point pos) { - return pos.x >= 0 && pos.x < mapSize.width && pos.y >= 0 && pos.y < mapSize.height; + return pos.x >= 0 && pos.x < mapSize.getWidth() && pos.y >= 0 && pos.y < mapSize.getHeight(); } /** @@ -986,20 +970,16 @@ return exit; } - @Deprecated public boolean checkResizeMap(final int newWidth, final int newHeight) { - return checkResizeMap(new Dimension(newWidth, newHeight)); - } - /** * Check if objects get cut off if the map was resized to the given bounds. * @param newSize the new level size * @return true if objects would be cut off */ - public boolean checkResizeMap(final Dimension newSize) { - if (mapSize.width > newSize.width) { + public boolean checkResizeMap(final Size2D newSize) { + if (mapSize.getWidth() > newSize.getWidth()) { // search the right stripe (as far as being cut off) - for (int x = newSize.width; x < mapSize.width; x++) { - for (int y = 0; y < mapSize.height; y++) { + for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { if (mapGrid[x][y] != null) { return true; } @@ -1007,10 +987,10 @@ } } - if (mapSize.height > newSize.height) { + if (mapSize.getHeight() > newSize.getHeight()) { // search the bottom stripe (as far as being cut off) - for (int y = newSize.height; y < mapSize.height; y++) { - for (int x = 0; x < mapSize.width; x++) { + for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { if (mapGrid[x][y] != null) { return true; } @@ -1021,34 +1001,25 @@ return false; } - @Deprecated public void resizeMap(final int newWidth, final int newHeight) { - resizeMap(new Dimension(newWidth, newHeight)); - } - /** * Resize this map to the new size. If any bounds are smaller than before, * the map gets cut on the right and bottom side. Accordingly, new space is * attached to right and bottom. * @param newSize new map size */ - public void resizeMap(final Dimension newSize) { - // don't allow negative values - if (newSize.width < 0) { - newSize.width = 0; + public void resizeMap(final Size2D newSize) { + if (newSize.equals(mapSize)) { + return; } - if (newSize.height < 0) { - newSize.height = 0; - } - // no other thread may access this mapmodel while resizing synchronized (this) { // first delete all arches in the area that will get cut off // (this is especially important to remove all multipart-objects // reaching into that area) - if (mapSize.width > newSize.width) { + if (mapSize.getWidth() > newSize.getWidth()) { // clear out the right stripe (as far as being cut off) - for (int x = newSize.width; x < mapSize.width; x++) { - for (int y = 0; y < mapSize.height; y++) { + for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { // for every map square: delete all arches on it final Iterator it = getArchObjectsDeleteMapArch(x, y, false, false); while (it.hasNext()) { @@ -1059,12 +1030,12 @@ } } - if (mapSize.height > newSize.height) { + if (mapSize.getHeight() > newSize.getHeight()) { // clear out the bottom stripe (as far as being cut off) // (and yes, there is an area getting sweeped twice - and yes it could // be optimized you smartass - but I don't care!) - for (int y = newSize.height; y < mapSize.height; y++) { - for (int x = 0; x < mapSize.width; x++) { + for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { // for every map square: delete all arches on it final Iterator it = getArchObjectsDeleteMapArch(x, y, false, false); while (it.hasNext()) { @@ -1077,17 +1048,17 @@ // Now the critical step: create an ArchObject array of new dimension, // copy all objects and set it to replace the current one. - final ArchObject[][] newGrid = new ArchObject[newSize.width][newSize.height]; + final ArchObject[][] newGrid = new ArchObject[newSize.getWidth()][newSize.getHeight()]; // fill it with nulls - for (int x = 0; x < newSize.width; x++) { - for (int y = 0; y < newSize.height; y++) { + for (int x = 0; x < newSize.getWidth(); x++) { + for (int y = 0; y < newSize.getHeight(); y++) { newGrid[x][y] = null; } } // relink all arches to the new grid - for (int x = 0; x < Math.min(newSize.width, mapSize.width); x++) { - for (int y = 0; y < Math.min(newSize.height, mapSize.height); y++) { + for (int x = 0; x < Math.min(newSize.getWidth(), mapSize.getWidth()); x++) { + for (int y = 0; y < Math.min(newSize.getHeight(), mapSize.getHeight()); y++) { newGrid[x][y] = mapGrid[x][y]; } } @@ -1096,7 +1067,7 @@ mapGrid = newGrid; // adjust the map and model attributes - mapSize.setSize(newSize.width, newSize.height); + mapSize = newSize; mapArch.setMapSize(newSize); // an important last point: if there is a highlighted area in a region @@ -1135,7 +1106,7 @@ * @return whether a match was found */ public boolean filterSquare(final Filter filter, final FilterConfig config, final int x, final int y) { - if (x < 0 || y < 0 || x >= mapSize.width || y >= mapSize.height) { + if (x < 0 || y < 0 || x >= mapSize.getWidth() || y >= mapSize.getHeight()) { return false; } Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,11 +24,11 @@ package cfeditor.map; +import app.net.sf.gridarta.Size2D; import cfeditor.IGUIConstants; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; -import java.awt.Dimension; /** * MapArchObject contains the specific meta data about a map that is stored in @@ -70,8 +70,10 @@ private final StringBuffer loreText = new StringBuffer(""); // lore text buffer - /** Size of this map. */ - private Dimension mapSize = new Dimension(); + /** + * Map size. + */ + private Size2D mapSize = new Size2D(1, 1); /** Default enter coordinates (usage not recommended). */ private int enterX, enterY; @@ -239,46 +241,27 @@ } /** - * Get the map width. - * @return map width + * Set map size. + * @param mapSize new map size */ - @Deprecated public int getWidth() { - return mapSize.width; - } + public void setMapSize(final Size2D mapSize) { + if (mapSize == null) { + throw new IllegalArgumentException("No map size set"); + } - /** - * Set the map width. - * @param x new map width - */ - @Deprecated public void setWidth(final int x) { - mapSize.width = x; + this.mapSize = mapSize; } /** - * Get the map height. - * @return map height + * Ensure that the map size is at least the given size. + * @param width the new minimum map width + * @param height the new minimum map height */ - @Deprecated public int getHeight() { - return mapSize.height; + public void ensureMapSize(final int width, final int height) { + mapSize = new Size2D(Math.max(mapSize.getWidth(), width), Math.max(mapSize.getHeight(), height)); } - /** - * Set the map height. - * @param y new map height - */ - @Deprecated public void setHeight(final int y) { - mapSize.height = y; - } - - /** - * Set map size. - * @param mapSize new map size - */ - public void setMapSize(final Dimension mapSize) { - this.mapSize.setSize(mapSize); - } - - public Dimension getMapSize() { + public Size2D getMapSize() { return mapSize; } @@ -619,11 +602,6 @@ return loreText.toString(); } - /** @return true if the mapsize is zero */ - public boolean sizeNull() { - return mapSize.width <= 0 && mapSize.height <= 0; - } - /** * Parsing the MapArchObject. This special object has it's own parser now * because it must be easily expandable for possible features. Who knows @@ -638,6 +616,9 @@ String line2; // input line, includes leading and trailing white space boolean loreflag = false; // flag for lore-text boolean archflag = false; // flag for arch<->end + int width = 0; + int height = 0; + try { boolean msgflag = false; // flag for map-message // read lines @@ -681,9 +662,9 @@ } else if (line.startsWith("region")) { region = line.substring(line.indexOf(" ") + 1).trim(); } else if (line.startsWith("width") || line.startsWith("x ")) { - mapSize.width = getLineValue(line); + width = getLineValue(line); } else if (line.startsWith("height") || line.startsWith("y ")) { - mapSize.height = getLineValue(line); + height = getLineValue(line); } else if (line.startsWith("enter_x") || line.startsWith("hp")) { enterX = getLineValue(line); } else if (line.startsWith("enter_y") || line.startsWith("sp")) { @@ -797,6 +778,9 @@ // if we reach eof here, the mapfile is corrupt return false; } + + mapSize = new Size2D(width, height); + return archflag; } @@ -874,12 +858,8 @@ if (darkness > 0) { stream.append("darkness " + darkness + "\n"); } - if (mapSize.width > 0) { - stream.append("width " + mapSize.width + "\n"); - } - if (mapSize.height > 0) { - stream.append("height " + mapSize.height + "\n"); - } + stream.append("width " + mapSize.getWidth() + "\n"); + stream.append("height " + mapSize.getHeight() + "\n"); if (enterX > 0) { stream.append("enter_x " + enterX + "\n"); } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package cfeditor.map; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.arch.ArchObjectIterator; import cfeditor.arch.ArchObjectIteratorDeleteMapArch; @@ -33,7 +34,6 @@ import cfeditor.CMapViewIFrame; import cfeditor.CUndoStack; import cfeditor.IGUIConstants; -import java.awt.Dimension; import java.awt.Point; import java.io.File; import java.util.Iterator; @@ -174,11 +174,11 @@ */ public void addEditType(final int newType) { // calculate only if needed - final Dimension size = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapSize(); final Point pos = new Point(); if (!hasEditType(newType)) { - for (pos.x = 0; pos.x < size.width; pos.x++) { - for (pos.y = 0; pos.y < size.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { final Iterator<ArchObject> it = mapModel.getArchObjects(pos); while (it.hasNext()) { final ArchObject arch = it.next(); @@ -355,7 +355,7 @@ * @param strMapTitle map name * @param newSize size of map */ - public void setProperties(final String archText, final String loreText, String strMapTitle, final Dimension newSize) { + public void setProperties(final String archText, final String loreText, String strMapTitle, final Size2D newSize) { // resize this map if (!newSize.equals(getMapSize())) { resizeMap(newSize); @@ -437,29 +437,11 @@ * Return the size of the level. * @return the map size */ - public Dimension getMapSize() { + public Size2D getMapSize() { return mapModel.getMapSize(); } /** - * Return the width of the level. - * @return the map width - * @deprecated use {@link #getMapSize()} instead. - */ - @Deprecated public int getMapWidth() { - return getMapSize().width; - } - - /** - * Return the height of the level. - * @return the map height - * @deprecated use {@link #getMapSize()} instead. - */ - @Deprecated public int getMapHeight() { - return getMapSize().height; - } - - /** * Return the current view position. * @return the current view position */ @@ -474,9 +456,9 @@ // TODO implement this int getDisplayMapWidth() { if (showTiles) { - return mapModel.getMapSize().width + eastWidth + westWidth; + return mapModel.getMapSize().getWidth() + eastWidth + westWidth; } else { - return mapModel.getMapSize().width; + return mapModel.getMapSize().getWidth(); } } @@ -486,9 +468,9 @@ */ int getDisplayMapHeight() { if (showTiles) { - return mapModel.getMapSize().height + northHeight + southHeight; + return mapModel.getMapSize().getHeight() + northHeight + southHeight; } else { - return mapModel.getMapSize().height; + return mapModel.getMapSize().getHeight(); } } @@ -536,7 +518,7 @@ return mapModel.pointValid(pos); } - public boolean checkResizeMap(final Dimension dim) { + public boolean checkResizeMap(final Size2D dim) { return mapModel.checkResizeMap(dim); } @@ -544,7 +526,7 @@ * Resize the map. * @param size the new level size */ - void resizeMap(final Dimension size) { + void resizeMap(final Size2D size) { mapModel.resizeMap(size); } Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-06-25 13:25:39 UTC (rev 187) @@ -1,10 +1,10 @@ package cfeditor.map; +import app.net.sf.gridarta.Size2D; import cfeditor.arch.ArchObject; import cfeditor.arch.ArchObjectIterator; import cfeditor.arch.ArchObjectIteratorDeleteArchMapObject; import cfeditor.arch.ArchObjectIteratorDeleteMapArch; -import java.awt.Dimension; import java.awt.Point; import java.util.Iterator; import org.jetbrains.annotations.Nullable; @@ -46,7 +46,7 @@ boolean isLevelChanged(); - Dimension getMapSize(); + Size2D getMapSize(); @Deprecated boolean addArchToMap(int archnr, int xx, int yy, int intern, boolean join, boolean insertBelow); boolean addArchToMap(int archnr, Point pos, int intern, boolean join, boolean insertBelow); @@ -67,10 +67,9 @@ @Nullable ArchObject getExit(); - @Deprecated boolean checkResizeMap(int newWidth, int newHeight); - boolean checkResizeMap(Dimension newSize); + boolean checkResizeMap(Size2D newSize); - void resizeMap(Dimension newSize); + void resizeMap(Size2D newSize); void moveTileUp(ArchObject prev, boolean refresh); Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-06-25 13:25:39 UTC (rev 187) @@ -114,12 +114,7 @@ // finally... here we go // last action: if the map is bigger than the specified size in // the maparch, we set the true size: the maxxlen/maxylen counters. - if (maparch.getWidth() < maxxlen + 1) { - maparch.setWidth(maxxlen + 1); - } - if (maparch.getHeight() < maxylen + 1) { - maparch.setHeight(maxylen + 1); - } + maparch.ensureMapSize(maxxlen + 1, maxylen + 1); return objects; // return first arch of the list } Modified: trunk/daimonin/src/daieditor/CMapFileEncode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,11 +24,11 @@ package daieditor; +import app.net.sf.gridarta.Size2D; import daieditor.arch.ArchObject; import daieditor.map.MapArchObject; import daieditor.map.MapModel; import daieditor.map.MapSquare; -import java.awt.Dimension; import java.awt.Point; import java.io.BufferedWriter; import java.io.File; @@ -72,10 +72,10 @@ mapArch.writeMapArch(writer); // FIXME: It doesn't look like a good idea to mix Push and Pull // first, write all one tile parts - final Dimension mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapSize(); final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.width; pos.x++) { - for (pos.y = 0; pos.y < mapSize.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { for (ArchObject node : mapModel.getMapSquare(pos)) { // only non muli suckers if (node.getMapMultiHead() == null && node.getMultiRefCount() == 0) { Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,6 +24,7 @@ package daieditor; +import app.net.sf.gridarta.Size2D; import daieditor.arch.ArchObject; import daieditor.gui.map.DefaultLevelRenderer; import daieditor.gui.map.MapUserListener; @@ -286,10 +287,10 @@ */ public Point[] getSelection() { final List<Point> selection = new ArrayList<Point>(); - final Dimension mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapSize(); final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.width; pos.x++) { - for (pos.y = 0; pos.y < mapSize.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { selection.add((Point) pos.clone()); } @@ -304,10 +305,10 @@ */ public List<MapSquare> getSelectedSquares() { final List<MapSquare> selection = new ArrayList<MapSquare>(); - final Dimension mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapSize(); final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.width; pos.x++) { - for (pos.y = 0; pos.y < mapSize.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { selection.add(mapModel.getMapSquare(pos)); } @@ -346,15 +347,15 @@ /** Refreshes the data in the view from the model. */ private void refreshDataFromModel() { - final Dimension mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapSize(); // define how much drawing space we need for the map final Point offset = renderer.getBorderOffset(); - final int sum = mapSize.width + mapSize.height; + final int sum = mapSize.getWidth() + mapSize.getHeight(); final Dimension forcedSize; if (isPickmap()) { forcedSize = new Dimension( - 2 * offset.x + (min(mapSize.height, 4) + min(mapSize.width, 7)) * IGUIConstants.TILE_ISO_XLEN2, + 2 * offset.x + (min(mapSize.getHeight(), 4) + min(mapSize.getWidth(), 7)) * IGUIConstants.TILE_ISO_XLEN2, 2 * offset.y + sum * IGUIConstants.TILE_ISO_YLEN2 ); } else { @@ -378,8 +379,7 @@ /** {@inheritDoc} */ public void mapSizeChanged(final MapModelEvent e) { - final Dimension size = e.getMap().getMapSize(); - mapGrid.resize(size); + mapGrid.resize(e.getMap().getMapSize()); // This will validate the map if necessary mainControl.mapSizeChanged(e.getMap()); refreshDataFromModel(); Modified: trunk/daimonin/src/daieditor/CNewMapDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CNewMapDialog.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/daimonin/src/daieditor/CNewMapDialog.java 2006-06-25 13:25:39 UTC (rev 187) @@ -25,6 +25,7 @@ package daieditor; +import app.net.sf.gridarta.Size2D; import static net.sf.japi.swing.ActionFactory.getFactory; import static daieditor.CMainControl.PREFS_USERNAME; import static daieditor.CMainControl.PREFS_USERNAME_DEFAULT; @@ -201,8 +202,9 @@ //maparch.setHeight(IGUIConstants.DEF_MAPSIZE); // Get and validate the width + final int width; try { - maparch.setWidth((Integer) mapWidthField.getValue()); + width = (Integer) mapWidthField.getValue(); } catch (final IllegalArgumentException e) { final String key = e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"; ACTION_FACTORY.showMessageDialog(this, key); @@ -211,8 +213,9 @@ } // Get and validate the height + final int height; try { - maparch.setHeight((Integer) mapHeightField.getValue()); + height = (Integer) mapHeightField.getValue(); } catch (final IllegalArgumentException e) { final String key = e instanceof NumberFormatException ? "newMapDimensionNotANumber" : "newMapDimensionOutOfRange"; ACTION_FACTORY.showMessageDialog(this, key); @@ -220,6 +223,8 @@ return false; } + maparch.setMapSize(new Size2D(width, height)); + // the mapmaker must enter a mapname to create a new map final String mapName = mapNameField.getText(); if (mapType == MapType.GAMEMAP && (mapName == null || mapName.length() <= 0)) { @@ -229,8 +234,8 @@ } if (mapType == MapType.GAMEMAP) { - prefs.putInt(DEFAULT_LEVEL_WIDTH_KEY, maparch.getWidth()); - prefs.putInt(DEFAULT_LEVEL_HEIGHT_KEY, maparch.getHeight()); + prefs.putInt(DEFAULT_LEVEL_WIDTH_KEY, width); + prefs.putInt(DEFAULT_LEVEL_HEIGHT_KEY, height); } // set file name Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-06-25 12:30:38 UTC (rev 186) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-06-25 13:25:39 UTC (rev 187) @@ -24,13 +24,13 @@ package daieditor; +import app.net.sf.gridarta.Size2D; import static daieditor.CMainControl.rnd; import daieditor.arch.ArchObject; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; import daieditor.map.MapSquare; -import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; @@ -139,8 +139,7 @@ wasEmpty = true; } - maparch.setWidth(selRec.width + 1); - maparch.setHeight(selRec.height + 1); + maparch.setMapSize(new Size2D(selRec.width + 1, selRec.height + 1)); copyMapCtrl = new MapControl(mainControl, null, maparch, false, false); // new MapControl copyMap = copyMapCtrl.getMapModel(); if (wasEmpty) { @@ -313,10 +312,10 @@ private static int countMapArches(final MapControl mapControl) { final MapModel map = mapControl.getMapModel(); int count = 0; - final Dimension mapSize = map.getMapSize(); + final Size2D mapSize = map.getMapSize(); final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.width; pos.x++) { - for (pos.y = 0; pos.y < mapSize.height; pos.y++) { + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { for (ArchObject node : map.getMapSquare(pos)) { ... [truncated message content] |
From: <chr...@us...> - 2006-06-25 16:16:53
|
Revision: 194 Author: christianhujer Date: 2006-06-25 09:16:39 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=194&view=rev Log Message: ----------- Fixed wrong tool assignment. Added feature to move arches within their square top or bottom. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapTileList.java trunk/daimonin/src/daieditor/action.properties trunk/daimonin/src/daieditor/arch/ArchObject.java trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java trunk/daimonin/src/daieditor/gui/map/tools/ToolSelectorPane.java Modified: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-06-25 16:10:56 UTC (rev 193) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-06-25 16:16:39 UTC (rev 194) @@ -54,6 +54,7 @@ import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; import static net.sf.japi.swing.ActionFactory.getFactory; /** @@ -103,13 +104,15 @@ final JPanel arrows = new JPanel(); if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(2, 1)); + arrows.setLayout(new GridLayout(4, 1)); add(arrows, BorderLayout.WEST); // put up/down buttons west } else { add(arrows, BorderLayout.SOUTH); // put up/down buttons south } + arrows.add(new JButton(ACTION_FACTORY.createAction(true, "moveTileTop", this))); arrows.add(new JButton(ACTION_FACTORY.createAction(true, "moveTileUp", this))); arrows.add(new JButton(ACTION_FACTORY.createAction(true, "moveTileDown", this))); + arrows.add(new JButton(ACTION_FACTORY.createAction(true, "moveTileBottom", this))); final JPanel compass = new JPanel(); compass.add(new JLabel(CGUIUtils.getSysIcon(IGUIConstants.TILE_NORTH))); @@ -125,10 +128,22 @@ } /** + * Action method for moving an arch topmost within its tile. + * @used + */ + @ActionMethod public void moveTileTop() { + final ArchObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveTop(); + } + refresh(); + } + + /** * Action method for moving an arch up within its tile. * @used */ - public void moveTileUp() { + @ActionMethod public void moveTileUp() { final ArchObject arch = getMapTileSelection(); if (arch != null) { arch.moveUp(); @@ -140,7 +155,7 @@ * Action method for moving an arch down within its tile. * @used */ - public void moveTileDown() { + @ActionMethod public void moveTileDown() { final ArchObject arch = getMapTileSelection(); if (arch != null) { arch.moveDown(); @@ -148,6 +163,18 @@ refresh(); } + /** + * Action method for moving an arch topmost within its tile. + * @used + */ + @ActionMethod public void moveTileBottom() { + final ArchObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveBottom(); + } + refresh(); + } + public void selectArchBelow() { list.setSelectedIndex(list.getSelectedIndex() + 1); } Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2006-06-25 16:10:56 UTC (rev 193) +++ trunk/daimonin/src/daieditor/action.properties 2006-06-25 16:16:39 UTC (rev 194) @@ -162,8 +162,10 @@ direction7.icon=Dir7 direction8.icon=Dir8 +moveTileTop.icon=navigation/Top16 moveTileUp.icon=navigation/Up16 moveTileDown.icon=navigation/Down16 +moveTileBottom.icon=navigation/Bottom16 prefsApp.icon=development/Application24 Modified: trunk/daimonin/src/daieditor/arch/ArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/arch/ArchObject.java 2006-06-25 16:10:56 UTC (rev 193) +++ trunk/daimonin/src/daieditor/arch/ArchObject.java 2006-06-25 16:16:39 UTC (rev 194) @@ -567,6 +567,11 @@ return artifact; } + /** Move this ArchObject top. */ + public void moveTop() { + container.moveTop(this); + } + /** Move this ArchObject up. */ public void moveUp() { container.moveUp(this); @@ -577,6 +582,11 @@ container.moveDown(this); } + /** Move this ArchObject bottom. */ + public void moveBottom() { + container.moveBottom(this); + } + /** * Remove this ArchObject from its container. * This method also takes perfectly well care of multihead arches. Modified: trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java =================================================================== --- trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java 2006-06-25 16:10:56 UTC (rev 193) +++ trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java 2006-06-25 16:16:39 UTC (rev 194) @@ -164,7 +164,7 @@ */ public final void moveTop(final ArchObject arch) { getMapSquare().getModel().beginTransaction(); - while (first != arch) { + while (last != arch) { swap(arch, arch.getNext()); } getMapSquare().getModel().endTransaction(); @@ -187,13 +187,13 @@ } /** - * Move an item to top. - * @param arch item to move to top + * Move an item to bottom. + * @param arch item to move to bottom */ public final void moveBottom(final ArchObject arch) { getMapSquare().getModel().beginTransaction(); - while (last != arch) { - swap(arch, arch.getPrev()); + while (first != arch) { + swap(arch.getPrev(), arch); } getMapSquare().getModel().endTransaction(); } Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelectorPane.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelectorPane.java 2006-06-25 16:10:56 UTC (rev 193) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelectorPane.java 2006-06-25 16:16:39 UTC (rev 194) @@ -23,10 +23,10 @@ private ToolSelector lmbSelector = new ToolSelector("selection"); /** The ToolSelector for mmb. */ - private ToolSelector mmbSelector = new ToolSelector("insertion"); + private ToolSelector mmbSelector = new ToolSelector("deletion"); /** The ToolSelector for rmb. */ - private ToolSelector rmbSelector = new ToolSelector("deletion"); + private ToolSelector rmbSelector = new ToolSelector("insertion"); /** Create a ToolSelectorPane. */ public ToolSelectorPane() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-07-05 22:06:03
|
Revision: 234 Author: christianhujer Date: 2006-07-05 15:05:43 -0700 (Wed, 05 Jul 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=234&view=rev Log Message: ----------- Added validator for map difficulty. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/messages.properties Added Paths: ----------- trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyError.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-07-03 21:21:15 UTC (rev 233) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-07-05 22:05:43 UTC (rev 234) @@ -69,6 +69,7 @@ import daieditor.map.validation.checks.SquareWithoutFloorChecker; import daieditor.map.validation.checks.SysObjectOnLayerZeroChecker; import daieditor.map.validation.checks.TilePathsChecker; +import daieditor.map.validation.checks.MapDifficultyChecker; import daieditor.textedit.scripteditor.ScriptEditControl; import java.awt.Image; import java.awt.Point; @@ -339,6 +340,7 @@ new DoubleLayerChecker(), new EmptySpawnPointChecker(), new ExitChecker(), + new MapDifficultyChecker(), new MobOutsideSpawnPointChecker(), new SquareWithoutFloorChecker(), new SlayingChecker(), Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2006-07-03 21:21:15 UTC (rev 233) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2006-07-05 22:05:43 UTC (rev 234) @@ -403,6 +403,9 @@ swapTime = parseProperty(fieldSwapTime.getText(), "Swap Time"); resetTimeout = parseProperty(fieldResetTimeout.getText(), "Reset Timeout"); difficulty = parseProperty(fieldDifficulty.getText(), "Difficulty"); + if (difficulty < 1) { + throw new IllegalArgumentException("Difficulty must be > 0"); // TODO: i18n/l10n + } darkness = parseProperty(fieldDarkness.getText(), "Darkness"); // Now do some sanity checks: Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-07-03 21:21:15 UTC (rev 233) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-07-05 22:05:43 UTC (rev 234) @@ -276,7 +276,7 @@ } public void setDifficulty(final int difficulty) { - this.difficulty = difficulty; + this.difficulty = difficulty < 1 ? 1 : difficulty; } public boolean isFixedReset() { @@ -472,7 +472,7 @@ } else if (line.startsWith("swap_time ")) { swapTime = getLineValue(line); } else if (line.startsWith("difficulty ")) { - difficulty = getLineValue(line); + setDifficulty(getLineValue(line)); } else if (line.startsWith("darkness ")) { darkness = getLineValue(line); } else if (line.startsWith("fixed_resettime ")) { Added: trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java 2006-07-05 22:05:43 UTC (rev 234) @@ -0,0 +1,30 @@ +package daieditor.map.validation.checks; + +import daieditor.map.MapModel; +import daieditor.map.MapArchObject; +import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; +import daieditor.map.validation.MapValidator; + +/** + * Validator that checks whether the map has a valid difficulty. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ +public class MapDifficultyChecker extends AbstractValidator implements MapValidator { + + /** + * Create a MapDifficultyChecker. + */ + public MapDifficultyChecker() { + } + + /** {@inheritDoc} */ + public void validate(final MapModel mapModel, final ErrorCollector errorCollector) { + final MapArchObject mapArch = mapModel.getMapArch(); + final int difficulty = mapArch.getDifficulty(); + if (difficulty < 1) { + errorCollector.collect(new MapDifficultyError(mapModel, difficulty)); + } + } + +} // class TilePathsChecker Property changes on: trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyError.java (rev 0) +++ trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyError.java 2006-07-05 22:05:43 UTC (rev 234) @@ -0,0 +1,33 @@ +package daieditor.map.validation.checks; + +import daieditor.map.MapModel; +import daieditor.map.validation.MapValidationError; + +/** + * Validation error that's used when a map has wrong tile paths. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ +public class MapDifficultyError extends MapValidationError { + + /** The difficulty that was wrong. */ + private final int difficulty; + + /** + * Create a MapDifficultyError + * @param mapModel the map on which the error occurred + * @param difficulty difficulty which was wrong + */ + public MapDifficultyError(final MapModel mapModel, final int difficulty) { + super(mapModel); + this.difficulty = difficulty; + } + + /** + * Returns the difficulty that was wrong. + * @return the difficulty that was wrong. + */ + public int getDifficulty() { + return difficulty; + } + +} // class MapDifficultyError Property changes on: trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyError.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2006-07-03 21:21:15 UTC (rev 233) +++ trunk/daimonin/src/daieditor/messages.properties 2006-07-05 22:05:43 UTC (rev 234) @@ -914,6 +914,9 @@ Validator.Exit.title=Exit path invalid Validator.Exit.msg=<html><h3>{0}</h3><p>This exit has an invalid path.<br>Change the path or create the missing map. +Validator.MapDifficulty.title=Map difficulty invalid +Validator.MapDifficulty.msg=<html><h3>{0}</h3>This map has an invalid difficulty.<br>Go to the map properties dialog and change the difficulty setting. + Validator.MobOutsideSpawnPoint.title=Mob outside spawn point Validator.MobOutsideSpawnPoint.msg=<html><h3>{0}</h3><p>On this square there is a mob outside a spawn point.<br>Mobs outside spawn points are okay, but you should perhaps still put the mob inside a spawn point.</p><p>You could:</p><ul><li>Ignore this</li><li>Create a spawn point for this mob</li></ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-08-28 11:28:27
|
Revision: 295 Author: christianhujer Date: 2006-08-28 04:28:13 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=295&view=rev Log Message: ----------- Minor refactoring of map loading. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-08-27 21:57:34 UTC (rev 294) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-08-28 11:28:13 UTC (rev 295) @@ -242,9 +242,6 @@ /** The current top map we are working with */ private MapControl currentMap; - /** The last opened map. Used for hidden working */ - private MapControl lastOpenedMap; - /** The current main directory. */ private File currentDir; @@ -1188,76 +1185,64 @@ * something went wrong */ boolean openFile(final File file) { - return openFile(file, true); + return openFile(file, true) != null; } /** * Load a mapfile. * @param file mapfile * @param view only create a view if this is true - * @return true if the file was new, false if the file already was open or - * something went wrong + * @return MapControl of loaded file or <code>null</code> if the file couldn't be opened */ - public boolean openFile(final File file, final boolean view) { - lastOpenedMap = null; + public MapControl openFile(final File file, final boolean view) { + // First look whether the file isn't already open. + // If so, return the previously loaded map. try { final File can = file.getCanonicalFile(); for (final MapControl level : levels) { final File levelFile = level.getMapFile(); if (levelFile != null && can.equals(levelFile.getCanonicalFile())) { - lastOpenedMap = level; if (view) { level.createView(); setCurrentLevel(level); setCurrentLevelView(level.getMapViewFrame()); } - return false; + return level; } } } catch (final IOException e) { logger.log(Level.WARNING, "canonIOE", e); } - final List<ArchObject> objects; - final MapArchObject maparch; - try { - objects = mapFileDecoder.decodeMapFile(file, mapDir.getAbsolutePath()); // parse mapfile - maparch = mapFileDecoder.getMapArch(); // get map arch + final List<ArchObject> objects = mapFileDecoder.decodeMapFile(file, mapDir.getAbsolutePath()); // parse mapfile + final MapArchObject maparch = mapFileDecoder.getMapArch(); // get map arch + // go to ArchObjectParser and add the default arch list information to them + if (!collectTempList(objects, file)) { // get face names, face id, etc. + return null; // What's this return here? + } + final List<ArchObject> sortedObjects = ArchObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) + final MapControl lastOpenedMap = newLevel(sortedObjects, maparch, view); // init the map + + // finally, show the map and refresh toolbars + lastOpenedMap.setMapFile(file); + lastOpenedMap.setActiveEditType(tileEdit); // map is loaded with current view settings + if (view) { + refreshMenusAndToolbars(); + addRecent(currentMap.getMapArch().getMapNameWithoutMusic(), file.toString()); + } + return lastOpenedMap; } catch (final FileNotFoundException e) { ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); - return false; + return null; } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); - return false; + return null; } catch (final OutOfMemoryError ignore) { // out of memory!! - display error ACTION_FACTORY.showMessageDialog(mainView, "mapOutOfMemory"); - return false; + return null; } - - // ok, we have it all!! - - if (objects == null) { - // The map is totally empty - lastOpenedMap = newLevel(objects, maparch, view); // init the map - } else { - // go to ArchObjectParser and add the default arch list information to them - if (!collectTempList(objects, file)) { // get face names, face id, etc. - return false; // What's this return here? - } - final List<ArchObject> sortedObjects = ArchObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) - lastOpenedMap = newLevel(sortedObjects, maparch, view); // init the map - } - - // finally, show the map and refresh toolbars - lastOpenedMap.setMapFile(file); - lastOpenedMap.setActiveEditType(tileEdit); // map is loaded with current view settings - if (view) { - refreshMenusAndToolbars(); - addRecent(currentMap.getMapArch().getMapNameWithoutMusic(), file.toString()); - } - return true; } /** @@ -2179,14 +2164,6 @@ return mapCursorControl; } - /** - * Returns the last opened map. Used for hidden working - * @return the last opened map. Used for hidden working - */ - public MapControl getLastOpenedMap() { - return lastOpenedMap; - } - public static String getBuildNumberAsString() { try { return getBundle("build").getString("build.number"); Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-08-27 21:57:34 UTC (rev 294) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-08-28 11:28:13 UTC (rev 295) @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.List; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * This class handles the reading of a mapfile and parsing the data @@ -65,7 +66,7 @@ * @param mapDir map directory * @return first <code>ArchObject</code> in the list */ - public synchronized List<ArchObject> decodeMapFile(final File file, final String mapDir) throws FileNotFoundException, IOException { + @NotNull public synchronized List<ArchObject> decodeMapFile(@NotNull final File file, final String mapDir) throws FileNotFoundException, IOException { final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), CMainControl.MAP_ENCODING)); final List<ArchObject> objects = new ArrayList<ArchObject>(); try { Modified: trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java 2006-08-27 21:57:34 UTC (rev 294) +++ trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java 2006-08-28 11:28:13 UTC (rev 295) @@ -174,8 +174,7 @@ } final CMainControl mainControl = CMainControl.getInstance(); // Open file without view - mainControl.openFile(file, false); - final MapControl mapControl = mainControl.getLastOpenedMap(); + final MapControl mapControl = mainControl.openFile(file, false); if (mapControl == null) { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-08-28 12:52:48
|
Revision: 301 Author: christianhujer Date: 2006-08-28 05:52:40 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=301&view=rev Log Message: ----------- Minor refactoring of loading maps (unfinnished). Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/arch/ArchObjectParser.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-08-28 12:52:09 UTC (rev 300) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-08-28 12:52:40 UTC (rev 301) @@ -1218,20 +1218,16 @@ final List<ArchObject> objects = mapFileDecoder.decodeMapFile(file, mapDir.getAbsolutePath()); // parse mapfile final MapArchObject maparch = mapFileDecoder.getMapArch(); // get map arch // go to ArchObjectParser and add the default arch list information to them - if (!collectTempList(objects, file)) { // get face names, face id, etc. - return null; // What's this return here? - } - final List<ArchObject> sortedObjects = ArchObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) - final MapControl lastOpenedMap = newLevel(sortedObjects, maparch, view); // init the map + final MapControl newMap = newLevel(objects, maparch, view); // init the map // finally, show the map and refresh toolbars - lastOpenedMap.setMapFile(file); - lastOpenedMap.setActiveEditType(tileEdit); // map is loaded with current view settings + newMap.setMapFile(file); + newMap.setActiveEditType(tileEdit); // map is loaded with current view settings if (view) { refreshMenusAndToolbars(); addRecent(currentMap.getMapArch().getMapNameWithoutMusic(), file.toString()); } - return lastOpenedMap; + return newMap; } catch (final FileNotFoundException e) { ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); return null; @@ -1279,7 +1275,7 @@ * browse first through the default arch list and attach map arches to it * then browse through the face list and try to find the pictures */ - boolean collectTempList(final List<ArchObject> objects, final File file) { + void collectTempList(final List<ArchObject> objects, final File file) { final StringBuilder noarch = new StringBuilder(); int noarchcount = 0; final List<ArchObject> tailList = new ArrayList<ArchObject>(); @@ -1310,7 +1306,6 @@ if (noarchcount > 0) { ACTION_FACTORY.showMessageDialog(mainView, "collectTemplistAutodelete", file.getName(), noarchcount, noarch); } - return true; } /** Invoked when user wants to save the current level. */ Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-08-28 12:52:09 UTC (rev 300) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-08-28 12:52:40 UTC (rev 301) @@ -25,6 +25,7 @@ package daieditor; import daieditor.arch.ArchObject; +import daieditor.arch.ArchObjectParser; import daieditor.map.MapArchObject; import java.io.BufferedReader; import java.io.File; @@ -63,7 +64,7 @@ /** * Loading a Daimonin map from the given mapfile. - * This method returns a list of arches, connected with the temp pointers. + * This method returns a list of arches. * @param file mapfile * @param mapDir map directory * @return first <code>ArchObject</code> in the list @@ -93,6 +94,8 @@ while ((thisLine = myInput.readLine()) != null) { readArch(myInput, thisLine); // all these are map arches } + CMainControl.getInstance().collectTempList(objects, file); + ArchObjectParser.sortTempList(objects); return objects; // return first arch of the list } finally { objects = null; Modified: trunk/daimonin/src/daieditor/CPickmapPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-08-28 12:52:09 UTC (rev 300) +++ trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-08-28 12:52:40 UTC (rev 301) @@ -146,11 +146,7 @@ final CMapViewBasic bmapview; // go to ArchObjectParser and add the default arch list information to them - if (!mainControl.collectTempList(objects, mapFile)) { // get face names, face id, etc. - return false; - } - final List<ArchObject> sortedObjects = ArchObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) - bmapview = newPickmap(sortedObjects, maparch, mapFile, index); // init the map + bmapview = newPickmap(objects, maparch, mapFile, index); // init the map // looks like it worked, so we add a panel and display this pickmap if (bmapview != null) { Modified: trunk/daimonin/src/daieditor/arch/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/arch/ArchObjectParser.java 2006-08-28 12:52:09 UTC (rev 300) +++ trunk/daimonin/src/daieditor/arch/ArchObjectParser.java 2006-08-28 12:52:40 UTC (rev 301) @@ -584,12 +584,11 @@ * Sort the temp list of arches, placing all multiparts at the end. * This is neccessary to assure multiparts are always on top. * @param objects list of objects - * @return the same list sorted (for convenience) * @note This method assumes that all pieces of one multipart are listed in * a row, which is okay as long as the loader puts it that way. * @note The returned list is the same list, not a new list. */ - public static List<ArchObject> sortTempList(final List<ArchObject> objects) { + public static void sortTempList(final List<ArchObject> objects) { final Comparator<ArchObject> sorter = new Comparator<ArchObject>() { public int compare(final ArchObject o1, final ArchObject o2) { final boolean b1 = o1.isMulti(); @@ -598,7 +597,6 @@ } }; sort(objects, sorter); - return objects; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-08-28 22:06:25
|
Revision: 307 Author: christianhujer Date: 2006-08-28 15:05:59 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=307&view=rev Log Message: ----------- Fixed some Serialization issues. Modified Paths: -------------- trunk/daimonin/src/daieditor/MultiArchData.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/arch/ArchObject.java trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java trunk/daimonin/src/daieditor/arch/NamedObject.java trunk/daimonin/src/daieditor/arch/face/DuplicateFaceException.java trunk/daimonin/src/daieditor/arch/face/FaceObject.java trunk/daimonin/src/daieditor/arch/match/ArchObjectMatcher.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapModel.java trunk/src/app/net/sf/gridarta/Size2D.java Modified: trunk/daimonin/src/daieditor/MultiArchData.java =================================================================== --- trunk/daimonin/src/daieditor/MultiArchData.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/MultiArchData.java 2006-08-28 22:05:59 UTC (rev 307) @@ -27,6 +27,7 @@ import daieditor.arch.ArchObject; import java.util.ArrayList; import java.util.List; +import java.io.Serializable; import org.jetbrains.annotations.Nullable; /** @@ -37,8 +38,11 @@ * a little bit of memory. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class MultiArchData { +public final class MultiArchData implements Serializable { + /** Serial Version. */ + private static final long serialVersionUID = 1L; + private boolean referenced; // true: this arch is a part of the tail - NOT the head private int refx; // multi tile: offset pos from head Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-08-28 22:05:59 UTC (rev 307) @@ -33,6 +33,7 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; +import java.io.Serializable; import java.util.Vector; import javax.swing.BorderFactory; import javax.swing.Box; @@ -59,8 +60,11 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @XXX This class is designed very badly, as it combines model and presentation. */ -public final class ScriptArchData { +public final class ScriptArchData implements Serializable { + /** Serial Version. */ + private static final long serialVersionUID = 1L; + /** ActionFactory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); Modified: trunk/daimonin/src/daieditor/arch/ArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/arch/ArchObject.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/arch/ArchObject.java 2006-08-28 22:05:59 UTC (rev 307) @@ -38,6 +38,7 @@ import daieditor.map.MapSquare; import java.util.Collections; import java.util.List; +import java.io.Serializable; import javax.swing.ImageIcon; import javax.swing.JList; import org.jetbrains.annotations.Nullable; @@ -56,8 +57,11 @@ * normal arches. * @todo this class is not always the best place for multipart object handling, see also {@link ArchObjectContainer} for issues about this */ -public final class ArchObject /*extends NamedObject*/ extends ArchObjectContainer implements Cloneable, net.sf.gridarta.arch.ArchObject { +public final class ArchObject /*extends NamedObject*/ extends ArchObjectContainer implements Cloneable, net.sf.gridarta.arch.ArchObject, Serializable { + /** Serial Version. */ + private static final long serialVersionUID = 1L; + /** Special constant that's used if an arch has no arch type set. */ public static final int TYPE_UNSET = -666; @@ -158,7 +162,6 @@ /** The transparent face. */ private ImageIcon transFace; - /** Create an ArchObject. */ public ArchObject() { archText = new StringBuffer(); Modified: trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java =================================================================== --- trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/arch/ArchObjectContainer.java 2006-08-28 22:05:59 UTC (rev 307) @@ -26,6 +26,10 @@ import java.util.List; import java.util.ArrayList; import java.util.ListIterator; +import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; @@ -40,8 +44,11 @@ * @todo: In case of MapSquares, this class is most likely bogus regarding multipart objects. This needs to be fixed. */ @SuppressWarnings({"ClassReferencesSubclass"}) -public abstract class ArchObjectContainer implements Iterable<ArchObject> { +public abstract class ArchObjectContainer implements Iterable<ArchObject>, Serializable { + /** Serial Version. */ + private static final long serialVersionUID = 1L; + /** * The contents of this container. * @note the order of this container is bottom to top. @@ -49,10 +56,10 @@ @NotNull private List<ArchObject> contents; /** Iterable implementation for recursice traversal. */ - @NotNull private Iterable<ArchObject> recursive; + @NotNull private transient Iterable<ArchObject> recursive; /** Iterable implementation for reverse traversal. */ - @NotNull private Iterable<ArchObject> reverse; + @NotNull private transient Iterable<ArchObject> reverse; /** Create a new ArchObjectContainer. */ protected ArchObjectContainer() { @@ -346,6 +353,14 @@ } } + /** {@inheritDoc} */ + // writeObject() is not required because this class doesn't require special handling during serialization. + private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + // initialize transients + initData(); + } + /** * An iterator for iterating over a list in reverse order. * @todo move this class to JAPI Modified: trunk/daimonin/src/daieditor/arch/NamedObject.java =================================================================== --- trunk/daimonin/src/daieditor/arch/NamedObject.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/arch/NamedObject.java 2006-08-28 22:05:59 UTC (rev 307) @@ -22,6 +22,7 @@ package daieditor.arch; import javax.swing.ImageIcon; +import java.io.Serializable; /** * A <code>NamedObject</code> has a name and tree position source and provides an icon for display. @@ -29,11 +30,14 @@ * {@link daieditor.arch.anim.AnimationObject}. * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> */ -public abstract class NamedObject implements Comparable<NamedObject> { +public abstract class NamedObject implements Comparable<NamedObject>, Serializable { /** The Path. */ private String path; + /** Serial Version. */ + private static final long serialVersionUID = 1L; + /** * Create a NamedObject. * @param path Path Modified: trunk/daimonin/src/daieditor/arch/face/DuplicateFaceException.java =================================================================== --- trunk/daimonin/src/daieditor/arch/face/DuplicateFaceException.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/arch/face/DuplicateFaceException.java 2006-08-28 22:05:59 UTC (rev 307) @@ -24,7 +24,6 @@ /** * Exception that's thrown in case a face name was not unique. * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> - * @serial exclude */ public class DuplicateFaceException extends Exception { Modified: trunk/daimonin/src/daieditor/arch/face/FaceObject.java =================================================================== --- trunk/daimonin/src/daieditor/arch/face/FaceObject.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/arch/face/FaceObject.java 2006-08-28 22:05:59 UTC (rev 307) @@ -23,6 +23,7 @@ import daieditor.arch.NamedObject; import javax.swing.ImageIcon; +import java.io.Serializable; /** * A FaceObject stores information and meta information about a face and provides methods for accessing these. @@ -36,7 +37,6 @@ * <li>File size</li> * </ul> * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> - * @todo this class should be Serializable because it's used as an Exception field. * @todo think how this class could be serialized because size, offset etc. are not serializable. */ public class FaceObject extends NamedObject { Modified: trunk/daimonin/src/daieditor/arch/match/ArchObjectMatcher.java =================================================================== --- trunk/daimonin/src/daieditor/arch/match/ArchObjectMatcher.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/arch/match/ArchObjectMatcher.java 2006-08-28 22:05:59 UTC (rev 307) @@ -22,12 +22,13 @@ package daieditor.arch.match; import daieditor.arch.ArchObject; +import java.io.Serializable; /** * Interface for classes that match ArchObjects. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface ArchObjectMatcher { +public interface ArchObjectMatcher extends Serializable { /** * Match an ArchObject. Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-08-28 22:05:59 UTC (rev 307) @@ -36,6 +36,8 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; +import java.io.IOException; +import java.io.ObjectInputStream; import javax.swing.event.EventListenerList; import net.sf.gridarta.Size2D; import net.sf.japi.swing.ActionFactory; @@ -63,7 +65,7 @@ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); /** Sync Lock Object. */ - private final Object syncLock = new Object(); + private final transient Object syncLock = new Object(); /** The registered event listeners. */ private EventListenerList listenerList = new EventListenerList(); @@ -90,11 +92,12 @@ * The CMainControl used for various operations. * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link CMainControl}. */ - @Deprecated private final CMainControl mainControl; + @Deprecated private final transient CMainControl mainControl; /** * The MapControl that controls this MapModel. * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link CMapControl}. + * @todo care about Serialization if this field remains */ @Deprecated private final MapControl mapControl; Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-08-28 22:05:59 UTC (rev 307) @@ -28,6 +28,7 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; +import java.io.Serializable; import net.sf.gridarta.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,8 +45,11 @@ * @todo This class should be changed so map attributes are reflected in a more * generic way like arch attributes. */ -public final class MapArchObject { +public final class MapArchObject implements Serializable { + /** Serial Version. */ + private static final long serialVersionUID = 1L; + // tags which appear in the map header private static final String TAG_START_TEXT = "msg"; @@ -57,7 +61,7 @@ /** * Map size. * @fixme this is redundant with {@link DefaultMapModel}. - */ + m */ @NotNull private Size2D mapSize = new Size2D(1, 1); /** Default enter coordinates (usage not recommended). */ Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-08-28 22:05:59 UTC (rev 307) @@ -3,6 +3,7 @@ import daieditor.arch.ArchObject; import java.awt.Point; import java.util.Iterator; +import java.io.Serializable; import net.sf.gridarta.Size2D; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; @@ -18,7 +19,7 @@ * And there is no rollback. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapModel extends Iterable<MapSquare>, net.sf.gridarta.map.MapModel { +public interface MapModel extends Iterable<MapSquare>, net.sf.gridarta.map.MapModel, Serializable { /** {@inheritDoc} */ Iterator<MapSquare> iterator(); Modified: trunk/src/app/net/sf/gridarta/Size2D.java =================================================================== --- trunk/src/app/net/sf/gridarta/Size2D.java 2006-08-28 13:56:44 UTC (rev 306) +++ trunk/src/app/net/sf/gridarta/Size2D.java 2006-08-28 22:05:59 UTC (rev 307) @@ -20,11 +20,16 @@ package net.sf.gridarta; +import java.io.Serializable; + /** * The class Size2D represents a 2d rectangular area. */ -public final class Size2D { +public final class Size2D implements Serializable { + /** Serial Version. */ + private static final long serialVersionUID = 1L; + /** * The width of the area. * It is always greater than zero. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-14 21:36:05
|
Revision: 1064 http://svn.sourceforge.net/gridarta/?rev=1064&view=rev Author: akirschbaum Date: 2006-12-14 13:36:04 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Fix messages. Modified Paths: -------------- trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2006-12-14 21:34:40 UTC (rev 1063) +++ trunk/daimonin/src/daieditor/messages.properties 2006-12-14 21:36:04 UTC (rev 1064) @@ -213,7 +213,7 @@ fileDialog.filter.anim=Animation definitions fileDialog.filter.unignored=All supported file types -createNew.text=New +createNew.text=New... createNew.shortdescription=Create new map createNew.longdescription=Creates a new map createNew.mnemonic=N @@ -228,7 +228,7 @@ recent.text=Recent recent.shortdescription=Load a recently opened map -recent.mnemonic=R +recent.mnemonic=T recentItem.shortdescriptionformat=Opens map {0} ({1}) close.text=Close @@ -273,8 +273,8 @@ options.text=Options... options.shortdescription=Shows options options.longdescription=Shows an option dialog to change the editor settings -options.mnemonic=O -options.accel=ctrl alt pressed s +options.mnemonic=P +options.accel=ctrl alt pressed S exit.text=Exit exit.shortdescription=Exit program Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2006-12-14 21:34:40 UTC (rev 1063) +++ trunk/daimonin/src/daieditor/messages_de.properties 2006-12-14 21:36:04 UTC (rev 1064) @@ -181,7 +181,7 @@ fileDialog.filter.arc=Archetypdefinitionen fileDialog.filter.anim=Animationsdefinitionen -createNew.text=Neu +createNew.text=Neu... createNew.shortdescription=Erzeuge neue Karte createNew.longdescription=Erzeut eine neue Karte createNew.mnemonic=N @@ -210,7 +210,7 @@ save.accel=ctrl pressed S save.error.text=Fehler beim Speichern -saveAs.text=Speichern Als... +saveAs.text=Speichern als... saveAs.shortdescription=Karte mit neuem Namen speichern saveAs.longdescription=Speichert die Karte unter einem neuen Namen saveAs.mnemonic=A @@ -221,7 +221,7 @@ revert.shortdescription=Zuletzt gespeicherte Fassung revert.longdescription=Macht alle \xC4nderungen r\xFCckg\xE4ngig und stellt die zuletzt gespeicherte Fassung wieder her revert.mnemonic=R -revert.error.text=Fehler beim zur\xFCcksetzen +revert.error.text=Fehler beim Zur\xFCcksetzen createImg.text=Bild speichern... createImg.shortdescription=Bild der Karte speichern @@ -373,6 +373,7 @@ # Tools tools.text=Werkzeuge +tools.mnemonic=W newScript.text=Neues Script newScript.mnemonic=P @@ -459,7 +460,7 @@ onlineHelp.text=Online-Hilfe onlineHelp.mnemonic=H -onlineHelp.accel=F11 +onlineHelp.accel=F1 about.text=\xDCber... about.mnemonic=A This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-25 20:22:17
|
Revision: 1275 http://svn.sourceforge.net/gridarta/?rev=1275&view=rev Author: christianhujer Date: 2006-12-25 12:22:17 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Merged FaceFacade with FaceObjects. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-25 15:03:10 UTC (rev 1274) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-25 20:22:17 UTC (rev 1275) @@ -32,7 +32,6 @@ import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; import daieditor.gameobject.anim.AnimationObjects; -import daieditor.gameobject.face.FaceFacade; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.match.MutableOrGameObjectMatcher; import daieditor.gameobject.match.ViewGameObjectMatcherManager; @@ -1508,7 +1507,7 @@ /** Invoked when the user wants to reload the images. */ public void reloadFaces() { - FaceFacade.reloadAll(); + FaceObjects.reloadAll(); } /** Invoked when user wants to exit from the program. */ @@ -1878,7 +1877,7 @@ } private static ImageIcon createWarningSquareIcon() { - final ImageFilter alphaFilter = FaceFacade.ALPHA_FILTER; + final ImageFilter alphaFilter = FaceObjects.ALPHA_FILTER; final ImageIcon sysIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_IWARNING); final Image image = sysIcon.getImage(); final ImageProducer source = image.getSource(); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-25 15:03:10 UTC (rev 1274) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-25 20:22:17 UTC (rev 1275) @@ -32,7 +32,7 @@ import daieditor.IGUIConstants; import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.DuplicateFaceException; -import daieditor.gameobject.face.FaceFacade; +import daieditor.gameobject.face.FaceObjects; import daieditor.icons.ArchFaceProvider; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -92,7 +92,7 @@ * @return face ImageIcon for face <var>faceName</var> */ public ImageIcon getFace(final String faceName) { - ImageIcon face = FaceFacade.normal.getFace(faceName); + ImageIcon face = FaceObjects.normal.getFace(faceName); if (face == null) { face = CMainControl.getUnknownTileIcon(); } @@ -105,7 +105,7 @@ * @return face ImageIcon for index <var>faceName</var> */ public ImageIcon getTrans(final String faceName) { - ImageIcon face = FaceFacade.ALPHA.getFace(faceName); + ImageIcon face = FaceObjects.ALPHA.getFace(faceName); if (face == null) { face = CMainControl.getUnknownTileIcon(); } @@ -134,7 +134,7 @@ if (mainControl.isArchLoadedFromCollection()) { loadArchFromCollected(); // load arches & images from collection } else { - FaceFacade.setNormal(new ArchFaceProvider()); + FaceObjects.setNormal(new ArchFaceProvider()); setLoadedFromArchive(false); // don't load from the collected files animFiles = new ArrayList<File>(); loadArchFromFiles(new File(mainControl.getArchDefaultFolder()), 0, "default", "default", false); // load arches & images from individual files @@ -424,7 +424,7 @@ */ private void addPNGFace(final String filename, final String name) { final String facename = generateFaceName(name); - ((ArchFaceProvider) FaceFacade.normal).addInfo(facename, filename); + ((ArchFaceProvider) FaceObjects.normal).addInfo(facename, filename); final int stripPath = new File(mainControl.getArchDefaultFolder()).getAbsolutePath().length(); try { mainControl.getFaceObjects().addFaceObject(facename, filename.substring(stripPath, filename.length() - 4).replace('\\', '/')); Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2006-12-25 15:03:10 UTC (rev 1274) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2006-12-25 20:22:17 UTC (rev 1275) @@ -26,7 +26,7 @@ package daieditor.gameobject.anim; -import daieditor.gameobject.face.FaceFacade; +import daieditor.gameobject.face.FaceObjects; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -103,7 +103,7 @@ /** {@inheritDoc} */ @Override public ImageIcon getDisplayIcon() { - return FaceFacade.normal.getFace(getFirstFrame(facings > 0 ? 1 : 0)); + return FaceObjects.normal.getFace(getFirstFrame(facings > 0 ? 1 : 0)); } /** Deleted: trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java 2006-12-25 15:03:10 UTC (rev 1274) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceFacade.java 2006-12-25 20:22:17 UTC (rev 1275) @@ -1,182 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2005 Christian Hujer - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.gameobject.face; - -import daieditor.icons.FaceProvider; -import daieditor.icons.FilterFaceProvider; -import java.awt.image.ImageFilter; -import java.awt.image.RGBImageFilter; -import javax.swing.GrayFilter; - -/** - * The FaceFacade hides the internals of the icons package in case the implementation changes. - * Access to features of the icons package is limited by the FaceFacade as well. - * The design of this class violates some oop rules to give as direct acess to faces as possible. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class FaceFacade { - - /** Grayscale filter to make grayscaled images. */ - private static final ImageFilter GRAY_FILTER = new GrayFilter(false, 50); - - /** Red filter to make images red. */ - private static final ImageFilter RED_FILTER = new ColourFilter(0x00FF0000); - - /** Green filter to make images green. */ - private static final ImageFilter GREEN_FILTER = new ColourFilter(0x0000FF00); - - /** Blue filter to make images blue. */ - private static final ImageFilter BLUE_FILTER = new ColourFilter(0x000000FF); - - /** Transparency filter to make transparent images. */ - public static final ImageFilter ALPHA_FILTER = new RGBImageFilter() { - - /** - * Converts a pixel by increasing the transparency. - * {@inheritDoc} - */ - @Override public int filterRGB(final int x, final int y, final int rgb) { - // This is sufficient since alpha channel isn't used in the graphics this is required for. - return rgb >>> 24 == 0 ? rgb : rgb & 0x00FFFFFF | 0x80000000; - } - - }; // ALPHA_FILTER - - /** Transparency filter using a full alpha grid instead of alpha blending. */ - private static final ImageFilter GRID_FILTER = new RGBImageFilter() { - - /** - * Converts every second pixel by making it transparent. - * {@inheritDoc} - */ - @Override public int filterRGB(final int x, final int y, final int rgb) { - return (x + y) % 2 != 0 ? rgb : rgb & 0x00FFFFFF; - } - - }; // GRID_FILTER - - /** Class to filter images by simply applying a boolean OR operation. */ - private static final class ColourFilter extends RGBImageFilter { - - /** The positive mask to apply. */ - private final int positiveMask; - - /** The negative mask to apply. */ - private final int negativeMask; - - /** - * Create an ColourFilter. - * @param mask Mask to apply - */ - private ColourFilter(final int mask) { - positiveMask = mask & 0xFFFFFF; - negativeMask = ~mask & 0xFFFFFF; - } - - /** - * Converts a pixel by applying an or operation. - * {@inheritDoc} - */ - @Override public int filterRGB(final int x, final int y, final int rgb) { - final int alpha = rgb & 0xFF000000; - final float r = rgb >> 16 & 0xFF; - final float g = rgb >> 8 & 0xFF; - final float b = rgb & 0xFF; - int gray1 = (int) (0.66 * r + 0.66 * g + 0.66 * b); - int gray2 = gray1 - 256; - if (gray1 < 0) { - gray1 = 0; - } - if (gray1 > 255) { - gray1 = 255; - } - if (gray2 < 0) { - gray2 = 0; - } - if (gray2 > 255) { - gray2 = 255; - } - gray1 = gray1 | gray1 << 8 | gray1 << 16; - gray2 = gray2 | gray2 << 8 | gray2 << 16; - - return alpha | gray1 & positiveMask | gray2 & negativeMask; - } - - /** {@inheritDoc} */ - @Override public Object clone() { - return super.clone(); - } - - } // class OrFilter - - /** - * The FaceProvider for normal faces. - * Only read this, do not write this! - * Setting this provider must be done with setNormalProvider, otherwise all other providers will not work! - */ - public static FaceProvider normal; - - /** The FaceProvider for GRAY faces. */ - public static final FaceProvider GRAY = new FilterFaceProvider(GRAY_FILTER); - - /** The FaceProvider for red faces. */ - public static final FaceProvider RED = new FilterFaceProvider(RED_FILTER); - - /** The FaceProvider for green faces. */ - public static final FaceProvider GREEN = new FilterFaceProvider(GREEN_FILTER); - - /** The FaceProvider for blue faces. */ - public static final FaceProvider BLUE = new FilterFaceProvider(BLUE_FILTER); - - /** The FaceProvider for alpha faces. */ - public static final FaceProvider ALPHA = new FilterFaceProvider(ALPHA_FILTER); - - /** The FaceProvider for grid faces. */ - public static final FaceProvider GRID = new FilterFaceProvider(GRID_FILTER); - - /** Reloads all providers provided by this FaceFacade. */ - public static void reloadAll() { - for (final FaceProvider faceProvider : new FaceProvider[]{normal, GRAY, RED, GREEN, BLUE, ALPHA, GRID}) { - faceProvider.reload(); - } - } - - /** - * Set the normal FaceProvider. - * The normal FaceProvider also serves as parent for all other FaceProviders. - * @param normal FaceProvider that provides normal images - */ - public static void setNormal(final FaceProvider normal) { - FaceFacade.normal = normal; - ((FilterFaceProvider) GRAY).setParent(normal); - ((FilterFaceProvider) RED).setParent(normal); - ((FilterFaceProvider) GREEN).setParent(normal); - ((FilterFaceProvider) BLUE).setParent(normal); - ((FilterFaceProvider) ALPHA).setParent(normal); - ((FilterFaceProvider) GRID).setParent(normal); - } - - /** Private constructor to avoid instantiation. */ - private FaceFacade() { - } - -} // class FaceFacade Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2006-12-25 15:03:10 UTC (rev 1274) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2006-12-25 20:22:17 UTC (rev 1275) @@ -108,7 +108,7 @@ /** {@inheritDoc} */ @Override public ImageIcon getDisplayIcon() { - return FaceFacade.normal.getFace(faceName); + return FaceObjects.normal.getFace(faceName); } /** Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-12-25 15:03:10 UTC (rev 1274) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-12-25 20:22:17 UTC (rev 1275) @@ -25,6 +25,8 @@ import daieditor.IGUIConstants; import daieditor.icons.ArchFaceProvider; import daieditor.icons.DaimoninFaceProvider; +import daieditor.icons.FaceProvider; +import daieditor.icons.FilterFaceProvider; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -39,11 +41,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.awt.image.RGBImageFilter; +import java.awt.image.ImageFilter; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import javax.swing.GrayFilter; /** * This class manages the FaceObjects. @@ -51,6 +56,146 @@ */ public final class FaceObjects extends AbstractFaceObjects<FaceObject> { + /** Grayscale filter to make grayscaled images. */ + private static final ImageFilter GRAY_FILTER = new GrayFilter(false, 50); + + /** Red filter to make images red. */ + private static final ImageFilter RED_FILTER = new ColourFilter(0x00FF0000); + + /** Green filter to make images green. */ + private static final ImageFilter GREEN_FILTER = new ColourFilter(0x0000FF00); + + /** Blue filter to make images blue. */ + private static final ImageFilter BLUE_FILTER = new ColourFilter(0x000000FF); + + /** Transparency filter to make transparent images. */ + public static final ImageFilter ALPHA_FILTER = new RGBImageFilter() { + + /** + * Converts a pixel by increasing the transparency. + * {@inheritDoc} + */ + @Override public int filterRGB(final int x, final int y, final int rgb) { + // This is sufficient since alpha channel isn't used in the graphics this is required for. + return rgb >>> 24 == 0 ? rgb : rgb & 0x00FFFFFF | 0x80000000; + } + + }; // ALPHA_FILTER + + /** Transparency filter using a full alpha grid instead of alpha blending. */ + private static final ImageFilter GRID_FILTER = new RGBImageFilter() { + + /** + * Converts every second pixel by making it transparent. + * {@inheritDoc} + */ + @Override public int filterRGB(final int x, final int y, final int rgb) { + return (x + y) % 2 != 0 ? rgb : rgb & 0x00FFFFFF; + } + + }; // GRID_FILTER + + /** Class to filter images by simply applying a boolean OR operation. */ + private static final class ColourFilter extends RGBImageFilter { + + /** The positive mask to apply. */ + private final int positiveMask; + + /** The negative mask to apply. */ + private final int negativeMask; + + /** + * Create an ColourFilter. + * @param mask Mask to apply + */ + private ColourFilter(final int mask) { + positiveMask = mask & 0xFFFFFF; + negativeMask = ~mask & 0xFFFFFF; + } + + /** + * Converts a pixel by applying an or operation. + * {@inheritDoc} + */ + @Override public int filterRGB(final int x, final int y, final int rgb) { + final int alpha = rgb & 0xFF000000; + final float r = rgb >> 16 & 0xFF; + final float g = rgb >> 8 & 0xFF; + final float b = rgb & 0xFF; + int gray1 = (int) (0.66 * r + 0.66 * g + 0.66 * b); + int gray2 = gray1 - 256; + if (gray1 < 0) { + gray1 = 0; + } + if (gray1 > 255) { + gray1 = 255; + } + if (gray2 < 0) { + gray2 = 0; + } + if (gray2 > 255) { + gray2 = 255; + } + gray1 = gray1 | gray1 << 8 | gray1 << 16; + gray2 = gray2 | gray2 << 8 | gray2 << 16; + + return alpha | gray1 & positiveMask | gray2 & negativeMask; + } + + /** {@inheritDoc} */ + @Override public Object clone() { + return super.clone(); + } + + } // class OrFilter + + /** + * The FaceProvider for normal faces. + * Only read this, do not write this! + * Setting this provider must be done with setNormalProvider, otherwise all other providers will not work! + */ + public static FaceProvider normal; + + /** The FaceProvider for GRAY faces. */ + public static final FaceProvider GRAY = new FilterFaceProvider(GRAY_FILTER); + + /** The FaceProvider for red faces. */ + public static final FaceProvider RED = new FilterFaceProvider(RED_FILTER); + + /** The FaceProvider for green faces. */ + public static final FaceProvider GREEN = new FilterFaceProvider(GREEN_FILTER); + + /** The FaceProvider for blue faces. */ + public static final FaceProvider BLUE = new FilterFaceProvider(BLUE_FILTER); + + /** The FaceProvider for alpha faces. */ + public static final FaceProvider ALPHA = new FilterFaceProvider(ALPHA_FILTER); + + /** The FaceProvider for grid faces. */ + public static final FaceProvider GRID = new FilterFaceProvider(GRID_FILTER); + + /** Reloads all providers provided by this FaceObjects. */ + public static void reloadAll() { + for (final FaceProvider faceProvider : new FaceProvider[]{normal, GRAY, RED, GREEN, BLUE, ALPHA, GRID}) { + faceProvider.reload(); + } + } + + /** + * Set the normal FaceProvider. + * The normal FaceProvider also serves as parent for all other FaceProviders. + * @param normal FaceProvider that provides normal images + */ + public static void setNormal(final FaceProvider normal) { + FaceObjects.normal = normal; + ((FilterFaceProvider) GRAY).setParent(normal); + ((FilterFaceProvider) RED).setParent(normal); + ((FilterFaceProvider) GREEN).setParent(normal); + ((FilterFaceProvider) BLUE).setParent(normal); + ((FilterFaceProvider) ALPHA).setParent(normal); + ((FilterFaceProvider) GRID).setParent(normal); + } + /** Size of the image buffer. */ private static final int IMAGE_BUFFER_SIZE = 50 * 1024; @@ -103,7 +248,7 @@ * @throws DuplicateFaceException in case a face was not unique */ public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - FaceFacade.setNormal(new DaimoninFaceProvider(faceFile)); + FaceObjects.setNormal(new DaimoninFaceProvider(faceFile)); final String actualFilename = faceFile.toString(); byte[] data; // open a bytestream to the resource file @@ -159,7 +304,7 @@ addFaceObject(faceName, originalFilename, actualFilename, offset, size); } } - ((DaimoninFaceProvider) FaceFacade.normal).addInfo(faceName, offset, size); // TODO Remove me + ((DaimoninFaceProvider) FaceObjects.normal).addInfo(faceName, offset, size); // TODO Remove me offset += size; } } finally { @@ -258,7 +403,7 @@ numBytes = 0; final String num2 = Integer.toString(++i); final String numstring2 = def.substring(0, 5 - num2.length()) + num2; - final String path2 = ((ArchFaceProvider) FaceFacade.normal).getFilename(face); + final String path2 = ((ArchFaceProvider) FaceObjects.normal).getFilename(face); try { // try to open the png image file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-25 20:43:01
|
Revision: 1276 http://svn.sourceforge.net/gridarta/?rev=1276&view=rev Author: christianhujer Date: 2006-12-25 12:43:00 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Merged icons package with gameobject/face package. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/package.html Added Paths: ----------- trunk/daimonin/src/daieditor/gameobject/face/AbstractFaceProvider.java trunk/daimonin/src/daieditor/gameobject/face/ArchFaceProvider.java trunk/daimonin/src/daieditor/gameobject/face/DaimoninFaceProvider.java trunk/daimonin/src/daieditor/gameobject/face/FaceProvider.java trunk/daimonin/src/daieditor/gameobject/face/FilterFaceProvider.java Removed Paths: ------------- trunk/daimonin/src/daieditor/icons/ Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-25 20:22:17 UTC (rev 1275) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -33,7 +33,7 @@ import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.DuplicateFaceException; import daieditor.gameobject.face.FaceObjects; -import daieditor.icons.ArchFaceProvider; +import daieditor.gameobject.face.ArchFaceProvider; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; Copied: trunk/daimonin/src/daieditor/gameobject/face/AbstractFaceProvider.java (from rev 1275, trunk/daimonin/src/daieditor/icons/AbstractFaceProvider.java) =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/AbstractFaceProvider.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/face/AbstractFaceProvider.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -0,0 +1,68 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2005 Christian Hujer + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gameobject.face; + +import java.lang.ref.SoftReference; +import java.util.HashMap; +import java.util.Map; +import javax.swing.ImageIcon; + +/** + * Abstract Base class for FaceProviders which implements a memory sensitive cache. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractFaceProvider implements FaceProvider { + + /** + * The HashMap to provide the icons from. + * Note: Weak hashing does not differ because the keys are definitely referenced elsewhere. + */ + private final Map<String, SoftReference<ImageIcon>> cache = new HashMap<String, SoftReference<ImageIcon>>(); + + /** {@inheritDoc} */ + public final ImageIcon getFace(final String faceName) { + ImageIcon icon = null; + final SoftReference<ImageIcon> ref = cache.get(faceName); + if (ref != null) { + icon = ref.get(); + } + if (icon == null) { + icon = createImage(faceName); + cache.put(faceName, new SoftReference<ImageIcon>(icon)); + } + return icon; + } + + /** {@inheritDoc} */ + public void reload() { + System.err.println("Clearing image cache."); + cache.clear(); + } + + /** + * Create an image not found in the cache. + * @param faceName face name to get image for, excluding path and ending + * @return icon for faceName + */ + protected abstract ImageIcon createImage(String faceName); + +} // class AbstractFaceProvider Property changes on: trunk/daimonin/src/daieditor/gameobject/face/AbstractFaceProvider.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/daimonin/src/daieditor/gameobject/face/ArchFaceProvider.java (from rev 1275, trunk/daimonin/src/daieditor/icons/ArchFaceProvider.java) =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/ArchFaceProvider.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/face/ArchFaceProvider.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -0,0 +1,79 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2005 Christian Hujer + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gameobject.face; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import javax.swing.ImageIcon; +import org.jetbrains.annotations.Nullable; + +/** + * Implementation of FaceProvider which reads images from the daimonin arch directory. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo Move scanning for face files to this class, so the faces can be easily reloaded while the application is running. + */ +public final class ArchFaceProvider extends AbstractFaceProvider { + + /** + * The icon filename. + * The value is a String with the full reachable path of the png file. + */ + private final Map<String, String> files = new HashMap<String, String>(); + + /** Create a ArchFaceProvider. */ + public ArchFaceProvider() { + } + + /** + * Report position of a face for loading it later. + * @param faceName face name to get image for, excluding path and ending + * @param fileName filename with full reachable path of the png file (maybe relative but must be loadable). + */ + public void addInfo(final String faceName, final String fileName) { + files.put(faceName, fileName); + } + + /** + * Get the filename for a face. + * @param faceName face name to get filename for + * @return filename for <var>faceName</var> or <code>null</code> if no face + */ + public String getFilename(final String faceName) { + return files.get(faceName); + } + + /** {@inheritDoc} */ + @Nullable @Override protected ImageIcon createImage(final String faceName) { + try { + final File file = new File(files.get(faceName)); + if (!file.exists()) { + return null; + } + //System.err.println("Loading new image for " + faceName); + return new ImageIcon(files.get(faceName)); + } catch (final Exception e) { + return null; + } + } + +} // class ArchFaceProvider Property changes on: trunk/daimonin/src/daieditor/gameobject/face/ArchFaceProvider.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/daimonin/src/daieditor/gameobject/face/DaimoninFaceProvider.java (from rev 1275, trunk/daimonin/src/daieditor/icons/DaimoninFaceProvider.java) =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/DaimoninFaceProvider.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/face/DaimoninFaceProvider.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -0,0 +1,90 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2005 Christian Hujer + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gameobject.face; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.RandomAccessFile; +import java.util.HashMap; +import java.util.Map; +import javax.swing.ImageIcon; +import org.jetbrains.annotations.Nullable; + +/** + * Implementation of FaceProvider which reads images from the daimonin PNG archive. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo Construction of this class should succeed even in case the face file is unavailable. + * @todo Move parsing of the face files to this class, so the faces can be easily reloaded while the application is running. + */ +public final class DaimoninFaceProvider extends AbstractFaceProvider { + + /** + * The icon position and size are stored here. + * The value is a long with the highint being the position and the lowint being the size. + */ + private final Map<String, Long> positions = new HashMap<String, Long>(); + + /** The file to read from. */ + private final RandomAccessFile file; + + /** + * Create a DaimoninFaceProvider. + * @param file file where icons are found + * @throws FileNotFoundException in case the File <var>file</var> wasn't found + */ + public DaimoninFaceProvider(final File file) throws FileNotFoundException { + this.file = new RandomAccessFile(file, "r"); + } + + /** + * Create a DaimoninFaceProvider. + * @param fileName name of file where icons are found + * @throws FileNotFoundException in case the File with name <var>fileName</var> wasn't found + */ + public DaimoninFaceProvider(final String fileName) throws FileNotFoundException { + this.file = new RandomAccessFile(fileName, "r"); + } + + /** + * Report posistion and size of a face for loading it later. + * @param faceName face name to get image for, excluding path and ending + * @param pos position of image + * @param size Size of image + */ + public void addInfo(final String faceName, final int pos, final int size) { + positions.put(faceName, (long) pos << 32 | size); + } + + /** {@inheritDoc} */ + @Nullable @Override protected ImageIcon createImage(final String faceName) { + try { + final long posI = positions.get(faceName); + file.seek(posI >> 32); + final byte[] buf = new byte[(int) posI]; + file.readFully(buf); + return new ImageIcon(buf); + } catch (final Exception e) { + return null; + } + } + +} // class DaimoninFaceProvider Property changes on: trunk/daimonin/src/daieditor/gameobject/face/DaimoninFaceProvider.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-12-25 20:22:17 UTC (rev 1275) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -23,10 +23,10 @@ import daieditor.CMainControl; import daieditor.IGUIConstants; -import daieditor.icons.ArchFaceProvider; -import daieditor.icons.DaimoninFaceProvider; -import daieditor.icons.FaceProvider; -import daieditor.icons.FilterFaceProvider; +import daieditor.gameobject.face.ArchFaceProvider; +import daieditor.gameobject.face.DaimoninFaceProvider; +import daieditor.gameobject.face.FaceProvider; +import daieditor.gameobject.face.FilterFaceProvider; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; Copied: trunk/daimonin/src/daieditor/gameobject/face/FaceProvider.java (from rev 1275, trunk/daimonin/src/daieditor/icons/FaceProvider.java) =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceProvider.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceProvider.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -0,0 +1,46 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2005 Christian Hujer + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gameobject.face; + +import javax.swing.ImageIcon; + +/** + * This interface represents a lazy loader that provides images on demand. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface FaceProvider { + + /** + * Get an image from this FaceProvider. + * @param faceName face name to get image for, excluding path and ending + * @return icon for faceName + */ + ImageIcon getFace(String faceName); + + /** + * Reload faces. + * This method does not really immediately reload all faces, lazy loading is allowed. + * But all old face information definitely is flushed, so in case the files on harddisk have changed, they will be freshly loaded from harddisk. + */ + void reload(); + +} // interface FaceProvider Property changes on: trunk/daimonin/src/daieditor/gameobject/face/FaceProvider.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/daimonin/src/daieditor/gameobject/face/FilterFaceProvider.java (from rev 1275, trunk/daimonin/src/daieditor/icons/FilterFaceProvider.java) =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FilterFaceProvider.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/face/FilterFaceProvider.java 2006-12-25 20:43:00 UTC (rev 1276) @@ -0,0 +1,83 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2005 Christian Hujer + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gameobject.face; + +import java.awt.Toolkit; +import java.awt.image.FilteredImageSource; +import java.awt.image.ImageFilter; +import javax.swing.ImageIcon; +import org.jetbrains.annotations.Nullable; + +/** + * A FilterFaceProvider provides modified versions of icons provided by another FaceProvider by applying a Filter. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class FilterFaceProvider extends AbstractFaceProvider { + + /** The FaceProvider to get the original icon from. */ + private FaceProvider parent; + + /** The Filter to apply. */ + private final ImageFilter filter; + + /** + * Create a FilterFaceProvider. + * The parent is unset. + * The parent must be set with {@link #setParent(FaceProvider)} bevore invoking {@link #getFace(String)} or {@link #createImage(String)} or getting + * a face resp. creating an image will throw an IllegalStateException. + * @param filter ImageFilter to apply for creating the images + */ + public FilterFaceProvider(final ImageFilter filter) { + this.filter = filter; + } + + /** + * Create a FilterFaceProvider. + * @param parent parent provider to get unfiltered images from + * @param filter ImageFilter to apply for creating the images + */ + public FilterFaceProvider(final FaceProvider parent, final ImageFilter filter) { + this.parent = parent; + this.filter = filter; + } + + /** + * Sets a new provider as parent. + * @param parent parent provider to get unfiltered images from + */ + public void setParent(final FaceProvider parent) { + this.parent = parent; + } + + /** {@inheritDoc} */ + @Nullable @Override protected ImageIcon createImage(final String faceName) { + try { + return new ImageIcon(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(parent.getFace(faceName).getImage().getSource(), filter))); + } catch (final Exception e) { + if (parent == null) { + throw new IllegalStateException("FilterFaceProvider in use but parent not set."); + } + return null; + } + } + +} // class FilterFaceProdiver Property changes on: trunk/daimonin/src/daieditor/gameobject/face/FilterFaceProvider.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gameobject/face/package.html =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/package.html 2006-12-25 20:22:17 UTC (rev 1275) +++ trunk/daimonin/src/daieditor/gameobject/face/package.html 2006-12-25 20:43:00 UTC (rev 1276) @@ -9,5 +9,69 @@ <p> This package containes classes related to faces. </p> + <p> + This package contains classes for managing icons in memory sensitive caches. + Currently, the keys to lookup the icons are Strings (usually the facename of an arch), and lookup is done in Hashmaps. + </p> + <p> + Hashmaps are fast, but, of course, never as fast as an indexed array. + Though, Hashmaps are easier to maintain. + In case someone complains about the usage of Hashmaps instead of arrays in this package, I have documented my performance considerations. + </p> + <dl> + <dt>How fast is String hashCode generation?</dt> + <dd>Extremely fast. Strings are often used as Hash keys, therefore a String's hash code is ached and only calculated the first time a it is + queried. All subsequent invocations return the previously calculated, cached hash code.</dd> + <dt>How fast is Hashmap lookup compared with Array indexing?</dt> + <dd> + To index an Array gives a constant speed of <var>O[array] = O(c)</var> where <var>c</var> is the time it takes to address and offset. + To lookup in a Hashmap gives a performance of approximately <var>O[hashmap] = O(2*c + log2(n)*c*2)</var> where <var>n</var> is the + number of HashMap entries. + In general, a Hashmap gives a very good performance, but not compared with an array when an index can be used. + </dd> + <dt>How does lookup scale?</dt> + <dd> + Lookup is used every time the code needs an image, which is nearly every time some painting is done by Java. + Since maps are 2.5-dimensional structures, the lookup part of painting maps gives a general perforamnce of <var>O[paintLookup] = O(O[lookup] * x * y * z)</var>. + For a map with the size 24*24 and an average tile coverage of 2 faces requires 24*24*2 lookups which is 1152 lookups. And let + <var>n</var>, the number of HashMap entries, be 3688. + If <var>O[lookup] == O[array]</var>, the performance is + <var>O[paintLookup] = O(c * x * y * z) = O(c * 1152)</var>. + If <var>O[lookup] == O[hashmap]</var>, the performance is + <var>O[paintLookup] = O((2*c + log2(n)*c*2) * x * y * z) = O((2*c + log2(3688)*c*2) * 1152) = O((2*c + 24*c) * 1152) = O(c * 29952)</var> + It is a realistic asumption that the number of effective cycles required for performing a lookup in Java is always smaller than 10 + times the performance. + That means, a complete map paint lookup for the given exmaple map takes less than 300,000 cycles when using a HashMap. Current CPUs + execute about 5,000,000,000 cycles per second. + </dd> + <dt>How often is lookup needed?</dt> + <dd> + Repainting is done when a new tile was painted, the map scrolls, a map was loaded, hidden or otherwise gets completely refreshed, an + archpanel scrolls or a pickmap is used. + Lookup does not happen more than 2-3 times per second, except for scrolling. + </dd> + <dt>Other considerations</dt> + <dd> + The design to generate artificial indices for faces has some flaws. + Keeping several arrays in parallel to hold the same information can cause serious, eventually difficult to find bugs. + Such a design also prevents the implementation of dynamic arch handling, where arches and faces should be loadable, editable and + unloadable during editor runtime. + The allocation of several large arrays also is a serious indicator for design flaws when using artificial indices, also these arrays + need to be anxiously oversized to not get into ArrayIndexOutOfBounds trouble. + The natural index of a face is its name, the object oriented index of a face is its own reference. + Mapping face names to face references therefore is a good and clear design and very resistent against bugs or overflouws. + <p /> + Also, an arch first naturally comes with a face name. + To get an index for a face name, it is required to first do a linear search. + Linear search is always wrong and averages to <var>O(n * c)</var> which is worse than HashMap performance. + If the indices are sorted, a binary search with a performance of <var>O(2*c + log2(n)*c*2)</var>, which is exactly what a Hashmap does. + That means, the term that best describes the usage of artificial face indices for increasing face lookup performance is "Augenauswischerei". + </dd> + </dl> + <h4>Conclusions</h4> + <ul> + <li>Do not use the face number for face lookup, use the face name instead.</li> + <li>Future: Refactor all code to eliminate artificial indices for faces and arches</li> + </ul> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-09 23:13:14
|
Revision: 1533 http://svn.sourceforge.net/gridarta/?rev=1533&view=rev Author: akirschbaum Date: 2007-01-09 15:13:11 -0800 (Tue, 09 Jan 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-09 23:10:02 UTC (rev 1532) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-09 23:13:11 UTC (rev 1533) @@ -709,10 +709,6 @@ mapArchPanel.setErrors(errors); } - public GameObjectAttributesPanel getMapArchPanel() { - return mapArchPanel; - } - /** * Return whether all pickmaps are locked. * Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-09 23:10:02 UTC (rev 1532) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-09 23:13:11 UTC (rev 1533) @@ -199,29 +199,7 @@ return mapControl.getActiveEditType(); } - public MapControl getMapControl() { - return mapControl; - } - /** - * Returns the controller of this view. - * @return The controller of this view. - */ - public MapControl getLevel() { - return mapControl; - } - - /** - * This method returns the bounding rectangle of the selection - * There may be non-selected tiles in that rectangle - * This method is mainly useful for creating a submap for copy/paste operations. - * @return selected Rectangle - */ - @Nullable public Rectangle getSelectionRec() { - return mapGrid.getSelectedRec(); - } - - /** * Get the cursor position. * The cursor position does not neccessarily mark a selection. * Selection is independent of the cursor. @@ -233,15 +211,6 @@ } /** - * Set the cursor position. - * @param cursorPosition cursor position - * @see #getCursorPosition() - */ - public void setCursorPosition(final Point cursorPosition) { - mapCursor.setLocation(cursorPosition); - } - - /** * Get the cursor square. * @return cursor square or <code>null</code> if no current cursor * @see #getCursorPosition() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-14 21:53:01
|
Revision: 1600 http://svn.sourceforge.net/gridarta/?rev=1600&view=rev Author: christianhujer Date: 2007-01-13 15:53:55 -0800 (Sat, 13 Jan 2007) Log Message: ----------- Adding Andreas Kirschbaum to list of Gridarta4Daimonin developers in about dialog. Modified Paths: -------------- trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2007-01-13 22:28:31 UTC (rev 1599) +++ trunk/daimonin/src/daieditor/messages.properties 2007-01-13 23:53:55 UTC (rev 1600) @@ -641,7 +641,7 @@ about.mnemonic=A about.title=About Gridarta for Daimonin -about=<html><h1 align="center">Gridarta for Daimonin</h1><p>Editor for Daimonin MMORPG maps and arches</p><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2006</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Build number:</td><td>{1}</td></tr><tr><td align="right">by:</td><td>{2}</td></tr><tr><td align="right">at:</td><td>{3}</td></tr></table></html> +about=<html><h1 align="center">Gridarta for Daimonin</h1><p>Editor for Daimonin MMORPG maps and arches</p><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2007</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas</td><td>Andreas Kirschbaum</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Build number:</td><td>{1}</td></tr><tr><td align="right">by:</td><td>{2}</td></tr><tr><td align="right">at:</td><td>{3}</td></tr></table></html> aboutTab.title=About license.text=License... Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2007-01-13 22:28:31 UTC (rev 1599) +++ trunk/daimonin/src/daieditor/messages_de.properties 2007-01-13 23:53:55 UTC (rev 1600) @@ -478,7 +478,7 @@ about.mnemonic=B about.title=\xDCber Gridarta -about=<html><h1 align="center">Gridarta f\xFCr Daimonin</h1><p>Editor f\xFCr Daimonin MMORPG Karten und Objekte</p><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2006</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Build-Nummer:</td><td>{1}</td></tr><tr><td align="right">Build-Entwickler:</td><td>{2}</td></tr><tr><td align="right">Build-Zeit:</td><td>{3}</td></tr></table></html> +about=<html><h1 align="center">Gridarta f\xFCr Daimonin</h1><p>Editor f\xFCr Daimonin MMORPG Karten und Objekte</p><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2006</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas</td><td>Andreas Kirschbaum</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Build-Nummer:</td><td>{1}</td></tr><tr><td align="right">Build-Entwickler:</td><td>{2}</td></tr><tr><td align="right">Build-Zeit:</td><td>{3}</td></tr></table></html> aboutTab.title=\xDCber license.text=Lizenz... Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2007-01-13 22:28:31 UTC (rev 1599) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2007-01-13 23:53:55 UTC (rev 1600) @@ -302,7 +302,7 @@ about.mnemonic=A about.title=\xC0 propos de DaimoninEditor BETA3 v0.966 -about=Version BETA3 v0.966\n(c) 2001-2005 Michael Toennies\nAndreas Vogl\nPeter Plischewsky\nGecko\nChristian Hujer +about=Version BETA3 v0.966\n(c) 2001-2005 Michael Toennies\nAndreas Vogl\nPeter Plischewsky\nGecko\nChristian Hujer\nAndreas Kirschbaum ############# # Status Bar Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2007-01-13 22:28:31 UTC (rev 1599) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2007-01-13 23:53:55 UTC (rev 1600) @@ -766,7 +766,7 @@ about.mnemonic=O about.title=Om DaimoninEditor BETA3 v0.966 -about=<html><h1 align="center">Daimonin Editor</h1><h2 align="center">Version BETA3 v0.966</h2><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2006</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Build number:</td><td>{1}</td></tr><tr><td align="right">av:</td><td>{2}</td></tr><tr><td align="right">datum:</td><td>{3}</td></tr></table></html> +about=<html><h1 align="center">Daimonin Editor</h1><h2 align="center">Version BETA3 v0.966</h2><table><tr><td valign="top" align="right" width="50%">Copyright \xA9 2001-2006</td><td width="50%">Michael Toennies<br>Andreas Vogl<br>Peter Plischewsky<br>Gecko<br>Christian Hujer<br>Daniel Viegas</td><td>Andreas Kirschbaum</td></tr><tr><td align="right">Java version:</td><td>{0}</td></tr><tr><td align="right">Build number:</td><td>{1}</td></tr><tr><td align="right">av:</td><td>{2}</td></tr><tr><td align="right">datum:</td><td>{3}</td></tr></table></html> aboutTab.title=Om license.text=Licens... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-23 19:03:20
|
Revision: 1670 http://svn.sourceforge.net/gridarta/?rev=1670&view=rev Author: akirschbaum Date: 2007-01-23 11:02:05 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Do not change view position when reverting a map. Modified Paths: -------------- trunk/daimonin/src/daieditor/CFJavaEditor.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/MapViewIFrame.java trunk/daimonin/src/daieditor/gui/NewMapDialog.java trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/map/MapControl.java Modified: trunk/daimonin/src/daieditor/CFJavaEditor.java =================================================================== --- trunk/daimonin/src/daieditor/CFJavaEditor.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/CFJavaEditor.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -142,7 +142,7 @@ } if (in.canRead()) { - final MapControl mapControl = mainControl.openFile(in, true); + final MapControl mapControl = mainControl.openFile(in, true, null); mainControl.createImageWanted(mapControl, out); mainControl.close(mapControl); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -859,14 +859,15 @@ * @param objects the list of map objects, or <code>null</code> for new empty maps * @param maparch map arch * @param view Only create a view if this is true + * @param initial the view position to show initially; null=show top left corner * @return map control of new map */ - public MapControl newLevel(final List<GameObject> objects, final MapArchObject maparch, final boolean view) { + public MapControl newLevel(final List<GameObject> objects, final MapArchObject maparch, final boolean view, final Point initial) { // Create a new level control and set the level view from that if (view) { setStatusText("Creating new map " + maparch.getMapName()); } - final MapControl mapControl = new MapControl(this, objects, maparch, false, view); + final MapControl mapControl = new MapControl(this, objects, maparch, false, initial, view); fireMapCreatedEvent(mapControl); levels.add(mapControl); if (view) { @@ -1096,16 +1097,17 @@ * something went wrong */ public boolean openFile(final File file) { - return openFile(file, true) != null; + return openFile(file, true, null) != null; } /** * Load a mapfile. * @param file mapfile * @param view only create a view if this is true + * @param initial the view position to show initially * @return MapControl of loaded file or <code>null</code> if the file couldn't be opened */ - @Nullable public MapControl openFile(final File file, final boolean view) { + @Nullable public MapControl openFile(final File file, final boolean view, final Point initial) { // First look whether the file isn't already open. // If so, return the previously loaded map. try { @@ -1114,7 +1116,7 @@ final File levelFile = mapControl.getMapFile(); if (levelFile != null && can.equals(levelFile.getCanonicalFile())) { if (view) { - mapControl.createView(); + mapControl.createView(null); setCurrentLevel(mapControl); setCurrentLevelView(mapControl.getMapViewFrame()); } @@ -1131,7 +1133,7 @@ final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile final MapArchObject maparch = decoder.getMapArch(); // get map arch // go to ArchetypeParser and add the default arch list information to them - final MapControl newMapControl = newLevel(objects, maparch, view); // init the map + final MapControl newMapControl = newLevel(objects, maparch, view, initial); // init the map // finally, show the map and refresh toolbars newMapControl.setMapFile(file); @@ -1327,7 +1329,7 @@ /** Invoked when user wants to create a new view of the current level. */ public void mapCreateView() { - currentMap.createView(); + currentMap.createView(null); } /** Invoked when user wants to see/edit the level properties. */ @@ -1611,8 +1613,9 @@ public void revert(@NotNull final MapControl mapControl) { if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { final File mfile = mapControl.getMapFile(); // store file + final Point initial = mapControl.getViewPosition(); closeLevel(mapControl, true); // close the old map - openFile(mfile); // open the new map + openFile(mfile, true, initial); // open the new map // Update the main view so the new map instantly pops up. mainView.update(mainView.getGraphics()); Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -114,8 +114,10 @@ * Constructs a level view. * @param mainControl the main controller * @param mapControl the controller of this view + * @param initial the initial view position to show; null=show top left + * corner */ - CMapViewBasic(final CMainControl mainControl, final MapControl mapControl) { + CMapViewBasic(final CMainControl mainControl, final MapControl mapControl, final Point initial) { super(VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; mapModel = mapControl.getMapModel(); @@ -142,6 +144,11 @@ // set the pixel increment scrolling for clicking once on a scrollbar arrow getVerticalScrollBar().setUnitIncrement(IGUIConstants.TILE_ISO_YLEN); getHorizontalScrollBar().setUnitIncrement(IGUIConstants.TILE_ISO_XLEN); + + if (initial != null) { + getViewport().setViewPosition(initial); + } + mapUserListener = new MapUserListener(mainControl, mapControl, this); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); @@ -284,6 +291,14 @@ } /** + * Return the current view position. + * @return the current view position + */ + public Point getViewPosition() { + return getViewport().getViewPosition(); + } + + /** * Highlight the tile at given coordinates (just as if it had been selected with leftclick). * Besides, the mapview is always centered on the coordinates as far as possible. * @param pos coordinate Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -123,7 +123,7 @@ } mapArch.setMapSize(new Size2D(selRec.width + 1, selRec.height + 1)); - copyMapCtrl = new MapControl(mainControl, null, mapArch, false, false); // new MapControl + copyMapCtrl = new MapControl(mainControl, null, mapArch, false, null, false); // new MapControl copyMapCtrl.setMapFileName("cb"); copyMap = copyMapCtrl.getMapModel(); Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -128,9 +128,11 @@ * Constructs a level view. * @param mainControl the main controller * @param mapControl the controller of this view + * @param initial the view position to show initially; null=show top left + * corner * @param number Each view of a level will get a number */ - public MapViewIFrame(final CMainControl mainControl, final MapControl mapControl, final int number) { + public MapViewIFrame(final CMainControl mainControl, final MapControl mapControl, final Point initial, final int number) { // set title super(PathManager.getMapPath(mapControl.getMapFileName()) + " [ " + mapControl.getMapArchObject().getMapDisplayName() + " ] (" + number + ')', true, true, true, true); this.mapControl = mapControl; @@ -140,7 +142,7 @@ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // create instance of "real" view object and add it to the frame - view = new CMapViewBasic(mainControl, mapControl); + view = new CMapViewBasic(mainControl, mapControl, initial); getContentPane().setLayout(new BorderLayout()); getContentPane().add(view, BorderLayout.CENTER); mapFileActions = null;//new MapFileActions(mainControl, mapControl); // XXX: uncomment this after JAPI can create multiple action sets @@ -230,6 +232,14 @@ return windowAction; } + /** + * Return the current view position. + * @return the current view position + */ + public Point getViewPosition() { + return view.getViewPosition(); + } + public CMapViewBasic getView() { return view; } Modified: trunk/daimonin/src/daieditor/gui/NewMapDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/NewMapDialog.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/gui/NewMapDialog.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -290,7 +290,7 @@ maparch.addText(String.format("Date: %tF", System.currentTimeMillis())); if (mapType == MapType.GAMEMAP) { - final MapControl mapControl = mainControl.newLevel(null, maparch, true); + final MapControl mapControl = mainControl.newLevel(null, maparch, true, null); mapControl.setMapFileName(filename != null ? filename : IGUIConstants.DEF_MAPFNAME); } else if (mapType == MapType.PICKMAP) { return mainControl.getMainView().getPickmapChooserControl().addNewPickmap(parent, maparch, mapName); Modified: trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -171,7 +171,7 @@ } final CMainControl mainControl = CMainControl.getInstance(); // Open file without view - final MapControl mapControl = mainControl.openFile(file, false); + final MapControl mapControl = mainControl.openFile(file, false, null); if (mapControl == null) { return null; } Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -181,7 +181,7 @@ * @param mapFile the file name of the pickmap */ private void newPickmap(final List<GameObject> objects, final MapArchObject maparch, final File mapFile) { - final MapControl mapControl = new MapControl(mainControl, objects, maparch, true, true); + final MapControl mapControl = new MapControl(mainControl, objects, maparch, true, null, true); mapControl.getMapViewFrame().setAutoscrolls(true); mapControl.setMapFile(mapFile); mapControl.setMapFileName(mapFile.getPath()); Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-23 18:14:19 UTC (rev 1669) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-23 19:02:05 UTC (rev 1670) @@ -131,16 +131,17 @@ * @param maparch the <code>MapArchObject</code> of the map * @param objects list of Objects (ArchObjects) which should be filled in map or <code>null</code> for empty * @param isPickmap true if this is a pickmap + * @param initial the view position to show initially * @param createView create view if this is true */ - public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject maparch, final boolean isPickmap, final boolean createView) { + public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject maparch, final boolean isPickmap, final Point initial, final boolean createView) { this.mainControl = mainControl; activeEditType = 0; // start with no edit types (saves time) this.isPickmap = isPickmap; // is this a pickmap? // we create model (= data) mapModel = new DefaultMapModel(mainControl, this, objects, maparch); if (createView) { - createView(); + createView(initial); } init(); } @@ -474,6 +475,14 @@ } /** + * Return the current view position. + * @return the current view position + */ + public Point getViewPosition() { + return mapViewFrame.getViewPosition(); + } + + /** * Return a <code>LevelRenderer</code> of the map. If no renderer is * available a new one is created and returned. * @return a <code>LevelRenderer</code> which may have to be created @@ -560,9 +569,10 @@ /** * Create a new view of this level. + * @param initial the view position to show initially */ - public void createView() { - mapViewFrame = new MapViewIFrame(mainControl, this, ++viewCounter); + public void createView(final Point initial) { + mapViewFrame = new MapViewIFrame(mainControl, this, initial, ++viewCounter); mapViewIFrames.add(mapViewFrame); if (!isPickmap) { mainControl.getMainView().addLevelView(mapViewFrame); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-05-16 15:22:10
|
Revision: 2511 http://svn.sourceforge.net/gridarta/?rev=2511&view=rev Author: christianhujer Date: 2007-05-16 08:22:10 -0700 (Wed, 16 May 2007) Log Message: ----------- Fixed direction bug. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-05-16 11:36:00 UTC (rev 2510) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-05-16 15:22:10 UTC (rev 2511) @@ -238,9 +238,7 @@ if (this.direction == direction) { return; } - this.direction = direction; - this.setAttributeString("direction", Integer.toString(direction)); squareChanged(); } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2007-05-16 11:36:00 UTC (rev 2510) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2007-05-16 15:22:10 UTC (rev 2511) @@ -148,6 +148,7 @@ final Integer direction = mainControl.getActiveDirection(); if (direction != null) { part.setDirection(mainControl.getActiveDirection()); + part.setAttributeString("direction", Integer.toString(direction)); } mainControl.getArchetypeParser().postParseGameObject(part, mapControl.getActiveEditType()); part.setObjectFace(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-08-03 19:52:42
|
Revision: 2835 http://gridarta.svn.sourceforge.net/gridarta/?rev=2835&view=rev Author: akirschbaum Date: 2007-08-03 12:52:43 -0700 (Fri, 03 Aug 2007) Log Message: ----------- Unify face calculating code. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gui/archetypechooser/CellRenderer.java trunk/daimonin/src/daieditor/gui/selectedsquare/CellRenderer.java Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-08-03 19:20:12 UTC (rev 2834) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-08-03 19:52:43 UTC (rev 2835) @@ -98,9 +98,19 @@ /** * Get the face ImageIcon with a certain face name. * @param faceName faceName of face ImageIcon + * @param hasUndefinedArchetype if set, return the face for an game object + * referencing an undefined archetype * @return face ImageIcon for face <var>faceName</var> */ - @NotNull public ImageIcon getFace(final String faceName) { + @NotNull private ImageIcon getFace(final String faceName, final boolean hasUndefinedArchetype) { + if (hasUndefinedArchetype) { + return CMainControl.getNoarchTileIcon(); + } + + if (faceName == null) { + return CMainControl.getNofaceTileIcon(); + } + final ImageIcon face = FaceObjects.normal.getImageIconForFacename(faceName); if (face == null) { return CMainControl.getUnknownTileIcon(); @@ -111,20 +121,35 @@ /** {@inheritDoc} */ @NotNull public ImageIcon getFace(@NotNull final Archetype archetype) { - return getFace(archetype.getFaceObjName()); + return getFace(archetype.getFaceObjName(), archetype.isUndefinedArchetype()); } /** {@inheritDoc} */ @NotNull public ImageIcon getFace(@NotNull final GameObject gameObject) { - return getFace(gameObject.getFaceObjName()); + return getFace(gameObject.getFaceObjName(), gameObject.hasUndefinedArchetype()); } + /** {@inheritDoc} */ + @NotNull public ImageIcon getTrans(@NotNull final GameObject gameObject) { + return getTrans(gameObject.getFaceObjName(), gameObject.hasUndefinedArchetype()); + } + /** * Get the transparent face ImageIcon with a certain face name. * @param faceName faceName of face ImageIcon + * @param hasUndefinedArchetype if set, return the face for an game object + * referencing an undefined archetype * @return face ImageIcon for index <var>faceName</var> */ - public ImageIcon getTrans(final String faceName) { + @NotNull private ImageIcon getTrans(final String faceName, final boolean hasUndefinedArchetype) { + if (hasUndefinedArchetype) { + return CMainControl.getNoarchTileIcon(); + } + + if (faceName == null) { + return CMainControl.getNofaceTileIcon(); + } + final ImageIcon face = FaceObjects.ALPHA.getImageIconForFacename(faceName); if (face == null) { return CMainControl.getUnknownTileIcon(); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-08-03 19:20:12 UTC (rev 2834) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-08-03 19:52:43 UTC (rev 2835) @@ -277,16 +277,8 @@ * This method is for speeding up rendering. */ private void setFace() { - if (!hasArchetype()) { - normalFace = CMainControl.getNoarchTileIcon(); - transFace = normalFace; - } else if (hasFaceObject()) { - normalFace = CMainControl.getNofaceTileIcon(); - transFace = normalFace; - } else { - normalFace = CMainControl.getInstance().getArchetypeSet().getFace(faceObjName); - transFace = CMainControl.getInstance().getArchetypeSet().getTrans(faceObjName); - } + normalFace = CMainControl.getInstance().getArchetypeSet().getFace(this); + transFace = CMainControl.getInstance().getArchetypeSet().getTrans(this); } /** Modified: trunk/daimonin/src/daieditor/gui/archetypechooser/CellRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/archetypechooser/CellRenderer.java 2007-08-03 19:20:12 UTC (rev 2834) +++ trunk/daimonin/src/daieditor/gui/archetypechooser/CellRenderer.java 2007-08-03 19:52:43 UTC (rev 2835) @@ -19,12 +19,11 @@ package daieditor.gui.archetypechooser; -import daieditor.CMainControl; import daieditor.gameobject.GameObject; import java.awt.Component; import javax.swing.DefaultListCellRenderer; -import javax.swing.ImageIcon; import javax.swing.JList; +import net.sf.gridarta.AbstractMainControl; /** Cell Renderer for rendering cells in the ArchPanelPan. * @author Andreas Kirschbaum @@ -42,12 +41,7 @@ final GameObject archetype = (GameObject) value; setText(archetype.getArchetypeName()); - if (archetype.hasFaceObject()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else { - final ImageIcon icon = CMainControl.getInstance().getArchetypeSet().getFace(archetype.getFaceName()); - setIcon(icon); - } + setIcon(AbstractMainControl.getInstance().getArchetypeSet().getFace(archetype)); return this; } Modified: trunk/daimonin/src/daieditor/gui/selectedsquare/CellRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/selectedsquare/CellRenderer.java 2007-08-03 19:20:12 UTC (rev 2834) +++ trunk/daimonin/src/daieditor/gui/selectedsquare/CellRenderer.java 2007-08-03 19:52:43 UTC (rev 2835) @@ -27,7 +27,6 @@ import java.awt.Component; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; -import javax.swing.ImageIcon; import javax.swing.JList; import net.sf.gridarta.gameobject.GameObjectContainer; import org.jetbrains.annotations.NotNull; @@ -59,15 +58,7 @@ if (arch != null) { arch = arch.getHead(); - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.hasFaceObject()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else { - final String faceObjName = arch.getFaceObjName(); - final ImageIcon icon = faceObjName != null ? archetypeSet.getFace(faceObjName) : null; - setIcon(icon != null ? icon : CMainControl.getUnknownTileIcon()); - } + setIcon(archetypeSet.getFace(arch)); // In the map-tile-window the object names are displayed // next to the icons This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |