From: <chr...@us...> - 2006-12-27 01:04:58
|
Revision: 1302 http://svn.sourceforge.net/gridarta/?rev=1302&view=rev Author: christianhujer Date: 2006-12-26 17:04:58 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Some ReplaceDialog unification - added missing transactions to daieditor ReplaceDialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/daimonin/src/daieditor/ReplaceDialog.java Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-27 00:55:12 UTC (rev 1301) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-27 01:04:58 UTC (rev 1302) @@ -285,12 +285,12 @@ return 0; } - mapControl.getMapModel().beginTransaction("Replace"); // TODO: I18N/L10N final MapViewIFrame mapViewIFrame = mapControl.getMapViewFrame(); assert mapViewIFrame != null; int replaceCount = 0; final ArrayList<GameObject> objectsToReplace = new ArrayList<GameObject>(); + mapControl.getMapModel().beginTransaction("Replace"); // TODO: I18N/L10N for (final MapSquare<GameObject> square : entireMap ? mapControl.getMapModel() : mapViewIFrame.getView().getSelectedSquares()) { // find objects to replace objectsToReplace.clear(); Modified: trunk/daimonin/src/daieditor/ReplaceDialog.java =================================================================== --- trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-12-27 00:55:12 UTC (rev 1301) +++ trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-12-27 01:04:58 UTC (rev 1302) @@ -318,6 +318,7 @@ assert mapViewIFrame != null; int replaceCount = 0; final int replaceListSize = replaceList == null ? 0 : replaceList.size(); + mapControl.getMapModel().beginTransaction("Replace"); // TODO: I18N/L10N for (final MapSquare<GameObject> square : entireMap ? mapControl.getMapModel() : mapViewIFrame.getView().getSelectedSquares()) { for (final GameObject node : square) { if (!node.isMulti() && (matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString) || matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString))) { @@ -342,6 +343,7 @@ } } + mapControl.getMapModel().endTransaction(); // now the map and toolbars must be redrawn mapControl.repaint(); mainControl.getMainView().refreshMapTileList(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-29 20:29:07
|
Revision: 1307 http://svn.sourceforge.net/gridarta/?rev=1307&view=rev Author: christianhujer Date: 2006-12-29 12:29:07 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Added api documentation to build process. Modified Paths: -------------- trunk/build.xml trunk/src/doc/dev/start.xhtml Added Paths: ----------- trunk/src/doc/dev/api/ trunk/src/doc/dev/api/.htaccess Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2006-12-29 19:42:50 UTC (rev 1306) +++ trunk/build.xml 2006-12-29 20:29:07 UTC (rev 1307) @@ -424,7 +424,8 @@ depends = "editorialDoc" > <exec executable="rsync" failonerror="true"> - <arg line="-auzv --exclude=api/*/ -e ssh dest/doc/ ${user.rsync.username}@${user.rsync.host}:${user.rsync.dir}/htdocs/" /> + <!--arg line="-auzv - -exclude=api/*/ -e ssh dest/doc/ ${user.rsync.username}@${user.rsync.host}:${user.rsync.dir}/htdocs/" /--> + <arg line="-auzv -e ssh dest/doc/ ${user.rsync.username}@${user.rsync.host}:${user.rsync.dir}/htdocs/" /> </exec> </target> @@ -557,4 +558,77 @@ </megaxslt> </target> + <target + name = "javadoc" + description = "Creates the JavaDoc documentation for the complete editor source." + > + <mkdir dir="dest/doc/dev/api" /> + <javadoc + destdir = "dest/doc/dev/api" + locale = "en_US" + version = "yes" + author = "yes" + use = "yes" + splitindex = "yes" + windowtitle = "Gridarta Editor — API Documentation" + doctitle = "Gridarta Editor<br />API Documentation" + header = "Gridarta Editor<br />API Documentation" + footer = "Gridarta Editor<br />API Documentation" + serialwarn = "yes" + charset = "utf-8" + docencoding = "utf-8" + source = "${build.source.version}" + encoding = "${build.source.encoding}" + linksource = "yes" + private = "yes" + link = "${user.javadoc.link}" + > + <classpath> + <fileset dir="daimonin/lib" includes="*.jar" excludes="LICENSE-*.jar" /> + <fileset dir="crossfire/lib" includes="*.jar" excludes="LICENSE-*.jar" /> + <fileset dir="lib" includes="*.jar" excludes="LICENSE-*.jar" /> + </classpath> + <packageset dir="src/app" /> + <packageset dir="crossfire/src" /> + <packageset dir="daimonin/src" /> + <bottom> + <![CDATA[<address> + <a href="http://sourceforge.net/"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=166996&type=1" alt="SourceForge.net Logo" width="88" height="31" class="now" /></a> + <a href="http://sourceforge.net/donate/index.php?group_id=166996"><img src="http://sourceforge.net/images/project-support.jpg" width="88" height="32" alt="Support This Project" class="now" /></a> + <a href="http://freshmeat.net/projects/gridarta/"><img src="http://images.freshmeat.net/img/link_button_4.gif" width="88" height="31" alt="freshmeat.net" class="now" /></a> + <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" class="now" /></a>--> + <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="http://jigsaw.w3.org/css-validator/images/vcss" width="88" height="31" alt="Valid CSS!" class="now" /></a> + Feedback: <a href="mailto:ch...@ri...">webmaster</a> + </address> + <p class="copyright"> + © 2003 Andreas Vogl, Michael Toennis, 2004-2006 The Daimonin Developers, 2004-2006 The Crossfire Developers, 2005-2006 Christian Hujer, 2006 The Gridarta Developers. All rights reserved. + </p>]]> + </bottom> + <tag + name="todo" + description="Todo:" + /> + <tag + name="used" + description="Manually marked as used." + enabled="false" + /> + <tag + name="fixme" + description="Fixme:" + /> + <tag + name="xxx" + description="XXX:" + /> + <tag + name="note" + description="Note:" + /> + <tag + name="devs" + description="At Developers:" + /> + </javadoc> + </target> </project> Added: trunk/src/doc/dev/api/.htaccess =================================================================== --- trunk/src/doc/dev/api/.htaccess (rev 0) +++ trunk/src/doc/dev/api/.htaccess 2006-12-29 20:29:07 UTC (rev 1307) @@ -0,0 +1 @@ +DirectoryIndex index.html Property changes on: trunk/src/doc/dev/api/.htaccess ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/doc/dev/start.xhtml =================================================================== --- trunk/src/doc/dev/start.xhtml 2006-12-29 19:42:50 UTC (rev 1306) +++ trunk/src/doc/dev/start.xhtml 2006-12-29 20:29:07 UTC (rev 1307) @@ -13,6 +13,7 @@ <li><a href="codeStyle">Gridarta Code Conventions</a></li> <li><a href="transactions">Transaction System</a></li> <li><a href="todo">Todo list</a></li> + <li><a href="api/">Javadoc API documentation</a></li> </ul> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-29 22:09:41
|
Revision: 1311 http://svn.sourceforge.net/gridarta/?rev=1311&view=rev Author: christianhujer Date: 2006-12-29 14:09:40 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Updated project documentation. Modified Paths: -------------- trunk/CREDITS trunk/INSTALL trunk/MAINTAINERS trunk/README Modified: trunk/CREDITS =================================================================== --- trunk/CREDITS 2006-12-29 22:01:19 UTC (rev 1310) +++ trunk/CREDITS 2006-12-29 22:09:40 UTC (rev 1311) @@ -11,17 +11,28 @@ * Christian Hujer <ch...@ri...> He maintained DaimoninEditor from 2005-2006, creator of Gridarta. + Takes care of Gridarta4Daimonin. * Daniel Viegas <der...@us...> Added many new features. * Andreas Kirschbaum <aki...@us...> Added many new features. + Takes care of Gridarta4Crossfire. Gridarta wouldn't exist without the following projects: -* Gridder, a simple 2D grid based game map editor. http://www.gamedev.net/hosted/javanerd/gridder.asp -* Crossfire, a 2D MMORPG. http://crossfire.real-time.com/ -* Daimonin, a 2D MMORPG, branch of Crossfire. http://www.daimonin.net/ -* JAPI, a library for improved Java software development. http://japi.sourceforge.net/ +* Gridder, a simple 2D grid based game map editor. + http://www.gamedev.net/hosted/javanerd/gridder.asp +* Crossfire, a 2D MMORPG. + http://crossfire.real-time.com/ +* Daimonin, a 2D MMORPG, branch of Crossfire. + http://www.daimonin.net/ + + +Additionally, Gridarta is supported by the existence following projects: +* JAPI, a library for improved Java software development. + http://japi.sourceforge.net/ +* Log4J, a library for logging in Java applications. + http://logging.apache.org/log4j/docs/ Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2006-12-29 22:01:19 UTC (rev 1310) +++ trunk/INSTALL 2006-12-29 22:09:40 UTC (rev 1311) @@ -19,9 +19,24 @@ Howto Build ----------- -Change to the project root directory and run "ant". +Change to the directory of the version you want to build and run "ant". To find out options about building Gridarta, run "ant -projecthelp". +Example: Building Gridarta4Crossfire +cd crossfire/ +ant + +Example: Building Gridarta4Daimonin +cd daimonin/ +ant + + Howto Run --------- java -jar Gridarta.jar + + +Howto Generate Documentation (Javadoc) +-------------------------------------- +Change to the main directory and run "ant javadoc". The documentation will be +placed in dest/doc/api/. Modified: trunk/MAINTAINERS =================================================================== --- trunk/MAINTAINERS 2006-12-29 22:01:19 UTC (rev 1310) +++ trunk/MAINTAINERS 2006-12-29 22:09:40 UTC (rev 1311) @@ -1,6 +1,6 @@ The current maintainers of Gridarta are: * Christian Hujer <ch...@ri...> +* Andreas Kirschbaum <aki...@us...> * Daniel Viegas <der...@us...> -* Andreas Kirschbaum <aki...@us...> * Anja Heim <z0...@us...> Modified: trunk/README =================================================================== --- trunk/README 2006-12-29 22:01:19 UTC (rev 1310) +++ trunk/README 2006-12-29 22:09:40 UTC (rev 1311) @@ -38,12 +38,16 @@ SYSTEM REQUIREMENTS ------------------- -Java 5.0 +Java 5.0 or later Previous versions of Java will not work. Gridarta uses Generics, autoboxing, static imports, foreach loops, assertions, covariant return types and varargs quite a lot. + Note: Future versions of Gridarta might require Java 6.0 or later. If you + have a chance to upgrade your Java, do so. Java 6.0 has some features we + are very much interested in, most notably a framework for supporting + scripting languages in a Java application. -Ant 1.6.5 +Ant 1.6.5 or later Previous versions of Ant might work but are not tested. @@ -51,6 +55,7 @@ -------------- build.xml The build file to build the project with Ant. + See also INSTALL. COPYING Gridarta license conditions. Note: applies to Gridarta only, not third @@ -60,10 +65,10 @@ List of project contributors. See also MAINTAINERS. crossfire/ - Legacy directory containing the old Crossfire Map Editor. + Directory containing the Crossfire Map Editor / Crossfire specific code. daimonin/ - Legacy directory containing the old Daimonin Map Editor. + Directory containing the Daimonin Map Editor / Daimonin specific code. dest/ (generated) The directory containing generated files. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:06:31
|
Revision: 1313 http://svn.sourceforge.net/gridarta/?rev=1313&view=rev Author: christianhujer Date: 2006-12-29 16:06:31 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Improved package documentation, added some missing package documentation. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/anim/package.html trunk/daimonin/src/daieditor/gameobject/package.html trunk/daimonin/src/daieditor/gui/map/package.html trunk/daimonin/src/daieditor/gui/package.html trunk/daimonin/src/daieditor/package.html trunk/src/app/net/sf/gridarta/gameobject/package.html trunk/src/app/net/sf/gridarta/gui/map/package.html trunk/src/app/net/sf/gridarta/gui/package.html Added Paths: ----------- trunk/crossfire/src/cfeditor/gameobject/anim/package.html trunk/crossfire/src/cfeditor/gameobject/face/package.html trunk/crossfire/src/cfeditor/gameobject/package.html trunk/crossfire/src/cfeditor/gui/map/package.html trunk/crossfire/src/cfeditor/gui/package.html trunk/crossfire/src/cfeditor/package.html trunk/src/app/net/sf/gridarta/gameobject/anim/package.html trunk/src/app/net/sf/gridarta/gameobject/face/package.html Added: trunk/crossfire/src/cfeditor/gameobject/anim/package.html =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/anim/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Handles the Crossfire variants of {@link net.sf.gridarta.gameobject.anim.AnimationObject animations}. + </p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/gameobject/anim/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/gameobject/face/package.html =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/face/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Handles the Crossfire variants of {@link net.sf.gridarta.gameobject.face.FaceObject faces}. + </p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/gameobject/face/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/gameobject/package.html =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Handles the Crossfire variants of {@link net.sf.gridarta.gameobject.GameObject GameObjects} and {@link net.sf.gridarta.gameobject.Archetype Archetypes}. + </p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/gameobject/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/gui/map/package.html =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Renders maps. + Note that the management of maps is in a different package: {@link cfeditor.map}. + </p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/gui/map/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/gui/package.html =================================================================== --- trunk/crossfire/src/cfeditor/gui/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/gui/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p>Graphical User Interface of Gridarta4Crossfire.</p> + <p>Note: Not all classes are here yet, they are currently moving to here.</p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/gui/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/package.html =================================================================== --- trunk/crossfire/src/cfeditor/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Main package of Gridarta4Crossfire, contains all classes specific to the Crossfire version of the Gridarta map editor. + @serial exclude + </p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gameobject/anim/package.html =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/daimonin/src/daieditor/gameobject/anim/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,7 +7,7 @@ </head> <body> <p> - This package containes classes related to animations. + Handles the Daimonin variants of {@link net.sf.gridarta.gameobject.anim.AnimationObject Animations}. </p> </body> </html> Modified: trunk/daimonin/src/daieditor/gameobject/package.html =================================================================== --- trunk/daimonin/src/daieditor/gameobject/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/daimonin/src/daieditor/gameobject/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,7 +7,7 @@ </head> <body> <p> - This package containes classes and subpackages related to arches. + Handles the Daimonin variants of {@link net.sf.gridarta.gameobject.GameObject GameObjects} and {@link net.sf.gridarta.gameobject.Archetype Archetypes}. </p> </body> </html> Modified: trunk/daimonin/src/daieditor/gui/map/package.html =================================================================== --- trunk/daimonin/src/daieditor/gui/map/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/daimonin/src/daieditor/gui/map/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,7 +7,7 @@ </head> <body> <p> - The package <code>daieditor.gui.map</code> is about displaying and rendering maps. + Renders maps. Note that the management of maps is in a different package: {@link daieditor.map}. </p> </body> Modified: trunk/daimonin/src/daieditor/gui/package.html =================================================================== --- trunk/daimonin/src/daieditor/gui/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/daimonin/src/daieditor/gui/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -6,7 +6,7 @@ <title></title> </head> <body> - <p>This package contains the GUI classes of Daimonin.</p> + <p>Graphical User Interface of Gridarta4Daimonin.</p> <p>Note: Not all classes are here yet, they are currently moving to here.</p> </body> </html> Modified: trunk/daimonin/src/daieditor/package.html =================================================================== --- trunk/daimonin/src/daieditor/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/daimonin/src/daieditor/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,8 +7,7 @@ </head> <body> <p> - This is the main package of the Daimonin editor. - It contains all classes specific to the Daimonin editor. + Main package of Gridarta4Daimonin, contains all classes specific to the Daimonin version of the Gridarta map editor. @serial exclude </p> </body> Added: trunk/src/app/net/sf/gridarta/gameobject/anim/package.html =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/package.html (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + Gridarta can handle frame information of animations and allow the selection of an animation using a tree. + In future, Gridarta might even show Animations really animated in the editor window. + </p> + </body> +</html> Property changes on: trunk/src/app/net/sf/gridarta/gameobject/anim/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gameobject/face/package.html =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/package.html (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/face/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <title></title> + </head> + <body> + <p> + The Face is the appearance of an object. + </p> + </body> +</html> Property changes on: trunk/src/app/net/sf/gridarta/gameobject/face/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/package.html =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/src/app/net/sf/gridarta/gameobject/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,7 +7,8 @@ </head> <body> <p> - This package containes classes and subpackages related to GameObjects. + GameObjects are the objects found on maps and based on Archetypes. + Everything related to both of them is handled by this package or one of its subpackages. </p> <h4>Small GameObject Glossary</h4> <dl> Modified: trunk/src/app/net/sf/gridarta/gui/map/package.html =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/src/app/net/sf/gridarta/gui/map/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,7 +7,7 @@ </head> <body> <p> - This package containes classes related to map visualisation. + Base classes for rendering maps. </p> <p> A {@link MapGrid} contains a 2D array of flags for highlighting tiles on a map. Modified: trunk/src/app/net/sf/gridarta/gui/package.html =================================================================== --- trunk/src/app/net/sf/gridarta/gui/package.html 2006-12-30 00:05:32 UTC (rev 1312) +++ trunk/src/app/net/sf/gridarta/gui/package.html 2006-12-30 00:06:31 UTC (rev 1313) @@ -7,7 +7,10 @@ </head> <body> <p> - This package containes GUI related classes. + Graphical User Interface of Gridarta. </p> + <p> + Contains both, common used classes and base classes extended by both editors. + </p> </body> </html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:13:01
|
Revision: 1314 http://svn.sourceforge.net/gridarta/?rev=1314&view=rev Author: christianhujer Date: 2006-12-29 16:12:59 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Fixed a bug in the faq generation. Modified Paths: -------------- trunk/FAQ trunk/src/doc/faq2txt.xslt Modified: trunk/FAQ =================================================================== --- trunk/FAQ 2006-12-30 00:06:31 UTC (rev 1313) +++ trunk/FAQ 2006-12-30 00:12:59 UTC (rev 1314) @@ -1,14 +1,14 @@ -Gridarta FAQ +Gridarta FAQ Note: This file is auto-generated from src/doc/faq.xhtml using src/doc/faq2txt.xslt. If you want to change the faq, please make your changes in src/doc/faq.xhtml. Question: -Will feature xyz be implemented in Gridarta? +Will feature xyz be implemented in Gridarta? Answer: -Please use our feature request tracker <https://sourceforge.net/tracker/?group_id=166996&atid=841185>. -Also take a look at our TODO list <http://gridarta.sourceforge.net/dev/todo>. +Please use our feature request tracker <https://sourceforge.net/tracker/?group_id=166996&atid=841185>. +Also take a look at our TODO list <http://gridarta.sourceforge.net/dev/todo>. Modified: trunk/src/doc/faq2txt.xslt =================================================================== --- trunk/src/doc/faq2txt.xslt 2006-12-30 00:06:31 UTC (rev 1313) +++ trunk/src/doc/faq2txt.xslt 2006-12-30 00:12:59 UTC (rev 1314) @@ -52,7 +52,7 @@ <xsl:if test="ends-with(., '
')"> <xsl:text>
</xsl:text> </xsl:if> - <xsl:if test="ends-with(., '')"> + <xsl:if test="ends-with(., ' ')"> <xsl:text> </xsl:text> </xsl:if> </xsl:template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:18:28
|
Revision: 1315 http://svn.sourceforge.net/gridarta/?rev=1315&view=rev Author: christianhujer Date: 2006-12-29 16:18:29 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Improved package documentation, added some missing package documentation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/prefs/package.html trunk/daimonin/src/daieditor/gameobject/face/package.html trunk/daimonin/src/daieditor/gui/prefs/package.html trunk/src/app/net/sf/gridarta/io/package.html Added Paths: ----------- trunk/crossfire/src/cfeditor/io/package.html trunk/daimonin/src/daieditor/io/package.html Modified: trunk/crossfire/src/cfeditor/gui/prefs/package.html =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/package.html 2006-12-30 00:12:59 UTC (rev 1314) +++ trunk/crossfire/src/cfeditor/gui/prefs/package.html 2006-12-30 00:18:29 UTC (rev 1315) @@ -6,6 +6,6 @@ <title></title> </head> <body> - <p>This package contains the preferences ui modules.</p> + <p>This package contains the Crossfire preferences ui modules.</p> </body> </html> Added: trunk/crossfire/src/cfeditor/io/package.html =================================================================== --- trunk/crossfire/src/cfeditor/io/package.html (rev 0) +++ trunk/crossfire/src/cfeditor/io/package.html 2006-12-30 00:18:29 UTC (rev 1315) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>net.sf.gridarta.io</title> + </head> + <body> + <p> + Reading and Writing of Crossfire maps, handling of paths. + </p> + </body> +</html> Property changes on: trunk/crossfire/src/cfeditor/io/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gameobject/face/package.html =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/package.html 2006-12-30 00:12:59 UTC (rev 1314) +++ trunk/daimonin/src/daieditor/gameobject/face/package.html 2006-12-30 00:18:29 UTC (rev 1315) @@ -7,7 +7,7 @@ </head> <body> <p> - This package containes classes related to faces. + Handles the Daimonin variants of {@link net.sf.gridarta.gameobject.face.FaceObject faces}. </p> <p> This package contains classes for managing icons in memory sensitive caches. Modified: trunk/daimonin/src/daieditor/gui/prefs/package.html =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/package.html 2006-12-30 00:12:59 UTC (rev 1314) +++ trunk/daimonin/src/daieditor/gui/prefs/package.html 2006-12-30 00:18:29 UTC (rev 1315) @@ -6,6 +6,6 @@ <title></title> </head> <body> - <p>This package contains the preferences ui modules.</p> + <p>This package contains the Daimonin preferences ui modules.</p> </body> </html> Added: trunk/daimonin/src/daieditor/io/package.html =================================================================== --- trunk/daimonin/src/daieditor/io/package.html (rev 0) +++ trunk/daimonin/src/daieditor/io/package.html 2006-12-30 00:18:29 UTC (rev 1315) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>net.sf.gridarta.io</title> + </head> + <body> + <p> + Reading and Writing of Daimonin maps, handling of paths. + </p> + </body> +</html> Property changes on: trunk/daimonin/src/daieditor/io/package.html ___________________________________________________________________ Name: svn:mime-type + text/html Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/io/package.html =================================================================== --- trunk/src/app/net/sf/gridarta/io/package.html 2006-12-30 00:12:59 UTC (rev 1314) +++ trunk/src/app/net/sf/gridarta/io/package.html 2006-12-30 00:18:29 UTC (rev 1315) @@ -6,7 +6,7 @@ </head> <body> <p> - This package contains I/O related classes. + Reading and Writing of maps, handling of paths. </p> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:36:19
|
Revision: 1318 http://svn.sourceforge.net/gridarta/?rev=1318&view=rev Author: christianhujer Date: 2006-12-29 16:36:19 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Extracted common LevelRenderer methods into a common interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/LevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-30 00:29:16 UTC (rev 1317) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-30 00:36:19 UTC (rev 1318) @@ -31,25 +31,10 @@ * * @author tchize */ -public abstract class LevelRenderer extends JComponent { +public abstract class LevelRenderer extends JComponent implements net.sf.gridarta.gui.map.LevelRenderer { public abstract void updateLookAndFeel(); - /** - * Returns an image of the entire mapview. - * @return An image of the entire mapview. - */ - public abstract BufferedImage getFullImage(); - - /** - * 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 <code>(retPoint != null)</code> this point will be returned otherwise a new point will be created - * @return The map location. - */ - @Nullable public abstract Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint); - public abstract void modelChanged(); public abstract void freeBackBuffer(); Modified: trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-12-30 00:29:16 UTC (rev 1317) +++ trunk/daimonin/src/daieditor/gui/map/LevelRenderer.java 2006-12-30 00:36:19 UTC (rev 1318) @@ -32,21 +32,6 @@ * * @author tchize */ -public abstract class LevelRenderer extends JComponent { +public abstract class LevelRenderer extends JComponent implements net.sf.gridarta.gui.map.LevelRenderer { - /** - * Returns an image of the entire mapview. - * @return An image of the entire mapview. - */ - public abstract BufferedImage getFullImage(); - - /** - * 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 <code>(retPoint != null)</code> this point will be returned otherwise a new point will be created - * @return The map location. - */ - @Nullable public abstract Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint); - } // class LevelRenderer Added: trunk/src/app/net/sf/gridarta/gui/map/LevelRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/LevelRenderer.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/LevelRenderer.java 2006-12-30 00:36:19 UTC (rev 1318) @@ -0,0 +1,29 @@ +package net.sf.gridarta.gui.map; + +import java.awt.image.BufferedImage; +import java.awt.Point; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; + +/** + * Common interface for LevelRenderers. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface LevelRenderer { + + /** + * Returns an image of the entire mapview. + * @return An image of the entire mapview. + */ + public abstract BufferedImage getFullImage(); + + /** + * 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 <code>(retPoint != null)</code> this point will be returned otherwise a new point will be created + * @return The map location. + */ + @Nullable public abstract Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint); + +} // interface LevelRenderer Property changes on: trunk/src/app/net/sf/gridarta/gui/map/LevelRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:38:19
|
Revision: 1319 http://svn.sourceforge.net/gridarta/?rev=1319&view=rev Author: christianhujer Date: 2006-12-29 16:38:16 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Changed StatusBars to reference the common LevelRenderer interface instead of the specific classes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/StatusBar.java trunk/daimonin/src/daieditor/gui/StatusBar.java Modified: trunk/crossfire/src/cfeditor/gui/StatusBar.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/StatusBar.java 2006-12-30 00:36:19 UTC (rev 1318) +++ trunk/crossfire/src/cfeditor/gui/StatusBar.java 2006-12-30 00:38:16 UTC (rev 1319) @@ -26,7 +26,6 @@ package cfeditor.gui; import cfeditor.CMainControl; -import cfeditor.gui.map.LevelRenderer; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -40,6 +39,7 @@ import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gui/StatusBar.java =================================================================== --- trunk/daimonin/src/daieditor/gui/StatusBar.java 2006-12-30 00:36:19 UTC (rev 1318) +++ trunk/daimonin/src/daieditor/gui/StatusBar.java 2006-12-30 00:38:16 UTC (rev 1319) @@ -26,7 +26,6 @@ package daieditor.gui; import daieditor.CMainControl; -import daieditor.gui.map.LevelRenderer; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -40,6 +39,7 @@ import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:40:40
|
Revision: 1320 http://svn.sourceforge.net/gridarta/?rev=1320&view=rev Author: christianhujer Date: 2006-12-29 16:40:41 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Extracted getFaceObjects() method into common MainControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 00:38:16 UTC (rev 1319) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 00:40:41 UTC (rev 1320) @@ -216,10 +216,7 @@ return instance; } - /** - * Get the Face Objects. - * @return faceObjects - */ + /** {@inheritDoc} */ public FaceObjects getFaceObjects() { return faceObjects; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 00:38:16 UTC (rev 1319) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 00:40:41 UTC (rev 1320) @@ -390,10 +390,7 @@ return animationObjects; } - /** - * Get the Face Objects. - * @return faceObjects - */ + /** {@inheritDoc} */ public FaceObjects getFaceObjects() { return faceObjects; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-12-30 00:38:16 UTC (rev 1319) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-12-30 00:40:41 UTC (rev 1320) @@ -4,6 +4,7 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.face.FaceObjects; import org.jetbrains.annotations.NotNull; /** @@ -58,6 +59,12 @@ ArchetypeParser getArchetypeParser(); /** + * Get the FaceObjects for the available Faces. + * @return FaceObjects + */ + FaceObjects getFaceObjects(); + + /** * Returns the MainView of this MainControl. * @return The MainView of this MainControl. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:45:13
|
Revision: 1321 http://svn.sourceforge.net/gridarta/?rev=1321&view=rev Author: christianhujer Date: 2006-12-29 16:45:13 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Replaced CMainControl reference in StatusBars with common MainControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/StatusBar.java trunk/daimonin/src/daieditor/gui/StatusBar.java trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/gui/StatusBar.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/StatusBar.java 2006-12-30 00:40:41 UTC (rev 1320) +++ trunk/crossfire/src/cfeditor/gui/StatusBar.java 2006-12-30 00:45:13 UTC (rev 1321) @@ -25,7 +25,6 @@ package cfeditor.gui; -import cfeditor.CMainControl; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -36,10 +35,11 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.BevelBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; -import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,7 +64,7 @@ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); /** Controller of this statusbar view. */ - private final CMainControl mainControl; + private final MainControl mainControl; /** The label that shows the mouse. */ private final JLabel mouse; @@ -84,9 +84,9 @@ /** * Constructs a statusbar that has the given main controller object set * as its controller. - * @param mainControl The controller of this view. + * @param mainControl The MainControl for statistical data. */ - public StatusBar(final CMainControl mainControl) { + public StatusBar(final MainControl mainControl) { this.mainControl = mainControl; setLayout(new GridBagLayout()); setBorder(new BevelBorder(BevelBorder.LOWERED)); Modified: trunk/daimonin/src/daieditor/gui/StatusBar.java =================================================================== --- trunk/daimonin/src/daieditor/gui/StatusBar.java 2006-12-30 00:40:41 UTC (rev 1320) +++ trunk/daimonin/src/daieditor/gui/StatusBar.java 2006-12-30 00:45:13 UTC (rev 1321) @@ -25,7 +25,6 @@ package daieditor.gui; -import daieditor.CMainControl; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -36,10 +35,11 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.BevelBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; -import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,7 +64,7 @@ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); /** Controller of this statusbar view. */ - private final CMainControl mainControl; + private final MainControl mainControl; /** The label that shows the mouse. */ private final JLabel mouse; @@ -84,9 +84,9 @@ /** * Constructs a statusbar that has the given main controller object set * as its controller. - * @param mainControl The controller of this view. + * @param mainControl The MainControl for statistical data. */ - public StatusBar(final CMainControl mainControl) { + public StatusBar(final MainControl mainControl) { this.mainControl = mainControl; setLayout(new GridBagLayout()); setBorder(new BevelBorder(BevelBorder.LOWERED)); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java 2006-12-30 00:40:41 UTC (rev 1320) +++ trunk/src/app/net/sf/gridarta/gameobject/face/FaceObjects.java 2006-12-30 00:45:13 UTC (rev 1321) @@ -8,4 +8,10 @@ */ public interface FaceObjects<T extends FaceObject> extends Collectable, Iterable<T> { + /** + * Get the number of face objects. + * @return face object count + */ + int size(); + } // interface FaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:49:15
|
Revision: 1322 http://svn.sourceforge.net/gridarta/?rev=1322&view=rev Author: christianhujer Date: 2006-12-29 16:49:15 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Merged StatusBar. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/StatusBar.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/StatusBar.java trunk/daimonin/src/daieditor/gui/StatusBar.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-30 00:45:13 UTC (rev 1321) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-30 00:49:15 UTC (rev 1322) @@ -28,7 +28,6 @@ import cfeditor.gui.GameObjectAttributesPanel; import cfeditor.gui.InsertionObjectChooser; import cfeditor.gui.PickmapChooser; -import cfeditor.gui.StatusBar; import cfeditor.gui.selectedsquare.SelectedSquareControl; import cfeditor.map.MapControl; import cfeditor.menu.AggregateMenuLocation; @@ -62,6 +61,7 @@ import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ToggleAction; Deleted: trunk/crossfire/src/cfeditor/gui/StatusBar.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/StatusBar.java 2006-12-30 00:45:13 UTC (rev 1321) +++ trunk/crossfire/src/cfeditor/gui/StatusBar.java 2006-12-30 00:49:15 UTC (rev 1322) @@ -1,231 +0,0 @@ -/* - * Crossfire 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 cfeditor.gui; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; -import java.text.NumberFormat; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.border.BevelBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.map.LevelRenderer; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * <code>StatusBar</code> implements the main statusbar of the - * application. Used to show one line text messages to the user about - * progress, state etc. Also includes level info and memory info - * panels. - * @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> - * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> - * @todo Separate labels and methods for mouse coordinates - */ -public final class StatusBar extends JPanel implements MapCursorListener, MouseMotionListener { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** Controller of this statusbar view. */ - private final MainControl mainControl; - - /** The label that shows the mouse. */ - private final JLabel mouse; - - /** The label that shows the cursor. */ - private final JLabel cursor; - - /** The label that shows the one line text message. */ - private final JLabel status; - - /** The label that shows the memory status. */ - private final JLabel memory; - - /** Temporary used to get map coordinates. */ - private final Point mouseMapTmp = new Point(); - - /** - * Constructs a statusbar that has the given main controller object set - * as its controller. - * @param mainControl The MainControl for statistical data. - */ - public StatusBar(final MainControl mainControl) { - this.mainControl = mainControl; - setLayout(new GridBagLayout()); - setBorder(new BevelBorder(BevelBorder.LOWERED)); - - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - gbc.ipadx = 1; - - gbc.weightx = 0.0; - mouse = new JLabel(" "); - mouse.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(mouse, gbc); - - cursor = new JLabel(" "); - cursor.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(cursor, gbc); - - gbc.weightx = 5.0; - status = new JLabel(" "); - status.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(status, gbc); - - gbc.weightx = 0.0; - memory = new JLabel(" "); - memory.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(memory, gbc); - } - - /** - * Sets the level status text, which usually displays arch numbers. - * @param text String to set - */ - public void setStatusText(final String text) { - status.setText(text); - refresh(); - } - - /** Refreshes the memory usage info panel. */ - public void refresh() { - final Runtime runtime = Runtime.getRuntime(); - final long freeMem = runtime.freeMemory(); - final long totMem = runtime.totalMemory(); - final long usedMem = totMem - freeMem; - - memory.setText(ACTION_FACTORY.format("memory", - mainControl.getArchetypeSet().getArchetypeCount(), - mainControl.getFaceObjects().size(), - getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem) - )); - } - - /** The DecimalFormat to use for formatting the numbers in {@link #getMemoryString(long)}.. */ - private static final NumberFormat FORMAT = NumberFormat.getInstance(); - - static { - FORMAT.setMinimumFractionDigits(1); - FORMAT.setMaximumFractionDigits(1); - } - - /** The units used by {@link #getMemoryString(long)}. */ - private static final String[] UNITS = {"Bytes", "KB", "MB", "GB"}; - - /** - * Returns the given memory amount as a string scales the value - * to be bytes, kilobytes or megabytes. - * @param mem memory amount to calculate - * @return String for <var>memory</var> - */ - @Nullable private static String getMemoryString(final long mem) { - for (int i = UNITS.length - 1; i >= 0; i--) { - final int m = 1 << i * 10; - if (mem > m) { - return FORMAT.format((double) mem / m) + UNITS[i]; - } - } - assert false; - return null; - } - - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - mapCursorChanged(e.getSource()); - } - - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - mapCursorChanged(e.getSource()); - } - - /** - * Set coordinates of MapCursor to cursor label and the offset when in drag mode. - * @param mapCursor MapCursor to set coordinates from. - */ - private void mapCursorChanged(final MapCursor mapCursor) { - final String formatCursor; - if (mapCursor.isActive()) { - final Point pos = mapCursor.getLocation(); - assert pos != null; - final int cursorX = pos.x; - final int cursorY = pos.y; - if (mapCursor.isDragging()) { - final Dimension offset = mapCursor.getDragOffset(); - assert offset != null; - final int offsetX = Math.abs(offset.width) + 1; - final int offsetY = Math.abs(offset.height) + 1; - formatCursor = ACTION_FACTORY.format("statusSelect", cursorX, cursorY, offsetX, offsetY); - } else { - formatCursor = ACTION_FACTORY.format("statusNormal", cursorX, cursorY); - } - } else { - formatCursor = ACTION_FACTORY.format("statusCursorOff"); - } - cursor.setText(formatCursor); - } - - public void mouseDragged(final MouseEvent e) { - mousePosChanged(e); - } - - public void mouseMoved(final MouseEvent e) { - mousePosChanged(e); - } - - /** - * Set new mouse and map coordinates to mouse label. - * @param e Event that was fired from #MapCursor - */ - private void mousePosChanged(final MouseEvent e) { - final Point mousePos = e.getPoint(); - final int mouseX = mousePos.x; - final int mouseY = mousePos.y; - final LevelRenderer renderer = (LevelRenderer) e.getSource(); - final Point mouseMap = renderer.getTileLocationAt(mousePos, mouseMapTmp); - if (mouseMap != null) { - final int mouseMapX = mouseMap.x; - final int mouseMapY = mouseMap.y; - mouse.setText(ACTION_FACTORY.format("statusMouseOn", mouseX, mouseY, mouseMapX, mouseMapY)); - } else { - mouse.setText(ACTION_FACTORY.format("statusMouseOff", mouseX, mouseY)); - } - } - -} // class StatusBar Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-30 00:45:13 UTC (rev 1321) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-30 00:49:15 UTC (rev 1322) @@ -29,7 +29,6 @@ import daieditor.gui.GameObjectAttributesPanel; import daieditor.gui.InsertionObjectChooser; import daieditor.gui.PickmapChooser; -import daieditor.gui.StatusBar; import daieditor.gui.selectedsquare.SelectedSquareControl; import daieditor.map.MapControl; import daieditor.map.validation.ErrorCollector; @@ -62,6 +61,7 @@ import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.ThrowableHandler; Deleted: trunk/daimonin/src/daieditor/gui/StatusBar.java =================================================================== --- trunk/daimonin/src/daieditor/gui/StatusBar.java 2006-12-30 00:45:13 UTC (rev 1321) +++ trunk/daimonin/src/daieditor/gui/StatusBar.java 2006-12-30 00:49:15 UTC (rev 1322) @@ -1,231 +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.gui; - -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; -import java.text.NumberFormat; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.border.BevelBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.map.LevelRenderer; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * <code>StatusBar</code> implements the main statusbar of the - * application. Used to show one line text messages to the user about - * progress, state etc. Also includes level info and memory info - * panels. - * @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> - * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> - * @todo Separate labels and methods for mouse coordinates - */ -public final class StatusBar extends JPanel implements MapCursorListener, MouseMotionListener { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Controller of this statusbar view. */ - private final MainControl mainControl; - - /** The label that shows the mouse. */ - private final JLabel mouse; - - /** The label that shows the cursor. */ - private final JLabel cursor; - - /** The label that shows the one line text message. */ - private final JLabel status; - - /** The label that shows the memory status. */ - private final JLabel memory; - - /** Temporary used to get map coordinates. */ - private final Point mouseMapTmp = new Point(); - - /** - * Constructs a statusbar that has the given main controller object set - * as its controller. - * @param mainControl The MainControl for statistical data. - */ - public StatusBar(final MainControl mainControl) { - this.mainControl = mainControl; - setLayout(new GridBagLayout()); - setBorder(new BevelBorder(BevelBorder.LOWERED)); - - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - gbc.ipadx = 1; - - gbc.weightx = 0.0; - mouse = new JLabel(" "); - mouse.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(mouse, gbc); - - cursor = new JLabel(" "); - cursor.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(cursor, gbc); - - gbc.weightx = 5.0; - status = new JLabel(" "); - status.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(status, gbc); - - gbc.weightx = 0.0; - memory = new JLabel(" "); - memory.setBorder(new BevelBorder(BevelBorder.LOWERED)); - add(memory, gbc); - } - - /** - * Sets the level status text, which usually displays arch numbers. - * @param text String to set - */ - public void setStatusText(final String text) { - status.setText(text); - refresh(); - } - - /** Refreshes the memory usage info panel. */ - public void refresh() { - final Runtime runtime = Runtime.getRuntime(); - final long freeMem = runtime.freeMemory(); - final long totMem = runtime.totalMemory(); - final long usedMem = totMem - freeMem; - - memory.setText(ACTION_FACTORY.format("memory", - mainControl.getArchetypeSet().getArchetypeCount(), - mainControl.getFaceObjects().size(), - getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem) - )); - } - - /** The DecimalFormat to use for formatting the numbers in {@link #getMemoryString(long)}.. */ - private static final NumberFormat FORMAT = NumberFormat.getInstance(); - - static { - FORMAT.setMinimumFractionDigits(1); - FORMAT.setMaximumFractionDigits(1); - } - - /** The units used by {@link #getMemoryString(long)}. */ - private static final String[] UNITS = {"Bytes", "KB", "MB", "GB"}; - - /** - * Returns the given memory amount as a string scales the value - * to be bytes, kilobytes or megabytes. - * @param mem memory amount to calculate - * @return String for <var>memory</var> - */ - @Nullable private static String getMemoryString(final long mem) { - for (int i = UNITS.length - 1; i >= 0; i--) { - final int m = 1 << i * 10; - if (mem > m) { - return FORMAT.format((double) mem / m) + UNITS[i]; - } - } - assert false; - return null; - } - - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - mapCursorChanged(e.getSource()); - } - - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - mapCursorChanged(e.getSource()); - } - - /** - * Set coordinates of MapCursor to cursor label and the offset when in drag mode. - * @param mapCursor MapCursor to set coordinates from. - */ - private void mapCursorChanged(final MapCursor mapCursor) { - final String formatCursor; - if (mapCursor.isActive()) { - final Point pos = mapCursor.getLocation(); - assert pos != null; - final int cursorX = pos.x; - final int cursorY = pos.y; - if (mapCursor.isDragging()) { - final Dimension offset = mapCursor.getDragOffset(); - assert offset != null; - final int offsetX = Math.abs(offset.width) + 1; - final int offsetY = Math.abs(offset.height) + 1; - formatCursor = ACTION_FACTORY.format("statusSelect", cursorX, cursorY, offsetX, offsetY); - } else { - formatCursor = ACTION_FACTORY.format("statusNormal", cursorX, cursorY); - } - } else { - formatCursor = ACTION_FACTORY.format("statusCursorOff"); - } - cursor.setText(formatCursor); - } - - public void mouseDragged(final MouseEvent e) { - mousePosChanged(e); - } - - public void mouseMoved(final MouseEvent e) { - mousePosChanged(e); - } - - /** - * Set new mouse and map coordinates to mouse label. - * @param e Event that was fired from #MapCursor - */ - private void mousePosChanged(final MouseEvent e) { - final Point mousePos = e.getPoint(); - final int mouseX = mousePos.x; - final int mouseY = mousePos.y; - final LevelRenderer renderer = (LevelRenderer) e.getSource(); - final Point mouseMap = renderer.getTileLocationAt(mousePos, mouseMapTmp); - if (mouseMap != null) { - final int mouseMapX = mouseMap.x; - final int mouseMapY = mouseMap.y; - mouse.setText(ACTION_FACTORY.format("statusMouseOn", mouseX, mouseY, mouseMapX, mouseMapY)); - } else { - mouse.setText(ACTION_FACTORY.format("statusMouseOff", mouseX, mouseY)); - } - } - -} // class StatusBar Copied: trunk/src/app/net/sf/gridarta/gui/StatusBar.java (from rev 1321, trunk/daimonin/src/daieditor/gui/StatusBar.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2006-12-30 00:49:15 UTC (rev 1322) @@ -0,0 +1,232 @@ +/* + * 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.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Point; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; +import java.text.NumberFormat; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.BevelBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.map.LevelRenderer; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * <code>StatusBar</code> implements the main statusbar of the + * application. Used to show one line text messages to the user about + * progress, state etc. Also includes level info and memory info + * panels. + * @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> + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + * @todo Separate labels and methods for mouse coordinates + */ +public final class StatusBar extends JPanel implements MapCursorListener, MouseMotionListener { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + + /** Controller of this statusbar view. */ + private final MainControl mainControl; + + /** The label that shows the mouse. */ + private final JLabel mouse; + + /** The label that shows the cursor. */ + private final JLabel cursor; + + /** The label that shows the one line text message. */ + private final JLabel status; + + /** The label that shows the memory status. */ + private final JLabel memory; + + /** Temporary used to get map coordinates. */ + private final Point mouseMapTmp = new Point(); + + /** + * Constructs a statusbar that has the given main controller object set + * as its controller. + * @param mainControl The MainControl for statistical data. + */ + public StatusBar(final MainControl mainControl) { + this.mainControl = mainControl; + setLayout(new GridBagLayout()); + setBorder(new BevelBorder(BevelBorder.LOWERED)); + + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.WEST; + gbc.ipadx = 1; + + gbc.weightx = 0.0; + mouse = new JLabel(" "); + mouse.setBorder(new BevelBorder(BevelBorder.LOWERED)); + add(mouse, gbc); + + cursor = new JLabel(" "); + cursor.setBorder(new BevelBorder(BevelBorder.LOWERED)); + add(cursor, gbc); + + gbc.weightx = 5.0; + status = new JLabel(" "); + status.setBorder(new BevelBorder(BevelBorder.LOWERED)); + add(status, gbc); + + gbc.weightx = 0.0; + memory = new JLabel(" "); + memory.setBorder(new BevelBorder(BevelBorder.LOWERED)); + add(memory, gbc); + } + + /** + * Sets the level status text, which usually displays arch numbers. + * @param text String to set + */ + public void setStatusText(final String text) { + status.setText(text); + refresh(); + } + + /** Refreshes the memory usage info panel. */ + public void refresh() { + final Runtime runtime = Runtime.getRuntime(); + final long freeMem = runtime.freeMemory(); + final long totMem = runtime.totalMemory(); + final long usedMem = totMem - freeMem; + + memory.setText(ACTION_FACTORY.format("memory", + mainControl.getArchetypeSet().getArchetypeCount(), + mainControl.getFaceObjects().size(), + getMemoryString(usedMem), getMemoryString(freeMem), getMemoryString(totMem) + )); + } + + /** The DecimalFormat to use for formatting the numbers in {@link #getMemoryString(long)}.. */ + private static final NumberFormat FORMAT = NumberFormat.getInstance(); + + static { + FORMAT.setMinimumFractionDigits(1); + FORMAT.setMaximumFractionDigits(1); + } + + /** The units used by {@link #getMemoryString(long)}. */ + private static final String[] UNITS = {"Bytes", "KB", "MB", "GB"}; + + /** + * Returns the given memory amount as a string scales the value + * to be bytes, kilobytes or megabytes. + * @param mem memory amount to calculate + * @return String for <var>memory</var> + */ + @Nullable private static String getMemoryString(final long mem) { + for (int i = UNITS.length - 1; i >= 0; i--) { + final int m = 1 << i * 10; + if (mem > m) { + return FORMAT.format((double) mem / m) + UNITS[i]; + } + } + assert false; + return null; + } + + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + mapCursorChanged(e.getSource()); + } + + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + mapCursorChanged(e.getSource()); + } + + /** + * Set coordinates of MapCursor to cursor label and the offset when in drag mode. + * @param mapCursor MapCursor to set coordinates from. + */ + private void mapCursorChanged(final MapCursor mapCursor) { + final String formatCursor; + if (mapCursor.isActive()) { + final Point pos = mapCursor.getLocation(); + assert pos != null; + final int cursorX = pos.x; + final int cursorY = pos.y; + if (mapCursor.isDragging()) { + final Dimension offset = mapCursor.getDragOffset(); + assert offset != null; + final int offsetX = Math.abs(offset.width) + 1; + final int offsetY = Math.abs(offset.height) + 1; + formatCursor = ACTION_FACTORY.format("statusSelect", cursorX, cursorY, offsetX, offsetY); + } else { + formatCursor = ACTION_FACTORY.format("statusNormal", cursorX, cursorY); + } + } else { + formatCursor = ACTION_FACTORY.format("statusCursorOff"); + } + cursor.setText(formatCursor); + } + + public void mouseDragged(final MouseEvent e) { + mousePosChanged(e); + } + + public void mouseMoved(final MouseEvent e) { + mousePosChanged(e); + } + + /** + * Set new mouse and map coordinates to mouse label. + * @param e Event that was fired from #MapCursor + */ + private void mousePosChanged(final MouseEvent e) { + final Point mousePos = e.getPoint(); + final int mouseX = mousePos.x; + final int mouseY = mousePos.y; + final LevelRenderer renderer = (LevelRenderer) e.getSource(); + final Point mouseMap = renderer.getTileLocationAt(mousePos, mouseMapTmp); + if (mouseMap != null) { + final int mouseMapX = mouseMap.x; + final int mouseMapY = mouseMap.y; + mouse.setText(ACTION_FACTORY.format("statusMouseOn", mouseX, mouseY, mouseMapX, mouseMapY)); + } else { + mouse.setText(ACTION_FACTORY.format("statusMouseOff", mouseX, mouseY)); + } + } + +} // class StatusBar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 00:51:30
|
Revision: 1323 http://svn.sourceforge.net/gridarta/?rev=1323&view=rev Author: christianhujer Date: 2006-12-29 16:51:28 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Fixed build breakers caused by now wrong @Override annotations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-30 00:49:15 UTC (rev 1322) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-30 00:51:28 UTC (rev 1323) @@ -155,7 +155,7 @@ } /** {@inheritDoc} */ - @Override public BufferedImage getFullImage() { + public BufferedImage getFullImage() { final int viewWidth = 32 * mapSize.getWidth(); final int viewHeight = 32 * mapSize.getHeight(); @@ -330,7 +330,7 @@ } /** {@inheritDoc} */ - @Override @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { + @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { final int xm, ym; if (point.x >= borderOffset.x && point.x < mapSize.getWidth() * 32 + borderOffset.x && point.y >= borderOffset.y && point.y < mapSize.getHeight() * 32 + borderOffset.y) { xm = (point.x - borderOffset.x) / 32; Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-30 00:49:15 UTC (rev 1322) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-30 00:51:28 UTC (rev 1323) @@ -186,7 +186,7 @@ } /** {@inheritDoc} */ - @Override public BufferedImage getFullImage() { + public BufferedImage getFullImage() { // set map dimensions for iso view final int sum = mapSize.getWidth() + mapSize.getHeight(); final int viewWidth = sum * IGUIConstants.TILE_ISO_XLEN2; @@ -428,7 +428,7 @@ } /** {@inheritDoc} */ - @Override @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { + @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; Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2006-12-30 00:49:15 UTC (rev 1322) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2006-12-30 00:51:28 UTC (rev 1323) @@ -76,7 +76,7 @@ * Returns an image of the entire map view. * @return An image of the entire map view. */ - @Override public BufferedImage getFullImage() { + public BufferedImage getFullImage() { // set map dimensions for iso view calculateOrigin(); final int sum = mapSize.getWidth() + mapSize.getHeight(); @@ -179,7 +179,7 @@ } } - @Override @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { + @Nullable public Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint) { throw new IllegalStateException(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 01:44:26
|
Revision: 1326 http://svn.sourceforge.net/gridarta/?rev=1326&view=rev Author: christianhujer Date: 2006-12-29 17:44:26 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Migrated some constant references from IGUIConstants to CommonConstants. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -44,6 +44,7 @@ import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.ScrollPaneConstants; +import net.sf.gridarta.CommonConstants; import net.sf.gridarta.EditOperation; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapCursor; @@ -142,7 +143,7 @@ frame = fi; if (isPickmap()) { - setBackground(IGUIConstants.BG_COLOR); + setBackground(CommonConstants.BG_COLOR); } renderer = new DefaultLevelRenderer(this, mainControl, mapControl, isPickmap(), mapGrid); setViewportView(renderer); Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -8,7 +8,6 @@ package cfeditor.gui; import cfeditor.CMainControl; -import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; import java.awt.Color; import java.awt.Component; @@ -36,6 +35,7 @@ import javax.swing.border.LineBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import net.sf.gridarta.CommonConstants; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -191,11 +191,11 @@ icon = new JLabel(); popup = new JPopupMenu(); popup.setLayout(new FlowLayout()); - popup.setBackground(IGUIConstants.BG_COLOR); + popup.setBackground(CommonConstants.BG_COLOR); popup.setBorder(new LineBorder(Color.black)); popup.add(icon); popup.setFocusable(false); - setBackground(IGUIConstants.BG_COLOR); + setBackground(CommonConstants.BG_COLOR); } } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -30,7 +30,6 @@ import cfeditor.CFArchTypeList; import cfeditor.CFTreasureListTree; import cfeditor.CMainControl; -import cfeditor.IGUIConstants; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import java.awt.BorderLayout; @@ -91,6 +90,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.NamedObject; @@ -583,7 +583,7 @@ case LONG: case FLOAT: { cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(dType == ArchAttribType.FLOAT ? IGUIConstants.FLOAT_COLOR : IGUIConstants.INT_COLOR); + cLabel.setForeground(dType == ArchAttribType.FLOAT ? CommonConstants.FLOAT_COLOR : CommonConstants.INT_COLOR); newAttr = new DialogAttrib<JFormattedTextField>(attrib); final int fieldLength = attrib.getInputLength() == 0 ? TEXTFIELD_COLUMNS : attrib.getInputLength(); final NumberFormat format; @@ -683,7 +683,7 @@ case ZSPELL: case LIST: { cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(IGUIConstants.INT_COLOR); + cLabel.setForeground(CommonConstants.INT_COLOR); newAttr = new DialogAttrib<JComboBox>(attrib); // create ComboBox with parsed selection final JComboBox input; @@ -716,7 +716,7 @@ case DBLLIST: { final JPanel compo = new JPanel(new BorderLayout()); cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(IGUIConstants.INT_COLOR); + cLabel.setForeground(CommonConstants.INT_COLOR); newAttr = new DialogAttrib<JComboBox[]>(attrib); // create ComboBox with parsed selection final JComboBox[] inputs = new JComboBox[2]; Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -27,7 +27,6 @@ import cfeditor.CFilterControl; import cfeditor.CMainControl; import cfeditor.CMapViewBasic; -import cfeditor.IGUIConstants; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; @@ -40,6 +39,7 @@ import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; +import net.sf.gridarta.CommonConstants; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; @@ -536,7 +536,7 @@ private void setColor(final Graphics grfx) { if (isPickmap) { // draw greenisch background for pickmaps - grfx.setColor(IGUIConstants.BG_COLOR); + grfx.setColor(CommonConstants.BG_COLOR); } else { grfx.setColor(mainControl.getMainView().getBackground()); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -47,6 +47,7 @@ import javax.imageio.ImageIO; import javax.swing.JScrollPane; import javax.swing.JViewport; +import net.sf.gridarta.CommonConstants; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; @@ -131,7 +132,7 @@ this.mainControl = mainControl; if (isPickmap()) { - setBackground(IGUIConstants.BG_COLOR); + setBackground(CommonConstants.BG_COLOR); } renderer = new DefaultLevelRenderer(mainControl, mapControl, mapControl.isPickmap(), mapGrid); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -30,7 +30,6 @@ import daieditor.CFArchTypeList; import daieditor.CFTreasureListTree; import daieditor.CMainControl; -import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import java.awt.BorderLayout; import java.awt.CardLayout; @@ -90,6 +89,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.NamedObject; @@ -578,7 +578,7 @@ case LONG: case FLOAT: { cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(dType == ArchAttribType.FLOAT ? IGUIConstants.FLOAT_COLOR : IGUIConstants.INT_COLOR); + cLabel.setForeground(dType == ArchAttribType.FLOAT ? CommonConstants.FLOAT_COLOR : CommonConstants.INT_COLOR); newAttr = new DialogAttrib<JFormattedTextField>(attrib); final int fieldLength = attrib.getInputLength() == 0 ? TEXTFIELD_COLUMNS : attrib.getInputLength(); final NumberFormat format; @@ -678,7 +678,7 @@ case ZSPELL: case LIST: { cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(IGUIConstants.INT_COLOR); + cLabel.setForeground(CommonConstants.INT_COLOR); newAttr = new DialogAttrib<JComboBox>(attrib); // create ComboBox with parsed selection final JComboBox input; @@ -711,7 +711,7 @@ case DBLLIST: { final JPanel compo = new JPanel(new BorderLayout()); cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(IGUIConstants.INT_COLOR); + cLabel.setForeground(CommonConstants.INT_COLOR); newAttr = new DialogAttrib<JComboBox[]>(attrib); // create ComboBox with parsed selection final JComboBox[] inputs = new JComboBox[2]; Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-30 01:38:51 UTC (rev 1325) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-30 01:44:26 UTC (rev 1326) @@ -42,6 +42,7 @@ import java.awt.image.BufferedImage; import java.util.Map; import javax.swing.ImageIcon; +import net.sf.gridarta.CommonConstants; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; @@ -112,7 +113,7 @@ isPickmap = pickmap; if (isPickmap) { setBorderOffset(0, IGUIConstants.TILE_ISO_YLEN); - setBackground(IGUIConstants.BG_COLOR); + setBackground(CommonConstants.BG_COLOR); } else { setBorderOffset(IGUIConstants.TILE_ISO_XLEN, 2 * IGUIConstants.TILE_ISO_YLEN); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 01:48:47
|
Revision: 1327 http://svn.sourceforge.net/gridarta/?rev=1327&view=rev Author: christianhujer Date: 2006-12-29 17:48:48 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Added status bar text and arch panel quick object to MainControl unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 01:44:26 UTC (rev 1326) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 01:48:48 UTC (rev 1327) @@ -85,7 +85,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author Andreas Kirschbaum */ -public final class CMainControl implements ThrowableHandler, MainControl { +public final class CMainControl implements ThrowableHandler, MainControl<GameObject> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 01:44:26 UTC (rev 1326) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 01:48:48 UTC (rev 1327) @@ -134,7 +134,7 @@ * @author Andreas Kirschbaum * @fixme I'm 2200 lines long, therefor I suck. */ -public final class CMainControl implements ThrowableHandler, MapModelListener, MainControl { +public final class CMainControl implements ThrowableHandler, MapModelListener, MainControl<GameObject> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-12-30 01:44:26 UTC (rev 1326) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-12-30 01:48:48 UTC (rev 1327) @@ -4,6 +4,7 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; import org.jetbrains.annotations.NotNull; @@ -12,7 +13,7 @@ * It should become obsolete after a while. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MainControl { +public interface MainControl<G extends GameObject> { /** * Global random number generator. @@ -81,12 +82,20 @@ * Register a MainControlListener. * @param listener MainControlListener to register */ - void addMainControlListener(@NotNull final MainControlListener listener); + void addMainControlListener(@NotNull MainControlListener listener); /** * Remove a MainControlListener. * @param listener MainControlListener to remove */ - void removeMainControlListener(@NotNull final MainControlListener listener); + void removeMainControlListener(@NotNull MainControlListener listener); + void showArchPanelQuickObject(G gameObject); + + /** + * Sets a status message which will be shown in the status bar. + * @param string Status message to show + */ + void setStatusText(String string); + } // interface MainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 01:49:37
|
Revision: 1328 http://svn.sourceforge.net/gridarta/?rev=1328&view=rev Author: christianhujer Date: 2006-12-29 17:49:37 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Extracted unified ArchetypeChooser parts into gridarta class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/gui/ArchetypeChooser.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java Modified: trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java 2006-12-30 01:48:48 UTC (rev 1327) +++ trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java 2006-12-30 01:49:37 UTC (rev 1328) @@ -43,190 +43,37 @@ import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.ListSelectionModel; +import javax.swing.ListCellRenderer; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.MainControl; /** * Panel for Archetypes. * @author unknown * @author Andreas Kirschbaum */ -public final class ArchetypeChooser extends JPanel { +public final class ArchetypeChooser extends net.sf.gridarta.gui.ArchetypeChooser<GameObject> { private static final Logger log = Logger.getLogger(ArchetypeChooser.class); /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** Controller of this subview. */ - private final CMainControl mainControl; - - /** - * List of archetypes for each folder. The folders correspond to the - * entries in {@link #comboBox}. - * @note The first entry is always <code>null</code>. - */ - private final ArrayList<ArrayList<GameObject>> folders = new ArrayList<ArrayList<GameObject>>(); - - /** - * The list of currently shown archetypes; it is updated from {@link - * #folders} each time a new folder is selected. - */ - private final JList archList; - - private final DefaultListModel model; - - private final JComboBox comboBox; - - private final InsertionObjectChooser archPanel; - - /** - * Comparator used to sort entries shown in {@link #archList}. - */ - private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() - { - public int compare(final GameObject o1, final GameObject o2) { - return o1.getArchetypeName().compareToIgnoreCase(o2.getArchetypeName()); - } - }; - - /** - * Temporary variable used to collect and sort the archeteypes to be - * inserted into {@link #archList}. - */ - private static final TreeSet<GameObject> sortedArchetypes = new TreeSet<GameObject>(archComparator); - /* Build Panel */ - public ArchetypeChooser(final InsertionObjectChooser controlPanel, final CMainControl mainControl) { - super(new BorderLayout()); - this.mainControl = mainControl; - archPanel = controlPanel; - - comboBox = new JComboBox(); - - model = new DefaultListModel(); - archList = new JList(model); - archList.setCellRenderer(new MyCellRenderer()); - archList.setBackground(IGUIConstants.BG_COLOR); - archList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - final JScrollPane scrollPane = new JScrollPane(archList); - add(scrollPane, BorderLayout.CENTER); - add(comboBox, BorderLayout.NORTH); - scrollPane.setAutoscrolls(true); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - - comboBox.setAutoscrolls(true); + public ArchetypeChooser(final InsertionObjectChooser controlPanel, final MainControl mainControl) { + super(controlPanel, mainControl); } - public void finishBuildProcess() { - comboBox.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - showArchList(); - } - }); - - archList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(final ListSelectionEvent e) { - updateSelectedArchListObject(); - } - }); + @Override protected ListCellRenderer createRenderer() { + return new MyCellRenderer(); } - /** - * Get the GameObject currently selected in the list. - * @return GameObject or <code>null</code> if no selection - */ - public GameObject getArchListObject() { - return (GameObject) archList.getSelectedValue(); - } - - /** - * Show the selected archetype. - */ - private void updateSelectedArchListObject() { - final GameObject archetype = (GameObject) archList.getSelectedValue(); - mainControl.setStatusText(archetype != null ? archetype.getArchetypeName() : ""); - archPanel.setSelectedArch(archetype); - mainControl.showArchPanelQuickObject(archetype); - } - - /** - * Add an archetype to this panel. - * - * @param folderName the folder to add it to - * - * @param arch the archetype to add - */ - public void addArchetype(@NotNull final String folderName, @NotNull final GameObject arch) { - final ArrayList<GameObject> folder = findOrCreateFolder(folderName); - folder.add(arch); - } - - /** - * Return a folder by name. If this folder does not exist, create a new one. - * - * @param folderName the folder name - * - * @return the folder - */ - @NotNull private ArrayList<GameObject> findOrCreateFolder(@NotNull final String folderName) { - assert folders.size() == comboBox.getItemCount(); - for (int i = 1; i < folders.size(); i++) { - if (folderName.equals(comboBox.getItemAt(i))) { - return folders.get(i); - } - } - - if (folders.size() <= 0) { - comboBox.addItem("show all"); - folders.add(null); // first entry is always empty - } - - // insert new folder in alphabetical order - int i; - for (i = 1; i < folders.size(); i++) { - if (folderName.compareToIgnoreCase((String) comboBox.getItemAt(i)) <= 0) { - break; - } - } - - final ArrayList<GameObject> folder = new ArrayList<GameObject>(); - comboBox.insertItemAt(folderName, i); - folders.add(i, folder); - - return folder; - } - - /** - * Update {@link #archList} to contain the currently selected folder. - */ - public void showArchList() { - final int index = comboBox.getSelectedIndex(); - - sortedArchetypes.clear(); - if (index == 0) { - for (int i = 1; i < folders.size(); i++) { - sortedArchetypes.addAll(folders.get(i)); - } - } else if (index > 0) { - final ArrayList<GameObject> archList = folders.get(index); - if (archList != null) { - sortedArchetypes.addAll(archList); - } - } - - archList.setVisible(false); - model.removeAllElements(); - for (final GameObject arch : sortedArchetypes) { - model.addElement(arch); - } - archList.setVisible(true); - } - /** Cell Renderer for rendering cells in the ArchPanelPan. */ - private final class MyCellRenderer extends DefaultListCellRenderer { + private static final class MyCellRenderer extends DefaultListCellRenderer { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -244,7 +91,7 @@ } else if (archetype.getFaceNr() == -1) { setIcon(CMainControl.getUnknownTileIcon()); } else { - setIcon(mainControl.getFace(archetype.getFaceNr())); + setIcon(CMainControl.getInstance().getFace(archetype.getFaceNr())); } return this; Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2006-12-30 01:48:48 UTC (rev 1327) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2006-12-30 01:49:37 UTC (rev 1328) @@ -49,7 +49,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author Andreas Kirschbaum */ -public final class InsertionObjectChooser extends JPanel { +public final class InsertionObjectChooser extends JPanel implements net.sf.gridarta.gui.InsertionObjectChooser<GameObject> { private static final String ARCHPANEL_LOCATION_KEY = "MainWindowArchPanel.dividerLocation"; Modified: trunk/daimonin/src/daieditor/gui/ArchetypeChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchetypeChooser.java 2006-12-30 01:48:48 UTC (rev 1327) +++ trunk/daimonin/src/daieditor/gui/ArchetypeChooser.java 2006-12-30 01:49:37 UTC (rev 1328) @@ -47,9 +47,12 @@ import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.ListSelectionModel; +import javax.swing.ListCellRenderer; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.sf.japi.swing.ActionFactory; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.MainControl; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -58,7 +61,7 @@ * @author unknown * @author Andreas Kirschbaum */ -public final class ArchetypeChooser extends JPanel { +public final class ArchetypeChooser extends net.sf.gridarta.gui.ArchetypeChooser<GameObject> { private static final Logger log = Logger.getLogger(ArchetypeChooser.class); @@ -68,71 +71,17 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** Controller of this subview. */ - private final CMainControl mainControl; - - /** - * List of archetypes for each folder. The folders correspond to the - * entries in {@link #comboBox}. - * @note The first entry is always <code>null</code>. - */ - private final ArrayList<ArrayList<GameObject>> folders = new ArrayList<ArrayList<GameObject>>(); - - /** - * The list of currently shown archetypes; it is updated from {@link - * #folders} each time a new folder is selected. - */ - private final JList archList; - - private final DefaultListModel model; - - private final JComboBox comboBox; - /** The popup menu for the arch lists to bring up the editor. */ // This looks unused, but don't remove it. It will be used in future. private final JPopupMenu menu = createListPopupMenu(); - private final InsertionObjectChooser archPanel; - - /** - * Comparator used to sort entries shown in {@link #archList}. - */ - private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() - { - public int compare(final GameObject o1, final GameObject o2) { - return o1.getArchetypeName().compareToIgnoreCase(o2.getArchetypeName()); - } - }; - - /** - * Temporary variable used to collect and sort the archeteypes to be - * inserted into {@link #archList}. - */ - private static final TreeSet<GameObject> sortedArchetypes = new TreeSet<GameObject>(archComparator); - /* Build Panel */ - public ArchetypeChooser(final InsertionObjectChooser controlPanel, final CMainControl mainControl) { - super(new BorderLayout()); - this.mainControl = mainControl; - archPanel = controlPanel; - - comboBox = new JComboBox(); - - model = new DefaultListModel(); - archList = new JList(model); - archList.setCellRenderer(new MyCellRenderer()); - archList.setBackground(IGUIConstants.BG_COLOR); - archList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - final JScrollPane scrollPane = new JScrollPane(archList); - add(scrollPane, BorderLayout.CENTER); - add(comboBox, BorderLayout.NORTH); - scrollPane.setAutoscrolls(true); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - - comboBox.setAutoscrolls(true); + public ArchetypeChooser(final InsertionObjectChooser controlPanel, final MainControl mainControl) { + super(controlPanel, mainControl); } - public void finishBuildProcess() { + /*@Override public void finishBuildProcess() { + super.finishBuildProcess(); // listening for mouse-click events in the ArchPanel list archList.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { @@ -144,20 +93,9 @@ } }); - comboBox.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - showArchList(); - } - }); - archList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(final ListSelectionEvent e) { - updateSelectedArchListObject(); - } - }); - //archList.setComponentPopupMenu(menu); - } + }*/ private JPopupMenu createListPopupMenu() { final JPopupMenu menu = new JPopupMenu(); @@ -170,102 +108,16 @@ */ public void editPopup() { final GameObject arch = getArchListObject(); - GameObjectAttributesDialog.showAttribDialog(mainControl.getTypeList(), arch, mainControl); + GameObjectAttributesDialog.showAttribDialog(CMainControl.getInstance().getTypeList(), arch, CMainControl.getInstance()); } - /** - * Get the GameObject currently selected in the list. - * @return GameObject or <code>null</code> if no selection - */ - public GameObject getArchListObject() { - return (GameObject) archList.getSelectedValue(); - } - /** - * Show the selected archetype. - */ - private void updateSelectedArchListObject() { - final GameObject archetype = (GameObject) archList.getSelectedValue(); - mainControl.setStatusText(archetype != null ? archetype.getArchetypeName() : ""); - archPanel.setSelectedArch(archetype); - mainControl.showArchPanelQuickObject(archetype); + @Override protected ListCellRenderer createRenderer() { + return new MyCellRenderer(); } - /** - * Add an archetype to this panel. - * - * @param folderName the folder to add it to - * - * @param arch the archetype to add - */ - public void addArchetype(@NotNull final String folderName, @NotNull final GameObject arch) { - final ArrayList<GameObject> folder = findOrCreateFolder(folderName); - folder.add(arch); - } - - /** - * Return a folder by name. If this folder does not exist, create a new one. - * - * @param folderName the folder name - * - * @return the folder - */ - @NotNull private ArrayList<GameObject> findOrCreateFolder(@NotNull final String folderName) { - assert folders.size() == comboBox.getItemCount(); - for (int i = 1; i < folders.size(); i++) { - if (folderName.equals(comboBox.getItemAt(i))) { - return folders.get(i); - } - } - - if (folders.size() <= 0) { - comboBox.addItem("show all"); - folders.add(null); // first entry is always empty - } - - // insert new folder in alphabetical order - int i; - for (i = 1; i < folders.size(); i++) { - if (folderName.compareToIgnoreCase((String) comboBox.getItemAt(i)) <= 0) { - break; - } - } - - final ArrayList<GameObject> folder = new ArrayList<GameObject>(); - comboBox.insertItemAt(folderName, i); - folders.add(i, folder); - - return folder; - } - - /** - * Update {@link #archList} to contain the currently selected folder. - */ - public void showArchList() { - final int index = comboBox.getSelectedIndex(); - - sortedArchetypes.clear(); - if (index == 0) { - for (int i = 1; i < folders.size(); i++) { - sortedArchetypes.addAll(folders.get(i)); - } - } else if (index > 0) { - final ArrayList<GameObject> archList = folders.get(index); - if (archList != null) { - sortedArchetypes.addAll(archList); - } - } - - archList.setVisible(false); - model.removeAllElements(); - for (final GameObject arch : sortedArchetypes) { - model.addElement(arch); - } - archList.setVisible(true); - } - /** Cell Renderer for rendering cells in the ArchPanelPan. */ - private final class MyCellRenderer extends DefaultListCellRenderer { + private static final class MyCellRenderer extends DefaultListCellRenderer { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -281,7 +133,7 @@ if (archetype.hasFaceObject()) { setIcon(CMainControl.getNofaceTileIcon()); } else { - final ImageIcon icon = mainControl.getArchetypeSet().getFace(archetype.getFaceRealName()); + final ImageIcon icon = CMainControl.getInstance().getArchetypeSet().getFace(archetype.getFaceRealName()); if (icon == null) { //setIcon(mainControl.nofaceTileIcon); } else { Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2006-12-30 01:48:48 UTC (rev 1327) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2006-12-30 01:49:37 UTC (rev 1328) @@ -48,7 +48,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public final class InsertionObjectChooser extends JPanel { +public final class InsertionObjectChooser extends JPanel implements net.sf.gridarta.gui.InsertionObjectChooser<GameObject> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; Added: trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java 2006-12-30 01:49:37 UTC (rev 1328) @@ -0,0 +1,202 @@ +package net.sf.gridarta.gui; + +import javax.swing.JPanel; +import javax.swing.JComboBox; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JViewport; +import javax.swing.ListSelectionModel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.gameobject.GameObject; +import java.awt.BorderLayout; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.TreeSet; +import org.jetbrains.annotations.NotNull; + +/** + * Common base class for the panel for Archetypes. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class ArchetypeChooser<G extends GameObject> extends JPanel { + + /** Controller of this subview. */ + private final MainControl mainControl; + + /** + * List of archetypes for each folder. The folders correspond to the + * entries in {@link #comboBox}. + * @note The first entry is always <code>null</code>. + */ + private final ArrayList<ArrayList<G>> folders = new ArrayList<ArrayList<G>>(); + + /** + * The list of currently shown archetypes; it is updated from {@link + * #folders} each time a new folder is selected. + */ + private final JList archList; + + private final DefaultListModel model; + + private final JComboBox comboBox; + + private final InsertionObjectChooser archPanel; + + /** + * Comparator used to sort entries shown in {@link #archList}. + */ + private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() + { + public int compare(final GameObject o1, final GameObject o2) { + return o1.getArchetypeName().compareToIgnoreCase(o2.getArchetypeName()); + } + }; + + /** + * Temporary variable used to collect and sort the archeteypes to be + * inserted into {@link #archList}. + */ + private static final TreeSet<GameObject> sortedArchetypes = new TreeSet<GameObject>(archComparator); + + /** + * Creates an ArchetypeChooser. + * @param controlPanel InsertionObjectChooser + * @param mainControl MainControl, used for status messages. + */ + protected ArchetypeChooser(@NotNull final InsertionObjectChooser controlPanel, @NotNull final MainControl mainControl) { + super(new BorderLayout()); + this.mainControl = mainControl; + archPanel = controlPanel; + + comboBox = new JComboBox(); + + model = new DefaultListModel(); + archList = new JList(model); + //noinspection AbstractMethodCallInConstructor + archList.setCellRenderer(createRenderer()); + archList.setBackground(CommonConstants.BG_COLOR); + archList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + final JScrollPane scrollPane = new JScrollPane(archList); + add(scrollPane, BorderLayout.CENTER); + add(comboBox, BorderLayout.NORTH); + scrollPane.setAutoscrolls(true); + scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); + + comboBox.setAutoscrolls(true); + } + + public void finishBuildProcess() { + comboBox.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent e) { + showArchList(); + } + }); + + archList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(final ListSelectionEvent e) { + updateSelectedArchListObject(); + } + }); + + } + /** + * Get the GameObject currently selected in the list. + * @return GameObject or <code>null</code> if no selection + */ + public G getArchListObject() { + return (G) archList.getSelectedValue(); + } + + /** + * Show the selected archetype. + */ + private void updateSelectedArchListObject() { + final G archetype = (G) archList.getSelectedValue(); + mainControl.setStatusText(archetype != null ? archetype.getArchetypeName() : ""); + archPanel.setSelectedArch(archetype); + mainControl.showArchPanelQuickObject(archetype); + } + + /** + * Add an archetype to this panel. + * + * @param folderName the folder to add it to + * + * @param arch the archetype to add + */ + public void addArchetype(@NotNull final String folderName, @NotNull final G arch) { + final ArrayList<G> folder = findOrCreateFolder(folderName); + folder.add(arch); + } + + /** + * Return a folder by name. If this folder does not exist, create a new one. + * + * @param folderName the folder name + * + * @return the folder + */ + @NotNull private ArrayList<G> findOrCreateFolder(@NotNull final String folderName) { + assert folders.size() == comboBox.getItemCount(); + for (int i = 1; i < folders.size(); i++) { + if (folderName.equals(comboBox.getItemAt(i))) { + return folders.get(i); + } + } + + if (folders.size() <= 0) { + comboBox.addItem("show all"); + folders.add(null); // first entry is always empty + } + + // insert new folder in alphabetical order + int i; + for (i = 1; i < folders.size(); i++) { + if (folderName.compareToIgnoreCase((String) comboBox.getItemAt(i)) <= 0) { + break; + } + } + + final ArrayList<G> folder = new ArrayList<G>(); + comboBox.insertItemAt(folderName, i); + folders.add(i, folder); + + return folder; + } + + /** + * Update {@link #archList} to contain the currently selected folder. + */ + public void showArchList() { + final int index = comboBox.getSelectedIndex(); + + sortedArchetypes.clear(); + if (index == 0) { + for (int i = 1; i < folders.size(); i++) { + sortedArchetypes.addAll(folders.get(i)); + } + } else if (index > 0) { + final ArrayList<G> archList = folders.get(index); + if (archList != null) { + sortedArchetypes.addAll(archList); + } + } + + archList.setVisible(false); + model.removeAllElements(); + for (final GameObject arch : sortedArchetypes) { + model.addElement(arch); + } + archList.setVisible(true); + } + + protected abstract ListCellRenderer createRenderer(); + +} // class ArchetypeChooser. Property changes on: trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java 2006-12-30 01:49:37 UTC (rev 1328) @@ -0,0 +1,13 @@ +package net.sf.gridarta.gui; + +import net.sf.gridarta.gameobject.GameObject; + +/** + * Common base interface for InsertionObjectChoosers. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface InsertionObjectChooser<G extends GameObject> { + + void setSelectedArch(G selectedArch); + +} // interface InsertionObjectChooser Property changes on: trunk/src/app/net/sf/gridarta/gui/InsertionObjectChooser.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 01:50:13
|
Revision: 1329 http://svn.sourceforge.net/gridarta/?rev=1329&view=rev Author: christianhujer Date: 2006-12-29 17:50:13 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Removed unified constants. 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-12-30 01:49:37 UTC (rev 1328) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-30 01:50:13 UTC (rev 1329) @@ -154,14 +154,6 @@ /** Application image definitions. */ String STARTUP_IMAGE = "CFIntro.gif"; - /** Background Color (for the Panels). */ - Color BG_COLOR = new Color(100, 219, 169); - - /** Color for float/int values (AttribDialog). */ - Color FLOAT_COLOR = new Color(19, 134, 0); - - Color INT_COLOR = new Color(74, 70, 156); - /** Application icon definitions (icon-dir). */ String APP_ICON = "CFIcon.gif"; Modified: trunk/daimonin/src/daieditor/IGUIConstants.java =================================================================== --- trunk/daimonin/src/daieditor/IGUIConstants.java 2006-12-30 01:49:37 UTC (rev 1328) +++ trunk/daimonin/src/daieditor/IGUIConstants.java 2006-12-30 01:50:13 UTC (rev 1329) @@ -156,14 +156,6 @@ String ARTIFACTS_FILE = "artifacts"; // file with artifact definitions - /** Background Color (for the Panels). */ - Color BG_COLOR = new Color(100, 219, 169); - - /** Color for float/int values (AttribDialog). */ - Color FLOAT_COLOR = new Color(19, 134, 0); - - Color INT_COLOR = new Color(74, 70, 156); - /** Application icon definitions (icon-dir). */ String APP_ICON = "CFIcon.gif"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 13:44:51
|
Revision: 1330 http://svn.sourceforge.net/gridarta/?rev=1330&view=rev Author: christianhujer Date: 2006-12-30 05:44:52 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Moved map folder to interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 01:50:13 UTC (rev 1329) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 13:44:52 UTC (rev 1330) @@ -546,6 +546,7 @@ /** Swing FileFilter for Python scripts. */ public static final FileFilter pythonFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.python"), ".py")); + /** {@inheritDoc} */ public String getMapDefaultFolder() { return strMapDir; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 01:50:13 UTC (rev 1329) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 13:44:52 UTC (rev 1330) @@ -724,6 +724,7 @@ /** Swing FileFilter for all unignored files. */ public static final FileFilter unignoredFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.unignored"), "")); + /** {@inheritDoc} */ public String getMapDefaultFolder() { return strMapDir; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-12-30 01:50:13 UTC (rev 1329) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-12-30 13:44:52 UTC (rev 1330) @@ -33,6 +33,12 @@ String getArchDefaultFolder(); /** + * Get the default folder of maps. + * @return default folder of maps. + */ + String getMapDefaultFolder(); + + /** * Get the FileFilter that matches script files of this implementation's server side scripting language. * @return FileFilter that matches script files of this implementation's server side scripting language. * @see #getScriptSuffix() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 13:49:07
|
Revision: 1331 http://svn.sourceforge.net/gridarta/?rev=1331&view=rev Author: christianhujer Date: 2006-12-30 05:49:07 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Refactored PathManager to use MainControl interface instead of CMainControl implementations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/io/PathManager.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/io/PathManager.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 13:44:52 UTC (rev 1330) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 13:49:07 UTC (rev 1331) @@ -39,6 +39,7 @@ import cfeditor.gui.prefs.ResPrefs; import cfeditor.io.CMapReader; import cfeditor.io.CMapWriter; +import cfeditor.io.PathManager; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -206,6 +207,7 @@ scriptControl = new CScriptController(this); mapCursorControl = new MapCursorControl(this); mainView = new CMainView(); + PathManager.setMainControl(this); } /** Modified: trunk/crossfire/src/cfeditor/io/PathManager.java =================================================================== --- trunk/crossfire/src/cfeditor/io/PathManager.java 2006-12-30 13:44:52 UTC (rev 1330) +++ trunk/crossfire/src/cfeditor/io/PathManager.java 2006-12-30 13:49:07 UTC (rev 1331) @@ -21,9 +21,9 @@ package cfeditor.io; -import cfeditor.CMainControl; import java.io.File; import java.io.IOException; +import net.sf.gridarta.MainControl; /** * This class contains methods for converting relative map paths to absolute map paths and vice versa. @@ -31,12 +31,14 @@ * Therefore it makes sense to treat them as URIs in the editor as well. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo make more use of URI - * @todo This class knows CMainControl. The dependency should be flipped: instead CMainControl should use this class. Then this class could be used by crossfire, too. */ public final class PathManager { // NOTE: There are certainly faster algorithms. But these methods are rarely used. + /** Reference to MainControl for obtaining folder information. */ + private static MainControl mainControl; + /** * Private constructor. * There are only static methods, so prevent this class from being instanciated. @@ -45,13 +47,21 @@ } /** + * Sets the reference to MainControl for obtaining folder information. + * @param mainControl Reference to MainControl + */ + public static void setMainControl(final MainControl mainControl) { + PathManager.mainControl = mainControl; + } + + /** * Create arch path. * Replaces all occurences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. * @param path to create arch path from * @return fixed path */ public static String getArchPath(final String path) { - final String archDirName = CMainControl.getInstance().getArchDefaultFolder(); + final String archDirName = mainControl.getArchDefaultFolder(); String archPath = path.replace('\\', '/'); if (archPath.startsWith(archDirName)) { archPath = archPath.substring(archDirName.length()); @@ -71,7 +81,7 @@ * @throws IOException In case of problems converting / creating the map path. */ public static String getMapPath(final String path) throws IOException { - final String mapDirName = CMainControl.getInstance().getMapDefaultFolder(); + final String mapDirName = mainControl.getMapDefaultFolder(); String mapPath = path.replace('\\', '/'); if (mapPath.startsWith(mapDirName)) { mapPath = mapPath.substring(mapDirName.length()); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 13:44:52 UTC (rev 1330) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 13:49:07 UTC (rev 1331) @@ -52,6 +52,7 @@ import daieditor.gui.prefs.UpdatePrefs; import daieditor.io.CMapReader; import daieditor.io.CMapWriter; +import daieditor.io.PathManager; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; @@ -317,6 +318,7 @@ refreshMenusAndToolbars(); archetypeSet.loadArchetypes(); validators = createMapValidators(); + PathManager.setMainControl(this); } /** Modified: trunk/daimonin/src/daieditor/io/PathManager.java =================================================================== --- trunk/daimonin/src/daieditor/io/PathManager.java 2006-12-30 13:44:52 UTC (rev 1330) +++ trunk/daimonin/src/daieditor/io/PathManager.java 2006-12-30 13:49:07 UTC (rev 1331) @@ -21,9 +21,9 @@ package daieditor.io; -import daieditor.CMainControl; import java.io.File; import java.io.IOException; +import net.sf.gridarta.MainControl; /** * This class contains methods for converting relative map paths to absolute map paths and vice versa. @@ -31,12 +31,14 @@ * Therefore it makes sense to treat them as URIs in the editor as well. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo make more use of URI - * @todo This class knows CMainControl. The dependency should be flipped: instead CMainControl should use this class. Then this class could be used by crossfire, too. */ public final class PathManager { // NOTE: There are certainly faster algorithms. But these methods are rarely used. + /** Reference to MainControl for obtaining folder information. */ + private static MainControl mainControl; + /** * Private constructor. * There are only static methods, so prevent this class from being instanciated. @@ -45,13 +47,21 @@ } /** + * Sets the reference to MainControl for obtaining folder information. + * @param mainControl Reference to MainControl + */ + public static void setMainControl(final MainControl mainControl) { + PathManager.mainControl = mainControl; + } + + /** * Create arch path. * Replaces all occurences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. * @param path to create arch path from * @return fixed path */ public static String getArchPath(final String path) { - final String archDirName = CMainControl.getInstance().getArchDefaultFolder(); + final String archDirName = mainControl.getArchDefaultFolder(); String archPath = path.replace('\\', '/'); if (archPath.startsWith(archDirName)) { archPath = archPath.substring(archDirName.length()); @@ -71,7 +81,7 @@ * @throws IOException In case of problems converting / creating the map path. */ public static String getMapPath(final String path) throws IOException { - final String mapDirName = CMainControl.getInstance().getMapDefaultFolder(); + final String mapDirName = mainControl.getMapDefaultFolder(); String mapPath = path.replace('\\', '/'); if (mapPath.startsWith(mapDirName)) { mapPath = mapPath.substring(mapDirName.length()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 13:58:00
|
Revision: 1332 http://svn.sourceforge.net/gridarta/?rev=1332&view=rev Author: christianhujer Date: 2006-12-30 05:57:56 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Moved unified PathManager to Gridarta. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java trunk/crossfire/src/cfeditor/io/package.html trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/io/package.html trunk/daimonin/src/test/daieditor/io/PathManagerTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/io/PathManager.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/io/PathManager.java trunk/daimonin/src/daieditor/io/PathManager.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -39,7 +39,6 @@ import cfeditor.gui.prefs.ResPrefs; import cfeditor.io.CMapReader; import cfeditor.io.CMapWriter; -import cfeditor.io.PathManager; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -68,6 +67,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGridEvent; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.MapType; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.japi.swing.ActionFactory; Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -26,7 +26,6 @@ import cfeditor.IGUIConstants; import static cfeditor.IGUIConstants.DIALOG_BORDER; import cfeditor.ResourceFileManager; -import cfeditor.io.PathManager; import java.awt.Component; import java.awt.Container; import java.awt.FlowLayout; @@ -45,6 +44,7 @@ import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.JFileChooserButton; import net.sf.japi.swing.prefs.AbstractPrefs; Deleted: trunk/crossfire/src/cfeditor/io/PathManager.java =================================================================== --- trunk/crossfire/src/cfeditor/io/PathManager.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/crossfire/src/cfeditor/io/PathManager.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -1,228 +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 cfeditor.io; - -import java.io.File; -import java.io.IOException; -import net.sf.gridarta.MainControl; - -/** - * This class contains methods for converting relative map paths to absolute map paths and vice versa. - * Serverside, paths to maps always are URIs with the maps directory being the root directory for the maps. - * Therefore it makes sense to treat them as URIs in the editor as well. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo make more use of URI - */ -public final class PathManager { - - // NOTE: There are certainly faster algorithms. But these methods are rarely used. - - /** Reference to MainControl for obtaining folder information. */ - private static MainControl mainControl; - - /** - * Private constructor. - * There are only static methods, so prevent this class from being instanciated. - */ - private PathManager() { - } - - /** - * Sets the reference to MainControl for obtaining folder information. - * @param mainControl Reference to MainControl - */ - public static void setMainControl(final MainControl mainControl) { - PathManager.mainControl = mainControl; - } - - /** - * Create arch path. - * Replaces all occurences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. - * @param path to create arch path from - * @return fixed path - */ - public static String getArchPath(final String path) { - final String archDirName = mainControl.getArchDefaultFolder(); - String archPath = path.replace('\\', '/'); - if (archPath.startsWith(archDirName)) { - archPath = archPath.substring(archDirName.length()); - } - if (archPath.startsWith(new File(archDirName).getAbsolutePath())) { - archPath = archPath.substring(new File(archDirName).getAbsolutePath().length()); - } - archPath = archPath.replace('\\', '/'); - return archPath; - } - - /** - * Create map path. - * Replaces all occurences of '\' with '/' and removes the path to the map directory (absolute, relative or canonical) from the path. - * @param path to create map path from - * @return fixed path - * @throws IOException In case of problems converting / creating the map path. - */ - public static String getMapPath(final String path) throws IOException { - final String mapDirName = mainControl.getMapDefaultFolder(); - String mapPath = path.replace('\\', '/'); - if (mapPath.startsWith(mapDirName)) { - mapPath = mapPath.substring(mapDirName.length()); - } - if (mapPath.startsWith(new File(mapDirName).getAbsolutePath())) { - mapPath = mapPath.substring(new File(mapDirName).getAbsolutePath().length()); - } - if (mapPath.startsWith(new File(mapDirName).getCanonicalPath())) { - mapPath = mapPath.substring(new File(mapDirName).getCanonicalPath().length()); - } - mapPath = mapPath.replace('\\', '/'); - return mapPath; - } - - /** - * Check whether a path is absolute. - * Paths starting with "/" are absolute, paths starting with other characters are relative. - * Empty paths are relative. - * @param path Path to check - * @return <code>true</code> if <var>path</var> is absolute, <code>false</code> otherwise - * @see #isRelative(String) which nearly is the opposite of this method - */ - public static boolean isAbsolute(final String path) { - return path.startsWith("/") || new File(path).isAbsolute(); - } - - /** - * Check whether a path is relative. - * Paths not starting with "/" are relative, paths starting with are absolute. - * Empty paths are relative. - * @param path Path to check - * @return <code>true</code> if <var>path</var> is relative, <code>false</code> otherwise - * @see #isAbsolute(String) which nearly is the opposite of this method - */ - public static boolean isRelative(final String path) { - return !path.startsWith("/") && !new File(path).isAbsolute(); - } - - /** - * Converts a relative path to an absolute path. - * If the path already is relative, this method simply returns the path. - * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. - * @param reference reference file the relative path works on. - * @param relative destination file with relative path - * @return absolute path from the base directory - */ - public static String relativeToAbsolute(final String reference, final String relative) { - if (reference.contains("\\") || relative.contains("\\")) { - return relativeToAbsolute(reference.replace('\\', '/'), relative.replace('\\', '/')); - } - if (isAbsolute(relative)) { - return relative; - } - String work = reference.substring(0, reference.lastIndexOf("/") + 1) + relative; // + 1 to include the "/" - String work2; - do { - work2 = work; - work = work2.replaceAll("[^/]+/\\.\\./", ""); - } while (!work2.equals(work)); - return work; - } - - /** - * Converts an absolute path to a relative path. - * If the path already is absolute, this method simply returns the path. - * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. - * @param reference reference file the relative path works on - * @param absolute destination file with relative path - * @return absolute path from the base directory - */ - public static String absoluteToRelative(final String reference, final String absolute) { - if (reference.contains("\\") || absolute.contains("\\")) { - return absoluteToRelative(reference.replace('\\', '/'), absolute.replace('\\', '/')); - } - if (isRelative(absolute)) { - return absolute; - } - //String reference2 = - // First: Strip equal path parts - final int difference = findDifference(reference, absolute); - final StringBuilder relative = new StringBuilder(absolute.substring(difference)); - final String referencePath = reference.substring(difference); - for (int i = 0, l = findOccurrences(referencePath, '/'); i < l; i++) { - relative.insert(0, "../"); - } - return relative.toString(); - } - - /** - * Helper method that returns the first string index at which two strings denoting paths aren't identical. - * That is, the index always points at the beginning or a '/'-character. - * The return value of this method is in every case good for a String.substring() invocation start index. - * @param s1 first string to compare - * @param s2 second string to compare - * @return index of first / after which s1 and s2 aren't identical or 0 if they differ from start - */ - private static int findDifference(final String s1, final String s2) { - int s1slash = -1; - int s2slash = -1; - char c1 = (char) 0; // initialize for equality for first loop cycle - char c2 = (char) 0; - for (int index = 0, l1 = s1.length(), l2 = s2.length(); index < l1 && index < l2 && c1 == c2; index++) { - c1 = s1.charAt(index); - c2 = s2.charAt(index); - if (c1 == '/') { - s1slash = index; - } - if (c2 == '/') { - s2slash = index; - } - } - return Math.min(s1slash, s2slash) + 1; - } - - /** - * Counts the occurrences of a character within a string. - * @param s String to count in - * @param c character to count - * @return number of occurences of <var>c</var> in <var>s</var> - */ - private static int findOccurrences(final String s, final char c) { - int occurrences = 0; - for (int i = 0, l = s.length(); i < l; i++) { - if (s.charAt(i) == c) { - occurrences++; - } - } - return occurrences; - } - - /** - * Create a reasonable path. - * @param str String to create path from - * @return path - */ - public static String path(final String str) { - String path = str.replaceAll("\\\\", "/"); - path = path.endsWith("/") ? path.substring(0, path.length() - 1) : path; - path = path.startsWith("file:") ? path.substring("file:".length()) : path; - path = path.replaceAll("//*", "/"); - return path; - } - -} // class PathManager Modified: trunk/crossfire/src/cfeditor/io/package.html =================================================================== --- trunk/crossfire/src/cfeditor/io/package.html 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/crossfire/src/cfeditor/io/package.html 2006-12-30 13:57:56 UTC (rev 1332) @@ -6,7 +6,7 @@ </head> <body> <p> - Reading and Writing of Crossfire maps, handling of paths. + Reading and Writing of Crossfire maps. </p> </body> </html> Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -52,7 +52,6 @@ import daieditor.gui.prefs.UpdatePrefs; import daieditor.io.CMapReader; import daieditor.io.CMapWriter; -import daieditor.io.PathManager; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; @@ -109,6 +108,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGridEvent; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -26,7 +26,6 @@ import daieditor.gameobject.GameObject; import daieditor.gui.GameObjectAttributesPanel; -import daieditor.io.PathManager; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Insets; @@ -49,6 +48,7 @@ import javax.swing.JPanel; import javax.swing.JTextField; import static javax.swing.WindowConstants.HIDE_ON_CLOSE; +import net.sf.gridarta.io.PathManager; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.Arrays2; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -27,7 +27,6 @@ import daieditor.CMainControl; import daieditor.MultiPositionData; -import daieditor.io.PathManager; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -35,6 +34,7 @@ import java.io.IOException; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -26,7 +26,6 @@ package daieditor.gameobject.anim; import daieditor.IGUIConstants; -import daieditor.io.PathManager; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -43,6 +42,7 @@ import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.Progress; import org.jetbrains.annotations.NotNull; Modified: trunk/daimonin/src/daieditor/gui/map/MapTilePane.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapTilePane.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/gui/map/MapTilePane.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -26,7 +26,6 @@ import daieditor.CMainControl; import daieditor.IGUIConstants; import daieditor.gui.DirectionLayout; -import daieditor.io.PathManager; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import java.awt.GridBagConstraints; @@ -59,6 +58,7 @@ import javax.swing.event.ChangeListener; import net.sf.gridarta.Size2D; import net.sf.gridarta.io.IOUtils; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -29,7 +29,6 @@ import static daieditor.CMainControl.PREFS_APP_SERVER; import static daieditor.CMainControl.PREFS_APP_SERVER_DEFAULT; import static daieditor.IGUIConstants.DIALOG_BORDER; -import daieditor.io.PathManager; import java.awt.Component; import java.awt.Container; import java.awt.FlowLayout; @@ -45,6 +44,7 @@ import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.JFileChooserButton; import net.sf.japi.swing.prefs.AbstractPrefs; Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -24,7 +24,6 @@ import daieditor.CMainControl; import static daieditor.IGUIConstants.DIALOG_BORDER; import daieditor.ResourceFileManager; -import daieditor.io.PathManager; import java.awt.Component; import java.awt.Container; import java.awt.FlowLayout; @@ -42,6 +41,7 @@ import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; +import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.JFileChooserButton; import net.sf.japi.swing.prefs.AbstractPrefs; Deleted: trunk/daimonin/src/daieditor/io/PathManager.java =================================================================== --- trunk/daimonin/src/daieditor/io/PathManager.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/io/PathManager.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -1,228 +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.io; - -import java.io.File; -import java.io.IOException; -import net.sf.gridarta.MainControl; - -/** - * This class contains methods for converting relative map paths to absolute map paths and vice versa. - * Serverside, paths to maps always are URIs with the maps directory being the root directory for the maps. - * Therefore it makes sense to treat them as URIs in the editor as well. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo make more use of URI - */ -public final class PathManager { - - // NOTE: There are certainly faster algorithms. But these methods are rarely used. - - /** Reference to MainControl for obtaining folder information. */ - private static MainControl mainControl; - - /** - * Private constructor. - * There are only static methods, so prevent this class from being instanciated. - */ - private PathManager() { - } - - /** - * Sets the reference to MainControl for obtaining folder information. - * @param mainControl Reference to MainControl - */ - public static void setMainControl(final MainControl mainControl) { - PathManager.mainControl = mainControl; - } - - /** - * Create arch path. - * Replaces all occurences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. - * @param path to create arch path from - * @return fixed path - */ - public static String getArchPath(final String path) { - final String archDirName = mainControl.getArchDefaultFolder(); - String archPath = path.replace('\\', '/'); - if (archPath.startsWith(archDirName)) { - archPath = archPath.substring(archDirName.length()); - } - if (archPath.startsWith(new File(archDirName).getAbsolutePath())) { - archPath = archPath.substring(new File(archDirName).getAbsolutePath().length()); - } - archPath = archPath.replace('\\', '/'); - return archPath; - } - - /** - * Create map path. - * Replaces all occurences of '\' with '/' and removes the path to the map directory (absolute, relative or canonical) from the path. - * @param path to create map path from - * @return fixed path - * @throws IOException In case of problems converting / creating the map path. - */ - public static String getMapPath(final String path) throws IOException { - final String mapDirName = mainControl.getMapDefaultFolder(); - String mapPath = path.replace('\\', '/'); - if (mapPath.startsWith(mapDirName)) { - mapPath = mapPath.substring(mapDirName.length()); - } - if (mapPath.startsWith(new File(mapDirName).getAbsolutePath())) { - mapPath = mapPath.substring(new File(mapDirName).getAbsolutePath().length()); - } - if (mapPath.startsWith(new File(mapDirName).getCanonicalPath())) { - mapPath = mapPath.substring(new File(mapDirName).getCanonicalPath().length()); - } - mapPath = mapPath.replace('\\', '/'); - return mapPath; - } - - /** - * Check whether a path is absolute. - * Paths starting with "/" are absolute, paths starting with other characters are relative. - * Empty paths are relative. - * @param path Path to check - * @return <code>true</code> if <var>path</var> is absolute, <code>false</code> otherwise - * @see #isRelative(String) which nearly is the opposite of this method - */ - public static boolean isAbsolute(final String path) { - return path.startsWith("/") || new File(path).isAbsolute(); - } - - /** - * Check whether a path is relative. - * Paths not starting with "/" are relative, paths starting with are absolute. - * Empty paths are relative. - * @param path Path to check - * @return <code>true</code> if <var>path</var> is relative, <code>false</code> otherwise - * @see #isAbsolute(String) which nearly is the opposite of this method - */ - public static boolean isRelative(final String path) { - return !path.startsWith("/") && !new File(path).isAbsolute(); - } - - /** - * Converts a relative path to an absolute path. - * If the path already is relative, this method simply returns the path. - * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. - * @param reference reference file the relative path works on. - * @param relative destination file with relative path - * @return absolute path from the base directory - */ - public static String relativeToAbsolute(final String reference, final String relative) { - if (reference.contains("\\") || relative.contains("\\")) { - return relativeToAbsolute(reference.replace('\\', '/'), relative.replace('\\', '/')); - } - if (isAbsolute(relative)) { - return relative; - } - String work = reference.substring(0, reference.lastIndexOf("/") + 1) + relative; // + 1 to include the "/" - String work2; - do { - work2 = work; - work = work2.replaceAll("[^/]+/\\.\\./", ""); - } while (!work2.equals(work)); - return work; - } - - /** - * Converts an absolute path to a relative path. - * If the path already is absolute, this method simply returns the path. - * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. - * @param reference reference file the relative path works on - * @param absolute destination file with relative path - * @return absolute path from the base directory - */ - public static String absoluteToRelative(final String reference, final String absolute) { - if (reference.contains("\\") || absolute.contains("\\")) { - return absoluteToRelative(reference.replace('\\', '/'), absolute.replace('\\', '/')); - } - if (isRelative(absolute)) { - return absolute; - } - //String reference2 = - // First: Strip equal path parts - final int difference = findDifference(reference, absolute); - final StringBuilder relative = new StringBuilder(absolute.substring(difference)); - final String referencePath = reference.substring(difference); - for (int i = 0, l = findOccurrences(referencePath, '/'); i < l; i++) { - relative.insert(0, "../"); - } - return relative.toString(); - } - - /** - * Helper method that returns the first string index at which two strings denoting paths aren't identical. - * That is, the index always points at the beginning or a '/'-character. - * The return value of this method is in every case good for a String.substring() invocation start index. - * @param s1 first string to compare - * @param s2 second string to compare - * @return index of first / after which s1 and s2 aren't identical or 0 if they differ from start - */ - private static int findDifference(final String s1, final String s2) { - int s1slash = -1; - int s2slash = -1; - char c1 = (char) 0; // initialize for equality for first loop cycle - char c2 = (char) 0; - for (int index = 0, l1 = s1.length(), l2 = s2.length(); index < l1 && index < l2 && c1 == c2; index++) { - c1 = s1.charAt(index); - c2 = s2.charAt(index); - if (c1 == '/') { - s1slash = index; - } - if (c2 == '/') { - s2slash = index; - } - } - return Math.min(s1slash, s2slash) + 1; - } - - /** - * Counts the occurrences of a character within a string. - * @param s String to count in - * @param c character to count - * @return number of occurences of <var>c</var> in <var>s</var> - */ - private static int findOccurrences(final String s, final char c) { - int occurrences = 0; - for (int i = 0, l = s.length(); i < l; i++) { - if (s.charAt(i) == c) { - occurrences++; - } - } - return occurrences; - } - - /** - * Create a reasonable path. - * @param str String to create path from - * @return path - */ - public static String path(final String str) { - String path = str.replaceAll("\\\\", "/"); - path = path.endsWith("/") ? path.substring(0, path.length() - 1) : path; - path = path.startsWith("file:") ? path.substring("file:".length()) : path; - path = path.replaceAll("//*", "/"); - return path; - } - -} // class PathManager Modified: trunk/daimonin/src/daieditor/io/package.html =================================================================== --- trunk/daimonin/src/daieditor/io/package.html 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/daieditor/io/package.html 2006-12-30 13:57:56 UTC (rev 1332) @@ -6,7 +6,7 @@ </head> <body> <p> - Reading and Writing of Daimonin maps, handling of paths. + Reading and Writing of Daimonin maps. </p> </body> </html> Modified: trunk/daimonin/src/test/daieditor/io/PathManagerTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/io/PathManagerTest.java 2006-12-30 13:49:07 UTC (rev 1331) +++ trunk/daimonin/src/test/daieditor/io/PathManagerTest.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -1,6 +1,6 @@ package test.daieditor.io; -import daieditor.io.PathManager; +import net.sf.gridarta.io.PathManager; import org.junit.Assert; import org.junit.Test; Copied: trunk/src/app/net/sf/gridarta/io/PathManager.java (from rev 1331, trunk/daimonin/src/daieditor/io/PathManager.java) =================================================================== --- trunk/src/app/net/sf/gridarta/io/PathManager.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/PathManager.java 2006-12-30 13:57:56 UTC (rev 1332) @@ -0,0 +1,228 @@ +/* + * 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 net.sf.gridarta.io; + +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.MainControl; + +/** + * This class contains methods for converting relative map paths to absolute map paths and vice versa. + * Serverside, paths to maps always are URIs with the maps directory being the root directory for the maps. + * Therefore it makes sense to treat them as URIs in the editor as well. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo make more use of URI + */ +public final class PathManager { + + // NOTE: There are certainly faster algorithms. But these methods are rarely used. + + /** Reference to MainControl for obtaining folder information. */ + private static MainControl mainControl; + + /** + * Private constructor. + * There are only static methods, so prevent this class from being instanciated. + */ + private PathManager() { + } + + /** + * Sets the reference to MainControl for obtaining folder information. + * @param mainControl Reference to MainControl + */ + public static void setMainControl(final MainControl mainControl) { + PathManager.mainControl = mainControl; + } + + /** + * Create arch path. + * Replaces all occurences of '\' with '/' and removes the path to the arch directory (absolute, relative or canonical) from the path. + * @param path to create arch path from + * @return fixed path + */ + public static String getArchPath(final String path) { + final String archDirName = mainControl.getArchDefaultFolder(); + String archPath = path.replace('\\', '/'); + if (archPath.startsWith(archDirName)) { + archPath = archPath.substring(archDirName.length()); + } + if (archPath.startsWith(new File(archDirName).getAbsolutePath())) { + archPath = archPath.substring(new File(archDirName).getAbsolutePath().length()); + } + archPath = archPath.replace('\\', '/'); + return archPath; + } + + /** + * Create map path. + * Replaces all occurences of '\' with '/' and removes the path to the map directory (absolute, relative or canonical) from the path. + * @param path to create map path from + * @return fixed path + * @throws IOException In case of problems converting / creating the map path. + */ + public static String getMapPath(final String path) throws IOException { + final String mapDirName = mainControl.getMapDefaultFolder(); + String mapPath = path.replace('\\', '/'); + if (mapPath.startsWith(mapDirName)) { + mapPath = mapPath.substring(mapDirName.length()); + } + if (mapPath.startsWith(new File(mapDirName).getAbsolutePath())) { + mapPath = mapPath.substring(new File(mapDirName).getAbsolutePath().length()); + } + if (mapPath.startsWith(new File(mapDirName).getCanonicalPath())) { + mapPath = mapPath.substring(new File(mapDirName).getCanonicalPath().length()); + } + mapPath = mapPath.replace('\\', '/'); + return mapPath; + } + + /** + * Check whether a path is absolute. + * Paths starting with "/" are absolute, paths starting with other characters are relative. + * Empty paths are relative. + * @param path Path to check + * @return <code>true</code> if <var>path</var> is absolute, <code>false</code> otherwise + * @see #isRelative(String) which nearly is the opposite of this method + */ + public static boolean isAbsolute(final String path) { + return path.startsWith("/") || new File(path).isAbsolute(); + } + + /** + * Check whether a path is relative. + * Paths not starting with "/" are relative, paths starting with are absolute. + * Empty paths are relative. + * @param path Path to check + * @return <code>true</code> if <var>path</var> is relative, <code>false</code> otherwise + * @see #isAbsolute(String) which nearly is the opposite of this method + */ + public static boolean isRelative(final String path) { + return !path.startsWith("/") && !new File(path).isAbsolute(); + } + + /** + * Converts a relative path to an absolute path. + * If the path already is relative, this method simply returns the path. + * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. + * @param reference reference file the relative path works on. + * @param relative destination file with relative path + * @return absolute path from the base directory + */ + public static String relativeToAbsolute(final String reference, final String relative) { + if (reference.contains("\\") || relative.contains("\\")) { + return relativeToAbsolute(reference.replace('\\', '/'), relative.replace('\\', '/')); + } + if (isAbsolute(relative)) { + return relative; + } + String work = reference.substring(0, reference.lastIndexOf("/") + 1) + relative; // + 1 to include the "/" + String work2; + do { + work2 = work; + work = work2.replaceAll("[^/]+/\\.\\./", ""); + } while (!work2.equals(work)); + return work; + } + + /** + * Converts an absolute path to a relative path. + * If the path already is absolute, this method simply returns the path. + * If the reference ends on "/", it is treated as being a base directory, otherwise a file that's directory is taken as base. + * @param reference reference file the relative path works on + * @param absolute destination file with relative path + * @return absolute path from the base directory + */ + public static String absoluteToRelative(final String reference, final String absolute) { + if (reference.contains("\\") || absolute.contains("\\")) { + return absoluteToRelative(reference.replace('\\', '/'), absolute.replace('\\', '/')); + } + if (isRelative(absolute)) { + return absolute; + } + //String reference2 = + // First: Strip equal path parts + final int difference = findDifference(reference, absolute); + final StringBuilder relative = new StringBuilder(absolute.substring(difference)); + final String referencePath = reference.substring(difference); + for (int i = 0, l = findOccurrences(referencePath, '/'); i < l; i++) { + relative.insert(0, "../"); + } + return relative.toString(); + } + + /** + * Helper method that returns the first string index at which two strings denoting paths aren't identical. + * That is, the index always points at the beginning or a '/'-character. + * The return value of this method is in every case good for a String.substring() invocation start index. + * @param s1 first string to compare + * @param s2 second string to compare + * @return index of first / after which s1 and s2 aren't identical or 0 if they differ from start + */ + private static int findDifference(final String s1, final String s2) { + int s1slash = -1; + int s2slash = -1; + char c1 = (char) 0; // initialize for equality for first loop cycle + char c2 = (char) 0; + for (int index = 0, l1 = s1.length(), l2 = s2.length(); index < l1 && index < l2 && c1 == c2; index++) { + c1 = s1.charAt(index); + c2 = s2.charAt(index); + if (c1 == '/') { + s1slash = index; + } + if (c2 == '/') { + s2slash = index; + } + } + return Math.min(s1slash, s2slash) + 1; + } + + /** + * Counts the occurrences of a character within a string. + * @param s String to count in + * @param c character to count + * @return number of occurences of <var>c</var> in <var>s</var> + */ + private static int findOccurrences(final String s, final char c) { + int occurrences = 0; + for (int i = 0, l = s.length(); i < l; i++) { + if (s.charAt(i) == c) { + occurrences++; + } + } + return occurrences; + } + + /** + * Create a reasonable path. + * @param str String to create path from + * @return path + */ + public static String path(final String str) { + String path = str.replaceAll("\\\\", "/"); + path = path.endsWith("/") ? path.substring(0, path.length() - 1) : path; + path = path.startsWith("file:") ? path.substring("file:".length()) : path; + path = path.replaceAll("//*", "/"); + return path; + } + +} // class PathManager Property changes on: trunk/src/app/net/sf/gridarta/io/PathManager.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 14:43:32
|
Revision: 1333 http://svn.sourceforge.net/gridarta/?rev=1333&view=rev Author: christianhujer Date: 2006-12-30 06:43:33 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Unified ObjectChoiceDisplay. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/ObjectChoiceDisplay.java trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java Modified: trunk/crossfire/src/cfeditor/gui/ObjectChoiceDisplay.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChoiceDisplay.java 2006-12-30 13:57:56 UTC (rev 1332) +++ trunk/crossfire/src/cfeditor/gui/ObjectChoiceDisplay.java 2006-12-30 14:43:33 UTC (rev 1333) @@ -93,6 +93,13 @@ } /** + * Sets the archObjNameText when the gameObject is null. + */ + private void setArchObjNameTextNull() { + archObjNameText.setText(null); + } + + /** * Show quick info for an object. * * @param gameObject the object to show; this may be any part of a multi-part @@ -100,7 +107,7 @@ */ public void showArchPanelQuickObject(@Nullable final GameObject gameObject) { if (gameObject == null) { - archObjNameText.setText(null); + setArchObjNameTextNull(); archArchNameText.setText(null); archTypeText.setText(null); archTileText.setText(null); Modified: trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java 2006-12-30 13:57:56 UTC (rev 1332) +++ trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java 2006-12-30 14:43:33 UTC (rev 1333) @@ -93,6 +93,18 @@ } /** + * Sets the archObjNameText when the gameObject is null. + */ + private void setArchObjNameTextNull() { + if (mainControl.getMainView().isPickmapActive()) { + archObjNameText.setText(" -random pick- "); + archObjNameText.setForeground(Color.BLUE); + } else { + archObjNameText.setText(null); + } + } + + /** * Show quick info for an object. * * @param gameObject the object to show; this may be any part of a multi-part @@ -100,12 +112,7 @@ */ public void showArchPanelQuickObject(@Nullable final GameObject gameObject) { if (gameObject == null) { - if (mainControl.getMainView().isPickmapActive()) { - archObjNameText.setText(" -random pick- "); - archObjNameText.setForeground(Color.BLUE); - } else { - archObjNameText.setText(null); - } + setArchObjNameTextNull(); archArchNameText.setText(null); archTypeText.setText(null); archTileText.setText(null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 15:02:12
|
Revision: 1335 http://svn.sourceforge.net/gridarta/?rev=1335&view=rev Author: christianhujer Date: 2006-12-30 07:02:11 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Introduced AbstractGameObjectAttributesDialog for unification of GameObjectAttributesDialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 14:49:37 UTC (rev 1334) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) @@ -61,7 +61,6 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; -import javax.swing.ComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -70,7 +69,6 @@ import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -93,8 +91,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.NamedObject; -import net.sf.gridarta.gameobject.NamedObjects; +import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; @@ -108,7 +105,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @fixme I suck */ -public final class GameObjectAttributesDialog extends JOptionPane implements FocusListener { +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog implements FocusListener { private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); @@ -1701,82 +1698,4 @@ } // class TypesBoxAL - /** - * KeySelectionManager to manage the select-per-keystroke in a JComboBox - * (The default KeySelectionManager fails because all strings start with - * whitespace ' '). - * <p/> - * Unfortunately, this class cannot be used anymore because it does not - * work together with the listener <code>TypesBoxAL</code> - */ - private static final class StringKeyManager implements JComboBox.KeySelectionManager { - - /** JComboBox reference. */ - private final JComboBox box; - - /** - * Create a StringKeyManager. - * @param box JComboBox to create StringKeyManager for - */ - private StringKeyManager(final JComboBox box) { - this.box = box; - } - - /** {@inheritDoc} */ - public int selectionForKey(final char aKey, final ComboBoxModel aModel) { - for (int i = 0; i < aModel.getSize(); i++) { - if (((String) aModel.getElementAt(i)).toLowerCase().charAt(1) == aKey) { - //typeListener.ignoreEvent = true; - box.setSelectedIndex(i); // should happen automatically, but doesn't - //typeListener.ignoreEvent = false; - //typeListener.listenAction = true; - return i; - } - } - return -1; // no match found - } - - } // class StringKeyManager - - /** Action for choosing a face or animation. */ - private static final class TreeChooseAction extends AbstractAction { - - /** JTextField to update upon tree selection. */ - private JTextField textField; - - /** Objects providing the tree. */ - private NamedObjects<? extends NamedObject> objects; - - /** - * Create a TreeChooseAction. - * @param text text for label / button - * @param textField JTextField to update upon tree selection - * @param objects NamedObjects that provide the tree - */ - private TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { - super(text); - this.textField = textField; - this.objects = objects; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - String initial = textField.getText(); - final NamedObject selected = objects.get(initial); - if (selected != null) { - initial = selected.getPath(); - } - final String newValue = objects.showNodeChooserDialog(textField, initial); - if (newValue != null) { - textField.setText(newValue); - } - } - - /** {@inheritDoc} */ - @Override protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } // class TreeChooseAction - } // class GameObjectAttributesDialog Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 14:49:37 UTC (rev 1334) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) @@ -60,7 +60,6 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; -import javax.swing.ComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -69,7 +68,6 @@ import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -92,8 +90,7 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.NamedObject; -import net.sf.gridarta.gameobject.NamedObjects; +import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; import net.sf.gridarta.help.Help; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; @@ -108,7 +105,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @fixme I suck */ -public final class GameObjectAttributesDialog extends JOptionPane implements FocusListener { +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog implements FocusListener { private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); @@ -1677,82 +1674,4 @@ } // class TypesBoxAL - /** - * KeySelectionManager to manage the select-per-keystroke in a JComboBox - * (The default KeySelectionManager fails because all strings start with - * whitespace ' '). - * <p/> - * Unfortunately, this class cannot be used anymore because it does not - * work together with the listener <code>TypesBoxAL</code> - */ - private static final class StringKeyManager implements JComboBox.KeySelectionManager { - - /** JComboBox reference. */ - private final JComboBox box; - - /** - * Create a StringKeyManager. - * @param box JComboBox to create StringKeyManager for - */ - private StringKeyManager(final JComboBox box) { - this.box = box; - } - - /** {@inheritDoc} */ - public int selectionForKey(final char aKey, final ComboBoxModel aModel) { - for (int i = 0; i < aModel.getSize(); i++) { - if (((String) aModel.getElementAt(i)).toLowerCase().charAt(1) == aKey) { - //typeListener.ignoreEvent = true; - box.setSelectedIndex(i); // should happen automatically, but doesn't - //typeListener.ignoreEvent = false; - //typeListener.listenAction = true; - return i; - } - } - return -1; // no match found - } - - } // class StringKeyManager - - /** Action for choosing a face or animation. */ - private static final class TreeChooseAction extends AbstractAction { - - /** JTextField to update upon tree selection. */ - private JTextField textField; - - /** Objects providing the tree. */ - private NamedObjects<? extends NamedObject> objects; - - /** - * Create a TreeChooseAction. - * @param text text for label / button - * @param textField JTextField to update upon tree selection - * @param objects NamedObjects that provide the tree - */ - private TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { - super(text); - this.textField = textField; - this.objects = objects; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - String initial = textField.getText(); - final NamedObject selected = objects.get(initial); - if (selected != null) { - initial = selected.getPath(); - } - final String newValue = objects.showNodeChooserDialog(textField, initial); - if (newValue != null) { - textField.setText(newValue); - } - } - - /** {@inheritDoc} */ - @Override protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } // class TreeChooseAction - } // class GameObjectAttributesDialog Added: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) @@ -0,0 +1,101 @@ +package net.sf.gridarta.gui; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.ComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import net.sf.gridarta.gameobject.NamedObject; +import net.sf.gridarta.gameobject.NamedObjects; +import org.apache.log4j.Logger; + +/** + * Common base class for game object attributes dialogs. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class AbstractGameObjectAttributesDialog extends JOptionPane { + + private static final Logger log = Logger.getLogger(AbstractGameObjectAttributesDialog.class); + + /** + * KeySelectionManager to manage the select-per-keystroke in a JComboBox + * (The default KeySelectionManager fails because all strings start with + * whitespace ' '). + * <p/> + * Unfortunately, this class cannot be used anymore because it does not + * work together with the listener <code>TypesBoxAL</code> + */ + protected static final class StringKeyManager implements JComboBox.KeySelectionManager { + + /** JComboBox reference. */ + private final JComboBox box; + + /** + * Create a StringKeyManager. + * @param box JComboBox to create StringKeyManager for + */ + @SuppressWarnings({"PublicConstructorInNonPublicClass"}) + public StringKeyManager(final JComboBox box) { + this.box = box; + } + + /** {@inheritDoc} */ + public int selectionForKey(final char aKey, final ComboBoxModel aModel) { + for (int i = 0; i < aModel.getSize(); i++) { + if (((String) aModel.getElementAt(i)).toLowerCase().charAt(1) == aKey) { + //typeListener.ignoreEvent = true; + box.setSelectedIndex(i); // should happen automatically, but doesn't + //typeListener.ignoreEvent = false; + //typeListener.listenAction = true; + return i; + } + } + return -1; // no match found + } + + } // class StringKeyManager + + /** Action for choosing a face or animation. */ + protected static final class TreeChooseAction extends AbstractAction { + + /** JTextField to update upon tree selection. */ + private JTextField textField; + + /** Objects providing the tree. */ + private NamedObjects<? extends NamedObject> objects; + + /** + * Create a TreeChooseAction. + * @param text text for label / button + * @param textField JTextField to update upon tree selection + * @param objects NamedObjects that provide the tree + */ + @SuppressWarnings({"PublicConstructorInNonPublicClass"}) + public TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { + super(text); + this.textField = textField; + this.objects = objects; + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + String initial = textField.getText(); + final NamedObject selected = objects.get(initial); + if (selected != null) { + initial = selected.getPath(); + } + final String newValue = objects.showNodeChooserDialog(textField, initial); + if (newValue != null) { + textField.setText(newValue); + } + } + + /** {@inheritDoc} */ + @Override protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + } // class TreeChooseAction + +} // class AbstractGameObjectAttributesDialog Property changes on: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 15:09:27
|
Revision: 1336 http://svn.sourceforge.net/gridarta/?rev=1336&view=rev Author: christianhujer Date: 2006-12-30 07:09:27 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Pulled ConfirmErrorsAL up. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:09:27 UTC (rev 1336) @@ -49,8 +49,6 @@ import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.text.NumberFormat; import java.util.ArrayList; import java.util.HashMap; @@ -1564,65 +1562,6 @@ } // class ViewTreasurelistAL - /** - * ActionListener for the buttons in the ConfirmErrors popup dialog and - * also WindowListener for the closebox of the dialog (which would equal a - * "keep all" button). - */ - private static final class ConfirmErrorsAL extends WindowAdapter implements ActionListener { - - private JDialog dialog; // the popup dialog itself - - private final JButton keepButton; // button "keep what is in the textfield" - - private final JTextArea text; // textfield containing the error-text to keep - - private final GameObject gameObject; // the according gameObject - - private final String allErrors; // list of all errors - - /** - * Constructor. - * @param dialog the popup dialog - * @param gameObject the gameObject which has the error to be added - * @param errors list of all errors (= initial content of the textarea) - * @param keepB button "keep what is in the textfield" - * @param textNew textfield containing the error-text to keep - */ - private ConfirmErrorsAL(final JDialog dialog, final GameObject gameObject, final String errors, final JButton keepB, final JTextArea textNew) { - this.gameObject = gameObject; - keepButton = keepB; - text = textNew; - this.dialog = dialog; - allErrors = errors; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - if (e.getSource() == keepButton) { - // the user pressed "keep", so we append the contents - // of the textfield to the archtext - if (text.getText() != null && text.getText().trim().length() > 0) { - gameObject.addObjectText(text.getText().trim()); - } - } - - // nuke the popup dialog - dialog.dispose(); - dialog = null; - } - - /** {@inheritDoc} */ - @Override public void windowClosing(final WindowEvent e) { - gameObject.addObjectText(allErrors.trim()); - - // nuke the popup dialog - dialog.dispose(); - dialog = null; - } - - } // class ConfirmErrorsAL - /** ItemListener for the type-selection box on the attribute-dialog. */ private final class TypesBoxAL implements ItemListener { Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2006-12-30 15:09:27 UTC (rev 1336) @@ -48,8 +48,6 @@ import java.awt.event.FocusListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.text.NumberFormat; import java.util.ArrayList; import java.util.HashMap; @@ -1542,65 +1540,6 @@ } // class ViewTreasurelistAL - /** - * ActionListener for the buttons in the ConfirmErrors popup dialog and - * also WindowListener for the closebox of the dialog (which would equal a - * "keep all" button). - */ - private static final class ConfirmErrorsAL extends WindowAdapter implements ActionListener { - - private JDialog dialog; // the popup dialog itself - - private final JButton keepButton; // button "keep what is in the textfield" - - private final JTextArea text; // textfield containing the error-text to keep - - private final GameObject gameObject; // the according gameObject - - private final String allErrors; // list of all errors - - /** - * Constructor. - * @param dialog the popup dialog - * @param gameObject the gameObject which has the error to be added - * @param errors list of all errors (= initial content of the textarea) - * @param keepB button "keep what is in the textfield" - * @param textNew textfield containing the error-text to keep - */ - private ConfirmErrorsAL(final JDialog dialog, final GameObject gameObject, final String errors, final JButton keepB, final JTextArea textNew) { - this.gameObject = gameObject; - keepButton = keepB; - text = textNew; - this.dialog = dialog; - allErrors = errors; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - if (e.getSource() == keepButton) { - // the user pressed "keep", so we append the contents - // of the textfield to the archtext - if (text.getText() != null && text.getText().trim().length() > 0) { - gameObject.addObjectText(text.getText().trim()); - } - } - - // nuke the popup dialog - dialog.dispose(); - dialog = null; - } - - /** {@inheritDoc} */ - @Override public void windowClosing(final WindowEvent e) { - gameObject.addObjectText(allErrors.trim()); - - // nuke the popup dialog - dialog.dispose(); - dialog = null; - } - - } // class ConfirmErrorsAL - /** ItemListener for the type-selection box on the attribute-dialog. */ private final class TypesBoxAL implements ItemListener { Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2006-12-30 15:02:11 UTC (rev 1335) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2006-12-30 15:09:27 UTC (rev 1336) @@ -1,11 +1,18 @@ package net.sf.gridarta.gui; import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.swing.AbstractAction; import javax.swing.ComboBoxModel; +import javax.swing.JButton; import javax.swing.JComboBox; +import javax.swing.JDialog; import javax.swing.JOptionPane; +import javax.swing.JTextArea; import javax.swing.JTextField; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.NamedObject; import net.sf.gridarta.gameobject.NamedObjects; import org.apache.log4j.Logger; @@ -19,6 +26,69 @@ private static final Logger log = Logger.getLogger(AbstractGameObjectAttributesDialog.class); /** + * ActionListener for the buttons in the ConfirmErrors popup dialog and + * also WindowListener for the closebox of the dialog (which would equal a + * "keep all" button). + */ + protected static final class ConfirmErrorsAL extends WindowAdapter implements ActionListener { + + /** The popup dialog. */ + private JDialog dialog; + + /** The button to keep what's in the textfield. */ + private final JButton keepButton; + + /** The textfield containing the error text to keep. */ + private final JTextArea text; + + /** The affected GameObject. */ + private final GameObject gameObject; + + /** List of all errors. */ + private final String allErrors; + + /** + * Constructor. + * @param dialog the popup dialog + * @param gameObject the gameObject which has the error to be added + * @param errors list of all errors (= initial content of the textarea) + * @param keepB button "keep what is in the textfield" + * @param textNew textfield containing the error-text to keep + */ + @SuppressWarnings({"PublicConstructorInNonPublicClass"}) + public ConfirmErrorsAL(final JDialog dialog, final GameObject gameObject, final String errors, final JButton keepB, final JTextArea textNew) { + this.gameObject = gameObject; + keepButton = keepB; + text = textNew; + this.dialog = dialog; + allErrors = errors; + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + if (e.getSource() == keepButton) { + // the user pressed "keep", so we append the contents + // of the textfield to the archtext + if (text.getText() != null && text.getText().trim().length() > 0) { + gameObject.addObjectText(text.getText().trim()); + } + } + + // nuke the popup dialog + dialog.dispose(); + dialog = null; + } + + /** {@inheritDoc} */ + @Override public void windowClosing(final WindowEvent e) { + gameObject.addObjectText(allErrors.trim()); + dialog.dispose(); + dialog = null; + } + + } // class ConfirmErrorsAL + + /** * KeySelectionManager to manage the select-per-keystroke in a JComboBox * (The default KeySelectionManager fails because all strings start with * whitespace ' '). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 15:19:31
|
Revision: 1337 http://svn.sourceforge.net/gridarta/?rev=1337&view=rev Author: christianhujer Date: 2006-12-30 07:19:31 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Extracted FileField class from ResPrefs. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/FileField.java Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2006-12-30 15:09:27 UTC (rev 1336) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2006-12-30 15:19:31 UTC (rev 1337) @@ -28,7 +28,6 @@ import cfeditor.ResourceFileManager; import java.awt.Component; import java.awt.Container; -import java.awt.FlowLayout; import static java.util.Arrays.sort; import javax.swing.Box; import static javax.swing.Box.createHorizontalBox; @@ -36,17 +35,15 @@ import static javax.swing.Box.createVerticalGlue; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JComponent; import static javax.swing.JFileChooser.DIRECTORIES_ONLY; import javax.swing.JLabel; import static javax.swing.JOptionPane.WARNING_MESSAGE; -import javax.swing.JTextField; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; +import net.sf.gridarta.gui.FileField; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.JFileChooserButton; import net.sf.japi.swing.prefs.AbstractPrefs; /** @@ -252,60 +249,4 @@ return imageSet.equals("none") ? "disabled" : imageSet; } - /** Class for selecting a file. - * @todo replace with JFileField from JAPI - */ - private static class FileField extends JComponent { - - /** The label. */ - private final JLabel label; - - /** The file field. */ - private final JTextField fileField; - - /** The button to start the JFileChooser. */ - private final JFileChooserButton chooserButton; - - /** - * Create a FileField. - * @param labelText the text for the label - * @param initial the initial path - * @param fileSelectionMode the mode for the file selection - */ - private FileField(final String labelText, final String initial, final int fileSelectionMode) { - setLayout(new FlowLayout(FlowLayout.RIGHT)); - fileField = new JTextField(initial, 16); - chooserButton = new JFileChooserButton(fileField, fileSelectionMode); - label = new JLabel(labelText); - add(label); - add(fileField); - add(chooserButton); - } - - /** {@inheritDoc} */ - @Override public void setEnabled(final boolean enabled) { - super.setEnabled(enabled); - fileField.setEnabled(enabled); - chooserButton.setEnabled(enabled); - label.setEnabled(enabled); - } - - /** - * Set the text, which is the filename. - * @param text filename - */ - public void setText(final String text) { - fileField.setText(text); - } - - /** - * Get the text, which is the filename. - * @return text (filename) - */ - public String getText() { - return fileField.getText(); - } - - } // class FileField - } // class ResPrefs Modified: trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2006-12-30 15:09:27 UTC (rev 1336) +++ trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java 2006-12-30 15:19:31 UTC (rev 1337) @@ -26,24 +26,20 @@ import daieditor.ResourceFileManager; import java.awt.Component; import java.awt.Container; -import java.awt.FlowLayout; import java.util.prefs.Preferences; import static java.util.prefs.Preferences.userNodeForPackage; import javax.swing.Box; import static javax.swing.Box.createVerticalBox; import static javax.swing.Box.createVerticalGlue; import javax.swing.JCheckBox; -import javax.swing.JComponent; import static javax.swing.JFileChooser.DIRECTORIES_ONLY; -import javax.swing.JLabel; import static javax.swing.JOptionPane.WARNING_MESSAGE; -import javax.swing.JTextField; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; +import net.sf.gridarta.gui.FileField; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.JFileChooserButton; import net.sf.japi.swing.prefs.AbstractPrefs; /** @@ -204,60 +200,4 @@ return fileField; } - /** Class for selecting a file. - * @todo replace with JFileField from JAPI - */ - private static class FileField extends JComponent { - - /** The label. */ - private final JLabel label; - - /** The file field. */ - private final JTextField fileField; - - /** The button to start the JFileChooser. */ - private final JFileChooserButton chooserButton; - - /** - * Create a FileField. - * @param labelText the text for the label - * @param initial the initial path - * @param fileSelectionMode the mode for the file selection - */ - private FileField(final String labelText, final String initial, final int fileSelectionMode) { - setLayout(new FlowLayout(FlowLayout.RIGHT)); - fileField = new JTextField(initial, 16); - chooserButton = new JFileChooserButton(fileField, fileSelectionMode); - label = new JLabel(labelText); - add(label); - add(fileField); - add(chooserButton); - } - - /** {@inheritDoc} */ - @Override public void setEnabled(final boolean enabled) { - super.setEnabled(enabled); - fileField.setEnabled(enabled); - chooserButton.setEnabled(enabled); - label.setEnabled(enabled); - } - - /** - * Set the text, which is the filename. - * @param text filename - */ - public void setText(final String text) { - fileField.setText(text); - } - - /** - * Get the text, which is the filename. - * @return text (filename) - */ - public String getText() { - return fileField.getText(); - } - - } // class FileField - } // class ResPrefs Added: trunk/src/app/net/sf/gridarta/gui/FileField.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/FileField.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/FileField.java 2006-12-30 15:19:31 UTC (rev 1337) @@ -0,0 +1,65 @@ +package net.sf.gridarta.gui; + +import java.awt.FlowLayout; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTextField; +import net.sf.japi.swing.JFileChooserButton; + +/** + * Class for selecting a file. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo replace with JFileField from JAPI. + */ +public class FileField extends JComponent { + + /** The label. */ + private final JLabel label; + + /** The file field. */ + private final JTextField fileField; + + /** The button to start the JFileChooser. */ + private final JFileChooserButton chooserButton; + + /** + * Create a FileField. + * @param labelText the text for the label + * @param initial the initial path + * @param fileSelectionMode the mode for the file selection + */ + public FileField(final String labelText, final String initial, final int fileSelectionMode) { + setLayout(new FlowLayout(FlowLayout.RIGHT)); + fileField = new JTextField(initial, 16); + chooserButton = new JFileChooserButton(fileField, fileSelectionMode); + label = new JLabel(labelText); + add(label); + add(fileField); + add(chooserButton); + } + + /** {@inheritDoc} */ + @Override public void setEnabled(final boolean enabled) { + super.setEnabled(enabled); + fileField.setEnabled(enabled); + chooserButton.setEnabled(enabled); + label.setEnabled(enabled); + } + + /** + * Set the text, which is the filename. + * @param text filename + */ + public void setText(final String text) { + fileField.setText(text); + } + + /** + * Get the text, which is the filename. + * @return text (filename) + */ + public String getText() { + return fileField.getText(); + } + +} // class FileField Property changes on: trunk/src/app/net/sf/gridarta/gui/FileField.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 15:39:39
|
Revision: 1338 http://svn.sourceforge.net/gridarta/?rev=1338&view=rev Author: christianhujer Date: 2006-12-30 07:39:40 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Unified Spells. Modified Paths: -------------- trunk/crossfire/src/cfeditor/Spells.java trunk/daimonin/src/daieditor/Spells.java Modified: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java 2006-12-30 15:19:31 UTC (rev 1337) +++ trunk/crossfire/src/cfeditor/Spells.java 2006-12-30 15:39:40 UTC (rev 1338) @@ -31,6 +31,7 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; @@ -75,7 +76,9 @@ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(false); fileChooser.setFileFilter(SPELLIST_H_FILE_FILTER); // apply file filter - fileChooser.setCurrentDirectory(new File(System.getProperty("user.dir"))); + final File cd = new File(System.getProperty("user.dir")); + final File sd = new File(cd, "../server/src/include"); + fileChooser.setCurrentDirectory(sd.exists() ? sd : cd); final int returnVal = fileChooser.showOpenDialog(mainControl.getMainView()); @@ -94,7 +97,7 @@ } /** - * Read all spells from a CF spellist file and write an + * Read all spells from a Crossfire spellist file and write an * alphabetical list into "spells.def". * @param spellfile spellfile to read * @return number of successfully collected spells @@ -171,7 +174,6 @@ new File("resource").mkdir(); new File(IGUIConstants.CONFIG_DIR).mkdir(); } - dfile = new File(IGUIConstants.CONFIG_DIR, IGUIConstants.SPELL_FILE); } else { dfile = new File(IGUIConstants.SPELL_FILE); @@ -182,27 +184,23 @@ try { // header: out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); + //out.println("<!DOCTYPE spells SYSTEM \"spells.dtd\">"); + out.println("<!--"); + out.println(" - ##########################################################"); + out.println(" - # You may add new spells to this file, but there's no #"); + out.println(" - # need to do it because the file can be autogenerated. #"); + out.println(" - # In the editor, select menu \"Resources->Collect Spells\" #"); + out.println(" - # to generate a new version of this file. #"); + out.println(" - ##########################################################"); + out.println(" -->"); + out.println("<!-- Generated on: " + new Date() + " -->"); out.println("<spells>"); - out.println("<!--"); - out.println(" ##########################################################"); - out.println(" # You may add new spells to this file, but there's no #"); - out.println(" # need to do it because the file can be autogenerated. #"); - out.println(" # In the editor, select menu \"Resources->Collect Spells\" #"); - out.println(" # to generate a new version of this file. #"); - out.println(" ##########################################################\n-->"); - // write spell-entries: + final String[] spaces = {" ", " ", ""}; for (final String entry : list) { - tmp = String.valueOf(entry); - final String id = tmp.substring(0, tmp.indexOf(" ")).trim(); - final String name = tmp.substring(tmp.indexOf(" ") + 1).trim(); - String space = ""; - if (id.length() == 1) { - space = " "; - } else if (id.length() == 2) { - space = " "; - } - out.println(" <spell id=\"" + id + "\"" + space + " name=\"" + name + "\" />"); + final String id = entry.substring(0, entry.indexOf(" ")).trim(); + final String name = entry.substring(entry.indexOf(" ") + 1).trim(); + out.println(" <spell id=\"" + id + '\"' + spaces[id.length() - 1] + " name=\"" + name + "\" />"); } out.println("</spells>"); } finally { @@ -213,11 +211,18 @@ log.error("Cannot write file '" + dfile.getAbsolutePath() + "'!"); } } - return 0; } /** + * Returns the base directory to read the spells from. + * @return base directory to read the spells from. + */ + public String getSpellsBaseDir() { + return IGUIConstants.CONFIG_DIR; + } + + /** * Read the spells from "spells.xml" into the arrays 'spellNames' * and 'spellNumbers'. This method is called at startup. * @param documentBuilder Document Builder to use for parsing @@ -228,7 +233,7 @@ try { // open reading stream to the spells xml file - final String baseDir = IGUIConstants.CONFIG_DIR; + final String baseDir = getSpellsBaseDir(); // parse xml document final Document doc = documentBuilder.parse(new File(baseDir, IGUIConstants.SPELL_FILE)); Modified: trunk/daimonin/src/daieditor/Spells.java =================================================================== --- trunk/daimonin/src/daieditor/Spells.java 2006-12-30 15:19:31 UTC (rev 1337) +++ trunk/daimonin/src/daieditor/Spells.java 2006-12-30 15:39:40 UTC (rev 1338) @@ -32,10 +32,9 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.TreeSet; +import java.util.TreeMap; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import javax.xml.parsers.DocumentBuilder; @@ -100,13 +99,13 @@ } /** - * Read all spells from a CF spellist file and write an + * Read all spells from a Daimonin spellist file and write an * alphabetical list into "spells.def". * @param spellfile spellfile to read * @return number of successfully collected spells */ private static int importSpells(final File spellfile) { - final Map<String, String> spells = new HashMap<String, String>(); + final Map<String, String> spells = new TreeMap<String, String>(); if ("spellist.h".equalsIgnoreCase(spellfile.getName())) { try { final BufferedReader in = new BufferedReader(new FileReader(spellfile.getAbsolutePath())); @@ -173,7 +172,7 @@ out.println("<spells>"); final String[] spaces = {" ", " ", ""}; - for (final String name : new TreeSet<String>(spells.keySet())) { + for (final String name : spells.keySet()) { final String id = spells.get(name); out.println(" <spell id=\"" + id + '\"' + spaces[id.length() - 1] + " name=\"" + name + "\" />"); } @@ -189,6 +188,14 @@ } /** + * Returns the base directory to read the spells from. + * @return base directory to read the spells from. + */ + public String getSpellsBaseDir() { + return CMainControl.getInstance().getArchDefaultFolder() + "/" + IGUIConstants.CONFIG_DIR; + } + + /** * Read the spells from "spells.xml" into the arrays 'spellNames' * and 'spellNumbers'. This method is called at startup. * @param documentBuilder Document Builder to use for parsing @@ -199,7 +206,7 @@ try { // open reading stream to the spells xml file - final String baseDir = CMainControl.getInstance().getArchDefaultFolder() + "/" + IGUIConstants.CONFIG_DIR; + final String baseDir = getSpellsBaseDir(); // parse xml document final Document doc = documentBuilder.parse(new File(baseDir, IGUIConstants.SPELL_FILE)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-30 17:50:10
|
Revision: 1341 http://svn.sourceforge.net/gridarta/?rev=1341&view=rev Author: christianhujer Date: 2006-12-30 09:50:07 -0800 (Sat, 30 Dec 2006) Log Message: ----------- Changed importSpellsWanted() to be an instance method for later refactoring. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/Spells.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/Spells.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 17:42:42 UTC (rev 1340) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-30 17:50:07 UTC (rev 1341) @@ -122,6 +122,9 @@ /** The Face Objects. */ private FaceObjects faceObjects; + /** The Spells. */ + private final Spells spells = new Spells(); + // icons for the map and arch pictures. private static ImageIcon mapSelIcon; @@ -303,7 +306,7 @@ /** Collect Spells. */ @ActionMethod public void collectSpells() { - Spells.importSpellsWanted(this); + spells.importSpellsWanted(this); } /** View Treasure Lists. */ Modified: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java 2006-12-30 17:42:42 UTC (rev 1340) +++ trunk/crossfire/src/cfeditor/Spells.java 2006-12-30 17:50:07 UTC (rev 1341) @@ -69,7 +69,7 @@ * then import spells. * @param mainControl main control */ - public static void importSpellsWanted(final CMainControl mainControl) { + public void importSpellsWanted(final CMainControl mainControl) { // open a file chooser window final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open CF Spellist File"); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 17:42:42 UTC (rev 1340) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-30 17:50:07 UTC (rev 1341) @@ -205,6 +205,9 @@ /** The Face Objects. */ private FaceObjects faceObjects; + /** The Spells. */ + private final Spells spells = new Spells(); + // icons for the map and arch pictures. private static ImageIcon mapSelIcon; @@ -532,7 +535,7 @@ /** Collect Spells. */ @ActionMethod public void collectSpells() { - Spells.importSpellsWanted(this); + spells.importSpellsWanted(this); } /** View Treasure Lists. */ Modified: trunk/daimonin/src/daieditor/Spells.java =================================================================== --- trunk/daimonin/src/daieditor/Spells.java 2006-12-30 17:42:42 UTC (rev 1340) +++ trunk/daimonin/src/daieditor/Spells.java 2006-12-30 17:50:07 UTC (rev 1341) @@ -71,7 +71,7 @@ * then import spells. * @param mainControl main control */ - public static void importSpellsWanted(final CMainControl mainControl) { + public void importSpellsWanted(final CMainControl mainControl) { // open a file chooser window final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open CF Spellist File"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |