You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2010-07-05 23:10:39
|
Revision: 8584 http://gridarta.svn.sourceforge.net/gridarta/?rev=8584&view=rev Author: akirschbaum Date: 2010-07-05 22:02:08 +0000 (Mon, 05 Jul 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java Modified: trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java 2010-07-05 21:57:18 UTC (rev 8583) +++ trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java 2010-07-05 22:02:08 UTC (rev 8584) @@ -131,21 +131,22 @@ * @return new editType for this GameObject */ public int calculateEditType2(@NotNull final GameObject<?, ?, ?> gameObject, final int checkType) { + final int editType = gameObject.getEditType(); if (checkType == 0) { - return gameObject.getEditType(); + return editType; } int newEditType; - if (gameObject.getEditType() != GUIConstants.EDIT_TYPE_NONE && gameObject.getEditType() != 0) { + if (editType != GUIConstants.EDIT_TYPE_NONE && editType != 0) { // all flags from 'checkType' must be unset in this arch because they get recalculated now - newEditType = gameObject.getEditType() & ~checkType; + newEditType = editType & ~checkType; } else { newEditType = 0; } newEditType |= calculateEditType(gameObject, checkType); gameObject.setEditType(newEditType); - return gameObject.getEditType(); + return newEditType; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-05 23:10:33
|
Revision: 8582 http://gridarta.svn.sourceforge.net/gridarta/?rev=8582&view=rev Author: akirschbaum Date: 2010-07-05 21:53:46 +0000 (Mon, 05 Jul 2010) Log Message: ----------- Fix unchecked warning. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/script/parameter/MapParameter.java Modified: trunk/src/app/net/sf/gridarta/script/parameter/MapParameter.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/parameter/MapParameter.java 2010-07-05 16:34:13 UTC (rev 8581) +++ trunk/src/app/net/sf/gridarta/script/parameter/MapParameter.java 2010-07-05 21:53:46 UTC (rev 8582) @@ -95,7 +95,7 @@ if (value == null) { return super.setValue(null); } else { - final MapControl<G, A, R> map = (MapControl<G, A, R>) value; + final MapControl<?, ?, ?> map = (MapControl<?, ?, ?>) value; return super.setValue(map.getMapModel().getMapArchObject().getMapName()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-05 23:10:21
|
Revision: 8583 http://gridarta.svn.sourceforge.net/gridarta/?rev=8583&view=rev Author: akirschbaum Date: 2010-07-05 21:57:18 +0000 (Mon, 05 Jul 2010) Log Message: ----------- Fix options for 'unchecked warnings' profile. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-07-05 21:53:46 UTC (rev 8582) +++ trunk/gridarta.ipr 2010-07-05 21:57:18 UTC (rev 8583) @@ -623,11 +623,13 @@ <option name="myName" value="unchecked warnings" /> <option name="myLocal" value="false" /> <inspection_tool class="AccessStaticViaInstance" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="Annotator" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="AntDuplicateImportedTargetsInspection" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AntDuplicateTargetsInspection" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="AntMissingPropertiesFileInspection" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="ArrayEquals" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="AssertEqualsBetweenInconvertibleTypes" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="AssertWithSideEffects" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="BooleanConstructor" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="BooleanMethodIsAlwaysInverted" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CanBeFinal" enabled="false" level="WARNING" enabled_by_default="false"> @@ -643,6 +645,7 @@ <inspection_tool class="CheckTagEmptyBody" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CheckValidXmlInScriptTagBody" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="CheckXmlFileWithXercesValidator" enabled="false" level="ERROR" enabled_by_default="false" /> + <inspection_tool class="ClassInitializerMayBeStatic" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CloneCallsSuperClone" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CloneDeclaresCloneNotSupported" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ComparatorMethodParameterNotUsed" enabled="false" level="WARNING" enabled_by_default="false" /> @@ -654,6 +657,7 @@ <inspection_tool class="ConstantIfStatement" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ContinueOrBreakFromFinallyBlock" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CssInvalidElementInspection" enabled="false" level="ERROR" enabled_by_default="false" /> + <inspection_tool class="CssInvalidHtmlTagReferenceInspection" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CssInvalidImportInspection" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="CssInvalidShorthandPropertyValue" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="CssNegativeValueInspection" enabled="false" level="ERROR" enabled_by_default="false" /> @@ -730,6 +734,7 @@ <inspection_tool class="HardwiredNamespacePrefix" level="WARNING" enabled="false" /> <inspection_tool class="HtmlDeprecatedTag" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="HtmlExtraClosingTag" enabled="false" level="ERROR" enabled_by_default="false" /> + <inspection_tool class="HtmlFormInputWithoutLabel" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="HtmlPresentationalElement" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="HtmlUnknownAttribute" enabled="false" level="WARNING" enabled_by_default="false"> <option name="myValues"> @@ -816,6 +821,7 @@ <inspection_tool class="MalformedXPath" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ManualArrayCopy" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ManualArrayToCollectionCopy" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="MavenModelInspection" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="MethodNameSameAsClassName" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="MismatchedArrayReadWrite" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="MismatchedCollectionQueryUpdate" enabled="false" level="WARNING" enabled_by_default="false" /> @@ -832,8 +838,10 @@ <option name="REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS" value="true" /> </inspection_tool> <inspection_tool class="NumberEquality" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="NumericOverflow" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ObjectEqualsNull" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="OctalLiteral" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="OrredNotEqualExpression" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="PointlessArithmeticExpression" enabled="false" level="WARNING" enabled_by_default="false"> <option name="m_ignoreExpressionsContainingConstants" value="false" /> </inspection_tool> @@ -844,6 +852,10 @@ <option name="m_ignoreExpressionsContainingConstants" value="false" /> </inspection_tool> <inspection_tool class="PrimitiveArrayArgumentToVariableArgMethod" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="RawUseOfParameterizedType" enabled="true" level="WARNING" enabled_by_default="true"> + <option name="ignoreObjectConstruction" value="true" /> + <option name="ignoreTypeCasts" value="false" /> + </inspection_tool> <inspection_tool class="RedundantArrayCreation" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="RedundantCast" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="RedundantThrows" enabled="false" level="WARNING" enabled_by_default="false" /> @@ -863,6 +875,11 @@ <inspection_tool class="SillyAssignment" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="SimplifiableConditionalExpression" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="SimplifiableIfStatement" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false"> + <option name="processCode" value="true" /> + <option name="processLiterals" value="true" /> + <option name="processComments" value="true" /> + </inspection_tool> <inspection_tool class="StringConcatenationInsideStringBufferAppend" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="StringConstructor" enabled="false" level="WARNING" enabled_by_default="false"> <option name="ignoreSubstringArguments" value="false" /> @@ -883,6 +900,7 @@ <option name="reportMethodParameters" value="true" /> </inspection_tool> <inspection_tool class="SynchronizeOnNonFinalField" enabled="false" level="WARNING" enabled_by_default="false" /> + <inspection_tool class="SyntaxError" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="ThrowFromFinallyBlock" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ThrowableInstanceNeverThrown" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="ThrowableResultOfMethodCallIgnored" enabled="false" level="WARNING" enabled_by_default="false" /> @@ -948,6 +966,7 @@ <inspection_tool class="WhileCanBeForeach" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="WrongPackageStatement" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="XmlDuplicatedId" enabled="false" level="ERROR" enabled_by_default="false" /> + <inspection_tool class="XmlHighlighting" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="XmlUnboundNsPrefix" enabled="false" level="WARNING" enabled_by_default="false" /> <inspection_tool class="XmlWrongClosingTagName" level="ERROR" enabled="false" /> <inspection_tool class="XmlWrongRootElement" enabled="false" level="ERROR" enabled_by_default="false" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-05 22:13:12
|
Revision: 8586 http://gridarta.svn.sourceforge.net/gridarta/?rev=8586&view=rev Author: akirschbaum Date: 2010-07-05 22:13:05 +0000 (Mon, 05 Jul 2010) Log Message: ----------- Remove NamedGameObjectMatcher.calculateEditType(). Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java trunk/model/src/app/net/sf/gridarta/model/match/NamedGameObjectMatcher.java Modified: trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java 2010-07-05 22:05:37 UTC (rev 8585) +++ trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatchers.java 2010-07-05 22:13:05 UTC (rev 8586) @@ -152,7 +152,10 @@ private int calculateEditType(@NotNull final GameObject<?, ?, ?> gameObject, final int checkType) { int editType = 0; for (final NamedGameObjectMatcher matcher : gameObjectMatchers) { - editType |= matcher.calculateEditType(gameObject, checkType); + final int matcherEditType = matcher.getEditType(); + if ((matcherEditType & checkType) != 0 && matcher.isMatching(gameObject)) { + editType |= matcherEditType; + } } return editType; } Modified: trunk/model/src/app/net/sf/gridarta/model/match/NamedGameObjectMatcher.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/match/NamedGameObjectMatcher.java 2010-07-05 22:05:37 UTC (rev 8585) +++ trunk/model/src/app/net/sf/gridarta/model/match/NamedGameObjectMatcher.java 2010-07-05 22:13:05 UTC (rev 8586) @@ -164,14 +164,4 @@ return systemMatcher; } - /** - * Returns the edit type for a {@link GameObject}. - * @param gameObject the game object - * @param checkType the edit type to calculate - * @return the edit type - */ - public int calculateEditType(@NotNull final GameObject<?, ?, ?> gameObject, final int checkType) { - return (checkType & editType) != 0 && isMatching(gameObject) ? editType : 0; - } - } // class NamedGameObjectMatcher This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-05 16:34:20
|
Revision: 8581 http://gridarta.svn.sourceforge.net/gridarta/?rev=8581&view=rev Author: akirschbaum Date: 2010-07-05 16:34:13 +0000 (Mon, 05 Jul 2010) Log Message: ----------- Fix problems with some compiler versions. Modified Paths: -------------- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java 2010-07-03 09:56:58 UTC (rev 8580) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java 2010-07-05 16:34:13 UTC (rev 8581) @@ -282,7 +282,7 @@ * @param mapSquare the map square * @param gameObjects the game object */ - public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final TestGameObject... gameObjects) { + public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final BaseObject<?, ?, ?, ?>... gameObjects) { int i = 0; for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { final String gameObjectName = gameObject.getBestName(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-03 09:57:04
|
Revision: 8580 http://gridarta.svn.sourceforge.net/gridarta/?rev=8580&view=rev Author: akirschbaum Date: 2010-07-03 09:56:58 +0000 (Sat, 03 Jul 2010) Log Message: ----------- Update autojoin definitions for Crossfire to support alternative archetypes. Modified Paths: -------------- trunk/crossfire/resource/resource/conf/autojoin.txt Modified: trunk/crossfire/resource/resource/conf/autojoin.txt =================================================================== --- trunk/crossfire/resource/resource/conf/autojoin.txt 2010-07-03 09:55:23 UTC (rev 8579) +++ trunk/crossfire/resource/resource/conf/autojoin.txt 2010-07-03 09:56:58 UTC (rev 8580) @@ -1,14 +1,17 @@ # # autojoin.txt - This file contains data about which (wall-)arches belong -# together and in which directions they point. That is used by the -# CrossfireEditor to determine how to join walls in the autojoining mode. +# together and in which directions they point. That is used by +# Gridarta to determine how to join walls in the autojoining mode. # Feel free to modify this file to suite your needs. # # The file must be kept in the following format: # Arches of same joining type must be grouped into sections. A new section -# is started by "start", then arch names get listed, 16 total - -# one per line. The section is followed by "end". -# The arch names must be listed in the following order +# is started by "start", then arch names get listed, 16 lines total - +# at least one per line. The first archetype is the "main" archetype that +# supports autojoining. Remaining archetypes on a line are alternative variants +# that do not support autojoining. (For example, weak walls or walls with +# windows are considered alternative variants.) The section is followed by +# "end". The arch names must be listed in the following order # (0 = no connection, N = north, E = east, S = south, W = west): # # 0, N, E, NE, S, NS, ES, NES, W, WN, WE, WNE, SW, SWN, ESW, NESW @@ -24,12 +27,12 @@ awall_1_4 awall_2_2_1 awall_1_1 -awall_2_1_1 +awall_2_1_1 weak_wall_1 awall_win1 awall_2_2_2 awall_3_2 awall_1_3 awall_2_2_4 -awall_2_1_2 +awall_2_1_2 weak_wall_2 awall_win2 awall_3_1 awall_2_2_3 awall_3_4 @@ -100,12 +103,12 @@ bwall_1_4 bwall_2_2_1 bwall_1_1 -bwall_2_1_1 +bwall_2_1_1 bwall_hole_2_1_1 bwall_2_2_2 bwall_3_2 bwall_1_3 bwall_2_2_4 -bwall_2_1_2 +bwall_2_1_2 bwall_hole_2_1_2 bwall_3_1 bwall_2_2_3 bwall_3_4 @@ -116,15 +119,15 @@ start cwall_0 cwall_1_2 -cwall_1_4 +cwall_1_4 cwall_mural_end_1_2 cwall_2_2_1 cwall_1_1 -cwall_2_1_1 +cwall_2_1_1 weak_wall_3 cityport_b guard_house_1 guard_house_2 cwall_2_2_2 cwall_3_2 -cwall_1_3 +cwall_1_3 cwall_mural_end_1_1 cwall_2_2_4 -cwall_2_1_2 +cwall_2_1_2 weak_wall_4 cityport_a guard_house_3 guard_house_4 cwall_3_1 cwall_2_2_3 cwall_3_4 @@ -157,12 +160,12 @@ ewall_1_4 ewall_2_2_1 ewall_1_1 -ewall_2_1_1 +ewall_2_1_1 ewall_win1 ewall_2_2_2 ewall_3_2 ewall_1_3 ewall_2_2_4 -ewall_2_1_2 +ewall_2_1_2 ewall_win2 ewall_3_1 ewall_2_2_3 ewall_3_4 @@ -176,12 +179,12 @@ westcwall_1_4 westcwall_2_2_1 westcwall_1_1 -westcwall_2_1_1 +westcwall_2_1_1 westweak_wall_3 westcityport_b westguard_house_1 westguard_house_2 westcwall_win1 westcwall_2_2_2 westcwall_3_2 westcwall_1_3 westcwall_2_2_4 -westcwall_2_1_2 +westcwall_2_1_2 westweak_wall_4 westcityport_a westguard_house_3 westguard_house_4 westcwall_win2 westcwall_3_1 westcwall_2_2_3 westcwall_3_4 @@ -191,14 +194,14 @@ start dirtroad_0 -dirtroad_1_2 -dirtroad_1_4 +dirtroad_1_2 dirtroad_2_141 dirtroad_2_181 +dirtroad_1_4 dirtroad_2_211 dirtroad_2_281 dirtroad_2_2_1 -dirtroad_1_1 +dirtroad_1_1 dirtroad_2_411 dirtroad_2_421 dirtroad_2_1_1 dirtroad_2_2_2 dirtroad_3_2 -dirtroad_1_3 +dirtroad_1_3 dirtroad_2_821 dirtroad_2_841 dirtroad_2_2_4 dirtroad_2_1_2 dirtroad_3_1 @@ -252,12 +255,12 @@ dwall_1_4 dwall_2_2_1 dwall_1_1 -dwall_2_1_1 +dwall_2_1_1 dwall_win1 dwall_win3 dwall_2_2_2 dwall_3_2 dwall_1_3 dwall_2_2_4 -dwall_2_1_2 +dwall_2_1_2 dwall_win2 dwall_win4 dwall_3_1 dwall_2_2_3 dwall_3_4 @@ -276,7 +279,7 @@ flagstone_3_2 flagstone_1_3 flagstone_2_2_4 -flagstone_2_1_2 +flagstone_2_1_2 flagstone_win1 flagstone_3_1 flagstone_2_2_3 flagstone_3_4 @@ -480,12 +483,12 @@ stwall_1_4 stwall_2_2_1 stwall_1_1 -stwall_2_1_1 +stwall_2_1_1 stwall_door_2_1_1 stwindow_win1 stwall_2_2_2 stwall_3_2 stwall_1_3 stwall_2_2_4 -stwall_2_1_2 +stwall_2_1_2 stwall_door_1_4 stwindow_win2 stwall_3_1 stwall_2_2_3 stwall_3_4 @@ -495,14 +498,14 @@ start swall_0 -swall_1_2 -swall_1_4 +swall_1_2 swall_1_2_half +swall_1_4 swall_1_4_half swall_2_2_1 -swall_1_1 +swall_1_1 swall_1_1_half swall_2_1_1 swall_2_2_2 swall_3_2 -swall_1_3 +swall_1_3 swall_1_3_half swall_2_2_4 swall_2_1_2 swall_3_1 @@ -537,12 +540,12 @@ wall_1_4 wall_2_2_1 wall_1_1 -wall_2_1_1 +wall_2_1_1 window_win1 wall_2_2_2 wall_3_2 wall_1_3 wall_2_2_4 -wall_2_1_2 +wall_2_1_2 window_win2 wall_3_1 wall_2_2_3 wall_3_4 @@ -556,12 +559,12 @@ woodwall_1_4 woodwall_2_2_1 woodwall_1_1 -woodwall_2_1_1 +woodwall_2_1_1 woodwall_win1 woodwall_2_2_2 woodwall_3_2 woodwall_1_3 woodwall_2_2_4 -woodwall_2_1_2 +woodwall_2_1_2 woodwall_win2 woodwall_3_1 woodwall_2_2_3 woodwall_3_4 @@ -572,15 +575,15 @@ start wwall_0 wwall_1_2 -wwall_1_4 +wwall_1_4 wwall_right wwall_2_2_1 wwall_1_1 -wwall_2_1_1 +wwall_2_1_1 wwall_weak_1 wwall_win1 wwall_2_2_2 wwall_3_2 -wwall_1_3 +wwall_1_3 wwall_left wwall_2_2_4 -wwall_2_1_2 +wwall_2_1_2 wwall_weak_2 wwall_win2 wwall_3_1 wwall_2_2_3 wwall_3_4 @@ -689,12 +692,12 @@ redcwall_1_4 redcwall_2_2_1 redcwall_1_1 -redcwall_2_1_1 +redcwall_2_1_1 redweak_wall_3 redcityport_b redguard_house_1 redguard_house_2 redcwall_win1 redcwall_2_2_2 redcwall_3_2 redcwall_1_3 redcwall_2_2_4 -redcwall_2_1_2 +redcwall_2_1_2 redweak_wall_4 redcityport_a redguard_house_3 redguard_house_4 redcwall_win2 redcwall_3_1 redcwall_2_2_3 redcwall_3_4 @@ -724,15 +727,15 @@ start white_wall_0 white_wall_1_2 -white_wall_1_4 +white_wall_1_4 white_wall_right white_wall_2_2_1 -white_wall_1_1 -white_wall_2_1_1 +white_wall_1_1 white_wall_bottom +white_wall_2_1_1 white_wall_win1 white_wall_2_2_2 white_wall_3_2 -white_wall_1_3 +white_wall_1_3 white_wall_left white_wall_2_2_4 -white_wall_2_1_2 +white_wall_2_1_2 white_wall_win2 white_wall_3_1 white_wall_2_2_3 white_wall_3_4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-03 09:55:30
|
Revision: 8579 http://gridarta.svn.sourceforge.net/gridarta/?rev=8579&view=rev Author: akirschbaum Date: 2010-07-03 09:55:23 +0000 (Sat, 03 Jul 2010) Log Message: ----------- Implement #1726046 (Window handling): autojoining now supports alternative archetypes (such as windowed wall or weak walls). Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinListsParser.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/autojoin/InsertionResult.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/atrinik/ChangeLog 2010-07-03 09:55:23 UTC (rev 8579) @@ -1,3 +1,8 @@ +2010-07-03 Andreas Kirschbaum + + * Implement #1726046 (Window handling): autojoining now supports + alternative archetypes (such as windowed wall or weak walls). + 2010-06-27 Andreas Kirschbaum * Improve --script command-line option to report plugin script Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/crossfire/ChangeLog 2010-07-03 09:55:23 UTC (rev 8579) @@ -1,3 +1,8 @@ +2010-07-03 Andreas Kirschbaum + + * Implement #1726046 (Window handling): autojoining now supports + alternative archetypes (such as windowed wall or weak walls). + 2010-06-27 Andreas Kirschbaum * Improve --script command-line option to report plugin script Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/daimonin/ChangeLog 2010-07-03 09:55:23 UTC (rev 8579) @@ -1,3 +1,8 @@ +2010-07-03 Andreas Kirschbaum + + * Implement #1726046 (Window handling): autojoining now supports + alternative archetypes (such as windowed wall or weak walls). + 2010-06-27 Andreas Kirschbaum * Improve --script command-line option to report plugin script Modified: trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java 2010-07-03 09:55:23 UTC (rev 8579) @@ -21,7 +21,10 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; +import java.util.IdentityHashMap; import java.util.List; +import java.util.Map; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -62,13 +65,22 @@ public static final int WEST = 8; - // the arches' node numbers, interpreted in following order (0-15): - //index: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 - //means: 0, N, E, NE, S, NS, ES, NES, W, WN, WE, WNE, SW, SWN, ESW, NESW - // (0 = no connection, N = north, E = east, S = south, W = west) - + /** + * Maps index to list of archetypes representing autojoin-able archetypes + * for this direction. The first archetype is the main archetype that can be + * converted into other archetypes. Following archetypes are alternative + * variants that are recognized but never converted. Examples for + * alternative archetypes are walls having windows. + * <p/> + * The indices are interpreted in following order (0-15): + * <ol> + * <li>index: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15</li> + * <li>means: 0, N, E, NE, S, NS, ES, NES, W, WN, WE, WNE, SW, SWN, ESW, NESW</li> + * <li>(0 = no connection, N = north, E = east, S = south, W = west)</li> + * </ol> + */ @NotNull - private final List<R> archetypes; + private final List<List<R>> archetypes; /** * Create an AutojoinList. @@ -76,28 +88,50 @@ * @throws IllegalAutojoinListException if the autojoin list cannot be * created */ - public AutojoinList(@NotNull final List<R> archetypes) throws IllegalAutojoinListException { - final ArrayList<R> newArchetypes = new ArrayList<R>(archetypes); + public AutojoinList(@NotNull final Iterable<List<R>> archetypes) throws IllegalAutojoinListException { + final ArrayList<List<R>> newArchetypes = new ArrayList<List<R>>(); + + for (final List<R> archetypeList : archetypes) { + newArchetypes.add(validate(archetypeList)); + } + if (newArchetypes.size() > SIZE) { throw new IllegalAutojoinListException("autojoin list with more than " + SIZE + " valid entries"); } else if (newArchetypes.size() < SIZE) { throw new IllegalAutojoinListException("autojoin list with less than " + SIZE + " valid entries"); } - //final Map<R, R> tmp = new IdentityHashMap<R, R>(); - for (final R archetype : newArchetypes) { + newArchetypes.trimToSize(); + this.archetypes = newArchetypes; + } + + /** + * Validates a list of archetypes: no entry must be <null>, no duplicate + * entry must exist, at least one entry must exist. + * @param archetypeList the archetype list to validate + * @return a copy of the validated archetype list + * @throws IllegalAutojoinListException if a validation error was detected + */ + @NotNull + private static <R extends Archetype<?, ?, R>> List<R> validate(@NotNull final Iterable<R> archetypeList) throws IllegalAutojoinListException { + final ArrayList<R> result = new ArrayList<R>(); + final Map<R, R> tmp = new IdentityHashMap<R, R>(); + for (final R archetype : archetypeList) { if (archetype == null) { throw new IllegalArgumentException(); } - // Must not check for duplicate archetypes as Daimonin uses this. - //if (tmp.put(archetype, archetype) != null) { - // throw new IllegalAutojoinListException("autojoin list contains duplicate archetype '" + archetype.getArchetypeName() + "'"); - //} + if (tmp.put(archetype, archetype) != null) { + throw new IllegalAutojoinListException("autojoin list contains duplicate archetype '" + archetype.getArchetypeName() + "'"); + } + + result.add(archetype); } - - newArchetypes.trimToSize(); - this.archetypes = newArchetypes; + if (result.isEmpty()) { + throw new IllegalAutojoinListException("autojoin list is empty"); + } + result.trimToSize(); + return result; } /** @@ -105,9 +139,9 @@ * @param archetype node to lookup * @return index of the node in the array. */ - public int getIndex(@NotNull final Archetype<G, A, R> archetype) { + public int getIndex(@NotNull final R archetype) { for (int i = 0; i < SIZE; i++) { - if (archetypes.get(i) == archetype) { + if (archetypes.get(i).contains(archetype)) { return i; } } @@ -117,11 +151,54 @@ } /** + * Returns the index of an {@link Archetype} if it is a main archetype for + * any direction. + * @param archetype the archetype to check + * @return whether the archetype is a main archetype + */ + public boolean isMainIndex(@NotNull final R archetype) { + for (int i = 0; i < SIZE; i++) { + if (archetypes.get(i).get(0) == archetype) { + return true; + } + } + + return false; + } + + /** + * Returns the index of an {@link Archetype} if it is an alternative + * archetype for any direction. + * @param archetype the archetype to check + * @return the direction or <code>-1</code> + */ + public int getAlternativeIndex(@NotNull final R archetype) { + for (int i = 0; i < SIZE; i++) { + final List<R> tmp = archetypes.get(i); + if (tmp.get(0) != archetype && tmp.contains(archetype)) { + return i; + } + } + + return -1; + } + + /** * @noinspection TypeMayBeWeakened */ @NotNull public R getArchetype(final int index) { - return archetypes.get(index); + return archetypes.get(index).get(0); } + /** + * Returns all archetypes for an index. + * @param index the index + * @return the archetypes; the result contains at least one entry + */ + @NotNull + public Iterable<R> getArchetypes(final int index) { + return Collections.unmodifiableCollection(archetypes.get(index)); + } + } // class AutojoinList Modified: trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java 2010-07-03 09:55:23 UTC (rev 8579) @@ -75,7 +75,9 @@ } for (int i = 0; i < AutojoinList.SIZE; i++) { - autojoinLists.put(autojoinList.getArchetype(i), autojoinList); + for (final R archetype : autojoinList.getArchetypes(i)) { + autojoinLists.put(archetype, autojoinList); + } } } @@ -88,39 +90,66 @@ * @param point Location of the insert point on the map * @param archetype the archetype to connect with * @param mapModel Data model of the map - * @return the archetype to be inserted at point, or <code>null</code> if - * there's already an arch of this list on point + * @return the insertion result */ - @Nullable - public R joinInsert(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final R archetype) { + @NotNull + public InsertionResult<G, A, R> joinInsert(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final R archetype) { if (!mapViewSettings.isAutojoin()) { - return archetype; + return new InsertionResult<G, A, R>(null, archetype); } if (archetype.isMulti()) { - return archetype; + return new InsertionResult<G, A, R>(null, archetype); } final AutojoinList<G, A, R> autojoinList = autojoinLists.get(archetype); if (autojoinList == null) { - return archetype; + return new InsertionResult<G, A, R>(null, archetype); } // if there already is an arch of this list at point -> abort - if (findGameObjectOfAutojoinList(mapModel, point, autojoinList) != null) { - return null; // we don't want same arches over each other + final boolean isMainIndex = autojoinList.isMainIndex(archetype); + final G gameObject = findGameObjectOfAutojoinList(mapModel, point, autojoinList); + if (gameObject != null) { + final R gameObjectArchetype = gameObject.getArchetype(); + final boolean isExistingMainIndex = autojoinList.isMainIndex(gameObjectArchetype); + if (isMainIndex) { + // alt/main -> main + if (isExistingMainIndex) { + // ignore main -> main + return new InsertionResult<G, A, R>(null, null); // we don't want same archetypes over each other + } else { + // alt -> main -> update + } + } else { + // alt/main -> alt + if (isExistingMainIndex) { + // main -> alt -> update + } else { + // alt -> alt -> update if different archetype + if (gameObjectArchetype == archetype) { + return new InsertionResult<G, A, R>(null, null); // we don't want same archetypes over each other + } + } + } } // now do the joining in all four directions: + final int altIndex = isMainIndex ? -1 : autojoinList.getAlternativeIndex(archetype); int newIndex = 0; // return value, see above - newIndex |= joinInsert(mapModel, point, autojoinList, 0, -1, AutojoinList.NORTH, AutojoinList.SOUTH); - newIndex |= joinInsert(mapModel, point, autojoinList, +1, 0, AutojoinList.EAST, AutojoinList.WEST); - newIndex |= joinInsert(mapModel, point, autojoinList, 0, +1, AutojoinList.SOUTH, AutojoinList.NORTH); - newIndex |= joinInsert(mapModel, point, autojoinList, -1, 0, AutojoinList.WEST, AutojoinList.EAST); - return autojoinList.getArchetype(newIndex); + newIndex |= joinInsert(mapModel, point, autojoinList, 0, -1, AutojoinList.NORTH, AutojoinList.SOUTH, altIndex); + newIndex |= joinInsert(mapModel, point, autojoinList, +1, 0, AutojoinList.EAST, AutojoinList.WEST, altIndex); + newIndex |= joinInsert(mapModel, point, autojoinList, 0, +1, AutojoinList.SOUTH, AutojoinList.NORTH, altIndex); + newIndex |= joinInsert(mapModel, point, autojoinList, -1, 0, AutojoinList.WEST, AutojoinList.EAST, altIndex); + final R newArchetype = isMainIndex ? autojoinList.getArchetype(newIndex) : archetype; + if (gameObject != null) { + gameObject.setArchetype(newArchetype); + return new InsertionResult<G, A, R>(gameObject, null); + } + return new InsertionResult<G, A, R>(null, newArchetype); } - private int joinInsert(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir, final int reverseDir) { + private int joinInsert(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir, final int reverseDir, final int altIndex) { final Point tmp = new Point(point.x + dx, point.y + dy); if (!mapModel.getMapArchObject().isPointValid(tmp)) { return 0; @@ -131,7 +160,20 @@ return 0; } - gameObject.setArchetype(autojoinList.getArchetype(autojoinList.getIndex(gameObject.getArchetype()) | reverseDir)); + final R archetype = gameObject.getArchetype(); + final int index = autojoinList.getAlternativeIndex(archetype); + if (index != -1) { + return (index & reverseDir) == 0 ? 0 : dir; + } + + final int archetypeIndex = autojoinList.getIndex(archetype); + final int newIndex; + if ((altIndex & dir) == 0) { + newIndex = archetypeIndex & ~reverseDir; + } else { + newIndex = archetypeIndex | reverseDir; + } + gameObject.setArchetype(autojoinList.getArchetype(newIndex)); return dir; } @@ -144,7 +186,7 @@ * @param archetype the archetype to connect with * @param mapModel Data model of the map */ - public void joinDelete(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final Archetype<G, A, R> archetype) { + public void joinDelete(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final R archetype) { if (!mapViewSettings.isAutojoin()) { return; } @@ -158,19 +200,26 @@ return; } - joinDelete(mapModel, point, autojoinList, 0, -1, AutojoinList.SOUTH); - joinDelete(mapModel, point, autojoinList, +1, 0, AutojoinList.WEST); - joinDelete(mapModel, point, autojoinList, 0, +1, AutojoinList.NORTH); - joinDelete(mapModel, point, autojoinList, -1, 0, AutojoinList.EAST); + final boolean isMainIndex = autojoinList.isMainIndex(archetype); + final int altIndex = isMainIndex ? -1 : autojoinList.getAlternativeIndex(archetype); + + joinDelete(mapModel, point, autojoinList, 0, -1, AutojoinList.NORTH, AutojoinList.SOUTH, altIndex); + joinDelete(mapModel, point, autojoinList, +1, 0, AutojoinList.EAST, AutojoinList.WEST, altIndex); + joinDelete(mapModel, point, autojoinList, 0, +1, AutojoinList.SOUTH, AutojoinList.NORTH, altIndex); + joinDelete(mapModel, point, autojoinList, -1, 0, AutojoinList.WEST, AutojoinList.EAST, altIndex); } - private void joinDelete(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir) { + private void joinDelete(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int reverseDir, final int dir, final int altIndex) { + if ((altIndex & reverseDir) == 0) { + return; + } + final Point tmp = new Point(point.x + dx, point.y + dy); if (!mapModel.getMapArchObject().isPointValid(tmp)) { return; } - final GameObject<G, A, R> gameObject = findGameObjectOfAutojoinList(mapModel, tmp, autojoinList); + final GameObject<G, A, R> gameObject = findMainGameObjectOfAutojoinList(mapModel, tmp, autojoinList); if (gameObject == null) { return; } @@ -187,9 +236,9 @@ * @return arch which is part of this join-list, null if no such arch exists */ @Nullable - private GameObject<G, A, R> findGameObjectOfAutojoinList(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList) { + private G findGameObjectOfAutojoinList(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList) { // we look through the arches at the given location (top to bottom): - for (final GameObject<G, A, R> gameObject : mapModel.getMapSquare(point).reverse()) { + for (final G gameObject : mapModel.getMapSquare(point).reverse()) { if (autojoinLists.get(gameObject.getArchetype()) == autojoinList) { return gameObject; // we found an arch } @@ -198,4 +247,25 @@ return null; // nothing found } + /** + * Looks for an arch at map-position point which is the main archetypes part + * of an autojoin list. + * @param mapModel the map model to search + * @param point location to search + * @param autojoinList the autojoin list + * @return arch which is part of this join-list, null if no such arch exists + */ + @Nullable + private GameObject<G, A, R> findMainGameObjectOfAutojoinList(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList) { + // we look through the arches at the given location (top to bottom): + for (final GameObject<G, A, R> gameObject : mapModel.getMapSquare(point).reverse()) { + final R archetype = gameObject.getArchetype(); + if (autojoinLists.get(archetype) == autojoinList && autojoinList.isMainIndex(archetype)) { + return gameObject; // we found an arch + } + } + + return null; // nothing found + } + } // class AutojoinLists Modified: trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinListsParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinListsParser.java 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinListsParser.java 2010-07-03 09:55:23 UTC (rev 8579) @@ -36,6 +36,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.utils.IOUtils; +import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; /** @@ -119,7 +120,7 @@ */ private void loadList(@NotNull final URL url, @NotNull final BufferedReader bufferedReader) throws IOException { boolean sectionFlag = false; // true while section (start ... end) read; XXX: replace flag with control flow - final List<R> archetypes = new ArrayList<R>(AutojoinList.SIZE); + final List<List<R>> archetypes = new ArrayList<List<R>>(AutojoinList.SIZE); final StringBuilder undefinedArchetypes = new StringBuilder(); boolean skipList = true; while (true) { @@ -146,18 +147,22 @@ } sectionFlag = false; } else { - try { - final R archetype = archetypeSet.getArchetype(line); - if (archetype.isMulti()) { - errorView.addWarning(ErrorViewCategory.AUTOJOIN_ENTRY_INVALID, url + ": list contains multi-part game object: archetype '" + line + "'"); + final List<R> tmp = new ArrayList<R>(); + for (final String archetypeName : StringUtils.PATTERN_WHITESPACE.split(line)) { + try { + final R archetype = archetypeSet.getArchetype(archetypeName); + if (archetype.isMulti()) { + errorView.addWarning(ErrorViewCategory.AUTOJOIN_ENTRY_INVALID, url + ": list contains multi-part game object: archetype '" + line + "'"); + skipList = true; + } else { + tmp.add(archetype); + } + } catch (final UndefinedArchetypeException ex) { + undefinedArchetypes.append(' ').append(ex.getMessage()); skipList = true; - } else { - archetypes.add(archetype); } - } catch (final UndefinedArchetypeException ex) { - undefinedArchetypes.append(' ').append(ex.getMessage()); - skipList = true; } + archetypes.add(tmp); } } else { // we are outside a section Added: trunk/model/src/app/net/sf/gridarta/model/autojoin/InsertionResult.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/InsertionResult.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/InsertionResult.java 2010-07-03 09:55:23 UTC (rev 8579) @@ -0,0 +1,90 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.autojoin; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.Nullable; + +/** + * The result of an insertion operation involving autojoining. The result can be + * one of: + * <ol> + * <li>a new archetype should be inserted</li> + * <li>an existing game object has been modified</li> + * <li>the operation failed; nothing has been modified or should be + * inserted</li> + * </ol> + * @author Andreas Kirschbaum + */ +public class InsertionResult<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The {@link GameObject} that has been modified. Set to <code>null</code> + * if no game object has been modified. + */ + @Nullable + private final G gameObject; + + /** + * The {@link Archetype} that should be inserted. Set to <code>null</code> + * if no archetype should be inserted. + */ + @Nullable + private final R archetype; + + /** + * Creates a new instance. + * @param gameObject the game object that has been modified or + * <code>null</code> if no game object has been modified + * @param archetype the archetype that should be inserted or + * <code>null</code> if no archetype should be inserted + */ + public InsertionResult(@Nullable final G gameObject, @Nullable final R archetype) { + if (gameObject != null && archetype != null) { + throw new IllegalArgumentException(); + } + + this.gameObject = gameObject; + this.archetype = archetype; + } + + /** + * Returns the {@link GameObject} that has been modified. + * @return the game object that has been modified or <code>null</code> if no + * game object has been modified + */ + @Nullable + public G getGameObject() { + return gameObject; + } + + /** + * Returns the {@link Archetype} that should be inserted. + * @return the archetype that should be inserted or <code>null</code> if no + * archetype should be inserted + */ + @Nullable + public R getArchetype() { + return archetype; + } + +} // class InsertionResult Property changes on: trunk/model/src/app/net/sf/gridarta/model/autojoin/InsertionResult.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2010-07-03 09:55:23 UTC (rev 8579) @@ -31,6 +31,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.autojoin.InsertionResult; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; @@ -764,7 +765,13 @@ final R realArchetype = baseObject.getArchetype(); final R effectiveArchetype; if (join) { - effectiveArchetype = autojoinLists.joinInsert(this, pos, realArchetype); + final InsertionResult<G, A, R> insertionResult = autojoinLists.joinInsert(this, pos, realArchetype); + final G gameObject = insertionResult.getGameObject(); + if (gameObject != null) { + return gameObject; + } + + effectiveArchetype = insertionResult.getArchetype(); if (effectiveArchetype == null) { return null; // only one autojoin type per square allowed } Modified: trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-03 09:51:14 UTC (rev 8578) +++ trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-03 09:55:23 UTC (rev 8579) @@ -75,6 +75,8 @@ final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(); autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); autojoinListsHelper.newAutojoinListsFail("archetype 'a4' contained in more than one autojoin list", "b0", "b1", "b2", "b3", "a4", "b5", "b6", "b7", "b8", "b9", "b10", "b11", "b12", "b13", "b14", "b15"); + autojoinListsHelper.newAutojoinListsFail("autojoin list contains duplicate archetype 'c0'", "c0|c1|c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "c12", "c13", "c14", "c15"); + autojoinListsHelper.newAutojoinListsFail("autojoin list is empty", "d0", "d1", "d2", "", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15"); } /** @@ -95,6 +97,7 @@ final TestArchetype a1 = mapModelCreator.getArchetype("a1"); final TestArchetype a6 = mapModelCreator.getArchetype("a6"); final TestArchetype a8 = mapModelCreator.getArchetype("a8"); + mapModel.beginTransaction("TEST"); testMapModelHelper.insertArchetype(mapModel, 1, 0, a1, false); testMapModelHelper.insertArchetype(mapModel, 0, 1, a8, false); @@ -141,6 +144,7 @@ final TestArchetype a8 = mapModelCreator.getArchetype("a8"); final TestArchetype a10 = mapModelCreator.getArchetype("a10"); final TestArchetype a11 = mapModelCreator.getArchetype("a11"); + mapModel.beginTransaction("TEST"); final TestGameObject g10 = testMapModelHelper.insertArchetype(mapModel, 1, 0, a4, false); final TestGameObject g01 = testMapModelHelper.insertArchetype(mapModel, 0, 1, a10, false); testMapModelHelper.insertArchetype(mapModel, 1, 1, a11, false); @@ -163,6 +167,293 @@ } /** + * Checks that inserting alternative archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsertAlt1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a0 = mapModelCreator.getArchetype("a0"); + final TestArchetype a3 = mapModelCreator.getArchetype("a3"); + final TestArchetype a8 = mapModelCreator.getArchetype("a8"); + final TestArchetype b5 = mapModelCreator.getArchetype("b5"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 0, 0, b5, false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, b10, false); + testMapModelHelper.insertArchetype(mapModel, 0, 1, a3, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a8, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + // insert using autojoin + testMapModelHelper.insertArchetype(mapModel, 1, 0, a0, true); + TestMapModelHelper.checkMapContents(mapModel, "b5|a6|b10", "a3|a9|"); + } + + /** + * Checks that inserting alternative archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsertAlt2() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a3 = mapModelCreator.getArchetype("a3"); + final TestArchetype a8 = mapModelCreator.getArchetype("a8"); + final TestArchetype b5 = mapModelCreator.getArchetype("b5"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 0, 0, b5, false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, b10, false); + testMapModelHelper.insertArchetype(mapModel, 0, 1, a3, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a8, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + // insert using autojoin + testMapModelHelper.insertArchetype(mapModel, 1, 0, b10, true); + TestMapModelHelper.checkMapContents(mapModel, "b5|b10|b10", "a3|a8|"); + } + + /** + * Checks that inserting alternative archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsertAlt3() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a3 = mapModelCreator.getArchetype("a3"); + final TestArchetype a8 = mapModelCreator.getArchetype("a8"); + final TestArchetype b5 = mapModelCreator.getArchetype("b5"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 0, 0, b5, false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, b10, false); + testMapModelHelper.insertArchetype(mapModel, 0, 1, a3, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a8, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + // insert using autojoin + testMapModelHelper.insertArchetype(mapModel, 1, 0, b5, true); + TestMapModelHelper.checkMapContents(mapModel, "b5|b5|b10", "a3|a9|"); + } + + /** + * Checks that removing alternative archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testRemoveAlt1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a10 = mapModelCreator.getArchetype("a10"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + final TestArchetype a11 = mapModelCreator.getArchetype("a11"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 0, 0, a10, false); + final TestGameObject g10 = testMapModelHelper.insertArchetype(mapModel, 1, 0, b10, false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, a10, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a11, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + // remove using autojoin + mapModel.removeGameObject(g10, true); + TestMapModelHelper.checkMapContents(mapModel, "a8||a2", "|a11|"); + } + + /** + * Checks that removing alternative archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testRemoveAlt2() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype b5 = mapModelCreator.getArchetype("b5"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + final TestArchetype a11 = mapModelCreator.getArchetype("a11"); + final TestArchetype a12 = mapModelCreator.getArchetype("a12"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 0, 0, b10, false); + final TestGameObject g10 = testMapModelHelper.insertArchetype(mapModel, 1, 0, a12, false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, b5, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a11, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + // remove using autojoin + mapModel.removeGameObject(g10, true); + TestMapModelHelper.checkMapContents(mapModel, "b10||b5", "|a10|"); + } + + /** + * Checks that removing alternative archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testRemoveAlt3() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + final TestArchetype a11 = mapModelCreator.getArchetype("a11"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 0, 0, b10, false); + final TestGameObject g10 = testMapModelHelper.insertArchetype(mapModel, 1, 0, b10, false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, b10, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a11, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + // remove using autojoin + mapModel.removeGameObject(g10, true); + TestMapModelHelper.checkMapContents(mapModel, "b10||b10", "|a11|"); + } + + /** + * Checks that inserting duplicate archetypes with autojoin works as + * expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsertDuplicate1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 3); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a5 = mapModelCreator.getArchetype("a5"); + final TestArchetype b5 = mapModelCreator.getArchetype("b5"); + final TestArchetype a10 = mapModelCreator.getArchetype("a10"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + final TestArchetype a15 = mapModelCreator.getArchetype("a15"); + mapModel.beginTransaction("TEST"); + testMapModelHelper.insertArchetype(mapModel, 1, 0, a10, false); + testMapModelHelper.insertArchetype(mapModel, 0, 1, b10, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a15, false); + testMapModelHelper.insertArchetype(mapModel, 2, 1, a5, false); + testMapModelHelper.insertArchetype(mapModel, 1, 2, b5, false); + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + try { + testMapModelHelper.insertArchetype(mapModel, 1, 1, a10, true); + Assert.fail(); + } catch (final CannotInsertGameObjectException ignored) { + // ignore + } + try { + testMapModelHelper.insertArchetype(mapModel, 0, 1, b10, true); + Assert.fail(); + } catch (final CannotInsertGameObjectException ignored) { + // ignore + } + TestMapModelHelper.checkMapContents(mapModel, "|a10|", "b10|a15|a5", "|b5|"); + } + + /** + * Checks that replacing archetypes works as expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsertReplace1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5|b5", "a6", "a7", "a8", "a9", "a10|b10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 3); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a0 = mapModelCreator.getArchetype("a0"); + final TestArchetype a5 = mapModelCreator.getArchetype("a5"); + final TestArchetype b5 = mapModelCreator.getArchetype("b5"); + final TestArchetype a10 = mapModelCreator.getArchetype("a10"); + final TestArchetype b10 = mapModelCreator.getArchetype("b10"); + mapModel.beginTransaction("TEST"); + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 3; x++) { + testMapModelHelper.insertArchetype(mapModel, x, y, a10, false); + } + } + + mapModelCreator.getMapViewSettings().setAutojoin(true); + + TestMapModelHelper.checkMapContents(mapModel, "a10|a10|a10", "a10|a10|a10", "a10|a10|a10"); + testMapModelHelper.insertArchetype(mapModel, 1, 1, b5, true); // replace main->alt + TestMapModelHelper.checkMapContents(mapModel, "a10|a14|a10", "a8|b5|a2", "a10|a11|a10"); + testMapModelHelper.insertArchetype(mapModel, 1, 1, b10, true); // replace alt->alt, different archetype + TestMapModelHelper.checkMapContents(mapModel, "a10|a10|a10", "a10|b10|a10", "a10|a10|a10"); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a5, true); // replace alt->main + TestMapModelHelper.checkMapContents(mapModel, "a10|a14|a10", "a10|a15|a10", "a10|a11|a10"); + testMapModelHelper.insertArchetype(mapModel, 1, 1, b10, true); // replace main->alt + TestMapModelHelper.checkMapContents(mapModel, "a10|a10|a10", "a10|b10|a10", "a10|a10|a10"); + try { + testMapModelHelper.insertArchetype(mapModel, 1, 1, b10, true); // replace alt->alt, same archetype + Assert.fail(); + } catch (final CannotInsertGameObjectException ignored) { + // ignore + } + TestMapModelHelper.checkMapContents(mapModel, "a10|a10|a10", "a10|b10|a10", "a10|a10|a10"); + try { + testMapModelHelper.insertArchetype(mapModel, 1, 0, a0, true); // replace main->main + Assert.fail(); + } catch (final CannotInsertGameObjectException ignored) { + // ignore + } + TestMapModelHelper.checkMapContents(mapModel, "a10|a10|a10", "a10|b10|a10", "a10|a10|a10"); + } + + /** * Implements {@link AutojoinList} related functions. */ private static class AutojoinListsHelper { @@ -202,9 +493,15 @@ * cannot be created */ public void newAutojoinLists(@NotNull final String... archetypeNames) throws IllegalAutojoinListException { - final List<TestArchetype> archetypes = new ArrayList<TestArchetype>(); - for (final String archetypeName : archetypeNames) { - archetypes.add(mapModelCreator.getArchetype(archetypeName)); + final List<List<TestArchetype>> archetypes = new ArrayList<List<TestArchetype>>(); + for (final String archetypeNameList : archetypeNames) { + final List<TestArchetype> archetypeList = new ArrayList<TestArchetype>(); + if (!archetypeNameList.isEmpty()) { + for (final String archetypeName : archetypeNameList.split("\\|", -1)) { + archetypeList.add(mapModelCreator.getArchetype(archetypeName)); + } + } + archetypes.add(archetypeList); } autojoinLists.addAutojoinList(new AutojoinList<TestGameObject, TestMapArchObject, TestArchetype>(archetypes)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-03 09:51:20
|
Revision: 8578 http://gridarta.svn.sourceforge.net/gridarta/?rev=8578&view=rev Author: akirschbaum Date: 2010-07-03 09:51:14 +0000 (Sat, 03 Jul 2010) Log Message: ----------- Update HTML formatting options. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-07-02 08:17:52 UTC (rev 8577) +++ trunk/gridarta.ipr 2010-07-03 09:51:14 UTC (rev 8578) @@ -84,7 +84,7 @@ <option name="HTML_KEEP_LINE_BREAKS" value="false" /> <option name="HTML_KEEP_LINE_BREAKS_IN_TEXT" value="false" /> <option name="HTML_ALIGN_ATTRIBUTES" value="false" /> - <option name="HTML_ELEMENTS_TO_INSERT_NEW_LINE_BEFORE" value="body,div,p,form,h1,h2,h3,br" /> + <option name="HTML_ELEMENTS_TO_INSERT_NEW_LINE_BEFORE" value="body,div,p,form,h1,h2,h3,br,ol,ul,li" /> <option name="HTML_ELEMENTS_TO_REMOVE_NEW_LINE_BEFORE" value="" /> <option name="HTML_INLINE_ELEMENTS" value="a,abbr,acronym,b,basefont,bdo,big,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,span,strike,strong,sub,sup,textarea,tt,u,var" /> <ADDITIONAL_INDENT_OPTIONS fileType="groovy"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-02 08:17:59
|
Revision: 8577 http://gridarta.svn.sourceforge.net/gridarta/?rev=8577&view=rev Author: akirschbaum Date: 2010-07-02 08:17:52 +0000 (Fri, 02 Jul 2010) Log Message: ----------- Clean up AutojoinListsTest. Modified Paths: -------------- trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Modified: trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-02 07:37:56 UTC (rev 8576) +++ trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-02 08:17:52 UTC (rev 8577) @@ -21,35 +21,15 @@ import java.util.ArrayList; import java.util.List; -import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.TestAnimationObjects; -import net.sf.gridarta.model.archetype.ArchetypeFactory; -import net.sf.gridarta.model.archetype.ArchetypeSet; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.archetype.TestArchetypeFactory; -import net.sf.gridarta.model.archetype.TestArchetypeSet; import net.sf.gridarta.model.archetype.UndefinedArchetypeException; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.face.TestFaceObjects; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; -import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapmodel.MapModelFactory; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.model.mapmodel.TestMapModelHelper; -import net.sf.gridarta.model.mapmodel.TopmostInsertionMode; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; -import net.sf.gridarta.model.match.GameObjectMatchers; -import net.sf.gridarta.utils.GUIUtils; -import net.sf.gridarta.utils.Size2D; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.junit.Assert; import org.junit.Test; @@ -66,12 +46,12 @@ */ @Test public void testWrongCount() throws IllegalAutojoinListException { - final Creator creator = new Creator(); - creator.newAutojoinListsFail("autojoin list with less than 16 valid entries"); - creator.newAutojoinListsFail("autojoin list with less than 16 valid entries", "a0"); - creator.newAutojoinListsFail("autojoin list with less than 16 valid entries", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14"); - creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); - creator.newAutojoinListsFail("autojoin list with more than 16 valid entries", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16"); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(); + autojoinListsHelper.newAutojoinListsFail("autojoin list with less than 16 valid entries"); + autojoinListsHelper.newAutojoinListsFail("autojoin list with less than 16 valid entries", "a0"); + autojoinListsHelper.newAutojoinListsFail("autojoin list with less than 16 valid entries", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14"); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + autojoinListsHelper.newAutojoinListsFail("autojoin list with more than 16 valid entries", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16"); } /** @@ -80,10 +60,10 @@ */ @Test public void testDuplicateArchetype1() throws IllegalAutojoinListException { - final Creator creator = new Creator(); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(); //Check disabled for now as Daimonin uses this feature: - //creator.newAutojoinListsFail("autojoin list contains duplicate archetype 'a0'", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a0"); - creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a0"); + //autojoinListsHelper.newAutojoinListsFail("autojoin list contains duplicate archetype 'a0'", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a0"); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a0"); } /** @@ -92,9 +72,9 @@ */ @Test public void testDuplicateArchetype2() throws IllegalAutojoinListException { - final Creator creator = new Creator(); - creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); - creator.newAutojoinListsFail("archetype 'a4' contained in more than one autojoin list", "b0", "b1", "b2", "b3", "a4", "b5", "b6", "b7", "b8", "b9", "b10", "b11", "b12", "b13", "b14", "b15"); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + autojoinListsHelper.newAutojoinListsFail("archetype 'a4' contained in more than one autojoin list", "b0", "b1", "b2", "b3", "a4", "b5", "b6", "b7", "b8", "b9", "b10", "b11", "b12", "b13", "b14", "b15"); } /** @@ -106,19 +86,19 @@ */ @Test public void testInsert1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { - final Creator creator = new Creator(); - creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); - final Creator2 creator2 = new Creator2(creator); - final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = creator2.newMapModel(3, 2); - final TestMapModelHelper testMapModelHelper = newTestMapModelCreator(creator); - final TestArchetype a0 = creator.archetypeSet.getArchetype("a0"); - final TestArchetype a1 = creator.archetypeSet.getArchetype("a1"); - final TestArchetype a6 = creator.archetypeSet.getArchetype("a6"); - final TestArchetype a8 = creator.archetypeSet.getArchetype("a8"); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a0 = mapModelCreator.getArchetype("a0"); + final TestArchetype a1 = mapModelCreator.getArchetype("a1"); + final TestArchetype a6 = mapModelCreator.getArchetype("a6"); + final TestArchetype a8 = mapModelCreator.getArchetype("a8"); testMapModelHelper.insertArchetype(mapModel, 1, 0, a1, false); testMapModelHelper.insertArchetype(mapModel, 0, 1, a8, false); - creator.mapViewSettings.setAutojoin(true); + mapModelCreator.getMapViewSettings().setAutojoin(true); // insert using autojoin testMapModelHelper.insertArchetype(mapModel, 1, 1, a0, true); @@ -138,7 +118,7 @@ TestMapModelHelper.checkMapContents(mapModel, "|a5|", "a10|a11|a8"); // insert using autojoin but disabled autojoin globally - creator.mapViewSettings.setAutojoin(false); + mapModelCreator.getMapViewSettings().setAutojoin(false); testMapModelHelper.insertArchetype(mapModel, 2, 0, a6, true); TestMapModelHelper.checkMapContents(mapModel, "|a5|a6", "a10|a11|a8"); } @@ -152,97 +132,67 @@ */ @Test public void testRemove1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { - final Creator creator = new Creator(); - creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); - final Creator2 creator2 = new Creator2(creator); - final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = creator2.newMapModel(3, 2); - final TestMapModelHelper testMapModelHelper = newTestMapModelCreator(creator); - final TestArchetype a4 = creator.archetypeSet.getArchetype("a4"); - final TestArchetype a8 = creator.archetypeSet.getArchetype("a8"); - final TestArchetype a10 = creator.archetypeSet.getArchetype("a10"); - final TestArchetype a11 = creator.archetypeSet.getArchetype("a11"); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final AutojoinListsHelper autojoinListsHelper = new AutojoinListsHelper(mapModelCreator); + autojoinListsHelper.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = mapModelCreator.newTestMapModelHelper(); + final TestArchetype a4 = mapModelCreator.getArchetype("a4"); + final TestArchetype a8 = mapModelCreator.getArchetype("a8"); + final TestArchetype a10 = mapModelCreator.getArchetype("a10"); + final TestArchetype a11 = mapModelCreator.getArchetype("a11"); final TestGameObject g10 = testMapModelHelper.insertArchetype(mapModel, 1, 0, a4, false); final TestGameObject g01 = testMapModelHelper.insertArchetype(mapModel, 0, 1, a10, false); testMapModelHelper.insertArchetype(mapModel, 1, 1, a11, false); final TestGameObject g21 = testMapModelHelper.insertArchetype(mapModel, 2, 1, a8, false); // remove using autojoin - creator.mapViewSettings.setAutojoin(true); + mapModelCreator.getMapViewSettings().setAutojoin(true); mapModel.removeGameObject(g21, true); TestMapModelHelper.checkMapContents(mapModel, "|a4|", "a10|a9|"); // remove using autojoin but globally disabled - creator.mapViewSettings.setAutojoin(false); + mapModelCreator.getMapViewSettings().setAutojoin(false); mapModel.removeGameObject(g10, true); TestMapModelHelper.checkMapContents(mapModel, "||", "a10|a9|"); // remove using autojoin - creator.mapViewSettings.setAutojoin(true); + mapModelCreator.getMapViewSettings().setAutojoin(true); mapModel.removeGameObject(g01, true); TestMapModelHelper.checkMapContents(mapModel, "||", "|a1|"); } /** - * Creates a new {@link TestMapModelHelper} instance. - * @param creator the creator to use - * @return the new test map model creator instance - * @throws DuplicateArchetypeException if an internal error occurs + * Implements {@link AutojoinList} related functions. */ - @NotNull - private static TestMapModelHelper newTestMapModelCreator(@NotNull final Creator creator) throws DuplicateArchetypeException { - final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(creator.faceObjectProviders, creator.animationObjects); - final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); - return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, creator.archetypeSet, creator.faceObjectProviders, creator.animationObjects); - } + private static class AutojoinListsHelper { - /** - * Creator for {@link AutojoinList} instances. - */ - private static class Creator { - /** - * The {@link AutojoinLists} instance. + * The {@link TestMapModelCreator} instance. */ @NotNull - private final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists; + private final TestMapModelCreator mapModelCreator; /** - * The {@link FaceObjectProviders} instance. + * The {@link AutojoinLists} instance. */ @NotNull - private final FaceObjectProviders faceObjectProviders; + private final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists; /** - * The {@link AnimationObjects} instance. + * Creates a new instance. */ - @NotNull - private final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects; + private AutojoinListsHelper() { + this(new TestMapModelCreator(false)); + } /** - * The {@link MapViewSettings} instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** - * The {@link ArchetypeSet} instance. - */ - @NotNull - private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; - - /** * Creates a new instance. + * @param mapModelCreator the map model creator instance */ - private Creator() { - final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); - faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); - archetypeSet = new TestArchetypeSet(archetypeFactory, "arch", faceObjectProviders); - animationObjects = new TestAnimationObjects(); - mapViewSettings = new TestMapViewSettings(); - autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); + private AutojoinListsHelper(@NotNull final TestMapModelCreator mapModelCreator) { + this.mapModelCreator = mapModelCreator; + autojoinLists = mapModelCreator.getAutojoinLists(); } /** @@ -254,7 +204,7 @@ public void newAutojoinLists(@NotNull final String... archetypeNames) throws IllegalAutojoinListException { final List<TestArchetype> archetypes = new ArrayList<TestArchetype>(); for (final String archetypeName : archetypeNames) { - archetypes.add(getArchetype(archetypeName)); + archetypes.add(mapModelCreator.getArchetype(archetypeName)); } autojoinLists.addAutojoinList(new AutojoinList<TestGameObject, TestMapArchObject, TestArchetype>(archetypes)); } @@ -273,63 +223,6 @@ } } - /** - * Returns or creates an archetype by name. - * @param archetypeName the archetype name - * @return the archetype - */ - @NotNull - private TestArchetype getArchetype(@NotNull final String archetypeName) { - try { - return archetypeSet.getArchetype(archetypeName); - } catch (final UndefinedArchetypeException ignored) { - final TestArchetype archetype = new TestArchetype(archetypeName, faceObjectProviders, animationObjects); - try { - archetypeSet.addArchetype(archetype); - } catch (final DuplicateArchetypeException ex) { - Assert.fail(ex.getMessage()); - } - return archetype; - } - } - } - /** - * Creator for {@link MapModel} instances. - */ - private static class Creator2 { - - /** - * The {@link MapModelFactory} for creating {@link MapModel} instances. - */ - @NotNull - private final MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype> mapModelFactory; - - /** - * Creates a new instance. - * @param creator the creator to use - */ - private Creator2(@NotNull final Creator creator) { - final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); - final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(creator.faceObjectProviders, creator.animationObjects); - final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); - final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); - mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, creator.autojoinLists, creator.mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); - } - - /** - * Creates a new {@link MapModel} instance. - * @param width the map width in squares - * @param height the map height in squares - * @return the map model instance - */ - @NotNull - public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel(final int width, final int height) { - final TestMapArchObject mapArchObject = new TestMapArchObject(); - mapArchObject.setMapSize(new Size2D(width, height)); - return mapModelFactory.newMapModel(mapArchObject); - } - } - } // class AutojoinListsTest Modified: trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-07-02 07:37:56 UTC (rev 8576) +++ trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-07-02 08:17:52 UTC (rev 8577) @@ -45,9 +45,9 @@ */ @Test public void testDoMoveSquareTopSingle() throws CannotInsertGameObjectException, DuplicateArchetypeException { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final TestMapModelHelper mapModelHelper = mapModelCreator.newMapModelCreator(); - final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(1, 1); final Point point = new Point(0, 0); mapModel.beginTransaction("TEST"); Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-02 07:37:56 UTC (rev 8576) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-02 08:17:52 UTC (rev 8577) @@ -143,7 +143,7 @@ */ @Test public void testEmpty() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -157,7 +157,7 @@ */ @Test public void testResizeMap1() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -172,7 +172,7 @@ */ @Test public void testResizeMap2() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -192,7 +192,7 @@ */ @Test public void testResizeMap3() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -214,7 +214,7 @@ */ @Test public void testResizeMap4() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -239,7 +239,7 @@ */ @Test public void testAddGameObjectToMap1() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -259,7 +259,7 @@ */ @Test public void testAddGameObjectToMap2() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -280,7 +280,7 @@ */ @Test public void testModifiedGameObject1() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -302,7 +302,7 @@ */ @Test public void testModifiedGameObject2() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); mapModel.beginTransaction("TEST"); @@ -325,7 +325,7 @@ */ @Test public void testGetAllGameObjects1() { - final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, TestArchetype> archetype = mapModelCreator.getArchetype("arch"); final TestArchetype archetype2 = mapModelCreator.getArchetype("arch2"); @@ -382,7 +382,7 @@ */ @NotNull public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel(@NotNull final TestMapModelCreator mapModelCreator) { - final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(1, 1); result.setLength(0); mapModel.addMapModelListener(mapModelListener); Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-07-02 07:37:56 UTC (rev 8576) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-07-02 08:17:52 UTC (rev 8577) @@ -47,6 +47,7 @@ import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.junit.Assert; @@ -70,6 +71,12 @@ private static final String[] ICON_NAMES = { SystemIcons.SQUARE_SELECTED_SQUARE, SystemIcons.SQUARE_SELECTED_SQUARE_NORTH, SystemIcons.SQUARE_SELECTED_SQUARE_EAST, SystemIcons.SQUARE_SELECTED_SQUARE_SOUTH, SystemIcons.SQUARE_SELECTED_SQUARE_WEST, SystemIcons.SQUARE_PRE_SELECTED_SQUARE, SystemIcons.SQUARE_CURSOR, SystemIcons.SQUARE_EMPTY, SystemIcons.SQUARE_UNKNOWN, SystemIcons.SQUARE_NO_FACE, SystemIcons.SQUARE_NO_ARCH, SystemIcons.DEFAULT_ICON, SystemIcons.DEFAULT_PREVIEW, SystemIcons.SQUARE_WARNING, }; /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings = new TestMapViewSettings(); + + /** * The {@link FaceObjectProviders} instance. */ @NotNull @@ -119,14 +126,16 @@ /** * Creates a new instance. + * @param createIcons whether to create icon instances */ - public TestMapModelCreator() { - final MapViewSettings mapViewSettings = new TestMapViewSettings(); + public TestMapModelCreator(final boolean createIcons) { autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); final GUIUtils guiUtils = new GUIUtils(); - final ImageIcon imageIcon = new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); - for (final String iconName : ICON_NAMES) { - guiUtils.addToCache(iconName, imageIcon); + if (createIcons) { + final ImageIcon imageIcon = new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); + for (final String iconName : ICON_NAMES) { + guiUtils.addToCache(iconName, imageIcon); + } } final SystemIcons systemIcons = new SystemIcons(guiUtils); final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); @@ -141,11 +150,14 @@ /** * Creates a new {@link MapModel} instance. + * @param w the width in squares + * @param h the height in squares * @return the new map model instance */ @NotNull - public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel() { + public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel(final int w, final int h) { final TestMapArchObject mapArchObject = new TestMapArchObject(); + mapArchObject.setMapSize(new Size2D(w, h)); return new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, mapArchObject, archetypeChooserModel, 0, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); } @@ -234,4 +246,32 @@ return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, archetypeSet, faceObjectProviders, animationObjects); } + /** + * Returns the {@link MapViewSettings} instance. + * @return the map view settings instance + */ + @NotNull + public MapViewSettings getMapViewSettings() { + return mapViewSettings; + } + + /** + * Creates a new {@link TestMapModelHelper} instance. + * @return the new test map model creator instance + * @throws DuplicateArchetypeException if an internal error occurs + */ + @NotNull + public TestMapModelHelper newTestMapModelHelper() throws DuplicateArchetypeException { + return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, archetypeSet, faceObjectProviders, animationObjects); + } + + /** + * Returns the {@link AutojoinLists} instance. + * @return the autojoin lists instance + */ + @NotNull + public AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> getAutojoinLists() { + return autojoinLists; + } + } // class TestMapModelCreator Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-07-02 07:37:56 UTC (rev 8576) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-07-02 08:17:52 UTC (rev 8577) @@ -323,15 +323,6 @@ } /** - * Returns the {@link GameObjectFactory} instance. - * @return the game object factory - */ - @NotNull - public GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> getGameObjectFactory() { - return gameObjectFactory; - } - - /** * Creates a new {@link MapViewsManager} instance. * @return the map views manager instance */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-02 07:38:03
|
Revision: 8576 http://gridarta.svn.sourceforge.net/gridarta/?rev=8576&view=rev Author: akirschbaum Date: 2010-07-02 07:37:56 +0000 (Fri, 02 Jul 2010) Log Message: ----------- Move GameObjectFactoryTest to model module. Modified Paths: -------------- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java Removed Paths: ------------- trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java Copied: trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java (from rev 8575, trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-07-02 07:37:56 UTC (rev 8576) @@ -0,0 +1,69 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.gameobject; + +import java.awt.Point; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link GameObjectFactory}. + * @author Andreas Kirschbaum + */ +public class GameObjectFactoryTest { + + /** + * Checks that {@link + * net.sf.gridarta.model.gameobject.GameObjectFactory#cloneGameObject(GameObject)} + * correctly updates the container. + * @throws DuplicateArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws CannotInsertGameObjectException, DuplicateArchetypeException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final TestMapModelHelper mapModelHelper = mapModelCreator.newMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(); + + final Point point = new Point(0, 0); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = mapModelHelper.insertFloor(mapModel, point); + final TestGameObject ob2 = mapModelHelper.insertExit(ob1); + + final TestGameObject ob1Clone = mapModelCreator.getGameObjectFactory().cloneGameObject(ob1); + + Assert.assertNotSame(ob1, ob1Clone); + Assert.assertEquals(1, ob1Clone.countInvObjects()); + final TestGameObject ob2Clone = ob1Clone.getFirst(); + Assert.assertNotNull(ob2Clone); + Assert.assertNotSame(ob2, ob2Clone); + + Assert.assertSame(ob1, ob2.getContainer()); + Assert.assertSame(ob1Clone, ob2Clone.getContainer()); + } + +} // class GameObjectFactoryTest Property changes on: trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-02 07:07:32 UTC (rev 8575) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-02 07:37:56 UTC (rev 8576) @@ -20,40 +20,22 @@ package net.sf.gridarta.model.mapmodel; import java.awt.Point; -import java.awt.image.BufferedImage; import java.io.File; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.TreeSet; -import javax.swing.ImageIcon; -import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.MapArchObjectListener; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; -import net.sf.gridarta.model.match.GameObjectMatchers; -import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; import net.sf.gridarta.model.validation.ErrorCollector; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.Size2D; -import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; /** @@ -65,13 +47,7 @@ public class DefaultMapModelTest { /** - * Predefined icon names. - */ - @NotNull - private static final String[] ICON_NAMES = { SystemIcons.SQUARE_SELECTED_SQUARE, SystemIcons.SQUARE_SELECTED_SQUARE_NORTH, SystemIcons.SQUARE_SELECTED_SQUARE_EAST, SystemIcons.SQUARE_SELECTED_SQUARE_SOUTH, SystemIcons.SQUARE_SELECTED_SQUARE_WEST, SystemIcons.SQUARE_PRE_SELECTED_SQUARE, SystemIcons.SQUARE_CURSOR, SystemIcons.SQUARE_EMPTY, SystemIcons.SQUARE_UNKNOWN, SystemIcons.SQUARE_NO_FACE, SystemIcons.SQUARE_NO_ARCH, SystemIcons.DEFAULT_ICON, SystemIcons.DEFAULT_PREVIEW, SystemIcons.SQUARE_WARNING, }; - - /** - * The map model listener registered to {@link #mapModel} to record map + * The map model listener registered to all map models to record map * changes. */ @NotNull @@ -132,7 +108,7 @@ }; /** - * The {@link MapArchObjectListener} registered to {@link #mapModel} to + * The {@link MapArchObjectListener} registered to all map models to * record map changes. */ @NotNull @@ -163,34 +139,13 @@ private final StringBuilder result = new StringBuilder(); /** - * The map model that gets changed. - */ - @Nullable - private DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = null; - - /** - * The {@link SystemIcons} instance. - */ - @Nullable - private SystemIcons systemIcons = null; - - /** - * The {@link AnimationObjects} instance. - */ - @Nullable - private AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = null; - - /** - * The {@link InsertionModeSet} instance. - */ - @Nullable - private InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> insertionModeSet = null; - - /** * Test case for an empty transaction. */ @Test public void testEmpty() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.endTransaction(); Assert.assertEquals("", result.toString()); @@ -202,6 +157,9 @@ */ @Test public void testResizeMap1() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); @@ -214,6 +172,9 @@ */ @Test public void testResizeMap2() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); @@ -231,14 +192,17 @@ */ @Test public void testResizeMap3() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); - addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 2, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); @@ -250,9 +214,12 @@ */ @Test public void testResizeMap4() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); result.setLength(0); @@ -260,7 +227,7 @@ for (final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> gameObject : mapModel.getMapSquare(new Point(1, 2))) { gameObject.setAttributeString("key", "value"); } - addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 2, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); @@ -272,13 +239,16 @@ */ @Test public void testAddGameObjectToMap1() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); Assert.assertEquals("mapSquaresChanged:\n" + "square 1 2\n" + "no game objects\n", result.toString()); } @@ -289,15 +259,18 @@ */ @Test public void testAddGameObjectToMap2() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); - addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 2, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); Assert.assertEquals("mapSquaresChanged:\n" + "square 1 2\n" + "square 2 2\n" + "no game objects\n", result.toString()); } @@ -307,15 +280,18 @@ */ @Test public void testModifiedGameObject1() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); for (final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject : mapModel.getMapSquare(new Point(1, 2))) { - insertGameObject(gameObject, "2"); + mapModelCreator.insertGameObject(gameObject, "2"); } mapModel.endTransaction(); Assert.assertEquals("mapObjectsChanged:\n" + "no squares\n" + "game object 1 2 1\n", result.toString()); @@ -326,9 +302,12 @@ */ @Test public void testModifiedGameObject2() { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); - addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); + mapModelCreator.addGameObjectToMap(mapModel, "1", 1, 2, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); result.setLength(0); @@ -346,17 +325,16 @@ */ @Test public void testGetAllGameObjects1() { - final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); - assert animationObjects != null; - final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, TestArchetype> archetype = new TestArchetype("arch", faceObjectProviders, animationObjects); - assert animationObjects != null; - final TestArchetype archetype2 = new TestArchetype("arch2", faceObjectProviders, animationObjects); + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = newMapModel(mapModelCreator); + final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, TestArchetype> archetype = mapModelCreator.getArchetype("arch"); + final TestArchetype archetype2 = mapModelCreator.getArchetype("arch2"); archetype2.setMultiY(1); archetype.addTailPart(archetype2); mapModel.beginTransaction("TEST"); mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); - final TestGameObject gameObject = mapModel.insertBaseObject(archetype, new Point(0, 0), true, false, insertionModeSet.getAutoInsertionMode()); + final TestGameObject gameObject = mapModel.insertBaseObject(archetype, new Point(0, 0), true, false, mapModelCreator.getInsertionModeSet().getAutoInsertionMode()); mapModel.endTransaction(); final List<TestGameObject> gameObjects = mapModel.getAllGameObjects(); @@ -365,44 +343,6 @@ } /** - * Inserts a game object into a map. - * @param mapModel the map to add to - * @param name the name of the game object to add - * @param x the x coordinate to add to - * @param y the y coordinate to add to - * @param insertionMode the insertion mode to use - */ - private void addGameObjectToMap(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String name, final int x, final int y, @NotNull final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> insertionMode) { - final TestGameObject gameObject = newGameObject(name); - mapModel.addGameObjectToMap(gameObject, new Point(x, y), insertionMode); - } - - /** - * Inserts a game object into the inventory of another game object. - * @param gameObject the game object to add to - * @param name the name of the game object to add - */ - private void insertGameObject(@NotNull final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject, @NotNull final String name) { - final TestGameObject inv = newGameObject(name); - gameObject.addLast(inv); - } - - /** - * Creates a new game object. - * @param objectName the object name to set - * @return the game object - */ - private TestGameObject newGameObject(@NotNull final String objectName) { - final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); - assert animationObjects != null; - final TestArchetype archetype = new TestArchetype("arch", faceObjectProviders, animationObjects); - assert animationObjects != null; - final TestGameObject gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects); - gameObject.setAttributeString(BaseObject.NAME, objectName); - return gameObject; - } - - /** * Records a change event. * @param name the event name * @param mapSquares the changed map squares @@ -436,45 +376,20 @@ } /** - * Sets up a test. + * Creates a new {@link MapModel} instance. + * @param mapModelCreator the map model creator to use + * @return the new map model instance */ - @Before - public void setUp() { - final ImageIcon imageIcon = new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); - final GUIUtils guiUtils = new GUIUtils(); - systemIcons = new SystemIcons(guiUtils); - for (final String iconName : ICON_NAMES) { - guiUtils.addToCache(iconName, imageIcon); - } - final TestMapArchObject mapArchObject = new TestMapArchObject(); - final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); - final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); - final MapViewSettings mapViewSettings = new TestMapViewSettings(); - final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); - animationObjects = new TestAnimationObjects(); - final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); - final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); - insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); - insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); - mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, mapArchObject, archetypeChooserModel, 0, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + @NotNull + public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel(@NotNull final TestMapModelCreator mapModelCreator) { + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(); result.setLength(0); mapModel.addMapModelListener(mapModelListener); mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); Assert.assertEquals("", result.toString()); - } - /** - * Creates a new {@link FaceObjectProviders} instance. - * @return the face object providers instance - */ - @NotNull - private FaceObjectProviders newFaceObjectProviders() { - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); - assert systemIcons != null; - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - return faceObjectProviders; + return mapModel; } } // class DefaultMapModelTest Added: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2010-07-02 07:37:56 UTC (rev 8576) @@ -0,0 +1,237 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapmodel; + +import java.awt.Point; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; +import net.sf.gridarta.model.archetype.ArchetypeFactory; +import net.sf.gridarta.model.archetype.ArchetypeSet; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.archetype.TestArchetypeFactory; +import net.sf.gridarta.model.archetype.TestArchetypeSet; +import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.gameobject.TestGameObjectFactory; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; +import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; + +/** + * Helper class for regression tests to create {@link MapModel} instances. + * @author Andreas Kirschbaum + */ +public class TestMapModelCreator { + + /** + * The {@link ArchetypeSet} instance. + */ + @NotNull + private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; + + /** + * Predefined icon names. + */ + @NotNull + private static final String[] ICON_NAMES = { SystemIcons.SQUARE_SELECTED_SQUARE, SystemIcons.SQUARE_SELECTED_SQUARE_NORTH, SystemIcons.SQUARE_SELECTED_SQUARE_EAST, SystemIcons.SQUARE_SELECTED_SQUARE_SOUTH, SystemIcons.SQUARE_SELECTED_SQUARE_WEST, SystemIcons.SQUARE_PRE_SELECTED_SQUARE, SystemIcons.SQUARE_CURSOR, SystemIcons.SQUARE_EMPTY, SystemIcons.SQUARE_UNKNOWN, SystemIcons.SQUARE_NO_FACE, SystemIcons.SQUARE_NO_ARCH, SystemIcons.DEFAULT_ICON, SystemIcons.DEFAULT_PREVIEW, SystemIcons.SQUARE_WARNING, }; + + /** + * The {@link FaceObjectProviders} instance. + */ + @NotNull + private final FaceObjectProviders faceObjectProviders; + + /** + * The {@link GameObjectMatchers} instance. + */ + @NotNull + private final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); + + /** + * The {@link ArchetypeChooserModel} instance. + */ + @NotNull + private final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); + + /** + * The {@link AutojoinLists} instance. + */ + @NotNull + private final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists; + + /** + * The {@link GameObjectFactory} instance. + */ + @NotNull + private final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory; + + /** + * The {@link AnimationObjects} instance. + */ + @NotNull + private final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); + + /** + * The "topmost" {@link InsertionMode} instance. + */ + @NotNull + private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; + + /** + * The {@link InsertionModeSet} instance. + */ + @NotNull + private final InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> insertionModeSet; + + /** + * Creates a new instance. + */ + public TestMapModelCreator() { + final MapViewSettings mapViewSettings = new TestMapViewSettings(); + autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); + final GUIUtils guiUtils = new GUIUtils(); + final ImageIcon imageIcon = new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); + for (final String iconName : ICON_NAMES) { + guiUtils.addToCache(iconName, imageIcon); + } + final SystemIcons systemIcons = new SystemIcons(guiUtils); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); + faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); + archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); + gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); + topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); + insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); + insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); + } + + /** + * Creates a new {@link MapModel} instance. + * @return the new map model instance + */ + @NotNull + public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel() { + final TestMapArchObject mapArchObject = new TestMapArchObject(); + return new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, mapArchObject, archetypeChooserModel, 0, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + } + + /** + * Creates a new game object. + * @param objectName the object name to set + * @return the game object + */ + private TestGameObject newGameObject(@NotNull final String objectName) { + final TestArchetype archetype = getArchetype("arch"); + final TestGameObject gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects); + gameObject.setAttributeString(BaseObject.NAME, objectName); + return gameObject; + } + + /** + * Inserts a game object into a map. + * @param mapModel the map to add to + * @param name the name of the game object to add + * @param x the x coordinate to add to + * @param y the y coordinate to add to + * @param insertionMode the insertion mode to use + */ + public void addGameObjectToMap(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String name, final int x, final int y, @NotNull final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> insertionMode) { + final TestGameObject gameObject = newGameObject(name); + mapModel.addGameObjectToMap(gameObject, new Point(x, y), insertionMode); + } + + /** + * Inserts a game object into the inventory of another game object. + * @param gameObject the game object to add to + * @param name the name of the game object to add + */ + public void insertGameObject(@NotNull final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject, @NotNull final String name) { + final TestGameObject inv = newGameObject(name); + gameObject.addLast(inv); + } + + /** + * Returns the {@link InsertionModeSet} instance. + * @return the insertion mode set instance + */ + @NotNull + public InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> getInsertionModeSet() { + return insertionModeSet; + } + + /** + * Returns an archetype. + * @param archetypeName the archetype name + * @return the archetype + */ + @NotNull + public TestArchetype getArchetype(@NotNull final String archetypeName) { + try { + return archetypeSet.getArchetype(archetypeName); + } catch (final UndefinedArchetypeException ignored) { + // ignore + } + + final TestArchetype archetype = new TestArchetype(archetypeName, faceObjectProviders, animationObjects); + try { + archetypeSet.addArchetype(archetype); + } catch (final DuplicateArchetypeException ex) { + Assert.fail(ex.getMessage()); + throw new AssertionError(ex); + } + return archetype; + } + + /** + * Returns the {@link GameObjectFactory} instance. + * @return the game object factory instance + */ + @NotNull + public GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> getGameObjectFactory() { + return gameObjectFactory; + } + + /** + * Creates a new {@link TestMapModelHelper} instance. + * @return the new instance + * @throws DuplicateArchetypeException if an internal error occurs + */ + public TestMapModelHelper newMapModelCreator() throws DuplicateArchetypeException { + return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, archetypeSet, faceObjectProviders, animationObjects); + } + +} // class TestMapModelCreator Property changes on: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Deleted: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-07-02 07:07:32 UTC (rev 8575) +++ trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-07-02 07:37:56 UTC (rev 8576) @@ -1,73 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.model.gameobject; - -import java.awt.Point; -import java.io.File; -import net.sf.gridarta.gui.map.test.TestMapControlCreator; -import net.sf.gridarta.model.archetype.DuplicateArchetypeException; -import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.mapcontrol.MapControl; -import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; -import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapmodel.TestMapModelHelper; -import net.sf.gridarta.utils.Size2D; -import org.junit.Assert; -import org.junit.Test; - -/** - * Regression tests for {@link GameObjectFactory}. - * @author Andreas Kirschbaum - */ -public class GameObjectFactoryTest { - - /** - * Checks that {@link - * net.sf.gridarta.model.gameobject.GameObjectFactory#cloneGameObject(GameObject)} - * correctly updates the container. - * @throws DuplicateArchetypeException if the test fails - * @throws CannotInsertGameObjectException if the test fails - */ - @Test - public void testDoMoveSquareTopSingle() throws CannotInsertGameObjectException, DuplicateArchetypeException { - final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); - final TestMapModelHelper mapModelHelper = testMapControlCreator.newMapModelCreator(); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); - - final Point point = new Point(0, 0); - final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); - mapModel.beginTransaction("TEST"); - final TestGameObject ob1 = mapModelHelper.insertFloor(mapModel, point); - final TestGameObject ob2 = mapModelHelper.insertExit(ob1); - - final TestGameObject ob1Clone = testMapControlCreator.getGameObjectFactory().cloneGameObject(ob1); - - Assert.assertNotSame(ob1, ob1Clone); - Assert.assertEquals(1, ob1Clone.countInvObjects()); - final TestGameObject ob2Clone = ob1Clone.getFirst(); - Assert.assertNotNull(ob2Clone); - Assert.assertNotSame(ob2, ob2Clone); - - Assert.assertSame(ob1, ob2.getContainer()); - Assert.assertSame(ob1Clone, ob2Clone.getContainer()); - } - -} // class GameObjectFactoryTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-02 07:07:38
|
Revision: 8575 http://gridarta.svn.sourceforge.net/gridarta/?rev=8575&view=rev Author: akirschbaum Date: 2010-07-02 07:07:32 +0000 (Fri, 02 Jul 2010) Log Message: ----------- Add nullable annotations. Modified Paths: -------------- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-01 21:47:09 UTC (rev 8574) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-02 07:07:32 UTC (rev 8575) @@ -74,6 +74,7 @@ * The map model listener registered to {@link #mapModel} to record map * changes. */ + @NotNull private final MapModelListener<TestGameObject, TestMapArchObject, TestArchetype> mapModelListener = new MapModelListener<TestGameObject, TestMapArchObject, TestArchetype>() { /** @@ -158,11 +159,13 @@ /** * Collects the map model changes. */ + @NotNull private final StringBuilder result = new StringBuilder(); /** * The map model that gets changed. */ + @Nullable private DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = null; /** @@ -180,6 +183,7 @@ /** * The {@link InsertionModeSet} instance. */ + @Nullable private InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype> insertionModeSet = null; /** @@ -368,7 +372,7 @@ * @param y the y coordinate to add to * @param insertionMode the insertion mode to use */ - private void addGameObjectToMap(final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, final String name, final int x, final int y, final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> insertionMode) { + private void addGameObjectToMap(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String name, final int x, final int y, @NotNull final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> insertionMode) { final TestGameObject gameObject = newGameObject(name); mapModel.addGameObjectToMap(gameObject, new Point(x, y), insertionMode); } @@ -378,7 +382,7 @@ * @param gameObject the game object to add to * @param name the name of the game object to add */ - private void insertGameObject(final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject, final String name) { + private void insertGameObject(@NotNull final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject, @NotNull final String name) { final TestGameObject inv = newGameObject(name); gameObject.addLast(inv); } @@ -404,7 +408,7 @@ * @param mapSquares the changed map squares * @param gameObjects the changed game objects */ - private void log(final String name, final Iterable<MapSquare<TestGameObject, TestMapArchObject, TestArchetype>> mapSquares, final Iterable<TestGameObject> gameObjects) { + private void log(@NotNull final String name, @Nullable final Iterable<MapSquare<TestGameObject, TestMapArchObject, TestArchetype>> mapSquares, @Nullable final Iterable<TestGameObject> gameObjects) { result.append(name); result.append(":\n"); if (mapSquares != null) { @@ -465,6 +469,7 @@ * Creates a new {@link FaceObjectProviders} instance. * @return the face object providers instance */ + @NotNull private FaceObjectProviders newFaceObjectProviders() { final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); assert systemIcons != null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 21:47:16
|
Revision: 8574 http://gridarta.svn.sourceforge.net/gridarta/?rev=8574&view=rev Author: akirschbaum Date: 2010-07-01 21:47:09 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Add regression tests for AutojoinLists. Modified Paths: -------------- trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/mapmodel/CannotInsertGameObjectException.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java Modified: trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-01 20:32:09 UTC (rev 8573) +++ trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -30,13 +30,25 @@ import net.sf.gridarta.model.archetype.TestArchetypeFactory; import net.sf.gridarta.model.archetype.TestArchetypeSet; import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.face.TestFaceObjects; +import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; +import net.sf.gridarta.model.mapmodel.InsertionMode; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapModelFactory; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; +import net.sf.gridarta.model.mapmodel.TopmostInsertionMode; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; +import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.junit.Assert; @@ -86,6 +98,104 @@ } /** + * Checks that inserting with autojoin works as expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testInsert1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final Creator creator = new Creator(); + creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + final Creator2 creator2 = new Creator2(creator); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = creator2.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = newTestMapModelCreator(creator); + final TestArchetype a0 = creator.archetypeSet.getArchetype("a0"); + final TestArchetype a1 = creator.archetypeSet.getArchetype("a1"); + final TestArchetype a6 = creator.archetypeSet.getArchetype("a6"); + final TestArchetype a8 = creator.archetypeSet.getArchetype("a8"); + testMapModelHelper.insertArchetype(mapModel, 1, 0, a1, false); + testMapModelHelper.insertArchetype(mapModel, 0, 1, a8, false); + + creator.mapViewSettings.setAutojoin(true); + + // insert using autojoin + testMapModelHelper.insertArchetype(mapModel, 1, 1, a0, true); + TestMapModelHelper.checkMapContents(mapModel, "|a5|", "a10|a9|"); + + // insert duplicate archetype is ignored + try { + testMapModelHelper.insertArchetype(mapModel, 1, 1, a0, true); + Assert.fail(); + } catch (final CannotInsertGameObjectException ignored) { + // ignore + } + TestMapModelHelper.checkMapContents(mapModel, "|a5|", "a10|a9|"); + + // insert using autojoin + testMapModelHelper.insertArchetype(mapModel, 2, 1, a6, true); + TestMapModelHelper.checkMapContents(mapModel, "|a5|", "a10|a11|a8"); + + // insert using autojoin but disabled autojoin globally + creator.mapViewSettings.setAutojoin(false); + testMapModelHelper.insertArchetype(mapModel, 2, 0, a6, true); + TestMapModelHelper.checkMapContents(mapModel, "|a5|a6", "a10|a11|a8"); + } + + /** + * Checks that removing with autojoin works as expected. + * @throws IllegalAutojoinListException if the test fails + * @throws DuplicateArchetypeException if the test fails + * @throws UndefinedArchetypeException if the test fails + * @throws CannotInsertGameObjectException if the test fails + */ + @Test + public void testRemove1() throws CannotInsertGameObjectException, DuplicateArchetypeException, IllegalAutojoinListException, UndefinedArchetypeException { + final Creator creator = new Creator(); + creator.newAutojoinLists("a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); + final Creator2 creator2 = new Creator2(creator); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = creator2.newMapModel(3, 2); + final TestMapModelHelper testMapModelHelper = newTestMapModelCreator(creator); + final TestArchetype a4 = creator.archetypeSet.getArchetype("a4"); + final TestArchetype a8 = creator.archetypeSet.getArchetype("a8"); + final TestArchetype a10 = creator.archetypeSet.getArchetype("a10"); + final TestArchetype a11 = creator.archetypeSet.getArchetype("a11"); + final TestGameObject g10 = testMapModelHelper.insertArchetype(mapModel, 1, 0, a4, false); + final TestGameObject g01 = testMapModelHelper.insertArchetype(mapModel, 0, 1, a10, false); + testMapModelHelper.insertArchetype(mapModel, 1, 1, a11, false); + final TestGameObject g21 = testMapModelHelper.insertArchetype(mapModel, 2, 1, a8, false); + + // remove using autojoin + creator.mapViewSettings.setAutojoin(true); + mapModel.removeGameObject(g21, true); + TestMapModelHelper.checkMapContents(mapModel, "|a4|", "a10|a9|"); + + // remove using autojoin but globally disabled + creator.mapViewSettings.setAutojoin(false); + mapModel.removeGameObject(g10, true); + TestMapModelHelper.checkMapContents(mapModel, "||", "a10|a9|"); + + // remove using autojoin + creator.mapViewSettings.setAutojoin(true); + mapModel.removeGameObject(g01, true); + TestMapModelHelper.checkMapContents(mapModel, "||", "|a1|"); + } + + /** + * Creates a new {@link TestMapModelHelper} instance. + * @param creator the creator to use + * @return the new test map model creator instance + * @throws DuplicateArchetypeException if an internal error occurs + */ + @NotNull + private static TestMapModelHelper newTestMapModelCreator(@NotNull final Creator creator) throws DuplicateArchetypeException { + final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(creator.faceObjectProviders, creator.animationObjects); + final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); + return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, creator.archetypeSet, creator.faceObjectProviders, creator.animationObjects); + } + + /** * Creator for {@link AutojoinList} instances. */ private static class Creator { @@ -109,6 +219,12 @@ private final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects; /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** * The {@link ArchetypeSet} instance. */ @NotNull @@ -125,7 +241,7 @@ faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); archetypeSet = new TestArchetypeSet(archetypeFactory, "arch", faceObjectProviders); animationObjects = new TestAnimationObjects(); - final TestMapViewSettings mapViewSettings = new TestMapViewSettings(); + mapViewSettings = new TestMapViewSettings(); autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); } @@ -179,4 +295,41 @@ } + /** + * Creator for {@link MapModel} instances. + */ + private static class Creator2 { + + /** + * The {@link MapModelFactory} for creating {@link MapModel} instances. + */ + @NotNull + private final MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype> mapModelFactory; + + /** + * Creates a new instance. + * @param creator the creator to use + */ + private Creator2(@NotNull final Creator creator) { + final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); + final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(creator.faceObjectProviders, creator.animationObjects); + final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); + final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); + mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, creator.autojoinLists, creator.mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + } + + /** + * Creates a new {@link MapModel} instance. + * @param width the map width in squares + * @param height the map height in squares + * @return the map model instance + */ + @NotNull + public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel(final int width, final int height) { + final TestMapArchObject mapArchObject = new TestMapArchObject(); + mapArchObject.setMapSize(new Size2D(width, height)); + return mapModelFactory.newMapModel(mapArchObject); + } + } + } // class AutojoinListsTest Added: trunk/model/src/test/net/sf/gridarta/model/mapmodel/CannotInsertGameObjectException.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/CannotInsertGameObjectException.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/CannotInsertGameObjectException.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -0,0 +1,46 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapmodel; + +import java.awt.Point; +import net.sf.gridarta.model.baseobject.BaseObject; +import org.jetbrains.annotations.NotNull; + +/** + * Exception thrown if a game object cannot be inserted into a map. + * @author Andreas Kirschbaum + */ +public class CannotInsertGameObjectException extends Exception { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance. + * @param archetype the archetypes that cannot be inserted + * @param point the insertion location + */ + public CannotInsertGameObjectException(@NotNull final BaseObject<?, ?, ?, ?> archetype, @NotNull final Point point) { + super(archetype.getBestName() + " at " + point.x + "/" + point.y); + } + +} // class CannotInsertGameObjectException Property changes on: trunk/model/src/test/net/sf/gridarta/model/mapmodel/CannotInsertGameObjectException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -0,0 +1,313 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapmodel; + +import java.awt.Point; +import java.util.regex.Pattern; +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.archetype.ArchetypeSet; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.baseobject.GameObjectContainer; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; + +/** + * Helper class for creating {@link MapModel} instances for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapModelHelper { + + /** + * The archetype type used for "exit" game objects. + */ + public static final int EXIT_TYPE = 1; + + /** + * The archetype type used for "floor" game objects. + */ + private static final int FLOOR_TYPE = 2; + + /** + * The archetype type used for "mob" game objects. + */ + private static final int MOB_TYPE = 3; + + /** + * An empty array of strings. + */ + @NotNull + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + /** + * The "topmost" {@link InsertionMode} instance. + */ + @NotNull + private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; + + /** + * The {@link GameObjectFactory} instance. + */ + @NotNull + private final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory; + + /** + * The archetype to create floor game objects. + */ + @NotNull + private final TestArchetype floorArchetype; + + /** + * The archetype to create exit game objects. + */ + @NotNull + private final TestArchetype exitArchetype; + + /** + * The archetype to create 2x1 mob game objects. + */ + @NotNull + private final TestArchetype mob21Archetype; + + /** + * Creates a new instance. + * @param topmostInsertionMode the "topmost" insertion mode instance + * @param gameObjectFactory the game object factory to use + * @param archetypeSet the archetype set to use + * @param faceObjectProviders the face object providers to use + * @param animationObjects the animation objects to use + * @throws DuplicateArchetypeException if an internal error occurs + */ + public TestMapModelHelper(@NotNull final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode, @NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects) throws DuplicateArchetypeException { + this.topmostInsertionMode = topmostInsertionMode; + this.gameObjectFactory = gameObjectFactory; + + floorArchetype = new TestArchetype("floor", faceObjectProviders, animationObjects); + floorArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(FLOOR_TYPE)); + archetypeSet.addArchetype(floorArchetype); + + exitArchetype = new TestArchetype("exit", faceObjectProviders, animationObjects); + exitArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(EXIT_TYPE)); + archetypeSet.addArchetype(exitArchetype); + + mob21Archetype = new TestArchetype("mob21", faceObjectProviders, animationObjects); + mob21Archetype.setAttributeString(BaseObject.TYPE, Integer.toString(MOB_TYPE)); + archetypeSet.addArchetype(mob21Archetype); + final TestArchetype mob21bArchetype = new TestArchetype("mob21b", faceObjectProviders, animationObjects); + mob21bArchetype.setMultiX(1); + mob21Archetype.addTailPart(mob21bArchetype); + archetypeSet.addArchetype(mob21bArchetype); + } + + /** + * Inserts a {@link #floorArchetype} game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @return the inserted game object + * @throws CannotInsertGameObjectException if the archetype cannot be + * inserted + */ + @NotNull + public TestGameObject insertFloor(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) throws CannotInsertGameObjectException { + return insertArchetype(mapModel, point, floorArchetype, false); + } + + /** + * Inserts an {@link #exitArchetype} game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @return the inserted game object + * @throws CannotInsertGameObjectException if the archetype cannot be + * inserted + */ + @NotNull + public TestGameObject insertExit(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) throws CannotInsertGameObjectException { + return insertArchetype(mapModel, point, exitArchetype, false); + } + + /** + * Inserts a {@link #mob21Archetype} game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @return the inserted game object + * @throws CannotInsertGameObjectException if the archetype cannot be + * inserted + */ + @NotNull + public TestGameObject insertMob21(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) throws CannotInsertGameObjectException { + return insertArchetype(mapModel, point, mob21Archetype, false); + } + + /** + * Inserts an archetype game object into a map model. + * @param mapModel the map model to insert into + * @param x the x coordinate to insert at + * @param y the y coordinate to insert at + * @param archetype the archetype to insert + * @param join whether to perform autojoining + * @return the inserted game object + * @throws CannotInsertGameObjectException if the archetype cannot be + * inserted + */ + @NotNull + public TestGameObject insertArchetype(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, final int x, final int y, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype, final boolean join) throws CannotInsertGameObjectException { + return insertArchetype(mapModel, new Point(x, y), archetype, join); + } + + /** + * Inserts an archetype game object into a map model. + * @param mapModel the map model to insert into + * @param point the position to insert at + * @param archetype the archetype to insert + * @param join whether to perform autojoining + * @return the inserted game object + * @throws CannotInsertGameObjectException if the archetype cannot be + * inserted + */ + @NotNull + public TestGameObject insertArchetype(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype, final boolean join) throws CannotInsertGameObjectException { + final TestGameObject gameObject = mapModel.insertBaseObject(archetype, point, true, join, topmostInsertionMode); + if (gameObject == null) { + throw new CannotInsertGameObjectException(archetype, point); + } + return gameObject; + } + + /** + * Inserts an {@link #exitArchetype} game object into a game object. + * @param gameObject the game object + * @return the inserted game object + */ + @NotNull + public TestGameObject insertExit(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject) { + return insertArchetype(gameObject, exitArchetype); + } + + /** + * Inserts a {@link #mob21Archetype} game object into a game object. + * @param gameObject the game object + * @return the inserted game object + */ + @NotNull + public TestGameObject insertMob21(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject) { + return insertArchetype(gameObject, mob21Archetype); + } + + /** + * Inserts an archetype into a game object. + * @param gameObject the game object + * @param archetype the archetype to insert + * @return the inserted game object + */ + @NotNull + public TestGameObject insertArchetype(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype) { + final TestGameObject newGameObject = archetype.newInstance(gameObjectFactory); + gameObject.addLast(newGameObject); + return newGameObject; + } + + /** + * Checks for expected {@link MapModel}'s contents. + * @param mapModel the map model + * @param lines the expected contents + */ + public static void checkMapContents(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String... lines) { + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + Assert.assertEquals(lines.length, mapSize.getHeight()); + final Pattern pattern1 = Pattern.compile("\\|"); + final Pattern pattern2 = Pattern.compile(","); + final Point pos = new Point(); + for (int y = 0; y < lines.length; y++) { + final CharSequence line = lines[y]; + final String[] square = pattern1.split(line, -1); + Assert.assertEquals(square.length, mapSize.getWidth()); + + for (int x = 0; x < square.length; x++) { + final String square2 = square[x]; + final String[] gameObjects = square2.isEmpty() ? EMPTY_STRING_ARRAY : pattern2.split(square2, -1); + pos.x = x; + pos.y = y; + checkContentsString(mapModel.getMapSquare(pos), gameObjects); + } + } + } + + /** + * Checks that a {@link MapSquare} contains the given game objects. + * @param mapSquare the map square + * @param gameObjects the game object + */ + private static void checkContentsString(@NotNull final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare, @NotNull final String... gameObjects) { + int i = 0; + for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { + final String gameObjectName = gameObject.getBestName(); + if (i >= gameObjects.length) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains excess game object '" + gameObjectName + "'"); + } else if (!gameObjectName.equals(gameObjects[i])) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i] + "'"); + } + i++; + } + if (i < gameObjects.length) { + Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " is missing game object '" + gameObjects[i] + "'"); + } + } + + /** + * Checks that a {@link MapSquare} contains the given game objects. + * @param mapSquare the map square + * @param gameObjects the game object + */ + public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final TestGameObject... gameObjects) { + int i = 0; + for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { + final String gameObjectName = gameObject.getBestName(); + if (i >= gameObjects.length) { + Assert.fail("map square contains excess game object '" + gameObjectName + "'"); + } else if (gameObject != gameObjects[i]) { + Assert.fail("map square contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i].getBestName() + "'"); + } + i++; + } + if (i < gameObjects.length) { + Assert.fail("map square is missing game object '" + gameObjects[i].getBestName() + "'"); + } + + final boolean inContainer = mapSquare instanceof GameObject; + for (final GameObject<?, ?, ?> gameObject : mapSquare) { + Assert.assertEquals(inContainer, gameObject.isInContainer()); + if (inContainer) { + // game objects within inventories must not contain tail parts + Assert.assertFalse(gameObject.isMulti()); + } else { + // game objects on the map must have expanded tail parts + Assert.assertEquals(gameObject.getArchetype().isMulti(), gameObject.isMulti()); + } + } + } + +} // class TestMapModelHelper Property changes on: trunk/model/src/test/net/sf/gridarta/model/mapmodel/TestMapModelHelper.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-07-01 20:32:09 UTC (rev 8573) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -32,7 +32,9 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -73,6 +75,12 @@ private TestMapControlCreator testMapControlCreator = null; /** + * The {@link TestMapModelHelper} instance. + */ + @Nullable + private TestMapModelHelper mapModelHelper = null; + + /** * Checks that {@link ExitConnectorActions#doExitCopy(boolean, MapControl, * Point)} does work. */ @@ -104,9 +112,10 @@ /** * Checks that {@link ExitConnectorActions#doExitPaste(boolean, MapControl, * Point)} does work. + * @throws CannotInsertGameObjectException if the test fails */ @Test - public void testExitPaste1() { + public void testExitPaste1() throws CannotInsertGameObjectException { final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); final Size2D mapSize = new Size2D(5, 5); @@ -125,8 +134,8 @@ mapModel.beginTransaction("TEST"); try { - assert testMapControlCreator != null; - testMapControlCreator.insertFloor(mapModel, point1); + assert mapModelHelper != null; + mapModelHelper.insertFloor(mapModel, point1); } finally { mapModel.endTransaction(); } @@ -136,8 +145,8 @@ mapModel.beginTransaction("TEST"); try { - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel, point1); + assert mapModelHelper != null; + mapModelHelper.insertExit(mapModel, point1); } finally { mapModel.endTransaction(); } @@ -184,9 +193,10 @@ /** * Checks that {@link ExitConnectorActions#doExitConnect(boolean, * MapControl, Point)} does work. + * @throws CannotInsertGameObjectException if the test fails */ @Test - public void testExitConnect1() { + public void testExitConnect1() throws CannotInsertGameObjectException { final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); @@ -210,8 +220,8 @@ mapModel1.beginTransaction("TEST"); try { - assert testMapControlCreator != null; - testMapControlCreator.insertFloor(mapModel1, point1); + assert mapModelHelper != null; + mapModelHelper.insertFloor(mapModel1, point1); } finally { mapModel1.endTransaction(); } @@ -221,8 +231,8 @@ mapModel1.beginTransaction("TEST"); try { - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel1, point1); + assert mapModelHelper != null; + mapModelHelper.insertExit(mapModel1, point1); } finally { mapModel1.endTransaction(); } @@ -232,8 +242,8 @@ mapModel2.beginTransaction("TEST"); try { - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel2, point2); + assert mapModelHelper != null; + mapModelHelper.insertExit(mapModel2, point2); } finally { mapModel2.endTransaction(); } @@ -298,9 +308,10 @@ /** * Checks that exit paths are correctly generated. + * @throws CannotInsertGameObjectException if the test fails */ @Test - public void testPath1() { + public void testPath1() throws CannotInsertGameObjectException { // both root ==> relative testPath("/a", "/b", "b"); // both root ==> relative @@ -326,8 +337,9 @@ * exit object * @param mapPathTo the map path to connect to * @param expectedExitPath the expected map in the exit object + * @throws CannotInsertGameObjectException if the test fails */ - private void testPath(@NotNull final String mapPathFrom, @NotNull final String mapPathTo, @NotNull final String expectedExitPath) { + private void testPath(@NotNull final String mapPathFrom, @NotNull final String mapPathTo, @NotNull final String expectedExitPath) throws CannotInsertGameObjectException { final ExitConnectorModel model = new TestExitConnectorModel(); final ExitConnectorActions<TestGameObject, TestMapArchObject, TestArchetype> actions = createActions(model); @@ -348,8 +360,8 @@ model.setExitLocation(new ExitLocation(mapFileTo, pointTo, MAP_NAME2, testMapControlCreator.getPathManager())); mapModel.beginTransaction("TEST"); try { - assert testMapControlCreator != null; - testMapControlCreator.insertExit(mapModel, pointFrom); + assert mapModelHelper != null; + mapModelHelper.insertExit(mapModel, pointFrom); } finally { mapModel.endTransaction(); } @@ -366,6 +378,7 @@ @Before public void setUp() throws DuplicateArchetypeException { testMapControlCreator = new TestMapControlCreator(); + mapModelHelper = testMapControlCreator.newMapModelCreator(); } /** @@ -393,7 +406,7 @@ int thisIndex = 0; for (final BaseObject<?, ?, ?, ?> gameObject : mapModel.getMapSquare(point)) { if (thisIndex == index) { - if (gameObject.getTypeNo() != TestMapControlCreator.EXIT_TYPE) { + if (gameObject.getTypeNo() != TestMapModelHelper.EXIT_TYPE) { break; } Modified: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2010-07-01 20:32:09 UTC (rev 8573) +++ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -30,7 +30,9 @@ import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapgrid.SelectionMode; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; import net.sf.gridarta.utils.Size2D; import org.junit.Test; @@ -53,24 +55,26 @@ /** * Checks that {@link CopyBuffer#cut(MapView, Rectangle)} followed by {@link * CopyBuffer#paste(MapView, Point)} does work. + * @throws CannotInsertGameObjectException if the test fails * @throws DuplicateArchetypeException if the test fails */ @Test - public void testCutPaste1() throws DuplicateArchetypeException { + public void testCutPaste1() throws CannotInsertGameObjectException, DuplicateArchetypeException { final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final TestMapModelHelper mapModelHelper = testMapControlCreator.newMapModelCreator(); final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(3, 3)); final Point point = new Point(1, 1); final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); - final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); - final TestGameObject ob2 = testMapControlCreator.insertMob21(ob1); + final TestGameObject ob1 = mapModelHelper.insertFloor(mapModel, point); + final TestGameObject ob2 = mapModelHelper.insertMob21(ob1); - TestMapControlCreator.checkMapContents(mapModel, + TestMapModelHelper.checkMapContents(mapModel, "||", "|floor|", "||"); - TestMapControlCreator.checkContents(ob1, ob2); + TestMapModelHelper.checkContents(ob1, ob2); // select + cut final CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> copyBuffer = testMapControlCreator.newCopyBuffer(); @@ -78,7 +82,7 @@ mapView.getMapViewBasic().getMapGrid().select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); copyBuffer.cut(mapView, new Rectangle(1, 1, 1, 1)); - TestMapControlCreator.checkMapContents(mapModel, + TestMapModelHelper.checkMapContents(mapModel, "||", "||", "||"); @@ -86,7 +90,7 @@ // paste copyBuffer.paste(mapView, new Point(1, 1)); - TestMapControlCreator.checkMapContents(mapModel, + TestMapModelHelper.checkMapContents(mapModel, "||", "|floor|", "||"); Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-07-01 20:32:09 UTC (rev 8573) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -20,10 +20,8 @@ package net.sf.gridarta.gui.map.test; import java.awt.Image; -import java.awt.Point; import java.awt.image.BufferedImage; import java.io.File; -import java.util.regex.Pattern; import net.sf.gridarta.gui.copybuffer.CopyBuffer; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewBasic; @@ -50,14 +48,10 @@ import net.sf.gridarta.model.archetype.TestArchetypeSet; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.autojoin.AutojoinLists; -import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.exitconnector.ExitMatcher; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; @@ -80,9 +74,8 @@ import net.sf.gridarta.model.mapcontrol.TestMapControlFactory; import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.InsertionModeSet; -import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapModelFactory; -import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; import net.sf.gridarta.model.mapmodel.TopmostInsertionMode; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; @@ -96,7 +89,6 @@ import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.junit.Assert; /** * Helper class for creating {@link MapControl} instances for regression tests. @@ -105,33 +97,12 @@ public class TestMapControlCreator { /** - * The archetype type used for "exit" game objects. + * The {@link AnimationObjects} instance. */ - public static final int EXIT_TYPE = 1; - - /** - * The archetype type used for "floor" game objects. - */ - private static final int FLOOR_TYPE = 2; - - /** - * The archetype type used for "mob" game objects. - */ - private static final int MOB_TYPE = 3; - - /** - * An empty array of strings. - */ @NotNull - private static final String[] EMPTY_STRING_ARRAY = new String[0]; + private final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects; /** - * The {@link SystemIcons} instance. - */ - @NotNull - private final SystemIcons systemIcons; - - /** * The {@link MapManager} instance. */ @NotNull @@ -156,36 +127,30 @@ private final PathManager pathManager; /** - * The {@link ExitMatcher} instance. + * The "topmost" {@link InsertionMode} instance. */ @NotNull - private final ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> exitMatcher; + private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; /** - * The {@link ArchetypeSet} instance. + * The {@link ExitMatcher} instance. */ @NotNull - private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; + private final ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype> exitMatcher; /** - * The archetype to create floor game objects. + * The {@link FaceObjectProviders} instance. */ @NotNull - private final TestArchetype floorArchetype; + private final FaceObjectProviders faceObjectProviders; /** - * The archetype to create exit game objects. + * The {@link ArchetypeSet} instance. */ @NotNull - private final TestArchetype exitArchetype; + private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; /** - * The archetype to create 2x1 mob game objects. - */ - @NotNull - private final TestArchetype mob21Archetype; - - /** * The {@link GlobalSettings} instance. */ @NotNull @@ -216,12 +181,6 @@ private final MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype> mapModelFactory; /** - * The "topmost" {@link InsertionMode} instance. - */ - @NotNull - private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; - - /** * The {@link InsertionModeSet} instance. */ @NotNull @@ -229,16 +188,16 @@ /** * Creates a new instance. - * @throws DuplicateArchetypeException if an internal error occurs */ - public TestMapControlCreator() throws DuplicateArchetypeException { + public TestMapControlCreator() { final GUIUtils guiUtils = new GUIUtils(); - systemIcons = new SystemIcons(guiUtils); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); - final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(EXIT_TYPE); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(TestMapModelHelper.EXIT_TYPE); exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); - final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); + faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); mapViewSettings = new TestMapViewSettings(); @@ -262,22 +221,15 @@ final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpPickmapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); tmpPickmapManager.setFileControl(fileControl); pickmapManager = tmpPickmapManager; + } - floorArchetype = new TestArchetype("floor", faceObjectProviders, animationObjects); - floorArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(FLOOR_TYPE)); - archetypeSet.addArchetype(floorArchetype); - - exitArchetype = new TestArchetype("exit", faceObjectProviders, animationObjects); - exitArchetype.setAttributeString(BaseObject.TYPE, Integer.toString(EXIT_TYPE)); - archetypeSet.addArchetype(exitArchetype); - - mob21Archetype = new TestArchetype("mob21", faceObjectProviders, animationObjects); - mob21Archetype.setAttributeString(BaseObject.TYPE, Integer.toString(MOB_TYPE)); - archetypeSet.addArchetype(mob21Archetype); - final TestArchetype mob21bArchetype = new TestArchetype("mob21b", faceObjectProviders, animationObjects); - mob21bArchetype.setMultiX(1); - mob21Archetype.addTailPart(mob21bArchetype); - archetypeSet.addArchetype(mob21bArchetype); + /** + * Creates a new {@link TestMapModelHelper} instance. + * @return the new instance + * @throws DuplicateArchetypeException if an internal error occurs + */ + public TestMapModelHelper newMapModelCreator() throws DuplicateArchetypeException { + return new TestMapModelHelper(topmostInsertionMode, gameObjectFactory, archetypeSet, faceObjectProviders, animationObjects); } /** @@ -296,99 +248,6 @@ } /** - * Inserts a {@link #floorArchetype} game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - * @return the inserted game object - */ - @NotNull - public TestGameObject insertFloor(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { - return insertArchetype(mapModel, point, floorArchetype); - } - - /** - * Inserts an {@link #exitArchetype} game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - * @return the inserted game object - */ - @NotNull - public TestGameObject insertExit(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { - return insertArchetype(mapModel, point, exitArchetype); - } - - /** - * Inserts a {@link #mob21Archetype} game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - * @return the inserted game object - */ - @NotNull - public TestGameObject insertMob21(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point) { - return insertArchetype(mapModel, point, mob21Archetype); - } - - /** - * Inserts an archetype game object into a map model. - * @param mapModel the map model to insert into - * @param point the position to insert at - * @param archetype the archetype to insert - * @return the inserted game object - */ - @NotNull - private TestGameObject insertArchetype(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Point point, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype) { - final TestGameObject gameObject = mapModel.insertBaseObject(archetype, point, true, false, topmostInsertionMode); - if (gameObject == null) { - throw new AssertionError(); - } - return gameObject; - } - - /** - * Inserts an {@link #exitArchetype} game object into a game object. - * @param gameObject the game object - * @return the inserted game object - */ - @NotNull - public TestGameObject insertExit(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject) { - return insertArchetype(gameObject, exitArchetype); - } - - /** - * Inserts a {@link #mob21Archetype} game object into a game object. - * @param gameObject the game object - * @return the inserted game object - */ - @NotNull - public TestGameObject insertMob21(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject) { - return insertArchetype(gameObject, mob21Archetype); - } - - /** - * Inserts an archetype into a game object. - * @param gameObject the game object - * @param archetype the archetype to insert - * @return the inserted game object - */ - @NotNull - public TestGameObject insertArchetype(@NotNull final GameObjectContainer<TestGameObject, TestMapArchObject, TestArchetype> gameObject, @NotNull final BaseObject<TestGameObject, TestMapArchObject, TestArchetype, ?> archetype) { - final TestGameObject newGameObject = archetype.newInstance(gameObjectFactory); - gameObject.addLast(newGameObject); - return newGameObject; - } - - /** - * Creates a new {@link FaceObjectProviders} instance. - * @return the face object providers instance - */ - private FaceObjectProviders newFaceObjectProviders() { - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("test", "bmaps.paths", Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - return faceObjectProviders; - } - - /** * Returns the {@link PathManager}. * @return the path manager */ @@ -443,60 +302,6 @@ } /** - * Checks that a {@link MapSquare} contains the given game objects. - * @param mapSquare the map square - * @param gameObjects the game object - */ - public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final TestGameObject... gameObjects) { - int i = 0; - for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { - final String gameObjectName = gameObject.getBestName(); - if (i >= gameObjects.length) { - Assert.fail("map square contains excess game object '" + gameObjectName + "'"); - } else if (gameObject != gameObjects[i]) { - Assert.fail("map square contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i].getBestName() + "'"); - } - i++; - } - if (i < gameObjects.length) { - Assert.fail("map square is missing game object '" + gameObjects[i].getBestName() + "'"); - } - - final boolean inContainer = mapSquare instanceof GameObject; - for (final GameObject<?, ?, ?> gameObject : mapSquare) { - Assert.assertEquals(inContainer, gameObject.isInContainer()); - if (inContainer) { - // game objects within inventories must not contain tail parts - Assert.assertFalse(gameObject.isMulti()); - } else { - // game objects on the map must have expanded tail parts - Assert.assertEquals(gameObject.getArchetype().isMulti(), gameObject.isMulti()); - } - } - } - - /** - * Checks that a {@link MapSquare} contains the given game objects. - * @param mapSquare the map square - * @param gameObjects the game object - */ - private static void checkContentsString(@NotNull final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare, @NotNull final String... gameObjects) { - int i = 0; - for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { - final String gameObjectName = gameObject.getBestName(); - if (i >= gameObjects.length) { - Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains excess game object '" + gameObjectName + "'"); - } else if (!gameObjectName.equals(gameObjects[i])) { - Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains wrong game object '" + gameObjectName + "' at index " + i + ", expected '" + gameObjects[i] + "'"); - } - i++; - } - if (i < gameObjects.length) { - Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " is missing game object '" + gameObjects[i] + "'"); - } - } - - /** * Creates a new {@link MapView} instance. * @param mapControl the associated map control * @return the map view instance @@ -518,32 +323,6 @@ } /** - * Checks for expected {@link MapModel}'s contents. - * @param mapModel the map model - * @param lines the expected contents - */ - public static void checkMapContents(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final String... lines) { - final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); - Assert.assertEquals(lines.length, mapSize.getHeight()); - final Pattern pattern1 = Pattern.compile("\\|"); - final Pattern pattern2 = Pattern.compile(","); - final Point pos = new Point(); - for (int y = 0; y < lines.length; y++) { - final CharSequence line = lines[y]; - final String[] square = pattern1.split(line, -1); - Assert.assertEquals(square.length, mapSize.getWidth()); - - for (int x = 0; x < square.length; x++) { - final String square2 = square[x]; - final String[] gameObjects = square2.isEmpty() ? EMPTY_STRING_ARRAY : pattern2.split(square2, -1); - pos.x = x; - pos.y = y; - checkContentsString(mapModel.getMapSquare(pos), gameObjects); - } - } - } - - /** * Returns the {@link GameObjectFactory} instance. * @return the game object factory */ Modified: trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-07-01 20:32:09 UTC (rev 8573) +++ trunk/src/test/net/sf/gridarta/gui/selectedsquare/SelectedSquareActionsTest.java 2010-07-01 21:47:09 UTC (rev 8574) @@ -28,8 +28,10 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.mapmodel.TestMapModelHelper; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.junit.Assert; @@ -54,11 +56,13 @@ /** * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does * work for single-square game objects. + * @throws CannotInsertGameObjectException if the test fails * @throws DuplicateArchetypeException if the test fails */ @Test - public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + public void testDoMoveSquareTopSingle() throws CannotInsertGameObjectException, DuplicateArchetypeException { final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final TestMapModelHelper mapModelHelper = testMapControlCreator.newMapModelCreator(); final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, new Size2D(1, 1)); final SelectedSquareModel<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareModel = newSelectedSquareModel(mapControl); final SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype> selectedSquareActions = new SelectedSquareActions<TestGameObject, TestMapArchObject, TestArchetype>(selectedSquareModel); @@ -67,10 +71,10 @@ final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("TEST"); final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare = mapModel.getMapSquare(point); - final TestGameObject ob2 = testMapControlCreator.insertFloor(mapModel, point); - final TestGameObject ob1 = testMapControlCreator.insertExit(mapModel, point); + final TestGameObject ob2 = mapModelHelper.insertFloor(mapModel, point); + final TestGameObject ob1 = mapModelHelper.insertExit(mapModel, point); - TestMapControlCreator.checkContents(mapSquare, ob2, ob1); + TestMapModelHelper.checkContents(mapSquare, ob2, ob1); // empty selection => nothing to move Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); @@ -82,22 +86,24 @@ // [ob2, ob1] => ob2 can move Assert.assertTrue(selectedSquareActions.doMoveSquareTop(false)); Assert.assertTrue(selectedSquareActions.doMoveSquareTop(true)); - TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + TestMapModelHelper.checkContents(mapSquare, ob1, ob2); // [ob1, ob2] => ob2 cannot move Assert.assertFalse(selectedSquareActions.doMoveSquareTop(false)); Assert.assertFalse(selectedSquareActions.doMoveSquareTop(true)); - TestMapControlCreator.checkContents(mapSquare, ob1, ob2); + TestMapModelHelper.checkContents(mapSquare, ob1, ob2); } /** * Checks that {@link SelectedSquareActions#doMoveSquareTop(boolean)} does * work for multi-square game objects. + * @throws CannotInsertGameObjectException if the test fails * @throws DuplicateArchetypeException if the test fails */ @Test - public void testDoMoveSquareTopMulti() throws DuplicateArchetypeException { + public void testDoMoveSquareTopMulti() throws CannotInsertGameObjectException, DuplicateArchetypeException { final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final TestMapModelHelper mapModelHelper = testMapControlCreator.newMapModelCreator(); final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(MAP_FILE1, MAP_NAME1, n... [truncated message content] |
From: <aki...@us...> - 2010-07-01 20:32:15
|
Revision: 8573 http://gridarta.svn.sourceforge.net/gridarta/?rev=8573&view=rev Author: akirschbaum Date: 2010-07-01 20:32:09 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Add @NotNull annotation. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java Modified: trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java 2010-07-01 19:26:04 UTC (rev 8572) +++ trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java 2010-07-01 20:32:09 UTC (rev 8573) @@ -37,7 +37,7 @@ * Creates a new instance. * @param name localized name of the object type, e.g. used in dialogs */ - protected AbstractFaceObjects(final String name) { + protected AbstractFaceObjects(@NotNull final String name) { super(name); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 19:26:11
|
Revision: 8572 http://gridarta.svn.sourceforge.net/gridarta/?rev=8572&view=rev Author: akirschbaum Date: 2010-07-01 19:26:04 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Move DefaultAnimationObjects and DefaultFaceObjects out of model module. Modified Paths: -------------- trunk/build.xml Added Paths: ----------- trunk/src/app/net/sf/gridarta/model/ trunk/src/app/net/sf/gridarta/model/anim/ trunk/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java trunk/src/app/net/sf/gridarta/model/face/ trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java Removed Paths: ------------- trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-07-01 19:12:05 UTC (rev 8571) +++ trunk/build.xml 2010-07-01 19:26:04 UTC (rev 8572) @@ -245,6 +245,7 @@ <fileset dir="lib" includes="japi-lib-swing-action-0.1.0.jar"/> <fileset dir="lib" includes="junit-4.2.jar"/> <pathelement location="dest/atrinik/app"/> + <pathelement location="dest/gridarta/app"/> <pathelement location="dest/model/app"/> <pathelement location="dest/model/test"/> <pathelement location="dest/utils/app"/> @@ -279,6 +280,7 @@ <fileset dir="lib" includes="japi-lib-swing-action-0.1.0.jar"/> <fileset dir="lib" includes="junit-4.2.jar"/> <pathelement location="dest/crossfire/app"/> + <pathelement location="dest/gridarta/app"/> <pathelement location="dest/model/app"/> <pathelement location="dest/model/test"/> <pathelement location="dest/utils/app"/> @@ -312,6 +314,7 @@ <fileset dir="lib" includes="annotations.jar"/> <fileset dir="lib" includes="junit-4.2.jar"/> <pathelement location="dest/daimonin/app"/> + <pathelement location="dest/gridarta/app"/> <pathelement location="dest/model/app"/> <pathelement location="dest/utils/app"/> </classpath> Deleted: trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java 2010-07-01 19:12:05 UTC (rev 8571) +++ trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java 2010-07-01 19:26:04 UTC (rev 8572) @@ -1,128 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.model.anim; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.data.NamedObject; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.io.GameObjectParser; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.utils.ActionBuilderUtils; -import net.sf.gridarta.utils.IOUtils; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import net.sf.japi.swing.misc.Progress; -import org.jetbrains.annotations.NotNull; - -/** - * Abstract base implementation of {@link AnimationObjects}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DefaultAnimationObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAnimationObjects<G, A, R> { - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** - * Action Builder. - */ - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** - * The collected animation tree file. - */ - @NotNull - private final String animTreeFile; - - /** - * Creates a new instance. - * @param animTreeFile the collected animation tree file - */ - public DefaultAnimationObjects(@NotNull final String animTreeFile) { - super(ActionBuilderUtils.getString(ACTION_BUILDER, "nameOfAnimationObject")); - this.animTreeFile = animTreeFile; - } - - /** - * {@inheritDoc} Collects the Animations. The animation data is written to - * "animations". The tree information for the editor is written to - * "animtree". - */ - @Override - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final GameObjectParser<G, A, R> gameObjectParser) throws IOException { - collectAnimations(progress, collectedDirectory); - collectAnimTree(progress, collectedDirectory); - } - - /** - * Collects the animation data into the file "animations". - * @param progress Progress to report progress to. - * @param collectedDirectory the destination directory to collect data to - * @throws IOException in case of I/O problems during collection - */ - private void collectAnimations(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectAnimations"), size()); - final BufferedWriter animations = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(collectedDirectory, "animations")), IOUtils.MAP_ENCODING)); - try { - int counter = 0; // counter for progress bar - for (final AnimationObject anim : this) { - animations.append("anim ").append(anim.getAnimName()).append('\n').append(anim.getAnimList()).append("mina\n"); - if (counter++ % 128 == 0) { - progress.setValue(counter); - } - } - } finally { - animations.close(); - } - progress.setValue(size()); - } - - /** - * Collects the animation data into the file "animations". - * @param progress Progress to report progress to. - * @param collectedDirectory the destination directory to collect data to - * @throws IOException in case of I/O problems during collection - */ - private void collectAnimTree(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectAnimTree"), size()); - final BufferedWriter animtree = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(collectedDirectory, animTreeFile)), IOUtils.MAP_ENCODING)); - try { - int counter = 0; // counter for progress bar - for (final NamedObject anim : this) { - animtree.append(anim.getPath()).append('\n'); - if (counter++ % 128 == 0) { - progress.setValue(counter); - } - } - } finally { - animtree.close(); - } - progress.setValue(size()); - } - - -} // class DefaultAnimationObjects Deleted: trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-01 19:12:05 UTC (rev 8571) +++ trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-01 19:26:04 UTC (rev 8572) @@ -1,420 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.model.face; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Reader; -import java.net.URL; -import java.nio.channels.FileChannel; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.data.NamedObject; -import net.sf.gridarta.model.errorview.ErrorView; -import net.sf.gridarta.model.errorview.ErrorViewCategory; -import net.sf.gridarta.model.errorview.ErrorViewCollector; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.io.GameObjectParser; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.utils.ActionBuilderUtils; -import net.sf.gridarta.utils.ArrayUtils; -import net.sf.gridarta.utils.CommonConstants; -import net.sf.gridarta.utils.IOUtils; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import net.sf.japi.swing.misc.Progress; -import org.apache.log4j.Category; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -/** - * Abstract base implementation of {@link FaceObjects}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class DefaultFaceObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractFaceObjects<G, A, R> { - - /** - * The serial version UID. - */ - private static final long serialVersionUID = 1L; - - /** - * The chunk size in bytes when reading file contents. - */ - private static final int CHUNK_SIZE = 4096; - - /** - * The Logger for printing log messages. - */ - private static final Category log = Logger.getLogger(DefaultFaceObjects.class); - - /** - * Action Builder. - */ - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** - * The filename of the collected image file. - * @serial - */ - @NotNull - private final String pngFile; - - /** - * The filename of the face tree file. - * @serial - */ - @NotNull - private final String faceTreeFile; - - /** - * The {@link Pattern} for parsing face tree files. The pattern must return - * the face name in the first capturing group. - * @serial - */ - @NotNull - private final Pattern faceTreeInputPattern; - - /** - * The format string for writing face tree files. - * @serial - */ - @NotNull - private final String faceTreeOutputFormat; - - /** - * The {@link ArchFaceProvider} to use for collection. - */ - @NotNull - private final ArchFaceProvider archFaceProvider; - - /** - * Creates a new instance. - * @param pngFile the filename of the collected image file - * @param faceTreeFile the filename of the face tree file - * @param faceTreeInputPattern the pattern for parsing face tree files - * @param faceTreeOutputFormat the format string for writing face tree - * files - * @param archFaceProvider the arch face provider to use for collection - */ - public DefaultFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat, @NotNull final ArchFaceProvider archFaceProvider) { - super(ActionBuilderUtils.getString(ACTION_BUILDER, "nameOfFaceObject")); - this.pngFile = pngFile; - this.faceTreeFile = faceTreeFile; - this.faceTreeInputPattern = faceTreeInputPattern; - this.faceTreeOutputFormat = faceTreeOutputFormat; - this.archFaceProvider = archFaceProvider; - } - - /** - * {@inheritDoc} Collects the faces. The graphics information is written to - * "crossfire.0" resp. "daimonin.0". The meta information (offsets etc.) is - * written to "bmaps". The tree information for the editor is written to - * "bmaps.paths" resp. "facetree". <p/> Theoretically it would also be - * possible to recode the images. But the Java image encoder isn't as good - * as that of gimp in many cases (yet much better as the old visualtek's). - */ - @Override - public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final GameObjectParser<G, A, R> gameObjectParser) throws IOException { - collectTreeFile(progress, collectedDirectory); - collectBmapsFile(progress, collectedDirectory); - collectImageFile(progress, collectedDirectory); - } - - /** - * Creates the image file. - * @param progress Progress to report progress to. - * @param collectedDirectory the destination directory to collect data to - * @throws IOException in case of I/O problems during collection - */ - private void collectImageFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - final File file = new File(collectedDirectory, pngFile); - final FileOutputStream fos = new FileOutputStream(file); - try { - final FileChannel outChannel = fos.getChannel(); - try { - final PrintStream binFile = new PrintStream(fos); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectImages"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = archFaceProvider.getFilename(face); - try { - final FileInputStream fin = new FileInputStream(path); - try { - final FileChannel inChannel = fin.getChannel(); - final long imageSize = inChannel.size(); - binFile.format("IMAGE %d %d %s\n", i, imageSize, face); - inChannel.transferTo(0L, imageSize, outChannel); - } finally { - fin.close(); - } - } catch (final FileNotFoundException ignored) { - ACTION_BUILDER.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); - return; - } catch (final IOException e) { - ACTION_BUILDER.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); - return; - } - - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(size()); // finished - } finally { - binFile.close(); - } - } finally { - outChannel.close(); - } - } finally { - fos.close(); - } - } - - /** - * Creates the tree file. - * @param progress Progress to report progress to. - * @param collectedDirectory the destination directory to collect data to - * @throws IOException in case of I/O problems during collection - */ - private void collectTreeFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - final FileOutputStream fos = new FileOutputStream(new File(collectedDirectory, faceTreeFile)); - try { - final OutputStreamWriter osw = new OutputStreamWriter(fos, "us-ascii"); - try { - final BufferedWriter treeFile = new BufferedWriter(osw); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectTree"), numOfFaceObjects); - int i = 0; - for (final NamedObject faceObject : this) { - final String path = faceObject.getPath(); - treeFile.append(String.format(faceTreeOutputFormat, i, path)).append('\n'); - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(numOfFaceObjects); - } finally { - treeFile.close(); - } - } finally { - osw.close(); - } - } finally { - fos.close(); - } - } - - /** - * Creates the bmaps file. - * @param progress Progress to report progress to. - * @param collectedDirectory the destination directory to collect data to - * @throws IOException in case of I/O problems during collection - */ - protected void collectBmapsFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { - final FileOutputStream fos = new FileOutputStream(new File(collectedDirectory, CommonConstants.BMAPS_FILE)); - try { - final OutputStreamWriter osw = new OutputStreamWriter(fos); - try { - final BufferedWriter bw = new BufferedWriter(osw); - try { - final PrintWriter textFile = new PrintWriter(bw, false); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectBmaps"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - textFile.format("%05d %s\n", i, face); - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(numOfFaceObjects); - } finally { - textFile.close(); - } - } finally { - bw.close(); - } - } finally { - osw.close(); - } - } finally { - fos.close(); - } - } - - @NotNull - @Override - public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { - final File tmpFaceFile; - try { - tmpFaceFile = IOUtils.getFile(collectedDirectory, faceFile); - } catch (final IOException ex) { - errorView.addWarning(ErrorViewCategory.FACES_FILE_INVALID, new File(collectedDirectory, faceFile) + ": " + ex.getMessage()); - return new EmptyFaceProvider(); - } - final CollectedFaceProvider collectedFaceProvider; - int faces = 0; - final ErrorViewCollector faceFileErrorViewCollector = new ErrorViewCollector(errorView, tmpFaceFile); - try { - collectedFaceProvider = new CollectedFaceProvider(tmpFaceFile); - final byte[] data = getFileContents(tmpFaceFile); - - // Note: treeIn might stay null, this is optional data. - final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, new File(collectedDirectory, treeFile)); - BufferedReader treeIn = null; - try { - final URL url = IOUtils.getResource(collectedDirectory, treeFile); - final InputStream inputStream2 = url.openStream(); - final Reader reader = new InputStreamReader(inputStream2, IOUtils.MAP_ENCODING); - //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. - //noinspection IOResourceOpenedButNotSafelyClosed - treeIn = new BufferedReader(reader); - } catch (final FileNotFoundException ignored) { - treeFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_FILE_INVALID); - } - final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png - final StringBuilder faceB = new StringBuilder(); // face name of png - try { - int offset = 0; - while (offset < data.length) { - // File: Structure* - // Structure: "IMAGE " seqNr ' ' size ' ' facename '\n' PNGBinary - if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("expecting 'IMAGE' at position " + offset); - } - offset += 6; // skip "IMAGE "; - while (data[offset++] != (byte) 0x20) { - // skip seqNr ' ' - } - int size = 0; - // read size ' ' - while (true) { - final char c = (char) data[offset++]; // XXX: do not cast from byte to char - if (c == ' ') { - break; - } - if (c < '0' || c > '9') { - throw new IOException("syntax error at position " + offset + ": not a digit"); - } - size *= 10; - size += (int) c - (int) '0'; - } - faceB.setLength(0); - // read facename '\n' - while (true) { - final char c = (char) data[offset++]; // XXX: do not cast from byte to char - if (c == '\n') { - break; - } - if (c == '/') { - faceB.setLength(0); - } else { - faceB.append(c); - } - } - final String faceName = faceB.toString().intern(); - - if (offset + size > data.length) { - throw new IOException("truncated at position " + offset); - } - - if (treeIn != null) { - final String originalFilename = treeIn.readLine(); - if (originalFilename == null) { - log.warn(ACTION_BUILDER.format("logFaceObjectWithoutOriginalName", faceName)); - } else { - final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); - if (matcher.matches()) { - try { - addFaceObject(faceName, matcher.group(1), offset, size); - } catch (final DuplicateFaceException ex) { - faceFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_ENTRY_INVALID, "duplicate face: " + ex.getDuplicate().getFaceName()); - } catch (final IllegalFaceException ex) { - faceFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_ENTRY_INVALID, "invalid face: " + ex.getFaceObject().getFaceName()); - } - } else { - treeFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_ENTRY_INVALID, "syntax error: " + originalFilename); - } - } - } - collectedFaceProvider.addInfo(faceName, offset, size); // TODO Remove me - faces++; - offset += size; - } - } finally { - if (treeIn != null) { - treeIn.close(); - } - } - } catch (final IOException ex) { - faceFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_FILE_INVALID, ex.getMessage()); - return new EmptyFaceProvider(); - } - if (log.isInfoEnabled()) { - log.info("Loaded " + faces + " faces from '" + tmpFaceFile + "'."); - } - return collectedFaceProvider; - } - - /** - * Returns the contents of a {@link File} as a <code>byte</code> array. - * @param file the file to read - * @return the file contents - * @throws IOException if the file cannot be read - */ - private static byte[] getFileContents(@NotNull final File file) throws IOException { - final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) file.length()); - final InputStream inputStream = new FileInputStream(file); - try { - final byte[] buf = new byte[CHUNK_SIZE]; - while (true) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - bufOut.write(buf, 0, len); - } - } finally { - inputStream.close(); - } - return bufOut.toByteArray(); - } - -} // class DefaultFaceObjects Copied: trunk/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java (from rev 8570, trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java) =================================================================== --- trunk/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java 2010-07-01 19:26:04 UTC (rev 8572) @@ -0,0 +1,128 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.anim; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.data.NamedObject; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.utils.ActionBuilderUtils; +import net.sf.gridarta.utils.IOUtils; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import net.sf.japi.swing.misc.Progress; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base implementation of {@link AnimationObjects}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DefaultAnimationObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAnimationObjects<G, A, R> { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Action Builder. + */ + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + /** + * The collected animation tree file. + */ + @NotNull + private final String animTreeFile; + + /** + * Creates a new instance. + * @param animTreeFile the collected animation tree file + */ + public DefaultAnimationObjects(@NotNull final String animTreeFile) { + super(ActionBuilderUtils.getString(ACTION_BUILDER, "nameOfAnimationObject")); + this.animTreeFile = animTreeFile; + } + + /** + * {@inheritDoc} Collects the Animations. The animation data is written to + * "animations". The tree information for the editor is written to + * "animtree". + */ + @Override + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final GameObjectParser<G, A, R> gameObjectParser) throws IOException { + collectAnimations(progress, collectedDirectory); + collectAnimTree(progress, collectedDirectory); + } + + /** + * Collects the animation data into the file "animations". + * @param progress Progress to report progress to. + * @param collectedDirectory the destination directory to collect data to + * @throws IOException in case of I/O problems during collection + */ + private void collectAnimations(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectAnimations"), size()); + final BufferedWriter animations = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(collectedDirectory, "animations")), IOUtils.MAP_ENCODING)); + try { + int counter = 0; // counter for progress bar + for (final AnimationObject anim : this) { + animations.append("anim ").append(anim.getAnimName()).append('\n').append(anim.getAnimList()).append("mina\n"); + if (counter++ % 128 == 0) { + progress.setValue(counter); + } + } + } finally { + animations.close(); + } + progress.setValue(size()); + } + + /** + * Collects the animation data into the file "animations". + * @param progress Progress to report progress to. + * @param collectedDirectory the destination directory to collect data to + * @throws IOException in case of I/O problems during collection + */ + private void collectAnimTree(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectAnimTree"), size()); + final BufferedWriter animtree = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(collectedDirectory, animTreeFile)), IOUtils.MAP_ENCODING)); + try { + int counter = 0; // counter for progress bar + for (final NamedObject anim : this) { + animtree.append(anim.getPath()).append('\n'); + if (counter++ % 128 == 0) { + progress.setValue(counter); + } + } + } finally { + animtree.close(); + } + progress.setValue(size()); + } + + +} // class DefaultAnimationObjects Property changes on: trunk/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java (from rev 8568, trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java) =================================================================== --- trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-01 19:26:04 UTC (rev 8572) @@ -0,0 +1,420 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.face; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.net.URL; +import java.nio.channels.FileChannel; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.data.NamedObject; +import net.sf.gridarta.model.errorview.ErrorView; +import net.sf.gridarta.model.errorview.ErrorViewCategory; +import net.sf.gridarta.model.errorview.ErrorViewCollector; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.utils.ActionBuilderUtils; +import net.sf.gridarta.utils.ArrayUtils; +import net.sf.gridarta.utils.CommonConstants; +import net.sf.gridarta.utils.IOUtils; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import net.sf.japi.swing.misc.Progress; +import org.apache.log4j.Category; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base implementation of {@link FaceObjects}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class DefaultFaceObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractFaceObjects<G, A, R> { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * The chunk size in bytes when reading file contents. + */ + private static final int CHUNK_SIZE = 4096; + + /** + * The Logger for printing log messages. + */ + private static final Category log = Logger.getLogger(DefaultFaceObjects.class); + + /** + * Action Builder. + */ + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + /** + * The filename of the collected image file. + * @serial + */ + @NotNull + private final String pngFile; + + /** + * The filename of the face tree file. + * @serial + */ + @NotNull + private final String faceTreeFile; + + /** + * The {@link Pattern} for parsing face tree files. The pattern must return + * the face name in the first capturing group. + * @serial + */ + @NotNull + private final Pattern faceTreeInputPattern; + + /** + * The format string for writing face tree files. + * @serial + */ + @NotNull + private final String faceTreeOutputFormat; + + /** + * The {@link ArchFaceProvider} to use for collection. + */ + @NotNull + private final ArchFaceProvider archFaceProvider; + + /** + * Creates a new instance. + * @param pngFile the filename of the collected image file + * @param faceTreeFile the filename of the face tree file + * @param faceTreeInputPattern the pattern for parsing face tree files + * @param faceTreeOutputFormat the format string for writing face tree + * files + * @param archFaceProvider the arch face provider to use for collection + */ + public DefaultFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern, @NotNull final String faceTreeOutputFormat, @NotNull final ArchFaceProvider archFaceProvider) { + super(ActionBuilderUtils.getString(ACTION_BUILDER, "nameOfFaceObject")); + this.pngFile = pngFile; + this.faceTreeFile = faceTreeFile; + this.faceTreeInputPattern = faceTreeInputPattern; + this.faceTreeOutputFormat = faceTreeOutputFormat; + this.archFaceProvider = archFaceProvider; + } + + /** + * {@inheritDoc} Collects the faces. The graphics information is written to + * "crossfire.0" resp. "daimonin.0". The meta information (offsets etc.) is + * written to "bmaps". The tree information for the editor is written to + * "bmaps.paths" resp. "facetree". <p/> Theoretically it would also be + * possible to recode the images. But the Java image encoder isn't as good + * as that of gimp in many cases (yet much better as the old visualtek's). + */ + @Override + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final GameObjectParser<G, A, R> gameObjectParser) throws IOException { + collectTreeFile(progress, collectedDirectory); + collectBmapsFile(progress, collectedDirectory); + collectImageFile(progress, collectedDirectory); + } + + /** + * Creates the image file. + * @param progress Progress to report progress to. + * @param collectedDirectory the destination directory to collect data to + * @throws IOException in case of I/O problems during collection + */ + private void collectImageFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + final File file = new File(collectedDirectory, pngFile); + final FileOutputStream fos = new FileOutputStream(file); + try { + final FileChannel outChannel = fos.getChannel(); + try { + final PrintStream binFile = new PrintStream(fos); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectImages"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + final String path = archFaceProvider.getFilename(face); + try { + final FileInputStream fin = new FileInputStream(path); + try { + final FileChannel inChannel = fin.getChannel(); + final long imageSize = inChannel.size(); + binFile.format("IMAGE %d %d %s\n", i, imageSize, face); + inChannel.transferTo(0L, imageSize, outChannel); + } finally { + fin.close(); + } + } catch (final FileNotFoundException ignored) { + ACTION_BUILDER.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); + return; + } catch (final IOException e) { + ACTION_BUILDER.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); + return; + } + + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(size()); // finished + } finally { + binFile.close(); + } + } finally { + outChannel.close(); + } + } finally { + fos.close(); + } + } + + /** + * Creates the tree file. + * @param progress Progress to report progress to. + * @param collectedDirectory the destination directory to collect data to + * @throws IOException in case of I/O problems during collection + */ + private void collectTreeFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + final FileOutputStream fos = new FileOutputStream(new File(collectedDirectory, faceTreeFile)); + try { + final OutputStreamWriter osw = new OutputStreamWriter(fos, "us-ascii"); + try { + final BufferedWriter treeFile = new BufferedWriter(osw); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectTree"), numOfFaceObjects); + int i = 0; + for (final NamedObject faceObject : this) { + final String path = faceObject.getPath(); + treeFile.append(String.format(faceTreeOutputFormat, i, path)).append('\n'); + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(numOfFaceObjects); + } finally { + treeFile.close(); + } + } finally { + osw.close(); + } + } finally { + fos.close(); + } + } + + /** + * Creates the bmaps file. + * @param progress Progress to report progress to. + * @param collectedDirectory the destination directory to collect data to + * @throws IOException in case of I/O problems during collection + */ + protected void collectBmapsFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException { + final FileOutputStream fos = new FileOutputStream(new File(collectedDirectory, CommonConstants.BMAPS_FILE)); + try { + final OutputStreamWriter osw = new OutputStreamWriter(fos); + try { + final BufferedWriter bw = new BufferedWriter(osw); + try { + final PrintWriter textFile = new PrintWriter(bw, false); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ActionBuilderUtils.getString(ACTION_BUILDER, "archCollectBmaps"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + textFile.format("%05d %s\n", i, face); + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(numOfFaceObjects); + } finally { + textFile.close(); + } + } finally { + bw.close(); + } + } finally { + osw.close(); + } + } finally { + fos.close(); + } + } + + @NotNull + @Override + public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { + final File tmpFaceFile; + try { + tmpFaceFile = IOUtils.getFile(collectedDirectory, faceFile); + } catch (final IOException ex) { + errorView.addWarning(ErrorViewCategory.FACES_FILE_INVALID, new File(collectedDirectory, faceFile) + ": " + ex.getMessage()); + return new EmptyFaceProvider(); + } + final CollectedFaceProvider collectedFaceProvider; + int faces = 0; + final ErrorViewCollector faceFileErrorViewCollector = new ErrorViewCollector(errorView, tmpFaceFile); + try { + collectedFaceProvider = new CollectedFaceProvider(tmpFaceFile); + final byte[] data = getFileContents(tmpFaceFile); + + // Note: treeIn might stay null, this is optional data. + final ErrorViewCollector treeFileErrorViewCollector = new ErrorViewCollector(errorView, new File(collectedDirectory, treeFile)); + BufferedReader treeIn = null; + try { + final URL url = IOUtils.getResource(collectedDirectory, treeFile); + final InputStream inputStream2 = url.openStream(); + final Reader reader = new InputStreamReader(inputStream2, IOUtils.MAP_ENCODING); + //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. + //noinspection IOResourceOpenedButNotSafelyClosed + treeIn = new BufferedReader(reader); + } catch (final FileNotFoundException ignored) { + treeFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_FILE_INVALID); + } + final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png + final StringBuilder faceB = new StringBuilder(); // face name of png + try { + int offset = 0; + while (offset < data.length) { + // File: Structure* + // Structure: "IMAGE " seqNr ' ' size ' ' facename '\n' PNGBinary + if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE + throw new IOException("expecting 'IMAGE' at position " + offset); + } + offset += 6; // skip "IMAGE "; + while (data[offset++] != (byte) 0x20) { + // skip seqNr ' ' + } + int size = 0; + // read size ' ' + while (true) { + final char c = (char) data[offset++]; // XXX: do not cast from byte to char + if (c == ' ') { + break; + } + if (c < '0' || c > '9') { + throw new IOException("syntax error at position " + offset + ": not a digit"); + } + size *= 10; + size += (int) c - (int) '0'; + } + faceB.setLength(0); + // read facename '\n' + while (true) { + final char c = (char) data[offset++]; // XXX: do not cast from byte to char + if (c == '\n') { + break; + } + if (c == '/') { + faceB.setLength(0); + } else { + faceB.append(c); + } + } + final String faceName = faceB.toString().intern(); + + if (offset + size > data.length) { + throw new IOException("truncated at position " + offset); + } + + if (treeIn != null) { + final String originalFilename = treeIn.readLine(); + if (originalFilename == null) { + log.warn(ACTION_BUILDER.format("logFaceObjectWithoutOriginalName", faceName)); + } else { + final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); + if (matcher.matches()) { + try { + addFaceObject(faceName, matcher.group(1), offset, size); + } catch (final DuplicateFaceException ex) { + faceFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_ENTRY_INVALID, "duplicate face: " + ex.getDuplicate().getFaceName()); + } catch (final IllegalFaceException ex) { + faceFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_ENTRY_INVALID, "invalid face: " + ex.getFaceObject().getFaceName()); + } + } else { + treeFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_ENTRY_INVALID, "syntax error: " + originalFilename); + } + } + } + collectedFaceProvider.addInfo(faceName, offset, size); // TODO Remove me + faces++; + offset += size; + } + } finally { + if (treeIn != null) { + treeIn.close(); + } + } + } catch (final IOException ex) { + faceFileErrorViewCollector.addWarning(ErrorViewCategory.FACES_FILE_INVALID, ex.getMessage()); + return new EmptyFaceProvider(); + } + if (log.isInfoEnabled()) { + log.info("Loaded " + faces + " faces from '" + tmpFaceFile + "'."); + } + return collectedFaceProvider; + } + + /** + * Returns the contents of a {@link File} as a <code>byte</code> array. + * @param file the file to read + * @return the file contents + * @throws IOException if the file cannot be read + */ + private static byte[] getFileContents(@NotNull final File file) throws IOException { + final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) file.length()); + final InputStream inputStream = new FileInputStream(file); + try { + final byte[] buf = new byte[CHUNK_SIZE]; + while (true) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + bufOut.write(buf, 0, len); + } + } finally { + inputStream.close(); + } + return bufOut.toByteArray(); + } + +} // class DefaultFaceObjects Property changes on: trunk/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 19:12:12
|
Revision: 8571 http://gridarta.svn.sourceforge.net/gridarta/?rev=8571&view=rev Author: akirschbaum Date: 2010-07-01 19:12:05 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Add TestAnimationObjects and TestFaceObjects; use these instead of DefaultAnimationObjects and DefaultFaceObjects in regression tests. Modified Paths: -------------- trunk/build.xml trunk/model/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java trunk/model/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java trunk/model/src/test/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/anim/ trunk/model/src/test/net/sf/gridarta/model/anim/TestAnimationObjects.java trunk/model/src/test/net/sf/gridarta/model/face/ trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/build.xml 2010-07-01 19:12:05 UTC (rev 8571) @@ -382,6 +382,7 @@ <javac srcdir="model/src/test" destdir="dest/model/test" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="yes"> <classpath> <fileset dir="lib" includes="annotations.jar"/> + <fileset dir="lib" includes="japi-lib-swing-misc-trunk-1398.jar"/> <fileset dir="lib" includes="junit-4.2.jar"/> <fileset dir="lib" includes="log4j-1.2.13.jar"/> <pathelement location="dest/model/app"/> Added: trunk/model/src/test/net/sf/gridarta/model/anim/TestAnimationObjects.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/anim/TestAnimationObjects.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/anim/TestAnimationObjects.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -0,0 +1,57 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.anim; + +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.japi.swing.misc.Progress; +import org.jetbrains.annotations.NotNull; + +/** + * An {@link AnimationObjects} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestAnimationObjects extends AbstractAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance. + */ + public TestAnimationObjects() { + super("anim"); + } + + /** + * {@inheritDoc} + */ + @Override + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser) throws IOException { + throw new AssertionError(); + } + +} // class TestAnimationObjects Property changes on: trunk/model/src/test/net/sf/gridarta/model/anim/TestAnimationObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/archetype/ArchetypeParserTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -20,13 +20,11 @@ package net.sf.gridarta.model.archetype; import java.io.IOException; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; @@ -126,12 +124,11 @@ @NotNull @Override protected AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, ? extends AbstractArchetypeBuilder<TestGameObject, TestMapArchObject, TestArchetype>> newArchetypeParser() { - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("png", "facetree", Pattern.compile(".*"), "facetree.output", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("animtree"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); final TestArchetypeBuilder archetypeBuilder = new TestArchetypeBuilder(gameObjectFactory); final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); Modified: trunk/model/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -19,15 +19,13 @@ package net.sf.gridarta.model.archetypetype; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.utils.GUIUtils; @@ -48,10 +46,9 @@ public void testAttributes1() { final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("png", "facetree", Pattern.compile(".*"), "", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("animtree"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final ArchetypeAttributes archetypeAttributes = new ArchetypeAttributes(); final ArchetypeAttributesDefinition typeAttributes = new ArchetypeAttributesDefinition(); final BaseObject<?, ?, ?, ?> archetype = new TestArchetype("base", faceObjectProviders, animationObjects); @@ -67,10 +64,9 @@ public void testAttributes2() { final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("png", "facetree", Pattern.compile(".*"), "", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("animtree"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final ArchetypeAttributes archetypeAttributes = new ArchetypeAttributes(); final ArchetypeAttributesDefinition typeAttributes = new ArchetypeAttributesDefinition(); final BaseObject<?, ?, ?, ?> archetype = new TestArchetype("base", faceObjectProviders, animationObjects); @@ -99,10 +95,9 @@ public void testAttributes3() { final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("png", "facetree", Pattern.compile(".*"), "", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("animtree"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final ArchetypeAttributes archetypeAttributes = new ArchetypeAttributes(); final ArchetypeAttributesDefinition typeAttributes = new ArchetypeAttributesDefinition(); final BaseObject<?, ?, ?, ?> archetype = new TestArchetype("base", faceObjectProviders, animationObjects); Modified: trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/artifact/ArtifactParserTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -26,9 +26,8 @@ import java.io.StringReader; import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.AbstractArchetypeParser; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; @@ -40,10 +39,9 @@ import net.sf.gridarta.model.archetype.UndefinedArchetypeException; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.errorview.TestErrorView; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; @@ -69,11 +67,10 @@ final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("png", "facetree", Pattern.compile(".*"), "", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("animtree"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final TestArchetype baseArchetype = new TestArchetype("base", faceObjectProviders, animationObjects); baseArchetype.setObjectText("sp 2\n"); archetypeSet.addArchetype(baseArchetype); Modified: trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/autojoin/AutojoinListsTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -21,9 +21,8 @@ import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.ArchetypeFactory; import net.sf.gridarta.model.archetype.ArchetypeSet; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; @@ -31,10 +30,9 @@ import net.sf.gridarta.model.archetype.TestArchetypeFactory; import net.sf.gridarta.model.archetype.TestArchetypeSet; import net.sf.gridarta.model.archetype.UndefinedArchetypeException; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; @@ -123,11 +121,10 @@ final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("png", "facetree", Pattern.compile(""), "", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); archetypeSet = new TestArchetypeSet(archetypeFactory, "arch", faceObjectProviders); - animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("animtree"); + animationObjects = new TestAnimationObjects(); final TestMapViewSettings mapViewSettings = new TestMapViewSettings(); autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); } Modified: trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -19,14 +19,12 @@ package net.sf.gridarta.model.baseobject; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; @@ -55,7 +53,7 @@ */ @Test public void testSetFaceName1() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects); Assert.assertNull(archetype.getFaceName()); @@ -100,7 +98,7 @@ */ @Test public void testSetFaceName2() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", "face arch_face", faceObjectProviders, animationObjects); final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects); @@ -118,7 +116,7 @@ */ @Test public void testSetAttributeString() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", "key1 value1\n" + "key2 value2\n", faceObjectProviders, animationObjects); @@ -193,7 +191,7 @@ */ @Test public void testDirection1() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects); final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects); @@ -211,7 +209,7 @@ */ @Test public void testDirection2() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", "direction 2", faceObjectProviders, animationObjects); final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects); @@ -227,7 +225,7 @@ */ @Test public void testDirection3() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype1 = newArchetype("arch", "direction 1", faceObjectProviders, animationObjects); final TestArchetype archetype2 = newArchetype("arch", "direction 2", faceObjectProviders, animationObjects); @@ -259,7 +257,7 @@ */ @Test public void testType1() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects); final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects); @@ -277,7 +275,7 @@ */ @Test public void testType2() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", "type 2", faceObjectProviders, animationObjects); final GameObject<TestGameObject, TestMapArchObject, TestArchetype> gameObject = newGameObject(archetype, "test", faceObjectProviders, animationObjects); @@ -293,7 +291,7 @@ */ @Test public void testType3() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype1 = newArchetype("arch", "type 1", faceObjectProviders, animationObjects); final TestArchetype archetype2 = newArchetype("arch", "type 2", faceObjectProviders, animationObjects); @@ -325,7 +323,7 @@ */ @Test public void testName1() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", null, faceObjectProviders, animationObjects); final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects); @@ -343,7 +341,7 @@ */ @Test public void testName2() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype = newArchetype("arch", "name 2", faceObjectProviders, animationObjects); final BaseObject<?, ?, ?, ?> gameObject = new TestGameObject(archetype, faceObjectProviders, animationObjects); @@ -359,7 +357,7 @@ */ @Test public void testName3() { - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final TestArchetype archetype1 = newArchetype("arch", "name 1", faceObjectProviders, animationObjects); final TestArchetype archetype2 = newArchetype("arch", "name 2", faceObjectProviders, animationObjects); @@ -426,8 +424,7 @@ * @return the face object providers instance */ private FaceObjectProviders newFaceObjectProviders() { - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("test", "bmaps.paths", Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); assert systemIcons != null; final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); return faceObjectProviders; Added: trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -0,0 +1,67 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.face; + +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.errorview.ErrorView; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.japi.swing.misc.Progress; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link FaceObjects} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestFaceObjects extends AbstractFaceObjects<TestGameObject, TestMapArchObject, TestArchetype> { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new instance. + */ + public TestFaceObjects() { + super("test"); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { + throw new AssertionError(); + } + + /** + * {@inheritDoc} + */ + @Override + public void collect(@NotNull final Progress progress, @NotNull final File collectedDirectory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser) throws IOException { + throw new AssertionError(); + } + +} // class TestFaceObjects Property changes on: trunk/model/src/test/net/sf/gridarta/model/face/TestFaceObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/mapmodel/DefaultMapModelTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -26,18 +26,16 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; -import java.util.regex.Pattern; import javax.swing.ImageIcon; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; @@ -449,7 +447,7 @@ final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); final MapViewSettings mapViewSettings = new TestMapViewSettings(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); - animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + animationObjects = new TestAnimationObjects(); final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); @@ -468,8 +466,7 @@ * @return the face object providers instance */ private FaceObjectProviders newFaceObjectProviders() { - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("test", "bmaps.paths", Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); assert systemIcons != null; final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); return faceObjectProviders; Modified: trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -19,15 +19,13 @@ package net.sf.gridarta.model.match; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; @@ -61,7 +59,7 @@ final GameObjectMatcher invGameObjectMatcher = new TypeNrsGameObjectMatcher(1); final GameObjectMatcher namedGameObjectMatcher = new NamedGameObjectMatcher(0, "namedGameObjectMatcher", "namedGameObjectMatcher", false, null, invGameObjectMatcher); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); Assert.assertTrue(namedGameObjectMatcher.isMatching(newGameObjects(gameObjectFactory, faceObjectProviders, animationObjects, 1))); Assert.assertFalse(namedGameObjectMatcher.isMatching(newGameObjects(gameObjectFactory, faceObjectProviders, animationObjects, 2))); @@ -86,7 +84,7 @@ final GameObjectMatcher envGameObjectMatcher = new TypeNrsGameObjectMatcher(2); final GameObjectMatcher namedGameObjectMatcher = new NamedGameObjectMatcher(0, "namedGameObjectMatcher", "namedGameObjectMatcher", false, envGameObjectMatcher, invGameObjectMatcher); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>("anim"); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); Assert.assertFalse(namedGameObjectMatcher.isMatching(newGameObjects(gameObjectFactory, faceObjectProviders, animationObjects, 1))); Assert.assertFalse(namedGameObjectMatcher.isMatching(newGameObjects(gameObjectFactory, faceObjectProviders, animationObjects, 2))); @@ -165,8 +163,7 @@ * @return the face object providers instance */ private FaceObjectProviders newFaceObjectProviders() { - final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>("test", "bmaps.paths", Pattern.compile("^.*\t\\.?(.*)"), "\\%1$05d\t./arch%2$s", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); assert systemIcons != null; final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); return faceObjectProviders; Modified: trunk/model/src/test/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java 2010-07-01 18:36:35 UTC (rev 8570) +++ trunk/model/src/test/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java 2010-07-01 19:12:05 UTC (rev 8571) @@ -28,10 +28,9 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; import net.sf.gridarta.model.anim.AnimationObject; import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.DefaultAnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; import net.sf.gridarta.model.archetype.AbstractArchetypeParser; import net.sf.gridarta.model.archetype.ArchetypeFactory; import net.sf.gridarta.model.archetype.ArchetypeSet; @@ -43,9 +42,9 @@ import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.TestErrorView; import net.sf.gridarta.model.face.ArchFaceProvider; -import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; @@ -110,12 +109,12 @@ private static AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> readAnimations(@NotNull final File archDirectory, @NotNull final File collectedDirectory) { final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new DefaultFaceObjects<TestGameObject, TestMapArchObject, TestArchetype>(new File(collectedDirectory, "gridarta.0").getPath(), new File(collectedDirectory, "facetree").getPath(), Pattern.compile(""), "", archFaceProvider); + final FaceObjects<TestGameObject, TestMapArchObject, TestArchetype> faceObjects = new TestFaceObjects(); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet = new TestArchetypeSet(archetypeFactory, new File(collectedDirectory, "archetypes").getPath(), faceObjectProviders); - final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new DefaultAnimationObjects<TestGameObject, TestMapArchObject, TestArchetype>(new File(collectedDirectory, "animtree").getPath()); + final AnimationObjects<TestGameObject, TestMapArchObject, TestArchetype> animationObjects = new TestAnimationObjects(); final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); final TestArchetypeBuilder archetypeBuilder = new TestArchetypeBuilder(gameObjectFactory); final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, ?> archetypeParser = new TestArchetypeParser(archetypeBuilder, animationObjects, archetypeSet); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 18:36:41
|
Revision: 8570 http://gridarta.svn.sourceforge.net/gridarta/?rev=8570&view=rev Author: akirschbaum Date: 2010-07-01 18:36:35 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Extract AbstractAnimationObjects from DefaultAnimationObjects. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/anim/AbstractAnimationObjects.java Added: trunk/model/src/app/net/sf/gridarta/model/anim/AbstractAnimationObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/anim/AbstractAnimationObjects.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/anim/AbstractAnimationObjects.java 2010-07-01 18:36:35 UTC (rev 8570) @@ -0,0 +1,65 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.anim; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.data.AbstractNamedObjects; +import net.sf.gridarta.model.data.IllegalNamedObjectException; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base class for {@link AnimationObjects} implementations. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public abstract class AbstractAnimationObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractNamedObjects<AnimationObject> implements AnimationObjects<G, A, R> { + + /** + * Creates a new instance. + * @param name localized name of the object type, e.g. used in dialogs + */ + protected AbstractAnimationObjects(final String name) { + super(name); + } + + /** + * Adds a new animation object. + * @param animName name of the animation object to add + * @param list String with animation list data + * @param path Path relative to the arch directory + * @throws DuplicateAnimationException in case the animation was not unique + * @throws IllegalAnimationException if the animation cannot be added + */ + @Override + public void addAnimationObject(@NotNull final String animName, @NotNull final String list, @NotNull final String path) throws DuplicateAnimationException, IllegalAnimationException { + final AnimationObject animationObject = new DefaultAnimationObject(animName, list, path + '/' + animName); + if (containsKey(animName)) { + throw new DuplicateAnimationException(animationObject); + } + try { + put(animationObject); + } catch (final IllegalNamedObjectException ex) { + throw new IllegalAnimationException(animationObject, ex); + } + } + +} // class AbstractAnimationObjects Property changes on: trunk/model/src/app/net/sf/gridarta/model/anim/AbstractAnimationObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java 2010-07-01 18:27:19 UTC (rev 8569) +++ trunk/model/src/app/net/sf/gridarta/model/anim/DefaultAnimationObjects.java 2010-07-01 18:36:35 UTC (rev 8570) @@ -25,8 +25,6 @@ import java.io.IOException; import java.io.OutputStreamWriter; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.data.AbstractNamedObjects; -import net.sf.gridarta.model.data.IllegalNamedObjectException; import net.sf.gridarta.model.data.NamedObject; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.GameObjectParser; @@ -42,7 +40,7 @@ * Abstract base implementation of {@link AnimationObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class DefaultAnimationObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractNamedObjects<AnimationObject> implements AnimationObjects<G, A, R> { +public class DefaultAnimationObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAnimationObjects<G, A, R> { /** * The serial version UID. @@ -70,27 +68,6 @@ } /** - * Adds a new animation object. - * @param animName name of the animation object to add - * @param list String with animation list data - * @param path Path relative to the arch directory - * @throws DuplicateAnimationException in case the animation was not unique - * @throws IllegalAnimationException if the animation cannot be added - */ - @Override - public void addAnimationObject(@NotNull final String animName, @NotNull final String list, @NotNull final String path) throws DuplicateAnimationException, IllegalAnimationException { - final AnimationObject animationObject = new DefaultAnimationObject(animName, list, path + '/' + animName); - if (containsKey(animName)) { - throw new DuplicateAnimationException(animationObject); - } - try { - put(animationObject); - } catch (final IllegalNamedObjectException ex) { - throw new IllegalAnimationException(animationObject, ex); - } - } - - /** * {@inheritDoc} Collects the Animations. The animation data is written to * "animations". The tree information for the editor is written to * "animtree". This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 18:27:25
|
Revision: 8569 http://gridarta.svn.sourceforge.net/gridarta/?rev=8569&view=rev Author: akirschbaum Date: 2010-07-01 18:27:19 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Use project default inspection profile, not global default. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-07-01 18:25:12 UTC (rev 8568) +++ trunk/gridarta.ipr 2010-07-01 18:27:19 UTC (rev 8569) @@ -956,8 +956,8 @@ <inspection_tool class="XsltUnusedDeclaration" level="WARNING" enabled="false" /> </profile> </profiles> - <option name="PROJECT_PROFILE" /> - <option name="USE_PROJECT_PROFILE" value="false" /> + <option name="PROJECT_PROFILE" value="Project Default" /> + <option name="USE_PROJECT_PROFILE" value="true" /> <version value="1.0" /> <list size="5"> <item index="0" class="java.lang.String" itemvalue="SERVER PROBLEM" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 18:25:19
|
Revision: 8568 http://gridarta.svn.sourceforge.net/gridarta/?rev=8568&view=rev Author: akirschbaum Date: 2010-07-01 18:25:12 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Extract AbstractFaceObjects from DefaultFaceObjects. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java Added: trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java 2010-07-01 18:25:12 UTC (rev 8568) @@ -0,0 +1,61 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.face; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.data.AbstractNamedObjects; +import net.sf.gridarta.model.data.IllegalNamedObjectException; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base class for {@link FaceObjects} implementations. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public abstract class AbstractFaceObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractNamedObjects<FaceObject> implements FaceObjects<G, A, R> { + + /** + * Creates a new instance. + * @param name localized name of the object type, e.g. used in dialogs + */ + protected AbstractFaceObjects(final String name) { + super(name); + } + + /** + * {@inheritDoc} + */ + @Override + public void addFaceObject(@NotNull final String faceName, @NotNull final String originalFilename, final int offset, final int size) throws DuplicateFaceException, IllegalFaceException { + final FaceObject faceObject = new DefaultFaceObject(faceName, originalFilename, offset, size); + final FaceObject otherFaceObject = get(faceName); + if (otherFaceObject != null) { + throw new DuplicateFaceException(faceObject, otherFaceObject); + } + try { + put(faceObject); + } catch (final IllegalNamedObjectException ex) { + throw new IllegalFaceException(faceObject, ex); + } + } + +} // class AbstractFaceObjects Property changes on: trunk/model/src/app/net/sf/gridarta/model/face/AbstractFaceObjects.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-01 17:22:27 UTC (rev 8567) +++ trunk/model/src/app/net/sf/gridarta/model/face/DefaultFaceObjects.java 2010-07-01 18:25:12 UTC (rev 8568) @@ -38,8 +38,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.data.AbstractNamedObjects; -import net.sf.gridarta.model.data.IllegalNamedObjectException; import net.sf.gridarta.model.data.NamedObject; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; @@ -62,7 +60,7 @@ * Abstract base implementation of {@link FaceObjects}. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class DefaultFaceObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractNamedObjects<FaceObject> implements FaceObjects<G, A, R> { +public class DefaultFaceObjects<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractFaceObjects<G, A, R> { /** * The serial version UID. @@ -281,26 +279,6 @@ } } - /** - * {@inheritDoc} - */ - @Override - public void addFaceObject(final String faceName, final String originalFilename, final int offset, final int size) throws DuplicateFaceException, IllegalFaceException { - final FaceObject faceObject = new DefaultFaceObject(faceName, originalFilename, offset, size); - final FaceObject otherFaceObject = get(faceName); - if (otherFaceObject != null) { - throw new DuplicateFaceException(faceObject, otherFaceObject); - } - try { - put(faceObject); - } catch (final IllegalNamedObjectException ex) { - throw new IllegalFaceException(faceObject, ex); - } - } - - /** - * {@inheritDoc} - */ @NotNull @Override public FaceProvider loadFacesCollection(@NotNull final ErrorView errorView, @NotNull final File collectedDirectory, @NotNull final String faceFile, @NotNull final String treeFile) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-07-01 17:22:34
|
Revision: 8567 http://gridarta.svn.sourceforge.net/gridarta/?rev=8567&view=rev Author: akirschbaum Date: 2010-07-01 17:22:27 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Remove dependency ArchetypeType -> ActionBuilder. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeType.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeType.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeType.java 2010-06-30 19:52:40 UTC (rev 8566) +++ trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeType.java 2010-07-01 17:22:27 UTC (rev 8567) @@ -21,8 +21,6 @@ import java.util.Iterator; import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,11 +34,6 @@ public class ArchetypeType implements Iterable<ArchetypeAttribute> { /** - * Action Builder. - */ - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** * The type name (artificial). */ @NotNull @@ -113,14 +106,6 @@ } /** - * Create the documentation to this GameObject-type. - * @return the full html-text to be (parsed and) displayed - */ - public String createHtmlDocumentation() { - return ACTION_BUILDER.format("arcDoc.htmlText", typeName, description != null ? description.trim() : "", use != null ? use.trim() : ""); - } - - /** * {@inheritDoc} */ @NotNull @@ -165,6 +150,24 @@ } /** + * Returns the description. + * @return the description + */ + @NotNull + public String getDescription() { + return description == null ? "" : description.trim(); + } + + /** + * Returns the usage notes. + * @return the usage notes + */ + @NotNull + public String getUse() { + return use == null ? "" : use.trim(); + } + + /** * Checks whether a {@link BaseObject} matches all type attributes. * @param baseObject the base object to check * @return whether the base object matches Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-30 19:52:40 UTC (rev 8566) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-07-01 17:22:27 UTC (rev 8567) @@ -1158,7 +1158,8 @@ */ @ActionMethod public void attribHelp() { - new Help(/* XXX */ parent, typesBoxItemListener.archetypeType.createHtmlDocumentation()).setVisible(true); + final String helpText = ACTION_BUILDER.format("arcDoc.htmlText", typesBoxItemListener.archetypeType.getTypeName(), typesBoxItemListener.archetypeType.getDescription(), typesBoxItemListener.archetypeType.getUse()); + new Help(/* XXX */ parent, helpText).setVisible(true); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-30 19:52:46
|
Revision: 8566 http://gridarta.svn.sourceforge.net/gridarta/?rev=8566&view=rev Author: akirschbaum Date: 2010-06-30 19:52:40 +0000 (Wed, 30 Jun 2010) Log Message: ----------- Extract TestCacheFiles from TestMapControlCreator. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/src/test/net/sf/gridarta/model/io/ trunk/src/test/net/sf/gridarta/model/io/TestCacheFiles.java Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-30 19:49:51 UTC (rev 8565) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-30 19:52:40 UTC (rev 8566) @@ -68,6 +68,7 @@ import net.sf.gridarta.model.io.MapReaderFactory; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.io.PathManager; +import net.sf.gridarta.model.io.TestCacheFiles; import net.sf.gridarta.model.io.TestGameObjectParser; import net.sf.gridarta.model.io.TestMapArchObjectParserFactory; import net.sf.gridarta.model.io.TestMapReaderFactory; @@ -570,15 +571,7 @@ final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final Image defaultIcon = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); final Image defaultPreview = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); - final CacheFiles cacheFiles = new CacheFiles() { - - @NotNull - @Override - public File getCacheFile(@NotNull final File file, @Nullable final String prefix) { - return file; - } - - }; + final CacheFiles cacheFiles = new TestCacheFiles(); return new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype>(mapManager, defaultIcon, defaultPreview, rendererFactory, cacheFiles); } Added: trunk/src/test/net/sf/gridarta/model/io/TestCacheFiles.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/io/TestCacheFiles.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/io/TestCacheFiles.java 2010-06-30 19:52:40 UTC (rev 8566) @@ -0,0 +1,41 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.io; + +import java.io.File; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link CacheFiles} implementation for regression test. + * @author Andreas Kirschbaum + */ +public class TestCacheFiles implements CacheFiles { + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public File getCacheFile(@NotNull final File file, @Nullable final String prefix) { + return file; + } + +} // class TestCacheFiles Property changes on: trunk/src/test/net/sf/gridarta/model/io/TestCacheFiles.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-30 19:49:57
|
Revision: 8565 http://gridarta.svn.sourceforge.net/gridarta/?rev=8565&view=rev Author: akirschbaum Date: 2010-06-30 19:49:51 +0000 (Wed, 30 Jun 2010) Log Message: ----------- Weaken types. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-30 19:35:09 UTC (rev 8564) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-30 19:49:51 UTC (rev 8565) @@ -448,7 +448,7 @@ */ public static void checkContents(@NotNull final Iterable<TestGameObject> mapSquare, @NotNull final TestGameObject... gameObjects) { int i = 0; - for (final TestGameObject gameObject : mapSquare) { + for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { final String gameObjectName = gameObject.getBestName(); if (i >= gameObjects.length) { Assert.fail("map square contains excess game object '" + gameObjectName + "'"); @@ -462,7 +462,7 @@ } final boolean inContainer = mapSquare instanceof GameObject; - for (final TestGameObject gameObject : mapSquare) { + for (final GameObject<?, ?, ?> gameObject : mapSquare) { Assert.assertEquals(inContainer, gameObject.isInContainer()); if (inContainer) { // game objects within inventories must not contain tail parts @@ -481,7 +481,7 @@ */ private static void checkContentsString(@NotNull final MapSquare<TestGameObject, TestMapArchObject, TestArchetype> mapSquare, @NotNull final String... gameObjects) { int i = 0; - for (final TestGameObject gameObject : mapSquare) { + for (final BaseObject<?, ?, ?, ?> gameObject : mapSquare) { final String gameObjectName = gameObject.getBestName(); if (i >= gameObjects.length) { Assert.fail("map square " + mapSquare.getMapX() + "/" + mapSquare.getMapY() + " contains excess game object '" + gameObjectName + "'"); @@ -528,7 +528,7 @@ final Pattern pattern2 = Pattern.compile(","); final Point pos = new Point(); for (int y = 0; y < lines.length; y++) { - final String line = lines[y]; + final CharSequence line = lines[y]; final String[] square = pattern1.split(line, -1); Assert.assertEquals(square.length, mapSize.getWidth()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-30 19:35:15
|
Revision: 8564 http://gridarta.svn.sourceforge.net/gridarta/?rev=8564&view=rev Author: akirschbaum Date: 2010-06-30 19:35:09 +0000 (Wed, 30 Jun 2010) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java Modified: trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java 2010-06-30 19:28:01 UTC (rev 8563) +++ trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java 2010-06-30 19:35:09 UTC (rev 8564) @@ -22,8 +22,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import org.apache.log4j.Category; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-30 19:28:08
|
Revision: 8563 http://gridarta.svn.sourceforge.net/gridarta/?rev=8563&view=rev Author: akirschbaum Date: 2010-06-30 19:28:01 +0000 (Wed, 30 Jun 2010) Log Message: ----------- Suppress warning. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-06-30 19:27:19 UTC (rev 8562) +++ trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSetParser.java 2010-06-30 19:28:01 UTC (rev 8563) @@ -414,6 +414,7 @@ } else { if (encoding.length() != 0) { errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, bitmaskName + ": unused '" + XML_BMENTRY_ENCODING + "' attribute"); + //noinspection UnnecessaryReturnStatement return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-30 19:27:30
|
Revision: 8562 http://gridarta.svn.sourceforge.net/gridarta/?rev=8562&view=rev Author: akirschbaum Date: 2010-06-30 19:27:19 +0000 (Wed, 30 Jun 2010) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/gridarta.ipr trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java trunk/model/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -139,8 +139,6 @@ import net.sf.gridarta.var.atrinik.model.scripts.DefaultScriptedEventFactory; import net.sf.gridarta.var.atrinik.model.settings.DefaultGlobalSettings; import net.sf.gridarta.var.atrinik.resource.DefaultResources; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.prefs.PreferencesGroup; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -183,11 +181,6 @@ private static final Category log = Logger.getLogger(DefaultEditorFactory.class); /** - * Action Builder. - */ - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** * The {@link IsoMapSquareInfo} instance. */ @NotNull @@ -503,8 +496,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -399,8 +399,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapModelFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapModelFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -140,8 +140,6 @@ import net.sf.gridarta.var.daimonin.model.scripts.DefaultScriptedEventFactory; import net.sf.gridarta.var.daimonin.model.settings.DefaultGlobalSettings; import net.sf.gridarta.var.daimonin.resource.DefaultResources; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.prefs.PreferencesGroup; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -184,11 +182,6 @@ private static final Category log = Logger.getLogger(DefaultEditorFactory.class); /** - * Action Builder. - */ - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** * The {@link IsoMapSquareInfo} instance. */ @NotNull @@ -504,8 +497,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, pluginParameterFactory); } /** Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/gridarta.ipr 2010-06-30 19:27:19 UTC (rev 8562) @@ -956,8 +956,8 @@ <inspection_tool class="XsltUnusedDeclaration" level="WARNING" enabled="false" /> </profile> </profiles> - <option name="PROJECT_PROFILE" value="Project Default" /> - <option name="USE_PROJECT_PROFILE" value="true" /> + <option name="PROJECT_PROFILE" /> + <option name="USE_PROJECT_PROFILE" value="false" /> <version value="1.0" /> <list size="5"> <item index="0" class="java.lang.String" itemvalue="SERVER PROBLEM" /> Modified: trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinList.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -21,9 +21,7 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.IdentityHashMap; import java.util.List; -import java.util.Map; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -86,7 +84,7 @@ throw new IllegalAutojoinListException("autojoin list with less than " + SIZE + " valid entries"); } - final Map<R, R> tmp = new IdentityHashMap<R, R>(); + //final Map<R, R> tmp = new IdentityHashMap<R, R>(); for (final R archetype : newArchetypes) { if (archetype == null) { throw new IllegalArgumentException(); Modified: trunk/model/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/model/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -432,7 +432,7 @@ protected abstract int loadEditType(); /** - * Saves the {@link #editType} }value. + * Saves the {@link #editType} value. * @param editType the edit type value */ protected abstract void saveEditType(final int editType); Modified: trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/model/src/app/net/sf/gridarta/model/scripts/AbstractScriptedEvent.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -32,11 +32,6 @@ */ public abstract class AbstractScriptedEvent<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements ScriptedEvent<G, A, R> { - /** - * The Logger for printing log messages. - */ - private static final Category log = Logger.getLogger(AbstractScriptedEvent.class); - @NotNull protected abstract String typeName(final int eventType); Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -354,12 +354,11 @@ * @param resources the resources * @param gameObjectSpells the game object spells to use * @param numberSpells the number spells to use - * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use * @return the new instance */ - public GUIMainControl<G, A, R> createGUIMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @Nullable final String spellFile, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final CacheFiles cacheFiles, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final FaceObjects<G, A, R> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final String scriptsDir, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final AnimationObjects<G, A, R> animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, final boolean allowRandomMapParameters, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final Direction[] directionMap, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { - return new GUIMainControl<G, A, R>(createDirectionPane, mapManager, pickmapManager, archetypeSet, faceObjects, globalSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, compassIcon, gridartaJarFilename, GuiFileFilters.mapFileFilter, scriptFileFilter, scriptExtension, validators, resources, gameObjectMatchers, errorView, attributeRangeChecker, lockedItemsTypeNumbers, scriptsDir, scriptModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchData, scriptArchDataUtils, scriptArchUtils, autoValidatorDefault, spellFile, allowRandomMapParameters, directionMap, editorFactory, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, cacheFiles, gameObjectSpells, numberSpells, undefinedSpellIndex, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, scriptExecutor, scriptParameters); + public GUIMainControl<G, A, R> createGUIMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final int[] lockedItemsTypeNumbers, final boolean autoValidatorDefault, @Nullable final String spellFile, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final CacheFiles cacheFiles, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final FaceObjects<G, A, R> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, final int undefinedSpellIndex, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final String scriptsDir, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final AnimationObjects<G, A, R> animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, final boolean allowRandomMapParameters, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final Direction[] directionMap, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { + return new GUIMainControl<G, A, R>(createDirectionPane, mapManager, pickmapManager, archetypeSet, faceObjects, globalSettings, mapViewSettings, mapModelFactory, mapReaderFactory, mapArchObjectFactory, treasureTree, archetypeTypeSet, compassIcon, gridartaJarFilename, GuiFileFilters.mapFileFilter, scriptFileFilter, scriptExtension, validators, resources, gameObjectMatchers, errorView, lockedItemsTypeNumbers, scriptsDir, scriptModel, archetypeChooserModel, animationObjects, scriptArchEditor, scriptedEventEditor, scriptArchData, scriptArchDataUtils, scriptArchUtils, autoValidatorDefault, spellFile, allowRandomMapParameters, directionMap, editorFactory, faceObjectProviders, pluginParameterFactory, gameObjectFactory, pathManager, cacheFiles, gameObjectSpells, numberSpells, undefinedSpellIndex, systemIcons, configSourceFactory, topmostInsertionMode, rendererFactory, filterControl, scriptExecutor, scriptParameters); } } // class DefaultMainControl Modified: trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -369,12 +369,11 @@ * @param resources the resources * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use - * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use * @return the new instance */ @NotNull - GUIMainControl<G, A, R> createGUIMainControl(@NotNull DefaultMainControl<G, A, R> mainControl, @NotNull ErrorView errorView, @NotNull GUIUtils guiUtils, @NotNull ConfigSourceFactory configSourceFactory, @NotNull RendererFactory<G, A, R> rendererFactory, @NotNull FilterControl<G, A, R> filterControl, @NotNull ScriptExecutor<G, A, R> scriptExecutor, @NotNull ScriptParameters scriptParameters, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull MapManager<G, A, R> pickmapManager, @NotNull MapModelFactory<G, A, R> mapModelFactory, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull FaceObjects<G, A, R> faceObjects, @NotNull GlobalSettings globalSettings, @NotNull MapViewSettings mapViewSettings, @NotNull FaceObjectProviders faceObjectProviders, @NotNull PathManager pathManager, @NotNull InsertionMode<G, A, R> topmostInsertionMode, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull SystemIcons systemIcons, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull ScriptModel<G, A, R> scriptModel, @NotNull AnimationObjects<G, A, R> animationObjects, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory); + GUIMainControl<G, A, R> createGUIMainControl(@NotNull DefaultMainControl<G, A, R> mainControl, @NotNull ErrorView errorView, @NotNull GUIUtils guiUtils, @NotNull ConfigSourceFactory configSourceFactory, @NotNull RendererFactory<G, A, R> rendererFactory, @NotNull FilterControl<G, A, R> filterControl, @NotNull ScriptExecutor<G, A, R> scriptExecutor, @NotNull ScriptParameters scriptParameters, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull MapManager<G, A, R> pickmapManager, @NotNull MapModelFactory<G, A, R> mapModelFactory, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull FaceObjects<G, A, R> faceObjects, @NotNull GlobalSettings globalSettings, @NotNull MapViewSettings mapViewSettings, @NotNull FaceObjectProviders faceObjectProviders, @NotNull PathManager pathManager, @NotNull InsertionMode<G, A, R> topmostInsertionMode, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull SystemIcons systemIcons, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull ScriptModel<G, A, R> scriptModel, @NotNull AnimationObjects<G, A, R> animationObjects, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory); /** * Creates a new {@link AbstractResources} instance. Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -172,7 +172,6 @@ import net.sf.gridarta.utils.ProcessRunner; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.validation.DelegatingMapValidator; -import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.gridarta.validation.checks.BlockedSquareChecker; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -389,7 +388,6 @@ * @param resources the resources to collect * @param gameObjectMatchers the game object matchers instance * @param errorView the error view for reporting errors - * @param attributeRangeChecker the attribute range checker instance * @param lockedItemsTypeNumbers the type numbers of game objects being * locked items * @param scriptsDir the plugin scripts directory @@ -424,7 +422,7 @@ * @param scriptExecutor the script executor instance * @param scriptParameters the script parameters instance */ - public GUIMainControl(final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects<G, A, R> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @NotNull final MapReaderFactory<G, A> mapReaderFactory, final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final AbstractResources<G, A, R> resources, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorView errorView, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final int[] lockedItemsTypeNumbers, @NotNull final String scriptsDir, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AnimationObjects<G, A, R> animationObjects, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, final boolean autoValidatorDefault, @Nullable final String spellFile, final boolean allowRandomMapParameters, @NotNull final Direction[] directionMap, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final PathManager pathManager, @NotNull final CacheFiles cacheFiles, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters) { + public GUIMainControl(final boolean createDirectionPane, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects<G, A, R> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @NotNull final MapReaderFactory<G, A> mapReaderFactory, final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final TreasureTree treasureTree, @NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final ImageIcon compassIcon, @NotNull final String gridartaJarFilename, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final AbstractResources<G, A, R> resources, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorView errorView, @NotNull final int[] lockedItemsTypeNumbers, @NotNull final String scriptsDir, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AnimationObjects<G, A, R> animationObjects, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchData<G, A, R> scriptArchData, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, final boolean autoValidatorDefault, @Nullable final String spellFile, final boolean allowRandomMapParameters, @NotNull final Direction[] directionMap, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final PathManager pathManager, @NotNull final CacheFiles cacheFiles, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters) { this.archetypeSet = archetypeSet; this.configSourceFactory = configSourceFactory; this.rendererFactory = rendererFactory; Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-30 19:03:37 UTC (rev 8561) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-30 19:27:19 UTC (rev 8562) @@ -293,7 +293,7 @@ try { switch (mode) { case NORMAL: - returnCode = runNormal(args2, mainControl, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, mapManager, pickmapManager, mapModelFactory, archetypeSet, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, scriptModel, animationObjects, archetypeChooserModel, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + returnCode = runNormal(args2, mainControl, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, mapManager, pickmapManager, mapModelFactory, archetypeSet, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, scriptModel, animationObjects, archetypeChooserModel, scriptedEventEditor, resources, numberSpells, gameObjectSpells, pluginParameterFactory); break; case BATCH_PNG: @@ -413,18 +413,17 @@ * @param resources the resources * @param numberSpells the number spells to use * @param gameObjectSpells the game object spells to use - * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use * @return return code suitable for passing to {@link System#exit(int)} */ - private int runNormal(@NotNull final Iterable<String> args, @NotNull final DefaultMainControl<G, A, R> mainControl, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects<G, A, R> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final AnimationObjects<G, A, R> animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { + private int runNormal(@NotNull final Iterable<String> args, @NotNull final DefaultMainControl<G, A, R> mainControl, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final MapModelFactory<G, A, R> mapModelFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects<G, A, R> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final AnimationObjects<G, A, R> animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { final GUIMainControl<?, ?, ?>[] guiMainControl = new GUIMainControl<?, ?, ?>[1]; final Runnable runnable = new Runnable() { /** {@inheritDoc} */ @Override public void run() { - guiMainControl[0] = editorFactory.createGUIMainControl(mainControl, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, mapManager, pickmapManager, mapModelFactory, archetypeSet, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, scriptModel, animationObjects, archetypeChooserModel, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + guiMainControl[0] = editorFactory.createGUIMainControl(mainControl, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, mapManager, pickmapManager, mapModelFactory, archetypeSet, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, scriptModel, animationObjects, archetypeChooserModel, scriptedEventEditor, resources, numberSpells, gameObjectSpells, pluginParameterFactory); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-30 19:03:45
|
Revision: 8561 http://gridarta.svn.sourceforge.net/gridarta/?rev=8561&view=rev Author: akirschbaum Date: 2010-06-30 19:03:37 +0000 (Wed, 30 Jun 2010) Log Message: ----------- Extract MapModelFactory from MapControlFactory. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/mapcontrol/DefaultMapControlFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/mapcontrol/DefaultMapControlFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/mapcontrol/DefaultMapControlFactory.java trunk/model/src/app/net/sf/gridarta/model/mapcontrol/MapControlFactory.java trunk/model/src/test/net/sf/gridarta/model/mapcontrol/TestMapControlFactory.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModelFactory.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -78,6 +78,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.mapcontrol.MapControlFactory; import net.sf.gridarta.model.mapmodel.InsertionMode; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.mappathnormalizer.MapPathNormalizer; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; @@ -283,8 +284,8 @@ */ @NotNull @Override - public MapControlFactory<GameObject, MapArchObject, Archetype> newMapControlFactory(@NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode) { - return new DefaultMapControlFactory(archetypeChooserModel, autojoinLists, mapViewSettings, mapWriter, gameObjectFactory, gameObjectMatchers, globalSettings, topmostInsertionMode); + public MapControlFactory<GameObject, MapArchObject, Archetype> newMapControlFactory(@NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GlobalSettings globalSettings, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory) { + return new DefaultMapControlFactory(mapWriter, globalSettings, mapModelFactory); } /** @@ -502,8 +503,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/mapcontrol/DefaultMapControlFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/mapcontrol/DefaultMapControlFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/mapcontrol/DefaultMapControlFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -21,18 +21,12 @@ import java.io.File; import java.util.List; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.mapcontrol.DefaultMapControl; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.MapControlFactory; -import net.sf.gridarta.model.mapmodel.DefaultMapModel; -import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.var.atrinik.model.archetype.Archetype; import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; @@ -47,74 +41,34 @@ public class DefaultMapControlFactory implements MapControlFactory<GameObject, MapArchObject, Archetype> { /** - * The {@link ArchetypeChooserModel} instance to use. - */ - @NotNull - private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel; - - /** - * The {@link AutojoinLists} instance to use. - */ - @NotNull - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; - - /** - * The map view settings instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * The {@link MapWriter} for saving {@link MapControl} instances. */ @NotNull private final MapWriter<GameObject, MapArchObject, Archetype> mapWriter; /** - * The {@link GameObjectFactory} for creating {@link GameObject}s. - */ - @NotNull - private final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; - - /** - * The {@link GameObjectMatchers} to use. - */ - @NotNull - private final GameObjectMatchers gameObjectMatchers; - - /** * The {@link GlobalSettings} to use. */ @NotNull private final GlobalSettings globalSettings; /** - * The "topmost" {@link InsertionMode}. + * The {@link MapModelFactory} for creating {@link MapModel} instances. */ @NotNull - private final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode; + private final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory; /** * Creates a new instance. - * @param archetypeChooserModel the archetype chooser model to use - * @param autojoinLists the autojoin lists to use - * @param mapViewSettings the map view settings instance * @param mapWriter the map writer for saving map control instances - * @param gameObjectFactory the game object factory for creating game - * objects - * @param gameObjectMatchers the game object matchers to use * @param globalSettings the global settings to use - * @param topmostInsertionMode the "topmost" insertion mode + * @param mapModelFactory the map model factory for creating map model + * instances */ - public DefaultMapControlFactory(@NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode) { - this.archetypeChooserModel = archetypeChooserModel; - this.autojoinLists = autojoinLists; - this.mapViewSettings = mapViewSettings; + public DefaultMapControlFactory(@NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GlobalSettings globalSettings, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory) { this.mapWriter = mapWriter; - this.gameObjectFactory = gameObjectFactory; - this.gameObjectMatchers = gameObjectMatchers; this.globalSettings = globalSettings; - this.topmostInsertionMode = topmostInsertionMode; + this.mapModelFactory = mapModelFactory; } /** @@ -123,7 +77,7 @@ @NotNull @Override public MapControl<GameObject, MapArchObject, Archetype> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @Nullable final File file) { - final MapModel<GameObject, MapArchObject, Archetype> mapModel = newMapModel(mapArchObject); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapModelFactory.newMapModel(mapArchObject); if (objects != null) { mapModel.beginTransaction("init"); try { @@ -145,7 +99,7 @@ @Override public MapControl<GameObject, MapArchObject, Archetype> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @Nullable final File file) { mapArchObject.setDifficulty(1); - final MapModel<GameObject, MapArchObject, Archetype> mapModel = newMapModel(mapArchObject); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapModelFactory.newMapModel(mapArchObject); if (objects != null) { mapModel.beginTransaction("init"); try { @@ -161,13 +115,4 @@ return mapControl; } - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapModel<GameObject, MapArchObject, Archetype> newMapModel(@NotNull final MapArchObject mapArchObject) { - return new DefaultMapModel<GameObject, MapArchObject, Archetype>(autojoinLists, mapArchObject, archetypeChooserModel, mapViewSettings.getEditType(), gameObjectFactory, gameObjectMatchers, topmostInsertionMode); - } - } // class DefaultMapControlFactory Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -73,6 +73,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.mapcontrol.MapControlFactory; import net.sf.gridarta.model.mapmodel.InsertionMode; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.mappathnormalizer.MapPathNormalizer; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; @@ -239,8 +240,8 @@ */ @NotNull @Override - public MapControlFactory<GameObject, MapArchObject, Archetype> newMapControlFactory(@NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode) { - return new DefaultMapControlFactory(archetypeChooserModel, autojoinLists, mapViewSettings, mapWriter, gameObjectFactory, gameObjectMatchers, globalSettings, topmostInsertionMode); + public MapControlFactory<GameObject, MapArchObject, Archetype> newMapControlFactory(@NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GlobalSettings globalSettings, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory) { + return new DefaultMapControlFactory(mapWriter, globalSettings, mapModelFactory); } /** @@ -398,8 +399,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapModelFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/mapcontrol/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/mapcontrol/DefaultMapControlFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/mapcontrol/DefaultMapControlFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -21,18 +21,12 @@ import java.io.File; import java.util.List; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.mapcontrol.DefaultMapControl; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.MapControlFactory; -import net.sf.gridarta.model.mapmodel.DefaultMapModel; -import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; @@ -47,74 +41,34 @@ public class DefaultMapControlFactory implements MapControlFactory<GameObject, MapArchObject, Archetype> { /** - * The {@link ArchetypeChooserModel} instance to use. - */ - @NotNull - private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel; - - /** - * The {@link AutojoinLists} instance to use. - */ - @NotNull - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; - - /** - * The map view settings instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * The {@link MapWriter} for saving {@link MapControl} instances. */ @NotNull private final MapWriter<GameObject, MapArchObject, Archetype> mapWriter; /** - * The {@link GameObjectFactory} for creating {@link GameObject}s. - */ - @NotNull - private final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; - - /** - * The {@link GameObjectMatchers} to use. - */ - @NotNull - private final GameObjectMatchers gameObjectMatchers; - - /** * The {@link GlobalSettings} to use. */ @NotNull private final GlobalSettings globalSettings; /** - * The "topmost" {@link InsertionMode}. + * The {@link MapModelFactory} for creating {@link MapModel} instances. */ @NotNull - private final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode; + private final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory; /** * Creates a new instance. - * @param archetypeChooserModel the archetype chooser model to use - * @param autojoinLists the autojoin lists to use - * @param mapViewSettings the map view settings instance * @param mapWriter the map writer for saving map control instances - * @param gameObjectFactory the game object factory for creating game - * objects - * @param gameObjectMatchers the game object matchers to use * @param globalSettings the global settings to use - * @param topmostInsertionMode the "topmost" insertion mode + * @param mapModelFactory the map model factory for creating map model + * instances */ - public DefaultMapControlFactory(@NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode) { - this.archetypeChooserModel = archetypeChooserModel; - this.autojoinLists = autojoinLists; - this.mapViewSettings = mapViewSettings; + public DefaultMapControlFactory(@NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GlobalSettings globalSettings, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory) { this.mapWriter = mapWriter; - this.gameObjectFactory = gameObjectFactory; - this.gameObjectMatchers = gameObjectMatchers; this.globalSettings = globalSettings; - this.topmostInsertionMode = topmostInsertionMode; + this.mapModelFactory = mapModelFactory; } /** @@ -123,7 +77,7 @@ @NotNull @Override public MapControl<GameObject, MapArchObject, Archetype> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @Nullable final File file) { - final MapModel<GameObject, MapArchObject, Archetype> mapModel = newMapModel(mapArchObject); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapModelFactory.newMapModel(mapArchObject); if (objects != null) { mapModel.beginTransaction("init"); try { @@ -144,7 +98,7 @@ @NotNull @Override public MapControl<GameObject, MapArchObject, Archetype> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @Nullable final File file) { - final MapModel<GameObject, MapArchObject, Archetype> mapModel = newMapModel(mapArchObject); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapModelFactory.newMapModel(mapArchObject); if (objects != null) { mapModel.beginTransaction("init"); try { @@ -160,13 +114,4 @@ return mapControl; } - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapModel<GameObject, MapArchObject, Archetype> newMapModel(@NotNull final MapArchObject mapArchObject) { - return new DefaultMapModel<GameObject, MapArchObject, Archetype>(autojoinLists, mapArchObject, archetypeChooserModel, mapViewSettings.getEditType(), gameObjectFactory, gameObjectMatchers, topmostInsertionMode); - } - } // class DefaultMapControlFactory Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -78,6 +78,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.mapcontrol.MapControlFactory; import net.sf.gridarta.model.mapmodel.InsertionMode; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.mappathnormalizer.MapPathNormalizer; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; @@ -284,8 +285,8 @@ */ @NotNull @Override - public MapControlFactory<GameObject, MapArchObject, Archetype> newMapControlFactory(@NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode) { - return new DefaultMapControlFactory(archetypeChooserModel, autojoinLists, mapViewSettings, mapWriter, gameObjectFactory, gameObjectMatchers, globalSettings, topmostInsertionMode); + public MapControlFactory<GameObject, MapArchObject, Archetype> newMapControlFactory(@NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GlobalSettings globalSettings, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory) { + return new DefaultMapControlFactory(mapWriter, globalSettings, mapModelFactory); } /** @@ -503,8 +504,8 @@ */ @NotNull @Override - public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects<GameObject, MapArchObject, Archetype> faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects<GameObject, MapArchObject, Archetype> animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { + return mainControl.createGUIMainControl(GuiFileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapModelFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/mapcontrol/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/mapcontrol/DefaultMapControlFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/mapcontrol/DefaultMapControlFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -21,18 +21,12 @@ import java.io.File; import java.util.List; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.mapcontrol.DefaultMapControl; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.MapControlFactory; -import net.sf.gridarta.model.mapmodel.DefaultMapModel; -import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.var.daimonin.model.archetype.Archetype; import net.sf.gridarta.var.daimonin.model.gameobject.GameObject; @@ -47,74 +41,34 @@ public class DefaultMapControlFactory implements MapControlFactory<GameObject, MapArchObject, Archetype> { /** - * The {@link ArchetypeChooserModel} instance to use. - */ - @NotNull - private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel; - - /** - * The {@link AutojoinLists} instance to use. - */ - @NotNull - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; - - /** - * The map view settings instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * The {@link MapWriter} for saving {@link MapControl} instances. */ @NotNull private final MapWriter<GameObject, MapArchObject, Archetype> mapWriter; /** - * The {@link GameObjectFactory} for creating {@link GameObject}s. - */ - @NotNull - private final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; - - /** - * The {@link GameObjectMatchers} to use. - */ - @NotNull - private final GameObjectMatchers gameObjectMatchers; - - /** * The {@link GlobalSettings} to use. */ @NotNull private final GlobalSettings globalSettings; /** - * The "topmost" {@link InsertionMode}. + * The {@link MapModelFactory} for creating {@link MapModel} instances. */ @NotNull - private final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode; + private final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory; /** * Creates a new instance. - * @param archetypeChooserModel the archetype chooser model to use - * @param autojoinLists the autojoin lists to use - * @param mapViewSettings the map view settings instance * @param mapWriter the map writer for saving map control instances - * @param gameObjectFactory the game object factory for creating game - * objects - * @param gameObjectMatchers the game object matchers to use * @param globalSettings the global settings to use - * @param topmostInsertionMode the "topmost" insertion mode + * @param mapModelFactory the map model factory for creating map model + * instances */ - public DefaultMapControlFactory(@NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GlobalSettings globalSettings, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode) { - this.archetypeChooserModel = archetypeChooserModel; - this.autojoinLists = autojoinLists; - this.mapViewSettings = mapViewSettings; + public DefaultMapControlFactory(@NotNull final MapWriter<GameObject, MapArchObject, Archetype> mapWriter, @NotNull final GlobalSettings globalSettings, @NotNull final MapModelFactory<GameObject, MapArchObject, Archetype> mapModelFactory) { this.mapWriter = mapWriter; - this.gameObjectFactory = gameObjectFactory; - this.gameObjectMatchers = gameObjectMatchers; this.globalSettings = globalSettings; - this.topmostInsertionMode = topmostInsertionMode; + this.mapModelFactory = mapModelFactory; } /** @@ -123,7 +77,7 @@ @NotNull @Override public MapControl<GameObject, MapArchObject, Archetype> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @Nullable final File file) { - final MapModel<GameObject, MapArchObject, Archetype> mapModel = newMapModel(mapArchObject); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapModelFactory.newMapModel(mapArchObject); if (objects != null) { mapModel.beginTransaction("init"); try { @@ -145,7 +99,7 @@ @Override public MapControl<GameObject, MapArchObject, Archetype> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @Nullable final File file) { mapArchObject.setDifficulty(1); - final MapModel<GameObject, MapArchObject, Archetype> mapModel = newMapModel(mapArchObject); + final MapModel<GameObject, MapArchObject, Archetype> mapModel = mapModelFactory.newMapModel(mapArchObject); if (objects != null) { mapModel.beginTransaction("init"); try { @@ -161,13 +115,4 @@ return mapControl; } - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapModel<GameObject, MapArchObject, Archetype> newMapModel(@NotNull final MapArchObject mapArchObject) { - return new DefaultMapModel<GameObject, MapArchObject, Archetype>(autojoinLists, mapArchObject, archetypeChooserModel, mapViewSettings.getEditType(), gameObjectFactory, gameObjectMatchers, topmostInsertionMode); - } - } // class DefaultMapControlFactory Modified: trunk/model/src/app/net/sf/gridarta/model/mapcontrol/MapControlFactory.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcontrol/MapControlFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/model/src/app/net/sf/gridarta/model/mapcontrol/MapControlFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -24,7 +24,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,12 +53,4 @@ @NotNull MapControl<G, A, R> newPickmapControl(@Nullable List<G> objects, @NotNull A mapArchObject, @Nullable File file); - /** - * Creates a new {@link MapModel} instance. - * @param mapArchObject the map arch object to use for the new map model - * @return the new map model instance - */ - @NotNull - MapModel<G, A, R> newMapModel(@NotNull A mapArchObject); - } // interface MapControlFactory Added: trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModelFactory.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModelFactory.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModelFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -0,0 +1,103 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapmodel; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.match.GameObjectMatchers; +import org.jetbrains.annotations.NotNull; + +/** + * A factory for creating {@link MapModel} instances. + * @author Andreas Kirschbaum + */ +public class MapModelFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The {@link ArchetypeChooserModel} instance to use. + */ + @NotNull + private final ArchetypeChooserModel<G, A, R> archetypeChooserModel; + + /** + * The {@link AutojoinLists} instance to use. + */ + @NotNull + private final AutojoinLists<G, A, R> autojoinLists; + + /** + * The map view settings instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** + * The {@link GameObjectFactory} for creating {@link GameObject}s. + */ + @NotNull + private final GameObjectFactory<G, A, R> gameObjectFactory; + + /** + * The {@link GameObjectMatchers} to use. + */ + @NotNull + private final GameObjectMatchers gameObjectMatchers; + + /** + * The "topmost" {@link InsertionMode}. + */ + @NotNull + private final InsertionMode<G, A, R> topmostInsertionMode; + + /** + * Creates a new instance. + * @param archetypeChooserModel the archetype chooser model to use + * @param autojoinLists the autojoin lists to use + * @param mapViewSettings the map view settings instance + * @param gameObjectFactory the game object factory for creating game + * objects + * @param gameObjectMatchers the game object matchers to use + * @param topmostInsertionMode the "topmost" insertion mode + */ + public MapModelFactory(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final InsertionMode<G, A, R> topmostInsertionMode) { + this.archetypeChooserModel = archetypeChooserModel; + this.autojoinLists = autojoinLists; + this.mapViewSettings = mapViewSettings; + this.gameObjectFactory = gameObjectFactory; + this.gameObjectMatchers = gameObjectMatchers; + this.topmostInsertionMode = topmostInsertionMode; + } + + /** + * Creates a new {@link MapModel} instance. + * @param mapArchObject the map arch object for the map model + * @return the map model instance + */ + @NotNull + public MapModel<G, A, R> newMapModel(@NotNull final A mapArchObject) { + return new DefaultMapModel<G, A, R>(autojoinLists, mapArchObject, archetypeChooserModel, mapViewSettings.getEditType(), gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + } + +} // class MapModelFactory Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModelFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/test/net/sf/gridarta/model/mapcontrol/TestMapControlFactory.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapcontrol/TestMapControlFactory.java 2010-06-30 06:09:26 UTC (rev 8560) +++ trunk/model/src/test/net/sf/gridarta/model/mapcontrol/TestMapControlFactory.java 2010-06-30 19:03:37 UTC (rev 8561) @@ -22,16 +22,11 @@ import java.io.File; import java.util.List; import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.model.autojoin.AutojoinLists; -import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.mapmodel.DefaultMapModel; -import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.settings.GlobalSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,60 +44,28 @@ private final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter; /** - * The {@link AutojoinLists} for new maps. - */ - @NotNull - private final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists; - - /** - * The {@link ArchetypeChooserModel} for new maps. - */ - @NotNull - private final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel; - - /** - * The {@link GameObjectFactory} for for creating game objects. - */ - @NotNull - private final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory; - - /** * The {@link GlobalSettings} to use. */ @NotNull private final GlobalSettings globalSettings; /** - * The {@link GameObjectMatchers} to use. + * The {@link MapModelFactory} for creating {@link MapModel} instances. */ @NotNull - private final GameObjectMatchers gameObjectMatchers; + private final MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype> mapModelFactory; /** - * The "topmost" {@link InsertionMode}. - */ - @NotNull - private final InsertionMode<TestGameObject, TestMapArchObject, TestArchetype> topmostInsertionMode; - - /** * Creates a new instance. * @param mapWriter the map writer for saving map control instances - * @param autojoinLists the autojoin lists for new maps - * @param archetypeChooserModel the autojoin lists - * @param gameObjectFactory the game object factory for creating game - * objects * @param globalSettings the global settings to use - * @param gameObjectMatchers the game object matchers to use - * @param topmostInsertionMode the "topmost" insertion mode + * @param mapModelFactory... [truncated message content] |