From: <chr...@us...> - 2007-01-02 09:22:02
|
Revision: 1377 http://svn.sourceforge.net/gridarta/?rev=1377&view=rev Author: christianhujer Date: 2007-01-02 01:22:02 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Removing auto-generated merge diagram, updated merge diagram generation. Modified Paths: -------------- trunk/mergeProgressHistory.sh trunk/src/mergeMetrics.gpl Removed Paths: ------------- trunk/src/doc/dev/mergeDiagram.png Modified: trunk/mergeProgressHistory.sh =================================================================== --- trunk/mergeProgressHistory.sh 2007-01-02 09:08:18 UTC (rev 1376) +++ trunk/mergeProgressHistory.sh 2007-01-02 09:22:02 UTC (rev 1377) @@ -1,11 +1,14 @@ #!/bin/sh #echo "Revision;Date;Merged Code (excluding textedit);Merged Code (including textedit);Crossfire Code;Daimonin Code;Crossfire diff to Daimonin;Daimonin diff to Crossfire" >>mergeStatistics.csv +date rm mergeStatistics.dat -rsync -av gridarta.svn.sourceforge.net::svn/gridarta/ repoBackup/ +rsync -qav gridarta.svn.sourceforge.net::svn/gridarta/ repoBackup/ rm -rf mergeMetrics svn co -q file://$(pwd)/repoBackup/trunk/ mergeMetrics cd mergeMetrics || exit 1 +svn -q up recent=$(env -i svn info | grep Revision | cut -d ' ' -f 2) +echo recent $recent for ((i = 1; i <= recent; i++)) do svn up -q -r $i @@ -34,8 +37,13 @@ echo -n $(<differences grep '^<' | wc -l) echo -n ' ' echo -n $(<differences grep '^>' | wc -l) + echo -n ' ' + echo -n $(cat common_src crossfire_src daimonin_src | xargs cat | wc -l) + echo -n ' ' + echo -n $(grep -v textedit common_src crossfire_src daimonin_src | xargs cat | wc -l) echo ) >>../mergeStatistics.dat 2>/dev/null done cd .. gnuplot <src/mergeMetrics.gpl >src/doc/dev/mergeDiagram.png +date Deleted: trunk/src/doc/dev/mergeDiagram.png =================================================================== (Binary files differ) Modified: trunk/src/mergeMetrics.gpl =================================================================== --- trunk/src/mergeMetrics.gpl 2007-01-02 09:08:18 UTC (rev 1376) +++ trunk/src/mergeMetrics.gpl 2007-01-02 09:22:02 UTC (rev 1377) @@ -1,4 +1,4 @@ -set terminal png size 768,432 +set terminal png size 1024,640 #set terminal svg size 1200 600 dynamic set grid set nologscale x @@ -6,6 +6,7 @@ set xlabel 'revision' set ylabel 'sloc' set title 'Gridarta Merge Statistics' +set key below plot 'mergeStatistics.dat' using 1:2 title "Merged Code (excluding textedit)" with lines, \ 'mergeStatistics.dat' using 1:3 title "Merged Code (including textedit)" with lines, \ 'mergeStatistics.dat' using 1:4 title "Crossfire Code (excluding textedit)" with lines, \ @@ -13,4 +14,6 @@ 'mergeStatistics.dat' using 1:6 title "Daimonin Code (excluding textedit)" with lines, \ 'mergeStatistics.dat' using 1:7 title "Daimonin Code (including textedit)" with lines, \ 'mergeStatistics.dat' using 1:8 title "Crossfire diff to Daimonin" with lines, \ - 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines + 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 1:10 title "Complete Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:11 title "Complete Code (including textedit)" with lines This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 09:36:16
|
Revision: 1378 http://svn.sourceforge.net/gridarta/?rev=1378&view=rev Author: christianhujer Date: 2007-01-02 01:36:14 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Fixed NPE during startup. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 09:22:02 UTC (rev 1377) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 09:36:14 UTC (rev 1378) @@ -205,12 +205,12 @@ /** Constructs the main controller and its model and view. */ public CMainControl() { + PathManager.setMainControl(this); instance = this; archetypeSet = new ArchetypeSet(this); scriptControl = new CScriptController(this); mapCursorControl = new MapCursorControl(this); mainView = new CMainView(); - PathManager.setMainControl(this); } /** Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 09:22:02 UTC (rev 1377) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 09:36:14 UTC (rev 1378) @@ -312,6 +312,7 @@ /** Constructs the main controller and its model and view. */ public CMainControl() { + PathManager.setMainControl(this); instance = this; archetypeSet = new ArchetypeSet(this); mapCursorControl = new MapCursorControl(this); @@ -321,7 +322,6 @@ refreshMenusAndToolbars(); archetypeSet.loadArchetypes(); validators = createMapValidators(); - PathManager.setMainControl(this); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 09:46:53
|
Revision: 1380 http://svn.sourceforge.net/gridarta/?rev=1380&view=rev Author: christianhujer Date: 2007-01-02 01:46:50 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Pulled setTypeList up in GameObject. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 09:37:02 UTC (rev 1379) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 09:46:50 UTC (rev 1380) @@ -261,7 +261,7 @@ // load the list with archtype-data from "types.txt" typeList = new CFArchTypeList(); - GameObject.setTypeList(typeList); // set reference in GameObject + net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject mainView.updateFocus(false); } Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-02 09:37:02 UTC (rev 1379) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-02 09:46:50 UTC (rev 1380) @@ -25,7 +25,6 @@ package cfeditor.gameobject; import cfeditor.AutojoinList; -import cfeditor.CFArchTypeList; import cfeditor.IGUIConstants; import cfeditor.ScriptArchData; import cfeditor.gui.GameObjectAttributesPanel; @@ -51,9 +50,6 @@ /** Logger. */ private static final Logger log = Logger.getLogger(GameObject.class); - /** Static reference to the typeList (find syntax errors). */ - private static CFArchTypeList typeList; - private String faceName; // face name : 1 private StringBuffer animText; // anim text buffer @@ -117,11 +113,9 @@ archType = TYPE_UNSET; // type must be set } - public static void setTypeList(final CFArchTypeList tlist) { - typeList = tlist; - } - - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public int calculateEditType(final int checkType) { // ATTENTION! BE VERY CAREFUL WHEN YOU TRY TO UNIFY MORE OF THIS WITH DAIMONIN! /* if one of the types in checkType already is in editType, Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 09:37:02 UTC (rev 1379) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 09:46:50 UTC (rev 1380) @@ -437,7 +437,7 @@ // load the list with archtype-data from "types.txt" typeList = new CFArchTypeList(); - GameObject.setTypeList(typeList); // set reference in GameObject + net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject mainView.updateFocus(false); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 09:37:02 UTC (rev 1379) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 09:46:50 UTC (rev 1380) @@ -25,7 +25,6 @@ package daieditor.gameobject; -import daieditor.CFArchTypeList; import daieditor.CMainControl; import daieditor.IGUIConstants; import daieditor.ScriptArchData; @@ -63,9 +62,6 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - /** Static reference to the typeList (find syntax errors). */ - private static CFArchTypeList typeList; - /** Face name, can be from animation or face. */ private String faceObjName; @@ -137,10 +133,6 @@ script = new ScriptArchData(this); } - public static void setTypeList(final CFArchTypeList tlist) { - typeList = tlist; - } - /** * {@inheritDoc} * @deprecated use arch object matchers, this method will be removed Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-02 09:37:02 UTC (rev 1379) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-02 09:46:50 UTC (rev 1380) @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.Map; +import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,6 +18,9 @@ /** Special constant that's used if a GameObject has no GameObject type set. */ public static final int TYPE_UNSET = -666; + /** Static reference to the typeList (find syntax errors). */ + protected static CFArchTypeList typeList; + /** * If this flag is set, this Archetype is not a "real" Archetype but comes from the artifacts file. * Such Archetypes instances are not included in the Archetype collection process, since the artifacts file is the same for editor and server. @@ -97,6 +101,14 @@ } /** + * Sets the CFArchTypeList that should be used for finding syntax errors. + * @param typeList CFArchTypeList to use + */ + public static void setTypeList(final CFArchTypeList typeList) { + GameObject.typeList = typeList; + } + + /** * Count the number of all inventory items (recursively). * The returned value does not include this GameObject. * @return number of objects in the inventory (recursively) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 10:00:21
|
Revision: 1381 http://svn.sourceforge.net/gridarta/?rev=1381&view=rev Author: christianhujer Date: 2007-01-02 02:00:22 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Pulled up insertBefore and insertAfter. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-02 09:46:50 UTC (rev 1380) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-02 10:00:22 UTC (rev 1381) @@ -284,22 +284,6 @@ } /** - * Insert a GameObject before this GameObject. - * @param node GameObject to append - */ - public void insertBefore(final GameObject node) { - getContainer().insertBefore(node, this); - } - - /** - * Insert a GameObject after this GameObject. - * @param node GameObject to append - */ - public void insertAfter(final GameObject node) { - getContainer().insertAfter(this, node); - } - - /** * Determine the horizontal extent in tiles. For single-part objects 1 is * returned. * @@ -394,6 +378,8 @@ * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) * is often used as way to find multi-heads. * @return number of parts + * @todo rename me, "Ref" is a term in Java short for "Reference" and this + * is not about "References" but about multi-tile arches. */ @Override public int getMultiRefCount() { return multi != null ? multi.getMultiRefCount() : 0; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 09:46:50 UTC (rev 1380) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 10:00:22 UTC (rev 1381) @@ -207,22 +207,6 @@ } /** - * Insert a GameObject before this GameObject. - * @param node GameObject to append - */ - public void insertBefore(final GameObject node) { - getContainer().insertBefore(node, this); - } - - /** - * Insert a GameObject after this GameObject. - * @param node GameObject to append - */ - public void insertAfter(final GameObject node) { - getContainer().insertAfter(this, node); - } - - /** * Determine the horizontal extent in tiles. For single-part objects 1 is * returned. * Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-02 09:46:50 UTC (rev 1380) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-02 10:00:22 UTC (rev 1381) @@ -451,6 +451,22 @@ head.container.remove(head); } + /** + * Insert a GameObject before this GameObject. + * @param node GameObject to append + */ + public void insertBefore(final G node) { + getContainer().insertBefore(node, (G) this); + } + + /** + * Insert a GameObject after this GameObject. + * @param node GameObject to append + */ + public void insertAfter(final G node) { + getContainer().insertAfter((G) this, node); + } + /** {@inheritDoc} */ public abstract int getArchTypNr(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 10:31:34
|
Revision: 1382 http://svn.sourceforge.net/gridarta/?rev=1382&view=rev Author: christianhujer Date: 2007-01-02 02:31:34 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Pulled multi related code up. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-02 10:00:22 UTC (rev 1381) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-02 10:31:34 UTC (rev 1382) @@ -35,7 +35,6 @@ import java.util.List; import javax.swing.JList; import net.sf.gridarta.CFArchType; -import net.sf.gridarta.gameobject.MultiArchData; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,12 +58,6 @@ private int archTextCount; // lines inserted in ArchText /** - * Data for multitile-arches. - * Stays null for singlesquare-arches. - */ - @Nullable private MultiArchData<GameObject> multi = null; - - /** * Data for scripted events. * Stays null if no events defined. */ @@ -283,117 +276,6 @@ } } - /** - * Determine the horizontal extent in tiles. For single-part objects 1 is - * returned. - * - * @return the horizontal extent - */ - public int getSizeX() { - return multi != null ? multi.getSizeX() : 1; - } - - /** - * Determine the vertical extent in tiles. For single-part objects 1 is - * returned. - * - * @return the vertical extent - */ - public int getSizeY() { - return multi != null ? multi.getSizeY() : 1; - } - - /** - * Determine the maximum x-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the maximum x-coordinate - */ - public int getMaxX() { - return multi != null ? multi.getMaxX() : 0; - } - - /** - * Determine the maximum y-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the maximum y-coordinate - */ - public int getMaxY() { - return multi != null ? multi.getMaxY() : 0; - } - - /** - * Determine the minimum x-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the minimum x-coordinate - */ - public int getMinX() { - return multi != null ? multi.getMinX() : 0; - } - - /** - * Determine the minimum y-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the minimum y-coordinate - */ - public int getMinY() { - return multi != null ? multi.getMinY() : 0; - } - - @Override public void addTailPart(final GameObject tail) { - initMultiData(); - tail.multi = multi; - multi.addPart(tail); - } - - /** - * Return the head part of a multi-part object. For single-part objects it - * is the object itself. - * - * @return the head of the object - */ - @Override public GameObject getHead() { - return multi != null ? multi.getHead() : this; - } - - /** - * Determine if this part is a tail part. For single-part objects this is - * never true. - * - * @return <code>true</code> iff this part if a tail part - */ - public boolean isTail() { - return getHead() != this; - } - - /** {@inheritDoc} */ - @Override @Nullable public GameObject getMultiNext() { - return multi != null ? multi.getNext(this) : null; - } - - /** - * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) - * is often used as way to find multi-heads. - * @return number of parts - * @todo rename me, "Ref" is a term in Java short for "Reference" and this - * is not about "References" but about multi-tile arches. - */ - @Override public int getMultiRefCount() { - return multi != null ? multi.getMultiRefCount() : 0; - } - - /** - * Initialize the multipart data object - must only be called for multipart - * arches. - */ - private void initMultiData() { - if (multi == null) { - multi = new MultiArchData<GameObject>(this); - } - } // ----- end multi-arch get/set ----- @Override public int getArchTypNr() { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 10:00:22 UTC (rev 1381) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 10:31:34 UTC (rev 1382) @@ -36,7 +36,6 @@ import javax.swing.JList; import net.sf.gridarta.CFArchType; import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.gameobject.MultiArchData; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -71,12 +70,6 @@ /** Object animation <code>animation <var>animName</var></code>. */ private String animName; - /** - * Data for multitile-arches. - * Stays null for singlesquare-arches. - */ - @Nullable private MultiArchData<GameObject> multi = null; - private int multiPartNr = 0; /** @@ -206,98 +199,6 @@ return editType; } - /** - * Determine the horizontal extent in tiles. For single-part objects 1 is - * returned. - * - * @return the horizontal extent - */ - public int getSizeX() { - return multi != null ? multi.getSizeX() : 1; - } - - /** - * Determine the vertical extent in tiles. For single-part objects 1 is - * returned. - * - * @return the vertical extent - */ - public int getSizeY() { - return multi != null ? multi.getSizeY() : 1; - } - - /** - * Determine the maximum x-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the maximum x-coordinate - */ - public int getMaxX() { - return multi != null ? multi.getMaxX() : 0; - } - - /** - * Determine the maximum y-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the maximum y-coordinate - */ - public int getMaxY() { - return multi != null ? multi.getMaxY() : 0; - } - - /** - * Determine the minimum x-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the minimum x-coordinate - */ - public int getMinX() { - return multi != null ? multi.getMinX() : 0; - } - - /** - * Determine the minimum y-coordinate of any part relative to the head - * part. For single-part objects 0 is returned. - * - * @return the minimum y-coordinate - */ - public int getMinY() { - return multi != null ? multi.getMinY() : 0; - } - - @Override public void addTailPart(final GameObject tail) { - initMultiData(); - tail.multi = multi; - multi.addPart(tail); - } - - /** - * Return the head part of a multi-part object. For single-part objects it - * is the object itself. - * - * @return the head of the object - */ - @Override public GameObject getHead() { - return multi != null ? multi.getHead() : this; - } - - /** - * Determine if this part is a tail part. For single-part objects this is - * never true. - * - * @return <code>true</code> iff this part if a tail part - */ - @SuppressWarnings({"ObjectEquality"}) - public boolean isTail() { - return getHead() != this; - } - - /** {@inheritDoc} */ - @Override @Nullable public GameObject getMultiNext() { - return multi != null ? multi.getNext(this) : null; - } - public int getMultiShapeID() { return multi != null ? multi.getMultiShapeID() : 0; } @@ -323,26 +224,6 @@ this.isLowestPart = isLowestPart; } - /** - * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) - * is often used as way to find multi-heads. - * @return number of parts - * @todo rename me, "Ref" is a term in Java short for "Reference" and this - * is not about "References" but about multi-tile arches. - */ - @Override public int getMultiRefCount() { - return multi != null ? multi.getMultiRefCount() : 0; - } - - /** - * Initialize the multipart data object - must only be called for multipart - * arches. - */ - private void initMultiData() { - if (multi == null) { - multi = new MultiArchData<GameObject>(this); - } - } // ----- end multi-arch get/set ----- @Override public int getArchTypNr() { Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-02 10:00:22 UTC (rev 1381) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-02 10:31:34 UTC (rev 1382) @@ -87,6 +87,12 @@ protected int multiY = 0; /** + * Data for multitile-arches. + * Stays null for singlesquare-arches. + */ + @Nullable protected MultiArchData<G> multi = null; + + /** * Edit Type. * @deprecated bad design for multiple reasons: * * Data is knowing view information (that's not nice) @@ -704,10 +710,40 @@ public abstract G createArch(); /** - * Appens a tail to this GameObject. + * Returns whether this object is a single-part object or the head of the multi-part object. + * @return <code>true</code> if single-part or head of multi-part, otherwise <code>false</code>. + */ + public boolean isHead() { + // == is okay because that's the definition of being head. + //noinspection ObjectEquality + return getHead() == this; + } + + /** {@inheritDoc} */ + @Nullable public G getMultiNext() { + return multi != null ? multi.getNext((G) this) : null; + } + + /** + * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) + * is often used as way to find multi-heads. + * @return number of parts + * @todo rename me, "Ref" is a term in Java short for "Reference" and this + * is not about "References" but about multi-tile arches. + */ + public int getMultiRefCount() { + return multi != null ? multi.getMultiRefCount() : 0; + } + + /** + * Appends a tail to this GameObject. * @param tail Tail to append. */ - public abstract void addTailPart(final G tail); + public void addTailPart(final G tail) { + initMultiData(); + tail.multi = multi; + multi.addPart(tail); + } /** * Return the head part of a multi-part object. For single-part objects it @@ -715,29 +751,91 @@ * * @return the head of the object */ - public abstract G getHead(); + public G getHead() { + return multi != null ? multi.getHead() : (G) this; + } /** - * Returns whether this object is a single-part object or the head of the multi-part object. - * @return <code>true</code> if single-part or head of multi-part, otherwise <code>false</code>. + * Determine if this part is a tail part. For single-part objects this is + * never true. + * + * @return <code>true</code> iff this part if a tail part */ - public boolean isHead() { - // == is okay because that's the definition of being head. - //noinspection ObjectEquality - return getHead() == this; + public boolean isTail() { + return getHead() != this; } - /** {@inheritDoc} */ - @Nullable public abstract G getMultiNext(); + /** + * Determine the horizontal extent in tiles. For single-part objects 1 is + * returned. + * + * @return the horizontal extent + */ + public int getSizeX() { + return multi != null ? multi.getSizeX() : 1; + } /** - * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) - * is often used as way to find multi-heads. - * @return number of parts + * Determine the vertical extent in tiles. For single-part objects 1 is + * returned. + * + * @return the vertical extent */ - public abstract int getMultiRefCount(); + public int getSizeY() { + return multi != null ? multi.getSizeY() : 1; + } /** + * Determine the maximum x-coordinate of any part relative to the head + * part. For single-part objects 0 is returned. + * + * @return the maximum x-coordinate + */ + public int getMaxX() { + return multi != null ? multi.getMaxX() : 0; + } + + /** + * Determine the maximum y-coordinate of any part relative to the head + * part. For single-part objects 0 is returned. + * + * @return the maximum y-coordinate + */ + public int getMaxY() { + return multi != null ? multi.getMaxY() : 0; + } + + /** + * Determine the minimum x-coordinate of any part relative to the head + * part. For single-part objects 0 is returned. + * + * @return the minimum x-coordinate + */ + public int getMinX() { + return multi != null ? multi.getMinX() : 0; + } + + /** + * Determine the minimum y-coordinate of any part relative to the head + * part. For single-part objects 0 is returned. + * + * @return the minimum y-coordinate + */ + public int getMinY() { + return multi != null ? multi.getMinY() : 0; + } + + /** + * Initialize the multipart data object - must only be called for multipart + * arches. + */ + protected void initMultiData() { + if (multi == null) { + multi = new MultiArchData<G>((G) this); + } + } + + /** * {@inheritDoc} * Implementations must not provide substitute clones of a different class. * I.e. implementations MUST return an object created by super.clone() or their own constructor. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 10:39:18
|
Revision: 1384 http://svn.sourceforge.net/gridarta/?rev=1384&view=rev Author: christianhujer Date: 2007-01-02 02:39:18 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Updated merge progress history to show 3 different diagrams. Modified Paths: -------------- trunk/mergeProgressHistory.sh trunk/src/doc/dev/mergeStats.xhtml trunk/src/mergeMetrics1.gpl Added Paths: ----------- trunk/src/mergeMetrics2.gpl trunk/src/mergeMetrics3.gpl Modified: trunk/mergeProgressHistory.sh =================================================================== --- trunk/mergeProgressHistory.sh 2007-01-02 10:34:43 UTC (rev 1383) +++ trunk/mergeProgressHistory.sh 2007-01-02 10:39:18 UTC (rev 1384) @@ -45,5 +45,7 @@ ) >>../mergeStatistics.dat 2>/dev/null done cd .. -gnuplot <src/mergeMetrics.gpl >src/doc/dev/mergeDiagram.png +gnuplot <src/mergeMetrics1.gpl >src/doc/dev/mergeDiagram1.png +gnuplot <src/mergeMetrics2.gpl >src/doc/dev/mergeDiagram2.png +gnuplot <src/mergeMetrics3.gpl >src/doc/dev/mergeDiagram3.png date Modified: trunk/src/doc/dev/mergeStats.xhtml =================================================================== --- trunk/src/doc/dev/mergeStats.xhtml 2007-01-02 10:34:43 UTC (rev 1383) +++ trunk/src/doc/dev/mergeStats.xhtml 2007-01-02 10:39:18 UTC (rev 1384) @@ -10,11 +10,17 @@ <body> <h1>Gridarta merge Statistics</h1> <p> - The following diagram illustrates the merge progress. + The following diagrams illustrate the merge progress. </p> <p> - <img src="mergeDiagram.png" alt="Diagram illustrating merge progress" /> + <img src="mergeDiagram1.png" alt="Diagram illustrating merge progress (including and excluding textedit)" /> </p> + <p> + <img src="mergeDiagram2.png" alt="Diagram illustrating merge progress (including textedit)" /> + </p> + <p> + <img src="mergeDiagram3.png" alt="Diagram illustrating merge progress (excluding textedit)" /> + </p> <h2>Explanation</h2> <p> X-Axis: commit number. Modified: trunk/src/mergeMetrics1.gpl =================================================================== --- trunk/src/mergeMetrics1.gpl 2007-01-02 10:34:43 UTC (rev 1383) +++ trunk/src/mergeMetrics1.gpl 2007-01-02 10:39:18 UTC (rev 1384) @@ -5,9 +5,10 @@ set nologscale y set xlabel 'revision' set ylabel 'sloc' -set title 'Gridarta Merge Statistics' +set title 'Gridarta Merge Statistics (including and excluding textedit)' set key below -plot 'mergeStatistics.dat' using 1:2 title "Merged Code (excluding textedit)" with lines, \ +plot \ + 'mergeStatistics.dat' using 1:2 title "Merged Code (excluding textedit)" with lines, \ 'mergeStatistics.dat' using 1:3 title "Merged Code (including textedit)" with lines, \ 'mergeStatistics.dat' using 1:4 title "Crossfire Code (excluding textedit)" with lines, \ 'mergeStatistics.dat' using 1:5 title "Crossfire Code (including textedit)" with lines, \ Copied: trunk/src/mergeMetrics2.gpl (from rev 1383, trunk/src/mergeMetrics1.gpl) =================================================================== --- trunk/src/mergeMetrics2.gpl (rev 0) +++ trunk/src/mergeMetrics2.gpl 2007-01-02 10:39:18 UTC (rev 1384) @@ -0,0 +1,16 @@ +set terminal png size 1024,640 +#set terminal svg size 1200 600 dynamic +set grid +set nologscale x +set nologscale y +set xlabel 'revision' +set ylabel 'sloc' +set title 'Gridarta Merge Statistics (including textedit)' +set key below +plot \ + 'mergeStatistics.dat' using 1:3 title "Merged Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:5 title "Crossfire Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:7 title "Daimonin Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:8 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 1:11 title "Complete Code (including textedit)" with lines Copied: trunk/src/mergeMetrics3.gpl (from rev 1383, trunk/src/mergeMetrics1.gpl) =================================================================== --- trunk/src/mergeMetrics3.gpl (rev 0) +++ trunk/src/mergeMetrics3.gpl 2007-01-02 10:39:18 UTC (rev 1384) @@ -0,0 +1,16 @@ +set terminal png size 1024,640 +#set terminal svg size 1200 600 dynamic +set grid +set nologscale x +set nologscale y +set xlabel 'revision' +set ylabel 'sloc' +set title 'Gridarta Merge Statistics (excluding textedit)' +set key below +plot \ + 'mergeStatistics.dat' using 1:2 title "Merged Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:4 title "Crossfire Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:6 title "Daimonin Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:8 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 1:10 title "Complete Code (excluding textedit)" with lines This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 11:09:06
|
Revision: 1386 http://svn.sourceforge.net/gridarta/?rev=1386&view=rev Author: christianhujer Date: 2007-01-02 03:09:05 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Pulled common AnimationObject members up. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java 2007-01-02 10:44:59 UTC (rev 1385) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java 2007-01-02 11:09:05 UTC (rev 1386) @@ -27,7 +27,6 @@ import java.io.Serializable; import javax.swing.ImageIcon; -import net.sf.gridarta.gameobject.NamedObject; import net.sf.gridarta.gameobject.anim.AbstractAnimationObject; /** @@ -42,19 +41,7 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - /** The name of this animation. */ - private final String animName; - /** - * The animation list of this animation. - * The individual entries are all postfixed with '\n'. - */ - private final String animList; - - /** The number of facings, which is different sub animations, for instance for different directions. */ - private final int facings; - - /** * Create an AnimationObject. Therefore animList is parsed. Do not invoke * this constructor directly, use {@link * AnimationObjects#addAnimationObject(String,String)} instead. If you @@ -67,69 +54,12 @@ * @param path path of file where the animation was found in */ AnimationObject(final String animName, final String animList, final String path) { - super(path); - this.animName = animName; - this.animList = animList; - int tmpFacings = 0; - boolean first = true; - for (final String line : animList.split("\n")) { - if (first && line.startsWith("facings ")) { - tmpFacings = Integer.parseInt(line.substring(8)); - first = false; - } else { - } - } - facings = tmpFacings; + super(animName, animList, path); } - /** - * {@inheritDoc} - * @return the same String as {@link #getAnimName()}. - */ - @Override public String getName() { - return animName; - } - /** {@inheritDoc} */ @Override public ImageIcon getDisplayIcon() { return null; // TODO } - /** {@inheritDoc} */ - public int getFacings() { - return facings; - } - - /** - * {@inheritDoc} - * @see #getName() - */ - public String getAnimName() { - return animName; - } - - /** {@inheritDoc} */ - public String getAnimList() { - return animList; - } - - /** - * {@inheritDoc} - * The String representation of an AnimationObject is suitable for writing into the animations file. - */ - @Override public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("anim "); - sb.append(animName); - sb.append('\n'); - sb.append(animList); - sb.append("mina\n"); - return sb.toString(); - } - - /** {@inheritDoc} */ - @Override public int compareTo(final NamedObject o) { - return animName.compareTo(((AnimationObject) o).animName); - } - } // class AnimationObject Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2007-01-02 10:44:59 UTC (rev 1385) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2007-01-02 11:09:05 UTC (rev 1386) @@ -45,21 +45,9 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - /** The name of this animation. */ - private final String animName; - - /** - * The animation list of this animation. - * The individual entries are all postfixed with '\n'. - */ - private final String animList; - /** The names of the animation frames. */ private final List<String> frames = new ArrayList<String>(); - /** The number of facings, which is different sub animations, for instance for different directions. */ - private final int facings; - /** The number of frames per facing in the animation. */ private final int frameCount; @@ -76,34 +64,21 @@ * @param path path of file where the animation was found in */ AnimationObject(final String animName, final String animList, final String path) { - super(path); - this.animName = animName; - this.animList = animList; + super(animName, animList, path); int tmpFacings = 0; boolean first = true; for (final String line : animList.split("\n")) { if (first && line.startsWith("facings ")) { - tmpFacings = Integer.parseInt(line.substring(8)); - first = false; } else { frames.add(line); } } frameCount = tmpFacings == 0 ? 1 : frames.size() / tmpFacings; - facings = tmpFacings; } - /** - * {@inheritDoc} - * @return the same String as {@link #getAnimName()}. - */ - @Override public String getName() { - return animName; - } - /** {@inheritDoc} */ @Override public ImageIcon getDisplayIcon() { - return FaceObjects.normal.getImageIconForFacename(getFirstFrame(facings > 0 ? 1 : 0)); + return FaceObjects.normal.getImageIconForFacename(getFirstFrame(getFacings() > 0 ? 1 : 0)); } /** @@ -114,11 +89,6 @@ return frameCount; } - /** {@inheritDoc} */ - public int getFacings() { - return facings; - } - /** * Get the first frame. * @param facing facing to get frame for, usually a direction @@ -143,31 +113,4 @@ return frames.get(facing * tmpFrameCount + frame); } - /** - * {@inheritDoc} - * @see #getName() - */ - public String getAnimName() { - return animName; - } - - /** {@inheritDoc} */ - public String getAnimList() { - return animList; - } - - /** - * {@inheritDoc} - * The String representation of an AnimationObject is suitable for writing into the animations file. - */ - @Override public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("anim "); - sb.append(animName); - sb.append('\n'); - sb.append(animList); - sb.append("mina\n"); - return sb.toString(); - } - } // class AnimationObject Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 10:44:59 UTC (rev 1385) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 11:09:05 UTC (rev 1386) @@ -8,12 +8,84 @@ */ public abstract class AbstractAnimationObject extends NamedObject implements AnimationObject { + /** The number of facings, which is different sub animations, for instance for different directions. */ + private final int facings; + + /** The name of this animation. */ + private final String animName; + /** - * Create an AnimationObject. + * The animation list of this animation. + * The individual entries are all postfixed with '\n'. + */ + private final String animList; + + /** + * Create an AnimationObject. Therefore animList is parsed. Do not invoke + * this constructor directly, use {@link + * AnimationObjects#addAnimationObject(String,String)} instead. If you + * invoke this constructor directly, the created AnimationObject will not + * be registered. + * @param animName name of the animation + * @param animList list of animation as found between "anim" and "mina", + * separated with "\n", including "facings" but including neither "anim" + * nor "mina" * @param path Path for this AnimationObject. */ - protected AbstractAnimationObject(final String path) { + protected AbstractAnimationObject(final String animName, final String animList, final String path) { super(path); + this.animName = animName; + this.animList = animList; + int tmpFacings = 0; + boolean first = true; + for (final String line : animList.split("\n")) { + if (first && line.startsWith("facings ")) { + tmpFacings = Integer.parseInt(line.substring(8)); + first = false; + } else { + } + } + facings = tmpFacings; } + /** + * {@inheritDoc} + * @return the same String as {@link #getAnimName()}. + */ + @Override public String getName() { + return animName; + } + + /** {@inheritDoc} */ + public int getFacings() { + return facings; + } + + /** + * {@inheritDoc} + * @see #getName() + */ + public String getAnimName() { + return animName; + } + + /** {@inheritDoc} */ + public String getAnimList() { + return animList; + } + + /** + * {@inheritDoc} + * The String representation of an AnimationObject is suitable for writing into the animations file. + */ + @Override public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("anim "); + sb.append(animName); + sb.append('\n'); + sb.append(animList); + sb.append("mina\n"); + return sb.toString(); + } + } // class AbstractAnimationObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 11:49:41
|
Revision: 1388 http://svn.sourceforge.net/gridarta/?rev=1388&view=rev Author: christianhujer Date: 2007-01-02 03:49:41 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Extracted some differences into separate methods. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:17:24 UTC (rev 1387) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:49:41 UTC (rev 1388) @@ -52,6 +52,7 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -349,6 +350,28 @@ } /** + * Returns the face for a GameObject. + * @param gameObject GameObject to return face for. + * @return Face for the supplied GameObject. + */ + private ImageIcon getFace(@NotNull final GameObject gameObject) { + return mainControl.getArchetypeSet().getFace(gameObject.getFaceNr()); + } + + /** + * Returns the name of a face for a GameObject. + * @param gameObject GameObject to return face name for. + * @return Name of the GameObject's face. + */ + private String getFaceName(@NotNull final GameObject gameObject) { + if (gameObject.getFaceName() != null && gameObject.getFaceName().length() > 0) { + return gameObject.getFaceName(); + } else { + return gameObject.getArchetype().getFaceName(); + } + } + + /** * Construct the upper left part of the attribute dialog, * containing name, type, archetype name and face. * @return a <code>JScrollPane</code> with the upper left part of the dialog window @@ -363,7 +386,7 @@ gbc.weightx = 0.0; gbc.weighty = 3.0; gbc.gridheight = 3; - imagePanel = new JLabel(mainControl.getArchetypeSet().getFace(gameObject.getFaceNr())); + imagePanel = new JLabel(getFace(gameObject)); imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); header.add(imagePanel, gbc); gbc.gridheight = 1; Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:17:24 UTC (rev 1387) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:49:41 UTC (rev 1388) @@ -51,6 +51,7 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -344,6 +345,28 @@ } /** + * Returns the face for a GameObject. + * @param gameObject GameObject to return face for. + * @return Face for the supplied GameObject. + */ + private ImageIcon getFace(@NotNull final GameObject gameObject) { + return mainControl.getArchetypeSet().getFace(gameObject.getFaceObjName()); + } + + /** + * Returns the name of a face for a GameObject. + * @param gameObject GameObject to return face name for. + * @return Name of the GameObject's face. + */ + private String getFaceName(@NotNull final GameObject gameObject) { + if (gameObject.getFaceRealName() != null && gameObject.getFaceRealName().length() > 0) { + return gameObject.getFaceRealName(); + } else { + return gameObject.getArchetype().getFaceRealName(); + } + } + + /** * Construct the upper left part of the attribute dialog, * containing name, type, archetype name and face. * @return a <code>JScrollPane</code> with the upper left part of the dialog window @@ -358,7 +381,7 @@ gbc.weightx = 0.0; gbc.weighty = 3.0; gbc.gridheight = 3; - imagePanel = new JLabel(mainControl.getArchetypeSet().getFace(gameObject.getFaceObjName())); + imagePanel = new JLabel(getFace(gameObject)); imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); header.add(imagePanel, gbc); gbc.gridheight = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 11:54:55
|
Revision: 1389 http://svn.sourceforge.net/gridarta/?rev=1389&view=rev Author: christianhujer Date: 2007-01-02 03:54:54 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Extracted some differences into separate methods. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:49:41 UTC (rev 1388) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:54:54 UTC (rev 1389) @@ -654,11 +654,7 @@ dtxt = archetype.getArchetypeName(); } } else if (nameOld.equalsIgnoreCase("face")) { - if (gameObject.getFaceName() != null && gameObject.getFaceName().length() > 0) { - dtxt = gameObject.getFaceName(); - } else { - dtxt = archetype.getFaceName(); - } + dtxt = getFaceName(gameObject); } else { dtxt = gameObject.getAttributeString(nameOld); } Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:49:41 UTC (rev 1388) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2007-01-02 11:54:54 UTC (rev 1389) @@ -649,11 +649,7 @@ dtxt = archetype.getArchetypeName(); } } else if (nameOld.equalsIgnoreCase("face")) { - if (gameObject.getFaceRealName() != null && gameObject.getFaceRealName().length() > 0) { - dtxt = gameObject.getFaceRealName(); - } else { - dtxt = archetype.getFaceRealName(); - } + dtxt = getFaceName(gameObject); } else { dtxt = gameObject.getAttributeString(nameOld); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 12:43:08
|
Revision: 1393 http://svn.sourceforge.net/gridarta/?rev=1393&view=rev Author: christianhujer Date: 2007-01-02 04:43:08 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Introduced common CFTreasureListTree class (required for GameObjectAttributesDialog unification). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CFTreasureListTree.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2007-01-02 12:16:27 UTC (rev 1392) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2007-01-02 12:43:08 UTC (rev 1393) @@ -70,7 +70,7 @@ * @author Andreas Vogl * @todo don't extend JTree, instead create a proper model */ -public final class CFTreasureListTree extends JTree { +public final class CFTreasureListTree extends net.sf.gridarta.CFTreasureListTree { private static final Logger log = Logger.getLogger(CFTreasureListTree.class); @@ -82,8 +82,6 @@ private static final int UNSET = -1; // unset values - public static final String NONE_SYM = "<none>"; // string displayed in attribute dialog for "none" - private static CFTreasureListTree instance; // static instance of this object // root-node @@ -139,6 +137,7 @@ instance = new CFTreasureListTree(); instance.initSpecialTreasureLists(); instance.parseTreasures(); + net.sf.gridarta.CFTreasureListTree.instance = instance; } } @@ -454,16 +453,8 @@ showDialog(null, null); } - /** - * Show the Dialog window containing this tree. The user can select - * a treasurelist which is returned as String. - * The dialog window is built only ONCE, then hidden/shown as needed. - * As a side-effect, only one treasurelist window can be open at a time. - * When a second window is opened, the first one gets (re-)moved. - * @param input Textfield to show. - * @param parent Parent frame (attribute dialog) - */ - public synchronized void showDialog(final JTextField input, final Component parent) { + /** {@inheritDoc} */ + @Override public synchronized void showDialog(final JTextField input, final Component parent) { this.input = input; // set textfield for input/output if (!hasBeenDisplayed) { Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2007-01-02 12:16:27 UTC (rev 1392) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2007-01-02 12:43:08 UTC (rev 1393) @@ -72,7 +72,7 @@ * @author Andreas Vogl * @todo don't extend JTree, instead create a proper model */ -public final class CFTreasureListTree extends JTree { +public final class CFTreasureListTree extends net.sf.gridarta.CFTreasureListTree { private static final Logger log = Logger.getLogger(CFTreasureListTree.class); @@ -84,8 +84,6 @@ private static final int UNSET = -1; // unset values - public static final String NONE_SYM = "<none>"; // string displayed in attribute dialog for "none" - private static CFTreasureListTree instance; // static instance of this object // root-node @@ -141,6 +139,7 @@ instance = new CFTreasureListTree(); instance.initSpecialTreasureLists(); instance.parseTreasures(); + net.sf.gridarta.CFTreasureListTree.instance = instance; } } @@ -472,16 +471,8 @@ showDialog(null, null); } - /** - * Show the Dialog window containing this tree. The user can select - * a treasurelist which is returned as String. - * The dialog window is built only ONCE, then hidden/shown as needed. - * As a side-effect, only one treasurelist window can be open at a time. - * When a second window is opened, the first one gets (re-)moved. - * @param input Textfield to show. - * @param parent Parent frame (attribute dialog) - */ - public synchronized void showDialog(final JTextField input, final Component parent) { + /** {@inheritDoc} */ + @Override public synchronized void showDialog(final JTextField input, final Component parent) { this.input = input; // set textfield for input/output if (!hasBeenDisplayed) { Added: trunk/src/app/net/sf/gridarta/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFTreasureListTree.java (rev 0) +++ trunk/src/app/net/sf/gridarta/CFTreasureListTree.java 2007-01-02 12:43:08 UTC (rev 1393) @@ -0,0 +1,41 @@ +package net.sf.gridarta; + +import java.awt.Component; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; + +/** + * The CFTreasureListTree class fully manages treasurelists. + * CF datafile "treasures" gets parsed into a JTree structure. + * @author Andreas Vogl + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo don't extend JTree, instead create a proper model + */ +public abstract class CFTreasureListTree extends JTree { + + public static final String NONE_SYM = "<none>"; // string displayed in attribute dialog for "none" + + protected static CFTreasureListTree instance; // static instance of this object + + /** + * Construct an empty instance of this object. This method is private, + * so it is impossible to create non-static instances of this class. + * @param root Root node. + */ + protected CFTreasureListTree(final DefaultMutableTreeNode root) { + super(root); + } + + /** + * Show the Dialog window containing this tree. The user can select + * a treasurelist which is returned as String. + * The dialog window is built only ONCE, then hidden/shown as needed. + * As a side-effect, only one treasurelist window can be open at a time. + * When a second window is opened, the first one gets (re-)moved. + * @param input Textfield to show. + * @param parent Parent frame (attribute dialog) + */ + public abstract void showDialog(JTextField input, Component parent); + +} // class CFTreasureListTree Property changes on: trunk/src/app/net/sf/gridarta/CFTreasureListTree.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...> - 2007-01-02 12:59:05
|
Revision: 1396 http://svn.sourceforge.net/gridarta/?rev=1396&view=rev Author: christianhujer Date: 2007-01-02 04:59:06 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Added MainView base class (needed for GameObjectAttributesDialog unification). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/MainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-02 12:48:38 UTC (rev 1395) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-02 12:59:06 UTC (rev 1396) @@ -51,7 +51,6 @@ import javax.swing.ImageIcon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JDesktopPane; -import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JOptionPane; import javax.swing.JSplitPane; @@ -59,8 +58,8 @@ import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.event.InternalFrameEvent; -import javax.swing.event.InternalFrameListener; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; @@ -75,7 +74,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMainView extends JFrame implements InternalFrameListener { +public final class CMainView extends MainView { /** Action Factory to create Actions. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); @@ -468,8 +467,8 @@ refresh3(); } - /** Refresh the map arch panel (bottom window). */ - public void refreshMapArchPanel() { + /** {@inheritDoc} */ + @Override public void refreshMapArchPanel() { mapArchPanel.refresh(); } Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-02 12:48:38 UTC (rev 1395) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-02 12:59:06 UTC (rev 1396) @@ -49,7 +49,6 @@ import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JDesktopPane; -import javax.swing.JFrame; import javax.swing.JMenu; import static javax.swing.JOptionPane.WARNING_MESSAGE; import static javax.swing.JOptionPane.showMessageDialog; @@ -59,8 +58,8 @@ import javax.swing.JTabbedPane; import javax.swing.SwingConstants; import javax.swing.event.InternalFrameEvent; -import javax.swing.event.InternalFrameListener; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; @@ -77,7 +76,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo shouldn't extend JFrame */ -public final class CMainView extends JFrame implements ErrorHandler, InternalFrameListener, ThrowableHandler, WindowListener { +public final class CMainView extends MainView implements ErrorHandler, ThrowableHandler, WindowListener { /** Action Factory to create Actions. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); @@ -459,8 +458,8 @@ refresh3(); } - /** Refresh the map arch panel (bottom window). */ - public void refreshMapArchPanel() { + /** {@inheritDoc} */ + @Override public void refreshMapArchPanel() { mapArchPanel.refresh(); } Added: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2007-01-02 12:59:06 UTC (rev 1396) @@ -0,0 +1,27 @@ +package net.sf.gridarta.gui; + +import javax.swing.JFrame; +import javax.swing.event.InternalFrameListener; +import org.jetbrains.annotations.NotNull; + +/** + * Main window of the level editor. + * Contains the desktop for the map windows (internal frames) and the tools. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class MainView extends JFrame implements InternalFrameListener { + + /** + * Creates a new MainView. + * @param title Title + */ + protected MainView(@NotNull final String title) { + super(title); + } + + /** + * Refresh the map arch panel (bottom window). + */ + public abstract void refreshMapArchPanel(); + +} // class MainView Property changes on: trunk/src/app/net/sf/gridarta/gui/MainView.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...> - 2007-01-02 13:05:28
|
Revision: 1398 http://svn.sourceforge.net/gridarta/?rev=1398&view=rev Author: christianhujer Date: 2007-01-02 05:05:28 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Pulled many members in GameObjectAttributesDialog 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 2007-01-02 13:03:34 UTC (rev 1397) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 13:05:28 UTC (rev 1398) @@ -29,70 +29,22 @@ import cfeditor.CMainControl; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; import javax.swing.ImageIcon; -import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.JViewport; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.WindowConstants; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultFormatterFactory; -import javax.swing.text.Document; import javax.swing.text.JTextComponent; -import javax.swing.text.NumberFormatter; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; -import net.sf.gridarta.CAttribBitmask; import net.sf.gridarta.CFArchAttrib; import net.sf.gridarta.CFArchType; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; -import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; -import net.sf.gridarta.help.Help; -import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * GameObjectAttributesDialog poses the GUI for Crossfire object attributes. @@ -100,8 +52,9 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @fixme I suck */ -public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog { +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog<GameObject> { + /** Logger. */ private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); /** Serial Version UID. */ @@ -110,59 +63,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - // store width of input-textfields, then JChooseBoxes are set to this width too - public static final int TEXTFIELD_COLUMNS = 18; // number of columns for textfields - - private final CMainControl mainControl; // reference to the main control - - private final CFArchTypeList archTypeList; // reference to the list of CF type-data - - private List<DialogAttrib<?>> dialogAttribs = new ArrayList<DialogAttrib<?>>(); - - private JComboBox typesel; // selection box for type - - private JLabel imagePanel; // panel for object's face (png) - - /** The game object being modified. */ - @NotNull private final GameObject gameObject; - - private final Archetype<GameObject> archetype; - - private CFArchType type; // reference to the type data - - // this differs from the GameObject if the type is undefined - private int listNr; // the position of this type in the type list - - /** The CardLayout for toggling between edit and summary. */ - private final CardLayout cardLayout = new CardLayout(); - - /** The Action for switching to the summary. */ - private Action summaryAction = ACTION_FACTORY.createAction(false, "attribSummary", this); - - /** The Action for switching to the edit. */ - private Action editAction = ACTION_FACTORY.createAction(false, "attribEdit", this); - - /** The Button for toggling the summary. */ - private JButton summaryEditButton; - - /** The Button for cancel. */ - private JButton cancelButton; - - /** The Button for ok. */ - private JButton okButton; - - /** Central tabbed pane (the place where all the attribute tabs are). */ - private JTabbedPane tabbedPane; - - /** Central pane, this is the parent component of above tabbed pane. */ - private final JPanel centerPane; - - /** Text pane where the summary is displayed. */ - private final JTextPane summaryTP; - - /** The gameObject objects that already are shown, to avoid opening a dialog twice. */ - private static final Map<GameObject, JDialog> dialogs = new HashMap<GameObject, JDialog>(); - /** * Wrapper method for the constructor. * This method only creates a GameObjectAttributesDialog if there's no dialog for the same gameObject already. @@ -193,96 +93,12 @@ * @param mainControl main control */ private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final CMainControl mainControl) { - listNr = 0; - - this.mainControl = mainControl; // reference to the main control - this.archTypeList = archTypeList; // reference to the typelist - - // reference to the GameObject - this.gameObject = gameObject.getHead(); - archetype = this.gameObject.getArchetype(); - - type = archTypeList.getType(gameObject); - listNr = archTypeList.getArchTypeIndex(type); - - // first split top-left and -right - final JComponent leftPane = buildHeader(); - final JScrollPane rightPane = buildInv(); - - //Create a split pane with the two scroll panes in it. - final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane); - - // Now split horizontally - //JScrollPane centerPane = buildAttr(); - centerPane = new JPanel(cardLayout); - centerPane.add("edit", buildAttr()); - summaryTP = new JTextPane(); - summaryTP.setEditable(false); - summaryTP.setBorder(BorderFactory.createEmptyBorder(3, 15, 0, 0)); - centerPane.add("summary", new JScrollPane(summaryTP)); - final Dimension size = centerPane.getPreferredSize(); - size.height = 256; - centerPane.setMinimumSize(size); - centerPane.setPreferredSize(size); - - final JPanel contentPanel = new JPanel(new GridBagLayout()); - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.BOTH; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weighty = 0.0; - contentPanel.add(splitPane, gbc); - gbc.weighty = 1.0; - contentPanel.add(centerPane, gbc); - - setOptions(buildOptions()); - - setMessage(contentPanel); + super(archTypeList, gameObject, mainControl); } /** {@inheritDoc} */ - @Override public void setValue(final Object newValue) { - super.setValue(newValue); - if (newValue != UNINITIALIZED_VALUE) { - dialogs.remove(gameObject).dispose(); - } - } + @Override protected JComboBox buildSpellBox(final CFArchAttrib attr) { - /** - * Construct the Combo box of the available archetypes. - * @return a <code>JComponent</code> with the combo box in it - */ - private JComponent buildTypesBox() { - final String[] namelist = new String[archTypeList.getLength()]; // list of typenames - - // read all type names - int i = 0; - for (final CFArchType tmp : archTypeList) { - namelist[i++] = " " + tmp.getTypeName(); - } - - // the active type appears selected in the box - final int selection = listNr; // position of selected type in the list - - typesel = new JComboBox(namelist); // set "content" - typesel.setSelectedIndex(selection); // set active selection - - //typesel.setKeySelectionManager(new StringKeyManager(typesel)); - - typesel.setName("Types"); - - // the listener: - typesel.addItemListener(new TypesBoxAL(this, gameObject)); - return typesel; - } - - /** - * Construct the Combo box of the available spells. - * @param attr spell attribute - * @return the completed <code>JComboBox</code> - */ - private JComboBox buildSpellBox(final CFArchAttrib attr) { - // first parse the spell-number value from gameObject int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number @@ -315,55 +131,13 @@ return spellsel; } - /** - * Construct the Combo box for arrays of "list data" (this is used for ArchAttribType.LIST). - * @param attr list attribute - * @param listData List with list items and corresponding values, that means the types are altering: String,Integer - * @return the completed <code>JComboBox</code> - */ - private JComboBox buildArrayBox(final CFArchAttrib attr, final List<?> listData) { - // build the array of list-items - final String[] array = new String[(int) (listData.size() / 2.0)]; - boolean hasSelection = false; - int active = gameObject.getAttributeInt(attr.getNameOld()); - - for (int i = 0; i < array.length; i++) { - array[i] = (String) listData.get(i * 2 + 1); // put string to array - if (!hasSelection && (Integer) listData.get(i * 2) == active) { - hasSelection = true; // the selection is valid - active = i; // set selection to this index in the array - } - } - // if there is no valid pre-selection, show first element of list - if (!hasSelection) { - active = 0; - } - - final JComboBox arraysel = new JComboBox(array); // set "content" - arraysel.setSelectedIndex(active); // set active selection - arraysel.setMaximumRowCount(10); - arraysel.setKeySelectionManager(new StringKeyManager(arraysel)); - - arraysel.setName(attr.getNameNew()); - - return arraysel; + /** {@inheritDoc} */ + @Override protected ImageIcon getFace(@NotNull final GameObject gameObject) { + return ((CMainControl) mainControl).getArchetypeSet().getFace(gameObject.getFaceNr()); } - /** - * Returns the face for a GameObject. - * @param gameObject GameObject to return face for. - * @return Face for the supplied GameObject. - */ - private ImageIcon getFace(@NotNull final GameObject gameObject) { - return mainControl.getArchetypeSet().getFace(gameObject.getFaceNr()); - } - - /** - * Returns the name of a face for a GameObject. - * @param gameObject GameObject to return face name for. - * @return Name of the GameObject's face. - */ - private String getFaceName(@NotNull final GameObject gameObject) { + /** {@inheritDoc} */ + @Override protected String getFaceName(@NotNull final GameObject gameObject) { if (gameObject.getFaceName() != null && gameObject.getFaceName().length() > 0) { return gameObject.getFaceName(); } else { @@ -372,662 +146,12 @@ } /** - * Construct the upper left part of the attribute dialog, - * containing name, type, archetype name and face. - * @return a <code>JScrollPane</code> with the upper left part of the dialog window - */ - private JComponent buildHeader() { - final JPanel header = new JPanel(new GridBagLayout()); // the final thing, in a panel - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.BOTH; - gbc.insets = new Insets(2, 2, 2, 2); - gbc.gridx = 1; - gbc.gridy = 1; - gbc.weightx = 0.0; - gbc.weighty = 3.0; - gbc.gridheight = 3; - imagePanel = new JLabel(getFace(gameObject)); - imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); - header.add(imagePanel, gbc); - gbc.gridheight = 1; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - - gbc.weightx = 0.0; - gbc.gridx = 2; - gbc.gridy = 1; - header.add(new JLabel("Name: ", SwingConstants.TRAILING), gbc); // create label - gbc.gridy++; - header.add(new JLabel("Type: ", SwingConstants.TRAILING), gbc); - gbc.gridy++; - header.add(new JLabel("Archetype: ", SwingConstants.TRAILING), gbc); // create label - - gbc.gridx = 3; - gbc.gridy = 1; - gbc.weightx = 1.0; - final JTextField nameTF;if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { - nameTF = new JTextField(gameObject.getObjName(), 16); - } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - nameTF = new JTextField(archetype.getObjName(), 16); - } else { - nameTF = new JTextField(archetype.getArchetypeName(), 16); - } - nameTF.setEditable(false); - header.add(nameTF, gbc); - gbc.gridy++; - header.add(buildTypesBox(), gbc); // build type-selection box - gbc.gridy++; - final JTextField archetypeTF=new JTextField(archetype.getArchetypeName(), 16); - archetypeTF.setEditable(false); - header.add(archetypeTF, gbc); - - return header; - } - - /** - * Construct the upper right part of the attribute dialog, - * containing the object's inventory. - * @return a <code>JScrollPane</code> with the upper right part of the dialog window - */ - private static JScrollPane buildInv() { - final JPanel inv = new JPanel(); // the final thing, in a panel - inv.add(new JLabel("Inventory:")); // create label - - final JScrollPane scrollPane = new JScrollPane(inv); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane.setSize(80, 70); - - return scrollPane; - } - - /** - * Construct the central part of the attribute dialog, containing the - * object's gameObject attributes. - * @return When this method is called the first time: a <code>JScrollPane</code> - * with the central part of the dialog window. - * All further calls rebuild the existing tabbedpane and return null. - */ - @Nullable private JComponent buildAttr() { - boolean initialCall = false; - - if (tabbedPane == null) { - tabbedPane = new JTabbedPane(); - initialCall = true; - } - - for (int i = 0; i < type.getSectionNum(); i++) { - final Component panel1 = makeAttribPanel(i); - if (panel1 != null) { - tabbedPane.addTab(getSectionName(i), null, panel1); - } - } - - // set selected tab - tabbedPane.setSelectedIndex(0); - - if (initialCall) { - return tabbedPane; - } else { - return null; - } - } - - /** - * This method creates an attribute panel for one section of attributes. If - * the section is empty, null is returned. - * @param secId the identifier of the section - * @return a <code>Component</code> containing the attribute panel - * (currently always a JScrollPane) - * @todo I'm still 263 lines long, please make me shorter. - */ - @Nullable private Component makeAttribPanel(final int secId) { - int number = 0; // number of attributes in this section - boolean hasBitmask = false; // true if this section contains a bitmask attribute - - // first we check how many attribs this section has - for (int i = 0; type.getAttr().length > i; i++) { - if (type.getAttr()[i].getSecId() == secId) { - // count number of attributes - if (type.getAttr()[i].getDataType() != ArchAttribType.FIXED) { - number++; - } - // check for bitmask attributes - if (!hasBitmask && type.getAttr()[i].getDataType() == ArchAttribType.BITMASK) { - hasBitmask = true; - } - } - } - if (number == 0) { - return null; - } - - // All attribute-"lines" go into this panel: - final JPanel panel = new JPanel(new GridBagLayout()); - final Insets gbcInsets = new Insets(2, 2, 2, 2); - - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = gbcInsets; - final Object helpGbc = gbc.clone(); - gbc.fill = GridBagConstraints.HORIZONTAL; - final Object labelGbc = gbc.clone(); - gbc.weightx = 1.0; - gbc.gridwidth = GridBagConstraints.REMAINDER; - final Object compGbc = gbc.clone(); - gbc.anchor = GridBagConstraints.WEST; - final Object rowGbc = gbc.clone(); - gbc.fill = GridBagConstraints.BOTH; - gbc.weighty = 1.0; - boolean isText = false; - final Object glueGbc = gbc.clone(); - - final CFArchAttrib[] attribs = type.getAttr(); - // now add the entrys, line by line - for (int i = 0; attribs.length > i; i++) { - final CFArchAttrib attrib = attribs[i]; - final ArchAttribType dType = attrib.getDataType(); // data type of the attribute - if (attrib.getSecId() == secId && dType != ArchAttribType.FIXED) { - final String nameOld = attrib.getNameOld(); - final JButton helpButton = new JButton("?"); - helpButton.setMargin(new Insets(0, 5, 0, 5)); - panel.add(helpButton, helpGbc); - helpButton.addFocusListener(this); - - JComponent cLabel = null; - JComponent cComp = null; - JComponent cRow = null; - JComponent cGlue = null; - - // now create the attribute-GUI-instance - final DialogAttrib<?> newAttr; - - switch (dType) { - case TEXT: { - isText = true; // text section (need special embedding without additional scrollbars) - newAttr = new DialogAttrib<JTextArea>(attrib); - String text = ""; - if (nameOld.equalsIgnoreCase("msg")) { - if (archetype.getMsgText() != null && archetype.getMsgText().length() > 0 && (gameObject.getMsgText() == null || gameObject.getMsgText().trim().length() == 0)) { - text = archetype.getMsgText(); - } else { - text = gameObject.getMsgText(); - } - } - final JTextArea input = new JTextArea(text, 10, 20); - input.setBorder(BorderFactory.createEmptyBorder(3, 7, 0, 0)); - final JScrollPane scrollPane = new JScrollPane(input); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - ((DialogAttrib<JTextArea>) newAttr).input = input; - cGlue = scrollPane; - } - break; - case BOOL: - case BOOL_SPEC: { - newAttr = new DialogAttrib<JCheckBox>(attrib); - final JCheckBox input; - switch (dType) { - case BOOL: - // normal bool - input = new JCheckBox(attrib.getNameNew(), gameObject.getAttributeInt(nameOld) == 1); - break; - case BOOL_SPEC: { - // parse values for customized bool - final String trueVal = attrib.getMisc()[0]; - if (trueVal.equals("0")) { - final String attrString = gameObject.getAttributeString(nameOld); - input = new JCheckBox(attrib.getNameNew(), attrString.length() == 0 || attrString.equals("0")); - } else { - input = new JCheckBox(attrib.getNameNew(), gameObject.getAttributeString(nameOld).equals(trueVal)); - } - } - break; - default: - assert false; - input = null; - break; - } - ((DialogAttrib<JCheckBox>) newAttr).input = input; - cRow = input; - } - break; - case INT: - case LONG: - case FLOAT: { - cLabel = new JLabel(attrib.getNameNew() + ": "); - 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; - switch (dType) { - case INT: - case LONG: - format = NumberFormat.getIntegerInstance(); - break; - case FLOAT: - format = NumberFormat.getInstance(); - format.setMaximumFractionDigits(10); - break; - default: - assert false; - format = null; - break; - } - format.setGroupingUsed(false); - final NumberFormatter formatter = new NumberFormatter(format); - final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value; - switch (dType) { - case INT: - value = gameObject.getAttributeInt(nameOld); - break; - case LONG: - value = gameObject.getAttributeLong(nameOld); - break; - case FLOAT: - value = gameObject.getAttributeDouble(nameOld); - break; - default: - value = null; - assert false; - break; - } - final JFormattedTextField input = new JFormattedTextField(factory, value); - input.setColumns(fieldLength); - cComp = input; - ((DialogAttrib<JFormattedTextField>) newAttr).input = input; - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - final String dtxt; - if (nameOld.equalsIgnoreCase("name")) { - if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { - dtxt = gameObject.getObjName(); - } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - dtxt = archetype.getObjName(); - } else { - dtxt = archetype.getArchetypeName(); - } - } else if (nameOld.equalsIgnoreCase("face")) { - dtxt = getFaceName(gameObject); - } else { - dtxt = gameObject.getAttributeString(nameOld); - } - final JTextField input = new JTextField(dtxt, TEXTFIELD_COLUMNS); - switch (dType) { - case STRING: - cLabel = new JLabel(attrib.getNameNew() + ": "); - newAttr = new DialogAttrib<JTextField>(attrib); - break; - case FACENAME: - case ANIMNAME: - newAttr = new DialogAttrib<JTextField>(attrib); - switch (dType) { - case FACENAME: - cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, mainControl.getFaceObjects())); - break; - case ANIMNAME: - cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, mainControl.getAnimationObjects())); - break; - default: - assert false; - cLabel = null; - break; - } - break; - default: - assert false; - newAttr = null; - break; - } - cComp = input; - ((DialogAttrib<JTextField>) newAttr).input = input; - } - break; - case SPELL: - case ZSPELL: - case LIST: { - cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); - newAttr = new DialogAttrib<JComboBox>(attrib); - // create ComboBox with parsed selection - final JComboBox input; - switch (dType) { - case SPELL: - case ZSPELL: - input = buildSpellBox(attrib); - break; - case LIST: - if (attrib.getMisc() != null && archTypeList.getListTable().containsKey(attrib.getMisc()[0])) { - // build the list from vector data - input = buildArrayBox(attrib, archTypeList.getListTable().get(attrib.getMisc()[0])); - } else { - // error: list data is missing or corrupt - cComp = new JLabel("Error: Undefined List"); - input = null; - } - break; - default: - assert false; - input = null; - break; - } - if (input != null) { - cComp = input; - } - ((DialogAttrib<JComboBox>) newAttr).input = input; - } - break; - case DBLLIST: { - final JPanel compo = new JPanel(new BorderLayout()); - cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); - newAttr = new DialogAttrib<JComboBox[]>(attrib); - // create ComboBox with parsed selection - final JComboBox[] inputs = new JComboBox[2]; - if (attrib.getMisc() != null && archTypeList.getListTable().containsKey(attrib.getMisc()[0]) && archTypeList.getListTable().containsKey(attrib.getMisc()[1])) { - // Hack to set preselected if available - final int active = gameObject.getAttributeInt(nameOld); - final int[] activepart = {active & 0x0F, active & 0xF0}; - // build the lists from vector data - for (int j = 0; j < 2; j++) { - final List<?> listData = archTypeList.getListTable().get(attrib.getMisc()[j]); - inputs[j] = buildArrayBox(attrib, listData); - for (int k = 0; (double) k < listData.size() / 2.0; k++) { - if ((Integer) listData.get(k << 1) == activepart[j]) { - inputs[j].setSelectedIndex(k); // set active selection - break; - } - } - } - compo.add(inputs[0], BorderLayout.NORTH); - compo.add(inputs[1], BorderLayout.SOUTH); - cComp = compo; - } else { - // error: list data is missing or corrupt - cComp = new JLabel("Error: Undefined List"); - } - ((DialogAttrib<JComboBox[]>) newAttr).input = inputs; - } - break; - case BITMASK: { - newAttr = new BitmaskAttrib(attrib); - if (attrib.getMisc() != null && archTypeList.getBitmaskTable().containsKey(attrib.getMisc()[0])) { - // fetch the bitmask data, then build the attribute panel - final CAttribBitmask bitmask = archTypeList.getBitmaskTable().get(attrib.getMisc()[0]); - ((BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr).bitmask = bitmask; - cLabel = new JButton(new MaskChangeAL(attrib.getNameNew() + ":", (BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr)); - final JTextArea input = new JTextArea(); - input.setBackground(getBackground()); - input.setEditable(false); - input.setBorder(BorderFactory.createLineBorder(Color.gray)); - input.setText(bitmask.getText(((BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr).getValue())); - cComp = input; - ((DialogAttrib<JTextComponent>) newAttr).input = input; - ((BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr).setValue(gameObject.getAttributeInt(nameOld)); - } else { - cRow = new JLabel("Error: Undefined Bitmask"); - } - } - break; - case TREASURE: { - newAttr = new DialogAttrib<JTextField>(attrib); - // textfield (no direct input, text is set by the treasurelist dialog) - String treasureName = gameObject.getAttributeString(nameOld); - if (treasureName.trim().length() == 0 || treasureName.trim().equalsIgnoreCase("none")) { - treasureName = CFTreasureListTree.NONE_SYM; - } - final JTextField input = new JTextField(" " + treasureName, TEXTFIELD_COLUMNS); - input.setEditable(false); - cLabel = new JButton(new ViewTreasurelistAL((DialogAttrib<JTextField>) newAttr, this)); - cComp = input; - ((DialogAttrib<JTextField>) newAttr).input = input; - } - break; - default: - newAttr = null; - assert false; - break; - } // switch (dType) - - assert newAttr != null; - dialogAttribs.add(newAttr); - helpButton.addActionListener(new HelpActionListener(newAttr.ref)); - if (cLabel != null) { - panel.add(cLabel, labelGbc); - cLabel.addFocusListener(this); - } - if (cComp != null) { - panel.add(cComp, compGbc); - cComp.addFocusListener(this); - } - if (cRow != null) { - panel.add(cRow, rowGbc); - cRow.addFocusListener(this); - } - if (cGlue != null) { - panel.add(cGlue, glueGbc); - cGlue.addFocusListener(this); - } - } - } - - if (!isText) { - // if the component does not already have glue, put glue inside to align its contents to the top. - panel.add(Box.createGlue(), glueGbc); - } - final JScrollPane panelReturn = new JScrollPane(panel); - panelReturn.getVerticalScrollBar().setUnitIncrement(8); - return panelReturn; - } - - /** - * Looks up the section name from the ID. - * @param secId ID of the section - * @return name of that section - */ - private String getSectionName(final int secId) { - for (int i = 0; type.getAttr().length > i; i++) { - if (type.getAttr()[i].getSecId() == secId) { - // we've got the string, now capitalize the first letter - String s = type.getAttr()[i].getSecName(); - if (s.length() > 1) { - s = s.substring(0, 1).toUpperCase() + s.substring(1); - } - return s; - } - } - - return "???"; - } - - /** - * Construct the dialog options: help, default, okay, apply, cancel. - * @return Object[] with dialog options - */ - private Object[] buildOptions() { - return new Object[] { - new JButton(ACTION_FACTORY.createAction(false, "attribHelp", this)), - summaryEditButton = new JButton(summaryAction), - Box.createHorizontalStrut(32), - okButton = new JButton(ACTION_FACTORY.createAction(false, "attribOk", this)), - new JButton(ACTION_FACTORY.createAction(false, "attribApply", this)), - cancelButton = new JButton(ACTION_FACTORY.createAction(false, "attribCancel", this)), - }; - } - - /** - * Action method for help. - */ - public void attribHelp() { - new Help(mainControl.getMainView(), type.createHtmlDocu()).setVisible(true); - } - - /** - * Action method for ok. - */ - public void attribOk() { - if (applySettings()) { - setValue(okButton); - } - } - - /** - * Action method for apply. - */ - public void attribApply() { - applySettings(); - } - - /** - * Action method for cancel. - */ - public void attribCancel() { - setValue(cancelButton); - } - - /** - * Action method for summary. Switches the cardlayout to the summary list - * of all nonzero attributes. - */ - public void attribSummary() { - // interface is displayed, switch to summary - final Document doc = summaryTP.getDocument(); - - try { - // clear document - if (doc.getLength() > 0) { - doc.remove(0, doc.getLength()); - } - - final Style docStyle = summaryTP.getStyle(StyleContext.DEFAULT_STYLE); - StyleConstants.setForeground(docStyle, Color.black); - - // now loop through all attributes and write out nonzero ones - for (final DialogAttrib attr : dialogAttribs) { - switch (attr.ref.getDataType()) { - case BOOL: - case BOOL_SPEC: { - final boolean value = ((DialogAttrib<JCheckBox>) attr).input.isSelected(); // true/false - if (value) { - doc.insertString(doc.getLength(), "<" + attr.ref.getNameNew() + ">\n", docStyle); - } - } - break; - case INT: - case LONG: - case FLOAT: { - final String value = ((DialogAttrib<JFormattedTextField>) attr).input.getText(); // the attrib value - if (value != null && value.length() > 0 && !value.equals("0")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); - } - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - final String value = ((DialogAttrib<JTextField>) attr).input.getText(); // the attrib value - if (value != null && value.length() > 0) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); - } - } - break; - case SPELL: - case ZSPELL: - case LIST: { - final String value = ((DialogAttrib<JComboBox>) attr).input.getSelectedItem().toString().trim(); // the attrib value - if (value != null && value.length() > 0 && !value.startsWith("<")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); - } - } - break; - case DBLLIST: { - final String value1 = ((DialogAttrib<JComboBox[]>) attr).input[0].getSelectedItem().toString().trim(); - final String value2 = ((DialogAttrib<JComboBox[]>) attr).input[1].getSelectedItem().toString().trim(); - String out = null; - if (value1 != null && value1.length() > 0 && !value1.startsWith("<")) { - out = value1; - } - if (value2 != null && value2.length() > 0 && !value2.startsWith("<")) { - if (out == null) { - out = value2; - } else { - out += " / " + value2; - } - } - if (out != null) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + out + "\n", docStyle); - } - } - break; - case BITMASK: { - final String value = ((BitmaskAttrib) attr).input.getText().trim(); - if (value != null && value.length() > 0 && !value.startsWith("<")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); - } - } - break; - case TREASURE: { - final String value = ((DialogAttrib<JTextField>) attr).input.getText().trim(); // the attrib value - if (value != null && value.length() > 0 && !value.equals(CFTreasureListTree.NONE_SYM)) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); - } - } - break; - case TEXT: - /* Nothing to do. */ - break; - default: - assert false : "Unknown type: " + attr.ref.getDataType(); - break; - } - } - } catch (final BadLocationException e) { - log.error("toggleSummary: Bad Location in Document!", e); - } - - summaryTP.setCaretPosition(0); // this prevents the document from scrolling down - summaryEditButton.setAction(editAction); - cardLayout.show(centerPane, "summary"); - } - - /** - * Turns the summary off. - * Switches to the input-interface for all attributes and the summary list of all nonzero attributes. - */ - public void attribEdit() { - summaryEditButton.setAction(summaryAction); - cardLayout.show(centerPane, "edit"); - } - - /** * This method is called when the "apply"-button has been * pressed. All the settings from the dialog get * written into the GameObject. * @return true if the settings were applied, false if error occurred */ - private boolean applySettings() { - final MapModel mapModel = mainControl.getCurrentMap().getMapModel(); - mapModel.beginTransaction("Change object attributes"); - try { - return applySettings2(); - } finally { - mapModel.endTransaction(); - } - } - - /** - * This method is called when the "apply"-button has been - * pressed. All the settings from the dialog get - * written into the GameObject. - * @return true if the settings were applied, false if error occurred - */ - private boolean applySettings2() { + @Override protected boolean applySettings2() { final String oldArchText = gameObject.getObjectText(); // the old ArchText final String oldMsg = gameObject.getMsgText(); // old gameObject msg final CFArchType typeStruct = archTypeList.getTypeOfArch(gameObject); // the type structure for this gameObject @@ -1178,7 +302,7 @@ // get selected index of ComboBox final int attrValTmp = ((JComboBox) attr.input).getSelectedIndex(); // fetch value according to this list entry: - attrVal = (Integer) (archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); + attrVal = (Integer) ((List) archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); break; default: assert false; @@ -1198,8 +322,8 @@ } break; case DBLLIST: { - final int val1 = (Integer) archTypeList.getListTable().get(attr.ref.getMisc()[0]).get(2 * ((JComboBox[]) attr.input)[0].getSelectedIndex()); - final int val2 = (Integer) archTypeList.getListTable().get(attr.ref.getMisc()[1]).get(2 * ((JComboBox[]) attr.input)[1].getSelectedIndex()); + final int val1 = (Integer) ((List) archTypeList.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.input)[0].getSelectedIndex()); + final int val2 = (Integer) ((List) archTypeList.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.input)[1].getSelectedIndex()); final int combinedVal = val1 + val2; if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { @@ -1298,7 +422,7 @@ } } } - imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject.getFaceNr())); + imagePanel.setIcon(((CMainControl) mainControl).getArchetypeSet().getFace(gameObject.getFaceNr())); if (newMsg != null) { // set new msg text only when it is not equal to Archetype @@ -1333,216 +457,19 @@ (oldArchText == null && gameObject.getObjectText() != null) || (oldMsg != null && !oldMsg.equals(gameObject.getMsgText())) || (oldMsg == null && gameObject.getMsgText() != null)) { - mainControl.getCurrentMap().setLevelChangedFlag(); + ((CMainControl) mainControl).getCurrentMap().setLevelChangedFlag(); } // recalculate the editType value - gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(((CMainControl) mainControl).getCurrentMap().getActiveEditType()); - mainControl.getMainView().refreshMapArchPanel(); + ((CMainControl) mainControl).getMainView().refreshMapArchPanel(); return true; // apply succeeded } - /** - * Open a popup dialog and ask the user to confirm (or modify) - * the encountered syntax errors. - * If the user chooses to keep any errors, these get attached - * to the archtext by the actionlistener (<code>ConfirmErrorsAL</code>). - * <p/> - * Note that this method does not fork off with a new thread. - * It freezes the parent frames (and threads) until the popup - * window is closed, which mimics non-event-driven behaviour. - * @param errors a textual list of the encountered errors - */ - private void askConfirmErrors(final String errors) { - final JDialog frame = new JDialog((JFrame) null, "Syntax Errors", true); // dialog freezes parents - frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // closing is handled by listener - - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - final JPanel headerPanel = new JPanel(new GridLayout(2, 1)); - final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - - // create header labels - final JLabel header1 = new JLabel("The following lines from the archtext appear to be wrong."); - final JLabel header2 = new JLabel("They do not match the type definitions:"); - headerPanel.add(header1); - headerPanel.add(header2); - - // create textarea for showing errors - final JTextArea textarea = new JTextArea(errors, 7, 25); - textarea.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0)); - final JScrollPane scrollPane = new JScrollPane(textarea); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - - // create buttons - final JButton dumpButton = new JButton("Dump All Errors"); - final JButton keepButton = new JButton("Keep Above Text"); - buttonPanel.add(dumpButton); - buttonPanel.add(keepButton); - - // attach actionlistener to the buttons (and the frame) - final ConfirmErrorsAL listener = new ConfirmErrorsAL(frame, gameObject, errors, keepButton, textarea); - keepButton.addActionListener(listener); - dumpButton.addActionListener(listener); - frame.addWindowListener(listener); - - // stick panels together - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - mainPanel.add(headerPanel); - mainPanel.add(Box.createVerticalStrut(10)); - mainPanel.add(scrollPane); - mainPanel.add(Box.createVerticalStrut(10)); - mainPanel.add(buttonPanel); - - frame.getContentPane().add(mainPanel); - - // pack, position and show the popup - frame.pack(); - frame.setLocationRelativeTo(this); - frame.setVisible(true); + /** Notify of changes. */ + @Override protected void changeNotify() { + ((CMainControl) mainControl).getCurrentMap().setLevelChangedFlag(); } - /** ActionListener for the change buttons of bitmasks. */ - private static final class MaskChangeAL extends AbstractAction { - - private final BitmaskAttrib bmAttr; // attribute structure - - /** - * Constructor. - * @param label Name of this Action. - * @param newAttr the GUI-bitmask attribute where the change button belongs to - */ - private MaskChangeAL(final String label, final BitmaskAttrib newAttr) { - super(label); - bmAttr = newAttr; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - if (bmAttr != null) { - final Integer newValue = bmAttr.bitmask.showBitmaskDialog(bmAttr.input, bmAttr); - if (newValue != null) { - bmAttr.setValue(newValue); - } - } - } - - /** {@inheritDoc} */ - @Override protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } // class MaskChangeAL - - /** - * ActionListener for the buttons on treasurelists. When such a button is - * pressed, the dialog with treasurelists pops up. - */ - private static final class ViewTreasurelistAL extends AbstractAction { - - private final DialogAttrib<JTextField> strAttr; // attribute structure - - private final AbstractGameObjectAttributesDialog dialog; // reference to this dialog instance - - /** - * Constructor. - * @param attr the GUI-string attribute where the treasurelist button belongs to - * @param dialog Parent component to show on. - */ - private ViewTreasurelistAL(final DialogAttrib<JTextField> attr, final GameObjectAttributesDialog dialog) { - super("treasurelist:"); - strAttr = attr; - this.dialog = dialog; - } - - /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent e) { - if (strAttr != null) { - CFTreasureListTree.getInstance().showDialog(strAttr.input, dialog); - } - } - - /** {@inheritDoc} */ - @Override protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - } // class ViewTreasurelistAL - - /** ItemListener for the type-selection box on the attribute-dialog. */ - private final class TypesBoxAL implements ItemListener { - - private final GameObjectAttributesDialog frame; // the entire frame - - private final GameObject gameObject; // the according gameObject - - private String deselected; // the latest deselected item - - private boolean ignoreEvent; // while true, this listener ignores all events - - /** - * Constructor. - * @param frameNew the attribute-dialog mainframe - * @param gameObject the gameObject which has the error to be added - */ - private TypesBoxAL(final GameObjectAttributesDialog frameNew, final GameObject gameObject) { - frame = frameNew; - this.gameObject = gameObject; - ignoreEvent = false; - } - - /** {@inheritDoc} */ - public void itemStateChanged(final ItemEvent e) { - if (ignoreEvent) { - return; - } - - if (e.getStateChange() == ItemEvent.DESELECTED) { - // remember the deselected type - deselected = ((String) e.getItem()).trim(); - } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { - // new type was selected - // first, get new type structure - final CFArchType newType = archTypeList.getTypeByName((String) e.getItem()); - - frame.typesel.hidePopup(); - frame.update(frame.getGraphics()); - - if (deselected == null) { - deselected = frame.type.getTypeName(); - } - if (showConfirmDialog(frame, "Do you really want to change the type of this\nobject from \"" + deselected + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", YES_NO_OPTION, INFORMATION_MESSAGE) == YES_OPTION) { - // change is confirmed, now get it on... - frame.type = newType; // set new type structure - - // change the gameObject to be of the new type: - gameObject.setArchTypNr(newType.getTypeNr()); - dialogAttribs.clear(); - - listNr = frame.typesel.getSelectedIndex(); - - // rebuild the dialog frame to show the new tabs - frame.tabbedPane.removeAll(); - frame.buildAttr(); - frame.tabbedPane.validate(); - frame.update(frame.getGraphics()); - - // recalculate the editType value - gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); - // also update the gameObject panel (bottom) - mainControl.getMainView().refreshMapArchPanel(); - // map content has changed - mainControl.getCurrentMap().setLevelChangedFlag(); - } else { - // change not wanted -> reset the choosebox - ignoreEvent = true; // ignore events thrown by the forced reset - frame.typesel.setSelectedIndex(listNr); - ignoreEvent = false; - } - } - } - - } // class TypesBoxAL - } // class GameObjectAttributesDialog Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2007-01-02 13:03:34 UTC (rev 1397) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2007-01-02 13:05:28 UTC (rev 1398) @@ -28,71 +28,23 @@ import daieditor.CFTreasureListTree; import daieditor.CMainControl; import daieditor.gameobject.GameObject; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; import javax.swing.ImageIcon; -import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.JViewport; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.WindowConstants; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultFormatterFactory; -import javax.swing.text.Document; import javax.swing.text.JTextComponent; -import javax.swing.text.NumberFormatter; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; -import net.sf.gridarta.CAttribBitmask; import net.sf.gridarta.CFArchAttrib; import net.sf.gridarta.CFArchType; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.ArchAttribType; -import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gui.AbstractGameObjectAttributesDialog; -import net.sf.gridarta.help.Help; -import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.util.Arrays2.linearSearch; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * GameObjectAttributesDialog poses the GUI for Daimonin object attributes. @@ -100,8 +52,9 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @fixme I suck */ -public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog { +public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog<GameObject> { + /** Logger. */ private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); /** Serial Version UID. */ @@ -110,59 +63,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - // store width of input-textfields, then JChooseBoxes are set to this width too - public static final int TEXTFIELD_COLUMNS = 18; // number of columns for textfields - - private final CMainControl mainControl; // reference to the main control - - private final CFArchTypeList archTypeList; // reference to the list of CF type-data - - private List<DialogAttrib<?>> dialogAttribs = new ArrayList<DialogAttrib<?>>(); - - private JComboBox typesel; // selection box for type - - private JLabel imagePanel; // panel for object's face (png) - - /** The game object being modified. */ - @NotNull private final GameObject gameObject; - - private final Archetype<GameObject> archetype; - - private CFArchType type; // reference to the type data - - // this differs from the GameObject if the type is undefined - private int listNr; // the position of this type in the type list - - /** The CardLayout for toggling between edit and summary. */ - private final CardLayout cardLayout = new CardLayout(); - - /** The Action for switching to the summary. */ - private Action summaryAction = ACTION_FACTORY.createAction(false, "attribSummary", this); - - /** The Action for switching to the edit. */ - private Action editAction = ACTION_FACTORY.createAction(false, "attribEdit", this); - - /** The Button for toggling the summary. */ - private JButton summaryEditButton; - - /** The Button for cancel. */ - private JButton cancelButton; - - /** The Button for ok. */ - private JButton okButton; - - /** Central tabbed pane (the place where all the attribute tabs are). */ - private JTabbedPane tabbedPane; - - /** Central pane, this is the parent component of above tabbed pane. */ - private final JPanel centerPane; - - /** Text pane where the summary is displayed. */ - private final JTextPane summaryTP; - - /** The gameObject objects that already are shown, to avoid opening a dialog twice. */ - private static final Map<GameObject, JDialog> dialogs = new HashMap<GameObject, JDialog>(); - /** * Wrapper method for the constructor. * This method only creates a GameObjectAttributesDialog if there's no dialog for the same gameObject already. @@ -193,96 +93,12 @@ * @param mainControl main control */ private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final CMainControl mainControl) { - listNr = 0; - - this.mainControl = mainControl; // reference to the main control - this.archTypeList = archTypeList; // reference to the typelist - - // reference to the GameObject - this.gameObject = gameObject.getHead(); - archetype = this.gameObject.getArchetype(); - - type = archTypeList.getType... [truncated message content] |
From: <chr...@us...> - 2007-01-02 14:45:36
|
Revision: 1403 http://svn.sourceforge.net/gridarta/?rev=1403&view=rev Author: christianhujer Date: 2007-01-02 06:45:37 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Added method that returns a face for a GameObject in addition to the indexed methods. This should be useful for removing differences that result from different indices. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-02 14:18:57 UTC (rev 1402) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-02 14:45:37 UTC (rev 1403) @@ -102,6 +102,11 @@ return null; } + /** {@inheritDoc} */ + @Nullable public ImageIcon getFace(@NotNull final GameObject gameObject) { + return getFace(gameObject.getFaceNr()); + } + @Nullable public String getFaceName(final int i) { if (i >= 0 && i < faceListCount) { return faceObjects[i].getName(); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-02 14:18:57 UTC (rev 1402) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-02 14:45:37 UTC (rev 1403) @@ -56,6 +56,7 @@ import net.sf.japi.swing.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The <code>ArchetypeSet</code> contains all the Archetypes. @@ -99,6 +100,11 @@ return face; } + /** {@inheritDoc} */ + @Nullable public ImageIcon getFace(@NotNull final GameObject gameObject) { + return getFace(gameObject.getFaceRealName()); + } + /** * Get the transparent face ImageIcon with a certain face name. * @param faceName faceName of face ImageIcon Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2007-01-02 14:18:57 UTC (rev 1402) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2007-01-02 14:45:37 UTC (rev 1403) @@ -1,5 +1,6 @@ package net.sf.gridarta.gameobject; +import javax.swing.ImageIcon; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,20 +34,26 @@ * @return Archetype for <var>archetypeName</var> or <code>null</code> if no such Archetype * @see GameObject#createArch() for a similar method that instantiates. */ - @Nullable G getArchetype(@NotNull final String archetypeName); + @Nullable G getArchetype(@NotNull String archetypeName); /** * Adds an Archetype to this Set. * @param archetype Archetype to add. * @throws IllegalArgumentException in case the added GameObject is not an Archetype. */ - void addArchetype(@NotNull final G archetype) throws IllegalArgumentException; + void addArchetype(@NotNull G archetype) throws IllegalArgumentException; /** * Instructs this ArchetypeSet to load its Archetypes. */ void loadArchetypes(); + /** + * Returns the face of the GameObject as icon. + * @param gameObject GameObject to get face for + * @return The face of the GameObject as icon or <code>null</code> if no face could be found. + */ + @Nullable ImageIcon getFace(@NotNull G gameObject); /** * The load status of the ArchetypeSet. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 15:46:23
|
Revision: 1407 http://svn.sourceforge.net/gridarta/?rev=1407&view=rev Author: christianhujer Date: 2007-01-02 07:46:23 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Renamed NamedObject(s) to AbstractNamedObject(s). Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/data/NamedObject.java trunk/src/app/net/sf/gridarta/data/NamedObjects.java Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -53,7 +53,7 @@ * normal arches. * @todo this class is not always the best place for multipart object handling, see also {@link GameObjectContainer} for issues about this */ -public final class GameObject /*extends NamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { +public final class GameObject /*extends AbstractNamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { /** Logger. */ private static final Logger log = Logger.getLogger(GameObject.class); Copied: trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java (from rev 1406, trunk/src/app/net/sf/gridarta/data/NamedObject.java) =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -0,0 +1,100 @@ +/* + * Gridarta 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.data; + +import java.io.Serializable; +import javax.swing.ImageIcon; + +/** + * A <code>AbstractNamedObject</code> has a name and tree position source and provides an icon for display. + * <code>AbstractNamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and + * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. + * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + */ +public abstract class AbstractNamedObject implements Comparable<AbstractNamedObject>, Serializable { + + /** The Path. */ + private String path; + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** + * Create a AbstractNamedObject. + * @param path Path + * @see #getPath() + * @see #setPath(String) + */ + protected AbstractNamedObject(final String path) { + this.path = path; + } + + /** + * Get the name of this AbstractNamedObject. + * The name should be of user presentable but 100% machine processable nature, means it must be usable for reverse lookup of this AbstractNamedObject in + * Maps. + * For faces, the name should be the face name. + * For animations, the name should be the animation name. + * For arch objects, the name should be the arch name (definitely not the title). + * @return name of this AbstractNamedObject + */ + public abstract String getName(); + + /** + * Get the path of this AbstractNamedObject. + * The path should be of user presentable but 100% machine processable nature. + * The path must be usable for creating a tree for this AbstractNamedObject. + * The path returned by this method does not include the name of the object. + * The path separator must be "/" independently of the underlying operating system. + * @return path of this AbstractNamedObject + * @see #setPath(String) + */ + public String getPath() { + return path; + } + + /** + * Set the path of this AbstractNamedObject. + * @param path new path for this AbstractNamedObject + * @see #getPath() + */ + public void setPath(final String path) { + this.path = path; + } + + /** + * Get the display icon for this AbstractNamedObject. + * @return display icon of this AbstractNamedObject + */ + public abstract ImageIcon getDisplayIcon(); + + /** {@inheritDoc} */ + public int compareTo(final AbstractNamedObject o) { + return getName().compareTo(o.getName()); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return getName() + "@" + getPath(); + } + +} // class AbstractNamedObject Property changes on: trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java (from rev 1406, trunk/src/app/net/sf/gridarta/data/NamedObjects.java) =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -0,0 +1,186 @@ +/* + * Gridarta 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.data; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeSet; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.PLAIN_MESSAGE; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreePath; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.Nullable; + + +/** + * This class manages AbstractNamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. + * AbstractNamedObjects are iterated in Unicode (=ASCII) order. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractNamedObjects<T extends AbstractNamedObject> implements Iterable<T> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** The localized name of the object type, e.g. used in dialogs. */ + private final String name; + + /** The objects that are mapped. */ + private final Map<String, T> objectMap = new HashMap<String, T>(); + + /** The tree of defined objects. */ + private final NamedTreeNode<T> treeRoot = new NamedTreeNode<T>(); + + /** + * Create a AbstractNamedObjects instance. + * @param name localized name of the object type, e.g. used in dialogs + */ + protected AbstractNamedObjects(final String name) { + this.name = name; + } + + /** + * Get the object tree root. + * @return object tree root + */ + public final NamedTreeNode<T> getTreeRoot() { + return treeRoot; + } + + /** + * Store a AbstractNamedObject. + * @param object AbstractNamedObject to store + */ + protected final void put(final T object) { + objectMap.put(object.getName(), object); + treeRoot.append(object); + } + + /** + * Get the number of objects. + * @return object count + */ + public final int size() { + return objectMap.size(); + } + + /** + * Gets a AbstractNamedObject. + * @param objectName name of object + * @return named object for name <var>objectName</var> or <code>null</code> if none found + */ + public final T get(final String objectName) { + return objectMap.get(objectName); + } + + /** + * Check whether an object is defined. + * @param name object name to look for + * @return <code>true</code> if an object with that name is defined, otherwise <code>false</code> + */ + public final boolean containsKey(final String name) { + return objectMap.containsKey(name); + } + + /** + * {@inheritDoc} + * AbstractNamedObjects are iterated in Unicode (=case sensitive ASCII) order. + */ + public final Iterator<T> iterator() { + return new TreeSet<T>(objectMap.values()).iterator(); + } + + /** + * Show a dialog for choosing from the object tree. + * @param parentComponent parent component to show dialog on + * @param initial initially selected node name + * @return name of selected node or <code>null</code> if the user abandoned the selection dialog by usign cancel or close instead of okay + */ + @Nullable public final String showNodeChooserDialog(final Component parentComponent, final String initial) { + final AbstractNamedObject initialObject = get(initial); + final String initialPath = initialObject != null ? initialObject.getPath() : initial; + final JTree tree = new JTree(treeRoot); + tree.setCellRenderer(new NamedNodeTreeCellRenderer()); + final JScrollPane scroller = new JScrollPane(tree); + tree.setExpandsSelectedPaths(true); + final TreePath path = treeRoot.getPathFor(initialPath); + tree.makeVisible(path); + tree.setSelectionPath(path); + tree.scrollPathToVisible(path); + final JOptionPane pane = new JOptionPane(scroller, PLAIN_MESSAGE, OK_CANCEL_OPTION, null, null, null); + final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.format("chooseNamedObject.title", name)); + pane.selectInitialValue(); + tree.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(final MouseEvent e) { + if (e.getClickCount() == 2) { + final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); + if (selPath != null) { + final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); + if (node.isLeaf()) { + pane.setValue(0); + } + } + } + } + }); + dialog.setVisible(true); + dialog.dispose(); + // This only looks inconvertible. getValue() returns an Integer here. + //noinspection EqualsBetweenInconvertibleTypes + if (pane.getValue() == null || !pane.getValue().equals(0)) { + return null; + } else { + return ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName(); + } + + //return showConfirmDialog(parentComponent, scroller, "Choose a face", OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION && tree.getSelectionPath() != null ? ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName() : null; + } + + /** TreeCellRenderer for NamedTreeNodes in trees. */ + private static class NamedNodeTreeCellRenderer extends DefaultTreeCellRenderer { + + /** {@inheritDoc} */ + @Override + public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + final NamedTreeNode<? extends AbstractNamedObject> node = (NamedTreeNode<? extends AbstractNamedObject>) value; + final AbstractNamedObject object = node.getNamedObject(); + if (object != null) { + setIcon(object.getDisplayIcon()); + } + setText(node.getName()); + return this; + } + + } // class NamedNodeTreeCellRenderer + +} // class AbstractNamedObjects Property changes on: trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Deleted: trunk/src/app/net/sf/gridarta/data/NamedObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObject.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/data/NamedObject.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -1,100 +0,0 @@ -/* - * Gridarta 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.data; - -import java.io.Serializable; -import javax.swing.ImageIcon; - -/** - * A <code>NamedObject</code> has a name and tree position source and provides an icon for display. - * <code>NamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and - * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> - */ -public abstract class NamedObject implements Comparable<NamedObject>, Serializable { - - /** The Path. */ - private String path; - - /** Serial Version. */ - private static final long serialVersionUID = 1L; - - /** - * Create a NamedObject. - * @param path Path - * @see #getPath() - * @see #setPath(String) - */ - protected NamedObject(final String path) { - this.path = path; - } - - /** - * Get the name of this NamedObject. - * The name should be of user presentable but 100% machine processable nature, means it must be usable for reverse lookup of this NamedObject in - * Maps. - * For faces, the name should be the face name. - * For animations, the name should be the animation name. - * For arch objects, the name should be the arch name (definitely not the title). - * @return name of this NamedObject - */ - public abstract String getName(); - - /** - * Get the path of this NamedObject. - * The path should be of user presentable but 100% machine processable nature. - * The path must be usable for creating a tree for this NamedObject. - * The path returned by this method does not include the name of the object. - * The path separator must be "/" independently of the underlying operating system. - * @return path of this NamedObject - * @see #setPath(String) - */ - public String getPath() { - return path; - } - - /** - * Set the path of this NamedObject. - * @param path new path for this NamedObject - * @see #getPath() - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * Get the display icon for this NamedObject. - * @return display icon of this NamedObject - */ - public abstract ImageIcon getDisplayIcon(); - - /** {@inheritDoc} */ - public int compareTo(final NamedObject o) { - return getName().compareTo(o.getName()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return getName() + "@" + getPath(); - } - -} // class NamedObject Deleted: trunk/src/app/net/sf/gridarta/data/NamedObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObjects.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/data/NamedObjects.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -1,186 +0,0 @@ -/* - * Gridarta 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.data; - -import java.awt.Component; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeSet; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.PLAIN_MESSAGE; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreePath; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.Nullable; - - -/** - * This class manages NamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. - * NamedObjects are iterated in Unicode (=ASCII) order. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public abstract class NamedObjects<T extends NamedObject> implements Iterable<T> { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** The localized name of the object type, e.g. used in dialogs. */ - private final String name; - - /** The objects that are mapped. */ - private final Map<String, T> objectMap = new HashMap<String, T>(); - - /** The tree of defined objects. */ - private final NamedTreeNode<T> treeRoot = new NamedTreeNode<T>(); - - /** - * Create a NamedObjects instance. - * @param name localized name of the object type, e.g. used in dialogs - */ - protected NamedObjects(final String name) { - this.name = name; - } - - /** - * Get the object tree root. - * @return object tree root - */ - public final NamedTreeNode<T> getTreeRoot() { - return treeRoot; - } - - /** - * Store a NamedObject. - * @param object NamedObject to store - */ - protected final void put(final T object) { - objectMap.put(object.getName(), object); - treeRoot.append(object); - } - - /** - * Get the number of objects. - * @return object count - */ - public final int size() { - return objectMap.size(); - } - - /** - * Gets a NamedObject. - * @param objectName name of object - * @return named object for name <var>objectName</var> or <code>null</code> if none found - */ - public final T get(final String objectName) { - return objectMap.get(objectName); - } - - /** - * Check whether an object is defined. - * @param name object name to look for - * @return <code>true</code> if an object with that name is defined, otherwise <code>false</code> - */ - public final boolean containsKey(final String name) { - return objectMap.containsKey(name); - } - - /** - * {@inheritDoc} - * NamedObjects are iterated in Unicode (=case sensitive ASCII) order. - */ - public final Iterator<T> iterator() { - return new TreeSet<T>(objectMap.values()).iterator(); - } - - /** - * Show a dialog for choosing from the object tree. - * @param parentComponent parent component to show dialog on - * @param initial initially selected node name - * @return name of selected node or <code>null</code> if the user abandoned the selection dialog by usign cancel or close instead of okay - */ - @Nullable public final String showNodeChooserDialog(final Component parentComponent, final String initial) { - final NamedObject initialObject = get(initial); - final String initialPath = initialObject != null ? initialObject.getPath() : initial; - final JTree tree = new JTree(treeRoot); - tree.setCellRenderer(new NamedNodeTreeCellRenderer()); - final JScrollPane scroller = new JScrollPane(tree); - tree.setExpandsSelectedPaths(true); - final TreePath path = treeRoot.getPathFor(initialPath); - tree.makeVisible(path); - tree.setSelectionPath(path); - tree.scrollPathToVisible(path); - final JOptionPane pane = new JOptionPane(scroller, PLAIN_MESSAGE, OK_CANCEL_OPTION, null, null, null); - final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.format("chooseNamedObject.title", name)); - pane.selectInitialValue(); - tree.addMouseListener(new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - if (e.getClickCount() == 2) { - final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); - if (selPath != null) { - final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); - if (node.isLeaf()) { - pane.setValue(0); - } - } - } - } - }); - dialog.setVisible(true); - dialog.dispose(); - // This only looks inconvertible. getValue() returns an Integer here. - //noinspection EqualsBetweenInconvertibleTypes - if (pane.getValue() == null || !pane.getValue().equals(0)) { - return null; - } else { - return ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName(); - } - - //return showConfirmDialog(parentComponent, scroller, "Choose a face", OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION && tree.getSelectionPath() != null ? ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName() : null; - } - - /** TreeCellRenderer for NamedTreeNodes in trees. */ - private static class NamedNodeTreeCellRenderer extends DefaultTreeCellRenderer { - - /** {@inheritDoc} */ - @Override - public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - final NamedTreeNode<? extends NamedObject> node = (NamedTreeNode<? extends NamedObject>) value; - final NamedObject object = node.getNamedObject(); - if (object != null) { - setIcon(object.getDisplayIcon()); - } - setText(node.getName()); - return this; - } - - } // class NamedNodeTreeCellRenderer - -} // class NamedObjects Modified: trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -37,7 +37,7 @@ * TreeNode implementation for Named Objects (like arches, faces, animations, artifacts etc.), used for displaying faces in a {@link javax.swing.JTree}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class NamedTreeNode<T extends NamedObject> implements TreeNode, Comparable<NamedTreeNode<T>> { +public final class NamedTreeNode<T extends AbstractNamedObject> implements TreeNode, Comparable<NamedTreeNode<T>> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -73,7 +73,7 @@ /** * Create a root node. - * All other nodes must be created via {@link #append(NamedObject)}. + * All other nodes must be created via {@link #append(AbstractNamedObject)}. */ NamedTreeNode() { this(true, null, "/"); @@ -98,7 +98,7 @@ * The constructor has been made private to force users on factory methods * @param dir set this to <code>true</code> for directory nodes, <code>false</code> for face nodes * @param parent Parent node or <code>null</code> for root node - * @param namedObject NamedObject to show as this TreeNode + * @param namedObject AbstractNamedObject to show as this TreeNode */ private NamedTreeNode(final boolean dir, final NamedTreeNode<T> parent, final T namedObject) { this.dir = dir; @@ -123,7 +123,7 @@ * Append a node. * Direct invocation should only occur on the root node. * @param path path of node to append (parent path eventually removed) - * @param namedObject NamedObject to show as this TreeNode + * @param namedObject AbstractNamedObject to show as this TreeNode */ private void append(final String path, final T namedObject) { childNodeArray = null; @@ -169,9 +169,9 @@ // --Commented out by Inspection STOP (09.06.05 04:00) /** - * Get the NamedObject of this node. + * Get the AbstractNamedObject of this node. * Only returns an object for leaf nodes. For dir nodes, it returns <code>null</code> - * @return NamedObject of leaf node / <code>null</code> for dir nodes + * @return AbstractNamedObject of leaf node / <code>null</code> for dir nodes */ public T getNamedObject() { return namedObject; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -1,12 +1,12 @@ package net.sf.gridarta.gameobject.anim; -import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.AbstractNamedObject; /** * Abstract base implementation of {@link AnimationObject}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractAnimationObject extends NamedObject implements AnimationObject { +public abstract class AbstractAnimationObject extends AbstractNamedObject implements AnimationObject { /** The number of facings, which is different sub animations, for instance for different directions. */ private final int facings; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -1,14 +1,14 @@ package net.sf.gridarta.gameobject.anim; -import net.sf.gridarta.data.NamedObject; -import net.sf.gridarta.data.NamedObjects; +import net.sf.gridarta.data.AbstractNamedObject; +import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.japi.swing.ActionFactory; /** * Abstract base implementation of {@link AnimationObjects}. * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> */ -public abstract class AbstractAnimationObjects<T extends NamedObject & AnimationObject> extends NamedObjects<T> implements AnimationObjects<T> { +public abstract class AbstractAnimationObjects<T extends AbstractNamedObject & AnimationObject> extends AbstractNamedObjects<T> implements AnimationObjects<T> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -1,12 +1,12 @@ package net.sf.gridarta.gameobject.face; -import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.AbstractNamedObject; /** * Abstract base implementation of {@link FaceObject}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObject extends NamedObject implements FaceObject { +public abstract class AbstractFaceObject extends AbstractNamedObject implements FaceObject { /** * Create a FaceObject. Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -1,14 +1,14 @@ package net.sf.gridarta.gameobject.face; -import net.sf.gridarta.data.NamedObject; -import net.sf.gridarta.data.NamedObjects; +import net.sf.gridarta.data.AbstractNamedObject; +import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.japi.swing.ActionFactory; /** * Abstract base implementation of {@link FaceObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObjects <T extends NamedObject & FaceObject> extends NamedObjects<T> implements FaceObjects<T> { +public abstract class AbstractFaceObjects <T extends AbstractNamedObject & FaceObject> extends AbstractNamedObjects<T> implements FaceObjects<T> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2007-01-02 15:37:38 UTC (rev 1406) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2007-01-02 15:46:23 UTC (rev 1407) @@ -66,8 +66,8 @@ import net.sf.gridarta.CFTreasureListTree; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.data.NamedObject; -import net.sf.gridarta.data.NamedObjects; +import net.sf.gridarta.data.AbstractNamedObject; +import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -1221,16 +1221,16 @@ private JTextField textField; /** Objects providing the tree. */ - private NamedObjects<? extends NamedObject> objects; + private AbstractNamedObjects<? extends AbstractNamedObject> 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 + * @param objects AbstractNamedObjects that provide the tree */ @SuppressWarnings({"PublicConstructorInNonPublicClass"}) - public TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { + public TreeChooseAction(final String text, final JTextField textField, final AbstractNamedObjects<? extends AbstractNamedObject> objects) { super(text); this.textField = textField; this.objects = objects; @@ -1239,7 +1239,7 @@ /** {@inheritDoc} */ public void actionPerformed(final ActionEvent e) { String initial = textField.getText(); - final NamedObject selected = objects.get(initial); + final AbstractNamedObject selected = objects.get(initial); if (selected != null) { initial = selected.getPath(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 15:49:49
|
Revision: 1408 http://svn.sourceforge.net/gridarta/?rev=1408&view=rev Author: christianhujer Date: 2007-01-02 07:49:49 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Reverted last commit (was the wrong way). Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/data/NamedObject.java trunk/src/app/net/sf/gridarta/data/NamedObjects.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -53,7 +53,7 @@ * normal arches. * @todo this class is not always the best place for multipart object handling, see also {@link GameObjectContainer} for issues about this */ -public final class GameObject /*extends AbstractNamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { +public final class GameObject /*extends NamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { /** Logger. */ private static final Logger log = Logger.getLogger(GameObject.class); Deleted: trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -1,100 +0,0 @@ -/* - * Gridarta 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.data; - -import java.io.Serializable; -import javax.swing.ImageIcon; - -/** - * A <code>AbstractNamedObject</code> has a name and tree position source and provides an icon for display. - * <code>AbstractNamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and - * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> - */ -public abstract class AbstractNamedObject implements Comparable<AbstractNamedObject>, Serializable { - - /** The Path. */ - private String path; - - /** Serial Version. */ - private static final long serialVersionUID = 1L; - - /** - * Create a AbstractNamedObject. - * @param path Path - * @see #getPath() - * @see #setPath(String) - */ - protected AbstractNamedObject(final String path) { - this.path = path; - } - - /** - * Get the name of this AbstractNamedObject. - * The name should be of user presentable but 100% machine processable nature, means it must be usable for reverse lookup of this AbstractNamedObject in - * Maps. - * For faces, the name should be the face name. - * For animations, the name should be the animation name. - * For arch objects, the name should be the arch name (definitely not the title). - * @return name of this AbstractNamedObject - */ - public abstract String getName(); - - /** - * Get the path of this AbstractNamedObject. - * The path should be of user presentable but 100% machine processable nature. - * The path must be usable for creating a tree for this AbstractNamedObject. - * The path returned by this method does not include the name of the object. - * The path separator must be "/" independently of the underlying operating system. - * @return path of this AbstractNamedObject - * @see #setPath(String) - */ - public String getPath() { - return path; - } - - /** - * Set the path of this AbstractNamedObject. - * @param path new path for this AbstractNamedObject - * @see #getPath() - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * Get the display icon for this AbstractNamedObject. - * @return display icon of this AbstractNamedObject - */ - public abstract ImageIcon getDisplayIcon(); - - /** {@inheritDoc} */ - public int compareTo(final AbstractNamedObject o) { - return getName().compareTo(o.getName()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return getName() + "@" + getPath(); - } - -} // class AbstractNamedObject Deleted: trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -1,186 +0,0 @@ -/* - * Gridarta 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.data; - -import java.awt.Component; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeSet; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.PLAIN_MESSAGE; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreePath; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.Nullable; - - -/** - * This class manages AbstractNamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. - * AbstractNamedObjects are iterated in Unicode (=ASCII) order. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public abstract class AbstractNamedObjects<T extends AbstractNamedObject> implements Iterable<T> { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** The localized name of the object type, e.g. used in dialogs. */ - private final String name; - - /** The objects that are mapped. */ - private final Map<String, T> objectMap = new HashMap<String, T>(); - - /** The tree of defined objects. */ - private final NamedTreeNode<T> treeRoot = new NamedTreeNode<T>(); - - /** - * Create a AbstractNamedObjects instance. - * @param name localized name of the object type, e.g. used in dialogs - */ - protected AbstractNamedObjects(final String name) { - this.name = name; - } - - /** - * Get the object tree root. - * @return object tree root - */ - public final NamedTreeNode<T> getTreeRoot() { - return treeRoot; - } - - /** - * Store a AbstractNamedObject. - * @param object AbstractNamedObject to store - */ - protected final void put(final T object) { - objectMap.put(object.getName(), object); - treeRoot.append(object); - } - - /** - * Get the number of objects. - * @return object count - */ - public final int size() { - return objectMap.size(); - } - - /** - * Gets a AbstractNamedObject. - * @param objectName name of object - * @return named object for name <var>objectName</var> or <code>null</code> if none found - */ - public final T get(final String objectName) { - return objectMap.get(objectName); - } - - /** - * Check whether an object is defined. - * @param name object name to look for - * @return <code>true</code> if an object with that name is defined, otherwise <code>false</code> - */ - public final boolean containsKey(final String name) { - return objectMap.containsKey(name); - } - - /** - * {@inheritDoc} - * AbstractNamedObjects are iterated in Unicode (=case sensitive ASCII) order. - */ - public final Iterator<T> iterator() { - return new TreeSet<T>(objectMap.values()).iterator(); - } - - /** - * Show a dialog for choosing from the object tree. - * @param parentComponent parent component to show dialog on - * @param initial initially selected node name - * @return name of selected node or <code>null</code> if the user abandoned the selection dialog by usign cancel or close instead of okay - */ - @Nullable public final String showNodeChooserDialog(final Component parentComponent, final String initial) { - final AbstractNamedObject initialObject = get(initial); - final String initialPath = initialObject != null ? initialObject.getPath() : initial; - final JTree tree = new JTree(treeRoot); - tree.setCellRenderer(new NamedNodeTreeCellRenderer()); - final JScrollPane scroller = new JScrollPane(tree); - tree.setExpandsSelectedPaths(true); - final TreePath path = treeRoot.getPathFor(initialPath); - tree.makeVisible(path); - tree.setSelectionPath(path); - tree.scrollPathToVisible(path); - final JOptionPane pane = new JOptionPane(scroller, PLAIN_MESSAGE, OK_CANCEL_OPTION, null, null, null); - final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.format("chooseNamedObject.title", name)); - pane.selectInitialValue(); - tree.addMouseListener(new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - if (e.getClickCount() == 2) { - final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); - if (selPath != null) { - final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); - if (node.isLeaf()) { - pane.setValue(0); - } - } - } - } - }); - dialog.setVisible(true); - dialog.dispose(); - // This only looks inconvertible. getValue() returns an Integer here. - //noinspection EqualsBetweenInconvertibleTypes - if (pane.getValue() == null || !pane.getValue().equals(0)) { - return null; - } else { - return ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName(); - } - - //return showConfirmDialog(parentComponent, scroller, "Choose a face", OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION && tree.getSelectionPath() != null ? ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName() : null; - } - - /** TreeCellRenderer for NamedTreeNodes in trees. */ - private static class NamedNodeTreeCellRenderer extends DefaultTreeCellRenderer { - - /** {@inheritDoc} */ - @Override - public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - final NamedTreeNode<? extends AbstractNamedObject> node = (NamedTreeNode<? extends AbstractNamedObject>) value; - final AbstractNamedObject object = node.getNamedObject(); - if (object != null) { - setIcon(object.getDisplayIcon()); - } - setText(node.getName()); - return this; - } - - } // class NamedNodeTreeCellRenderer - -} // class AbstractNamedObjects Copied: trunk/src/app/net/sf/gridarta/data/NamedObject.java (from rev 1406, trunk/src/app/net/sf/gridarta/data/NamedObject.java) =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObject.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/NamedObject.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -0,0 +1,100 @@ +/* + * Gridarta 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.data; + +import java.io.Serializable; +import javax.swing.ImageIcon; + +/** + * A <code>NamedObject</code> has a name and tree position source and provides an icon for display. + * <code>NamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and + * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. + * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + */ +public abstract class NamedObject implements Comparable<NamedObject>, Serializable { + + /** The Path. */ + private String path; + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** + * Create a NamedObject. + * @param path Path + * @see #getPath() + * @see #setPath(String) + */ + protected NamedObject(final String path) { + this.path = path; + } + + /** + * Get the name of this NamedObject. + * The name should be of user presentable but 100% machine processable nature, means it must be usable for reverse lookup of this NamedObject in + * Maps. + * For faces, the name should be the face name. + * For animations, the name should be the animation name. + * For arch objects, the name should be the arch name (definitely not the title). + * @return name of this NamedObject + */ + public abstract String getName(); + + /** + * Get the path of this NamedObject. + * The path should be of user presentable but 100% machine processable nature. + * The path must be usable for creating a tree for this NamedObject. + * The path returned by this method does not include the name of the object. + * The path separator must be "/" independently of the underlying operating system. + * @return path of this NamedObject + * @see #setPath(String) + */ + public String getPath() { + return path; + } + + /** + * Set the path of this NamedObject. + * @param path new path for this NamedObject + * @see #getPath() + */ + public void setPath(final String path) { + this.path = path; + } + + /** + * Get the display icon for this NamedObject. + * @return display icon of this NamedObject + */ + public abstract ImageIcon getDisplayIcon(); + + /** {@inheritDoc} */ + public int compareTo(final NamedObject o) { + return getName().compareTo(o.getName()); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return getName() + "@" + getPath(); + } + +} // class NamedObject Copied: trunk/src/app/net/sf/gridarta/data/NamedObjects.java (from rev 1406, trunk/src/app/net/sf/gridarta/data/NamedObjects.java) =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/NamedObjects.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -0,0 +1,186 @@ +/* + * Gridarta 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.data; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeSet; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.PLAIN_MESSAGE; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreePath; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.Nullable; + + +/** + * This class manages NamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. + * NamedObjects are iterated in Unicode (=ASCII) order. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class NamedObjects<T extends NamedObject> implements Iterable<T> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** The localized name of the object type, e.g. used in dialogs. */ + private final String name; + + /** The objects that are mapped. */ + private final Map<String, T> objectMap = new HashMap<String, T>(); + + /** The tree of defined objects. */ + private final NamedTreeNode<T> treeRoot = new NamedTreeNode<T>(); + + /** + * Create a NamedObjects instance. + * @param name localized name of the object type, e.g. used in dialogs + */ + protected NamedObjects(final String name) { + this.name = name; + } + + /** + * Get the object tree root. + * @return object tree root + */ + public final NamedTreeNode<T> getTreeRoot() { + return treeRoot; + } + + /** + * Store a NamedObject. + * @param object NamedObject to store + */ + protected final void put(final T object) { + objectMap.put(object.getName(), object); + treeRoot.append(object); + } + + /** + * Get the number of objects. + * @return object count + */ + public final int size() { + return objectMap.size(); + } + + /** + * Gets a NamedObject. + * @param objectName name of object + * @return named object for name <var>objectName</var> or <code>null</code> if none found + */ + public final T get(final String objectName) { + return objectMap.get(objectName); + } + + /** + * Check whether an object is defined. + * @param name object name to look for + * @return <code>true</code> if an object with that name is defined, otherwise <code>false</code> + */ + public final boolean containsKey(final String name) { + return objectMap.containsKey(name); + } + + /** + * {@inheritDoc} + * NamedObjects are iterated in Unicode (=case sensitive ASCII) order. + */ + public final Iterator<T> iterator() { + return new TreeSet<T>(objectMap.values()).iterator(); + } + + /** + * Show a dialog for choosing from the object tree. + * @param parentComponent parent component to show dialog on + * @param initial initially selected node name + * @return name of selected node or <code>null</code> if the user abandoned the selection dialog by usign cancel or close instead of okay + */ + @Nullable public final String showNodeChooserDialog(final Component parentComponent, final String initial) { + final NamedObject initialObject = get(initial); + final String initialPath = initialObject != null ? initialObject.getPath() : initial; + final JTree tree = new JTree(treeRoot); + tree.setCellRenderer(new NamedNodeTreeCellRenderer()); + final JScrollPane scroller = new JScrollPane(tree); + tree.setExpandsSelectedPaths(true); + final TreePath path = treeRoot.getPathFor(initialPath); + tree.makeVisible(path); + tree.setSelectionPath(path); + tree.scrollPathToVisible(path); + final JOptionPane pane = new JOptionPane(scroller, PLAIN_MESSAGE, OK_CANCEL_OPTION, null, null, null); + final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.format("chooseNamedObject.title", name)); + pane.selectInitialValue(); + tree.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(final MouseEvent e) { + if (e.getClickCount() == 2) { + final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); + if (selPath != null) { + final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); + if (node.isLeaf()) { + pane.setValue(0); + } + } + } + } + }); + dialog.setVisible(true); + dialog.dispose(); + // This only looks inconvertible. getValue() returns an Integer here. + //noinspection EqualsBetweenInconvertibleTypes + if (pane.getValue() == null || !pane.getValue().equals(0)) { + return null; + } else { + return ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName(); + } + + //return showConfirmDialog(parentComponent, scroller, "Choose a face", OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION && tree.getSelectionPath() != null ? ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName() : null; + } + + /** TreeCellRenderer for NamedTreeNodes in trees. */ + private static class NamedNodeTreeCellRenderer extends DefaultTreeCellRenderer { + + /** {@inheritDoc} */ + @Override + public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + final NamedTreeNode<? extends NamedObject> node = (NamedTreeNode<? extends NamedObject>) value; + final NamedObject object = node.getNamedObject(); + if (object != null) { + setIcon(object.getDisplayIcon()); + } + setText(node.getName()); + return this; + } + + } // class NamedNodeTreeCellRenderer + +} // class NamedObjects Modified: trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -37,7 +37,7 @@ * TreeNode implementation for Named Objects (like arches, faces, animations, artifacts etc.), used for displaying faces in a {@link javax.swing.JTree}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class NamedTreeNode<T extends AbstractNamedObject> implements TreeNode, Comparable<NamedTreeNode<T>> { +public final class NamedTreeNode<T extends NamedObject> implements TreeNode, Comparable<NamedTreeNode<T>> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -73,7 +73,7 @@ /** * Create a root node. - * All other nodes must be created via {@link #append(AbstractNamedObject)}. + * All other nodes must be created via {@link #append(NamedObject)}. */ NamedTreeNode() { this(true, null, "/"); @@ -98,7 +98,7 @@ * The constructor has been made private to force users on factory methods * @param dir set this to <code>true</code> for directory nodes, <code>false</code> for face nodes * @param parent Parent node or <code>null</code> for root node - * @param namedObject AbstractNamedObject to show as this TreeNode + * @param namedObject NamedObject to show as this TreeNode */ private NamedTreeNode(final boolean dir, final NamedTreeNode<T> parent, final T namedObject) { this.dir = dir; @@ -123,7 +123,7 @@ * Append a node. * Direct invocation should only occur on the root node. * @param path path of node to append (parent path eventually removed) - * @param namedObject AbstractNamedObject to show as this TreeNode + * @param namedObject NamedObject to show as this TreeNode */ private void append(final String path, final T namedObject) { childNodeArray = null; @@ -169,9 +169,9 @@ // --Commented out by Inspection STOP (09.06.05 04:00) /** - * Get the AbstractNamedObject of this node. + * Get the NamedObject of this node. * Only returns an object for leaf nodes. For dir nodes, it returns <code>null</code> - * @return AbstractNamedObject of leaf node / <code>null</code> for dir nodes + * @return NamedObject of leaf node / <code>null</code> for dir nodes */ public T getNamedObject() { return namedObject; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -1,12 +1,12 @@ package net.sf.gridarta.gameobject.anim; -import net.sf.gridarta.data.AbstractNamedObject; +import net.sf.gridarta.data.NamedObject; /** * Abstract base implementation of {@link AnimationObject}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractAnimationObject extends AbstractNamedObject implements AnimationObject { +public abstract class AbstractAnimationObject extends NamedObject implements AnimationObject { /** The number of facings, which is different sub animations, for instance for different directions. */ private final int facings; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -1,14 +1,14 @@ package net.sf.gridarta.gameobject.anim; -import net.sf.gridarta.data.AbstractNamedObject; -import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.NamedObjects; import net.sf.japi.swing.ActionFactory; /** * Abstract base implementation of {@link AnimationObjects}. * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> */ -public abstract class AbstractAnimationObjects<T extends AbstractNamedObject & AnimationObject> extends AbstractNamedObjects<T> implements AnimationObjects<T> { +public abstract class AbstractAnimationObjects<T extends NamedObject & AnimationObject> extends NamedObjects<T> implements AnimationObjects<T> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -1,12 +1,12 @@ package net.sf.gridarta.gameobject.face; -import net.sf.gridarta.data.AbstractNamedObject; +import net.sf.gridarta.data.NamedObject; /** * Abstract base implementation of {@link FaceObject}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObject extends AbstractNamedObject implements FaceObject { +public abstract class AbstractFaceObject extends NamedObject implements FaceObject { /** * Create a FaceObject. Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -1,14 +1,14 @@ package net.sf.gridarta.gameobject.face; -import net.sf.gridarta.data.AbstractNamedObject; -import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.NamedObjects; import net.sf.japi.swing.ActionFactory; /** * Abstract base implementation of {@link FaceObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObjects <T extends AbstractNamedObject & FaceObject> extends AbstractNamedObjects<T> implements FaceObjects<T> { +public abstract class AbstractFaceObjects <T extends NamedObject & FaceObject> extends NamedObjects<T> implements FaceObjects<T> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2007-01-02 15:46:23 UTC (rev 1407) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2007-01-02 15:49:49 UTC (rev 1408) @@ -66,8 +66,8 @@ import net.sf.gridarta.CFTreasureListTree; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; -import net.sf.gridarta.data.AbstractNamedObject; -import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.NamedObjects; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -1221,16 +1221,16 @@ private JTextField textField; /** Objects providing the tree. */ - private AbstractNamedObjects<? extends AbstractNamedObject> objects; + private NamedObjects<? extends NamedObject> objects; /** * Create a TreeChooseAction. * @param text text for label / button * @param textField JTextField to update upon tree selection - * @param objects AbstractNamedObjects that provide the tree + * @param objects NamedObjects that provide the tree */ @SuppressWarnings({"PublicConstructorInNonPublicClass"}) - public TreeChooseAction(final String text, final JTextField textField, final AbstractNamedObjects<? extends AbstractNamedObject> objects) { + public TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { super(text); this.textField = textField; this.objects = objects; @@ -1239,7 +1239,7 @@ /** {@inheritDoc} */ public void actionPerformed(final ActionEvent e) { String initial = textField.getText(); - final AbstractNamedObject selected = objects.get(initial); + final NamedObject selected = objects.get(initial); if (selected != null) { initial = selected.getPath(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 17:10:23
|
Revision: 1409 http://svn.sourceforge.net/gridarta/?rev=1409&view=rev Author: christianhujer Date: 2007-01-02 09:10:22 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Extracted NamedObject* interfaces. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java trunk/src/app/net/sf/gridarta/data/NamedObject.java trunk/src/app/net/sf/gridarta/data/NamedObjects.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/data/NamedObject.java trunk/src/app/net/sf/gridarta/data/NamedObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -58,7 +58,7 @@ } /** {@inheritDoc} */ - @Override public ImageIcon getDisplayIcon() { + public ImageIcon getDisplayIcon() { return null; // TODO } Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -87,12 +87,12 @@ /** * {@inheritDoc} */ - @Override public String getName() { + public String getName() { return name; } /** {@inheritDoc} */ - @Override public ImageIcon getDisplayIcon() { + public ImageIcon getDisplayIcon() { return getFace(); } Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -53,7 +53,7 @@ * normal arches. * @todo this class is not always the best place for multipart object handling, see also {@link GameObjectContainer} for issues about this */ -public final class GameObject /*extends NamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { +public final class GameObject /*extends AbstractNamedObject*/ extends net.sf.gridarta.gameobject.GameObject<GameObject> implements Cloneable, Serializable { /** Logger. */ private static final Logger log = Logger.getLogger(GameObject.class); Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -77,7 +77,7 @@ } /** {@inheritDoc} */ - @Override public ImageIcon getDisplayIcon() { + public ImageIcon getDisplayIcon() { return FaceObjects.normal.getImageIconForFacename(getFirstFrame(getFacings() > 0 ? 1 : 0)); } Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -102,12 +102,12 @@ * {@inheritDoc} * @return the same String as {@link #getFaceName()}. */ - @Override public String getName() { + public String getName() { return faceName; } /** {@inheritDoc} */ - @Override public ImageIcon getDisplayIcon() { + public ImageIcon getDisplayIcon() { return FaceObjects.normal.getImageIconForFacename(faceName); } Copied: trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java (from rev 1408, trunk/src/app/net/sf/gridarta/data/NamedObject.java) =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -0,0 +1,68 @@ +/* + * Gridarta 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.data; + +/** + * A <code>AbstractNamedObject</code> has a name and tree position source and provides an icon for display. + * <code>AbstractNamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and + * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. + * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + */ +public abstract class AbstractNamedObject implements NamedObject { + + /** The Path. */ + private String path; + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** + * Create a AbstractNamedObject. + * @param path Path + * @see #getPath() + * @see #setPath(String) + */ + protected AbstractNamedObject(final String path) { + this.path = path; + } + + /** {@inheritDoc} */ + public String getPath() { + return path; + } + + /** {@inheritDoc} */ + public void setPath(final String path) { + this.path = path; + } + + /** {@inheritDoc} */ + public int compareTo(final NamedObject o) { + return getName().compareTo(o.getName()); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return getName() + "@" + getPath(); + } + +} // class AbstractNamedObject Property changes on: trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java (from rev 1408, trunk/src/app/net/sf/gridarta/data/NamedObjects.java) =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -0,0 +1,164 @@ +/* + * Gridarta 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.data; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeSet; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.PLAIN_MESSAGE; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreePath; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.Nullable; + + +/** + * This class manages NamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. + * NamedObjects are iterated in Unicode (=ASCII) order. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractNamedObjects<T extends NamedObject> implements NamedObjects<T> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** The localized name of the object type, e.g. used in dialogs. */ + private final String name; + + /** The objects that are mapped. */ + private final Map<String, T> objectMap = new HashMap<String, T>(); + + /** The tree of defined objects. */ + private final NamedTreeNode<T> treeRoot = new NamedTreeNode<T>(); + + /** + * Create a NamedObjects instance. + * @param name localized name of the object type, e.g. used in dialogs + */ + protected AbstractNamedObjects(final String name) { + this.name = name; + } + + /** {@inheritDoc} */ + public final NamedTreeNode<T> getTreeRoot() { + return treeRoot; + } + + /** + * Store a AbstractNamedObject. + * @param object AbstractNamedObject to store + */ + protected final void put(final T object) { + objectMap.put(object.getName(), object); + treeRoot.append(object); + } + + /** {@inheritDoc} */ + public final int size() { + return objectMap.size(); + } + + /** {@inheritDoc} */ + public final T get(final String objectName) { + return objectMap.get(objectName); + } + + /** {@inheritDoc} */ + public final boolean containsKey(final String name) { + return objectMap.containsKey(name); + } + + /** {@inheritDoc} */ + public final Iterator<T> iterator() { + return new TreeSet<T>(objectMap.values()).iterator(); + } + + /** {@inheritDoc} */ + @Nullable public final String showNodeChooserDialog(final Component parentComponent, final String initial) { + final NamedObject initialObject = get(initial); + final String initialPath = initialObject != null ? initialObject.getPath() : initial; + final JTree tree = new JTree(treeRoot); + tree.setCellRenderer(new NamedNodeTreeCellRenderer()); + final JScrollPane scroller = new JScrollPane(tree); + tree.setExpandsSelectedPaths(true); + final TreePath path = treeRoot.getPathFor(initialPath); + tree.makeVisible(path); + tree.setSelectionPath(path); + tree.scrollPathToVisible(path); + final JOptionPane pane = new JOptionPane(scroller, PLAIN_MESSAGE, OK_CANCEL_OPTION, null, null, null); + final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.format("chooseNamedObject.title", name)); + pane.selectInitialValue(); + tree.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(final MouseEvent e) { + if (e.getClickCount() == 2) { + final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); + if (selPath != null) { + final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); + if (node.isLeaf()) { + pane.setValue(0); + } + } + } + } + }); + dialog.setVisible(true); + dialog.dispose(); + // This only looks inconvertible. getValue() returns an Integer here. + //noinspection EqualsBetweenInconvertibleTypes + if (pane.getValue() == null || !pane.getValue().equals(0)) { + return null; + } else { + return ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName(); + } + + //return showConfirmDialog(parentComponent, scroller, "Choose a face", OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION && tree.getSelectionPath() != null ? ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName() : null; + } + + /** TreeCellRenderer for NamedTreeNodes in trees. */ + private static class NamedNodeTreeCellRenderer extends DefaultTreeCellRenderer { + + /** {@inheritDoc} */ + @Override + public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + final NamedTreeNode<? extends NamedObject> node = (NamedTreeNode<? extends NamedObject>) value; + final NamedObject object = node.getNamedObject(); + if (object != null) { + setIcon(object.getDisplayIcon()); + } + setText(node.getName()); + return this; + } + + } // class NamedNodeTreeCellRenderer + +} // class NamedObjects Property changes on: trunk/src/app/net/sf/gridarta/data/AbstractNamedObjects.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Deleted: trunk/src/app/net/sf/gridarta/data/NamedObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/data/NamedObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -1,100 +0,0 @@ -/* - * Gridarta 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.data; - -import java.io.Serializable; -import javax.swing.ImageIcon; - -/** - * A <code>NamedObject</code> has a name and tree position source and provides an icon for display. - * <code>NamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and - * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> - */ -public abstract class NamedObject implements Comparable<NamedObject>, Serializable { - - /** The Path. */ - private String path; - - /** Serial Version. */ - private static final long serialVersionUID = 1L; - - /** - * Create a NamedObject. - * @param path Path - * @see #getPath() - * @see #setPath(String) - */ - protected NamedObject(final String path) { - this.path = path; - } - - /** - * Get the name of this NamedObject. - * The name should be of user presentable but 100% machine processable nature, means it must be usable for reverse lookup of this NamedObject in - * Maps. - * For faces, the name should be the face name. - * For animations, the name should be the animation name. - * For arch objects, the name should be the arch name (definitely not the title). - * @return name of this NamedObject - */ - public abstract String getName(); - - /** - * Get the path of this NamedObject. - * The path should be of user presentable but 100% machine processable nature. - * The path must be usable for creating a tree for this NamedObject. - * The path returned by this method does not include the name of the object. - * The path separator must be "/" independently of the underlying operating system. - * @return path of this NamedObject - * @see #setPath(String) - */ - public String getPath() { - return path; - } - - /** - * Set the path of this NamedObject. - * @param path new path for this NamedObject - * @see #getPath() - */ - public void setPath(final String path) { - this.path = path; - } - - /** - * Get the display icon for this NamedObject. - * @return display icon of this NamedObject - */ - public abstract ImageIcon getDisplayIcon(); - - /** {@inheritDoc} */ - public int compareTo(final NamedObject o) { - return getName().compareTo(o.getName()); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return getName() + "@" + getPath(); - } - -} // class NamedObject Added: trunk/src/app/net/sf/gridarta/data/NamedObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObject.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/NamedObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -0,0 +1,55 @@ +package net.sf.gridarta.data; + +import java.io.Serializable; +import javax.swing.ImageIcon; + +/** + * A <code>AbstractNamedObject</code> has a name and tree position source and provides an icon for display. + * <code>AbstractNamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and + * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface NamedObject extends Comparable<NamedObject>, Serializable { + + /** + * Get the name of this AbstractNamedObject. + * The name should be of user presentable but 100% machine processable nature, means it must be usable for reverse lookup of this AbstractNamedObject in + * Maps. + * For faces, the name should be the face name. + * For animations, the name should be the animation name. + * For arch objects, the name should be the arch name (definitely not the title). + * @return name of this AbstractNamedObject + */ + String getName(); + + /** + * Get the path of this AbstractNamedObject. + * The path should be of user presentable but 100% machine processable nature. + * The path must be usable for creating a tree for this AbstractNamedObject. + * The path returned by this method does not include the name of the object. + * The path separator must be "/" independently of the underlying operating system. + * @return path of this AbstractNamedObject + * @see #setPath(String) + */ + String getPath(); + + /** + * Set the path of this AbstractNamedObject. + * @param path new path for this AbstractNamedObject + * @see #getPath() + */ + void setPath(String path); + + /** + * Get the display icon for this AbstractNamedObject. + * @return display icon of this AbstractNamedObject + */ + ImageIcon getDisplayIcon(); + + /** {@inheritDoc} */ + int compareTo(NamedObject o); + + /** {@inheritDoc} */ + @Override String toString(); + +} // interface NamedObject Property changes on: trunk/src/app/net/sf/gridarta/data/NamedObject.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Deleted: trunk/src/app/net/sf/gridarta/data/NamedObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObjects.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/data/NamedObjects.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -1,186 +0,0 @@ -/* - * Gridarta 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.data; - -import java.awt.Component; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeSet; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.PLAIN_MESSAGE; -import javax.swing.JScrollPane; -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreePath; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.Nullable; - - -/** - * This class manages NamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. - * NamedObjects are iterated in Unicode (=ASCII) order. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public abstract class NamedObjects<T extends NamedObject> implements Iterable<T> { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** The localized name of the object type, e.g. used in dialogs. */ - private final String name; - - /** The objects that are mapped. */ - private final Map<String, T> objectMap = new HashMap<String, T>(); - - /** The tree of defined objects. */ - private final NamedTreeNode<T> treeRoot = new NamedTreeNode<T>(); - - /** - * Create a NamedObjects instance. - * @param name localized name of the object type, e.g. used in dialogs - */ - protected NamedObjects(final String name) { - this.name = name; - } - - /** - * Get the object tree root. - * @return object tree root - */ - public final NamedTreeNode<T> getTreeRoot() { - return treeRoot; - } - - /** - * Store a NamedObject. - * @param object NamedObject to store - */ - protected final void put(final T object) { - objectMap.put(object.getName(), object); - treeRoot.append(object); - } - - /** - * Get the number of objects. - * @return object count - */ - public final int size() { - return objectMap.size(); - } - - /** - * Gets a NamedObject. - * @param objectName name of object - * @return named object for name <var>objectName</var> or <code>null</code> if none found - */ - public final T get(final String objectName) { - return objectMap.get(objectName); - } - - /** - * Check whether an object is defined. - * @param name object name to look for - * @return <code>true</code> if an object with that name is defined, otherwise <code>false</code> - */ - public final boolean containsKey(final String name) { - return objectMap.containsKey(name); - } - - /** - * {@inheritDoc} - * NamedObjects are iterated in Unicode (=case sensitive ASCII) order. - */ - public final Iterator<T> iterator() { - return new TreeSet<T>(objectMap.values()).iterator(); - } - - /** - * Show a dialog for choosing from the object tree. - * @param parentComponent parent component to show dialog on - * @param initial initially selected node name - * @return name of selected node or <code>null</code> if the user abandoned the selection dialog by usign cancel or close instead of okay - */ - @Nullable public final String showNodeChooserDialog(final Component parentComponent, final String initial) { - final NamedObject initialObject = get(initial); - final String initialPath = initialObject != null ? initialObject.getPath() : initial; - final JTree tree = new JTree(treeRoot); - tree.setCellRenderer(new NamedNodeTreeCellRenderer()); - final JScrollPane scroller = new JScrollPane(tree); - tree.setExpandsSelectedPaths(true); - final TreePath path = treeRoot.getPathFor(initialPath); - tree.makeVisible(path); - tree.setSelectionPath(path); - tree.scrollPathToVisible(path); - final JOptionPane pane = new JOptionPane(scroller, PLAIN_MESSAGE, OK_CANCEL_OPTION, null, null, null); - final JDialog dialog = pane.createDialog(parentComponent, ACTION_FACTORY.format("chooseNamedObject.title", name)); - pane.selectInitialValue(); - tree.addMouseListener(new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - if (e.getClickCount() == 2) { - final TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); - if (selPath != null) { - final NamedTreeNode<?> node = (NamedTreeNode<?>) selPath.getLastPathComponent(); - if (node.isLeaf()) { - pane.setValue(0); - } - } - } - } - }); - dialog.setVisible(true); - dialog.dispose(); - // This only looks inconvertible. getValue() returns an Integer here. - //noinspection EqualsBetweenInconvertibleTypes - if (pane.getValue() == null || !pane.getValue().equals(0)) { - return null; - } else { - return ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName(); - } - - //return showConfirmDialog(parentComponent, scroller, "Choose a face", OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION && tree.getSelectionPath() != null ? ((NamedTreeNode<?>) tree.getSelectionPath().getLastPathComponent()).getName() : null; - } - - /** TreeCellRenderer for NamedTreeNodes in trees. */ - private static class NamedNodeTreeCellRenderer extends DefaultTreeCellRenderer { - - /** {@inheritDoc} */ - @Override - public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean sel, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - final NamedTreeNode<? extends NamedObject> node = (NamedTreeNode<? extends NamedObject>) value; - final NamedObject object = node.getNamedObject(); - if (object != null) { - setIcon(object.getDisplayIcon()); - } - setText(node.getName()); - return this; - } - - } // class NamedNodeTreeCellRenderer - -} // class NamedObjects Added: trunk/src/app/net/sf/gridarta/data/NamedObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/data/NamedObjects.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -0,0 +1,54 @@ +package net.sf.gridarta.data; + +import java.awt.Component; +import java.util.Iterator; +import org.jetbrains.annotations.Nullable; + +/** + * This class manages NamedObjects, managing their tree as well as providing a method for showing a dialog for browsing their tree and selecting one from it. + * NamedObjects are iterated in Unicode (=ASCII) order. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface NamedObjects<T extends NamedObject> extends Iterable<T> { + + /** + * Get the object tree root. + * @return object tree root + */ + NamedTreeNode<T> getTreeRoot(); + + /** + * Get the number of objects. + * @return object count + */ + int size(); + + /** + * Gets a AbstractNamedObject. + * @param objectName name of object + * @return named object for name <var>objectName</var> or <code>null</code> if none found + */ + T get(String objectName); + + /** + * Check whether an object is defined. + * @param name object name to look for + * @return <code>true</code> if an object with that name is defined, otherwise <code>false</code> + */ + boolean containsKey(String name); + + /** + * {@inheritDoc} + * NamedObjects are iterated in Unicode (=case sensitive ASCII) order. + */ + Iterator<T> iterator(); + + /** + * Show a dialog for choosing from the object tree. + * @param parentComponent parent component to show dialog on + * @param initial initially selected node name + * @return name of selected node or <code>null</code> if the user abandoned the selection dialog by usign cancel or close instead of okay + */ + @Nullable String showNodeChooserDialog(Component parentComponent, String initial); + +} // interface NamedObjects Property changes on: trunk/src/app/net/sf/gridarta/data/NamedObjects.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/data/NamedTreeNode.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -98,7 +98,7 @@ * The constructor has been made private to force users on factory methods * @param dir set this to <code>true</code> for directory nodes, <code>false</code> for face nodes * @param parent Parent node or <code>null</code> for root node - * @param namedObject NamedObject to show as this TreeNode + * @param namedObject AbstractNamedObject to show as this TreeNode */ private NamedTreeNode(final boolean dir, final NamedTreeNode<T> parent, final T namedObject) { this.dir = dir; @@ -123,7 +123,7 @@ * Append a node. * Direct invocation should only occur on the root node. * @param path path of node to append (parent path eventually removed) - * @param namedObject NamedObject to show as this TreeNode + * @param namedObject AbstractNamedObject to show as this TreeNode */ private void append(final String path, final T namedObject) { childNodeArray = null; @@ -169,9 +169,9 @@ // --Commented out by Inspection STOP (09.06.05 04:00) /** - * Get the NamedObject of this node. + * Get the AbstractNamedObject of this node. * Only returns an object for leaf nodes. For dir nodes, it returns <code>null</code> - * @return NamedObject of leaf node / <code>null</code> for dir nodes + * @return AbstractNamedObject of leaf node / <code>null</code> for dir nodes */ public T getNamedObject() { return namedObject; Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -1,12 +1,12 @@ package net.sf.gridarta.gameobject.anim; -import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.AbstractNamedObject; /** * Abstract base implementation of {@link AnimationObject}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractAnimationObject extends NamedObject implements AnimationObject { +public abstract class AbstractAnimationObject extends AbstractNamedObject implements AnimationObject { /** The number of facings, which is different sub animations, for instance for different directions. */ private final int facings; @@ -52,7 +52,7 @@ * {@inheritDoc} * @return the same String as {@link #getAnimName()}. */ - @Override public String getName() { + public String getName() { return animName; } Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -1,14 +1,14 @@ package net.sf.gridarta.gameobject.anim; +import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.gridarta.data.NamedObject; -import net.sf.gridarta.data.NamedObjects; import net.sf.japi.swing.ActionFactory; /** * Abstract base implementation of {@link AnimationObjects}. * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> */ -public abstract class AbstractAnimationObjects<T extends NamedObject & AnimationObject> extends NamedObjects<T> implements AnimationObjects<T> { +public abstract class AbstractAnimationObjects<T extends NamedObject & AnimationObject> extends AbstractNamedObjects<T> implements AnimationObjects<T> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObject.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -1,12 +1,12 @@ package net.sf.gridarta.gameobject.face; -import net.sf.gridarta.data.NamedObject; +import net.sf.gridarta.data.AbstractNamedObject; /** * Abstract base implementation of {@link FaceObject}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObject extends NamedObject implements FaceObject { +public abstract class AbstractFaceObject extends AbstractNamedObject implements FaceObject { /** * Create a FaceObject. Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2007-01-02 15:49:49 UTC (rev 1408) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2007-01-02 17:10:22 UTC (rev 1409) @@ -1,14 +1,14 @@ package net.sf.gridarta.gameobject.face; +import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.gridarta.data.NamedObject; -import net.sf.gridarta.data.NamedObjects; import net.sf.japi.swing.ActionFactory; /** * Abstract base implementation of {@link FaceObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractFaceObjects <T extends NamedObject & FaceObject> extends NamedObjects<T> implements FaceObjects<T> { +public abstract class AbstractFaceObjects <T extends NamedObject & FaceObject> extends AbstractNamedObjects<T> implements FaceObjects<T> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 18:39:32
|
Revision: 1411 http://svn.sourceforge.net/gridarta/?rev=1411&view=rev Author: christianhujer Date: 2007-01-02 10:39:30 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Started merging CMainControls into AbstractMainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 17:17:52 UTC (rev 1410) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 18:39:30 UTC (rev 1411) @@ -58,7 +58,7 @@ import javax.swing.UnsupportedLookAndFeelException; import javax.swing.event.EventListenerList; import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -86,7 +86,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author Andreas Kirschbaum */ -public final class CMainControl implements ThrowableHandler, MainControl<GameObject> { +public final class CMainControl extends AbstractMainControl<GameObject> implements ThrowableHandler { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 17:17:52 UTC (rev 1410) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 18:39:30 UTC (rev 1411) @@ -99,7 +99,7 @@ import static javax.swing.KeyStroke.getKeyStroke; import javax.swing.event.EventListenerList; import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; @@ -135,7 +135,7 @@ * @author Andreas Kirschbaum * @fixme I'm 2200 lines long, therefor I suck. */ -public final class CMainControl implements ThrowableHandler, MapModelListener, MainControl<GameObject> { +public final class CMainControl extends AbstractMainControl<GameObject> implements ThrowableHandler, MapModelListener { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); Added: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2007-01-02 18:39:30 UTC (rev 1411) @@ -0,0 +1,19 @@ +package net.sf.gridarta; + +import net.sf.gridarta.gameobject.GameObject; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; + +/** + * MainControl is a central class that's used for access on global data structures / collections and global functions. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractMainControl<G extends GameObject<G>> implements MainControl<G> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** Logger. */ + private static final Logger log = Logger.getLogger(AbstractMainControl.class); + +} // class AbstractMainControl Property changes on: trunk/src/app/net/sf/gridarta/AbstractMainControl.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2007-01-02 17:17:52 UTC (rev 1410) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2007-01-02 18:39:30 UTC (rev 1411) @@ -16,7 +16,7 @@ * It should become obsolete after a while. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MainControl<G extends GameObject> { +public interface MainControl<G extends GameObject<G>> { /** * Global random number generator. @@ -60,13 +60,13 @@ * Get the ArchetypeSet for the available Archetypes. * @return ArchetypeSet */ - ArchetypeSet getArchetypeSet(); + ArchetypeSet<G> getArchetypeSet(); /** * Get the ArchetypeParser that parsers Archetypes. * @return ArchetypeParser */ - ArchetypeParser getArchetypeParser(); + ArchetypeParser<G> getArchetypeParser(); /** * Get the FaceObjects for the available Faces. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 21:31:01
|
Revision: 1412 http://svn.sourceforge.net/gridarta/?rev=1412&view=rev Author: christianhujer Date: 2007-01-02 13:30:51 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Implemented feature to preselect the direction of archetypes to be inserted. Note: This definitely is hacked and needs cleanup. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 18:39:30 UTC (rev 1411) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 21:30:51 UTC (rev 1412) @@ -2039,6 +2039,10 @@ } } + public int getActiveDirection() { + return mainView.getActiveDirection(); + } + /** Recent entry. */ public final class Recent extends AbstractAction { Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-02 18:39:30 UTC (rev 1411) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-02 21:30:51 UTC (rev 1412) @@ -858,4 +858,9 @@ /** {@inheritDoc} */ public void windowDeactivated(final WindowEvent e) { /* nothing to do. */ } + + public int getActiveDirection() { + return archPanel.currentDirection; + } + } // class CMainView Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2007-01-02 18:39:30 UTC (rev 1411) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2007-01-02 21:30:51 UTC (rev 1412) @@ -30,14 +30,21 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.tools.ToolPalette; import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; +import javax.swing.JToggleButton; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import net.sf.gridarta.gui.GSplitPane; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,6 +60,8 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + /** Controller of this subview. */ private final transient CMainControl mainControl; @@ -68,6 +77,14 @@ /** Panel holding both archlist and pickmaps. */ private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); + /** + * The panel with the ArchetypeChoosers (tabDesktop) and the direction setting. + */ + private final JPanel archPane = new JPanel(new BorderLayout()); + + /** The panel which allows setting the direction of newly inserted archetypes. */ + private final DirectionPane directionPane = new DirectionPane(this); + /** The Tab panel with arch lists. */ private final JTabbedPane tabDesktop = new JTabbedPane(SwingConstants.TOP); @@ -77,6 +94,8 @@ /** The active panel. */ private ArchetypeChooser selectedPanel; + public int currentDirection; + /** * Build Panel. * @param mainControl CMainControl @@ -88,8 +107,11 @@ tabDesktop.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); archQuickPanel = new ObjectChoiceDisplay(mainControl); + archPane.add(tabDesktop); + archPane.add(directionPane, BorderLayout.SOUTH); + // archAndPickPane is the panel containing both archpanel and pickmaps - archAndPickPane.addTab("Arch List", tabDesktop); + archAndPickPane.addTab("Arch List", archPane); archAndPickPane.addTab("Pickmaps", mainControl.getMainView().getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? PickmapChooser.getInstance().addArchNPickChangeListener(archAndPickPane); @@ -234,4 +256,115 @@ return toolPalette; } + public static class DirectionPane extends JPanel { + + /** Empty Insets. */ + private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0); + + /** The buttons for the direction panel. + * @see #directionButtonGroup + */ + private JToggleButton[] directionButtons = new JToggleButton[9]; + + /** + * The ButtonGroup for the direction buttons. + * @see #directionButtons + */ + private ButtonGroup directionButtonGroup = new ButtonGroup(); + + private final InsertionObjectChooser ioc; + + private DirectionPane(final InsertionObjectChooser ioc) { + super(new GridBagLayout()); + this.ioc = ioc; + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(1, 1, 1, 1); + createButton(7, this, gbc, 0, 0); + createButton(8, this, gbc, 1, 0); + createButton(1, this, gbc, 2, 0); + createButton(6, this, gbc, 0, 1); + createButton(0, this, gbc, 1, 1); + createButton(2, this, gbc, 2, 1); + createButton(5, this, gbc, 0, 2); + createButton(4, this, gbc, 1, 2); + createButton(3, this, gbc, 2, 2); + } + + /** + * Create a direction button. + * @param direction Direction for button + * @param panel Panel to add button to + * @param gbc GridBagConstraints to modify + * @param x x position of button + * @param y y position of button + */ + private void createButton(final int direction, final JPanel panel, final GridBagConstraints gbc, final int x, final int y) { + final JToggleButton button = new JToggleButton(ACTION_FACTORY.createAction(false, "direction" + direction, this)); + directionButtonGroup.add(button); + button.setFocusable(false); + //button.setEnabled(false); + button.setMargin(EMPTY_INSETS); + gbc.gridx = x; + gbc.gridy = y; + panel.add(button, gbc); + directionButtons[direction] = button; + } + + /** + * Action proxy for direction. + * @param direction Direction number + */ + private void direction(final int direction) { + ioc.currentDirection = direction; + } + + /** Action method for direction. */ + @ActionMethod public void direction0() { + direction(0); + } + + /** Action method for direction. */ + @ActionMethod public void direction1() { + direction(1); + } + + /** Action method for direction. */ + @ActionMethod public void direction2() { + direction(2); + } + + /** Action method for direction. */ + @ActionMethod public void direction3() { + direction(3); + } + + /** Action method for direction. */ + @ActionMethod public void direction4() { + direction(4); + } + + /** Action method for direction. */ + @ActionMethod public void direction5() { + direction(5); + } + + /** Action method for direction. */ + @ActionMethod public void direction6() { + direction(6); + } + + /** Action method for direction. */ + @ActionMethod public void direction7() { + direction(7); + } + + /** Action method for direction. */ + @ActionMethod public void direction8() { + direction(8); + } + + } // class DirectionPane + } // class InsertionObjectChooser Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2007-01-02 18:39:30 UTC (rev 1411) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2007-01-02 21:30:51 UTC (rev 1412) @@ -160,7 +160,7 @@ mapGrid[mapx][mapy].addLast(part); } - part.setDirection(archetypePart.getDirection()); + part.setDirection(mainControl.getActiveDirection()); mainControl.getArchetypeParser().postParseGameObject(part, mapControl.getActiveEditType()); part.setObjectFace(); } Modified: trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java 2007-01-02 18:39:30 UTC (rev 1411) +++ trunk/src/app/net/sf/gridarta/gui/ArchetypeChooser.java 2007-01-02 21:30:51 UTC (rev 1412) @@ -106,6 +106,7 @@ }); } + /** * Get the GameObject currently selected in the list. * @return GameObject or <code>null</code> if no selection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 23:51:37
|
Revision: 1415 http://svn.sourceforge.net/gridarta/?rev=1415&view=rev Author: christianhujer Date: 2007-01-02 15:51:38 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Added mapMetaChanged() to MapModelListener and implementations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java trunk/src/app/net/sf/gridarta/map/MapModelListener.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -614,6 +614,11 @@ // ignore } + /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + // ignore + } + public static final class CPaintOp implements EditOperation { final Rectangle fillRect; Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -413,6 +413,11 @@ modelChanged(); } + /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + // ignore + } + /** * Resize the backing buffer to the new grid size. * It will only be resized if the map is not a pickmap. Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -405,6 +405,11 @@ } } + /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + // ignore + } + /** * Set a map tile selection. * Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -2019,6 +2019,11 @@ } } + /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + // ignore + } + /** * Get controller of copybuffer. * @return Controller of copybuffer Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -371,6 +371,11 @@ // TODO: only repaint a specific region } + /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + // ignore + } + public void paintOnlyMap(final boolean b) { renderer.setPaintOnlyMap(b); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -680,6 +680,11 @@ changed = true; } + /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + changed = true; + } + /** * Determines if this map has an active selection. * Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -126,6 +126,11 @@ } /** {@inheritDoc} */ + public void mapMetaChanged(final MapModelEvent e) { + // ignore + } + + /** {@inheritDoc} */ public void currentMapChanged(@Nullable final MapControl mapControl) { this.mapControl = mapControl; scanMapForConnections(); Modified: trunk/src/app/net/sf/gridarta/map/MapModelListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModelListener.java 2007-01-02 23:46:35 UTC (rev 1414) +++ trunk/src/app/net/sf/gridarta/map/MapModelListener.java 2007-01-02 23:51:38 UTC (rev 1415) @@ -67,4 +67,11 @@ */ void mapObjectsChanged(MapModelEvent<G> e); + /** + * Meta information of a map has changed. + * The underlying {@link MapArchObject} was changed. + * @param e EventObject with event information + */ + void mapMetaChanged(MapModelEvent<G> e); + } // interface MapModelListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-03 02:31:08
|
Revision: 1419 http://svn.sourceforge.net/gridarta/?rev=1419&view=rev Author: christianhujer Date: 2007-01-02 18:31:08 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Improved statistics calculation / generation. Now includes time statistics and thumbnails. Modified Paths: -------------- trunk/mergeProgressHistory.sh trunk/src/doc/dev/mergeStats.xhtml trunk/src/mergeMetrics1.gpl trunk/src/mergeMetrics2.gpl trunk/src/mergeMetrics3.gpl Added Paths: ----------- trunk/src/mergeMetrics4.gpl trunk/src/mergeMetrics5.gpl trunk/src/mergeMetrics6.gpl Modified: trunk/mergeProgressHistory.sh =================================================================== --- trunk/mergeProgressHistory.sh 2007-01-03 01:25:27 UTC (rev 1418) +++ trunk/mergeProgressHistory.sh 2007-01-03 02:31:08 UTC (rev 1419) @@ -20,9 +20,9 @@ cat common_src crossfire_src daimonin_src >all_src diff -r -d -w -N -I '^package' -I '^import' -x '.svn' crossfire/src/cfeditor daimonin/src/daieditor >differences echo -n $i -#echo -n ' ' -#echo -n $(svn info --xml | xql.pl '/info/entry/commit/date/text()') echo -n ' ' + echo -n $(ls -rtl --time-style '+%s' repoBackup/db/revs/$i | cut -c 33-42) + echo -n ' ' echo -n $(<common_src grep -v textedit | xargs cat | wc -l) echo -n ' ' echo -n $(<common_src xargs cat | wc -l) @@ -46,7 +46,9 @@ ) >>../mergeStatistics.dat 2>/dev/null done cd .. -gnuplot <src/mergeMetrics1.gpl >src/doc/dev/mergeDiagram1.png -gnuplot <src/mergeMetrics2.gpl >src/doc/dev/mergeDiagram2.png -gnuplot <src/mergeMetrics3.gpl >src/doc/dev/mergeDiagram3.png +for ((i = 1; i <= 6; i++)) +do + (echo set terminal png size 1024,640 ; cat src/mergeMetrics$i.gpl ) | gnuplot >src/doc/dev/mergeDiagram$i.png + <src/doc/dev/mergeDiagram$i.png pngtopnm | pnmscale 0.2 | pnmtopng >src/doc/dev/mergeDiagram${i}t.png +done date Modified: trunk/src/doc/dev/mergeStats.xhtml =================================================================== --- trunk/src/doc/dev/mergeStats.xhtml 2007-01-03 01:25:27 UTC (rev 1418) +++ trunk/src/doc/dev/mergeStats.xhtml 2007-01-03 02:31:08 UTC (rev 1419) @@ -5,6 +5,19 @@ <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> <meta name="Date" content="$Date$" /> <title>Gridarta Merge Statistics</title> + <style type="text/css"> + .lmod { + font-size:85%; + } + table.statsList { + width:100%; + padding-left:12.5%; + padding-right:12.5%; + } + table.statsList td { + text-align:center; + } + </style> </head> <body> <h1>Gridarta merge Statistics</h1> @@ -12,26 +25,60 @@ <p> The following diagrams illustrate the merge progress. </p> - <p> - <img src="mergeDiagram1.png" alt="Diagram illustrating merge progress (including and excluding textedit)" /> - <br /> - Last modified: <!--#flastmod file="mergeDiagram1.png" --> - </p> - <p> - <img src="mergeDiagram2.png" alt="Diagram illustrating merge progress (including textedit)" /> - <br /> - Last modified: <!--#flastmod file="mergeDiagram2.png" --> - </p> - <p> - <img src="mergeDiagram3.png" alt="Diagram illustrating merge progress (excluding textedit)" /> - <br /> - Last modified: <!--#flastmod file="mergeDiagram3.png" --> - </p> + <table class="statsList"> + <tr> + <th>Per Revision</th> + <th>Per Time</th> + </tr> + <tr> + <th colspan="2">Including and Excluding textedit</th> + </tr> + <tr> + <td> + <a href="mergeDiagram1.png"><img src="mergeDiagram1t.png" alt="Diagram illustrating merge progress (including and excluding textedit)" /></a> + <br /> + <span class="lmod">Last modified: <!--#flastmod file="mergeDiagram1.png" --></span> + </td> + <td> + <a href="mergeDiagram4.png"><img src="mergeDiagram4t.png" alt="Diagram illustrating merge progress (including and excluding textedit)" /></a> + <br /> + <span class="lmod">Last modified: <!--#flastmod file="mergeDiagram4.png" --></span> + </td> + </tr> + <tr> + <th colspan="2">Including textedit</th> + </tr> + <tr> + <td> + <a href="mergeDiagram2.png"><img src="mergeDiagram2t.png" alt="Diagram illustrating merge progress (including textedit)" /></a> + <br /> + <span class="lmod">Last modified: <!--#flastmod file="mergeDiagram2.png" --></span> + </td> + <td> + <a href="mergeDiagram5.png"><img src="mergeDiagram5t.png" alt="Diagram illustrating merge progress (including textedit)" /></a> + <br /> + <span class="lmod">Last modified: <!--#flastmod file="mergeDiagram5.png" --></span> + </td> + </tr> + <tr> + <th colspan="2">Excluding textedit</th> + </tr> + <tr> + <td> + <a href="mergeDiagram3.png"><img src="mergeDiagram3t.png" alt="Diagram illustrating merge progress (excluding textedit)" /></a> + <br /> + <span class="lmod">Last modified: <!--#flastmod file="mergeDiagram3.png" --></span> + </td> + <td> + <a href="mergeDiagram6.png"><img src="mergeDiagram6t.png" alt="Diagram illustrating merge progress (excluding textedit)" /></a> + <br /> + <span class="lmod">Last modified: <!--#flastmod file="mergeDiagram6.png" --></span> + </td> + </tr> + </table> <h2>Explanation</h2> <p> - X-Axis: commit number. - <br /> - Y-Axis: raw lines of code, including comments and empty lines. + Y-Axis: sloc - raw lines of code, including comments and empty lines. </p> <p> All measurement was done on Java-files only. @@ -41,9 +88,7 @@ The measurements of Crossfire vs. Daimonin differences were done ignoring whitespace, package declarations and imports. </p> <p> - <em>Note:</em> The X-Axis shows commit number. - It's invalid to interpret the X-Axis as a linear time line. - To help readers, I've included a table with the commit dates of some specific revisions: + To help readers interpreting the diagrams, I've included a table with the commit dates of some specific revisions: </p> <table> <tr><th colspan="2">Commit</th></tr> Modified: trunk/src/mergeMetrics1.gpl =================================================================== --- trunk/src/mergeMetrics1.gpl 2007-01-03 01:25:27 UTC (rev 1418) +++ trunk/src/mergeMetrics1.gpl 2007-01-03 02:31:08 UTC (rev 1419) @@ -1,5 +1,3 @@ -set terminal png size 1024,640 -#set terminal svg size 1200 600 dynamic set grid set nologscale x set nologscale y @@ -8,13 +6,13 @@ set title 'Gridarta Merge Statistics (including and excluding textedit)' set key below plot \ - 'mergeStatistics.dat' using 1:2 title "Merged Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:3 title "Merged Code (including textedit)" with lines, \ - 'mergeStatistics.dat' using 1:4 title "Crossfire Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:5 title "Crossfire Code (including textedit)" with lines, \ - 'mergeStatistics.dat' using 1:6 title "Daimonin Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:7 title "Daimonin Code (including textedit)" with lines, \ - 'mergeStatistics.dat' using 1:8 title "Crossfire diff to Daimonin" with lines, \ - 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines, \ - 'mergeStatistics.dat' using 1:10 title "Complete Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:11 title "Complete Code (including textedit)" with lines + 'mergeStatistics.dat' using 1:3 title "Merged Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:4 title "Merged Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:5 title "Crossfire Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:6 title "Crossfire Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:7 title "Daimonin Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:8 title "Daimonin Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:9 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 1:10 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 1:11 title "Complete Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:12 title "Complete Code (including textedit)" with lines Modified: trunk/src/mergeMetrics2.gpl =================================================================== --- trunk/src/mergeMetrics2.gpl 2007-01-03 01:25:27 UTC (rev 1418) +++ trunk/src/mergeMetrics2.gpl 2007-01-03 02:31:08 UTC (rev 1419) @@ -1,5 +1,3 @@ -set terminal png size 1024,640 -#set terminal svg size 1200 600 dynamic set grid set nologscale x set nologscale y @@ -8,9 +6,9 @@ set title 'Gridarta Merge Statistics (including textedit)' set key below plot \ - 'mergeStatistics.dat' using 1:3 title "Merged Code (including textedit)" with lines, \ - 'mergeStatistics.dat' using 1:5 title "Crossfire Code (including textedit)" with lines, \ - 'mergeStatistics.dat' using 1:7 title "Daimonin Code (including textedit)" with lines, \ - 'mergeStatistics.dat' using 1:8 title "Crossfire diff to Daimonin" with lines, \ - 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines, \ - 'mergeStatistics.dat' using 1:11 title "Complete Code (including textedit)" with lines + 'mergeStatistics.dat' using 1:4 title "Merged Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:6 title "Crossfire Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:8 title "Daimonin Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 1:9 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 1:10 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 1:12 title "Complete Code (including textedit)" with lines Modified: trunk/src/mergeMetrics3.gpl =================================================================== --- trunk/src/mergeMetrics3.gpl 2007-01-03 01:25:27 UTC (rev 1418) +++ trunk/src/mergeMetrics3.gpl 2007-01-03 02:31:08 UTC (rev 1419) @@ -1,5 +1,3 @@ -set terminal png size 1024,640 -#set terminal svg size 1200 600 dynamic set grid set nologscale x set nologscale y @@ -8,9 +6,9 @@ set title 'Gridarta Merge Statistics (excluding textedit)' set key below plot \ - 'mergeStatistics.dat' using 1:2 title "Merged Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:4 title "Crossfire Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:6 title "Daimonin Code (excluding textedit)" with lines, \ - 'mergeStatistics.dat' using 1:8 title "Crossfire diff to Daimonin" with lines, \ - 'mergeStatistics.dat' using 1:9 title "Daimonin diff to Crossfire" with lines, \ - 'mergeStatistics.dat' using 1:10 title "Complete Code (excluding textedit)" with lines + 'mergeStatistics.dat' using 1:3 title "Merged Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:5 title "Crossfire Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:7 title "Daimonin Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 1:9 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 1:10 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 1:11 title "Complete Code (excluding textedit)" with lines Added: trunk/src/mergeMetrics4.gpl =================================================================== --- trunk/src/mergeMetrics4.gpl (rev 0) +++ trunk/src/mergeMetrics4.gpl 2007-01-03 02:31:08 UTC (rev 1419) @@ -0,0 +1,18 @@ +set grid +set nologscale x +set nologscale y +set xlabel 'time' +set ylabel 'sloc' +set title 'Gridarta Merge Statistics (including and excluding textedit)' +set key below +plot \ + 'mergeStatistics.dat' using 2:3 title "Merged Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:4 title "Merged Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 2:5 title "Crossfire Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:6 title "Crossfire Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 2:7 title "Daimonin Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:8 title "Daimonin Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 2:9 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 2:10 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 2:11 title "Complete Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:12 title "Complete Code (including textedit)" with lines Property changes on: trunk/src/mergeMetrics4.gpl ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/mergeMetrics5.gpl =================================================================== --- trunk/src/mergeMetrics5.gpl (rev 0) +++ trunk/src/mergeMetrics5.gpl 2007-01-03 02:31:08 UTC (rev 1419) @@ -0,0 +1,14 @@ +set grid +set nologscale x +set nologscale y +set xlabel 'time' +set ylabel 'sloc' +set title 'Gridarta Merge Statistics (including textedit)' +set key below +plot \ + 'mergeStatistics.dat' using 2:4 title "Merged Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 2:6 title "Crossfire Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 2:8 title "Daimonin Code (including textedit)" with lines, \ + 'mergeStatistics.dat' using 2:9 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 2:10 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 2:12 title "Complete Code (including textedit)" with lines Property changes on: trunk/src/mergeMetrics5.gpl ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/mergeMetrics6.gpl =================================================================== --- trunk/src/mergeMetrics6.gpl (rev 0) +++ trunk/src/mergeMetrics6.gpl 2007-01-03 02:31:08 UTC (rev 1419) @@ -0,0 +1,14 @@ +set grid +set nologscale x +set nologscale y +set xlabel 'time' +set ylabel 'sloc' +set title 'Gridarta Merge Statistics (excluding textedit)' +set key below +plot \ + 'mergeStatistics.dat' using 2:3 title "Merged Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:5 title "Crossfire Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:7 title "Daimonin Code (excluding textedit)" with lines, \ + 'mergeStatistics.dat' using 2:9 title "Crossfire diff to Daimonin" with lines, \ + 'mergeStatistics.dat' using 2:10 title "Daimonin diff to Crossfire" with lines, \ + 'mergeStatistics.dat' using 2:11 title "Complete Code (excluding textedit)" with lines Property changes on: trunk/src/mergeMetrics6.gpl ___________________________________________________________________ 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...> - 2007-01-03 23:41:06
|
Revision: 1420 http://svn.sourceforge.net/gridarta/?rev=1420&view=rev Author: christianhujer Date: 2007-01-03 15:41:03 -0800 (Wed, 03 Jan 2007) Log Message: ----------- Added support for collecting duplicate archetypes and display one message for all instead of a single message for each of them. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/messages.properties Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-03 02:31:08 UTC (rev 1419) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-03 23:41:03 UTC (rev 1420) @@ -119,6 +119,7 @@ return faceListCount; } + /** {@inheritDoc} */ @Override protected void handleDuplicate(final GameObject archetype) { log.warn("addArchToList: duplicate archetype '" + archetype.getArchetypeName() + "'"); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-03 02:31:08 UTC (rev 1419) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-03 23:41:03 UTC (rev 1420) @@ -46,7 +46,9 @@ import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; +import java.util.IdentityHashMap; import java.util.List; +import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationParseException; @@ -80,6 +82,13 @@ private List<File> animFiles; /** + * The duplicate arches. + * Stored for the error message. + * An IdentityHashMap is used because in future, GameObjects or Archetypes might use equals() / hashCode(). + */ + private final Map<GameObject, File> duplicateArches = new IdentityHashMap<GameObject, File>(); + + /** * Create the ArchetypeSet. * @param mainControl reference to CMainControl */ @@ -118,8 +127,10 @@ return face; } + /** {@inheritDoc} */ @Override protected void handleDuplicate(final GameObject archetype) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateArch", archetype.getArchetypeName(), currentFile); + log.warn("addArchToList: duplicate archetype '" + archetype.getArchetypeName() + "'"); + duplicateArches.put(archetype, currentFile); //throw new DuplicateArchetypeException(data); } @@ -145,6 +156,18 @@ animFiles = new ArrayList<File>(); loadArchetypesFromFiles(new File(mainControl.getArchDefaultFolder()), 0, "default", "default", false); // load arches & images from individual files loadAnimsFromFiles(); + if (!duplicateArches.isEmpty()) { + final StringBuilder duplicateArchesText = new StringBuilder(); + for (final Map.Entry<GameObject, File> duplicateEntry : duplicateArches.entrySet()) { + duplicateArchesText + .append(duplicateEntry.getKey().getArchetypeName()) + .append('(') + .append(duplicateEntry.getValue()) + .append(")\n"); + } + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateArch", duplicateArchesText); + duplicateArches.clear(); + } } loadArchesFromArtifacts(mainControl.getArchDefaultFolder() + "/" + IGUIConstants.ARTIFACTS_FILE, "Artifacts", "artifacts"); Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2007-01-03 02:31:08 UTC (rev 1419) +++ trunk/daimonin/src/daieditor/messages.properties 2007-01-03 23:41:03 UTC (rev 1420) @@ -94,7 +94,7 @@ loadDuplicateFace.title=Error: Duplicate face loadDuplicateFace.message=Warning!\n\nDuplicate face: ''{0}''\nFile: ''{1}''\nI will ignore this duplicate. loadDuplicateArch.title=Error: Duplicate arch -loadDuplicateArch.message=Warning!\n\nDuplicate arch: ''{0}''\nFile: ''{1}''\nI will ignore this duplicate. +loadDuplicateArch.message=Warning!\n\nDuplicate arches:\n{0}\nI will ignore these duplicates. # Treasure lists treasurelistForbidden.title=Invalid Selection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-04 17:06:44
|
Revision: 1423 http://svn.sourceforge.net/gridarta/?rev=1423&view=rev Author: christianhujer Date: 2007-01-04 09:06:43 -0800 (Thu, 04 Jan 2007) Log Message: ----------- Improved Map I/O code preventing NullPointerExceptions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/io/CMapReader.java trunk/crossfire/src/cfeditor/io/CMapWriter.java trunk/daimonin/src/daieditor/io/CMapReader.java trunk/daimonin/src/daieditor/io/CMapWriter.java trunk/src/app/net/sf/gridarta/io/AbstractMapReader.java trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java trunk/src/app/net/sf/gridarta/io/MapReader.java Modified: trunk/crossfire/src/cfeditor/io/CMapReader.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapReader.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/crossfire/src/cfeditor/io/CMapReader.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -32,6 +32,7 @@ import net.sf.gridarta.io.AbstractMapReader; import net.sf.gridarta.io.MapReader; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -67,7 +68,7 @@ } /** {@inheritDoc} */ - @Override protected MapArchObject createMapArchObject() { + @NotNull @Override protected MapArchObject createMapArchObject() { return new MapArchObject(); } @@ -77,7 +78,7 @@ * WARNING: this implementation should fail with multi head settings * if there are multi part items in the inventory (but this is not yet * included in CF!) - * @param thisLine first line of text, belonging to this new arch + * @param firstLine first line of text, belonging to this new arch * @return the new parsed <code>GameObject</code> * @throws IOException when an I/O-error occured during file reading * @fixme I'm too long, make me shorter. @@ -86,7 +87,8 @@ * @todo Find out whether effectively also trimming msg contents didn't break anything. */ // Note for programmers from Daimonin: Crossfire still has to support "More" which was used for multipart objects in the past. - @Override @Nullable protected GameObject readArch(String thisLine) throws IOException { + @Override @Nullable protected GameObject readArch(@NotNull final String firstLine) throws IOException { + String thisLine = firstLine; boolean msgflag = false; boolean archflag = false; boolean archmore = false; @@ -123,7 +125,9 @@ if (log.isDebugEnabled()) { log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); } - gameObject.addLast(readArch(thisLine)); + final GameObject invItem = readArch(thisLine); + assert invItem != null : "invItem must not be null here."; // That' assumed because thisLine.startsWith("arch ") + gameObject.addLast(invItem); if (log.isDebugEnabled()) { log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); } Modified: trunk/crossfire/src/cfeditor/io/CMapWriter.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapWriter.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/crossfire/src/cfeditor/io/CMapWriter.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -69,7 +69,7 @@ * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) * @throws IOException in case of I/O problems */ - @Override protected void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { + @Override protected void writeGameObject(@NotNull final GameObject gameObject, final int x, final int y) throws IOException { final Archetype<GameObject> archetype = gameObject.getArchetype(); // Collect all fields to write. @@ -100,15 +100,9 @@ } } - if (gameObject.getMsgText() != null && !gameObject.getMsgText().trim().equals((archetype == null || archetype.getMsgText() == null) ? "" : archetype.getMsgText().trim())) { - String msg = ""; - if (gameObject.getMsgText().trim().length() > 0) { - msg = gameObject.getMsgText(); - if (!msg.endsWith("\n")) { - msg += "\n"; - } - } - fields.put("msg", msg + "endmsg"); + final String msgText = gameObject.getMsgText(); + if (msgText != null && !msgText.trim().equals((archetype == null || archetype.getMsgText() == null) ? "" : archetype.getMsgText().trim())) { + fields.put("msg", String.format("%s%sendmsg", msgText, msgText.endsWith("\n") ? "" : "\n")); } if (archetype != null && gameObject.getArchTypNr() != archetype.getArchTypNr()) { @@ -120,7 +114,7 @@ // open a reading stream for the archText final StringReader sread = new StringReader(gameObject.getObjectText()); final BufferedReader sstream = new BufferedReader(sread); - String newArchtext = ""; + final StringBuilder newArchText = new StringBuilder(); try { for (String line; (line = sstream.readLine()) != null && line.length() > 0;) { @@ -129,7 +123,7 @@ if (line.startsWith("type ")) { // ommit this line } else { - newArchtext += line + "\n"; // append this line + newArchText.append(line).append('\n'); // append this line } } @@ -137,6 +131,7 @@ sstream.close(); sread.close(); + final String newArchtext = newArchText.toString(); if (newArchtext.trim().length() == 0) { gameObject.setObjectText(""); } else { Modified: trunk/daimonin/src/daieditor/io/CMapReader.java =================================================================== --- trunk/daimonin/src/daieditor/io/CMapReader.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/daimonin/src/daieditor/io/CMapReader.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -56,7 +56,7 @@ * @param uri URI of resource to open. * @throws FileNotFoundException in case the resource was not found. */ - public CMapReader(final String uri) throws FileNotFoundException { + public CMapReader(@NotNull final String uri) throws FileNotFoundException { super(uri); } @@ -65,17 +65,17 @@ * @param file File to open. * @throws FileNotFoundException in case the file was not found. */ - public CMapReader(final File file) throws FileNotFoundException { + public CMapReader(@NotNull final File file) throws FileNotFoundException { super(file); } /** {@inheritDoc} */ - @Override protected MapArchObject createMapArchObject() { + @NotNull @Override protected MapArchObject createMapArchObject() { return new MapArchObject(); } /** {@inheritDoc} */ - @Override @NotNull public List<GameObject> decodeMapFile() throws IOException { + @NotNull @Override public List<GameObject> decodeMapFile() throws IOException { final List<GameObject> objects = super.decodeMapFile(); CMainControl.getInstance().collectTempList(objects, uri); CMainControl.getInstance().getArchetypeParser().sortTempList(objects); @@ -88,14 +88,15 @@ * WARNING: this implementation should fail with multi head settings * if there are multi part items in the inventory (but this is not yet * included in CF!) - * @param thisLine first line of text, belonging to this new arch + * @param firstLine first line of text, belonging to this new arch * @return the new parsed <code>GameObject</code> * @throws IOException when an I/O-error occured during file reading * @fixme I'm too long, make me shorter. * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. */ // Note for programmers from Crossfire: Daimonin need not support "More". - @Override @Nullable protected GameObject readArch(String thisLine) throws IOException { + @Override @Nullable protected GameObject readArch(@NotNull final String firstLine) throws IOException { + String thisLine = firstLine; boolean msgflag = false; boolean archflag = false; GameObject gameObject = null; @@ -127,7 +128,9 @@ if (log.isDebugEnabled()) { log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); } - gameObject.addLast(readArch(thisLine)); + final GameObject invItem = readArch(thisLine); + assert invItem != null : "invItem must not be null here."; // That' assumed because thisLine.startsWith("arch ") + gameObject.addLast(invItem); if (log.isDebugEnabled()) { log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); } Modified: trunk/daimonin/src/daieditor/io/CMapWriter.java =================================================================== --- trunk/daimonin/src/daieditor/io/CMapWriter.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/daimonin/src/daieditor/io/CMapWriter.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -71,7 +71,7 @@ * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) * @throws IOException in case of I/O problems */ - @Override protected void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { + @Override protected void writeGameObject(@NotNull final GameObject gameObject, final int x, final int y) throws IOException { final Archetype<GameObject> archetype = gameObject.getArchetype(); // ok, we start with the standard parts... this is valid for all types @@ -86,7 +86,8 @@ // } final String msgText = gameObject.getMsgText(); - if (msgText != null && !msgText.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + final String archMsgText = archetype.getMsgText(); + if (msgText != null && !msgText.trim().equals(archMsgText == null ? "" : archMsgText.trim())) { format.format("msg\n%s%sendmsg\n", msgText, msgText.endsWith("\n") ? "" : "\n"); } Modified: trunk/src/app/net/sf/gridarta/io/AbstractMapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapReader.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapReader.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -21,23 +21,23 @@ public abstract class AbstractMapReader<G extends GameObject, A extends MapArchObject> implements MapReader<G, A> { /** ArchObjects that are read from the map. */ - protected final List<G> objects = new ArrayList<G>(); + @NotNull protected final List<G> objects = new ArrayList<G>(); /** Contains the map arch (see MapArchObject class). */ - protected A maparch; + @Nullable protected A maparch; /** The reader to read from. */ - private final BufferedReader myInput; + @NotNull private final BufferedReader myInput; /** The uri to read from. */ - protected final String uri; + @NotNull protected final String uri; /** * Open a resource for reading it as a map. * @param uri URI of resource to open. * @throws FileNotFoundException in case the resource was not found. */ - protected AbstractMapReader(final String uri) throws FileNotFoundException { + protected AbstractMapReader(@NotNull final String uri) throws FileNotFoundException { this.uri = uri; try { myInput = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(uri), IOUtils.MAP_ENCODING)); @@ -52,7 +52,7 @@ * @param file File to open. * @throws FileNotFoundException in case the file was not found. */ - protected AbstractMapReader(final File file) throws FileNotFoundException { + protected AbstractMapReader(@NotNull final File file) throws FileNotFoundException { this.uri = file.toURI().toString(); try { myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); @@ -68,7 +68,10 @@ } /** {@inheritDoc} */ - public final A getMapArch() { + @NotNull public final A getMapArch() { + if (maparch == null) { + throw new IllegalStateException("Map Arch not read yet."); + } return maparch; } @@ -77,7 +80,7 @@ * Implement this method to supply the appropriate MapArchObject implementation. * @return A newly created MapArchObject. */ - protected abstract A createMapArchObject(); + @NotNull protected abstract A createMapArchObject(); /** {@inheritDoc} */ @NotNull public List<G> decodeMapFile() throws IOException { @@ -102,11 +105,11 @@ * WARNING: this implementation should fail with multi head settings * if there are multi part items in the inventory (but this is not yet * included in CF!) - * @param thisLine first line of text, belonging to this new arch + * @param firstLine first line of text, belonging to this new arch * @return the new parsed <code>GameObject</code> * @throws IOException when an I/O-error occured during file reading */ - @Nullable protected abstract GameObject readArch(String thisLine) throws IOException; + @Nullable protected abstract GameObject readArch(@NotNull String firstLine) throws IOException; /** * Reads a single line. Modified: trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -31,7 +31,7 @@ * @param uri URI of resource to open. * @throws FileNotFoundException in case the resource couldn't be opened for writing */ - protected AbstractMapWriter(final String uri) throws FileNotFoundException { + protected AbstractMapWriter(@NotNull final String uri) throws FileNotFoundException { this.uri = uri; try { myOutput = new PrintWriter(new OutputStreamWriter(new FileOutputStream(uri), IOUtils.MAP_ENCODING)); @@ -46,7 +46,7 @@ * @param file File to open. * @throws FileNotFoundException in case the file couldn't be opened for writing */ - protected AbstractMapWriter(final File file) throws FileNotFoundException { + protected AbstractMapWriter(@NotNull final File file) throws FileNotFoundException { this.uri = file.toURI().toString(); try { myOutput = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), IOUtils.MAP_ENCODING)); @@ -104,7 +104,7 @@ * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) * @throws IOException in case of I/O problems */ - protected abstract void writeGameObject(final G gameObject, final int x, final int y) throws IOException; + protected abstract void writeGameObject(@NotNull final G gameObject, final int x, final int y) throws IOException; /** {@inheritDoc} */ public final void close() throws IOException { @@ -112,19 +112,19 @@ } /** {@inheritDoc} */ - public final Appendable append(final CharSequence csq) throws IOException { + @NotNull public final Appendable append(@NotNull final CharSequence csq) throws IOException { myOutput.append(csq); return this; } /** {@inheritDoc} */ - public final Appendable append(final CharSequence csq, final int start, final int end) throws IOException { + @NotNull public final Appendable append(@NotNull final CharSequence csq, final int start, final int end) throws IOException { myOutput.append(csq, start, end); return this; } /** {@inheritDoc} */ - public final Appendable append(final char c) throws IOException { + @NotNull public final Appendable append(final char c) throws IOException { myOutput.append(c); return this; } Modified: trunk/src/app/net/sf/gridarta/io/MapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapReader.java 2007-01-04 00:40:59 UTC (rev 1422) +++ trunk/src/app/net/sf/gridarta/io/MapReader.java 2007-01-04 17:06:43 UTC (rev 1423) @@ -17,8 +17,9 @@ * Returns the MapArchObject read from this MapFileDecode. * @note The MapArchObject will only contain reasonable data after {@link #decodeMapFile()} has been called. * @return The MapArchObject read from this MapFileDecode. + * @throws IllegalStateException in case the map arch hasn't been read yet. */ - A getMapArch(); + @NotNull A getMapArch(); /** * Loads a map from the given mapfile. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-04 19:48:39
|
Revision: 1427 http://svn.sourceforge.net/gridarta/?rev=1427&view=rev Author: akirschbaum Date: 2007-01-04 11:48:38 -0800 (Thu, 04 Jan 2007) Log Message: ----------- Do not crash for missing/broken types.xml file. 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 2007-01-04 19:47:30 UTC (rev 1426) +++ trunk/crossfire/src/cfeditor/gui/ObjectChoiceDisplay.java 2007-01-04 19:48:38 UTC (rev 1427) @@ -135,7 +135,7 @@ archArchNameText.setText(headObject.getArchetypeName()); final CFArchType archType = mainControl.getTypeList().getType(headObject); - archTypeText.setText(archType.getTypeName() + " (" + archType.getTypeNr() + ')'); + archTypeText.setText(archType == null ? "(unknown)" : archType.getTypeName() + " (" + archType.getTypeNr() + ')'); if (headObject.isMulti()) { archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + ',' + headObject.getSizeY() + ")</html>"); Modified: trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java 2007-01-04 19:47:30 UTC (rev 1426) +++ trunk/daimonin/src/daieditor/gui/ObjectChoiceDisplay.java 2007-01-04 19:48:38 UTC (rev 1427) @@ -140,7 +140,7 @@ archArchNameText.setText(headObject.getArchetypeName()); final CFArchType archType = mainControl.getTypeList().getType(headObject); - archTypeText.setText(archType.getTypeName() + " (" + archType.getTypeNr() + ')'); + archTypeText.setText(archType == null ? "(unknown)" : archType.getTypeName() + " (" + archType.getTypeNr() + ')'); if (headObject.isMulti()) { archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + ',' + headObject.getSizeY() + ")</html>"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-04 19:53:48
|
Revision: 1428 http://svn.sourceforge.net/gridarta/?rev=1428&view=rev Author: akirschbaum Date: 2007-01-04 11:53:45 -0800 (Thu, 04 Jan 2007) Log Message: ----------- Fix typo (types.xml instead of types.txt). Modified Paths: -------------- trunk/crossfire/resource/HelpFiles/tut_objects.html trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/CFArchTypeList.java trunk/src/app/net/sf/gridarta/messages.properties Modified: trunk/crossfire/resource/HelpFiles/tut_objects.html =================================================================== --- trunk/crossfire/resource/HelpFiles/tut_objects.html 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/crossfire/resource/HelpFiles/tut_objects.html 2007-01-04 19:53:45 UTC (rev 1428) @@ -27,7 +27,7 @@ graphical user interface.<br> Keep in mind that the syntax definitions for this entire thing are written in well-readable plain text. So if you notice that some attribute is wrong, - or missing, I strongly recommed you trying to edit the definitions file: "types.txt".<br><br> + or missing, I strongly recommed you trying to edit the definitions file: "types.xml".<br><br> <IMG SRC="attrib_window.jpg" WIDTH="298" HEIGHT="352" ALIGN="CENTER"> </LI></P> <P><LI><b>Modify the archtext directly</b><br> Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-04 19:53:45 UTC (rev 1428) @@ -189,7 +189,7 @@ /** Head of linked list, containing the autojoin data. */ private AutojoinList joinList = null; - /** The list of archtype-data (loaded from "types.txt"). */ + /** The list of archtype-data (loaded from "types.xml"). */ private CFArchTypeList typeList = null; /** Pickmaps cannot be edited while lockedPickmaps is true. */ @@ -258,7 +258,7 @@ animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); - // load the list with archtype-data from "types.txt" + // load the list with archtype-data from "types.xml" typeList = new CFArchTypeList(); net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject @@ -1004,7 +1004,7 @@ */ public void openAttrDialog(final GameObject gameObject) { if (typeList.isEmpty()) { - // types.txt is missing! + // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && gameObject.hasArchetype()) { GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this); Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-04 19:53:45 UTC (rev 1428) @@ -39,7 +39,7 @@ openFileWantedOutOfMemory.message=Es ist nicht gen\xFCgend freier Speicher vorhanden, um die\nKarte {0} zu laden. openAttrDialogNoTypes.title=Datei fehlt -openAttrDialogNoTypes.message=Die Konfigurationsdatei \"types.txt\" fehlt. Der Dialog zum \xC4ndern von Object-Attributen funktioniert nicht ohne diese Datei. +openAttrDialogNoTypes.message=Die Konfigurationsdatei \"types.xml\" fehlt. Der Dialog zum \xC4ndern von Object-Attributen funktioniert nicht ohne diese Datei. openAttrDialogNoDefaultArch.title=Attribute \xE4ndern openAttrDialogNoDefaultArch.message=Attribute von Objekten ohne Archetype k\xF6nnen nicht ge\xE4ndert werden. encodeMapFile.title=Fehler beim Sichern Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2007-01-04 19:53:45 UTC (rev 1428) @@ -30,7 +30,7 @@ openFileWantedNoArches.message=Det finns inga arketyper (arches) tillg\xE4ngliga!\nDu m\xE5ste ha arketyperna innan du kan \xF6ppna en karta.\nL\xE4s i online-dokumentationen hur du kan skaffa Daimonins arketypfiler.. openAttrDialogNoTypes.title=Fil saknas -openAttrDialogNoTypes.message=Defintionsfilen \"types.txt\" saknas!\nAttribut-gr\xE4nssnittet fungerar inte utan den filen. +openAttrDialogNoTypes.message=Defintionsfilen \"types.xml\" saknas!\nAttribut-gr\xE4nssnittet fungerar inte utan den filen. openAttrDialogNoDefaultArch.title=Ingen standardarketyp openAttrDialogNoDefaultArch.message=\xC4ndring av objektattribut utan tillg\xE5ng till standardarketyp \xE4r inte m\xF6jligt. encodeMapFile.title=Misslyckades att spara karta Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-04 19:53:45 UTC (rev 1428) @@ -267,7 +267,7 @@ /** Buffer managing copy data. */ private final CopyBuffer copybuffer = new CopyBuffer(this); - /** The list of archtype-data (loaded from "types.txt"). */ + /** The list of archtype-data (loaded from "types.xml"). */ private CFArchTypeList typeList = null; /** Pickmaps cannot be edited while lockedPickmaps is true. */ @@ -434,7 +434,7 @@ animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); - // load the list with archtype-data from "types.txt" + // load the list with archtype-data from "types.xml" typeList = new CFArchTypeList(); net.sf.gridarta.gameobject.GameObject.setTypeList(typeList); // set reference in GameObject @@ -1232,7 +1232,7 @@ */ public void openAttrDialog(final GameObject gameObject) { if (typeList.isEmpty()) { - // types.txt is missing! + // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && gameObject.hasArchetype()) { GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this); Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2007-01-04 19:53:45 UTC (rev 1428) @@ -78,7 +78,7 @@ openFileLoadMap.title=Kunde inte \xF6ppna kartan openFileLoadMap.message={0} openAttrDialogNoTypes.title=Fil saknas -openAttrDialogNoTypes.message=Defintionsfilen \"types.txt\" saknas!\nAttribut-gr\xE4nssnittet fungerar inte utan den filen. +openAttrDialogNoTypes.message=Defintionsfilen \"types.xml\" saknas!\nAttribut-gr\xE4nssnittet fungerar inte utan den filen. openAttrDialogNoDefaultArch.title=Ingen standardarketyp openAttrDialogNoDefaultArch.message=\xC4ndring av objektattribut utan tillg\xE5ng till standardarketyp \xE4r inte m\xF6jligt. encodeMapFile.title=Misslyckades att spara karta Modified: trunk/src/app/net/sf/gridarta/CFArchTypeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2007-01-04 19:53:45 UTC (rev 1428) @@ -298,7 +298,7 @@ /** * Find and return the type-structure (<code>CFArchType</code>) that * matches the given 'typeName'. These type-names are "artificial" - * names, defined in "types.txt". They appear in the type selection box + * names, defined in "types.xml". They appear in the type selection box * in the attribute-dialog. * @param typeName Name of the type to get. * @return the <code>CFArchType</code> that matches, Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2007-01-04 19:48:38 UTC (rev 1427) +++ trunk/src/app/net/sf/gridarta/messages.properties 2007-01-04 19:53:45 UTC (rev 1428) @@ -49,7 +49,7 @@ openPickmapNoPickmaps.message=There are no pickmaps. openAttrDialogNoTypes.title=File missing -openAttrDialogNoTypes.message=The definitions-file \"types.txt\" is missing! The\nattribute interface doesn''t work without that file. +openAttrDialogNoTypes.message=The definitions-file \"types.xml\" is missing! The\nattribute interface doesn''t work without that file. openAttrDialogNoDefaultArch.title=No default arch openAttrDialogNoDefaultArch.message=Changing attributes of arches without archetype is not supported. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-04 20:12:16
|
Revision: 1429 http://svn.sourceforge.net/gridarta/?rev=1429&view=rev Author: christianhujer Date: 2007-01-04 12:12:16 -0800 (Thu, 04 Jan 2007) Log Message: ----------- Updated merge stats generation. Now includes proper dates in diagrams. Modified Paths: -------------- trunk/mergeProgressHistory.sh trunk/src/mergeMetrics4.gpl trunk/src/mergeMetrics5.gpl trunk/src/mergeMetrics6.gpl Modified: trunk/mergeProgressHistory.sh =================================================================== --- trunk/mergeProgressHistory.sh 2007-01-04 19:53:45 UTC (rev 1428) +++ trunk/mergeProgressHistory.sh 2007-01-04 20:12:16 UTC (rev 1429) @@ -14,14 +14,14 @@ svn up -q -r $i echo -ne "\r" $i/$recent ( - find src/app -name "*.java" >common_src + find src/app src/test -name "*.java" >common_src find crossfire/src -name "*.java" >crossfire_src find daimonin/src -name "*.java" >daimonin_src cat common_src crossfire_src daimonin_src >all_src diff -r -d -w -N -I '^package' -I '^import' -x '.svn' crossfire/src/cfeditor daimonin/src/daieditor >differences echo -n $i echo -n ' ' - echo -n $(ls -rtl --time-style '+%s' repoBackup/db/revs/$i | cut -c 33-42) + echo -n $(stat -c '%Y' ../repoBackup/db/revs/$i) echo -n ' ' echo -n $(<common_src grep -v textedit | xargs cat | wc -l) echo -n ' ' Modified: trunk/src/mergeMetrics4.gpl =================================================================== --- trunk/src/mergeMetrics4.gpl 2007-01-04 19:53:45 UTC (rev 1428) +++ trunk/src/mergeMetrics4.gpl 2007-01-04 20:12:16 UTC (rev 1429) @@ -3,6 +3,9 @@ set nologscale y set xlabel 'time' set ylabel 'sloc' +set xdata time +set timefmt "%s" +set format x "%Y-%m-%d" set title 'Gridarta Merge Statistics (including and excluding textedit)' set key below plot \ Modified: trunk/src/mergeMetrics5.gpl =================================================================== --- trunk/src/mergeMetrics5.gpl 2007-01-04 19:53:45 UTC (rev 1428) +++ trunk/src/mergeMetrics5.gpl 2007-01-04 20:12:16 UTC (rev 1429) @@ -3,6 +3,9 @@ set nologscale y set xlabel 'time' set ylabel 'sloc' +set xdata time +set timefmt "%s" +set format x "%Y-%m-%d" set title 'Gridarta Merge Statistics (including textedit)' set key below plot \ Modified: trunk/src/mergeMetrics6.gpl =================================================================== --- trunk/src/mergeMetrics6.gpl 2007-01-04 19:53:45 UTC (rev 1428) +++ trunk/src/mergeMetrics6.gpl 2007-01-04 20:12:16 UTC (rev 1429) @@ -3,6 +3,9 @@ set nologscale y set xlabel 'time' set ylabel 'sloc' +set xdata time +set timefmt "%s" +set format x "%Y-%m-%d" set title 'Gridarta Merge Statistics (excluding textedit)' set key below plot \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |