diff --git a/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicEvent.java b/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicEvent.java index 0ed9fdcf8c..e29fc072d1 100644 --- a/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicEvent.java +++ b/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicEvent.java @@ -1,8 +1,8 @@ package net.sf.anathema.campaign.music.presenter; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IMusicEvent extends IIdentificate { +public interface IMusicEvent extends Identified { // Nothing to do } \ No newline at end of file diff --git a/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicMood.java b/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicMood.java index 191116cee5..a2e4412b11 100644 --- a/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicMood.java +++ b/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicMood.java @@ -1,7 +1,7 @@ package net.sf.anathema.campaign.music.presenter; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IMusicMood extends IIdentificate { +public interface IMusicMood extends Identified { // Nothing to do } \ No newline at end of file diff --git a/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicTheme.java b/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicTheme.java index d462ea2ba9..94414cfd32 100644 --- a/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicTheme.java +++ b/Campaign_Music/src/net/sf/anathema/campaign/music/presenter/IMusicTheme.java @@ -1,7 +1,7 @@ package net.sf.anathema.campaign.music.presenter; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IMusicTheme extends IIdentificate { +public interface IMusicTheme extends Identified { // Nothing to do } \ No newline at end of file diff --git a/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotElementContainer.java b/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotElementContainer.java index 9b287f4aa8..753c9d2e70 100644 --- a/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotElementContainer.java +++ b/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotElementContainer.java @@ -1,9 +1,9 @@ package net.sf.anathema.campaign.model.plot; import net.sf.anathema.framework.itemdata.model.IItemDescription; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IPlotElementContainer extends IIdentificate { +public interface IPlotElementContainer extends Identified { IPlotElement addChild(IItemDescription description, String repositoryId); diff --git a/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotTimeUnit.java b/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotTimeUnit.java index 10c51bafae..51ef689ea2 100644 --- a/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotTimeUnit.java +++ b/Campaign_Plot/src/net/sf/anathema/campaign/model/plot/IPlotTimeUnit.java @@ -1,9 +1,9 @@ package net.sf.anathema.campaign.model.plot; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; // Story, Episode, Scene -public interface IPlotTimeUnit extends IIdentificate { +public interface IPlotTimeUnit extends Identified { @Override String getId(); diff --git a/Character_Abyssal/src/net/sf/anathema/character/abyssal/equipment/FangStats.java b/Character_Abyssal/src/net/sf/anathema/character/abyssal/equipment/FangStats.java index 0606b903f0..3b107e5e7f 100644 --- a/Character_Abyssal/src/net/sf/anathema/character/abyssal/equipment/FangStats.java +++ b/Character_Abyssal/src/net/sf/anathema/character/abyssal/equipment/FangStats.java @@ -1,100 +1,100 @@ -package net.sf.anathema.character.abyssal.equipment; - -import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; -import net.sf.anathema.character.equipment.impl.creation.model.WeaponTag; -import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; -import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; -import net.sf.anathema.character.generic.health.HealthType; -import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.character.generic.traits.types.AbilityType; -import net.sf.anathema.character.generic.traits.types.AttributeType; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public class FangStats extends AbstractCombatStats implements IWeaponStats { - - @Override - public int getAccuracy() { - return 0; - } - - @Override - public int getDamage() { - return 0; - } - - @Override - public int getMinimumDamage() { - return 1; - } - - @Override - public int getMobilityPenalty() { - return 0; - } - - @Override - public ITraitType getDamageTraitType() { - return AttributeType.Strength; - } - - @Override - public HealthType getDamageType() { - return HealthType.Lethal; - } - - @Override - public Integer getDefence() { - return 0; - } - - @Override - public Integer getRange() { - return null; - } - - @Override - public Integer getRate() { - return null; - } - - @Override - public int getSpeed() { - return 6; - } - - @Override - public IIdentificate[] getTags() { - return new IIdentificate[]{WeaponTag.ClinchEnhancer, WeaponTag.Natural, WeaponTag.Piercing}; - } - - @Override - public ITraitType getTraitType() { - return AbilityType.MartialArts; - } - - @Override - public boolean inflictsNoDamage() { - return false; - } - - @Override - public boolean isRangedCombat() { - return false; - } - - @Override - public IIdentificate getName() { - return new Identificate("Abyssal.Fangs"); //$NON-NLS-1$ - } - - @Override - public IEquipmentStats[] getViews() { - return new IEquipmentStats[] { this }; - } - - @Override - public String getId() { - return getName().getId(); - } +package net.sf.anathema.character.abyssal.equipment; + +import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; +import net.sf.anathema.character.equipment.impl.creation.model.WeaponTag; +import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; +import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; +import net.sf.anathema.character.generic.health.HealthType; +import net.sf.anathema.character.generic.traits.ITraitType; +import net.sf.anathema.character.generic.traits.types.AbilityType; +import net.sf.anathema.character.generic.traits.types.AttributeType; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +public class FangStats extends AbstractCombatStats implements IWeaponStats { + + @Override + public int getAccuracy() { + return 0; + } + + @Override + public int getDamage() { + return 0; + } + + @Override + public int getMinimumDamage() { + return 1; + } + + @Override + public int getMobilityPenalty() { + return 0; + } + + @Override + public ITraitType getDamageTraitType() { + return AttributeType.Strength; + } + + @Override + public HealthType getDamageType() { + return HealthType.Lethal; + } + + @Override + public Integer getDefence() { + return 0; + } + + @Override + public Integer getRange() { + return null; + } + + @Override + public Integer getRate() { + return null; + } + + @Override + public int getSpeed() { + return 6; + } + + @Override + public Identified[] getTags() { + return new Identified[]{WeaponTag.ClinchEnhancer, WeaponTag.Natural, WeaponTag.Piercing}; + } + + @Override + public ITraitType getTraitType() { + return AbilityType.MartialArts; + } + + @Override + public boolean inflictsNoDamage() { + return false; + } + + @Override + public boolean isRangedCombat() { + return false; + } + + @Override + public Identified getName() { + return new Identificate("Abyssal.Fangs"); //$NON-NLS-1$ + } + + @Override + public IEquipmentStats[] getViews() { + return new IEquipmentStats[] { this }; + } + + @Override + public String getId() { + return getName().getId(); + } } \ No newline at end of file diff --git a/Character_Equipment/src/net/sf/anathema/character/equipment/MagicalMaterial.java b/Character_Equipment/src/net/sf/anathema/character/equipment/MagicalMaterial.java index efe9092e09..22aac9fb4e 100644 --- a/Character_Equipment/src/net/sf/anathema/character/equipment/MagicalMaterial.java +++ b/Character_Equipment/src/net/sf/anathema/character/equipment/MagicalMaterial.java @@ -3,7 +3,7 @@ import net.sf.anathema.character.generic.equipment.ArtifactAttuneType; import net.sf.anathema.character.generic.type.ICharacterType; import net.sf.anathema.character.generic.type.ICharacterTypeVisitor; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import java.util.List; @@ -13,7 +13,7 @@ import static net.sf.anathema.character.generic.equipment.ArtifactAttuneType.Unattuned; import static net.sf.anathema.character.generic.equipment.ArtifactAttuneType.UnharmoniouslyAttuned; -public enum MagicalMaterial implements IIdentificate { +public enum MagicalMaterial implements Identified { Orichalcum, Jade, Moonsilver, Starmetal, Soulsteel, Adamant, VitriolOrichalcum, VitriolJade, VitriolMoonsilver, VitriolStarmetal, VitriolSoulsteel, VitriolAdamant; diff --git a/Character_Equipment/src/net/sf/anathema/character/equipment/MaterialComposition.java b/Character_Equipment/src/net/sf/anathema/character/equipment/MaterialComposition.java index a9e3245aca..e224a1b63f 100644 --- a/Character_Equipment/src/net/sf/anathema/character/equipment/MaterialComposition.java +++ b/Character_Equipment/src/net/sf/anathema/character/equipment/MaterialComposition.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.equipment; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum MaterialComposition implements IIdentificate { +public enum MaterialComposition implements Identified { None() { @Override public boolean requiresMaterial() { diff --git a/Character_Equipment/src/net/sf/anathema/character/equipment/character/EquipmentStringBuilder.java b/Character_Equipment/src/net/sf/anathema/character/equipment/character/EquipmentStringBuilder.java index 822da6e36f..e2142a0664 100644 --- a/Character_Equipment/src/net/sf/anathema/character/equipment/character/EquipmentStringBuilder.java +++ b/Character_Equipment/src/net/sf/anathema/character/equipment/character/EquipmentStringBuilder.java @@ -10,7 +10,7 @@ import net.sf.anathema.character.generic.health.HealthType; import net.sf.anathema.lib.exception.UnreachableCodeReachedException; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class EquipmentStringBuilder implements IEquipmentStringBuilder { @@ -55,9 +55,9 @@ private String getStatsString(String keyPart, Integer value, boolean printSignum return createtNewStatsStart(keyPart) + signum + value; } - private String getTagsString( IIdentificate[] tags ) { + private String getTagsString( Identified[] tags ) { StringBuilder result = new StringBuilder(); - for( IIdentificate tag : tags ) { + for( Identified tag : tags ) { result.append( " " + tag.getId() ); } return result.toString(); diff --git a/Character_Equipment/src/net/sf/anathema/character/equipment/character/WeaponStatsNameStringFactory.java b/Character_Equipment/src/net/sf/anathema/character/equipment/character/WeaponStatsNameStringFactory.java index d63fc879cc..0e5e58eba7 100644 --- a/Character_Equipment/src/net/sf/anathema/character/equipment/character/WeaponStatsNameStringFactory.java +++ b/Character_Equipment/src/net/sf/anathema/character/equipment/character/WeaponStatsNameStringFactory.java @@ -1,14 +1,14 @@ package net.sf.anathema.character.equipment.character; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - import net.sf.anathema.character.equipment.character.model.IEquipmentItem; import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; public class WeaponStatsNameStringFactory { @@ -32,10 +32,10 @@ private boolean hasMultipleViews(IEquipmentItem item, IWeaponStats stats) { if (item == null) { return true; } - return Collections.frequency(getStatNames(item, new ArrayList()), stats.getName()) > 1; + return Collections.frequency(getStatNames(item, new ArrayList()), stats.getName()) > 1; } - private Collection getStatNames(IEquipmentItem item, Collection names) { + private Collection getStatNames(IEquipmentItem item, Collection names) { for (IEquipmentStats stats : item.getStats()) { names.add(stats.getName()); } diff --git a/Character_Equipment/src/net/sf/anathema/character/equipment/creation/model/stats/IWeaponTag.java b/Character_Equipment/src/net/sf/anathema/character/equipment/creation/model/stats/IWeaponTag.java index 04a860defe..6c6686b87b 100644 --- a/Character_Equipment/src/net/sf/anathema/character/equipment/creation/model/stats/IWeaponTag.java +++ b/Character_Equipment/src/net/sf/anathema/character/equipment/creation/model/stats/IWeaponTag.java @@ -1,7 +1,7 @@ package net.sf.anathema.character.equipment.creation.model.stats; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IWeaponTag extends IIdentificate { +public interface IWeaponTag extends Identified { // nothing to do } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/EffectiveArmour.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/EffectiveArmour.java index 605e61e402..ef1c23175b 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/EffectiveArmour.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/EffectiveArmour.java @@ -1,103 +1,103 @@ -package net.sf.anathema.character.equipment.impl.character.model.natural; - -import java.util.HashMap; -import java.util.Map; - -import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; -import net.sf.anathema.character.generic.equipment.weapon.IArmourStats; -import net.sf.anathema.character.generic.health.HealthType; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public class EffectiveArmour extends AbstractCombatStats implements IArmourStats { - - private int fatigue; - private int mobilityPenalty; - private final Map naturalSoakByHealthType = new HashMap() { - { - for (HealthType healthType : HealthType.values()) { - put(healthType, 0); - } - } - }; - private final Map equipmentSoakByHealthType = new HashMap() { - { - for (HealthType healthType : HealthType.values()) { - put(healthType, 0); - } - } - }; - private final Map hardnessByHealthType = new HashMap() { - { - for (HealthType healthType : HealthType.values()) { - put(healthType, 0); - } - } - }; - - @Override - public Integer getFatigue() { - return fatigue; - } - - @Override - public Integer getHardness(HealthType type) { - return hardnessByHealthType.get(type); - } - - @Override - public Integer getMobilityPenalty() { - return mobilityPenalty; - } - - @Override - public Integer getSoak(HealthType type) { - return naturalSoakByHealthType.get(type) + equipmentSoakByHealthType.get(type); - } - - @Override - public IIdentificate getName() { - return new Identificate("EffectiveArmour"); //$NON-NLS-1$ - } - - public void addArmour(IArmourStats armour) { - if (armour instanceof NaturalSoak) handleNaturalArmour(armour); - else handleEquipmentArmour(armour); - } - - private void handleNaturalArmour(IArmourStats armour) { - for (HealthType healthType : HealthType.values()) { - naturalSoakByHealthType.put(healthType, - getIncrementValue(naturalSoakByHealthType.get(healthType), armour.getSoak(healthType))); - } - } - - private void handleEquipmentArmour(IArmourStats armour) { - fatigue = getHighestValue(fatigue, armour.getFatigue()); - modifyMobilityPenalty(armour.getMobilityPenalty()); - for (HealthType healthType : HealthType.values()) { - equipmentSoakByHealthType.put(healthType, - getHighestValue(equipmentSoakByHealthType.get(healthType), armour.getSoak(healthType))); - hardnessByHealthType.put(healthType, - getHighestValue(hardnessByHealthType.get(healthType), armour.getHardness(healthType))); - } - } - - public void modifyMobilityPenalty(Integer amount) { - if (amount != null) mobilityPenalty += amount; - } - - private int getIncrementValue(int value, Integer increment) { - return increment == null ? value : value + increment; - } - - private int getHighestValue(int currentValue, Integer newValue) { - if (newValue == null) return currentValue; - return newValue > currentValue ? newValue : currentValue; - } - - @Override - public String getId() { - return getName().getId(); - } +package net.sf.anathema.character.equipment.impl.character.model.natural; + +import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; +import net.sf.anathema.character.generic.equipment.weapon.IArmourStats; +import net.sf.anathema.character.generic.health.HealthType; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.HashMap; +import java.util.Map; + +public class EffectiveArmour extends AbstractCombatStats implements IArmourStats { + + private int fatigue; + private int mobilityPenalty; + private final Map naturalSoakByHealthType = new HashMap() { + { + for (HealthType healthType : HealthType.values()) { + put(healthType, 0); + } + } + }; + private final Map equipmentSoakByHealthType = new HashMap() { + { + for (HealthType healthType : HealthType.values()) { + put(healthType, 0); + } + } + }; + private final Map hardnessByHealthType = new HashMap() { + { + for (HealthType healthType : HealthType.values()) { + put(healthType, 0); + } + } + }; + + @Override + public Integer getFatigue() { + return fatigue; + } + + @Override + public Integer getHardness(HealthType type) { + return hardnessByHealthType.get(type); + } + + @Override + public Integer getMobilityPenalty() { + return mobilityPenalty; + } + + @Override + public Integer getSoak(HealthType type) { + return naturalSoakByHealthType.get(type) + equipmentSoakByHealthType.get(type); + } + + @Override + public Identified getName() { + return new Identificate("EffectiveArmour"); //$NON-NLS-1$ + } + + public void addArmour(IArmourStats armour) { + if (armour instanceof NaturalSoak) handleNaturalArmour(armour); + else handleEquipmentArmour(armour); + } + + private void handleNaturalArmour(IArmourStats armour) { + for (HealthType healthType : HealthType.values()) { + naturalSoakByHealthType.put(healthType, + getIncrementValue(naturalSoakByHealthType.get(healthType), armour.getSoak(healthType))); + } + } + + private void handleEquipmentArmour(IArmourStats armour) { + fatigue = getHighestValue(fatigue, armour.getFatigue()); + modifyMobilityPenalty(armour.getMobilityPenalty()); + for (HealthType healthType : HealthType.values()) { + equipmentSoakByHealthType.put(healthType, + getHighestValue(equipmentSoakByHealthType.get(healthType), armour.getSoak(healthType))); + hardnessByHealthType.put(healthType, + getHighestValue(hardnessByHealthType.get(healthType), armour.getHardness(healthType))); + } + } + + public void modifyMobilityPenalty(Integer amount) { + if (amount != null) mobilityPenalty += amount; + } + + private int getIncrementValue(int value, Integer increment) { + return increment == null ? value : value + increment; + } + + private int getHighestValue(int currentValue, Integer newValue) { + if (newValue == null) return currentValue; + return newValue > currentValue ? newValue : currentValue; + } + + @Override + public String getId() { + return getName().getId(); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/NaturalSoak.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/NaturalSoak.java index 27dd4587e3..836351b538 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/NaturalSoak.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/NaturalSoak.java @@ -8,8 +8,8 @@ import net.sf.anathema.character.generic.traits.types.AttributeType; import net.sf.anathema.character.generic.traits.types.OtherTraitType; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class NaturalSoak extends AbstractCombatStats implements IArmourStats { @@ -86,7 +86,7 @@ private Integer getExaltedSoak(HealthType type) { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate("NaturalSoak"); //$NON-NLS-1$ } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Clinch.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Clinch.java index 7ef250a6e3..b8e579ebe0 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Clinch.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Clinch.java @@ -5,8 +5,8 @@ import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.AbilityType; import net.sf.anathema.character.generic.traits.types.AttributeType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class Clinch extends AbstractNaturalWeaponStats { @@ -41,8 +41,8 @@ public int getSpeed() { } @Override - public IIdentificate[] getTags() { - return new IIdentificate[] { WeaponTag.ClinchEnhancer, WeaponTag.Natural, WeaponTag.Piercing }; + public Identified[] getTags() { + return new Identified[] { WeaponTag.ClinchEnhancer, WeaponTag.Natural, WeaponTag.Piercing }; } @Override @@ -61,7 +61,7 @@ public boolean inflictsNoDamage() { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate("Clinch"); //$NON-NLS-1$ } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Kick.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Kick.java index 0e2065b5f3..3a477d2102 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Kick.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Kick.java @@ -5,8 +5,8 @@ import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.AbilityType; import net.sf.anathema.character.generic.traits.types.AttributeType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class Kick extends AbstractNaturalWeaponStats { @@ -41,8 +41,8 @@ public int getSpeed() { } @Override - public IIdentificate[] getTags() { - return new IIdentificate[] { WeaponTag.Natural }; + public Identified[] getTags() { + return new Identified[] { WeaponTag.Natural }; } @Override @@ -61,7 +61,7 @@ public boolean inflictsNoDamage() { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate("Kick"); //$NON-NLS-1$ } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Punch.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Punch.java index f4ca1c23f9..5fee81ca57 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Punch.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/natural/secondedition/Punch.java @@ -5,8 +5,8 @@ import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.AbilityType; import net.sf.anathema.character.generic.traits.types.AttributeType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class Punch extends AbstractNaturalWeaponStats { @@ -41,8 +41,8 @@ public int getSpeed() { } @Override - public IIdentificate[] getTags() { - return new IIdentificate[] { WeaponTag.Natural }; + public Identified[] getTags() { + return new Identified[] { WeaponTag.Natural }; } @Override @@ -61,7 +61,7 @@ public boolean inflictsNoDamage() { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate("Punch"); //$NON-NLS-1$ } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/ArmourStatsDecorationFactory.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/ArmourStatsDecorationFactory.java index 1142c301bb..c8ac1652c7 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/ArmourStatsDecorationFactory.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/ArmourStatsDecorationFactory.java @@ -5,8 +5,8 @@ import net.sf.anathema.character.generic.equipment.weapon.IArmourStats; import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; import net.sf.anathema.character.generic.health.HealthType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class ArmourStatsDecorationFactory implements IEquipmentStatsDecorationFactory { @@ -52,7 +52,7 @@ public Integer getSoak(HealthType type) { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate(name); } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/EquipmentPrintNameFactory.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/EquipmentPrintNameFactory.java index 1e68fb2792..9537062c6e 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/EquipmentPrintNameFactory.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/print/EquipmentPrintNameFactory.java @@ -1,15 +1,15 @@ package net.sf.anathema.character.equipment.impl.character.model.print; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - import net.sf.anathema.character.equipment.character.model.IEquipmentItem; import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; public class EquipmentPrintNameFactory { private final IResources resources; @@ -27,7 +27,7 @@ public String create(IEquipmentItem item, IWeaponStats stats) { builder.append(" - "); //$NON-NLS-1$ builder.append(stats.getName()); } - if (Collections.frequency(getStatNames(item, new ArrayList()), stats.getName()) > 1) { + if (Collections.frequency(getStatNames(item, new ArrayList()), stats.getName()) > 1) { builder.append(" ("); //$NON-NLS-1$ builder.append(resources.getString(stats.getTraitType().getId())); builder.append(")"); //$NON-NLS-1$ @@ -36,10 +36,10 @@ public String create(IEquipmentItem item, IWeaponStats stats) { } private boolean hasSingleOriginalStat(IEquipmentItem item) { - return getStatNames(item, new HashSet()).size() == 1; + return getStatNames(item, new HashSet()).size() == 1; } - private Collection getStatNames(IEquipmentItem item, Collection names) { + private Collection getStatNames(IEquipmentItem item, Collection names) { for (IEquipmentStats stats : item.getStats()) { if (!stats.representsItemForUseInCombat()) { continue; diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractStats.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractStats.java index 1b5c476326..db589306d9 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractStats.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractStats.java @@ -1,18 +1,18 @@ package net.sf.anathema.character.equipment.impl.character.model.stats; import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public abstract class AbstractStats implements IEquipmentStats { - private IIdentificate name; + private Identified name; @Override - public IIdentificate getName() { + public Identified getName() { return name; } - public final void setName(IIdentificate name) { + public final void setName(Identified name) { if (name == null) name = null; this.name = name; } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractWeaponStats.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractWeaponStats.java index 0bad937f04..1dc639175b 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractWeaponStats.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/AbstractWeaponStats.java @@ -7,8 +7,8 @@ import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.AttributeType; import net.sf.anathema.lib.collection.ArrayUtilities; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.ITransformer; +import net.sf.anathema.lib.util.Identified; import java.util.List; @@ -75,7 +75,7 @@ public int getSpeed() { } @Override - public IIdentificate[] getTags() { + public Identified[] getTags() { String[] tagIds = tags.toArray(new String[tags.size()]); return ArrayUtilities.transform(tagIds, WeaponTag.class, new ITransformer() { @Override @@ -130,7 +130,7 @@ public void setSpeed(int speed) { this.speed = speed; } - public void addTag(IIdentificate tag) { + public void addTag(Identified tag) { tags.add(tag.getId()); } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyArmourStats.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyArmourStats.java index 41b5a39207..28d3bebe6b 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyArmourStats.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyArmourStats.java @@ -15,7 +15,7 @@ import net.sf.anathema.character.generic.equipment.weapon.IArmourStats; import net.sf.anathema.character.generic.health.HealthType; import net.sf.anathema.character.generic.util.IProxy; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.util.ObjectUtilities; public class ProxyArmourStats extends AbstractStats implements IArmourStats, IProxy { @@ -66,7 +66,7 @@ private AttunementModifier createAttunementModifier(StatModifier modifier) { } @Override - public IIdentificate getName() { + public Identified getName() { return delegate.getName(); } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats.java index 5863131f55..d6851e3529 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats.java @@ -33,7 +33,7 @@ import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.util.IProxy; import net.sf.anathema.lib.collection.ArrayUtilities; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class ProxyWeaponStats extends AbstractStats implements IWeaponStats, IProxy { @@ -159,7 +159,7 @@ public int getSpeed() { } @Override - public IIdentificate[] getTags() { + public Identified[] getTags() { return new TagsModification(material).getModifiedValue(delegate.getTags()); } @@ -178,7 +178,7 @@ public boolean inflictsNoDamage() { } @Override - public IIdentificate getName() { + public Identified getName() { return delegate.getName(); } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/WeaponStatsDecorator.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/WeaponStatsDecorator.java index 35a95b9f8f..08b2e9a7ad 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/WeaponStatsDecorator.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/WeaponStatsDecorator.java @@ -5,13 +5,13 @@ import net.sf.anathema.character.generic.health.HealthType; import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.AbilityType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class WeaponStatsDecorator extends AbstractStats implements IWeaponStats { private IWeaponStats stats; private ITraitType ability; - private IIdentificate name; + private Identified name; public WeaponStatsDecorator(IWeaponStats stats, AbilityType statsAbility) { this.stats = stats; @@ -76,7 +76,7 @@ public int getSpeed() { } @Override - public IIdentificate[] getTags() { + public Identified[] getTags() { return stats.getTags(); } @@ -101,7 +101,7 @@ public IEquipmentStats[] getViews() { } @Override - public IIdentificate getName() { + public Identified getName() { return name; } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/modification/TagsModification.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/modification/TagsModification.java index e7c1951818..59666e822a 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/modification/TagsModification.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/model/stats/modification/TagsModification.java @@ -1,41 +1,41 @@ -package net.sf.anathema.character.equipment.impl.character.model.stats.modification; - -import com.google.common.collect.Lists; -import net.sf.anathema.character.equipment.impl.creation.model.WeaponTag; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import static net.sf.anathema.character.equipment.impl.creation.model.WeaponTag.Piercing; -import static net.sf.anathema.lib.collection.ArrayUtilities.containsValue; - -public class TagsModification { - private BaseMaterial material; - - public TagsModification(BaseMaterial material) { - this.material = material; - } - - - public IIdentificate[] getModifiedValue(IIdentificate[] tags) { - if (!material.isAdamantBased()) { - return tags; - } - if (!containsValue(tags, Piercing)) { - return addPiercing(tags); - } - return addAdamantPiercing(tags); - } - - private IIdentificate[] addAdamantPiercing(IIdentificate[] tags) { - return addTag(tags, new Identificate("AdamantPiercing")); - } - - private IIdentificate[] addPiercing(IIdentificate[] tags) { - WeaponTag newTag = Piercing; - return addTag(tags, newTag); - } - - private IIdentificate[] addTag(IIdentificate[] tags, IIdentificate newTag) { - return Lists.asList(newTag, tags).toArray(new IIdentificate[tags.length + 1]); - } +package net.sf.anathema.character.equipment.impl.character.model.stats.modification; + +import com.google.common.collect.Lists; +import net.sf.anathema.character.equipment.impl.creation.model.WeaponTag; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.character.equipment.impl.creation.model.WeaponTag.Piercing; +import static net.sf.anathema.lib.collection.ArrayUtilities.containsValue; + +public class TagsModification { + private BaseMaterial material; + + public TagsModification(BaseMaterial material) { + this.material = material; + } + + + public Identified[] getModifiedValue(Identified[] tags) { + if (!material.isAdamantBased()) { + return tags; + } + if (!containsValue(tags, Piercing)) { + return addPiercing(tags); + } + return addAdamantPiercing(tags); + } + + private Identified[] addAdamantPiercing(Identified[] tags) { + return addTag(tags, new Identificate("AdamantPiercing")); + } + + private Identified[] addPiercing(Identified[] tags) { + WeaponTag newTag = Piercing; + return addTag(tags, newTag); + } + + private Identified[] addTag(Identified[] tags, Identified newTag) { + return Lists.asList(newTag, tags).toArray(new Identified[tags.length + 1]); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/EnablePersonalizationPreferencesElement.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/EnablePersonalizationPreferencesElement.java index 01df54869c..9b13b89306 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/EnablePersonalizationPreferencesElement.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/EnablePersonalizationPreferencesElement.java @@ -1,44 +1,44 @@ -package net.sf.anathema.character.equipment.impl.character.preferences; - -import net.sf.anathema.framework.module.preferences.AbstractCheckBoxPreferencesElement; -import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.util.IIdentificate; - -import static net.sf.anathema.character.equipment.character.preference.IEquipmentPreferencesConstants.ENABLE_PERSONALIZATION; - -@PreferenceElement -public class EnablePersonalizationPreferencesElement extends AbstractCheckBoxPreferencesElement implements - IEquipmentPreferencesElement { - - private boolean enablePersonalization = EQUIPMENT_PREFERENCES.getBoolean(ENABLE_PERSONALIZATION, false); - - @Override - public void savePreferences() { - EQUIPMENT_PREFERENCES.putBoolean(ENABLE_PERSONALIZATION, enablePersonalization); - } - - @Override - protected boolean getBooleanParameter() { - return enablePersonalization; - } - - @Override - protected String getLabelKey() { - return "Equipment.Tools.Preferences.EnablePersonalization"; //$NON-NLS-1$ - } - - @Override - protected void resetValue() { - enablePersonalization = EQUIPMENT_PREFERENCES.getBoolean(ENABLE_PERSONALIZATION, false); - } - - @Override - protected void setValue(boolean value) { - enablePersonalization = value; - } - - @Override - public IIdentificate getCategory() { - return EQUIPMENT_CATEGORY; - } +package net.sf.anathema.character.equipment.impl.character.preferences; + +import net.sf.anathema.framework.module.preferences.AbstractCheckBoxPreferencesElement; +import net.sf.anathema.initialization.PreferenceElement; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.character.equipment.character.preference.IEquipmentPreferencesConstants.ENABLE_PERSONALIZATION; + +@PreferenceElement +public class EnablePersonalizationPreferencesElement extends AbstractCheckBoxPreferencesElement implements + IEquipmentPreferencesElement { + + private boolean enablePersonalization = EQUIPMENT_PREFERENCES.getBoolean(ENABLE_PERSONALIZATION, false); + + @Override + public void savePreferences() { + EQUIPMENT_PREFERENCES.putBoolean(ENABLE_PERSONALIZATION, enablePersonalization); + } + + @Override + protected boolean getBooleanParameter() { + return enablePersonalization; + } + + @Override + protected String getLabelKey() { + return "Equipment.Tools.Preferences.EnablePersonalization"; //$NON-NLS-1$ + } + + @Override + protected void resetValue() { + enablePersonalization = EQUIPMENT_PREFERENCES.getBoolean(ENABLE_PERSONALIZATION, false); + } + + @Override + protected void setValue(boolean value) { + enablePersonalization = value; + } + + @Override + public Identified getCategory() { + return EQUIPMENT_CATEGORY; + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/IEquipmentPreferencesElement.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/IEquipmentPreferencesElement.java index 1d00b7c69d..3f65015848 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/IEquipmentPreferencesElement.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/character/preferences/IEquipmentPreferencesElement.java @@ -1,15 +1,15 @@ -package net.sf.anathema.character.equipment.impl.character.preferences; - -import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import java.util.prefs.Preferences; - -import static net.sf.anathema.character.equipment.character.preference.IEquipmentPreferencesConstants.EQUIPMENT_PREFERENCES_NODE; - -public interface IEquipmentPreferencesElement extends IPreferencesElement { - - Preferences EQUIPMENT_PREFERENCES = Preferences.userRoot().node(EQUIPMENT_PREFERENCES_NODE); - IIdentificate EQUIPMENT_CATEGORY = new Identificate("Equipment"); //$NON-NLS-1$ +package net.sf.anathema.character.equipment.impl.character.preferences; + +import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.prefs.Preferences; + +import static net.sf.anathema.character.equipment.character.preference.IEquipmentPreferencesConstants.EQUIPMENT_PREFERENCES_NODE; + +public interface IEquipmentPreferencesElement extends IPreferencesElement { + + Preferences EQUIPMENT_PREFERENCES = Preferences.userRoot().node(EQUIPMENT_PREFERENCES_NODE); + Identified EQUIPMENT_CATEGORY = new Identificate("Equipment"); //$NON-NLS-1$ } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/EquipmentStatsCreationFactory.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/EquipmentStatsCreationFactory.java index 8c32e22aa6..dd57531350 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/EquipmentStatsCreationFactory.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/EquipmentStatsCreationFactory.java @@ -36,8 +36,8 @@ import net.sf.anathema.lib.gui.dialog.wizard.WizardDialog; import net.sf.anathema.lib.gui.wizard.AnathemaWizardDialog; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.awt.Component; @@ -134,7 +134,7 @@ private void createModel(IEquipmentStatisticsCreationModel model, IEquipmentStat } private void fillWeaponTagsModel(IWeaponTagsModel weaponTagsModel, IWeaponStats weaponStats) { - for (IIdentificate tag : weaponStats.getTags()) { + for (Identified tag : weaponStats.getTags()) { weaponTagsModel.getSelectedModel((WeaponTag) tag).setValue(true); } } diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/EquipmentGson.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/EquipmentGson.java index eede49a43c..d12ae80f55 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/EquipmentGson.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/EquipmentGson.java @@ -1,31 +1,31 @@ -package net.sf.anathema.character.equipment.impl.item.model.gson; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import net.sf.anathema.character.equipment.impl.character.model.EquipmentTemplate; -import net.sf.anathema.character.equipment.item.model.ICollectionFactory; -import net.sf.anathema.character.equipment.template.IEquipmentTemplate; -import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; -import net.sf.anathema.lib.util.IIdentificate; - -public class EquipmentGson { - - private Gson gson; - - public EquipmentGson() { - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.registerTypeAdapter(IEquipmentStats.class, new StatsAdapter()); - gsonBuilder.registerTypeAdapter(ICollectionFactory.class, new CollectionFactoryFactory()); - gsonBuilder.registerTypeAdapter(IIdentificate.class, new IdentificateAdapter()); - gsonBuilder.setPrettyPrinting(); - gson = gsonBuilder.create(); - } - - public String toJson(IEquipmentTemplate template) { - return gson.toJson(template); - } - - public IEquipmentTemplate fromJson(String json) { - return gson.fromJson(json, EquipmentTemplate.class); - } +package net.sf.anathema.character.equipment.impl.item.model.gson; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import net.sf.anathema.character.equipment.impl.character.model.EquipmentTemplate; +import net.sf.anathema.character.equipment.item.model.ICollectionFactory; +import net.sf.anathema.character.equipment.template.IEquipmentTemplate; +import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; +import net.sf.anathema.lib.util.Identified; + +public class EquipmentGson { + + private Gson gson; + + public EquipmentGson() { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapter(IEquipmentStats.class, new StatsAdapter()); + gsonBuilder.registerTypeAdapter(ICollectionFactory.class, new CollectionFactoryFactory()); + gsonBuilder.registerTypeAdapter(Identified.class, new IdentificateAdapter()); + gsonBuilder.setPrettyPrinting(); + gson = gsonBuilder.create(); + } + + public String toJson(IEquipmentTemplate template) { + return gson.toJson(template); + } + + public IEquipmentTemplate fromJson(String json) { + return gson.fromJson(json, EquipmentTemplate.class); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/IdentificateAdapter.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/IdentificateAdapter.java index 7196f55373..dbf3084ccb 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/IdentificateAdapter.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/item/model/gson/IdentificateAdapter.java @@ -1,22 +1,22 @@ -package net.sf.anathema.character.equipment.impl.item.model.gson; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import java.io.IOException; - -public class IdentificateAdapter extends TypeAdapter { - @Override - public void write(JsonWriter out, IIdentificate value) throws IOException { - out.value(value.getId()); - } - - @Override - public IIdentificate read(JsonReader in) throws IOException { - String id = in.nextString(); - return new Identificate(id); - } +package net.sf.anathema.character.equipment.impl.item.model.gson; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.io.IOException; + +public class IdentificateAdapter extends TypeAdapter { + @Override + public void write(JsonWriter out, Identified value) throws IOException { + out.value(value.getId()); + } + + @Override + public Identified read(JsonReader in) throws IOException { + String id = in.nextString(); + return new Identificate(id); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/reporting/content/stats/weapons/TagsStatsGroup.java b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/reporting/content/stats/weapons/TagsStatsGroup.java index c12f0c42e7..c02fcc2928 100644 --- a/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/reporting/content/stats/weapons/TagsStatsGroup.java +++ b/Character_Equipment_Impl/src/net/sf/anathema/character/equipment/impl/reporting/content/stats/weapons/TagsStatsGroup.java @@ -1,66 +1,66 @@ -package net.sf.anathema.character.equipment.impl.reporting.content.stats.weapons; - -import com.google.common.base.Joiner; -import com.itextpdf.text.BaseColor; -import com.itextpdf.text.Element; -import com.itextpdf.text.Font; -import com.itextpdf.text.Rectangle; -import com.itextpdf.text.pdf.PdfPCell; -import com.itextpdf.text.pdf.PdfPTable; -import net.sf.anathema.character.equipment.impl.reporting.content.stats.IEquipmentStatsGroup; -import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; -import net.sf.anathema.character.reporting.pdf.rendering.general.table.TableEncodingUtilities; -import net.sf.anathema.lib.collection.ArrayUtilities; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.ITransformer; - -public final class TagsStatsGroup implements IEquipmentStatsGroup { - private final String title; - private final IResources resources; - - public TagsStatsGroup(IResources resources) { - this.resources = resources; - this.title = resources.getString("Sheet.Equipment.Header.Tags"); //$NON-NLS-1$ ; - } - - @Override - public int getColumnCount() { - return 1; - } - - @Override - public String getTitle() { - return title; - } - - @Override - public Float[] getColumnWeights() { - return new Float[]{new Float(1.7)}; - } - - @Override - public void addContent(PdfPTable table, Font font, IWeaponStats weapon) { - if (weapon == null) { - table.addCell(createEmptyNameCell(font)); - } else { - IIdentificate[] tags = weapon.getTags(); - String[] values = ArrayUtilities.transform(tags, String.class, new ITransformer() { - @Override - public String transform(IIdentificate input) { - return resources.getString("Weapons.Tags." + input.getId() + ".Short"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }); - String valueString = values.length == 0 ? " " : Joiner.on(",").join(values); - table.addCell(createFilledContentCell(font, valueString)); - } - } - - private PdfPCell createEmptyNameCell(Font font) { - return createFilledContentCell(font, " "); //$NON-NLS-1$ - } - - private PdfPCell createFilledContentCell(Font font, String text) { - return TableEncodingUtilities.createContentCellTable(BaseColor.BLACK, text, font, 0.5f, Rectangle.BOTTOM, Element.ALIGN_LEFT); - } -} +package net.sf.anathema.character.equipment.impl.reporting.content.stats.weapons; + +import com.google.common.base.Joiner; +import com.itextpdf.text.BaseColor; +import com.itextpdf.text.Element; +import com.itextpdf.text.Font; +import com.itextpdf.text.Rectangle; +import com.itextpdf.text.pdf.PdfPCell; +import com.itextpdf.text.pdf.PdfPTable; +import net.sf.anathema.character.equipment.impl.reporting.content.stats.IEquipmentStatsGroup; +import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; +import net.sf.anathema.character.reporting.pdf.rendering.general.table.TableEncodingUtilities; +import net.sf.anathema.lib.collection.ArrayUtilities; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.ITransformer; +import net.sf.anathema.lib.util.Identified; + +public final class TagsStatsGroup implements IEquipmentStatsGroup { + private final String title; + private final IResources resources; + + public TagsStatsGroup(IResources resources) { + this.resources = resources; + this.title = resources.getString("Sheet.Equipment.Header.Tags"); //$NON-NLS-1$ ; + } + + @Override + public int getColumnCount() { + return 1; + } + + @Override + public String getTitle() { + return title; + } + + @Override + public Float[] getColumnWeights() { + return new Float[]{new Float(1.7)}; + } + + @Override + public void addContent(PdfPTable table, Font font, IWeaponStats weapon) { + if (weapon == null) { + table.addCell(createEmptyNameCell(font)); + } else { + Identified[] tags = weapon.getTags(); + String[] values = ArrayUtilities.transform(tags, String.class, new ITransformer() { + @Override + public String transform(Identified input) { + return resources.getString("Weapons.Tags." + input.getId() + ".Short"); //$NON-NLS-1$ //$NON-NLS-2$ + } + }); + String valueString = values.length == 0 ? " " : Joiner.on(",").join(values); + table.addCell(createFilledContentCell(font, valueString)); + } + } + + private PdfPCell createEmptyNameCell(Font font) { + return createFilledContentCell(font, " "); //$NON-NLS-1$ + } + + private PdfPCell createFilledContentCell(Font font, String text) { + return TableEncodingUtilities.createContentCellTable(BaseColor.BLACK, text, font, 0.5f, Rectangle.BOTTOM, Element.ALIGN_LEFT); + } +} diff --git a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoMeleeWeapon.java b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoMeleeWeapon.java index 798be07bd2..0de38d5794 100644 --- a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoMeleeWeapon.java +++ b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoMeleeWeapon.java @@ -1,148 +1,148 @@ -package net.sf.anathema.character.equipment.dummy; - -import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; -import net.sf.anathema.character.equipment.impl.creation.model.WeaponTag; -import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; -import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; -import net.sf.anathema.character.generic.health.HealthType; -import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.character.generic.traits.types.AbilityType; -import net.sf.anathema.character.generic.traits.types.AttributeType; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public class DemoMeleeWeapon extends AbstractCombatStats implements IWeaponStats { - - private final int accuracy; - private final int damage; - private final int minimumDamage; - private final HealthType healthType; - private final Integer defense; - private final int rate; - private final int speed; - private final int mobility; - private final WeaponTag[] tags; - private IIdentificate name; - - public DemoMeleeWeapon() { - this(new Identificate("Melee"), //$NON-NLS-1$ - 2, - -5, - 3, - 1, - HealthType.Aggravated, - -1, - 0, - 6, - WeaponTag.ClinchEnhancer, - WeaponTag.Piercing); - } - - public DemoMeleeWeapon( - IIdentificate name, - int speed, - int accuracy, - int damage, - int minimumDamage, - HealthType healthType, - int defense, - int mobility, - int rate, - WeaponTag... tags) { - this.name = name; - this.accuracy = accuracy; - this.damage = damage; - this.minimumDamage = minimumDamage; - this.healthType = healthType; - this.defense = defense; - this.mobility = mobility; - this.rate = rate; - this.speed = speed; - this.tags = tags; - } - - @Override - public int getAccuracy() { - return accuracy; - } - - @Override - public int getDamage() { - return damage; - } - - @Override - public HealthType getDamageType() { - return healthType; - } - - @Override - public int getMinimumDamage() { - return minimumDamage; - } - - @Override - public Integer getDefence() { - return defense; - } - - @Override - public int getMobilityPenalty() { - return mobility; - } - - @Override - public Integer getRange() { - return null; - } - - @Override - public Integer getRate() { - return rate; - } - - @Override - public int getSpeed() { - return speed; - } - - @Override - public IIdentificate[] getTags() { - return tags; - } - - @Override - public ITraitType getTraitType() { - return AbilityType.Melee; - } - - @Override - public ITraitType getDamageTraitType() { - return AttributeType.Strength; - } - - @Override - public boolean inflictsNoDamage() { - return false; - } - - @Override - public IIdentificate getName() { - return name; - } - - @Override - public boolean isRangedCombat() { - return false; - } - - @Override - public IEquipmentStats[] getViews() { - return new IEquipmentStats[] { this }; - } - - @Override - public String getId() { - return getName().getId(); - } +package net.sf.anathema.character.equipment.dummy; + +import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; +import net.sf.anathema.character.equipment.impl.creation.model.WeaponTag; +import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; +import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; +import net.sf.anathema.character.generic.health.HealthType; +import net.sf.anathema.character.generic.traits.ITraitType; +import net.sf.anathema.character.generic.traits.types.AbilityType; +import net.sf.anathema.character.generic.traits.types.AttributeType; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +public class DemoMeleeWeapon extends AbstractCombatStats implements IWeaponStats { + + private final int accuracy; + private final int damage; + private final int minimumDamage; + private final HealthType healthType; + private final Integer defense; + private final int rate; + private final int speed; + private final int mobility; + private final WeaponTag[] tags; + private Identified name; + + public DemoMeleeWeapon() { + this(new Identificate("Melee"), //$NON-NLS-1$ + 2, + -5, + 3, + 1, + HealthType.Aggravated, + -1, + 0, + 6, + WeaponTag.ClinchEnhancer, + WeaponTag.Piercing); + } + + public DemoMeleeWeapon( + Identified name, + int speed, + int accuracy, + int damage, + int minimumDamage, + HealthType healthType, + int defense, + int mobility, + int rate, + WeaponTag... tags) { + this.name = name; + this.accuracy = accuracy; + this.damage = damage; + this.minimumDamage = minimumDamage; + this.healthType = healthType; + this.defense = defense; + this.mobility = mobility; + this.rate = rate; + this.speed = speed; + this.tags = tags; + } + + @Override + public int getAccuracy() { + return accuracy; + } + + @Override + public int getDamage() { + return damage; + } + + @Override + public HealthType getDamageType() { + return healthType; + } + + @Override + public int getMinimumDamage() { + return minimumDamage; + } + + @Override + public Integer getDefence() { + return defense; + } + + @Override + public int getMobilityPenalty() { + return mobility; + } + + @Override + public Integer getRange() { + return null; + } + + @Override + public Integer getRate() { + return rate; + } + + @Override + public int getSpeed() { + return speed; + } + + @Override + public Identified[] getTags() { + return tags; + } + + @Override + public ITraitType getTraitType() { + return AbilityType.Melee; + } + + @Override + public ITraitType getDamageTraitType() { + return AttributeType.Strength; + } + + @Override + public boolean inflictsNoDamage() { + return false; + } + + @Override + public Identified getName() { + return name; + } + + @Override + public boolean isRangedCombat() { + return false; + } + + @Override + public IEquipmentStats[] getViews() { + return new IEquipmentStats[] { this }; + } + + @Override + public String getId() { + return getName().getId(); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoNaturalArmour.java b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoNaturalArmour.java index 3a33893aec..b84464f8e1 100644 --- a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoNaturalArmour.java +++ b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoNaturalArmour.java @@ -1,55 +1,55 @@ -package net.sf.anathema.character.equipment.dummy; - -import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; -import net.sf.anathema.character.generic.equipment.weapon.IArmourStats; -import net.sf.anathema.character.generic.health.HealthType; -import net.sf.anathema.lib.util.IIdentificate; - -public class DemoNaturalArmour extends AbstractCombatStats implements IArmourStats { - - private final int bashingSoak; - private final int lethalSoak; - private final IIdentificate name; - - public DemoNaturalArmour(IIdentificate identificate, int bashingSoak, int lethalSoak) { - this.name = identificate; - this.bashingSoak = bashingSoak; - this.lethalSoak = lethalSoak; - } - - @Override - public Integer getFatigue() { - return null; - } - - @Override - public Integer getHardness(HealthType healthType) { - return null; - } - - @Override - public Integer getMobilityPenalty() { - return null; - } - - @Override - public Integer getSoak(HealthType type) { - if (type == HealthType.Aggravated) { - return null; - } - if (type == HealthType.Lethal) { - return lethalSoak; - } - return bashingSoak; - } - - @Override - public IIdentificate getName() { - return name; - } - - @Override - public String getId() { - return getName().getId(); - } +package net.sf.anathema.character.equipment.dummy; + +import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; +import net.sf.anathema.character.generic.equipment.weapon.IArmourStats; +import net.sf.anathema.character.generic.health.HealthType; +import net.sf.anathema.lib.util.Identified; + +public class DemoNaturalArmour extends AbstractCombatStats implements IArmourStats { + + private final int bashingSoak; + private final int lethalSoak; + private final Identified name; + + public DemoNaturalArmour(Identified identificate, int bashingSoak, int lethalSoak) { + this.name = identificate; + this.bashingSoak = bashingSoak; + this.lethalSoak = lethalSoak; + } + + @Override + public Integer getFatigue() { + return null; + } + + @Override + public Integer getHardness(HealthType healthType) { + return null; + } + + @Override + public Integer getMobilityPenalty() { + return null; + } + + @Override + public Integer getSoak(HealthType type) { + if (type == HealthType.Aggravated) { + return null; + } + if (type == HealthType.Lethal) { + return lethalSoak; + } + return bashingSoak; + } + + @Override + public Identified getName() { + return name; + } + + @Override + public String getId() { + return getName().getId(); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoRangeWeapon.java b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoRangeWeapon.java index 65d3c65951..0d4a2509c9 100644 --- a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoRangeWeapon.java +++ b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/dummy/DemoRangeWeapon.java @@ -1,133 +1,133 @@ -package net.sf.anathema.character.equipment.dummy; - -import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; -import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; -import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; -import net.sf.anathema.character.generic.health.HealthType; -import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.character.generic.traits.types.AbilityType; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public class DemoRangeWeapon extends AbstractCombatStats implements IWeaponStats { - - private final int speed; - private final int accuracy; - private final int damage; - private final int minimumDamage; - private final HealthType damageType; - private final int range; - private final IIdentificate name; - private final int rate; - private final boolean isNoDamage; - - public DemoRangeWeapon() { - this(new Identificate("Range"), 0, 12, 15, 1, HealthType.Bashing, 200, 3, true); //$NON-NLS-1$ - } - - public DemoRangeWeapon( - Identificate name, - int speed, - int accuracy, - int damage, - int minimumDamage, - HealthType damageType, - int range, - int rate, - boolean isNoDamage) { - this.name = name; - this.speed = speed; - this.accuracy = accuracy; - this.damage = damage; - this.minimumDamage = minimumDamage; - this.damageType = damageType; - this.range = range; - this.rate = rate; - this.isNoDamage = isNoDamage; - } - - @Override - public int getAccuracy() { - return accuracy; - } - - @Override - public int getDamage() { - return damage; - } - - @Override - public int getMinimumDamage() { - return minimumDamage; - } - - @Override - public HealthType getDamageType() { - return damageType; - } - - @Override - public Integer getDefence() { - return null; - } - - @Override - public int getMobilityPenalty() { - return 0; - } - - @Override - public Integer getRange() { - return range; - } - - @Override - public Integer getRate() { - return rate; - } - - @Override - public int getSpeed() { - return speed; - } - - @Override - public IIdentificate[] getTags() { - return new IIdentificate[0]; - } - - @Override - public ITraitType getTraitType() { - return AbilityType.MartialArts; - } - - @Override - public ITraitType getDamageTraitType() { - return null; - } - - @Override - public boolean inflictsNoDamage() { - return isNoDamage; - } - - @Override - public IIdentificate getName() { - return name; - } - - @Override - public boolean isRangedCombat() { - return true; - } - - @Override - public IEquipmentStats[] getViews() { - return new IEquipmentStats[] { this }; - } - - @Override - public String getId() { - return getName().getId(); - } +package net.sf.anathema.character.equipment.dummy; + +import net.sf.anathema.character.equipment.impl.character.model.stats.AbstractCombatStats; +import net.sf.anathema.character.generic.equipment.weapon.IEquipmentStats; +import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; +import net.sf.anathema.character.generic.health.HealthType; +import net.sf.anathema.character.generic.traits.ITraitType; +import net.sf.anathema.character.generic.traits.types.AbilityType; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +public class DemoRangeWeapon extends AbstractCombatStats implements IWeaponStats { + + private final int speed; + private final int accuracy; + private final int damage; + private final int minimumDamage; + private final HealthType damageType; + private final int range; + private final Identified name; + private final int rate; + private final boolean isNoDamage; + + public DemoRangeWeapon() { + this(new Identificate("Range"), 0, 12, 15, 1, HealthType.Bashing, 200, 3, true); //$NON-NLS-1$ + } + + public DemoRangeWeapon( + Identificate name, + int speed, + int accuracy, + int damage, + int minimumDamage, + HealthType damageType, + int range, + int rate, + boolean isNoDamage) { + this.name = name; + this.speed = speed; + this.accuracy = accuracy; + this.damage = damage; + this.minimumDamage = minimumDamage; + this.damageType = damageType; + this.range = range; + this.rate = rate; + this.isNoDamage = isNoDamage; + } + + @Override + public int getAccuracy() { + return accuracy; + } + + @Override + public int getDamage() { + return damage; + } + + @Override + public int getMinimumDamage() { + return minimumDamage; + } + + @Override + public HealthType getDamageType() { + return damageType; + } + + @Override + public Integer getDefence() { + return null; + } + + @Override + public int getMobilityPenalty() { + return 0; + } + + @Override + public Integer getRange() { + return range; + } + + @Override + public Integer getRate() { + return rate; + } + + @Override + public int getSpeed() { + return speed; + } + + @Override + public Identified[] getTags() { + return new Identified[0]; + } + + @Override + public ITraitType getTraitType() { + return AbilityType.MartialArts; + } + + @Override + public ITraitType getDamageTraitType() { + return null; + } + + @Override + public boolean inflictsNoDamage() { + return isNoDamage; + } + + @Override + public Identified getName() { + return name; + } + + @Override + public boolean isRangedCombat() { + return true; + } + + @Override + public IEquipmentStats[] getViews() { + return new IEquipmentStats[] { this }; + } + + @Override + public String getId() { + return getName().getId(); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_AdamantTagsTest.java b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_AdamantTagsTest.java index 4157192075..43aebbd157 100644 --- a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_AdamantTagsTest.java +++ b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_AdamantTagsTest.java @@ -1,56 +1,56 @@ -package net.sf.anathema.character.equipment.impl.character.model.stats; - -import net.sf.anathema.character.equipment.MagicalMaterial; -import net.sf.anathema.character.equipment.impl.character.model.ModifierFactory; -import net.sf.anathema.character.equipment.impl.character.model.stats.modification.ReactiveBaseMaterial; -import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; -import org.junit.Test; -import org.junit.matchers.JUnitMatchers; - -import java.util.Arrays; -import java.util.List; - -import static net.sf.anathema.character.equipment.MagicalMaterial.Adamant; -import static net.sf.anathema.character.equipment.MagicalMaterial.Orichalcum; -import static net.sf.anathema.character.equipment.impl.creation.model.WeaponTag.Piercing; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class ProxyWeaponStats_AdamantTagsTest { - IWeaponStats original = mock(IWeaponStats.class); - - @Test - public void addsPiercingToAAdamantWeapon() throws Exception { - setOriginalTags(); - List tags = getModifiedTags(Adamant); - assertThat(tags, JUnitMatchers.hasItem(Piercing)); - } - - @Test - public void doesNotAddPiercingToAnotherMaterial() throws Exception { - setOriginalTags(); - List tags = getModifiedTags(Orichalcum); - assertThat(tags.size(), is(0)); - } - - @Test - public void addsSpecialPiercingTagIfItIsAlreadyPiercing() throws Exception { - setOriginalTags(Piercing); - List tags = getModifiedTags(Adamant); - assertThat(tags, JUnitMatchers.hasItem(new Identificate("AdamantPiercing"))); - } - - private List getModifiedTags(MagicalMaterial material) { - ModifierFactory modifiers = new NullModifierFactory(); - ProxyWeaponStats stats = new ProxyWeaponStats(original, new ReactiveBaseMaterial(material), modifiers); - return Arrays.asList(stats.getTags()); - } - - private void setOriginalTags(IIdentificate... tags) { - when(original.getTags()).thenReturn(tags); - } +package net.sf.anathema.character.equipment.impl.character.model.stats; + +import net.sf.anathema.character.equipment.MagicalMaterial; +import net.sf.anathema.character.equipment.impl.character.model.ModifierFactory; +import net.sf.anathema.character.equipment.impl.character.model.stats.modification.ReactiveBaseMaterial; +import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; +import org.junit.Test; +import org.junit.matchers.JUnitMatchers; + +import java.util.Arrays; +import java.util.List; + +import static net.sf.anathema.character.equipment.MagicalMaterial.Adamant; +import static net.sf.anathema.character.equipment.MagicalMaterial.Orichalcum; +import static net.sf.anathema.character.equipment.impl.creation.model.WeaponTag.Piercing; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class ProxyWeaponStats_AdamantTagsTest { + IWeaponStats original = mock(IWeaponStats.class); + + @Test + public void addsPiercingToAAdamantWeapon() throws Exception { + setOriginalTags(); + List tags = getModifiedTags(Adamant); + assertThat(tags, JUnitMatchers.hasItem(Piercing)); + } + + @Test + public void doesNotAddPiercingToAnotherMaterial() throws Exception { + setOriginalTags(); + List tags = getModifiedTags(Orichalcum); + assertThat(tags.size(), is(0)); + } + + @Test + public void addsSpecialPiercingTagIfItIsAlreadyPiercing() throws Exception { + setOriginalTags(Piercing); + List tags = getModifiedTags(Adamant); + assertThat(tags, JUnitMatchers.hasItem(new Identificate("AdamantPiercing"))); + } + + private List getModifiedTags(MagicalMaterial material) { + ModifierFactory modifiers = new NullModifierFactory(); + ProxyWeaponStats stats = new ProxyWeaponStats(original, new ReactiveBaseMaterial(material), modifiers); + return Arrays.asList(stats.getTags()); + } + + private void setOriginalTags(Identified... tags) { + when(original.getTags()).thenReturn(tags); + } } \ No newline at end of file diff --git a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_EquipmentModifierTest.java b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_EquipmentModifierTest.java index cbb6fa1074..4cfc9e2d8d 100644 --- a/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_EquipmentModifierTest.java +++ b/Character_Equipment_Impl/test/net/sf/anathema/character/equipment/impl/character/model/stats/ProxyWeaponStats_EquipmentModifierTest.java @@ -1,111 +1,111 @@ -package net.sf.anathema.character.equipment.impl.character.model.stats; - -import net.sf.anathema.character.equipment.IWeaponModifiers; -import net.sf.anathema.character.equipment.impl.character.model.ModifierFactory; -import net.sf.anathema.character.equipment.impl.character.model.stats.modification.BaseMaterial; -import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; -import net.sf.anathema.lib.util.IIdentificate; -import org.junit.Before; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class ProxyWeaponStats_EquipmentModifierTest { - IWeaponStats original = mock(IWeaponStats.class); - IWeaponModifiers modifiers = mock(IWeaponModifiers.class); - ModifierFactory factory = mock(ModifierFactory.class); - BaseMaterial material = mock(BaseMaterial.class); - ProxyWeaponStats stats = new ProxyWeaponStats(original, material, factory); - - @Before - public void createModifiers() throws Exception { - when(factory.createModifiers()).thenReturn(modifiers); - } - - @Before - public void setUpWeapon() throws Exception { - when(original.getTags()).thenReturn(new IIdentificate[]{}); - when(original.getSpeed()).thenReturn(5); - } - - @Test - public void respectsSpeedFromEquipment() throws Exception { - when(modifiers.getMeleeSpeedMod()).thenReturn(-2); - int speed = stats.getSpeed(); - assertThat(speed, is(3)); - } - - @Test - public void usesBestSpeedFromEquipmentAndMaterial() throws Exception { - when(material.isJadeBased()).thenReturn(true); - int speed = stats.getSpeed(); - assertThat(speed, is(4)); - } - - @Test - public void respectsAccuracyFromEquipment() throws Exception { - when(modifiers.getMeleeAccuracyMod()).thenReturn(5); - int accuracy = stats.getAccuracy(); - assertThat(accuracy, is(5)); - } - - @Test - public void usesBestAccuracyFromEquipmentAndMaterial() throws Exception { - when(material.isOrichalcumBased()).thenReturn(true); - int accuracy = stats.getAccuracy(); - assertThat(accuracy, is(2)); - } - - @Test - public void respectsDamageFromEquipment() throws Exception { - when(modifiers.getMeleeDamageMod()).thenReturn(2); - int damage = stats.getDamage(); - assertThat(damage, is(2)); - } - - @Test - public void usesBestDamageFromEquipmentAndMaterial() throws Exception { - when(material.isStarmetalBased()).thenReturn(true); - int damage = stats.getDamage(); - assertThat(damage, is(3)); - } - - @Test - public void usesDefenceFromMaterial() throws Exception { - when(material.isMoonsilverBased()).thenReturn(true); - int defence = stats.getDefence(); - assertThat(defence, is(2)); - } - - @Test - public void respectsPDVPoolFromEquipment() throws Exception { - when(modifiers.getPDVPoolMod()).thenReturn(2); - int defence = stats.getDefence(); - assertThat(defence, is(2)); - } - - @Test - public void usesBestDefenceFromEquipmentAndMaterial() throws Exception { - when(material.isMoonsilverBased()).thenReturn(true); - when(modifiers.getPDVPoolMod()).thenReturn(3); - int defence = stats.getDefence(); - assertThat(defence, is(3)); - } - - @Test - public void respectsRateFromEquipment() throws Exception { - when(modifiers.getMeleeRateMod()).thenReturn(2); - int rate = stats.getRate(); - assertThat(rate, is(2)); - } - - @Test - public void usesBestRateFromEquipmentAndMaterial() throws Exception { - when(material.isOrichalcumBased()).thenReturn(true); - int rate = stats.getRate(); - assertThat(rate, is(1)); - } +package net.sf.anathema.character.equipment.impl.character.model.stats; + +import net.sf.anathema.character.equipment.IWeaponModifiers; +import net.sf.anathema.character.equipment.impl.character.model.ModifierFactory; +import net.sf.anathema.character.equipment.impl.character.model.stats.modification.BaseMaterial; +import net.sf.anathema.character.generic.equipment.weapon.IWeaponStats; +import net.sf.anathema.lib.util.Identified; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class ProxyWeaponStats_EquipmentModifierTest { + IWeaponStats original = mock(IWeaponStats.class); + IWeaponModifiers modifiers = mock(IWeaponModifiers.class); + ModifierFactory factory = mock(ModifierFactory.class); + BaseMaterial material = mock(BaseMaterial.class); + ProxyWeaponStats stats = new ProxyWeaponStats(original, material, factory); + + @Before + public void createModifiers() throws Exception { + when(factory.createModifiers()).thenReturn(modifiers); + } + + @Before + public void setUpWeapon() throws Exception { + when(original.getTags()).thenReturn(new Identified[]{}); + when(original.getSpeed()).thenReturn(5); + } + + @Test + public void respectsSpeedFromEquipment() throws Exception { + when(modifiers.getMeleeSpeedMod()).thenReturn(-2); + int speed = stats.getSpeed(); + assertThat(speed, is(3)); + } + + @Test + public void usesBestSpeedFromEquipmentAndMaterial() throws Exception { + when(material.isJadeBased()).thenReturn(true); + int speed = stats.getSpeed(); + assertThat(speed, is(4)); + } + + @Test + public void respectsAccuracyFromEquipment() throws Exception { + when(modifiers.getMeleeAccuracyMod()).thenReturn(5); + int accuracy = stats.getAccuracy(); + assertThat(accuracy, is(5)); + } + + @Test + public void usesBestAccuracyFromEquipmentAndMaterial() throws Exception { + when(material.isOrichalcumBased()).thenReturn(true); + int accuracy = stats.getAccuracy(); + assertThat(accuracy, is(2)); + } + + @Test + public void respectsDamageFromEquipment() throws Exception { + when(modifiers.getMeleeDamageMod()).thenReturn(2); + int damage = stats.getDamage(); + assertThat(damage, is(2)); + } + + @Test + public void usesBestDamageFromEquipmentAndMaterial() throws Exception { + when(material.isStarmetalBased()).thenReturn(true); + int damage = stats.getDamage(); + assertThat(damage, is(3)); + } + + @Test + public void usesDefenceFromMaterial() throws Exception { + when(material.isMoonsilverBased()).thenReturn(true); + int defence = stats.getDefence(); + assertThat(defence, is(2)); + } + + @Test + public void respectsPDVPoolFromEquipment() throws Exception { + when(modifiers.getPDVPoolMod()).thenReturn(2); + int defence = stats.getDefence(); + assertThat(defence, is(2)); + } + + @Test + public void usesBestDefenceFromEquipmentAndMaterial() throws Exception { + when(material.isMoonsilverBased()).thenReturn(true); + when(modifiers.getPDVPoolMod()).thenReturn(3); + int defence = stats.getDefence(); + assertThat(defence, is(3)); + } + + @Test + public void respectsRateFromEquipment() throws Exception { + when(modifiers.getMeleeRateMod()).thenReturn(2); + int rate = stats.getRate(); + assertThat(rate, is(2)); + } + + @Test + public void usesBestRateFromEquipmentAndMaterial() throws Exception { + when(material.isOrichalcumBased()).thenReturn(true); + int rate = stats.getRate(); + assertThat(rate, is(1)); + } } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/caste/ITypedDescriptionType.java b/Character_Generic/src/net/sf/anathema/character/generic/caste/ITypedDescriptionType.java index aa0ab22ab2..a11913f253 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/caste/ITypedDescriptionType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/caste/ITypedDescriptionType.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.caste; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ITypedDescriptionType extends IIdentificate { +public interface ITypedDescriptionType extends Identified { // Nothing to do } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IEquipmentStats.java b/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IEquipmentStats.java index 0bd15e7d7c..3aae4c1149 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IEquipmentStats.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IEquipmentStats.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.equipment.weapon; import net.sf.anathema.character.generic.util.IStats; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IEquipmentStats extends IStats, IIdentificate { +public interface IEquipmentStats extends IStats, Identified { boolean representsItemForUseInCombat(); } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IWeaponStats.java b/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IWeaponStats.java index a6b345c318..3679e8359e 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IWeaponStats.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/equipment/weapon/IWeaponStats.java @@ -2,7 +2,7 @@ import net.sf.anathema.character.generic.health.HealthType; import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IWeaponStats extends IEquipmentStats { @@ -14,7 +14,7 @@ public interface IWeaponStats extends IEquipmentStats { int getSpeed(); - IIdentificate[] getTags(); + Identified[] getTags(); ITraitType getTraitType(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/health/HealthLevelType.java b/Character_Generic/src/net/sf/anathema/character/generic/health/HealthLevelType.java index 40a8d8e0bf..1409b1b02e 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/health/HealthLevelType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/health/HealthLevelType.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.health; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum HealthLevelType implements IIdentificate { +public enum HealthLevelType implements Identified { ZERO("0", 0) { //$NON-NLS-1$ @Override diff --git a/Character_Generic/src/net/sf/anathema/character/generic/health/HealthType.java b/Character_Generic/src/net/sf/anathema/character/generic/health/HealthType.java index df1e588460..90a06535f0 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/health/HealthType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/health/HealthType.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.health; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum HealthType implements IIdentificate { +public enum HealthType implements Identified { Bashing { @Override public void accept(IHealthTypeVisitor visitor) { diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharm.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharm.java index 26c24796b5..c231edb893 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharm.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharm.java @@ -2,7 +2,7 @@ import net.sf.anathema.character.generic.character.IMagicCollection; import net.sf.anathema.character.generic.magic.charms.ICharmLearnArbitrator; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import java.util.Set; @@ -24,9 +24,9 @@ public interface ICharm extends ICharmData, IMagic { Set getRenderingPrerequisiteLabels(); - boolean hasAttribute(IIdentificate attribute); + boolean hasAttribute(Identified attribute); - String getAttributeValue(IIdentificate attribute); + String getAttributeValue(Identified attribute); boolean hasChildren(); } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharmData.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharmData.java index 430ef2e27c..632223351e 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharmData.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/ICharmData.java @@ -8,19 +8,19 @@ import net.sf.anathema.character.generic.traits.IGenericTrait; import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.List; import java.util.Set; public interface ICharmData extends IMagicData { - IIdentificate FORM_ATTRIBUTE = new Identificate("Form"); //$NON-NLS-1$ - IIdentificate MERGED_ATTRIBUTE = new Identificate("Merged"); //$NON-NLS-1$ - IIdentificate ALLOWS_CELESTIAL_ATTRIBUTE = new Identificate("AllowsCelestial"); //$NON-NLS-1$ - IIdentificate UNRESTRICTED_ATTRIBUTE = new Identificate("Unrestricted"); //$NON-NLS-1$ - IIdentificate NO_STYLE_ATTRIBUTE = new Identificate("NoStyle"); //$NON-NLS-1$ - IIdentificate NATIVE = new Identificate("Native"); //$NON-NLS-1$ + Identified FORM_ATTRIBUTE = new Identificate("Form"); //$NON-NLS-1$ + Identified MERGED_ATTRIBUTE = new Identificate("Merged"); //$NON-NLS-1$ + Identified ALLOWS_CELESTIAL_ATTRIBUTE = new Identificate("AllowsCelestial"); //$NON-NLS-1$ + Identified UNRESTRICTED_ATTRIBUTE = new Identificate("Unrestricted"); //$NON-NLS-1$ + Identified NO_STYLE_ATTRIBUTE = new Identificate("NoStyle"); //$NON-NLS-1$ + Identified NATIVE = new Identificate("Native"); //$NON-NLS-1$ String FAVORED_CASTE_PREFIX = "FavoredCaste."; //$NON-NLS-1$ ICharacterType getCharacterType(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/IExtendedCharmData.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/IExtendedCharmData.java index 4ccf69d8d8..c144ba51cd 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/IExtendedCharmData.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/IExtendedCharmData.java @@ -1,31 +1,31 @@ package net.sf.anathema.character.generic.magic; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public interface IExtendedCharmData extends ICharmData { - IIdentificate COMBO_BASIC_ATTRIBUTE = new Identificate("Combo-Basic"); //$NON-NLS-1$ - IIdentificate COMBO_OK_ATTRIBUTE = new Identificate("Combo-OK"); //$NON-NLS-1$ - IIdentificate COMPULSION_ATTRIBUTE = new Identificate("Compulsion"); //$NON-NLS-1$ - IIdentificate COUNTERATTACK_ATTRIBUTE = new Identificate("Counterattack"); //$NON-NLS-1$ - IIdentificate CRIPPLING_ATTRIBUTE = new Identificate("Crippling"); //$NON-NLS-1$ - IIdentificate EMOTION_ATTRIBUTE = new Identificate("Emotion"); //$NON-NLS-1$ + Identified COMBO_BASIC_ATTRIBUTE = new Identificate("Combo-Basic"); //$NON-NLS-1$ + Identified COMBO_OK_ATTRIBUTE = new Identificate("Combo-OK"); //$NON-NLS-1$ + Identified COMPULSION_ATTRIBUTE = new Identificate("Compulsion"); //$NON-NLS-1$ + Identified COUNTERATTACK_ATTRIBUTE = new Identificate("Counterattack"); //$NON-NLS-1$ + Identified CRIPPLING_ATTRIBUTE = new Identificate("Crippling"); //$NON-NLS-1$ + Identified EMOTION_ATTRIBUTE = new Identificate("Emotion"); //$NON-NLS-1$ - IIdentificate HOLY_ATTRIBUTE = new Identificate("Holy"); //$NON-NLS-1$ - IIdentificate ILLUSION_ATTRIBUTE = new Identificate("Illusion"); //$NON-NLS-1$ - IIdentificate KNOCKBACK_ATTRIBUTE = new Identificate("Knockback"); //$NON-NLS-1$ - IIdentificate MANDATE_ATTRIBUTE = new Identificate("Mandate"); //$NON-NLS-1$ - IIdentificate OBVIOUS_ATTRIBUTE = new Identificate("Obvious"); //$NON-NLS-1$ - IIdentificate OVERDRIVE_ATTRIBUTE = new Identificate("Overdrive"); //$NON-NLS-1$ - IIdentificate POISON_ATTRIBUTE = new Identificate("Poison"); //$NON-NLS-1$ - IIdentificate SERVITUDE_ATTRIBUTE = new Identificate("Servitude"); //$NON-NLS-1$ - IIdentificate SHAPING_ATTRIBUTE = new Identificate("Shaping"); //$NON-NLS-1$ - IIdentificate SICKNESS_ATTRIBUTE = new Identificate("Sickness"); //$NON-NLS-1$ - IIdentificate SOCIAL_ATTRIBUTE = new Identificate("Social"); //$NON-NLS-1$ - IIdentificate STACKABLE_ATTRIBUTE = new Identificate("Stackable"); //$NON-NLS-1$ - IIdentificate TOUCH_ATTRIBUTE = new Identificate("Touch"); //$NON-NLS-1$ - IIdentificate TRAINING_ATTRIBUTE = new Identificate("Training"); //$NON-NLS-1$ - IIdentificate WAR_ATTRIBUTE = new Identificate("War"); //$NON-NLS-1$ + Identified HOLY_ATTRIBUTE = new Identificate("Holy"); //$NON-NLS-1$ + Identified ILLUSION_ATTRIBUTE = new Identificate("Illusion"); //$NON-NLS-1$ + Identified KNOCKBACK_ATTRIBUTE = new Identificate("Knockback"); //$NON-NLS-1$ + Identified MANDATE_ATTRIBUTE = new Identificate("Mandate"); //$NON-NLS-1$ + Identified OBVIOUS_ATTRIBUTE = new Identificate("Obvious"); //$NON-NLS-1$ + Identified OVERDRIVE_ATTRIBUTE = new Identificate("Overdrive"); //$NON-NLS-1$ + Identified POISON_ATTRIBUTE = new Identificate("Poison"); //$NON-NLS-1$ + Identified SERVITUDE_ATTRIBUTE = new Identificate("Servitude"); //$NON-NLS-1$ + Identified SHAPING_ATTRIBUTE = new Identificate("Shaping"); //$NON-NLS-1$ + Identified SICKNESS_ATTRIBUTE = new Identificate("Sickness"); //$NON-NLS-1$ + Identified SOCIAL_ATTRIBUTE = new Identificate("Social"); //$NON-NLS-1$ + Identified STACKABLE_ATTRIBUTE = new Identificate("Stackable"); //$NON-NLS-1$ + Identified TOUCH_ATTRIBUTE = new Identificate("Touch"); //$NON-NLS-1$ + Identified TRAINING_ATTRIBUTE = new Identificate("Training"); //$NON-NLS-1$ + Identified WAR_ATTRIBUTE = new Identificate("War"); //$NON-NLS-1$ - IIdentificate EXCLUSIVE_ATTRIBUTE = new Identificate("Exclusive"); //$NON-NLS-1$ + Identified EXCLUSIVE_ATTRIBUTE = new Identificate("Exclusive"); //$NON-NLS-1$ } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicData.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicData.java index d33351a80f..06bae44597 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicData.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicData.java @@ -2,9 +2,9 @@ import net.sf.anathema.character.generic.magic.general.ICostList; import net.sf.anathema.character.generic.rules.IExaltedSourceBook; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IMagicData extends IIdentificate { +public interface IMagicData extends Identified { IExaltedSourceBook[] getSources(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicStats.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicStats.java index c76851d382..ce97a9b74d 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicStats.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/IMagicStats.java @@ -2,12 +2,12 @@ import net.sf.anathema.character.generic.util.IStats; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IMagicStats extends IStats, Comparable { @Override - IIdentificate getName(); + Identified getName(); String getCostString(IResources resources); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttribute.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttribute.java index 32a6e54d8e..dbe0ead5b7 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttribute.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttribute.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.magic.charms; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ICharmAttribute extends IIdentificate { +public interface ICharmAttribute extends Identified { boolean isVisualized(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttributeRequirement.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttributeRequirement.java index 684e663124..4475fabfa5 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttributeRequirement.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmAttributeRequirement.java @@ -1,7 +1,7 @@ package net.sf.anathema.character.generic.magic.charms; import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ICharmAttributeRequirement { @@ -9,7 +9,7 @@ public interface ICharmAttributeRequirement { boolean isFulfilled(ICharm[] charms); - IIdentificate getAttribute(); + Identified getAttribute(); int getCount(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmGroup.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmGroup.java index e254480b90..f31fdde097 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmGroup.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/ICharmGroup.java @@ -2,9 +2,9 @@ import net.sf.anathema.character.generic.magic.ICharm; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ICharmGroup extends IIdentificate { +public interface ICharmGroup extends Identified { ICharm[] getAllCharms(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/MartialArtsLevel.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/MartialArtsLevel.java index 315a8a8c93..28c9b3364e 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/MartialArtsLevel.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/MartialArtsLevel.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.magic.charms; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum MartialArtsLevel implements IIdentificate { +public enum MartialArtsLevel implements Identified { Mortal, Terrestrial, Celestial, Sidereal; @Override diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/special/ISubeffect.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/special/ISubeffect.java index ada8de0da6..94d9f3f8ca 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/special/ISubeffect.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/special/ISubeffect.java @@ -1,9 +1,9 @@ package net.sf.anathema.character.generic.magic.charms.special; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ISubeffect extends IIdentificate { +public interface ISubeffect extends Identified { boolean isLearned(); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/CharmType.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/CharmType.java index 4642719d33..bcc45f149d 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/CharmType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/CharmType.java @@ -1,9 +1,9 @@ package net.sf.anathema.character.generic.magic.charms.type; import net.sf.anathema.character.generic.magic.charms.ICharmTypeVisitor; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum CharmType implements IIdentificate { +public enum CharmType implements Identified { Simple() { @Override public void accept(ICharmTypeVisitor visitor) { diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/TurnType.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/TurnType.java index 5c1e8c83d7..91fe9232e5 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/TurnType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/charms/type/TurnType.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.magic.charms.type; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum TurnType implements IIdentificate { +public enum TurnType implements Identified { Tick, LongTick, DramaticAction; diff --git a/Character_Generic/src/net/sf/anathema/character/generic/magic/spells/CircleType.java b/Character_Generic/src/net/sf/anathema/character/generic/magic/spells/CircleType.java index 73560eb40f..e4f213b6ec 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/magic/spells/CircleType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/magic/spells/CircleType.java @@ -1,12 +1,12 @@ package net.sf.anathema.character.generic.magic.spells; +import net.sf.anathema.lib.util.Identified; + import java.util.ArrayList; import java.util.List; -import net.sf.anathema.lib.util.IIdentificate; - //TODO: Find a way to operate with circletypes without breaking compareTo -public enum CircleType implements IIdentificate { +public enum CircleType implements Identified { Terrestrial { @Override diff --git a/Character_Generic/src/net/sf/anathema/character/generic/rules/IExaltedSourceBook.java b/Character_Generic/src/net/sf/anathema/character/generic/rules/IExaltedSourceBook.java index f0e411676b..8e6e074063 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/rules/IExaltedSourceBook.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/rules/IExaltedSourceBook.java @@ -1,7 +1,7 @@ package net.sf.anathema.character.generic.rules; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IExaltedSourceBook extends IIdentificate { +public interface IExaltedSourceBook extends Identified { //nothing to do } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/ITemplateType.java b/Character_Generic/src/net/sf/anathema/character/generic/template/ITemplateType.java index aa15bf0c53..1a933149a2 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/ITemplateType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/ITemplateType.java @@ -1,11 +1,11 @@ package net.sf.anathema.character.generic.template; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ITemplateType { ICharacterType getCharacterType(); - IIdentificate getSubType(); + Identified getSubType(); } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/TemplateType.java b/Character_Generic/src/net/sf/anathema/character/generic/template/TemplateType.java index ac9607f20a..4325633e0b 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/TemplateType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/TemplateType.java @@ -1,21 +1,21 @@ package net.sf.anathema.character.generic.template; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public final class TemplateType implements ITemplateType { - public static final IIdentificate DEFAULT_SUB_TYPE = new Identificate("TemplateType.Default"); //$NON-NLS-1$ + public static final Identified DEFAULT_SUB_TYPE = new Identificate("TemplateType.Default"); //$NON-NLS-1$ private final ICharacterType characterType; - private final IIdentificate subType; + private final Identified subType; public TemplateType(ICharacterType characterType) { this(characterType, DEFAULT_SUB_TYPE); } - public TemplateType(ICharacterType characterType, IIdentificate subType) { + public TemplateType(ICharacterType characterType, Identified subType) { this.characterType = characterType; this.subType = subType; } @@ -26,7 +26,7 @@ public ICharacterType getCharacterType() { } @Override - public IIdentificate getSubType() { + public Identified getSubType() { return subType; } diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/AbilityGroupType.java b/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/AbilityGroupType.java index c2b5f40cbd..d380f092f0 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/AbilityGroupType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/AbilityGroupType.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.template.abilities; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum AbilityGroupType implements IIdentificate { +public enum AbilityGroupType implements Identified { Life { @Override diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/GroupedTraitType.java b/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/GroupedTraitType.java index 397ac6d599..3b519e7dc9 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/GroupedTraitType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/abilities/GroupedTraitType.java @@ -1,9 +1,9 @@ package net.sf.anathema.character.generic.template.abilities; -import java.util.List; - import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.List; public class GroupedTraitType implements IGroupedTraitType { @@ -12,7 +12,7 @@ public class GroupedTraitType implements IGroupedTraitType { private final String groupCasteId; private List traitCasteIds; - public GroupedTraitType(ITraitType type, IIdentificate identificate, String casteId) { + public GroupedTraitType(ITraitType type, Identified identificate, String casteId) { this(type, identificate.getId(), casteId); } diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/additional/IAdditionalTemplate.java b/Character_Generic/src/net/sf/anathema/character/generic/template/additional/IAdditionalTemplate.java index 3a5d57be77..44271dde29 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/additional/IAdditionalTemplate.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/additional/IAdditionalTemplate.java @@ -1,7 +1,7 @@ package net.sf.anathema.character.generic.template.additional; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IAdditionalTemplate extends IIdentificate { +public interface IAdditionalTemplate extends Identified { // nothing to do } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/magic/FavoringTraitType.java b/Character_Generic/src/net/sf/anathema/character/generic/template/magic/FavoringTraitType.java index bc0c643450..3e93234933 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/magic/FavoringTraitType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/magic/FavoringTraitType.java @@ -5,9 +5,9 @@ import net.sf.anathema.character.generic.traits.types.AttributeType; import net.sf.anathema.character.generic.traits.types.VirtueType; import net.sf.anathema.character.generic.traits.types.YoziType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum FavoringTraitType implements IIdentificate { +public enum FavoringTraitType implements Identified { AbilityType() { @Override public void accept(IFavoringTraitTypeVisitor visitor) { diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/magic/IUniqueCharmType.java b/Character_Generic/src/net/sf/anathema/character/generic/template/magic/IUniqueCharmType.java index 6478b35fb8..2a48eaa2e9 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/magic/IUniqueCharmType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/magic/IUniqueCharmType.java @@ -1,11 +1,11 @@ -package net.sf.anathema.character.generic.template.magic; - -import net.sf.anathema.lib.util.IIdentificate; - -public interface IUniqueCharmType { - IIdentificate getId(); - - String getLabel(); - - boolean keywordMatches(String id); +package net.sf.anathema.character.generic.template.magic; + +import net.sf.anathema.lib.util.Identified; + +public interface IUniqueCharmType { + Identified getId(); + + String getLabel(); + + boolean keywordMatches(String id); } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/template/points/AttributeGroupPriority.java b/Character_Generic/src/net/sf/anathema/character/generic/template/points/AttributeGroupPriority.java index e40e2a8362..8214cd0ed4 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/template/points/AttributeGroupPriority.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/template/points/AttributeGroupPriority.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.template.points; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum AttributeGroupPriority implements IIdentificate { +public enum AttributeGroupPriority implements Identified { Primary { @Override diff --git a/Character_Generic/src/net/sf/anathema/character/generic/traits/ITraitType.java b/Character_Generic/src/net/sf/anathema/character/generic/traits/ITraitType.java index e42c2b5041..e4dca70b67 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/traits/ITraitType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/traits/ITraitType.java @@ -1,9 +1,9 @@ package net.sf.anathema.character.generic.traits; import net.sf.anathema.character.generic.traits.types.ITraitTypeVisitor; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ITraitType extends IIdentificate { +public interface ITraitType extends Identified { void accept(ITraitTypeVisitor visitor); } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IIdentifiedTraitTypeGroup.java b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IIdentifiedTraitTypeGroup.java index 293625c105..a80ce3fe2b 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IIdentifiedTraitTypeGroup.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IIdentifiedTraitTypeGroup.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.traits.groups; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IIdentifiedTraitTypeGroup extends ITraitTypeGroup { - IIdentificate getGroupId(); + Identified getGroupId(); } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedCasteTraitTypeGroup.java b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedCasteTraitTypeGroup.java index 9faa8100d0..6f2dcabcfa 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedCasteTraitTypeGroup.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedCasteTraitTypeGroup.java @@ -2,14 +2,14 @@ import net.sf.anathema.character.generic.caste.ICasteType; import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class IdentifiedCasteTraitTypeGroup extends IdentifiedTraitTypeGroup implements IIdentifiedCasteTraitTypeGroup { private final ICasteType groupCasteType; private final ICasteType[][] traitCasteTypes; - public IdentifiedCasteTraitTypeGroup(ITraitType[] traitTypes, IIdentificate groupId, ICasteType groupCasteTypes, ICasteType[][] traitCasteTypes) { + public IdentifiedCasteTraitTypeGroup(ITraitType[] traitTypes, Identified groupId, ICasteType groupCasteTypes, ICasteType[][] traitCasteTypes) { super(traitTypes, groupId); this.groupCasteType = groupCasteTypes; this.traitCasteTypes = traitCasteTypes; diff --git a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedTraitTypeGroup.java b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedTraitTypeGroup.java index 939921f591..35ccbf878a 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedTraitTypeGroup.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedTraitTypeGroup.java @@ -1,19 +1,19 @@ package net.sf.anathema.character.generic.traits.groups; import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class IdentifiedTraitTypeGroup extends TraitTypeGroup implements IIdentifiedTraitTypeGroup { - private final IIdentificate groupId; + private final Identified groupId; - public IdentifiedTraitTypeGroup(ITraitType[] traitTypes, IIdentificate groupId) { + public IdentifiedTraitTypeGroup(ITraitType[] traitTypes, Identified groupId) { super(traitTypes); this.groupId = groupId; } @Override - public IIdentificate getGroupId() { + public Identified getGroupId() { return groupId; } } \ No newline at end of file diff --git a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedYoziTypeGroup.java b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedYoziTypeGroup.java index 0f224e3edf..13280a25ba 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedYoziTypeGroup.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/traits/groups/IdentifiedYoziTypeGroup.java @@ -3,7 +3,7 @@ import net.sf.anathema.character.generic.caste.ICasteType; import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.YoziType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class IdentifiedYoziTypeGroup extends TraitTypeGroup implements IIdentifiedCasteTraitTypeGroup { @@ -28,7 +28,7 @@ public ICasteType[] getTraitCasteTypes(ITraitType type) { } @Override - public IIdentificate getGroupId() { + public Identified getGroupId() { return type; } } diff --git a/Character_Generic/src/net/sf/anathema/character/generic/traits/types/AttributeGroupType.java b/Character_Generic/src/net/sf/anathema/character/generic/traits/types/AttributeGroupType.java index a538923133..b596df8ad1 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/traits/types/AttributeGroupType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/traits/types/AttributeGroupType.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.traits.types; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum AttributeGroupType implements IIdentificate { +public enum AttributeGroupType implements Identified { Physical, Social, Mental; diff --git a/Character_Generic/src/net/sf/anathema/character/generic/type/ICharacterType.java b/Character_Generic/src/net/sf/anathema/character/generic/type/ICharacterType.java index 24d4a8c4bf..53ba8d9e1c 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/type/ICharacterType.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/type/ICharacterType.java @@ -1,9 +1,9 @@ package net.sf.anathema.character.generic.type; import net.sf.anathema.character.generic.template.magic.FavoringTraitType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ICharacterType extends IIdentificate, Comparable { +public interface ICharacterType extends Identified, Comparable { void accept(ICharacterTypeVisitor visitor); diff --git a/Character_Generic/src/net/sf/anathema/character/generic/util/IStats.java b/Character_Generic/src/net/sf/anathema/character/generic/util/IStats.java index 4005aa5965..17eed74d0b 100644 --- a/Character_Generic/src/net/sf/anathema/character/generic/util/IStats.java +++ b/Character_Generic/src/net/sf/anathema/character/generic/util/IStats.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.generic.util; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IStats { - IIdentificate getName(); + Identified getName(); } \ No newline at end of file diff --git a/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/IMagicLearnView.java b/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/IMagicLearnView.java index 5a4cd8e49d..d5f0439081 100644 --- a/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/IMagicLearnView.java +++ b/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/IMagicLearnView.java @@ -1,21 +1,21 @@ package net.sf.anathema.character.generic.framework.magic.view; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.event.ListSelectionListener; import java.util.Comparator; public interface IMagicLearnView { - void setMagicOptions(Object[] magics); + void addMagicOptions(Identified[] magics, Comparator comparator); - void setLearnedMagic(Object[] magics); + void setMagicOptions(Object[] magics); - void addMagicOptions(IIdentificate[] magics, Comparator comparator); + void removeMagicOptions(Object[] magics); void addLearnedMagic(Object[] magics); - void removeMagicOptions(Object[] magics); + void setLearnedMagic(Object[] magics); void removeLearnedMagic(Object[] magics); diff --git a/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/MagicLearnView.java b/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/MagicLearnView.java index bc8d0f2c86..3ce4363924 100644 --- a/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/MagicLearnView.java +++ b/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/magic/view/MagicLearnView.java @@ -4,7 +4,7 @@ import net.disy.commons.swing.layout.grid.GridDialogLayoutData; import net.sf.anathema.lib.gui.action.SmartAction; import net.sf.anathema.lib.gui.list.ComponentEnablingListSelectionListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import org.jmock.example.announcer.Announcer; import javax.swing.Action; @@ -177,15 +177,15 @@ public void addLearnedMagic(Object[] magics) { } @Override - public void addMagicOptions(IIdentificate[] magics, Comparator comparator) { + public void addMagicOptions(Identified[] magics, Comparator comparator) { DefaultListModel listModel = (DefaultListModel) learnOptionsList.getModel(); - for (IIdentificate spell : magics) { + for (Identified spell : magics) { boolean isInserted = false; for (int index = 0; index < listModel.getSize(); index++) { if (isInserted) { break; } - IIdentificate magicOption = (IIdentificate) listModel.get(index); + Identified magicOption = (Identified) listModel.get(index); if (comparator.compare(spell, magicOption) < 0) { listModel.add(index, spell); isInserted = true; diff --git a/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/xml/TemplateTypeParser.java b/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/xml/TemplateTypeParser.java index 369ca98002..17f76595bf 100644 --- a/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/xml/TemplateTypeParser.java +++ b/Character_Generic_Framework/src/net/sf/anathema/character/generic/framework/xml/TemplateTypeParser.java @@ -5,10 +5,9 @@ import net.sf.anathema.character.generic.type.CharacterType; import net.sf.anathema.character.generic.type.ICharacterType; import net.sf.anathema.lib.exception.PersistenceException; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.xml.ElementUtilities; - import org.dom4j.Element; public class TemplateTypeParser { @@ -17,11 +16,11 @@ public ITemplateType parse(Element element) throws PersistenceException { String characterTypeId = ElementUtilities.getRequiredAttrib(element, "characterType"); //$NON-NLS-1$ ICharacterType characterType = CharacterType.getById(characterTypeId); String subtemplate = element.attributeValue("subtemplate"); //$NON-NLS-1$ - IIdentificate subtemplateIdentificate = createSubtemplateIdentificate(subtemplate); + Identified subtemplateIdentificate = createSubtemplateIdentificate(subtemplate); return new TemplateType(characterType, subtemplateIdentificate); } - private IIdentificate createSubtemplateIdentificate(String subtemplate) { + private Identified createSubtemplateIdentificate(String subtemplate) { if (subtemplate == null || subtemplate.equals("default")) { //$NON-NLS-1$ return TemplateType.DEFAULT_SUB_TYPE; } diff --git a/Character_Generic_Framework/test/net/sf/anathema/character/generic/framework/xml/MagicTemplateParserTest.java b/Character_Generic_Framework/test/net/sf/anathema/character/generic/framework/xml/MagicTemplateParserTest.java index 5d80c195d0..de7e8bd121 100644 --- a/Character_Generic_Framework/test/net/sf/anathema/character/generic/framework/xml/MagicTemplateParserTest.java +++ b/Character_Generic_Framework/test/net/sf/anathema/character/generic/framework/xml/MagicTemplateParserTest.java @@ -1,201 +1,201 @@ -package net.sf.anathema.character.generic.framework.xml; - -import net.sf.anathema.character.generic.dummy.DummyCasteType; -import net.sf.anathema.character.generic.dummy.magic.DummyMartialArtsRules; -import net.sf.anathema.character.generic.dummy.template.DummyXmlTemplateRegistry; -import net.sf.anathema.character.generic.framework.xml.magic.GenericMagicTemplate; -import net.sf.anathema.character.generic.framework.xml.magic.GenericMagicTemplateParser; -import net.sf.anathema.character.generic.impl.template.magic.DefaultMartialArtsRules; -import net.sf.anathema.character.generic.magic.charms.MartialArtsLevel; -import net.sf.anathema.character.generic.magic.spells.CircleType; -import net.sf.anathema.character.generic.template.magic.FavoringTraitType; -import net.sf.anathema.character.generic.template.magic.ICharmTemplate; -import net.sf.anathema.dummy.character.magic.DummyCharm; -import net.sf.anathema.dummy.character.magic.DummyCharmUtilities; -import net.sf.anathema.lib.collection.ArrayUtilities; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.xml.DocumentUtilities; -import org.dom4j.Element; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class MagicTemplateParserTest { - - String xml = "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - private GenericMagicTemplateParser parser; - - @Before - public void setUp() throws Exception { - DummyXmlTemplateRegistry templateRegistry = new DummyXmlTemplateRegistry(); - parser = new GenericMagicTemplateParser(templateRegistry, null, null); - } - - @Test - public void testDefaultFreePicksPredicate() throws Exception { - Element templateElement = DocumentUtilities.read(xml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertTrue(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("TestCharm", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Test - public void testFalseFreePicksPredicate() throws Exception { - String customXml = "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(customXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertFalse(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("TestCharm", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Test - public void testIdExceptionInFreePicksPredicate() throws Exception { - String customXml = "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(customXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertFalse(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("BadId", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("ExpectedId", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Test - public void testGroupExceptionInFreePicksPredicate() throws Exception { - String customXml = "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(customXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertFalse(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("ExpectedId", "UnexpectedGroup"))); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("ExpectedId", "ExpectedGroup"))); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Test - public void testMortalCharmTemplate() throws Exception { - Element templateElement = DocumentUtilities.read(xml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - ICharmTemplate charmTemplate = template.getCharmTemplate(); - assertEquals(MartialArtsLevel.Mortal, charmTemplate.getMartialArtsRules().getStandardLevel()); - assertFalse(charmTemplate.canLearnCharms()); - } - - @Test - public void testMortalSpellTemplate() throws Exception { - Element templateElement = DocumentUtilities.read(xml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertFalse(template.getSpellMagic().canLearnSpellMagic()); - } - - @Test - public void testParsesMaximumNecromancyCircle() throws Exception { - String celestialXml = "" + //$NON-NLS-1$ - "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertTrue(ArrayUtilities.containsValue(template.getSpellMagic().getNecromancyCircles(), CircleType.Shadowlands)); - assertTrue(ArrayUtilities.containsValue(template.getSpellMagic().getNecromancyCircles(), CircleType.Labyrinth)); - assertFalse(ArrayUtilities.containsValue(template.getSpellMagic().getNecromancyCircles(), CircleType.Void)); - } - - @Test - public void testHighLevelSettingUnmodified() throws Exception { - String celestialXml = "" + //$NON-NLS-1$ - "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - DummyCharm dummyMartialArtsCharm = new DummyCharm("Dummy") { //$NON-NLS-1$ - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("MartialArts") || attribute.getId().equals("Celestial"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }; - assertFalse(template.getCharmTemplate().getMartialArtsRules().isCharmAllowed(dummyMartialArtsCharm, null, false)); - } - - @Test - public void testHighLevelSettingModified() throws Exception { - String celestialXml = "" + //$NON-NLS-1$ - "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - DummyCharm dummyMartialArtsCharm = new DummyCharm("Dummy") { //$NON-NLS-1$ - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("MartialArts") || attribute.getId().equals("Celestial"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }; - assertTrue(template.getCharmTemplate().getMartialArtsRules().isCharmAllowed(dummyMartialArtsCharm, null, false)); - } - - @Test - public void testDefaultRulesSetting() throws Exception { - String celestialXml = "" + //$NON-NLS-1$ - "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - Assert.assertTrue(template.getCharmTemplate().getMartialArtsRules() instanceof DefaultMartialArtsRules); - } - - @Test - public void picksUpMartialArtsRules() throws Exception { - String celestialXml = "" + //$NON-NLS-1$ - "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - Assert.assertTrue(template.getCharmTemplate().getMartialArtsRules() instanceof DummyMartialArtsRules); - } - - @Test - public void testFavoringTraitTypeUnmodified() throws Exception { - Element templateElement = DocumentUtilities.read(xml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertEquals(FavoringTraitType.AbilityType, template.getFavoringTraitType()); - } - - @Test - public void testFavoringTraitTypeModified() throws Exception { - String typeXml = "" //$NON-NLS-1$ - + ""//$NON-NLS-1$ - + "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(typeXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertEquals(FavoringTraitType.AttributeType, template.getFavoringTraitType()); - } - - @Test - public void testAlienCharmsAllowed() throws Exception { - String typeXml = "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + " " //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + "" //$NON-NLS-1$ - + ""; //$NON-NLS-1$ - Element templateElement = DocumentUtilities.read(typeXml).getRootElement(); - GenericMagicTemplate template = parser.parseTemplate(templateElement); - assertTrue(template.getCharmTemplate().isAllowedAlienCharms(new DummyCasteType("DummyCaste"))); //$NON-NLS-1$ - } +package net.sf.anathema.character.generic.framework.xml; + +import net.sf.anathema.character.generic.dummy.DummyCasteType; +import net.sf.anathema.character.generic.dummy.magic.DummyMartialArtsRules; +import net.sf.anathema.character.generic.dummy.template.DummyXmlTemplateRegistry; +import net.sf.anathema.character.generic.framework.xml.magic.GenericMagicTemplate; +import net.sf.anathema.character.generic.framework.xml.magic.GenericMagicTemplateParser; +import net.sf.anathema.character.generic.impl.template.magic.DefaultMartialArtsRules; +import net.sf.anathema.character.generic.magic.charms.MartialArtsLevel; +import net.sf.anathema.character.generic.magic.spells.CircleType; +import net.sf.anathema.character.generic.template.magic.FavoringTraitType; +import net.sf.anathema.character.generic.template.magic.ICharmTemplate; +import net.sf.anathema.dummy.character.magic.DummyCharm; +import net.sf.anathema.dummy.character.magic.DummyCharmUtilities; +import net.sf.anathema.lib.collection.ArrayUtilities; +import net.sf.anathema.lib.util.Identified; +import net.sf.anathema.lib.xml.DocumentUtilities; +import org.dom4j.Element; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class MagicTemplateParserTest { + + String xml = "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + private GenericMagicTemplateParser parser; + + @Before + public void setUp() throws Exception { + DummyXmlTemplateRegistry templateRegistry = new DummyXmlTemplateRegistry(); + parser = new GenericMagicTemplateParser(templateRegistry, null, null); + } + + @Test + public void testDefaultFreePicksPredicate() throws Exception { + Element templateElement = DocumentUtilities.read(xml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertTrue(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("TestCharm", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Test + public void testFalseFreePicksPredicate() throws Exception { + String customXml = "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(customXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertFalse(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("TestCharm", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Test + public void testIdExceptionInFreePicksPredicate() throws Exception { + String customXml = "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(customXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertFalse(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("BadId", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("ExpectedId", "Group"))); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Test + public void testGroupExceptionInFreePicksPredicate() throws Exception { + String customXml = "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(customXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertFalse(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("ExpectedId", "UnexpectedGroup"))); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue(template.canBuyFromFreePicks(DummyCharmUtilities.createCharm("ExpectedId", "ExpectedGroup"))); //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Test + public void testMortalCharmTemplate() throws Exception { + Element templateElement = DocumentUtilities.read(xml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + ICharmTemplate charmTemplate = template.getCharmTemplate(); + assertEquals(MartialArtsLevel.Mortal, charmTemplate.getMartialArtsRules().getStandardLevel()); + assertFalse(charmTemplate.canLearnCharms()); + } + + @Test + public void testMortalSpellTemplate() throws Exception { + Element templateElement = DocumentUtilities.read(xml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertFalse(template.getSpellMagic().canLearnSpellMagic()); + } + + @Test + public void testParsesMaximumNecromancyCircle() throws Exception { + String celestialXml = "" + //$NON-NLS-1$ + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertTrue(ArrayUtilities.containsValue(template.getSpellMagic().getNecromancyCircles(), CircleType.Shadowlands)); + assertTrue(ArrayUtilities.containsValue(template.getSpellMagic().getNecromancyCircles(), CircleType.Labyrinth)); + assertFalse(ArrayUtilities.containsValue(template.getSpellMagic().getNecromancyCircles(), CircleType.Void)); + } + + @Test + public void testHighLevelSettingUnmodified() throws Exception { + String celestialXml = "" + //$NON-NLS-1$ + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + DummyCharm dummyMartialArtsCharm = new DummyCharm("Dummy") { //$NON-NLS-1$ + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("MartialArts") || attribute.getId().equals("Celestial"); //$NON-NLS-1$ //$NON-NLS-2$ + } + }; + assertFalse(template.getCharmTemplate().getMartialArtsRules().isCharmAllowed(dummyMartialArtsCharm, null, false)); + } + + @Test + public void testHighLevelSettingModified() throws Exception { + String celestialXml = "" + //$NON-NLS-1$ + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + DummyCharm dummyMartialArtsCharm = new DummyCharm("Dummy") { //$NON-NLS-1$ + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("MartialArts") || attribute.getId().equals("Celestial"); //$NON-NLS-1$ //$NON-NLS-2$ + } + }; + assertTrue(template.getCharmTemplate().getMartialArtsRules().isCharmAllowed(dummyMartialArtsCharm, null, false)); + } + + @Test + public void testDefaultRulesSetting() throws Exception { + String celestialXml = "" + //$NON-NLS-1$ + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + Assert.assertTrue(template.getCharmTemplate().getMartialArtsRules() instanceof DefaultMartialArtsRules); + } + + @Test + public void picksUpMartialArtsRules() throws Exception { + String celestialXml = "" + //$NON-NLS-1$ + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(celestialXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + Assert.assertTrue(template.getCharmTemplate().getMartialArtsRules() instanceof DummyMartialArtsRules); + } + + @Test + public void testFavoringTraitTypeUnmodified() throws Exception { + Element templateElement = DocumentUtilities.read(xml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertEquals(FavoringTraitType.AbilityType, template.getFavoringTraitType()); + } + + @Test + public void testFavoringTraitTypeModified() throws Exception { + String typeXml = "" //$NON-NLS-1$ + + ""//$NON-NLS-1$ + + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(typeXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertEquals(FavoringTraitType.AttributeType, template.getFavoringTraitType()); + } + + @Test + public void testAlienCharmsAllowed() throws Exception { + String typeXml = "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + " " //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + "" //$NON-NLS-1$ + + ""; //$NON-NLS-1$ + Element templateElement = DocumentUtilities.read(typeXml).getRootElement(); + GenericMagicTemplate template = parser.parseTemplate(templateElement); + assertTrue(template.getCharmTemplate().isAllowedAlienCharms(new DummyCasteType("DummyCaste"))); //$NON-NLS-1$ + } } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/additional/ComplexAdditionalEssencePool.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/additional/ComplexAdditionalEssencePool.java index 18cd2a947f..aa15a16559 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/additional/ComplexAdditionalEssencePool.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/additional/ComplexAdditionalEssencePool.java @@ -1,19 +1,18 @@ package net.sf.anathema.character.generic.impl.additional; -import java.util.HashMap; -import java.util.Map; - -import net.sf.anathema.character.generic.character.IGenericTraitCollection; -import net.sf.anathema.character.generic.impl.util.AnathemaExpressionParameter; -import net.sf.anathema.character.generic.impl.util.AnathemaExpressionSyntax; -import net.sf.anathema.lib.util.IIdentificate; - import com.eteks.parser.CompilationException; import com.eteks.parser.CompiledExpression; import com.eteks.parser.ExpressionParser; import com.eteks.parser.IntegerInterpreter; +import net.sf.anathema.character.generic.character.IGenericTraitCollection; +import net.sf.anathema.character.generic.impl.util.AnathemaExpressionParameter; +import net.sf.anathema.character.generic.impl.util.AnathemaExpressionSyntax; +import net.sf.anathema.lib.util.Identified; + +import java.util.HashMap; +import java.util.Map; -public class ComplexAdditionalEssencePool implements IIdentificate { +public class ComplexAdditionalEssencePool implements Identified { private final String id; private final CompiledExpression expression; diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/Charm.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/Charm.java index e0e1e4452b..78aab1d4af 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/Charm.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/Charm.java @@ -1,424 +1,424 @@ -package net.sf.anathema.character.generic.impl.magic; - -import com.google.common.base.Preconditions; -import net.sf.anathema.character.generic.IBasicCharacterData; -import net.sf.anathema.character.generic.character.IGenericTraitCollection; -import net.sf.anathema.character.generic.character.IMagicCollection; -import net.sf.anathema.character.generic.impl.magic.charm.prerequisite.CompositeLearnWorker; -import net.sf.anathema.character.generic.impl.magic.charm.prerequisite.ICharmLearnWorker; -import net.sf.anathema.character.generic.impl.magic.charm.prerequisite.SelectiveCharmGroup; -import net.sf.anathema.character.generic.impl.magic.persistence.prerequisite.CharmPrerequisiteList; -import net.sf.anathema.character.generic.impl.magic.persistence.prerequisite.SelectiveCharmGroupTemplate; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.ICharmData; -import net.sf.anathema.character.generic.magic.IMagicVisitor; -import net.sf.anathema.character.generic.magic.charms.ComboRestrictions; -import net.sf.anathema.character.generic.magic.charms.ICharmAttribute; -import net.sf.anathema.character.generic.magic.charms.ICharmAttributeRequirement; -import net.sf.anathema.character.generic.magic.charms.ICharmLearnArbitrator; -import net.sf.anathema.character.generic.magic.charms.IComboRestrictions; -import net.sf.anathema.character.generic.magic.charms.duration.IDuration; -import net.sf.anathema.character.generic.magic.charms.type.ICharmTypeModel; -import net.sf.anathema.character.generic.magic.general.ICostList; -import net.sf.anathema.character.generic.rules.IExaltedSourceBook; -import net.sf.anathema.character.generic.template.magic.FavoringTraitType; -import net.sf.anathema.character.generic.template.magic.IFavoringTraitTypeVisitor; -import net.sf.anathema.character.generic.traits.IFavorableGenericTrait; -import net.sf.anathema.character.generic.traits.IGenericTrait; -import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.character.generic.traits.types.AbilityType; -import net.sf.anathema.character.generic.traits.types.AttributeType; -import net.sf.anathema.character.generic.traits.types.OtherTraitType; -import net.sf.anathema.character.generic.traits.types.YoziType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class Charm extends Identificate implements ICharm { - - private final CharmPrerequisiteList prerequisisteList; - - private final ICharacterType characterType; - private final IComboRestrictions comboRules; - private final IDuration duration; - private final String group; - private final boolean isGeneric; - - private final IExaltedSourceBook[] sources; - private final ICostList temporaryCost; - - private final List> alternatives = new ArrayList>(); - private final List> merges = new ArrayList>(); - private final List requiredSubeffects = new ArrayList(); - private final List parentCharms = new ArrayList(); - private final List children = new ArrayList(); - private final List selectiveCharmGroups = new ArrayList(); - private final List charmAttributes = new ArrayList(); - private final Set favoredCasteIds = new HashSet(); - - private final ICharmTypeModel typeModel; - - public Charm(ICharacterType characterType, String id, String group, boolean isGeneric, CharmPrerequisiteList prerequisiteList, - ICostList temporaryCost, IComboRestrictions comboRules, IDuration duration, ICharmTypeModel charmTypeModel, - IExaltedSourceBook[] sources) { - super(id); - Preconditions.checkNotNull(prerequisiteList); - Preconditions.checkNotNull(characterType); - Preconditions.checkNotNull(id); - Preconditions.checkNotNull(group); - Preconditions.checkNotNull(temporaryCost); - Preconditions.checkNotNull(comboRules); - Preconditions.checkNotNull(duration); - Preconditions.checkNotNull(charmTypeModel.getCharmType()); - Preconditions.checkNotNull(sources); - this.characterType = characterType; - this.group = group; - this.isGeneric = isGeneric; - this.prerequisisteList = prerequisiteList; - this.temporaryCost = temporaryCost; - this.comboRules = comboRules; - this.duration = duration; - this.typeModel = charmTypeModel; - this.sources = sources; - for (SelectiveCharmGroupTemplate template : prerequisiteList.getSelectiveCharmGroups()) { - selectiveCharmGroups.add(new SelectiveCharmGroup(template)); - } - } - - public Charm(ICharmData charmData) { - super(charmData.getId()); - this.characterType = charmData.getCharacterType(); - this.isGeneric = charmData.isInstanceOfGenericCharm(); - this.group = charmData.getGroupId(); - this.temporaryCost = charmData.getTemporaryCost(); - this.comboRules = new ComboRestrictions(); - this.duration = charmData.getDuration(); - this.sources = charmData.getSources(); - this.prerequisisteList = - new CharmPrerequisiteList(charmData.getPrerequisites(), charmData.getEssence(), new String[0], new SelectiveCharmGroupTemplate[0], - new ICharmAttributeRequirement[0]); - parentCharms.addAll(charmData.getParentCharms()); - this.typeModel = charmData.getCharmTypeModel(); - } - - public void addCharmAttribute(ICharmAttribute attribute) { - charmAttributes.add(attribute); - } - - @Override - public ICharmTypeModel getCharmTypeModel() { - return typeModel; - } - - @Override - public ICharacterType getCharacterType() { - return characterType; - } - - @Override - public IDuration getDuration() { - return duration; - } - - @Override - public IGenericTrait getEssence() { - return prerequisisteList.getEssence(); - } - - @Override - public IGenericTrait[] getPrerequisites() { - return prerequisisteList.getPrerequisites(); - } - - @Override - public IExaltedSourceBook[] getSources() { - return sources.length > 0 ? sources : null; - } - - @Override - public IExaltedSourceBook getPrimarySource() { - return sources.length > 0 ? sources[0] : null; - } - - @Override - public ICostList getTemporaryCost() { - return temporaryCost; - } - - @Override - public String getGroupId() { - return group; - } - - @Override - public boolean isInstanceOfGenericCharm() { - return isGeneric; - } - - @Override - public IComboRestrictions getComboRules() { - return comboRules; - } - - @Override - public void accept(IMagicVisitor visitor) { - visitor.visitCharm(this); - } - - public void addAlternative(Set alternative) { - alternatives.add(alternative); - } - - @Override - public boolean isBlockedByAlternative(IMagicCollection magicCollection) { - for (Set alternative : alternatives) { - for (ICharm charm : alternative) { - boolean isThis = charm.getId().equals(getId()); - if (!isThis && magicCollection.isLearned(charm)) { - return true; - } - } - } - return false; - } - - public void addMerged(Set merged) { - if (!merged.isEmpty()) { - merges.add(merged); - if (!hasAttribute(ICharmData.MERGED_ATTRIBUTE)) { - addCharmAttribute(new CharmAttribute(ICharmData.MERGED_ATTRIBUTE.getId(), true)); - } - } - } - - @Override - public Set getMergedCharms() { - Set mergedCharms = new HashSet(); - for (Set merge : merges) { - mergedCharms.addAll(merge); - } - return mergedCharms; - } - - @Override - public Set getParentCharms() { - return new HashSet(parentCharms); - } - - private boolean isSubeffectReference(String id) { - return id.split("\\.").length == 4; - } - - private boolean isGenericSubeffectReference(String id) { - return id.split("\\.").length == 5; - } - - public void extractParentCharms(Map charmsById) { - if (parentCharms.size() > 0) { - return; - } - for (String parentId : prerequisisteList.getParentIDs()) { - String id = parentId; - - if (isSubeffectReference(parentId)) { - String[] split = parentId.split("\\."); - id = split[0] + "." + split[1]; - requiredSubeffects.add(parentId); - } - if (isGenericSubeffectReference(parentId)) { - String[] split = parentId.split("\\."); - id = split[0] + "." + split[1] + "." + split[4]; - requiredSubeffects.add(parentId); - } - - Charm parentCharm = charmsById.get(id); - Preconditions.checkNotNull(parentCharm, "Parent Charm " + id + " not defined for " + getId()); //$NON-NLS-1$//$NON-NLS-2$ - parentCharms.add(parentCharm); - parentCharm.addChild(this); - } - for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { - charmGroup.extractCharms(charmsById, this); - } - } - - public void addChild(Charm child) { - children.add(child); - } - - @Override - public List getParentSubeffects() { - return requiredSubeffects; - } - - @Override - public Set getRenderingPrerequisiteCharms() { - Set prerequisiteCharms = new HashSet(); - prerequisiteCharms.addAll(parentCharms); - for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { - if (charmGroup.getLabel() == null) { - prerequisiteCharms.addAll(Arrays.asList(charmGroup.getAllGroupCharms())); - } - } - - return prerequisiteCharms; - } - - @Override - public Set getRenderingPrerequisiteLabels() { - Set prerequisiteLabels = new HashSet(); - for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { - if (charmGroup.getLabel() != null) { - prerequisiteLabels.add(charmGroup.getLabel()); - } - } - - return prerequisiteLabels; - } - - @Override - public Set getLearnPrerequisitesCharms(ICharmLearnArbitrator learnArbitrator) { - Set prerequisiteCharms = new HashSet(); - for (ICharm charm : getParentCharms()) { - prerequisiteCharms.addAll(charm.getLearnPrerequisitesCharms(learnArbitrator)); - prerequisiteCharms.add(charm); - } - for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { - prerequisiteCharms.addAll(charmGroup.getLearnPrerequisitesCharms(learnArbitrator)); - } - return prerequisiteCharms; - } - - @Override - public boolean isTreeRoot() { - return parentCharms.size() == 0 && selectiveCharmGroups.size() == 0 && getAttributeRequirements().length == 0; - } - - @Override - public Set getLearnFollowUpCharms(ICharmLearnArbitrator learnArbitrator) { - CompositeLearnWorker learnWorker = new CompositeLearnWorker(learnArbitrator); - for (Charm child : children) { - child.addCharmsToForget(learnWorker); - } - return learnWorker.getForgottenCharms(); - } - - @Override - public Set getLearnChildCharms() { - return new HashSet(children); - } - - private void addCharmsToForget(ICharmLearnWorker learnWorker) { - if (isCharmPrerequisiteListFullfilled(learnWorker)) { - return; - } - learnWorker.forget(this); - for (Charm child : children) { - child.addCharmsToForget(learnWorker); - } - } - - private boolean isCharmPrerequisiteListFullfilled(ICharmLearnArbitrator learnArbitrator) { - for (ICharm parent : parentCharms) { - if (!learnArbitrator.isLearned(parent)) { - return false; - } - } - for (SelectiveCharmGroup selectiveGroup : selectiveCharmGroups) { - if (!selectiveGroup.holdsThreshold(learnArbitrator)) { - return false; - } - } - return true; - } - - @Override - public ICharmAttribute[] getAttributes() { - return charmAttributes.toArray(new ICharmAttribute[charmAttributes.size()]); - } - - @Override - public boolean hasAttribute(IIdentificate attribute) { - return charmAttributes.contains(attribute); - } - - @Override - public String getAttributeValue(IIdentificate attribute) { - int index = charmAttributes.indexOf(attribute); - if (index < 0) { - return null; - } else { - return charmAttributes.get(index).getValue(); - } - } - - @Override - public ICharmAttributeRequirement[] getAttributeRequirements() { - return prerequisisteList.getAttributeRequirements(); - } - - public void addFavoredCasteId(String casteId) { - favoredCasteIds.add(casteId); - } - - @Override - public boolean isFavored(IBasicCharacterData basicCharacter, IGenericTraitCollection traitCollection) { - boolean specialFavored = favoredCasteIds.contains(basicCharacter.getCasteType().getId()); - if (specialFavored) { - return true; - } - if (getPrerequisites().length <= 0) { - return false; - } - - final boolean[] characterCanFavorMagicOfPrimaryType = new boolean[1]; - final ITraitType primaryTraitType = getPrimaryTraitType(); - if (hasAttribute(new Identificate("MartialArts")) && - ((IFavorableGenericTrait) traitCollection.getTrait(AbilityType.MartialArts)).isCasteOrFavored()) { - return true; - } - - basicCharacter.getCharacterType().getFavoringTraitType().accept(new IFavoringTraitTypeVisitor() { - @Override - public void visitAbilityType(FavoringTraitType visitedType) { - characterCanFavorMagicOfPrimaryType[0] = primaryTraitType instanceof AbilityType; - } - - @Override - public void visitAttributeType(FavoringTraitType visitedType) { - characterCanFavorMagicOfPrimaryType[0] = primaryTraitType instanceof AttributeType; - } - - @Override - public void visitYoziType(FavoringTraitType visitedType) { - characterCanFavorMagicOfPrimaryType[0] = primaryTraitType instanceof YoziType; - } - - @Override - public void visitVirtueType(FavoringTraitType visitedType) { - characterCanFavorMagicOfPrimaryType[0] = false; - } - }); - if (!characterCanFavorMagicOfPrimaryType[0]) { - return false; - } - IGenericTrait trait = traitCollection.getTrait(primaryTraitType); - return trait instanceof IFavorableGenericTrait && ((IFavorableGenericTrait) trait).isCasteOrFavored(); - } - - @Override - public ITraitType getPrimaryTraitType() { - return getPrerequisites().length == 0 ? OtherTraitType.Essence : getPrerequisites()[0].getType(); - } - - @Override - public boolean hasChildren() { - return !children.isEmpty(); - } +package net.sf.anathema.character.generic.impl.magic; + +import com.google.common.base.Preconditions; +import net.sf.anathema.character.generic.IBasicCharacterData; +import net.sf.anathema.character.generic.character.IGenericTraitCollection; +import net.sf.anathema.character.generic.character.IMagicCollection; +import net.sf.anathema.character.generic.impl.magic.charm.prerequisite.CompositeLearnWorker; +import net.sf.anathema.character.generic.impl.magic.charm.prerequisite.ICharmLearnWorker; +import net.sf.anathema.character.generic.impl.magic.charm.prerequisite.SelectiveCharmGroup; +import net.sf.anathema.character.generic.impl.magic.persistence.prerequisite.CharmPrerequisiteList; +import net.sf.anathema.character.generic.impl.magic.persistence.prerequisite.SelectiveCharmGroupTemplate; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.ICharmData; +import net.sf.anathema.character.generic.magic.IMagicVisitor; +import net.sf.anathema.character.generic.magic.charms.ComboRestrictions; +import net.sf.anathema.character.generic.magic.charms.ICharmAttribute; +import net.sf.anathema.character.generic.magic.charms.ICharmAttributeRequirement; +import net.sf.anathema.character.generic.magic.charms.ICharmLearnArbitrator; +import net.sf.anathema.character.generic.magic.charms.IComboRestrictions; +import net.sf.anathema.character.generic.magic.charms.duration.IDuration; +import net.sf.anathema.character.generic.magic.charms.type.ICharmTypeModel; +import net.sf.anathema.character.generic.magic.general.ICostList; +import net.sf.anathema.character.generic.rules.IExaltedSourceBook; +import net.sf.anathema.character.generic.template.magic.FavoringTraitType; +import net.sf.anathema.character.generic.template.magic.IFavoringTraitTypeVisitor; +import net.sf.anathema.character.generic.traits.IFavorableGenericTrait; +import net.sf.anathema.character.generic.traits.IGenericTrait; +import net.sf.anathema.character.generic.traits.ITraitType; +import net.sf.anathema.character.generic.traits.types.AbilityType; +import net.sf.anathema.character.generic.traits.types.AttributeType; +import net.sf.anathema.character.generic.traits.types.OtherTraitType; +import net.sf.anathema.character.generic.traits.types.YoziType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class Charm extends Identificate implements ICharm { + + private final CharmPrerequisiteList prerequisisteList; + + private final ICharacterType characterType; + private final IComboRestrictions comboRules; + private final IDuration duration; + private final String group; + private final boolean isGeneric; + + private final IExaltedSourceBook[] sources; + private final ICostList temporaryCost; + + private final List> alternatives = new ArrayList>(); + private final List> merges = new ArrayList>(); + private final List requiredSubeffects = new ArrayList(); + private final List parentCharms = new ArrayList(); + private final List children = new ArrayList(); + private final List selectiveCharmGroups = new ArrayList(); + private final List charmAttributes = new ArrayList(); + private final Set favoredCasteIds = new HashSet(); + + private final ICharmTypeModel typeModel; + + public Charm(ICharacterType characterType, String id, String group, boolean isGeneric, CharmPrerequisiteList prerequisiteList, + ICostList temporaryCost, IComboRestrictions comboRules, IDuration duration, ICharmTypeModel charmTypeModel, + IExaltedSourceBook[] sources) { + super(id); + Preconditions.checkNotNull(prerequisiteList); + Preconditions.checkNotNull(characterType); + Preconditions.checkNotNull(id); + Preconditions.checkNotNull(group); + Preconditions.checkNotNull(temporaryCost); + Preconditions.checkNotNull(comboRules); + Preconditions.checkNotNull(duration); + Preconditions.checkNotNull(charmTypeModel.getCharmType()); + Preconditions.checkNotNull(sources); + this.characterType = characterType; + this.group = group; + this.isGeneric = isGeneric; + this.prerequisisteList = prerequisiteList; + this.temporaryCost = temporaryCost; + this.comboRules = comboRules; + this.duration = duration; + this.typeModel = charmTypeModel; + this.sources = sources; + for (SelectiveCharmGroupTemplate template : prerequisiteList.getSelectiveCharmGroups()) { + selectiveCharmGroups.add(new SelectiveCharmGroup(template)); + } + } + + public Charm(ICharmData charmData) { + super(charmData.getId()); + this.characterType = charmData.getCharacterType(); + this.isGeneric = charmData.isInstanceOfGenericCharm(); + this.group = charmData.getGroupId(); + this.temporaryCost = charmData.getTemporaryCost(); + this.comboRules = new ComboRestrictions(); + this.duration = charmData.getDuration(); + this.sources = charmData.getSources(); + this.prerequisisteList = + new CharmPrerequisiteList(charmData.getPrerequisites(), charmData.getEssence(), new String[0], new SelectiveCharmGroupTemplate[0], + new ICharmAttributeRequirement[0]); + parentCharms.addAll(charmData.getParentCharms()); + this.typeModel = charmData.getCharmTypeModel(); + } + + public void addCharmAttribute(ICharmAttribute attribute) { + charmAttributes.add(attribute); + } + + @Override + public ICharmTypeModel getCharmTypeModel() { + return typeModel; + } + + @Override + public ICharacterType getCharacterType() { + return characterType; + } + + @Override + public IDuration getDuration() { + return duration; + } + + @Override + public IGenericTrait getEssence() { + return prerequisisteList.getEssence(); + } + + @Override + public IGenericTrait[] getPrerequisites() { + return prerequisisteList.getPrerequisites(); + } + + @Override + public IExaltedSourceBook[] getSources() { + return sources.length > 0 ? sources : null; + } + + @Override + public IExaltedSourceBook getPrimarySource() { + return sources.length > 0 ? sources[0] : null; + } + + @Override + public ICostList getTemporaryCost() { + return temporaryCost; + } + + @Override + public String getGroupId() { + return group; + } + + @Override + public boolean isInstanceOfGenericCharm() { + return isGeneric; + } + + @Override + public IComboRestrictions getComboRules() { + return comboRules; + } + + @Override + public void accept(IMagicVisitor visitor) { + visitor.visitCharm(this); + } + + public void addAlternative(Set alternative) { + alternatives.add(alternative); + } + + @Override + public boolean isBlockedByAlternative(IMagicCollection magicCollection) { + for (Set alternative : alternatives) { + for (ICharm charm : alternative) { + boolean isThis = charm.getId().equals(getId()); + if (!isThis && magicCollection.isLearned(charm)) { + return true; + } + } + } + return false; + } + + public void addMerged(Set merged) { + if (!merged.isEmpty()) { + merges.add(merged); + if (!hasAttribute(ICharmData.MERGED_ATTRIBUTE)) { + addCharmAttribute(new CharmAttribute(ICharmData.MERGED_ATTRIBUTE.getId(), true)); + } + } + } + + @Override + public Set getMergedCharms() { + Set mergedCharms = new HashSet(); + for (Set merge : merges) { + mergedCharms.addAll(merge); + } + return mergedCharms; + } + + @Override + public Set getParentCharms() { + return new HashSet(parentCharms); + } + + private boolean isSubeffectReference(String id) { + return id.split("\\.").length == 4; + } + + private boolean isGenericSubeffectReference(String id) { + return id.split("\\.").length == 5; + } + + public void extractParentCharms(Map charmsById) { + if (parentCharms.size() > 0) { + return; + } + for (String parentId : prerequisisteList.getParentIDs()) { + String id = parentId; + + if (isSubeffectReference(parentId)) { + String[] split = parentId.split("\\."); + id = split[0] + "." + split[1]; + requiredSubeffects.add(parentId); + } + if (isGenericSubeffectReference(parentId)) { + String[] split = parentId.split("\\."); + id = split[0] + "." + split[1] + "." + split[4]; + requiredSubeffects.add(parentId); + } + + Charm parentCharm = charmsById.get(id); + Preconditions.checkNotNull(parentCharm, "Parent Charm " + id + " not defined for " + getId()); //$NON-NLS-1$//$NON-NLS-2$ + parentCharms.add(parentCharm); + parentCharm.addChild(this); + } + for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { + charmGroup.extractCharms(charmsById, this); + } + } + + public void addChild(Charm child) { + children.add(child); + } + + @Override + public List getParentSubeffects() { + return requiredSubeffects; + } + + @Override + public Set getRenderingPrerequisiteCharms() { + Set prerequisiteCharms = new HashSet(); + prerequisiteCharms.addAll(parentCharms); + for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { + if (charmGroup.getLabel() == null) { + prerequisiteCharms.addAll(Arrays.asList(charmGroup.getAllGroupCharms())); + } + } + + return prerequisiteCharms; + } + + @Override + public Set getRenderingPrerequisiteLabels() { + Set prerequisiteLabels = new HashSet(); + for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { + if (charmGroup.getLabel() != null) { + prerequisiteLabels.add(charmGroup.getLabel()); + } + } + + return prerequisiteLabels; + } + + @Override + public Set getLearnPrerequisitesCharms(ICharmLearnArbitrator learnArbitrator) { + Set prerequisiteCharms = new HashSet(); + for (ICharm charm : getParentCharms()) { + prerequisiteCharms.addAll(charm.getLearnPrerequisitesCharms(learnArbitrator)); + prerequisiteCharms.add(charm); + } + for (SelectiveCharmGroup charmGroup : selectiveCharmGroups) { + prerequisiteCharms.addAll(charmGroup.getLearnPrerequisitesCharms(learnArbitrator)); + } + return prerequisiteCharms; + } + + @Override + public boolean isTreeRoot() { + return parentCharms.size() == 0 && selectiveCharmGroups.size() == 0 && getAttributeRequirements().length == 0; + } + + @Override + public Set getLearnFollowUpCharms(ICharmLearnArbitrator learnArbitrator) { + CompositeLearnWorker learnWorker = new CompositeLearnWorker(learnArbitrator); + for (Charm child : children) { + child.addCharmsToForget(learnWorker); + } + return learnWorker.getForgottenCharms(); + } + + @Override + public Set getLearnChildCharms() { + return new HashSet(children); + } + + private void addCharmsToForget(ICharmLearnWorker learnWorker) { + if (isCharmPrerequisiteListFullfilled(learnWorker)) { + return; + } + learnWorker.forget(this); + for (Charm child : children) { + child.addCharmsToForget(learnWorker); + } + } + + private boolean isCharmPrerequisiteListFullfilled(ICharmLearnArbitrator learnArbitrator) { + for (ICharm parent : parentCharms) { + if (!learnArbitrator.isLearned(parent)) { + return false; + } + } + for (SelectiveCharmGroup selectiveGroup : selectiveCharmGroups) { + if (!selectiveGroup.holdsThreshold(learnArbitrator)) { + return false; + } + } + return true; + } + + @Override + public ICharmAttribute[] getAttributes() { + return charmAttributes.toArray(new ICharmAttribute[charmAttributes.size()]); + } + + @Override + public boolean hasAttribute(Identified attribute) { + return charmAttributes.contains(attribute); + } + + @Override + public String getAttributeValue(Identified attribute) { + int index = charmAttributes.indexOf(attribute); + if (index < 0) { + return null; + } else { + return charmAttributes.get(index).getValue(); + } + } + + @Override + public ICharmAttributeRequirement[] getAttributeRequirements() { + return prerequisisteList.getAttributeRequirements(); + } + + public void addFavoredCasteId(String casteId) { + favoredCasteIds.add(casteId); + } + + @Override + public boolean isFavored(IBasicCharacterData basicCharacter, IGenericTraitCollection traitCollection) { + boolean specialFavored = favoredCasteIds.contains(basicCharacter.getCasteType().getId()); + if (specialFavored) { + return true; + } + if (getPrerequisites().length <= 0) { + return false; + } + + final boolean[] characterCanFavorMagicOfPrimaryType = new boolean[1]; + final ITraitType primaryTraitType = getPrimaryTraitType(); + if (hasAttribute(new Identificate("MartialArts")) && + ((IFavorableGenericTrait) traitCollection.getTrait(AbilityType.MartialArts)).isCasteOrFavored()) { + return true; + } + + basicCharacter.getCharacterType().getFavoringTraitType().accept(new IFavoringTraitTypeVisitor() { + @Override + public void visitAbilityType(FavoringTraitType visitedType) { + characterCanFavorMagicOfPrimaryType[0] = primaryTraitType instanceof AbilityType; + } + + @Override + public void visitAttributeType(FavoringTraitType visitedType) { + characterCanFavorMagicOfPrimaryType[0] = primaryTraitType instanceof AttributeType; + } + + @Override + public void visitYoziType(FavoringTraitType visitedType) { + characterCanFavorMagicOfPrimaryType[0] = primaryTraitType instanceof YoziType; + } + + @Override + public void visitVirtueType(FavoringTraitType visitedType) { + characterCanFavorMagicOfPrimaryType[0] = false; + } + }); + if (!characterCanFavorMagicOfPrimaryType[0]) { + return false; + } + IGenericTrait trait = traitCollection.getTrait(primaryTraitType); + return trait instanceof IFavorableGenericTrait && ((IFavorableGenericTrait) trait).isCasteOrFavored(); + } + + @Override + public ITraitType getPrimaryTraitType() { + return getPrerequisites().length == 0 ? OtherTraitType.Essence : getPrerequisites()[0].getType(); + } + + @Override + public boolean hasChildren() { + return !children.isEmpty(); + } } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/UniqueCharmType.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/UniqueCharmType.java index e54d8e25fc..3277a48b8d 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/UniqueCharmType.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/UniqueCharmType.java @@ -1,32 +1,32 @@ -package net.sf.anathema.character.generic.impl.magic; - -import net.sf.anathema.character.generic.template.magic.IUniqueCharmType; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public class UniqueCharmType implements IUniqueCharmType { - private final String label; - private final String type; - private final String keyword; - - public UniqueCharmType(String type, String label, String keyword) { - this.keyword = keyword; - this.label = label; - this.type = type; - } - - @Override - public String getLabel() { - return label; - } - - @Override - public boolean keywordMatches(String id) { - return keyword.equals(id); - } - - @Override - public IIdentificate getId() { - return new Identificate(type); - } +package net.sf.anathema.character.generic.impl.magic; + +import net.sf.anathema.character.generic.template.magic.IUniqueCharmType; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +public class UniqueCharmType implements IUniqueCharmType { + private final String label; + private final String type; + private final String keyword; + + public UniqueCharmType(String type, String label, String keyword) { + this.keyword = keyword; + this.label = label; + this.type = type; + } + + @Override + public String getLabel() { + return label; + } + + @Override + public boolean keywordMatches(String id) { + return keyword.equals(id); + } + + @Override + public Identified getId() { + return new Identificate(type); + } } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/CharmGroup.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/CharmGroup.java index 27d04efdaa..eba7622597 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/CharmGroup.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/CharmGroup.java @@ -3,9 +3,9 @@ import net.sf.anathema.character.generic.magic.ICharm; import net.sf.anathema.character.generic.magic.charms.ICharmGroup; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public class CharmGroup implements ICharmGroup, IIdentificate { +public class CharmGroup implements ICharmGroup, Identified { private final String id; private final ICharm[] charms; diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/special/Element.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/special/Element.java index 102c0a9a2d..22b5db6374 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/special/Element.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/charm/special/Element.java @@ -1,11 +1,11 @@ -package net.sf.anathema.character.generic.impl.magic.charm.special; - -import net.sf.anathema.lib.util.IIdentificate; - -enum Element { - Air, Earth, Fire, Water, Wood; - - public boolean matches(IIdentificate caste) { - return caste.getId().equals(name()); - } +package net.sf.anathema.character.generic.impl.magic.charm.special; + +import net.sf.anathema.lib.util.Identified; + +enum Element { + Air, Earth, Fire, Water, Wood; + + public boolean matches(Identified caste) { + return caste.getId().equals(name()); + } } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCache.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCache.java index f2cbd1f930..a6fa50eea5 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCache.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCache.java @@ -3,8 +3,8 @@ import net.sf.anathema.character.generic.magic.ICharm; import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharm; import net.sf.anathema.lib.collection.MultiEntryMap; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.ArrayList; import java.util.HashMap; @@ -13,18 +13,18 @@ public class CharmCache implements ICharmCache { - MultiEntryMap charmSets = new MultiEntryMap(); + MultiEntryMap charmSets = new MultiEntryMap(); Map renameData = new HashMap(); - Map> specialCharms = new HashMap>(); + Map> specialCharms = new HashMap>(); @Override - public ICharm[] getCharms(IIdentificate type) { + public ICharm[] getCharms(Identified type) { type = new Identificate(type.getId()); List charmList = charmSets.get(type); return charmList.toArray(new ICharm[charmList.size()]); } - public void addCharm(IIdentificate type, ICharm charm) { + public void addCharm(Identified type, ICharm charm) { type = new Identificate(type.getId()); charmSets.replace(type, charm, charm); } @@ -35,7 +35,7 @@ public boolean isEmpty() { public Iterable getCharms() { List allCharms = new ArrayList(); - for (IIdentificate type : charmSets.keySet()) { + for (Identified type : charmSets.keySet()) { for (ICharm charm : charmSets.get(type)) { allCharms.add(charm); } @@ -43,8 +43,8 @@ public Iterable getCharms() { return allCharms; } - private List getSpecialCharmList(IIdentificate type) { - Map> map = specialCharms; + private List getSpecialCharmList(Identified type) { + Map> map = specialCharms; type = new Identificate(type.getId()); List list = map.get(type); if (list == null) { @@ -55,12 +55,12 @@ private List getSpecialCharmList(IIdentificate type) { } @Override - public ISpecialCharm[] getSpecialCharmData(IIdentificate type) { + public ISpecialCharm[] getSpecialCharmData(Identified type) { List charmList = getSpecialCharmList(type); return charmList.toArray(new ISpecialCharm[charmList.size()]); } - public void addSpecialCharmData(IIdentificate type, List data) { + public void addSpecialCharmData(Identified type, List data) { if (data == null) { return; } @@ -86,7 +86,7 @@ public String getCharmRename(String id) { } @Override - public IIdentificate[] getCharmTypes() { - return charmSets.keySet().toArray(new IIdentificate[0]); + public Identified[] getCharmTypes() { + return charmSets.keySet().toArray(new Identified[0]); } } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCompiler.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCompiler.java index 4b941a169d..b99696214a 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCompiler.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/CharmCompiler.java @@ -1,5 +1,7 @@ package net.sf.anathema.character.generic.impl.magic.persistence; +import net.sf.anathema.character.generic.data.IExtensibleDataSet; +import net.sf.anathema.character.generic.data.IExtensibleDataSetCompiler; import net.sf.anathema.character.generic.impl.magic.Charm; import net.sf.anathema.character.generic.magic.ICharm; import net.sf.anathema.character.generic.magic.charms.CharmException; @@ -12,10 +14,8 @@ import net.sf.anathema.lib.registry.IIdentificateRegistry; import net.sf.anathema.lib.registry.IdentificateRegistry; import net.sf.anathema.lib.resources.ResourceFile; -import net.sf.anathema.character.generic.data.IExtensibleDataSet; -import net.sf.anathema.character.generic.data.IExtensibleDataSetCompiler; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.io.SAXReader; @@ -33,8 +33,8 @@ public class CharmCompiler implements IExtensibleDataSetCompiler { //matches stuff like data/charms/solar/Charms_Solar_SecondEdition_Occult.xml //the pattern is data/charms/REST_OF_PATH/Charms_TYPE_EDITION_ANYTHING.xml private static final String Charm_Data_Extraction_Pattern = ".*/Charms_(.*?)_(.*?)(?:_.*)?\\.xml"; - private final Map> charmFileTable = new HashMap>(); - private final IIdentificateRegistry registry = new IdentificateRegistry(); + private final Map> charmFileTable = new HashMap>(); + private final IIdentificateRegistry registry = new IdentificateRegistry(); private final CharmSetBuilder setBuilder = new CharmSetBuilder(); private final GenericCharmSetBuilder genericBuilder = new GenericCharmSetBuilder(); private final CharmAlternativeBuilder alternativeBuilder = new CharmAlternativeBuilder(); @@ -58,7 +58,7 @@ public void registerFile(ResourceFile resource) throws Exception { Matcher matcher = Pattern.compile(Charm_Data_Extraction_Pattern).matcher(resource.getFileName()); matcher.matches(); String typeString = matcher.group(1); - IIdentificate type = new Identificate(typeString); + Identified type = new Identificate(typeString); if (!registry.idRegistered(typeString)) { registry.add(type); } @@ -76,7 +76,7 @@ public void registerFile(ResourceFile resource) throws Exception { @Override public IExtensibleDataSet build() throws PersistenceException { - for (IIdentificate type : registry.getAll()) { + for (Identified type : registry.getAll()) { buildStandardCharms(type); buildGenericCharms(type); buildCharmAlternatives(type); @@ -88,11 +88,11 @@ public IExtensibleDataSet build() throws PersistenceException { return charmCache; } - private void buildStandardCharms(IIdentificate type) throws PersistenceException { + private void buildStandardCharms(Identified type) throws PersistenceException { buildCharms(type, setBuilder); } - private void buildGenericCharms(IIdentificate type) throws PersistenceException { + private void buildGenericCharms(Identified type) throws PersistenceException { try { ICharacterType characterType = CharacterType.getById(type.getId()); ITraitType[] primaryTypes = characterType.getFavoringTraitType().getTraitTypes(); @@ -103,7 +103,7 @@ private void buildGenericCharms(IIdentificate type) throws PersistenceException } } - private void buildCharmAlternatives(IIdentificate type) { + private void buildCharmAlternatives(Identified type) { if (charmFileTable.containsKey(type)) { for (Document charmDocument : charmFileTable.get(type)) { alternativeBuilder.buildAlternatives(charmDocument, charmCache.getCharms(type)); @@ -111,7 +111,7 @@ private void buildCharmAlternatives(IIdentificate type) { } } - private void buildCharmMerges(IIdentificate type) { + private void buildCharmMerges(Identified type) { if (charmFileTable.containsKey(type)) { for (Document charmDocument : charmFileTable.get(type)) { mergedBuilder.buildMerges(charmDocument, charmCache.getCharms(type)); @@ -119,7 +119,7 @@ private void buildCharmMerges(IIdentificate type) { } } - private void buildCharmRenames(IIdentificate type) { + private void buildCharmRenames(Identified type) { if (charmFileTable.containsKey(type)) { for (Document charmDocument : charmFileTable.get(type)) { charmCache.addCharmRenames(renameBuilder.buildRenames(charmDocument)); @@ -127,7 +127,7 @@ private void buildCharmRenames(IIdentificate type) { } } - private void buildCharms(IIdentificate type, ICharmSetBuilder builder) throws PersistenceException { + private void buildCharms(Identified type, ICharmSetBuilder builder) throws PersistenceException { if (charmFileTable.containsKey(type)) { List documents = charmFileTable.get(type); for (Document charmDocument : documents) { @@ -136,7 +136,7 @@ private void buildCharms(IIdentificate type, ICharmSetBuilder builder) throws Pe } } - private void buildTypeCharms(IIdentificate type, Document charmDocument, + private void buildTypeCharms(Identified type, Document charmDocument, ICharmSetBuilder builder) throws PersistenceException { List specialCharms = new ArrayList(); ICharm[] charmArray = builder.buildCharms(charmDocument, specialCharms); diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/ICharmCache.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/ICharmCache.java index 4464bb64b3..3aa788193c 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/ICharmCache.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/magic/persistence/ICharmCache.java @@ -1,16 +1,16 @@ package net.sf.anathema.character.generic.impl.magic.persistence; +import net.sf.anathema.character.generic.data.IExtensibleDataSet; import net.sf.anathema.character.generic.magic.ICharm; import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharm; -import net.sf.anathema.character.generic.data.IExtensibleDataSet; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ICharmCache extends IExtensibleDataSet { - ICharm[] getCharms(IIdentificate type); + ICharm[] getCharms(Identified type); - IIdentificate[] getCharmTypes(); + Identified[] getCharmTypes(); - ISpecialCharm[] getSpecialCharmData(IIdentificate type); + ISpecialCharm[] getSpecialCharmData(Identified type); String getCharmRename(String name); } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/CharmProvider.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/CharmProvider.java index c7b5139474..22cce0f199 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/CharmProvider.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/CharmProvider.java @@ -5,8 +5,8 @@ import net.sf.anathema.character.generic.magic.charms.ICharmIdMap; import net.sf.anathema.character.generic.magic.charms.ICharmLearnableArbitrator; import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharm; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.ArrayList; import java.util.HashMap; @@ -15,18 +15,18 @@ public class CharmProvider implements ICharmProvider { - private final Map charmsByType = new HashMap(); + private final Map charmsByType = new HashMap(); private final ICharmCache cache; public CharmProvider(ICharmCache cache) { this.cache = cache; - for (IIdentificate type : cache.getCharmTypes()) { + for (Identified type : cache.getCharmTypes()) { charmsByType.put(type, cache.getSpecialCharmData(type)); } } @Override - public ISpecialCharm[] getSpecialCharms(ICharmLearnableArbitrator arbitrator, ICharmIdMap map, IIdentificate preferredType) { + public ISpecialCharm[] getSpecialCharms(ICharmLearnableArbitrator arbitrator, ICharmIdMap map, Identified preferredType) { List relevantCharms = new ArrayList(); ISpecialCharm[] allSpecialCharms = getAllSpecialCharms(preferredType); for (ISpecialCharm specialCharm : allSpecialCharms) { @@ -39,7 +39,7 @@ public ISpecialCharm[] getSpecialCharms(ICharmLearnableArbitrator arbitrator, IC } @Override - public ISpecialCharm[] getSpecialCharms(IIdentificate type) { + public ISpecialCharm[] getSpecialCharms(Identified type) { ISpecialCharm[] specialCharms = charmsByType.get(new Identificate(type.getId())); if (specialCharms == null) { specialCharms = new ISpecialCharm[0]; @@ -47,9 +47,9 @@ public ISpecialCharm[] getSpecialCharms(IIdentificate type) { return specialCharms; } - private ISpecialCharm[] getAllSpecialCharms(IIdentificate preferredCharacterType) { + private ISpecialCharm[] getAllSpecialCharms(Identified preferredCharacterType) { SpecialCharmSet set = new SpecialCharmSet(); - for (IIdentificate type : charmsByType.keySet()) { + for (Identified type : charmsByType.keySet()) { set.add(getSpecialCharms(type)); } for (ISpecialCharm preferredCharm : getSpecialCharms(preferredCharacterType)) { diff --git a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/ICharmProvider.java b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/ICharmProvider.java index 0aa7a5fb76..312512c02b 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/ICharmProvider.java +++ b/Character_Generic_Impl/src/net/sf/anathema/character/generic/impl/template/magic/ICharmProvider.java @@ -3,13 +3,13 @@ import net.sf.anathema.character.generic.magic.charms.ICharmIdMap; import net.sf.anathema.character.generic.magic.charms.ICharmLearnableArbitrator; import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharm; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ICharmProvider { - ISpecialCharm[] getSpecialCharms(IIdentificate type); + ISpecialCharm[] getSpecialCharms(Identified type); - ISpecialCharm[] getSpecialCharms(ICharmLearnableArbitrator arbitrator, ICharmIdMap map, IIdentificate preferredType); + ISpecialCharm[] getSpecialCharms(ICharmLearnableArbitrator arbitrator, ICharmIdMap map, Identified preferredType); String getCharmRename(String name); } \ No newline at end of file diff --git a/Character_Generic_Impl/src/net/sf/anathema/dummy/character/magic/DummyCharm.java b/Character_Generic_Impl/src/net/sf/anathema/dummy/character/magic/DummyCharm.java index d235711590..b7d2be77bc 100644 --- a/Character_Generic_Impl/src/net/sf/anathema/dummy/character/magic/DummyCharm.java +++ b/Character_Generic_Impl/src/net/sf/anathema/dummy/character/magic/DummyCharm.java @@ -22,8 +22,8 @@ import net.sf.anathema.character.generic.traits.ITraitType; import net.sf.anathema.character.generic.traits.types.ValuedTraitType; import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.ArrayList; import java.util.Collections; @@ -188,12 +188,12 @@ public void setTemporaryCost(CostList list) { } @Override - public boolean hasAttribute(IIdentificate attribute) { + public boolean hasAttribute(Identified attribute) { return false; } @Override - public String getAttributeValue(IIdentificate attribute) { + public String getAttributeValue(Identified attribute) { return null; } diff --git a/Character_Generic_Impl/test/net/sf/anathema/character/generic/impl/magic/charm/special/ElementTest.java b/Character_Generic_Impl/test/net/sf/anathema/character/generic/impl/magic/charm/special/ElementTest.java index 35bcbb776e..232fd58690 100644 --- a/Character_Generic_Impl/test/net/sf/anathema/character/generic/impl/magic/charm/special/ElementTest.java +++ b/Character_Generic_Impl/test/net/sf/anathema/character/generic/impl/magic/charm/special/ElementTest.java @@ -1,24 +1,24 @@ -package net.sf.anathema.character.generic.impl.magic.charm.special; - -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; -import org.junit.Test; - -import static net.sf.anathema.character.generic.impl.magic.charm.special.Element.Fire; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class ElementTest { - - @Test - public void matchesIdentificateWithSameName() throws Exception { - IIdentificate identificate = new Identificate(Fire.name()); - assertThat(Fire.matches(identificate), is(true)); - } - - @Test - public void doesNotMatchDifferentIdentificate() throws Exception { - IIdentificate identificate = new Identificate("Dawn"); - assertThat(Fire.matches(identificate), is(false)); - } -} +package net.sf.anathema.character.generic.impl.magic.charm.special; + +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; +import org.junit.Test; + +import static net.sf.anathema.character.generic.impl.magic.charm.special.Element.Fire; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class ElementTest { + + @Test + public void matchesIdentificateWithSameName() throws Exception { + Identified identificate = new Identificate(Fire.name()); + assertThat(Fire.matches(identificate), is(true)); + } + + @Test + public void doesNotMatchDifferentIdentificate() throws Exception { + Identified identificate = new Identificate("Dawn"); + assertThat(Fire.matches(identificate), is(false)); + } +} diff --git a/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/CharmAttributeRequirementTest.java b/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/CharmAttributeRequirementTest.java index c6831a921c..90ee84c728 100644 --- a/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/CharmAttributeRequirementTest.java +++ b/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/CharmAttributeRequirementTest.java @@ -1,69 +1,69 @@ -package net.sf.anathema.character.generic.magic; - -import net.sf.anathema.character.generic.impl.magic.CharmAttribute; -import net.sf.anathema.character.generic.impl.magic.CharmAttributeRequirement; -import net.sf.anathema.dummy.character.magic.DummyCharm; -import net.sf.anathema.lib.util.IIdentificate; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class CharmAttributeRequirementTest { - - private CharmAttribute attribute; - - @Before - public void createAttribute() { - this.attribute = new CharmAttribute("Expected", false); //$NON-NLS-1$ - } - - @Test - public void isNotFulfilledWithoutCharms() throws Exception { - CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 1); - Assert.assertFalse(requirement.isFulfilled(new ICharm[0])); - } - - @Test - public void isFulfilledIfAttributeIsPresent() throws Exception { - CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 1); - DummyCharm charm = createAttributedDummyCharm(); - Assert.assertTrue(requirement.isFulfilled(new ICharm[] { charm })); - } - - @Test - public void isNotFulfilledWithoutCorrectAttribute() throws Exception { - CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 1); - DummyCharm charm = new DummyCharm(); - Assert.assertFalse(requirement.isFulfilled(new ICharm[] { charm })); - } - - @Test - public void isNotFulfilledWithoutCorrectCount() throws Exception { - CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 2); - DummyCharm charm = createAttributedDummyCharm(); - Assert.assertFalse(requirement.isFulfilled(new ICharm[] { charm })); - } - - @Test - public void isNotFulfilledWithoutCorrectAttributesAndCount() throws Exception { - CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 2); - DummyCharm charm = createAttributedDummyCharm(); - Assert.assertFalse(requirement.isFulfilled(new ICharm[] { charm, new DummyCharm() })); - } - - @Test - public void isFulfilledEvenIfChainIsBroken() throws Exception { - CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 2); - DummyCharm charm = createAttributedDummyCharm(); - Assert.assertTrue(requirement.isFulfilled(new ICharm[] { charm, new DummyCharm(), charm })); - } - - private DummyCharm createAttributedDummyCharm() { - return new DummyCharm() { - @Override - public boolean hasAttribute(IIdentificate charmAttribute) { - return true; - } - }; - } +package net.sf.anathema.character.generic.magic; + +import net.sf.anathema.character.generic.impl.magic.CharmAttribute; +import net.sf.anathema.character.generic.impl.magic.CharmAttributeRequirement; +import net.sf.anathema.dummy.character.magic.DummyCharm; +import net.sf.anathema.lib.util.Identified; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class CharmAttributeRequirementTest { + + private CharmAttribute attribute; + + @Before + public void createAttribute() { + this.attribute = new CharmAttribute("Expected", false); //$NON-NLS-1$ + } + + @Test + public void isNotFulfilledWithoutCharms() throws Exception { + CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 1); + Assert.assertFalse(requirement.isFulfilled(new ICharm[0])); + } + + @Test + public void isFulfilledIfAttributeIsPresent() throws Exception { + CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 1); + DummyCharm charm = createAttributedDummyCharm(); + Assert.assertTrue(requirement.isFulfilled(new ICharm[] { charm })); + } + + @Test + public void isNotFulfilledWithoutCorrectAttribute() throws Exception { + CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 1); + DummyCharm charm = new DummyCharm(); + Assert.assertFalse(requirement.isFulfilled(new ICharm[] { charm })); + } + + @Test + public void isNotFulfilledWithoutCorrectCount() throws Exception { + CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 2); + DummyCharm charm = createAttributedDummyCharm(); + Assert.assertFalse(requirement.isFulfilled(new ICharm[] { charm })); + } + + @Test + public void isNotFulfilledWithoutCorrectAttributesAndCount() throws Exception { + CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 2); + DummyCharm charm = createAttributedDummyCharm(); + Assert.assertFalse(requirement.isFulfilled(new ICharm[] { charm, new DummyCharm() })); + } + + @Test + public void isFulfilledEvenIfChainIsBroken() throws Exception { + CharmAttributeRequirement requirement = new CharmAttributeRequirement(attribute, 2); + DummyCharm charm = createAttributedDummyCharm(); + Assert.assertTrue(requirement.isFulfilled(new ICharm[] { charm, new DummyCharm(), charm })); + } + + private DummyCharm createAttributedDummyCharm() { + return new DummyCharm() { + @Override + public boolean hasAttribute(Identified charmAttribute) { + return true; + } + }; + } } \ No newline at end of file diff --git a/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/MartialArtsUtilitiesTest.java b/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/MartialArtsUtilitiesTest.java index 3dd9bed309..41d082fd4a 100644 --- a/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/MartialArtsUtilitiesTest.java +++ b/Character_Generic_Impl/test/net/sf/anathema/character/generic/magic/MartialArtsUtilitiesTest.java @@ -1,57 +1,57 @@ -package net.sf.anathema.character.generic.magic; - -import net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities; -import net.sf.anathema.character.generic.magic.charms.MartialArtsLevel; -import net.sf.anathema.dummy.character.magic.DummyCharm; -import net.sf.anathema.lib.util.IIdentificate; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class MartialArtsUtilitiesTest { - - @Test - public void testIsMartialArtsCharm() { - ICharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("MartialArts"); //$NON-NLS-1$ - } - }; - assertTrue(MartialArtsUtilities.isMartialArtsCharm(charm)); - } - - @Test - public void testIsFormCharm() throws Exception { - ICharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("Form"); //$NON-NLS-1$ - } - }; - assertTrue(MartialArtsUtilities.isFormCharm(charm)); - } - - @Test - public void testGetMartialArtsLevel() throws Exception { - DummyCharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("MartialArts") || attribute.getId().equals("Terrestrial"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }; - assertEquals(MartialArtsLevel.Terrestrial, MartialArtsUtilities.getLevel(charm)); - } - - @Test - public void testHasMartialArtsLevel() throws Exception { - DummyCharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("MartialArts") || attribute.getId().equals("Terrestrial"); //$NON-NLS-1$ //$NON-NLS-2$ - } - }; - assertTrue(MartialArtsUtilities.hasLevel(MartialArtsLevel.Terrestrial, charm)); - } +package net.sf.anathema.character.generic.magic; + +import net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities; +import net.sf.anathema.character.generic.magic.charms.MartialArtsLevel; +import net.sf.anathema.dummy.character.magic.DummyCharm; +import net.sf.anathema.lib.util.Identified; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class MartialArtsUtilitiesTest { + + @Test + public void testIsMartialArtsCharm() { + ICharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("MartialArts"); //$NON-NLS-1$ + } + }; + assertTrue(MartialArtsUtilities.isMartialArtsCharm(charm)); + } + + @Test + public void testIsFormCharm() throws Exception { + ICharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("Form"); //$NON-NLS-1$ + } + }; + assertTrue(MartialArtsUtilities.isFormCharm(charm)); + } + + @Test + public void testGetMartialArtsLevel() throws Exception { + DummyCharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("MartialArts") || attribute.getId().equals("Terrestrial"); //$NON-NLS-1$ //$NON-NLS-2$ + } + }; + assertEquals(MartialArtsLevel.Terrestrial, MartialArtsUtilities.getLevel(charm)); + } + + @Test + public void testHasMartialArtsLevel() throws Exception { + DummyCharm charm = new DummyCharm("Dummy") { //$NON-NLS-1$ + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("MartialArts") || attribute.getId().equals("Terrestrial"); //$NON-NLS-1$ //$NON-NLS-2$ + } + }; + assertTrue(MartialArtsUtilities.hasLevel(MartialArtsLevel.Terrestrial, charm)); + } } \ No newline at end of file diff --git a/Character_Library/src/net/sf/anathema/character/library/quality/model/Quality.java b/Character_Library/src/net/sf/anathema/character/library/quality/model/Quality.java index 38397cf77c..132571d71b 100644 --- a/Character_Library/src/net/sf/anathema/character/library/quality/model/Quality.java +++ b/Character_Library/src/net/sf/anathema/character/library/quality/model/Quality.java @@ -1,15 +1,15 @@ package net.sf.anathema.character.library.quality.model; -import java.util.ArrayList; -import java.util.List; - import net.sf.anathema.character.library.quality.presenter.IQuality; import net.sf.anathema.character.library.quality.presenter.IQualityPredicate; import net.sf.anathema.character.library.quality.presenter.IQualitySelection; import net.sf.anathema.character.library.quality.presenter.IQualityType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; -public abstract class Quality implements IQuality, IIdentificate { +public abstract class Quality implements IQuality, Identified { private final String id; private final List prerequisites = new ArrayList(); diff --git a/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQuality.java b/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQuality.java index cdcef9ed75..03c4222765 100644 --- a/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQuality.java +++ b/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQuality.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.library.quality.presenter; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IQuality extends IIdentificate { +public interface IQuality extends Identified { IQualityType getType(); diff --git a/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQualityType.java b/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQualityType.java index 4cda0a1d7f..cf33a7d8e6 100644 --- a/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQualityType.java +++ b/Character_Library/src/net/sf/anathema/character/library/quality/presenter/IQualityType.java @@ -1,7 +1,7 @@ package net.sf.anathema.character.library.quality.presenter; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IQualityType extends IIdentificate { +public interface IQualityType extends Identified { // Nothing to do } \ No newline at end of file diff --git a/Character_Library/src/net/sf/anathema/character/library/trait/TraitGroup.java b/Character_Library/src/net/sf/anathema/character/library/trait/TraitGroup.java index 7ccd321032..672417d239 100644 --- a/Character_Library/src/net/sf/anathema/character/library/trait/TraitGroup.java +++ b/Character_Library/src/net/sf/anathema/character/library/trait/TraitGroup.java @@ -5,7 +5,7 @@ import net.sf.anathema.character.library.trait.visitor.IAggregatedTrait; import net.sf.anathema.character.library.trait.visitor.IDefaultTrait; import net.sf.anathema.character.library.trait.visitor.ITraitVisitor; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class TraitGroup { @@ -53,7 +53,7 @@ public void visitAggregatedTrait(IAggregatedTrait visitedTrait) { return creationValueSum[0]; } - public IIdentificate getGroupId() { + public Identified getGroupId() { return groupType.getGroupId(); } } \ No newline at end of file diff --git a/Character_Library/src/net/sf/anathema/character/library/trait/favorable/FavorableState.java b/Character_Library/src/net/sf/anathema/character/library/trait/favorable/FavorableState.java index d418a33cef..25069685c4 100644 --- a/Character_Library/src/net/sf/anathema/character/library/trait/favorable/FavorableState.java +++ b/Character_Library/src/net/sf/anathema/character/library/trait/favorable/FavorableState.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.library.trait.favorable; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum FavorableState implements IIdentificate { +public enum FavorableState implements Identified { Default { @Override diff --git a/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsAdditionalModel.java b/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsAdditionalModel.java index 049632b462..bb0f5c3e20 100644 --- a/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsAdditionalModel.java +++ b/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsAdditionalModel.java @@ -8,7 +8,7 @@ import net.sf.anathema.character.linguistics.ILinguisticsAdditionalModel; import net.sf.anathema.character.linguistics.presenter.ILinguisticsModel; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class LinguisticsAdditionalModel extends AbstractAdditionalModelAdapter implements ILinguisticsAdditionalModel { @@ -37,6 +37,6 @@ public String getTemplateId() { @Override public void addChangeListener(IChangeListener listener) { - model.addModelChangeListener(new RemovableEntryChangeAdapter(listener)); + model.addModelChangeListener(new RemovableEntryChangeAdapter(listener)); } } \ No newline at end of file diff --git a/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsModel.java b/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsModel.java index 40638c10a2..e3db0706d4 100644 --- a/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsModel.java +++ b/Character_Linguistics/src/net/sf/anathema/character/linguistics/model/LinguisticsModel.java @@ -12,19 +12,19 @@ import net.sf.anathema.lib.collection.ArrayUtilities; import net.sf.anathema.lib.control.IChangeListener; import net.sf.anathema.lib.lang.StringUtilities; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import org.jmock.example.announcer.Announcer; import java.util.Arrays; -public class LinguisticsModel extends AbstractRemovableEntryModel implements ILinguisticsModel { +public class LinguisticsModel extends AbstractRemovableEntryModel implements ILinguisticsModel { private static final int barbarianLanguagesPerPoint= 4; - private final IIdentificate[] languages = new IIdentificate[] { new Identificate("HighRealm"), //$NON-NLS-1$ + private final Identified[] languages = new Identified[] { new Identificate("HighRealm"), //$NON-NLS-1$ new Identificate("LowRealm"), new Identificate("OldRealm"), new Identificate("Riverspeak"), new Identificate("Skytongue"), new Identificate("Flametongue"), new Identificate("Seatongue"), new Identificate("Foresttongue"), new Identificate("GuildCant"), new Identificate("ClawSpeak"), new Identificate("HighHolySpeech"), new Identificate("Pelagial") }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ - private IIdentificate selection; + private Identified selection; private int languagePointsAllowed; private final ICharacterModelContext context; private final Announcer pointControl = Announcer.to(IChangeListener.class); @@ -50,13 +50,13 @@ private void updateLanguagePointAllowance() { } @Override - public IIdentificate[] getPredefinedLanguages() { + public Identified[] getPredefinedLanguages() { return languages; } @Override - protected IIdentificate createEntry() { - IIdentificate selectionCopy = selection; + protected Identified createEntry() { + Identified selectionCopy = selection; this.selection = null; fireEntryChanged(); return selectionCopy; @@ -82,11 +82,11 @@ public void selectBarbarianLanguage(String customName) { } @Override - public void selectLanguage(final IIdentificate language) { + public void selectLanguage(final Identified language) { Preconditions.checkNotNull(language); - IIdentificate foundLanguage = Iterables.find(getEntries(), new Predicate() { + Identified foundLanguage = Iterables.find(getEntries(), new Predicate() { @Override - public boolean apply(IIdentificate selectedLanguage) { + public boolean apply(Identified selectedLanguage) { return Objects.equal(language, selectedLanguage); } }, null); @@ -98,10 +98,10 @@ public boolean apply(IIdentificate selectedLanguage) { } @Override - public IIdentificate getPredefinedLanguageById(final String id) { - return Iterables.find(Arrays.asList(languages), new Predicate(){ + public Identified getPredefinedLanguageById(final String id) { + return Iterables.find(Arrays.asList(languages), new Predicate(){ @Override - public boolean apply(IIdentificate definedLanuage) { + public boolean apply(Identified definedLanuage) { return Objects.equal(id, definedLanuage.getId()); } },null); @@ -115,7 +115,7 @@ public void addCharacterChangedListener(IChangeListener listener) { @Override public int getBarbarianLanguageCount() { int count = 0; - for (IIdentificate language : getEntries()) { + for (Identified language : getEntries()) { if (!isPredefinedLanguage(language)) { count++; } @@ -139,7 +139,7 @@ public int getLanguagePointsSpent() { @Override public int getPredefinedLanguageCount() { int count = 0; - for (IIdentificate language : getEntries()) { + for (Identified language : getEntries()) { if (isPredefinedLanguage(language)) { count++; } diff --git a/Character_Linguistics/src/net/sf/anathema/character/linguistics/persistence/LinguisticsPersister.java b/Character_Linguistics/src/net/sf/anathema/character/linguistics/persistence/LinguisticsPersister.java index 793e35826c..eb3fb7ec9b 100644 --- a/Character_Linguistics/src/net/sf/anathema/character/linguistics/persistence/LinguisticsPersister.java +++ b/Character_Linguistics/src/net/sf/anathema/character/linguistics/persistence/LinguisticsPersister.java @@ -5,9 +5,8 @@ import net.sf.anathema.character.linguistics.ILinguisticsAdditionalModel; import net.sf.anathema.character.linguistics.presenter.ILinguisticsModel; import net.sf.anathema.lib.exception.PersistenceException; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.xml.ElementUtilities; - import org.dom4j.Element; public class LinguisticsPersister implements IAdditionalPersister { @@ -21,7 +20,7 @@ public void load(Element parent, IAdditionalModel additionalModel) throws Persis ILinguisticsModel model = ((ILinguisticsAdditionalModel) additionalModel).getLinguisticsModel(); for (Element languageElement : ElementUtilities.elements(element, TAG_LANGUAGE)) { String name = languageElement.getText(); - IIdentificate language = model.getPredefinedLanguageById(name); + Identified language = model.getPredefinedLanguageById(name); if (language != null) { model.selectLanguage(language); } @@ -36,7 +35,7 @@ public void load(Element parent, IAdditionalModel additionalModel) throws Persis public void save(Element parent, IAdditionalModel additionalModel) { Element element = parent.addElement(TAG_LANGUAGES); ILinguisticsModel model = ((ILinguisticsAdditionalModel) additionalModel).getLinguisticsModel(); - for (IIdentificate language : model.getEntries()) { + for (Identified language : model.getEntries()) { Element languageElement = element.addElement(TAG_LANGUAGE); languageElement.addCDATA(language.getId()); } diff --git a/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/ILinguisticsModel.java b/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/ILinguisticsModel.java index 4a6497c470..989107cb29 100644 --- a/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/ILinguisticsModel.java +++ b/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/ILinguisticsModel.java @@ -2,19 +2,19 @@ import net.sf.anathema.character.library.removableentry.presenter.IRemovableEntryModel; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface ILinguisticsModel extends IRemovableEntryModel { +public interface ILinguisticsModel extends IRemovableEntryModel { - IIdentificate[] getPredefinedLanguages(); + Identified[] getPredefinedLanguages(); boolean isPredefinedLanguage(Object object); - IIdentificate getPredefinedLanguageById(String displayName); + Identified getPredefinedLanguageById(String displayName); void selectBarbarianLanguage(String customName); - void selectLanguage(IIdentificate language); + void selectLanguage(Identified language); boolean isEntryAllowed(); diff --git a/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/LinguisticsPresenter.java b/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/LinguisticsPresenter.java index 2dd9f4a0e1..b8f23935ba 100644 --- a/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/LinguisticsPresenter.java +++ b/Character_Linguistics/src/net/sf/anathema/character/linguistics/presenter/LinguisticsPresenter.java @@ -11,7 +11,7 @@ import net.sf.anathema.lib.control.legality.LegalityColorProvider; import net.sf.anathema.lib.gui.Presenter; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.workflow.labelledvalue.ILabelledAlotmentView; import net.sf.anathema.lib.workflow.labelledvalue.IValueView; @@ -30,8 +30,8 @@ public class LinguisticsPresenter implements Presenter { private final ILinguisticsModel model; private final ILinguisticsView view; private final IResources resources; - private final Map viewsByEntry = new HashMap(); - private final Map languagesByDisplayName = new HashMap(); + private final Map viewsByEntry = new HashMap(); + private final Map languagesByDisplayName = new HashMap(); public LinguisticsPresenter(ILinguisticsModel model, ILinguisticsView view, IResources resources) { this.model = model; @@ -53,9 +53,9 @@ private void initPointPresentation() { resources.getString("Linguistics.Overview.Barbarian"), 2); //$NON-NLS-1$ final ILabelledAlotmentView totalView = overview.addAlotmentView( resources.getString("Linguistics.Overview.Total"), 2); //$NON-NLS-1$ - model.addModelChangeListener(new IRemovableEntryListener() { + model.addModelChangeListener(new IRemovableEntryListener() { @Override - public void entryAdded(IIdentificate entry) { + public void entryAdded(Identified entry) { updateOverview(familyView, totalView, barbarianView); } @@ -65,7 +65,7 @@ public void entryAllowed(boolean complete) { } @Override - public void entryRemoved(IIdentificate entry) { + public void entryRemoved(Identified entry) { updateOverview(familyView, totalView, barbarianView); } }); @@ -130,7 +130,7 @@ public void valueChanged(Object newValue) { if (newValue == null) { return; } - IIdentificate definedLanguage = getLanguage(newValue); + Identified definedLanguage = getLanguage(newValue); if (definedLanguage == null) { model.selectBarbarianLanguage(newValue.toString()); } @@ -148,9 +148,9 @@ public void valueChanged(Object newValue) { model.commitSelection(); } }); - model.addModelChangeListener(new IRemovableEntryListener() { + model.addModelChangeListener(new IRemovableEntryListener() { @Override - public void entryAdded(IIdentificate entry) { + public void entryAdded(Identified entry) { addEntry(basicUi, entry); selectionView.setSelectedObject(null); } @@ -161,20 +161,20 @@ public void entryAllowed(boolean complete) { } @Override - public void entryRemoved(IIdentificate entry) { + public void entryRemoved(Identified entry) { IRemovableEntryView entryView = viewsByEntry.remove(entry); view.removeEntryView(entryView); } }); - for (IIdentificate language : model.getPredefinedLanguages()) { + for (Identified language : model.getPredefinedLanguages()) { languagesByDisplayName.put(getDisplayString(language), language); } - for (IIdentificate language : model.getEntries()) { + for (Identified language : model.getEntries()) { addEntry(basicUi, language); } } - private void addEntry(BasicUi basicUi, final IIdentificate language) { + private void addEntry(BasicUi basicUi, final Identified language) { IRemovableEntryView entryView = view.addEntryView(basicUi.getRemoveIcon(), null, getDisplayString(language)); viewsByEntry.put(language, entryView); entryView.addButtonListener(new ActionListener() { @@ -185,12 +185,12 @@ public void actionPerformed(ActionEvent e) { }); } - private IIdentificate getLanguage(Object anObject) { - if (anObject instanceof IIdentificate) { - return (IIdentificate) anObject; + private Identified getLanguage(Object anObject) { + if (anObject instanceof Identified) { + return (Identified) anObject; } String displayName = anObject.toString(); - IIdentificate language = languagesByDisplayName.get(displayName); + Identified language = languagesByDisplayName.get(displayName); if (language != null) { return language; } @@ -202,7 +202,7 @@ private String getDisplayString(Object object) { return null; } if (model.isPredefinedLanguage(object)) { - return resources.getString("Language." + ((IIdentificate) object).getId()); //$NON-NLS-1$ + return resources.getString("Language." + ((Identified) object).getId()); //$NON-NLS-1$ } return object.toString(); } diff --git a/Character_Linguistics/src/net/sf/anathema/character/linguistics/reporting/LinguisticsContent.java b/Character_Linguistics/src/net/sf/anathema/character/linguistics/reporting/LinguisticsContent.java index 013887fe4e..fff70105aa 100644 --- a/Character_Linguistics/src/net/sf/anathema/character/linguistics/reporting/LinguisticsContent.java +++ b/Character_Linguistics/src/net/sf/anathema/character/linguistics/reporting/LinguisticsContent.java @@ -1,47 +1,47 @@ -package net.sf.anathema.character.linguistics.reporting; - -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.linguistics.ILinguisticsAdditionalModel; -import net.sf.anathema.character.linguistics.presenter.ILinguisticsModel; -import net.sf.anathema.character.linguistics.template.LinguisticsTemplate; -import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; -import net.sf.anathema.character.reporting.pdf.content.ListSubBoxContent; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.List; - -public class LinguisticsContent extends AbstractSubBoxContent implements ListSubBoxContent { - - private IGenericCharacter character; - - public LinguisticsContent(IResources resources, IGenericCharacter character) { - super(resources); - this.character = character; - } - - @Override - public String getHeaderKey() { - return "Languages"; //$NON-NLS-1$ - } - - @Override - public List getPrintEntries() { - List printLanguages = new ArrayList(); - ILinguisticsModel model = getModel(); - for (IIdentificate language : model.getEntries()) { - String text = language.getId(); - if (model.isPredefinedLanguage(language)) { - text = getString("Language." + text); //$NON-NLS-1$ - } - printLanguages.add(text); - } - return printLanguages; - } - - private ILinguisticsModel getModel() { - ILinguisticsAdditionalModel additionalModel = (ILinguisticsAdditionalModel) character.getAdditionalModel(LinguisticsTemplate.ID); - return additionalModel.getLinguisticsModel(); - } -} +package net.sf.anathema.character.linguistics.reporting; + +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.linguistics.ILinguisticsAdditionalModel; +import net.sf.anathema.character.linguistics.presenter.ILinguisticsModel; +import net.sf.anathema.character.linguistics.template.LinguisticsTemplate; +import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; +import net.sf.anathema.character.reporting.pdf.content.ListSubBoxContent; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +public class LinguisticsContent extends AbstractSubBoxContent implements ListSubBoxContent { + + private IGenericCharacter character; + + public LinguisticsContent(IResources resources, IGenericCharacter character) { + super(resources); + this.character = character; + } + + @Override + public String getHeaderKey() { + return "Languages"; //$NON-NLS-1$ + } + + @Override + public List getPrintEntries() { + List printLanguages = new ArrayList(); + ILinguisticsModel model = getModel(); + for (Identified language : model.getEntries()) { + String text = language.getId(); + if (model.isPredefinedLanguage(language)) { + text = getString("Language." + text); //$NON-NLS-1$ + } + printLanguages.add(text); + } + return printLanguages; + } + + private ILinguisticsModel getModel() { + ILinguisticsAdditionalModel additionalModel = (ILinguisticsAdditionalModel) character.getAdditionalModel(LinguisticsTemplate.ID); + return additionalModel.getLinguisticsModel(); + } +} diff --git a/Character_Lunar/src/net/sf/anathema/character/lunar/beastform/model/BeastformNaturalSoak.java b/Character_Lunar/src/net/sf/anathema/character/lunar/beastform/model/BeastformNaturalSoak.java index bb2275d692..ef67fc4727 100644 --- a/Character_Lunar/src/net/sf/anathema/character/lunar/beastform/model/BeastformNaturalSoak.java +++ b/Character_Lunar/src/net/sf/anathema/character/lunar/beastform/model/BeastformNaturalSoak.java @@ -12,8 +12,8 @@ import net.sf.anathema.character.mutations.model.MutationVisitorAdapter; import net.sf.anathema.character.mutations.model.types.SoakProvidingMutation; import net.sf.anathema.lib.exception.UnreachableCodeReachedException; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.ArrayList; import java.util.List; @@ -117,7 +117,7 @@ public Integer getHardness(HealthType type) { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate("NaturalSoak"); //$NON-NLS-1$ } diff --git a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/GiftContent.java b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/GiftContent.java index f6e81846df..e3d03f1d64 100644 --- a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/GiftContent.java +++ b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/GiftContent.java @@ -1,51 +1,51 @@ -package net.sf.anathema.character.lunar.reporting.content; - -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.library.quality.presenter.IQualitySelection; -import net.sf.anathema.character.lunar.beastform.BeastformTemplate; -import net.sf.anathema.character.lunar.beastform.presenter.IBeastformModel; -import net.sf.anathema.character.mutations.model.IMutation; -import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; -import net.sf.anathema.character.reporting.pdf.content.ListSubBoxContent; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.List; - -public class GiftContent extends AbstractSubBoxContent implements ListSubBoxContent { - - private IGenericCharacter character; - - public GiftContent(IResources resources, IGenericCharacter character) { - super(resources); - this.character = character; - } - - @Override - public String getHeaderKey() { - return "Lunar.Gifts"; //$NON-NLS-1$ - } - - @Override - public List getPrintEntries() { - return getMutationsToPrint(); - } - - private List getMutationsToPrint() { - List printGifts = new ArrayList(); - for (IQualitySelection mutation : getModel().getMutationModel().getSelectedQualities()) { - String text = getMutationText(mutation.getQuality()); - printGifts.add(text); - } - return printGifts; - } - - private String getMutationText(IIdentificate mutation) { - return getString("Mutations.Mutation." + mutation.getId()); - } - - private IBeastformModel getModel() { - return (IBeastformModel) character.getAdditionalModel(BeastformTemplate.TEMPLATE_ID); - } -} +package net.sf.anathema.character.lunar.reporting.content; + +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.library.quality.presenter.IQualitySelection; +import net.sf.anathema.character.lunar.beastform.BeastformTemplate; +import net.sf.anathema.character.lunar.beastform.presenter.IBeastformModel; +import net.sf.anathema.character.mutations.model.IMutation; +import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; +import net.sf.anathema.character.reporting.pdf.content.ListSubBoxContent; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +public class GiftContent extends AbstractSubBoxContent implements ListSubBoxContent { + + private IGenericCharacter character; + + public GiftContent(IResources resources, IGenericCharacter character) { + super(resources); + this.character = character; + } + + @Override + public String getHeaderKey() { + return "Lunar.Gifts"; //$NON-NLS-1$ + } + + @Override + public List getPrintEntries() { + return getMutationsToPrint(); + } + + private List getMutationsToPrint() { + List printGifts = new ArrayList(); + for (IQualitySelection mutation : getModel().getMutationModel().getSelectedQualities()) { + String text = getMutationText(mutation.getQuality()); + printGifts.add(text); + } + return printGifts; + } + + private String getMutationText(Identified mutation) { + return getString("Mutations.Mutation." + mutation.getId()); + } + + private IBeastformModel getModel() { + return (IBeastformModel) character.getAdditionalModel(BeastformTemplate.TEMPLATE_ID); + } +} diff --git a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/knacks/KnackContent.java b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/knacks/KnackContent.java index a466ad6765..8fe03bb5c4 100644 --- a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/knacks/KnackContent.java +++ b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/knacks/KnackContent.java @@ -1,54 +1,54 @@ -package net.sf.anathema.character.lunar.reporting.content.knacks; - -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.lunar.reporting.content.stats.knacks.IKnackStats; -import net.sf.anathema.character.lunar.reporting.content.stats.knacks.KnackNameStatsGroup; -import net.sf.anathema.character.lunar.reporting.content.stats.knacks.KnackSourceStatsGroup; -import net.sf.anathema.character.lunar.reporting.content.stats.knacks.KnackStats; -import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; -import net.sf.anathema.character.reporting.pdf.content.stats.IStatsGroup; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import java.util.ArrayList; -import java.util.List; - -public class KnackContent extends AbstractSubBoxContent { - - private static IIdentificate KNACK = new Identificate("Knack"); - - private IGenericCharacter character; - - public KnackContent(IResources resources, IGenericCharacter character) { - super(resources); - this.character = character; - } - - public IStatsGroup[] createStatsGroups() { - IResources resources = getResources(); - return new IStatsGroup[]{new KnackNameStatsGroup(resources), new KnackSourceStatsGroup(resources)}; - } - - public List createPrintKnacks() { - List printKnacks = new ArrayList(); - ICharm[] charmSet = character.getLearnedCharms(); - for (ICharm charm : charmSet) { - if (!charm.hasAttribute(KNACK)) { - continue; - } - printKnacks.add(new KnackStats(charm)); - } - return printKnacks; - } - - @Override - public String getHeaderKey() { - return "Lunar.Knacks"; - } - - public String getGroupLabel(IKnackStats stats) { - return stats.getGroupName(getResources()); - } -} +package net.sf.anathema.character.lunar.reporting.content.knacks; + +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.lunar.reporting.content.stats.knacks.IKnackStats; +import net.sf.anathema.character.lunar.reporting.content.stats.knacks.KnackNameStatsGroup; +import net.sf.anathema.character.lunar.reporting.content.stats.knacks.KnackSourceStatsGroup; +import net.sf.anathema.character.lunar.reporting.content.stats.knacks.KnackStats; +import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; +import net.sf.anathema.character.reporting.pdf.content.stats.IStatsGroup; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +public class KnackContent extends AbstractSubBoxContent { + + private static Identified KNACK = new Identificate("Knack"); + + private IGenericCharacter character; + + public KnackContent(IResources resources, IGenericCharacter character) { + super(resources); + this.character = character; + } + + public IStatsGroup[] createStatsGroups() { + IResources resources = getResources(); + return new IStatsGroup[]{new KnackNameStatsGroup(resources), new KnackSourceStatsGroup(resources)}; + } + + public List createPrintKnacks() { + List printKnacks = new ArrayList(); + ICharm[] charmSet = character.getLearnedCharms(); + for (ICharm charm : charmSet) { + if (!charm.hasAttribute(KNACK)) { + continue; + } + printKnacks.add(new KnackStats(charm)); + } + return printKnacks; + } + + @Override + public String getHeaderKey() { + return "Lunar.Knacks"; + } + + public String getGroupLabel(IKnackStats stats) { + return stats.getGroupName(getResources()); + } +} diff --git a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/IKnackStats.java b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/IKnackStats.java index 59acd9ee3b..4241fd99f2 100644 --- a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/IKnackStats.java +++ b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/IKnackStats.java @@ -2,12 +2,12 @@ import net.sf.anathema.character.generic.util.IStats; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IKnackStats extends IStats { @Override - IIdentificate getName(); + Identified getName(); String getGroupName(IResources resources); diff --git a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/KnackStats.java b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/KnackStats.java index 70eea5627e..82b425ab83 100644 --- a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/KnackStats.java +++ b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/content/stats/knacks/KnackStats.java @@ -2,8 +2,8 @@ import net.sf.anathema.character.generic.magic.ICharm; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; public class KnackStats implements IKnackStats { @@ -19,7 +19,7 @@ public String getGroupName(IResources resources) { } @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate(charm.getId()); } diff --git a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/rendering/heartsblood/SecondEditionLunarHeartsBloodEncoder.java b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/rendering/heartsblood/SecondEditionLunarHeartsBloodEncoder.java index d1912e44a8..2f3ad316cc 100644 --- a/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/rendering/heartsblood/SecondEditionLunarHeartsBloodEncoder.java +++ b/Character_Lunar/src/net/sf/anathema/character/lunar/reporting/rendering/heartsblood/SecondEditionLunarHeartsBloodEncoder.java @@ -19,8 +19,8 @@ import net.sf.anathema.character.reporting.pdf.rendering.general.stats.AbstractStatsTableEncoder; import net.sf.anathema.character.reporting.pdf.rendering.graphics.SheetGraphics; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.ArrayList; import java.util.List; @@ -44,7 +44,7 @@ protected IHeartsBloodStats[] getPrintStats(ReportSession session) { for (final IAnimalForm form : model.getEntries()) { stats.add(new IHeartsBloodStats() { @Override - public IIdentificate getName() { + public Identified getName() { return new Identificate(form.getName()); } diff --git a/Character_Main/src/net/sf/anathema/character/model/charm/ICharmConfiguration.java b/Character_Main/src/net/sf/anathema/character/model/charm/ICharmConfiguration.java index 10686eab52..7ddb0da41f 100644 --- a/Character_Main/src/net/sf/anathema/character/model/charm/ICharmConfiguration.java +++ b/Character_Main/src/net/sf/anathema/character/model/charm/ICharmConfiguration.java @@ -8,7 +8,7 @@ import net.sf.anathema.charmtree.presenter.CharmFilterContainer; import net.sf.anathema.charmtree.presenter.view.ICharmGroupArbitrator; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ICharmConfiguration extends CharmFilterContainer, IExtendedCharmLearnableArbitrator, ICharmGroupArbitrator, ICharmIdMap { @@ -26,7 +26,7 @@ public interface ICharmConfiguration extends CharmFilterContainer, IExtendedChar ICharm[] getExperienceLearnedCharms(); - ILearningCharmGroup[] getCharmGroups(IIdentificate type); + ILearningCharmGroup[] getCharmGroups(Identified type); ICharm[] getLearnedCharms(boolean experienced); diff --git a/Character_Main/src/net/sf/anathema/character/model/traits/ICoreTraitConfiguration.java b/Character_Main/src/net/sf/anathema/character/model/traits/ICoreTraitConfiguration.java index 73c283ec92..12078681c4 100644 --- a/Character_Main/src/net/sf/anathema/character/model/traits/ICoreTraitConfiguration.java +++ b/Character_Main/src/net/sf/anathema/character/model/traits/ICoreTraitConfiguration.java @@ -6,7 +6,7 @@ import net.sf.anathema.character.library.trait.favorable.IFavorableTrait; import net.sf.anathema.character.library.trait.specialties.ISpecialtiesConfiguration; import net.sf.anathema.character.model.background.IBackgroundConfiguration; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ICoreTraitConfiguration extends ITraitCollection { @@ -22,5 +22,5 @@ public interface ICoreTraitConfiguration extends ITraitCollection { IFavorableTrait[] getAllAbilities(); - IIdentificate getAbilityGroupId(AbilityType abilityType); + Identified getAbilityGroupId(AbilityType abilityType); } \ No newline at end of file diff --git a/Character_Main/src/net/sf/anathema/character/model/traits/abilities/IAbilityGroup.java b/Character_Main/src/net/sf/anathema/character/model/traits/abilities/IAbilityGroup.java index e39c1c4828..7c93474506 100644 --- a/Character_Main/src/net/sf/anathema/character/model/traits/abilities/IAbilityGroup.java +++ b/Character_Main/src/net/sf/anathema/character/model/traits/abilities/IAbilityGroup.java @@ -1,9 +1,9 @@ package net.sf.anathema.character.model.traits.abilities; import net.sf.anathema.character.library.trait.IFavorableDefaultTrait; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IAbilityGroup extends IIdentificate { +public interface IAbilityGroup extends Identified { IFavorableDefaultTrait[] getAbilities(); } \ No newline at end of file diff --git a/Character_Main/src/net/sf/anathema/character/model/traits/attributes/IAttributeGroup.java b/Character_Main/src/net/sf/anathema/character/model/traits/attributes/IAttributeGroup.java index 04fac410ea..920aba6b28 100644 --- a/Character_Main/src/net/sf/anathema/character/model/traits/attributes/IAttributeGroup.java +++ b/Character_Main/src/net/sf/anathema/character/model/traits/attributes/IAttributeGroup.java @@ -2,9 +2,9 @@ import net.sf.anathema.character.generic.traits.types.AttributeType; import net.sf.anathema.character.library.trait.visitor.IDefaultTrait; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IAttributeGroup extends IIdentificate { +public interface IAttributeGroup extends Identified { boolean containsAttribute(AttributeType type); diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/AbstractCharmTypes.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/AbstractCharmTypes.java index d9c5591202..c2aab5c392 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/AbstractCharmTypes.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/AbstractCharmTypes.java @@ -1,25 +1,25 @@ -package net.sf.anathema.character.presenter.magic; - -import net.sf.anathema.charmtree.presenter.CharmTypes; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.List; - -import static net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities.MARTIAL_ARTS; - -public abstract class AbstractCharmTypes implements CharmTypes { - - @Override - public IIdentificate[] getCurrentCharmTypes() { - List types = new ArrayList(); - types.addAll(getCurrentCharacterTypes()); - types.addAll(getAdditionalCharmTypes()); - types.add(MARTIAL_ARTS); - return types.toArray(new IIdentificate[types.size()]); - } - - protected abstract List getCurrentCharacterTypes(); - - protected abstract List getAdditionalCharmTypes(); -} +package net.sf.anathema.character.presenter.magic; + +import net.sf.anathema.charmtree.presenter.CharmTypes; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +import static net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities.MARTIAL_ARTS; + +public abstract class AbstractCharmTypes implements CharmTypes { + + @Override + public Identified[] getCurrentCharmTypes() { + List types = new ArrayList(); + types.addAll(getCurrentCharacterTypes()); + types.addAll(getAdditionalCharmTypes()); + types.add(MARTIAL_ARTS); + return types.toArray(new Identified[types.size()]); + } + + protected abstract List getCurrentCharacterTypes(); + + protected abstract List getAdditionalCharmTypes(); +} diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterAlienCharmPresenter.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterAlienCharmPresenter.java index 13581d491d..fdf53436c9 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterAlienCharmPresenter.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterAlienCharmPresenter.java @@ -1,34 +1,34 @@ -package net.sf.anathema.character.presenter.magic; - -import net.sf.anathema.character.model.charm.ICharmConfiguration; -import net.sf.anathema.charmtree.presenter.AlienCharmPresenter; -import net.sf.anathema.charmtree.presenter.view.ICharmView; -import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; - -public class CharacterAlienCharmPresenter implements AlienCharmPresenter { - - private ICharmView view; - private CharacterCharmModel model; - - public CharacterAlienCharmPresenter(CharacterCharmModel model, ICharmView view) { - this.model = model; - this.view = view; - } - - @Override - public void initPresentation() { - model.addCasteChangeListener(new IChangeListener() { - @Override - public void changeOccurred() { - boolean alienCharms = model.isAllowedAlienCharms(); - ICharmConfiguration charmConfiguration = model.getCharmConfiguration(); - if (!alienCharms) { - charmConfiguration.unlearnAllAlienCharms(); - } - IIdentificate[] currentCharmTypes = new CharacterCharmTypes(model).getCurrentCharmTypes(); - view.fillCharmTypeBox(currentCharmTypes); - } - }); - } -} +package net.sf.anathema.character.presenter.magic; + +import net.sf.anathema.character.model.charm.ICharmConfiguration; +import net.sf.anathema.charmtree.presenter.AlienCharmPresenter; +import net.sf.anathema.charmtree.presenter.view.ICharmView; +import net.sf.anathema.lib.control.IChangeListener; +import net.sf.anathema.lib.util.Identified; + +public class CharacterAlienCharmPresenter implements AlienCharmPresenter { + + private ICharmView view; + private CharacterCharmModel model; + + public CharacterAlienCharmPresenter(CharacterCharmModel model, ICharmView view) { + this.model = model; + this.view = view; + } + + @Override + public void initPresentation() { + model.addCasteChangeListener(new IChangeListener() { + @Override + public void changeOccurred() { + boolean alienCharms = model.isAllowedAlienCharms(); + ICharmConfiguration charmConfiguration = model.getCharmConfiguration(); + if (!alienCharms) { + charmConfiguration.unlearnAllAlienCharms(); + } + Identified[] currentCharmTypes = new CharacterCharmTypes(model).getCurrentCharmTypes(); + view.fillCharmTypeBox(currentCharmTypes); + } + }); + } +} diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmGroupChangeListener.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmGroupChangeListener.java index 4d32baca72..2431df7023 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmGroupChangeListener.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmGroupChangeListener.java @@ -1,28 +1,28 @@ -package net.sf.anathema.character.presenter.magic; - -import net.sf.anathema.character.model.charm.ILearningCharmGroup; -import net.sf.anathema.charmtree.presenter.CharmFilterSet; -import net.sf.anathema.charmtree.presenter.view.AbstractCharmGroupChangeListener; -import net.sf.anathema.charmtree.presenter.view.CharmDisplayPropertiesMap; -import net.sf.anathema.charmtree.presenter.view.CharmTreeRenderer; -import net.sf.anathema.charmtree.presenter.view.ICharmGroupArbitrator; -import net.sf.anathema.lib.util.IIdentificate; - -public class CharacterCharmGroupChangeListener extends AbstractCharmGroupChangeListener { - - public CharacterCharmGroupChangeListener(ICharmGroupArbitrator arbitrator, CharmFilterSet charmFilterSet, - CharmTreeRenderer treeRenderer, - CharmDisplayPropertiesMap displayPropertiesMap) { - super(arbitrator, charmFilterSet, treeRenderer, displayPropertiesMap); - } - - @Override - protected void modifyCharmVisuals(IIdentificate type) { - // Nothing to do - } - - @Override - public ILearningCharmGroup getCurrentGroup() { - return (ILearningCharmGroup) super.getCurrentGroup(); - } -} +package net.sf.anathema.character.presenter.magic; + +import net.sf.anathema.character.model.charm.ILearningCharmGroup; +import net.sf.anathema.charmtree.presenter.CharmFilterSet; +import net.sf.anathema.charmtree.presenter.view.AbstractCharmGroupChangeListener; +import net.sf.anathema.charmtree.presenter.view.CharmDisplayPropertiesMap; +import net.sf.anathema.charmtree.presenter.view.CharmTreeRenderer; +import net.sf.anathema.charmtree.presenter.view.ICharmGroupArbitrator; +import net.sf.anathema.lib.util.Identified; + +public class CharacterCharmGroupChangeListener extends AbstractCharmGroupChangeListener { + + public CharacterCharmGroupChangeListener(ICharmGroupArbitrator arbitrator, CharmFilterSet charmFilterSet, + CharmTreeRenderer treeRenderer, + CharmDisplayPropertiesMap displayPropertiesMap) { + super(arbitrator, charmFilterSet, treeRenderer, displayPropertiesMap); + } + + @Override + protected void modifyCharmVisuals(Identified type) { + // Nothing to do + } + + @Override + public ILearningCharmGroup getCurrentGroup() { + return (ILearningCharmGroup) super.getCurrentGroup(); + } +} diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmTypes.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmTypes.java index 333e21aef0..fe0247b712 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmTypes.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterCharmTypes.java @@ -1,35 +1,35 @@ -package net.sf.anathema.character.presenter.magic; - -import com.google.common.collect.Lists; -import net.sf.anathema.character.generic.template.magic.IUniqueCharmType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.List; - -public class CharacterCharmTypes extends AbstractCharmTypes { - - private CharacterCharmModel model; - - public CharacterCharmTypes(CharacterCharmModel model) { - this.model = model; - } - - @Override - protected List getCurrentCharacterTypes() { - boolean alienCharms = model.isAllowedAlienCharms(); - ICharacterType[] characterTypes = model.getCharmConfiguration().getCharacterTypes(alienCharms); - return Lists.newArrayList(characterTypes); - } - - @Override - protected List getAdditionalCharmTypes() { - List typeIds = new ArrayList(); - if (model.hasUniqueCharmType()) { - IUniqueCharmType uniqueType = model.getUniqueCharmType(); - typeIds.add(uniqueType.getId()); - } - return typeIds; - } -} +package net.sf.anathema.character.presenter.magic; + +import com.google.common.collect.Lists; +import net.sf.anathema.character.generic.template.magic.IUniqueCharmType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +public class CharacterCharmTypes extends AbstractCharmTypes { + + private CharacterCharmModel model; + + public CharacterCharmTypes(CharacterCharmModel model) { + this.model = model; + } + + @Override + protected List getCurrentCharacterTypes() { + boolean alienCharms = model.isAllowedAlienCharms(); + ICharacterType[] characterTypes = model.getCharmConfiguration().getCharacterTypes(alienCharms); + return Lists.newArrayList(characterTypes); + } + + @Override + protected List getAdditionalCharmTypes() { + List typeIds = new ArrayList(); + if (model.hasUniqueCharmType()) { + IUniqueCharmType uniqueType = model.getUniqueCharmType(); + typeIds.add(uniqueType.getId()); + } + return typeIds; + } +} diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterGroupCharmTree.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterGroupCharmTree.java index 5a952b566c..6dd1185787 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterGroupCharmTree.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/CharacterGroupCharmTree.java @@ -1,20 +1,20 @@ -package net.sf.anathema.character.presenter.magic; - -import net.sf.anathema.character.generic.magic.charms.GroupCharmTree; -import net.sf.anathema.character.generic.magic.charms.ICharmGroup; -import net.sf.anathema.lib.util.IIdentificate; - -public final class CharacterGroupCharmTree implements GroupCharmTree { - private final IIdentificate cascadeType; - private CharacterCharmModel model; - - public CharacterGroupCharmTree(CharacterCharmModel model, IIdentificate cascadeType) { - this.cascadeType = cascadeType; - this.model = model; - } - - @Override - public ICharmGroup[] getAllCharmGroups() { - return model.getCharmConfiguration().getCharmGroups(cascadeType); - } -} +package net.sf.anathema.character.presenter.magic; + +import net.sf.anathema.character.generic.magic.charms.GroupCharmTree; +import net.sf.anathema.character.generic.magic.charms.ICharmGroup; +import net.sf.anathema.lib.util.Identified; + +public final class CharacterGroupCharmTree implements GroupCharmTree { + private final Identified cascadeType; + private CharacterCharmModel model; + + public CharacterGroupCharmTree(CharacterCharmModel model, Identified cascadeType) { + this.cascadeType = cascadeType; + this.model = model; + } + + @Override + public ICharmGroup[] getAllCharmGroups() { + return model.getCharmConfiguration().getCharmGroups(cascadeType); + } +} diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/charm/CharacterCharmTreePresenter.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/charm/CharacterCharmTreePresenter.java index ea07ddf4b6..d01f5c74d8 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/charm/CharacterCharmTreePresenter.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/charm/CharacterCharmTreePresenter.java @@ -1,70 +1,70 @@ -package net.sf.anathema.character.presenter.magic.charm; - -import net.sf.anathema.character.generic.magic.charms.GroupCharmTree; -import net.sf.anathema.character.presenter.magic.CharacterAlienCharmPresenter; -import net.sf.anathema.character.presenter.magic.CharacterCharmDye; -import net.sf.anathema.character.presenter.magic.CharacterCharmGroupChangeListener; -import net.sf.anathema.character.presenter.magic.CharacterCharmModel; -import net.sf.anathema.character.presenter.magic.CharacterCharmTreeViewProperties; -import net.sf.anathema.character.presenter.magic.CharacterCharmTypes; -import net.sf.anathema.character.presenter.magic.CharacterGroupCharmTree; -import net.sf.anathema.character.presenter.magic.CharacterGroupCollection; -import net.sf.anathema.character.presenter.magic.CharacterSpecialCharmPresenter; -import net.sf.anathema.character.presenter.magic.LearnInteractionPresenter; -import net.sf.anathema.character.presenter.magic.detail.DetailDemandingMagicPresenter; -import net.sf.anathema.character.presenter.magic.detail.ShowMagicDetailListener; -import net.sf.anathema.character.view.magic.IMagicViewFactory; -import net.sf.anathema.charmtree.presenter.AbstractCascadePresenter; -import net.sf.anathema.charmtree.presenter.CharmFilterContainer; -import net.sf.anathema.charmtree.presenter.view.CharmDisplayPropertiesMap; -import net.sf.anathema.charmtree.presenter.view.ICharmTreeViewProperties; -import net.sf.anathema.charmtree.presenter.view.ICharmView; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.platform.svgtree.document.visualizer.ITreePresentationProperties; - -public class CharacterCharmTreePresenter extends AbstractCascadePresenter implements DetailDemandingMagicPresenter { - - private final ICharmView view; - private final CharacterCharmModel model; - - public CharacterCharmTreePresenter(IResources resources, IMagicViewFactory factory, CharacterCharmModel charmModel, - ITreePresentationProperties presentationProperties, CharmDisplayPropertiesMap displayPropertiesMap) { - super(resources); - this.model = charmModel; - ICharmTreeViewProperties viewProperties = new CharacterCharmTreeViewProperties(resources, model.getCharmConfiguration(), model.getMagicDescriptionProvider()); - this.view = factory.createCharmSelectionView(viewProperties); - CharacterCharmGroupChangeListener charmGroupChangeListener = new CharacterCharmGroupChangeListener(model.getCharmConfiguration(), filterSet, - view.getCharmTreeRenderer(), - displayPropertiesMap); - CharacterCharmDye dye = new CharacterCharmDye(model, charmGroupChangeListener, presentationProperties.getColor(), view); - setCharmTypes(new CharacterCharmTypes(charmModel)); - setChangeListener(charmGroupChangeListener); - setView(view); - setSpecialPresenter(new CharacterSpecialCharmPresenter(view, resources, charmGroupChangeListener, charmModel, presentationProperties)); - setCharmDye(dye); - setAlienCharmPresenter(new CharacterAlienCharmPresenter(model, view)); - setInteractionPresenter(new LearnInteractionPresenter(model, view, charmGroupChangeListener, viewProperties, dye)); - setCharmGroups(new CharacterGroupCollection(model)); - } - - @Override - public ICharmView getView() { - return view; - } - - @Override - protected CharmFilterContainer getFilterContainer() { - return model.getCharmConfiguration(); - } - - @Override - protected GroupCharmTree getCharmTree(IIdentificate cascadeType) { - return new CharacterGroupCharmTree(model, cascadeType); - } - - @Override - public void addShowDetailListener(ShowMagicDetailListener listener) { - view.addCharmInteractionListener(new ShowDetailInteractionListener(listener)); - } -} +package net.sf.anathema.character.presenter.magic.charm; + +import net.sf.anathema.character.generic.magic.charms.GroupCharmTree; +import net.sf.anathema.character.presenter.magic.CharacterAlienCharmPresenter; +import net.sf.anathema.character.presenter.magic.CharacterCharmDye; +import net.sf.anathema.character.presenter.magic.CharacterCharmGroupChangeListener; +import net.sf.anathema.character.presenter.magic.CharacterCharmModel; +import net.sf.anathema.character.presenter.magic.CharacterCharmTreeViewProperties; +import net.sf.anathema.character.presenter.magic.CharacterCharmTypes; +import net.sf.anathema.character.presenter.magic.CharacterGroupCharmTree; +import net.sf.anathema.character.presenter.magic.CharacterGroupCollection; +import net.sf.anathema.character.presenter.magic.CharacterSpecialCharmPresenter; +import net.sf.anathema.character.presenter.magic.LearnInteractionPresenter; +import net.sf.anathema.character.presenter.magic.detail.DetailDemandingMagicPresenter; +import net.sf.anathema.character.presenter.magic.detail.ShowMagicDetailListener; +import net.sf.anathema.character.view.magic.IMagicViewFactory; +import net.sf.anathema.charmtree.presenter.AbstractCascadePresenter; +import net.sf.anathema.charmtree.presenter.CharmFilterContainer; +import net.sf.anathema.charmtree.presenter.view.CharmDisplayPropertiesMap; +import net.sf.anathema.charmtree.presenter.view.ICharmTreeViewProperties; +import net.sf.anathema.charmtree.presenter.view.ICharmView; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; +import net.sf.anathema.platform.svgtree.document.visualizer.ITreePresentationProperties; + +public class CharacterCharmTreePresenter extends AbstractCascadePresenter implements DetailDemandingMagicPresenter { + + private final ICharmView view; + private final CharacterCharmModel model; + + public CharacterCharmTreePresenter(IResources resources, IMagicViewFactory factory, CharacterCharmModel charmModel, + ITreePresentationProperties presentationProperties, CharmDisplayPropertiesMap displayPropertiesMap) { + super(resources); + this.model = charmModel; + ICharmTreeViewProperties viewProperties = new CharacterCharmTreeViewProperties(resources, model.getCharmConfiguration(), model.getMagicDescriptionProvider()); + this.view = factory.createCharmSelectionView(viewProperties); + CharacterCharmGroupChangeListener charmGroupChangeListener = new CharacterCharmGroupChangeListener(model.getCharmConfiguration(), filterSet, + view.getCharmTreeRenderer(), + displayPropertiesMap); + CharacterCharmDye dye = new CharacterCharmDye(model, charmGroupChangeListener, presentationProperties.getColor(), view); + setCharmTypes(new CharacterCharmTypes(charmModel)); + setChangeListener(charmGroupChangeListener); + setView(view); + setSpecialPresenter(new CharacterSpecialCharmPresenter(view, resources, charmGroupChangeListener, charmModel, presentationProperties)); + setCharmDye(dye); + setAlienCharmPresenter(new CharacterAlienCharmPresenter(model, view)); + setInteractionPresenter(new LearnInteractionPresenter(model, view, charmGroupChangeListener, viewProperties, dye)); + setCharmGroups(new CharacterGroupCollection(model)); + } + + @Override + public ICharmView getView() { + return view; + } + + @Override + protected CharmFilterContainer getFilterContainer() { + return model.getCharmConfiguration(); + } + + @Override + protected GroupCharmTree getCharmTree(Identified cascadeType) { + return new CharacterGroupCharmTree(model, cascadeType); + } + + @Override + public void addShowDetailListener(ShowMagicDetailListener listener) { + view.addCharmInteractionListener(new ShowDetailInteractionListener(listener)); + } +} diff --git a/Character_Main/src/net/sf/anathema/character/presenter/magic/spells/SpellPresenter.java b/Character_Main/src/net/sf/anathema/character/presenter/magic/spells/SpellPresenter.java index 854faa608e..5b2005ea39 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/magic/spells/SpellPresenter.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/magic/spells/SpellPresenter.java @@ -18,7 +18,7 @@ import net.sf.anathema.lib.control.ObjectValueListener; import net.sf.anathema.lib.gui.IView; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.JList; import javax.swing.event.ListSelectionEvent; @@ -63,7 +63,7 @@ public SpellPresenter(SpellModel spellModel, ICharacter character, IResources re @Override public void initPresentation() { - IIdentificate[] allowedCircles = spellModel.getCircles(); + Identified[] allowedCircles = spellModel.getCircles(); view.initGui(allowedCircles); view.addMagicViewListener(new IMagicViewListener() { @Override diff --git a/Character_Main/src/net/sf/anathema/character/presenter/overview/IOverviewModel.java b/Character_Main/src/net/sf/anathema/character/presenter/overview/IOverviewModel.java index ce0d535879..f4f8d73c89 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/overview/IOverviewModel.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/overview/IOverviewModel.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.presenter.overview; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IOverviewModel extends IIdentificate { +public interface IOverviewModel extends Identified { void accept(IOverviewModelVisitor visitor); diff --git a/Character_Main/src/net/sf/anathema/character/presenter/util/I18nComparator.java b/Character_Main/src/net/sf/anathema/character/presenter/util/I18nComparator.java index 488a220c41..6ce54f3f1f 100644 --- a/Character_Main/src/net/sf/anathema/character/presenter/util/I18nComparator.java +++ b/Character_Main/src/net/sf/anathema/character/presenter/util/I18nComparator.java @@ -1,11 +1,11 @@ package net.sf.anathema.character.presenter.util; -import java.util.Comparator; - import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.Comparator; -public class I18nComparator implements Comparator { +public class I18nComparator implements Comparator { private final String resourceKeyPrefix; private final IResources resources; @@ -16,7 +16,7 @@ public I18nComparator(IResources resources, String resourceKeyPrefix) { } @Override - public int compare(IIdentificate identificate1, IIdentificate identificate2) { + public int compare(Identified identificate1, Identified identificate2) { String firstDescription = resources.getString(resourceKeyPrefix + identificate1.getId()); String secondDescription = resources.getString(resourceKeyPrefix + identificate2.getId()); return firstDescription.compareToIgnoreCase(secondDescription); diff --git a/Character_Main/src/net/sf/anathema/character/view/magic/ISpellView.java b/Character_Main/src/net/sf/anathema/character/view/magic/ISpellView.java index 6e9989407a..fbf7cd2e62 100644 --- a/Character_Main/src/net/sf/anathema/character/view/magic/ISpellView.java +++ b/Character_Main/src/net/sf/anathema/character/view/magic/ISpellView.java @@ -4,11 +4,11 @@ import net.sf.anathema.character.generic.magic.spells.CircleType; import net.sf.anathema.lib.control.ObjectValueListener; import net.sf.anathema.lib.gui.IView; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface ISpellView extends IView, IMagicLearnView { - void initGui(IIdentificate[] circles); + void initGui(Identified[] circles); void addCircleSelectionListener(ObjectValueListener listener); } \ No newline at end of file diff --git a/Character_Main/test/net/sf/anathema/character/generic/dummy/magic/DummyCharmConfiguration.java b/Character_Main/test/net/sf/anathema/character/generic/dummy/magic/DummyCharmConfiguration.java index 3289d27071..0429d4b78c 100644 --- a/Character_Main/test/net/sf/anathema/character/generic/dummy/magic/DummyCharmConfiguration.java +++ b/Character_Main/test/net/sf/anathema/character/generic/dummy/magic/DummyCharmConfiguration.java @@ -1,182 +1,182 @@ -package net.sf.anathema.character.generic.dummy.magic; - -import net.sf.anathema.character.generic.impl.template.magic.ICharmProvider; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.charms.ICharmAttributeRequirement; -import net.sf.anathema.character.generic.magic.charms.ICharmGroup; -import net.sf.anathema.character.generic.magic.charms.ICharmIdMap; -import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharm; -import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharmConfiguration; -import net.sf.anathema.character.generic.type.CharacterType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.character.model.charm.ICharmConfiguration; -import net.sf.anathema.character.model.charm.ICharmLearnListener; -import net.sf.anathema.character.model.charm.ILearningCharmGroup; -import net.sf.anathema.charmtree.filters.ICharmFilter; -import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.exception.NotYetImplementedException; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.List; - -public class DummyCharmConfiguration implements ICharmConfiguration { - - private ICharm[] charms = new ICharm[0]; - - @Override - public void addLearnableListener(IChangeListener listener) { - throw new NotYetImplementedException(); - } - - @Override - public boolean isLearned(ICharm charm) { - throw new NotYetImplementedException(); - } - - @Override - public ICharm[] getCreationLearnedCharms() { - return charms; - } - - @Override - public void addCharmLearnListener(ICharmLearnListener listener) { - throw new NotYetImplementedException(); - } - - @Override - public boolean isLearned(String charmId) { - throw new NotYetImplementedException(); - } - - @Override - public ISpecialCharmConfiguration getSpecialCharmConfiguration(String charmId) { - return null; - } - - @Override - public boolean isLearnable(String charmId) { - throw new NotYetImplementedException(); - } - - @Override - public ILearningCharmGroup[] getCharmGroups(IIdentificate type) { - throw new NotYetImplementedException(); - } - - @Override - public boolean isUnlearnable(String charmId) { - throw new NotYetImplementedException(); - } - - @Override - public ICharm[] getExperienceLearnedCharms() { - return new ICharm[0]; - } - - @Override - public ICharm[] getLearnedCharms(boolean experienced) { - return charms; - } - - @Override - public boolean isLearnable(ICharm charm) { - throw new NotYetImplementedException(); - } - - @Override - public ICharm getCharmById(String charmId) { - throw new NotYetImplementedException(); - } - - public ICharacterType getCharacterType() { - throw new NotYetImplementedException(); - } - - public boolean isCelestialMartialArtsGroupCompleted() { - return false; - } - - @Override - public boolean isCompulsiveCharm(ICharm charm) { - return false; - } - - public boolean isFullfilled(ICharmAttributeRequirement requirement) { - return true; - } - - @Override - public String[] getUncompletedCelestialMartialArtsGroups() { - return new String[0]; - } - - @Override - public ILearningCharmGroup[] getAllGroups() { - throw new NotYetImplementedException(); - } - - @Override - public void unlearnAllAlienCharms() { - throw new NotYetImplementedException(); - } - - @Override - public boolean isAlienCharm(ICharm charm) { - for (ICharm currentCharm : charms) { - if (charm == currentCharm) { - return true; - } - } - return false; - } - - @Override - public ISpecialCharmConfiguration getSpecialCharmConfiguration(ICharm charm) { - return null; - } - - @Override - public ILearningCharmGroup getGroup(ICharm charm) { - throw new NotYetImplementedException(); - } - - @Override - public CharacterType[] getCharacterTypes(boolean includeAlienTypes) { - throw new NotYetImplementedException(); - } - - @Override - public ILearningCharmGroup getGroup(String characterType, String groupName) { - throw new NotYetImplementedException(); - } - - public ICharmProvider getCharmProvider() { - throw new NotYetImplementedException(); - } - - @Override - public ICharm[] getCharms(ICharmGroup charmGroup) { - return charmGroup.getAllCharms(); - } - - @Override - public ICharmIdMap getCharmIdMap() { - throw new NotYetImplementedException(); - } - - @Override - public ISpecialCharm[] getSpecialCharms() { - throw new NotYetImplementedException(); - } - - @Override - public List getCharmFilters() { - return null; - } - - @Override - public String getCharmTrueName(String charmName) { - // TODO Auto-generated method stub - return null; - } +package net.sf.anathema.character.generic.dummy.magic; + +import net.sf.anathema.character.generic.impl.template.magic.ICharmProvider; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.charms.ICharmAttributeRequirement; +import net.sf.anathema.character.generic.magic.charms.ICharmGroup; +import net.sf.anathema.character.generic.magic.charms.ICharmIdMap; +import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharm; +import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharmConfiguration; +import net.sf.anathema.character.generic.type.CharacterType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.character.model.charm.ICharmConfiguration; +import net.sf.anathema.character.model.charm.ICharmLearnListener; +import net.sf.anathema.character.model.charm.ILearningCharmGroup; +import net.sf.anathema.charmtree.filters.ICharmFilter; +import net.sf.anathema.lib.control.IChangeListener; +import net.sf.anathema.lib.exception.NotYetImplementedException; +import net.sf.anathema.lib.util.Identified; + +import java.util.List; + +public class DummyCharmConfiguration implements ICharmConfiguration { + + private ICharm[] charms = new ICharm[0]; + + @Override + public void addLearnableListener(IChangeListener listener) { + throw new NotYetImplementedException(); + } + + @Override + public boolean isLearned(ICharm charm) { + throw new NotYetImplementedException(); + } + + @Override + public ICharm[] getCreationLearnedCharms() { + return charms; + } + + @Override + public void addCharmLearnListener(ICharmLearnListener listener) { + throw new NotYetImplementedException(); + } + + @Override + public boolean isLearned(String charmId) { + throw new NotYetImplementedException(); + } + + @Override + public ISpecialCharmConfiguration getSpecialCharmConfiguration(String charmId) { + return null; + } + + @Override + public boolean isLearnable(String charmId) { + throw new NotYetImplementedException(); + } + + @Override + public ILearningCharmGroup[] getCharmGroups(Identified type) { + throw new NotYetImplementedException(); + } + + @Override + public boolean isUnlearnable(String charmId) { + throw new NotYetImplementedException(); + } + + @Override + public ICharm[] getExperienceLearnedCharms() { + return new ICharm[0]; + } + + @Override + public ICharm[] getLearnedCharms(boolean experienced) { + return charms; + } + + @Override + public boolean isLearnable(ICharm charm) { + throw new NotYetImplementedException(); + } + + @Override + public ICharm getCharmById(String charmId) { + throw new NotYetImplementedException(); + } + + public ICharacterType getCharacterType() { + throw new NotYetImplementedException(); + } + + public boolean isCelestialMartialArtsGroupCompleted() { + return false; + } + + @Override + public boolean isCompulsiveCharm(ICharm charm) { + return false; + } + + public boolean isFullfilled(ICharmAttributeRequirement requirement) { + return true; + } + + @Override + public String[] getUncompletedCelestialMartialArtsGroups() { + return new String[0]; + } + + @Override + public ILearningCharmGroup[] getAllGroups() { + throw new NotYetImplementedException(); + } + + @Override + public void unlearnAllAlienCharms() { + throw new NotYetImplementedException(); + } + + @Override + public boolean isAlienCharm(ICharm charm) { + for (ICharm currentCharm : charms) { + if (charm == currentCharm) { + return true; + } + } + return false; + } + + @Override + public ISpecialCharmConfiguration getSpecialCharmConfiguration(ICharm charm) { + return null; + } + + @Override + public ILearningCharmGroup getGroup(ICharm charm) { + throw new NotYetImplementedException(); + } + + @Override + public CharacterType[] getCharacterTypes(boolean includeAlienTypes) { + throw new NotYetImplementedException(); + } + + @Override + public ILearningCharmGroup getGroup(String characterType, String groupName) { + throw new NotYetImplementedException(); + } + + public ICharmProvider getCharmProvider() { + throw new NotYetImplementedException(); + } + + @Override + public ICharm[] getCharms(ICharmGroup charmGroup) { + return charmGroup.getAllCharms(); + } + + @Override + public ICharmIdMap getCharmIdMap() { + throw new NotYetImplementedException(); + } + + @Override + public ISpecialCharm[] getSpecialCharms() { + throw new NotYetImplementedException(); + } + + @Override + public List getCharmFilters() { + return null; + } + + @Override + public String getCharmTrueName(String charmName) { + // TODO Auto-generated method stub + return null; + } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/charm/CharmConfiguration.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/charm/CharmConfiguration.java index 57b4a0285c..db89d3f222 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/charm/CharmConfiguration.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/charm/CharmConfiguration.java @@ -44,7 +44,7 @@ import net.sf.anathema.charmtree.filters.ICharmFilter; import net.sf.anathema.lib.collection.ArrayUtilities; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import org.jmock.example.announcer.Announcer; import java.util.ArrayList; @@ -58,8 +58,8 @@ public class CharmConfiguration implements ICharmConfiguration { private final ISpecialCharmManager manager; private final MartialArtsCharmTree martialArtsCharmTree; - private final Map alienTreesByType = new HashMap(); - private final Map nonMartialArtsGroupsByType = new HashMap(); + private final Map alienTreesByType = new HashMap(); + private final Map nonMartialArtsGroupsByType = new HashMap(); private final Map templatesByType = new HashMap(); private final ICharacterType[] types; private final ILearningCharmGroupContainer learningCharmGroupContainer = new ILearningCharmGroupContainer() { @@ -288,7 +288,7 @@ public ICharm getCharmById(String charmId) { throw new IllegalArgumentException("No charm found for id \"" + charmId + "\""); //$NON-NLS-1$ //$NON-NLS-2$ } - private ICharmIdMap getCharmTree(IIdentificate type) { + private ICharmIdMap getCharmTree(Identified type) { return alienTreesByType.get(type); } @@ -311,7 +311,7 @@ public ICharm[] getExperienceLearnedCharms() { } @Override - public ILearningCharmGroup[] getCharmGroups(IIdentificate type) { + public ILearningCharmGroup[] getCharmGroups(Identified type) { if (MartialArtsUtilities.MARTIAL_ARTS.equals(type)) { return martialArtsGroups; } diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/CoreTraitConfiguration.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/CoreTraitConfiguration.java index e26534fcec..b51f6fc8d7 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/CoreTraitConfiguration.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/CoreTraitConfiguration.java @@ -29,7 +29,7 @@ import net.sf.anathema.character.model.background.IBackgroundConfiguration; import net.sf.anathema.character.model.traits.ICoreTraitConfiguration; import net.sf.anathema.lib.registry.IIdentificateRegistry; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import java.util.ArrayList; import java.util.Collections; @@ -132,7 +132,7 @@ public final IIdentifiedCasteTraitTypeGroup[] getYoziTypeGroups() { } @Override - public IIdentificate getAbilityGroupId(AbilityType abilityType) { + public Identified getAbilityGroupId(AbilityType abilityType) { for (IIdentifiedTraitTypeGroup group : getAbilityTypeGroups()) { if (group.contains(abilityType)) { return group.getGroupId(); diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbilityTypeGroupFactory.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbilityTypeGroupFactory.java index 4155c8e8a3..e190927098 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbilityTypeGroupFactory.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbilityTypeGroupFactory.java @@ -2,12 +2,12 @@ import net.sf.anathema.character.generic.caste.ICasteCollection; import net.sf.anathema.character.generic.template.abilities.AbilityGroupType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class AbilityTypeGroupFactory extends AbstractTraitTypeGroupFactory { @Override - protected IIdentificate getGroupIdentifier(ICasteCollection casteCollection, String groupId) { + protected Identified getGroupIdentifier(ICasteCollection casteCollection, String groupId) { return casteCollection.containsCasteType(groupId) ? casteCollection.getById(groupId) : AbilityGroupType.valueOf(groupId); diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbstractTraitTypeGroupFactory.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbstractTraitTypeGroupFactory.java index eba268a41f..30d8527618 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbstractTraitTypeGroupFactory.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AbstractTraitTypeGroupFactory.java @@ -1,10 +1,5 @@ package net.sf.anathema.character.impl.model.traits.creation; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import net.sf.anathema.character.generic.caste.ICasteCollection; import net.sf.anathema.character.generic.caste.ICasteType; import net.sf.anathema.character.generic.template.abilities.IGroupedTraitType; @@ -12,11 +7,16 @@ import net.sf.anathema.character.generic.traits.groups.IIdentifiedCasteTraitTypeGroup; import net.sf.anathema.character.generic.traits.groups.IdentifiedCasteTraitTypeGroup; import net.sf.anathema.lib.collection.MultiEntryMap; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public abstract class AbstractTraitTypeGroupFactory { - protected abstract IIdentificate getGroupIdentifier(ICasteCollection casteCollection, String groupId); + protected abstract Identified getGroupIdentifier(ICasteCollection casteCollection, String groupId); public IIdentifiedCasteTraitTypeGroup[] createTraitGroups( ICasteCollection casteCollection, @@ -74,7 +74,7 @@ private IIdentifiedCasteTraitTypeGroup createTraitGroup( List traitTypes, ICasteType[][] traitCasteTypes) { ICasteType casteType = casteCollection.containsCasteType(casteId) ? casteCollection.getById(casteId) : null; - IIdentificate groupIdentifier = getGroupIdentifier(casteCollection, groupId); + Identified groupIdentifier = getGroupIdentifier(casteCollection, groupId); return new IdentifiedCasteTraitTypeGroup( traitTypes.toArray(new ITraitType[traitTypes.size()]), groupIdentifier, diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AttributeTypeGroupFactory.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AttributeTypeGroupFactory.java index eb10f90192..7419e91464 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AttributeTypeGroupFactory.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/AttributeTypeGroupFactory.java @@ -2,12 +2,12 @@ import net.sf.anathema.character.generic.caste.ICasteCollection; import net.sf.anathema.character.generic.traits.types.AttributeGroupType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class AttributeTypeGroupFactory extends AbstractTraitTypeGroupFactory { @Override - protected IIdentificate getGroupIdentifier(ICasteCollection casteCollection, String groupId) { + protected Identified getGroupIdentifier(ICasteCollection casteCollection, String groupId) { return AttributeGroupType.valueOf(groupId); } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/YoziTypeGroupFactory.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/YoziTypeGroupFactory.java index fff826872d..5aae1ce2e0 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/YoziTypeGroupFactory.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/model/traits/creation/YoziTypeGroupFactory.java @@ -1,14 +1,13 @@ package net.sf.anathema.character.impl.model.traits.creation; import net.sf.anathema.character.generic.caste.ICasteCollection; -import net.sf.anathema.lib.util.IIdentificate; - import net.sf.anathema.character.generic.traits.types.YoziType; +import net.sf.anathema.lib.util.Identified; public class YoziTypeGroupFactory extends AbstractTraitTypeGroupFactory { @Override - protected IIdentificate getGroupIdentifier(ICasteCollection casteCollection, String groupId) { + protected Identified getGroupIdentifier(ICasteCollection casteCollection, String groupId) { return YoziType.valueOf(groupId); } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterPrintNameFileScanner.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterPrintNameFileScanner.java index 52b56e8c95..4ece1ff05a 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterPrintNameFileScanner.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterPrintNameFileScanner.java @@ -1,12 +1,5 @@ package net.sf.anathema.character.impl.module; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import net.sf.anathema.character.generic.caste.ICasteCollection; import net.sf.anathema.character.generic.type.CharacterType; import net.sf.anathema.character.generic.type.ICharacterType; @@ -15,14 +8,20 @@ import net.sf.anathema.framework.view.PrintNameFile; import net.sf.anathema.lib.exception.AnathemaException; import net.sf.anathema.lib.registry.IRegistry; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.xml.DocumentUtilities; - import org.apache.commons.io.FileUtils; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Element; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class CharacterPrintNameFileScanner { private static final String TYPE_ELEMENT_NAME = "CharacterType"; @@ -31,7 +30,7 @@ public class CharacterPrintNameFileScanner { private static final Pattern typePattern = Pattern.compile("<" + TYPE_ELEMENT_NAME + ".*>(.*?)"); //$NON-NLS-1$ private static final Pattern castePattern = Pattern.compile("<" + CASTE_ELEMENT_NAME + " " + CASTE_ELEMENT_TYPE_ATTR + "=\"(.*?)\"/>"); //$NON-NLS-1$ private final Map typesByFile = new HashMap(); - private final Map castesByFile = new HashMap(); + private final Map castesByFile = new HashMap(); private final IRegistry registry; private final IRepositoryFileResolver resolver; @@ -80,7 +79,7 @@ private void scan(PrintNameFile file) throws IOException { return; } - IIdentificate casteType = registry.get(characterType).getById(casteTypeStr); + Identified casteType = registry.get(characterType).getById(casteTypeStr); castesByFile.put(file, casteType); } @@ -99,7 +98,7 @@ private void scanCompatible(PrintNameFile file) throws IOException { castesByFile.put(file, null); return; } - IIdentificate casteType = registry.get(characterType).getById(casteMatcher.group(1)); + Identified casteType = registry.get(characterType).getById(casteMatcher.group(1)); castesByFile.put(file, casteType); } @@ -117,8 +116,8 @@ public ICharacterType getCharacterType(PrintNameFile file) { } } - public IIdentificate getCasteType(PrintNameFile file) { - IIdentificate caste = castesByFile.get(file); + public Identified getCasteType(PrintNameFile file) { + Identified caste = castesByFile.get(file); if (caste != null) { return caste; } diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterTypeUi.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterTypeUi.java index 41112d4b23..821cc31336 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterTypeUi.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/CharacterTypeUi.java @@ -5,7 +5,7 @@ import net.sf.anathema.framework.view.PrintNameFile; import net.sf.anathema.lib.gui.ui.IObjectUi; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.Icon; @@ -25,7 +25,7 @@ public String getLabel(Object value) { String printName = file.getPrintName(); ICharacterType characterType = scanner.getCharacterType(file); String characterString = resources.getString("CharacterGenerator.NewCharacter." + characterType.getId() + ".Name"); //$NON-NLS-1$//$NON-NLS-2$ - IIdentificate casteType = scanner.getCasteType(file); + Identified casteType = scanner.getCasteType(file); if (casteType == null) { return resources.getString("LoadCharacter.PrintNameFile.ShortMessage", new Object[] { //$NON-NLS-1$ printName, characterString }); diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/AbstractCharacterPreferencesElement.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/AbstractCharacterPreferencesElement.java index ee210454f1..5efc78a96e 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/AbstractCharacterPreferencesElement.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/AbstractCharacterPreferencesElement.java @@ -1,11 +1,11 @@ package net.sf.anathema.character.impl.module.preferences; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public abstract class AbstractCharacterPreferencesElement implements ICharacterPreferencesElement { @Override - public IIdentificate getCategory() { + public Identified getCategory() { return CHARACTER_CATEGORY; } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/ICharacterPreferencesElement.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/ICharacterPreferencesElement.java index 8c6a08acbd..a3464967bb 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/ICharacterPreferencesElement.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/ICharacterPreferencesElement.java @@ -1,8 +1,8 @@ package net.sf.anathema.character.impl.module.preferences; import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.prefs.Preferences; @@ -11,5 +11,5 @@ public interface ICharacterPreferencesElement extends IPreferencesElement { Preferences CHARACTER_PREFERENCES = Preferences.userRoot().node(CHARACTER_PREFERENCES_NODE); - IIdentificate CHARACTER_CATEGORY = new Identificate("Character"); //$NON-NLS-1$ + Identified CHARACTER_CATEGORY = new Identificate("Character"); //$NON-NLS-1$ } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintAllGenericsPreferencesElement.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintAllGenericsPreferencesElement.java index cda7e4ea29..291fdb872d 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintAllGenericsPreferencesElement.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintAllGenericsPreferencesElement.java @@ -1,43 +1,44 @@ -package net.sf.anathema.character.impl.module.preferences; - -import static net.sf.anathema.character.generic.framework.configuration.ICharacterPreferencesConstants.PRINT_ALL_GENERICS; -import net.sf.anathema.framework.module.preferences.AbstractCheckBoxPreferencesElement; -import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.util.IIdentificate; - -@PreferenceElement -public class PrintAllGenericsPreferencesElement extends AbstractCheckBoxPreferencesElement implements - ICharacterPreferencesElement { - - private boolean printAllGenerics = CHARACTER_PREFERENCES.getBoolean(PRINT_ALL_GENERICS, false); - - @Override - public void savePreferences() { - CHARACTER_PREFERENCES.putBoolean(PRINT_ALL_GENERICS, printAllGenerics); - } - - @Override - protected boolean getBooleanParameter() { - return printAllGenerics; - } - - @Override - protected String getLabelKey() { - return "Character.Tools.Preferences.PrintAllGenerics"; //$NON-NLS-1$ - } - - @Override - protected void resetValue() { - printAllGenerics = CHARACTER_PREFERENCES.getBoolean(PRINT_ALL_GENERICS, false); - } - - @Override - protected void setValue(boolean value) { - printAllGenerics = value; - } - - @Override - public IIdentificate getCategory() { - return CHARACTER_CATEGORY; - } +package net.sf.anathema.character.impl.module.preferences; + +import net.sf.anathema.framework.module.preferences.AbstractCheckBoxPreferencesElement; +import net.sf.anathema.initialization.PreferenceElement; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.character.generic.framework.configuration.ICharacterPreferencesConstants.PRINT_ALL_GENERICS; + +@PreferenceElement +public class PrintAllGenericsPreferencesElement extends AbstractCheckBoxPreferencesElement implements + ICharacterPreferencesElement { + + private boolean printAllGenerics = CHARACTER_PREFERENCES.getBoolean(PRINT_ALL_GENERICS, false); + + @Override + public void savePreferences() { + CHARACTER_PREFERENCES.putBoolean(PRINT_ALL_GENERICS, printAllGenerics); + } + + @Override + protected boolean getBooleanParameter() { + return printAllGenerics; + } + + @Override + protected String getLabelKey() { + return "Character.Tools.Preferences.PrintAllGenerics"; //$NON-NLS-1$ + } + + @Override + protected void resetValue() { + printAllGenerics = CHARACTER_PREFERENCES.getBoolean(PRINT_ALL_GENERICS, false); + } + + @Override + protected void setValue(boolean value) { + printAllGenerics = value; + } + + @Override + public Identified getCategory() { + return CHARACTER_CATEGORY; + } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroBackgroundsPreferencesElement.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroBackgroundsPreferencesElement.java index 82751656ca..1a63886576 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroBackgroundsPreferencesElement.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroBackgroundsPreferencesElement.java @@ -1,9 +1,10 @@ package net.sf.anathema.character.impl.module.preferences; -import static net.sf.anathema.character.generic.framework.configuration.ICharacterPreferencesConstants.PRINT_ZERO_BACKGROUNDS; import net.sf.anathema.framework.module.preferences.AbstractCheckBoxPreferencesElement; import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.character.generic.framework.configuration.ICharacterPreferencesConstants.PRINT_ZERO_BACKGROUNDS; @PreferenceElement public class PrintZeroBackgroundsPreferencesElement extends AbstractCheckBoxPreferencesElement implements @@ -37,7 +38,7 @@ protected void setValue(boolean value) { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return CHARACTER_CATEGORY; } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroCraftsPreferencesElement.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroCraftsPreferencesElement.java index ecfde1da5f..8bb88f6d9c 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroCraftsPreferencesElement.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/module/preferences/PrintZeroCraftsPreferencesElement.java @@ -1,9 +1,10 @@ package net.sf.anathema.character.impl.module.preferences; -import static net.sf.anathema.character.generic.framework.configuration.ICharacterPreferencesConstants.PRINT_ZERO_CRAFTS; import net.sf.anathema.framework.module.preferences.AbstractCheckBoxPreferencesElement; import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.character.generic.framework.configuration.ICharacterPreferencesConstants.PRINT_ZERO_CRAFTS; @PreferenceElement public class PrintZeroCraftsPreferencesElement extends AbstractCheckBoxPreferencesElement implements @@ -37,7 +38,7 @@ protected void setValue(boolean value) { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return CHARACTER_CATEGORY; } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/CharacterStatisticPersister.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/CharacterStatisticPersister.java index 25921d0e2d..4a621e5316 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/CharacterStatisticPersister.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/CharacterStatisticPersister.java @@ -16,8 +16,8 @@ import net.sf.anathema.character.model.ICharacter; import net.sf.anathema.framework.messaging.IAnathemaMessaging; import net.sf.anathema.lib.exception.PersistenceException; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.xml.ElementUtilities; import org.dom4j.Element; @@ -106,7 +106,7 @@ private ITemplateType loadTemplateType(Element parent) throws PersistenceExcepti String typeId = ElementUtilities.getRequiredText(parent, TAG_CHARACTER_TYPE); ICharacterType characterType = CharacterType.getById(typeId); String subTypeValue = parent.element(TAG_CHARACTER_TYPE).attributeValue(ATTRIB_SUB_TYPE); - IIdentificate subtype = subTypeValue == null ? TemplateType.DEFAULT_SUB_TYPE : new Identificate(subTypeValue); + Identified subtype = subTypeValue == null ? TemplateType.DEFAULT_SUB_TYPE : new Identificate(subTypeValue); return new TemplateType(characterType, subtype); } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmConfigurationPersister.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmConfigurationPersister.java index 9f6e90254c..3eee5c455b 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmConfigurationPersister.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmConfigurationPersister.java @@ -24,7 +24,7 @@ import net.sf.anathema.framework.persistence.TextPersister; import net.sf.anathema.lib.exception.PersistenceException; import net.sf.anathema.lib.message.MessageType; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.xml.ElementUtilities; import org.dom4j.Element; @@ -75,7 +75,7 @@ public void save(Element parent, ICharacter character) { private ICharmConfiguration saveCharms(Element charmsElement, ICharmTemplate charmTemplate, ICharmConfiguration charmConfiguration) { CharmSaver saver = new CharmSaver(charmConfiguration); - for (IIdentificate type : charmConfiguration.getCharacterTypes(true)) { + for (Identified type : charmConfiguration.getCharacterTypes(true)) { saver.saveCharms(type, charmsElement); } if (charmTemplate.hasUniqueCharms()) { diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmSaver.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmSaver.java index 631d073eb8..4676a064de 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmSaver.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/persistence/charm/CharmSaver.java @@ -1,62 +1,62 @@ -package net.sf.anathema.character.impl.persistence.charm; - -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharmConfiguration; -import net.sf.anathema.character.model.charm.ICharmConfiguration; -import net.sf.anathema.character.model.charm.ILearningCharmGroup; -import net.sf.anathema.lib.util.IIdentificate; -import org.dom4j.Element; - -import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.ATTRIB_EXPERIENCE_LEARNED; -import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.ATTRIB_NAME; -import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.ATTRIB_TYPE; -import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.TAG_CHARM; -import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.TAG_CHARMGROUP; -import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.TAG_SPECIAL; - -public class CharmSaver { - private ICharmConfiguration charmConfiguration; - private final ISpecialCharmPersister specialPersister; - - public CharmSaver(ICharmConfiguration charmConfiguration) { - this.charmConfiguration = charmConfiguration; - this.specialPersister = createSpecialCharmPersister(charmConfiguration); - } - - private ISpecialCharmPersister createSpecialCharmPersister(ICharmConfiguration charmConfiguration) { - return new SpecialCharmPersister(charmConfiguration.getSpecialCharms(), charmConfiguration.getCharmIdMap()); - } - - public void saveCharms(IIdentificate type, Element charmsElement) { - for (ILearningCharmGroup group : charmConfiguration.getCharmGroups(type)) { - if (group.hasLearnedCharms()) { - saveCharmGroup(charmsElement, group, specialPersister, charmConfiguration); - } - } - } - - private void saveCharmGroup(Element charmsElement, ILearningCharmGroup group, ISpecialCharmPersister specialPersister, - ICharmConfiguration charmConfiguration) { - Element groupElement = charmsElement.addElement(TAG_CHARMGROUP); - groupElement.addAttribute(ATTRIB_NAME, group.getId()); - groupElement.addAttribute(ATTRIB_TYPE, group.getCharacterType().getId()); - for (ICharm charm : group.getCreationLearnedCharms()) { - saveCharm(charmConfiguration, specialPersister, groupElement, charm, false); - } - for (ICharm charm : group.getExperienceLearnedCharms()) { - saveCharm(charmConfiguration, specialPersister, groupElement, charm, true); - } - } - - private void saveCharm(ICharmConfiguration charmConfiguration, ISpecialCharmPersister specialPersister, - Element groupElement, ICharm charm, boolean experienceLearned) { - Element charmElement = groupElement.addElement(TAG_CHARM); - charmElement.addAttribute(ATTRIB_NAME, charm.getId()); - charmElement.addAttribute(ATTRIB_EXPERIENCE_LEARNED, String.valueOf(experienceLearned)); - ISpecialCharmConfiguration specialCharmConfiguration = charmConfiguration.getSpecialCharmConfiguration(charm); - if (specialCharmConfiguration != null) { - Element specialElement = charmElement.addElement(TAG_SPECIAL); - specialPersister.saveConfiguration(specialElement, specialCharmConfiguration); - } - } +package net.sf.anathema.character.impl.persistence.charm; + +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.charms.special.ISpecialCharmConfiguration; +import net.sf.anathema.character.model.charm.ICharmConfiguration; +import net.sf.anathema.character.model.charm.ILearningCharmGroup; +import net.sf.anathema.lib.util.Identified; +import org.dom4j.Element; + +import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.ATTRIB_EXPERIENCE_LEARNED; +import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.ATTRIB_NAME; +import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.ATTRIB_TYPE; +import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.TAG_CHARM; +import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.TAG_CHARMGROUP; +import static net.sf.anathema.character.impl.persistence.ICharacterXmlConstants.TAG_SPECIAL; + +public class CharmSaver { + private ICharmConfiguration charmConfiguration; + private final ISpecialCharmPersister specialPersister; + + public CharmSaver(ICharmConfiguration charmConfiguration) { + this.charmConfiguration = charmConfiguration; + this.specialPersister = createSpecialCharmPersister(charmConfiguration); + } + + private ISpecialCharmPersister createSpecialCharmPersister(ICharmConfiguration charmConfiguration) { + return new SpecialCharmPersister(charmConfiguration.getSpecialCharms(), charmConfiguration.getCharmIdMap()); + } + + public void saveCharms(Identified type, Element charmsElement) { + for (ILearningCharmGroup group : charmConfiguration.getCharmGroups(type)) { + if (group.hasLearnedCharms()) { + saveCharmGroup(charmsElement, group, specialPersister, charmConfiguration); + } + } + } + + private void saveCharmGroup(Element charmsElement, ILearningCharmGroup group, ISpecialCharmPersister specialPersister, + ICharmConfiguration charmConfiguration) { + Element groupElement = charmsElement.addElement(TAG_CHARMGROUP); + groupElement.addAttribute(ATTRIB_NAME, group.getId()); + groupElement.addAttribute(ATTRIB_TYPE, group.getCharacterType().getId()); + for (ICharm charm : group.getCreationLearnedCharms()) { + saveCharm(charmConfiguration, specialPersister, groupElement, charm, false); + } + for (ICharm charm : group.getExperienceLearnedCharms()) { + saveCharm(charmConfiguration, specialPersister, groupElement, charm, true); + } + } + + private void saveCharm(ICharmConfiguration charmConfiguration, ISpecialCharmPersister specialPersister, + Element groupElement, ICharm charm, boolean experienceLearned) { + Element charmElement = groupElement.addElement(TAG_CHARM); + charmElement.addAttribute(ATTRIB_NAME, charm.getId()); + charmElement.addAttribute(ATTRIB_EXPERIENCE_LEARNED, String.valueOf(experienceLearned)); + ISpecialCharmConfiguration specialCharmConfiguration = charmConfiguration.getSpecialCharmConfiguration(charm); + if (specialCharmConfiguration != null) { + Element specialElement = charmElement.addElement(TAG_SPECIAL); + specialPersister.saveConfiguration(specialElement, specialCharmConfiguration); + } + } } \ No newline at end of file diff --git a/Character_Main_Impl/src/net/sf/anathema/character/impl/view/magic/SpellView.java b/Character_Main_Impl/src/net/sf/anathema/character/impl/view/magic/SpellView.java index a11156512a..a57545429b 100644 --- a/Character_Main_Impl/src/net/sf/anathema/character/impl/view/magic/SpellView.java +++ b/Character_Main_Impl/src/net/sf/anathema/character/impl/view/magic/SpellView.java @@ -9,7 +9,7 @@ import net.sf.anathema.character.presenter.magic.spells.SpellViewProperties; import net.sf.anathema.character.view.magic.ISpellView; import net.sf.anathema.lib.control.ObjectValueListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import org.jmock.example.announcer.Announcer; import javax.swing.JButton; @@ -50,13 +50,13 @@ public JComponent getComponent() { } @Override - public void initGui(IIdentificate[] circles) { + public void initGui(Identified[] circles) { JComponent selectionPanel = createSelectionPanel(circles); IGridDialogLayoutData data = GridDialogLayoutData.FILL_BOTH; content.add(selectionPanel, data); } - private JPanel createSelectionPanel(IIdentificate[] circles) { + private JPanel createSelectionPanel(Identified[] circles) { JPanel panel = createFilterBox(properties.getCircleLabel(), circles, properties.getCircleSelectionRenderer()); magicLearnView.addAdditionalOptionsPanel(panel); magicLearnView.init(properties); @@ -117,7 +117,7 @@ public void addLearnedMagic(Object[] magics) { } @Override - public void addMagicOptions(IIdentificate[] magics, Comparator comparator) { + public void addMagicOptions(Identified[] magics, Comparator comparator) { magicLearnView.addMagicOptions(magics, comparator); } diff --git a/Character_Main_Impl/test/net/sf/anathema/character/dummy/trait/DummyCoreTraitConfiguration.java b/Character_Main_Impl/test/net/sf/anathema/character/dummy/trait/DummyCoreTraitConfiguration.java index 2e45dd81a5..3a00ce1349 100644 --- a/Character_Main_Impl/test/net/sf/anathema/character/dummy/trait/DummyCoreTraitConfiguration.java +++ b/Character_Main_Impl/test/net/sf/anathema/character/dummy/trait/DummyCoreTraitConfiguration.java @@ -1,126 +1,126 @@ -package net.sf.anathema.character.dummy.trait; - -import net.sf.anathema.character.generic.dummy.DummyCharacterModelContext; -import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.character.generic.traits.groups.IIdentifiedCasteTraitTypeGroup; -import net.sf.anathema.character.generic.traits.groups.IIdentifiedTraitTypeGroup; -import net.sf.anathema.character.generic.traits.groups.IdentifiedAttributeTypeGroup; -import net.sf.anathema.character.generic.traits.groups.IdentifiedTraitTypeGroup; -import net.sf.anathema.character.generic.traits.types.AbilityType; -import net.sf.anathema.character.generic.traits.types.AttributeGroupType; -import net.sf.anathema.character.library.trait.AbstractTraitCollection; -import net.sf.anathema.character.library.trait.ITrait; -import net.sf.anathema.character.library.trait.TraitGroup; -import net.sf.anathema.character.library.trait.favorable.IFavorableTrait; -import net.sf.anathema.character.library.trait.specialties.ISpecialtiesConfiguration; -import net.sf.anathema.character.library.trait.specialties.SpecialtiesConfiguration; -import net.sf.anathema.character.model.background.IBackgroundConfiguration; -import net.sf.anathema.character.model.traits.ICoreTraitConfiguration; -import net.sf.anathema.lib.collection.ArrayUtilities; -import net.sf.anathema.lib.collection.MultiEntryMap; -import net.sf.anathema.lib.exception.NotYetImplementedException; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.IPredicate; -import net.sf.anathema.lib.util.Identificate; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class DummyCoreTraitConfiguration extends AbstractTraitCollection implements ICoreTraitConfiguration { - - private final MultiEntryMap abilityGroupsByType = new MultiEntryMap(); - private ISpecialtiesConfiguration specialtyConfiguration; - - @Override - public IBackgroundConfiguration getBackgrounds() { - throw new NotYetImplementedException(); - } - - private IIdentifiedTraitTypeGroup getAttributeTypeGroup(final AttributeGroupType type) { - IIdentifiedCasteTraitTypeGroup[] allAttributeTypeGroups = getAttributeTypeGroups(); - return ArrayUtilities.getFirst(allAttributeTypeGroups, new IPredicate() { - @Override - public boolean evaluate(IIdentifiedCasteTraitTypeGroup group) { - return group.getGroupId() == type; - } - }); - } - - public ITrait[] getAllTraits(AttributeGroupType groupType) { - IIdentifiedTraitTypeGroup attributeTypeGroup = getAttributeTypeGroup(groupType); - TraitGroup traitGroup = new TraitGroup(this, attributeTypeGroup); - return traitGroup.getGroupTraits(); - } - - public boolean containsAllTraits(AttributeGroupType attributeGroupType, ITrait[] traits) { - for (ITrait trait : traits) { - if (!ArrayUtilities.containsValue(getAllTraits(attributeGroupType), trait)) { - return false; - } - } - return true; - } - - public void addTestTrait(ITrait trait) { - addTrait(trait); - } - - @Override - public IIdentifiedTraitTypeGroup[] getAbilityTypeGroups() { - List groups = new ArrayList(); - for (String groupId : abilityGroupsByType.keySet()) { - groups.add(new IdentifiedTraitTypeGroup( - abilityGroupsByType.get(groupId).toArray(new ITraitType[0]), - new Identificate(groupId))); - } - return groups.toArray(new IIdentifiedTraitTypeGroup[groups.size()]); - } - - @Override - public IIdentifiedTraitTypeGroup[] getYoziTypeGroups() { - return null; - } - - @Override - public ISpecialtiesConfiguration getSpecialtyConfiguration() { - if (specialtyConfiguration == null) { - specialtyConfiguration = new SpecialtiesConfiguration( - this, - getAbilityTypeGroups(), - new DummyCharacterModelContext()); - } - return specialtyConfiguration; - } - - @Override - public final IIdentifiedCasteTraitTypeGroup[] getAttributeTypeGroups() { - return new IIdentifiedCasteTraitTypeGroup[] { - new IdentifiedAttributeTypeGroup(AttributeGroupType.Physical), - new IdentifiedAttributeTypeGroup(AttributeGroupType.Social), - new IdentifiedAttributeTypeGroup(AttributeGroupType.Mental) }; - } - - @Override - public IIdentificate getAbilityGroupId(AbilityType abilityType) { - for (IIdentifiedTraitTypeGroup group : getAbilityTypeGroups()) { - if (group.contains(abilityType)) { - return group.getGroupId(); - } - } - throw new IllegalStateException("Ability type in no group: " + abilityType); //$NON-NLS-1$ - } - - public void addAbilityTypeToGroup(AbilityType traitType, String id) { - abilityGroupsByType.add(id, traitType); - } - - @Override - public IFavorableTrait[] getAllAbilities() { - List abilityTypes = new ArrayList(); - for (IIdentifiedTraitTypeGroup group : getAbilityTypeGroups()) { - Collections.addAll(abilityTypes, group.getAllGroupTypes()); - } - return getFavorableTraits(abilityTypes.toArray(new ITraitType[abilityTypes.size()])); - } +package net.sf.anathema.character.dummy.trait; + +import net.sf.anathema.character.generic.dummy.DummyCharacterModelContext; +import net.sf.anathema.character.generic.traits.ITraitType; +import net.sf.anathema.character.generic.traits.groups.IIdentifiedCasteTraitTypeGroup; +import net.sf.anathema.character.generic.traits.groups.IIdentifiedTraitTypeGroup; +import net.sf.anathema.character.generic.traits.groups.IdentifiedAttributeTypeGroup; +import net.sf.anathema.character.generic.traits.groups.IdentifiedTraitTypeGroup; +import net.sf.anathema.character.generic.traits.types.AbilityType; +import net.sf.anathema.character.generic.traits.types.AttributeGroupType; +import net.sf.anathema.character.library.trait.AbstractTraitCollection; +import net.sf.anathema.character.library.trait.ITrait; +import net.sf.anathema.character.library.trait.TraitGroup; +import net.sf.anathema.character.library.trait.favorable.IFavorableTrait; +import net.sf.anathema.character.library.trait.specialties.ISpecialtiesConfiguration; +import net.sf.anathema.character.library.trait.specialties.SpecialtiesConfiguration; +import net.sf.anathema.character.model.background.IBackgroundConfiguration; +import net.sf.anathema.character.model.traits.ICoreTraitConfiguration; +import net.sf.anathema.lib.collection.ArrayUtilities; +import net.sf.anathema.lib.collection.MultiEntryMap; +import net.sf.anathema.lib.exception.NotYetImplementedException; +import net.sf.anathema.lib.util.IPredicate; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class DummyCoreTraitConfiguration extends AbstractTraitCollection implements ICoreTraitConfiguration { + + private final MultiEntryMap abilityGroupsByType = new MultiEntryMap(); + private ISpecialtiesConfiguration specialtyConfiguration; + + @Override + public IBackgroundConfiguration getBackgrounds() { + throw new NotYetImplementedException(); + } + + private IIdentifiedTraitTypeGroup getAttributeTypeGroup(final AttributeGroupType type) { + IIdentifiedCasteTraitTypeGroup[] allAttributeTypeGroups = getAttributeTypeGroups(); + return ArrayUtilities.getFirst(allAttributeTypeGroups, new IPredicate() { + @Override + public boolean evaluate(IIdentifiedCasteTraitTypeGroup group) { + return group.getGroupId() == type; + } + }); + } + + public ITrait[] getAllTraits(AttributeGroupType groupType) { + IIdentifiedTraitTypeGroup attributeTypeGroup = getAttributeTypeGroup(groupType); + TraitGroup traitGroup = new TraitGroup(this, attributeTypeGroup); + return traitGroup.getGroupTraits(); + } + + public boolean containsAllTraits(AttributeGroupType attributeGroupType, ITrait[] traits) { + for (ITrait trait : traits) { + if (!ArrayUtilities.containsValue(getAllTraits(attributeGroupType), trait)) { + return false; + } + } + return true; + } + + public void addTestTrait(ITrait trait) { + addTrait(trait); + } + + @Override + public IIdentifiedTraitTypeGroup[] getAbilityTypeGroups() { + List groups = new ArrayList(); + for (String groupId : abilityGroupsByType.keySet()) { + groups.add(new IdentifiedTraitTypeGroup( + abilityGroupsByType.get(groupId).toArray(new ITraitType[0]), + new Identificate(groupId))); + } + return groups.toArray(new IIdentifiedTraitTypeGroup[groups.size()]); + } + + @Override + public IIdentifiedTraitTypeGroup[] getYoziTypeGroups() { + return null; + } + + @Override + public ISpecialtiesConfiguration getSpecialtyConfiguration() { + if (specialtyConfiguration == null) { + specialtyConfiguration = new SpecialtiesConfiguration( + this, + getAbilityTypeGroups(), + new DummyCharacterModelContext()); + } + return specialtyConfiguration; + } + + @Override + public final IIdentifiedCasteTraitTypeGroup[] getAttributeTypeGroups() { + return new IIdentifiedCasteTraitTypeGroup[] { + new IdentifiedAttributeTypeGroup(AttributeGroupType.Physical), + new IdentifiedAttributeTypeGroup(AttributeGroupType.Social), + new IdentifiedAttributeTypeGroup(AttributeGroupType.Mental) }; + } + + @Override + public Identified getAbilityGroupId(AbilityType abilityType) { + for (IIdentifiedTraitTypeGroup group : getAbilityTypeGroups()) { + if (group.contains(abilityType)) { + return group.getGroupId(); + } + } + throw new IllegalStateException("Ability type in no group: " + abilityType); //$NON-NLS-1$ + } + + public void addAbilityTypeToGroup(AbilityType traitType, String id) { + abilityGroupsByType.add(id, traitType); + } + + @Override + public IFavorableTrait[] getAllAbilities() { + List abilityTypes = new ArrayList(); + for (IIdentifiedTraitTypeGroup group : getAbilityTypeGroups()) { + Collections.addAll(abilityTypes, group.getAllGroupTypes()); + } + return getFavorableTraits(abilityTypes.toArray(new ITraitType[abilityTypes.size()])); + } } \ No newline at end of file diff --git a/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/charm/LearningCharmGroupArbitratorTest.java b/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/charm/LearningCharmGroupArbitratorTest.java index 2633168200..e3f113e528 100644 --- a/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/charm/LearningCharmGroupArbitratorTest.java +++ b/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/charm/LearningCharmGroupArbitratorTest.java @@ -1,40 +1,40 @@ -package net.sf.anathema.test.character.main.impl.charm; - -import net.sf.anathema.character.generic.character.IMagicCollection; -import net.sf.anathema.character.generic.framework.additionaltemplate.model.ICharacterModelContext; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.impl.model.charm.LearningCharmGroupArbitrator; -import net.sf.anathema.character.model.charm.ILearningCharmGroup; -import net.sf.anathema.dummy.character.magic.DummyCharm; -import net.sf.anathema.lib.util.IIdentificate; -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mockito; - -public class LearningCharmGroupArbitratorTest { - - @Test - public void testAlternativesDontBlockCompletion() throws Exception { - ICharacterModelContext context = Mockito.mock(ICharacterModelContext.class); - ILearningCharmGroup group = Mockito.mock(ILearningCharmGroup.class); - expectCoreCharmsCall(group); - expectCoreCharmsCall(group); - LearningCharmGroupArbitrator arbitrator = new LearningCharmGroupArbitrator(null, context); - boolean celestialMartialArtsGroupCompleted = arbitrator.isCelestialMartialArtsGroupCompleted(new ILearningCharmGroup[] { group }); - Assert.assertTrue(celestialMartialArtsGroupCompleted); - } - - private void expectCoreCharmsCall(ILearningCharmGroup group) { - Mockito.when(group.getCoreCharms()).thenReturn(new ICharm[]{new DummyCharm() { - @Override - public boolean isBlockedByAlternative(IMagicCollection magicCollection) { - return true; - } - - @Override - public boolean hasAttribute(IIdentificate attribute) { - return !attribute.equals(NO_STYLE_ATTRIBUTE); - } - }}); - } -} +package net.sf.anathema.test.character.main.impl.charm; + +import net.sf.anathema.character.generic.character.IMagicCollection; +import net.sf.anathema.character.generic.framework.additionaltemplate.model.ICharacterModelContext; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.impl.model.charm.LearningCharmGroupArbitrator; +import net.sf.anathema.character.model.charm.ILearningCharmGroup; +import net.sf.anathema.dummy.character.magic.DummyCharm; +import net.sf.anathema.lib.util.Identified; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +public class LearningCharmGroupArbitratorTest { + + @Test + public void testAlternativesDontBlockCompletion() throws Exception { + ICharacterModelContext context = Mockito.mock(ICharacterModelContext.class); + ILearningCharmGroup group = Mockito.mock(ILearningCharmGroup.class); + expectCoreCharmsCall(group); + expectCoreCharmsCall(group); + LearningCharmGroupArbitrator arbitrator = new LearningCharmGroupArbitrator(null, context); + boolean celestialMartialArtsGroupCompleted = arbitrator.isCelestialMartialArtsGroupCompleted(new ILearningCharmGroup[] { group }); + Assert.assertTrue(celestialMartialArtsGroupCompleted); + } + + private void expectCoreCharmsCall(ILearningCharmGroup group) { + Mockito.when(group.getCoreCharms()).thenReturn(new ICharm[]{new DummyCharm() { + @Override + public boolean isBlockedByAlternative(IMagicCollection magicCollection) { + return true; + } + + @Override + public boolean hasAttribute(Identified attribute) { + return !attribute.equals(NO_STYLE_ATTRIBUTE); + } + }}); + } +} diff --git a/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/costs/CostAnalyzerTest.java b/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/costs/CostAnalyzerTest.java index 195103754d..2d2b02ec91 100644 --- a/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/costs/CostAnalyzerTest.java +++ b/Character_Main_Impl/test/net/sf/anathema/test/character/main/impl/costs/CostAnalyzerTest.java @@ -1,49 +1,52 @@ -package net.sf.anathema.test.character.main.impl.costs; - -import net.sf.anathema.character.dummy.trait.DummyCoreTraitConfiguration; -import net.sf.anathema.character.generic.IBasicCharacterData; -import net.sf.anathema.character.generic.dummy.DummyBasicCharacterData; -import net.sf.anathema.character.generic.magic.IMagic; -import net.sf.anathema.character.generic.magic.charms.MartialArtsLevel; -import net.sf.anathema.character.impl.model.advance.CostAnalyzer; -import net.sf.anathema.dummy.character.magic.DummyCharm; -import net.sf.anathema.lib.util.IIdentificate; -import org.junit.Test; -import org.mockito.Mockito; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -public class CostAnalyzerTest { - - private static final String CHARM_ID = "charmId"; //$NON-NLS-1$ - private DummyCoreTraitConfiguration dummyCoreTraitConfiguration = new DummyCoreTraitConfiguration(); - private DummyBasicCharacterData basicCharacterData = new DummyBasicCharacterData(); - private CostAnalyzer costAnalyzer = new CostAnalyzer(basicCharacterData, dummyCoreTraitConfiguration); - - @Test - public void testIsFavoredMagicDelegatesToMagic() throws Exception { - IMagic magic = Mockito.mock(IMagic.class); - IBasicCharacterData trueCharacterData = new DummyBasicCharacterData(); - Mockito.when(magic.isFavored(trueCharacterData, dummyCoreTraitConfiguration)).thenReturn(true); - IBasicCharacterData falseCharacterData = new DummyBasicCharacterData(); - when(magic.isFavored(falseCharacterData, dummyCoreTraitConfiguration)).thenReturn(false); - assertTrue(new CostAnalyzer(trueCharacterData, dummyCoreTraitConfiguration).isMagicFavored(magic)); - assertFalse(new CostAnalyzer(falseCharacterData, dummyCoreTraitConfiguration).isMagicFavored(magic)); - } - - @Test - public void testGetMartialArtsLevelFromMartialArtsCharm() throws Exception { - assertEquals(MartialArtsLevel.Terrestrial, costAnalyzer.getMartialArtsLevel(new DummyCharm(CHARM_ID) { - @Override - public boolean hasAttribute(IIdentificate attribute) { - return attribute.getId().equals("MartialArts") || attribute.getId().equals("Terrestrial"); //$NON-NLS-1$ //$NON-NLS-2$ - } - })); - } - - @Test - public void testGetMartialArtsLevelFromNonMartialArtsCharm() throws Exception { - assertNull(costAnalyzer.getMartialArtsLevel(new DummyCharm(CHARM_ID))); - } +package net.sf.anathema.test.character.main.impl.costs; + +import net.sf.anathema.character.dummy.trait.DummyCoreTraitConfiguration; +import net.sf.anathema.character.generic.IBasicCharacterData; +import net.sf.anathema.character.generic.dummy.DummyBasicCharacterData; +import net.sf.anathema.character.generic.magic.IMagic; +import net.sf.anathema.character.generic.magic.charms.MartialArtsLevel; +import net.sf.anathema.character.impl.model.advance.CostAnalyzer; +import net.sf.anathema.dummy.character.magic.DummyCharm; +import net.sf.anathema.lib.util.Identified; +import org.junit.Test; +import org.mockito.Mockito; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +public class CostAnalyzerTest { + + private static final String CHARM_ID = "charmId"; //$NON-NLS-1$ + private DummyCoreTraitConfiguration dummyCoreTraitConfiguration = new DummyCoreTraitConfiguration(); + private DummyBasicCharacterData basicCharacterData = new DummyBasicCharacterData(); + private CostAnalyzer costAnalyzer = new CostAnalyzer(basicCharacterData, dummyCoreTraitConfiguration); + + @Test + public void testIsFavoredMagicDelegatesToMagic() throws Exception { + IMagic magic = Mockito.mock(IMagic.class); + IBasicCharacterData trueCharacterData = new DummyBasicCharacterData(); + Mockito.when(magic.isFavored(trueCharacterData, dummyCoreTraitConfiguration)).thenReturn(true); + IBasicCharacterData falseCharacterData = new DummyBasicCharacterData(); + when(magic.isFavored(falseCharacterData, dummyCoreTraitConfiguration)).thenReturn(false); + assertTrue(new CostAnalyzer(trueCharacterData, dummyCoreTraitConfiguration).isMagicFavored(magic)); + assertFalse(new CostAnalyzer(falseCharacterData, dummyCoreTraitConfiguration).isMagicFavored(magic)); + } + + @Test + public void testGetMartialArtsLevelFromMartialArtsCharm() throws Exception { + assertEquals(MartialArtsLevel.Terrestrial, costAnalyzer.getMartialArtsLevel(new DummyCharm(CHARM_ID) { + @Override + public boolean hasAttribute(Identified attribute) { + return attribute.getId().equals("MartialArts") || attribute.getId().equals("Terrestrial"); //$NON-NLS-1$ //$NON-NLS-2$ + } + })); + } + + @Test + public void testGetMartialArtsLevelFromNonMartialArtsCharm() throws Exception { + assertNull(costAnalyzer.getMartialArtsLevel(new DummyCharm(CHARM_ID))); + } } \ No newline at end of file diff --git a/Character_Mutations/src/net/sf/anathema/character/mutations/reporting/MutationContent.java b/Character_Mutations/src/net/sf/anathema/character/mutations/reporting/MutationContent.java index cfbe5133ab..7d60ae16e4 100644 --- a/Character_Mutations/src/net/sf/anathema/character/mutations/reporting/MutationContent.java +++ b/Character_Mutations/src/net/sf/anathema/character/mutations/reporting/MutationContent.java @@ -1,53 +1,53 @@ -package net.sf.anathema.character.mutations.reporting; - -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.library.quality.presenter.IQualitySelection; -import net.sf.anathema.character.mutations.model.IMutation; -import net.sf.anathema.character.mutations.model.IMutationsModel; -import net.sf.anathema.character.mutations.model.MutationsAdditionalModel; -import net.sf.anathema.character.mutations.template.MutationsTemplate; -import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; -import net.sf.anathema.character.reporting.pdf.content.ListSubBoxContent; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.List; - -public class MutationContent extends AbstractSubBoxContent implements ListSubBoxContent { - - private IGenericCharacter character; - - public MutationContent(IResources resources, IGenericCharacter character) { - super(resources); - this.character = character; - } - - @Override - public String getHeaderKey() { - return "Mutations"; //$NON-NLS-1$ - } - - @Override - public boolean hasContent() { - IMutationsModel model = getMutationModel(); - return model.getSelectedQualities().length > 0; - } - - @Override - public List getPrintEntries() { - List printMutations = new ArrayList(); - IMutationsModel model = getMutationModel(); - IQualitySelection[] mutations = model.getSelectedQualities(); - for (int index = 0; index < mutations.length; index++) { - IIdentificate mutation = mutations[index].getQuality(); - printMutations.add(getResources().getString("Mutations.Mutation." + mutation.getId())); //$NON-NLS-1$ - } - return printMutations; - } - - private IMutationsModel getMutationModel() { - MutationsAdditionalModel additionalModel = (MutationsAdditionalModel) character.getAdditionalModel(MutationsTemplate.ID); - return additionalModel.getModel(); - } -} +package net.sf.anathema.character.mutations.reporting; + +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.library.quality.presenter.IQualitySelection; +import net.sf.anathema.character.mutations.model.IMutation; +import net.sf.anathema.character.mutations.model.IMutationsModel; +import net.sf.anathema.character.mutations.model.MutationsAdditionalModel; +import net.sf.anathema.character.mutations.template.MutationsTemplate; +import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; +import net.sf.anathema.character.reporting.pdf.content.ListSubBoxContent; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +public class MutationContent extends AbstractSubBoxContent implements ListSubBoxContent { + + private IGenericCharacter character; + + public MutationContent(IResources resources, IGenericCharacter character) { + super(resources); + this.character = character; + } + + @Override + public String getHeaderKey() { + return "Mutations"; //$NON-NLS-1$ + } + + @Override + public boolean hasContent() { + IMutationsModel model = getMutationModel(); + return model.getSelectedQualities().length > 0; + } + + @Override + public List getPrintEntries() { + List printMutations = new ArrayList(); + IMutationsModel model = getMutationModel(); + IQualitySelection[] mutations = model.getSelectedQualities(); + for (int index = 0; index < mutations.length; index++) { + Identified mutation = mutations[index].getQuality(); + printMutations.add(getResources().getString("Mutations.Mutation." + mutation.getId())); //$NON-NLS-1$ + } + return printMutations; + } + + private IMutationsModel getMutationModel() { + MutationsAdditionalModel additionalModel = (MutationsAdditionalModel) character.getAdditionalModel(MutationsTemplate.ID); + return additionalModel.getModel(); + } +} diff --git a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/AbstractMagicStats.java b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/AbstractMagicStats.java index 5814dfe2ac..f1d243244c 100644 --- a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/AbstractMagicStats.java +++ b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/AbstractMagicStats.java @@ -1,42 +1,42 @@ -package net.sf.anathema.character.reporting.pdf.content.stats.magic; - -import net.sf.anathema.character.generic.framework.magic.stringbuilder.CostStringBuilder; -import net.sf.anathema.character.generic.framework.magic.stringbuilder.HealthCostStringBuilder; -import net.sf.anathema.character.generic.framework.magic.stringbuilder.MagicInfoStringBuilder; -import net.sf.anathema.character.generic.magic.IMagic; -import net.sf.anathema.character.generic.magic.IMagicStats; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public abstract class AbstractMagicStats implements IMagicStats { - - public static MagicInfoStringBuilder createMagicInfoStringBuilder(IResources resources) { - CostStringBuilder essenceBuilder = new CostStringBuilder(resources, "CharacterSheet.Charm.Mote"); //$NON-NLS-1$ - CostStringBuilder willpowerBuilder = new CostStringBuilder(resources, "CharacterSheet.Charm.Willpower"); //$NON-NLS-1$ - HealthCostStringBuilder healthBuilder = new HealthCostStringBuilder(resources, "CharacterSheet.Charm.HealthLevel"); //$NON-NLS-1$ - CostStringBuilder experienceBuilder = new CostStringBuilder(resources, "CharacterSheet.Charm.ExperiencePoints"); //$NON-NLS-1$ - return new MagicInfoStringBuilder(resources, essenceBuilder, willpowerBuilder, healthBuilder, experienceBuilder); - } - - private final T magic; - - public AbstractMagicStats(T magic) { - this.magic = magic; - } - - @Override - public IIdentificate getName() { - return new Identificate(magic.getId()); - } - - @Override - public String getCostString(IResources resources) { - MagicInfoStringBuilder infoBuilder = createMagicInfoStringBuilder(resources); - return infoBuilder.createCostString(magic); - } - - protected final T getMagic() { - return magic; - } -} +package net.sf.anathema.character.reporting.pdf.content.stats.magic; + +import net.sf.anathema.character.generic.framework.magic.stringbuilder.CostStringBuilder; +import net.sf.anathema.character.generic.framework.magic.stringbuilder.HealthCostStringBuilder; +import net.sf.anathema.character.generic.framework.magic.stringbuilder.MagicInfoStringBuilder; +import net.sf.anathema.character.generic.magic.IMagic; +import net.sf.anathema.character.generic.magic.IMagicStats; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +public abstract class AbstractMagicStats implements IMagicStats { + + public static MagicInfoStringBuilder createMagicInfoStringBuilder(IResources resources) { + CostStringBuilder essenceBuilder = new CostStringBuilder(resources, "CharacterSheet.Charm.Mote"); //$NON-NLS-1$ + CostStringBuilder willpowerBuilder = new CostStringBuilder(resources, "CharacterSheet.Charm.Willpower"); //$NON-NLS-1$ + HealthCostStringBuilder healthBuilder = new HealthCostStringBuilder(resources, "CharacterSheet.Charm.HealthLevel"); //$NON-NLS-1$ + CostStringBuilder experienceBuilder = new CostStringBuilder(resources, "CharacterSheet.Charm.ExperiencePoints"); //$NON-NLS-1$ + return new MagicInfoStringBuilder(resources, essenceBuilder, willpowerBuilder, healthBuilder, experienceBuilder); + } + + private final T magic; + + public AbstractMagicStats(T magic) { + this.magic = magic; + } + + @Override + public Identified getName() { + return new Identificate(magic.getId()); + } + + @Override + public String getCostString(IResources resources) { + MagicInfoStringBuilder infoBuilder = createMagicInfoStringBuilder(resources); + return infoBuilder.createCostString(magic); + } + + protected final T getMagic() { + return magic; + } +} diff --git a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/GenericCharmStats.java b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/GenericCharmStats.java index 78eb159789..4c48a4a9e8 100644 --- a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/GenericCharmStats.java +++ b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/stats/magic/GenericCharmStats.java @@ -1,58 +1,58 @@ -package net.sf.anathema.character.reporting.pdf.content.stats.magic; - -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.generic.framework.magic.MagicDisplayLabeler; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.IMagicStats; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -public class GenericCharmStats extends CharmStats { - - private final String genericId; - - public GenericCharmStats(ICharm charm, IGenericCharacter character) { - super(charm, character); - - String charmId = charm.getId(); - genericId = charmId.substring(0, charmId.lastIndexOf('.')); - } - - @Override - public String[] getDetailStrings(IResources resources) { - String description = resources.getString(getName() + ".Description.Short"); - return new String[]{description}; //$NON-NLS-1$ - } - - @Override - public IIdentificate getName() { - return new Identificate(genericId); - } - - @Override - public String getNameString(IResources resources) - { - return new MagicDisplayLabeler(resources).getGenericLabelForMagic(getMagic()); - } - - @Override - public final String getGroupName(IResources resources) { - return resources.getString("Generics"); //$NON-NLS-1$ - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof GenericCharmStats && this.getName().getId().equals(((GenericCharmStats)obj).getName().getId()); - } - - @Override - public int compareTo(IMagicStats stats) { - if (stats instanceof GenericCharmStats) { - return this.getName().getId().compareTo(stats.getName().getId()); - } else { - return -1; - } - } -} +package net.sf.anathema.character.reporting.pdf.content.stats.magic; + +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.generic.framework.magic.MagicDisplayLabeler; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.IMagicStats; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +public class GenericCharmStats extends CharmStats { + + private final String genericId; + + public GenericCharmStats(ICharm charm, IGenericCharacter character) { + super(charm, character); + + String charmId = charm.getId(); + genericId = charmId.substring(0, charmId.lastIndexOf('.')); + } + + @Override + public String[] getDetailStrings(IResources resources) { + String description = resources.getString(getName() + ".Description.Short"); + return new String[]{description}; //$NON-NLS-1$ + } + + @Override + public Identified getName() { + return new Identificate(genericId); + } + + @Override + public String getNameString(IResources resources) + { + return new MagicDisplayLabeler(resources).getGenericLabelForMagic(getMagic()); + } + + @Override + public final String getGroupName(IResources resources) { + return resources.getString("Generics"); //$NON-NLS-1$ + } + + @Override + public boolean equals(Object obj) + { + return obj instanceof GenericCharmStats && this.getName().getId().equals(((GenericCharmStats)obj).getName().getId()); + } + + @Override + public int compareTo(IMagicStats stats) { + if (stats instanceof GenericCharmStats) { + return this.getName().getId().compareTo(stats.getName().getId()); + } else { + return -1; + } + } +} diff --git a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/traits/FavorableTraitContent.java b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/traits/FavorableTraitContent.java index b134d89cc5..4306c152b7 100644 --- a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/traits/FavorableTraitContent.java +++ b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/content/traits/FavorableTraitContent.java @@ -1,133 +1,133 @@ -package net.sf.anathema.character.reporting.pdf.content.traits; - -import net.sf.anathema.character.generic.caste.ICasteType; -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.generic.character.IGenericTraitCollection; -import net.sf.anathema.character.generic.magic.IMagic; -import net.sf.anathema.character.generic.magic.IMagicStats; -import net.sf.anathema.character.generic.traits.ITraitTemplate; -import net.sf.anathema.character.generic.traits.ITraitType; -import net.sf.anathema.character.generic.traits.groups.IIdentifiedTraitTypeGroup; -import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; -import net.sf.anathema.character.reporting.pdf.content.magic.GenericCharmUtilities; -import net.sf.anathema.lib.collection.CollectionUtilities; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.IPredicate; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public abstract class FavorableTraitContent extends AbstractSubBoxContent { - - private IGenericCharacter character; - - public FavorableTraitContent(IGenericCharacter character, IResources resources) { - super(resources); - this.character = character; - } - - public abstract List getMarkedTraitTypes(); - - protected IGenericCharacter getCharacter() { - return character; - } - - public IMagicStats[] getExcellencies() { - List excellencies = new ArrayList(); - if (shouldShowExcellencies()) { - for (IMagicStats stats : GenericCharmUtilities.getGenericCharmStats(character)) { - String genericId = stats.getName().getId(); - if (genericId.endsWith("Excellency")) { - excellencies.add(stats); - } - } - Collections.sort(excellencies, new Comparator() { - @Override - public int compare(IMagicStats a, IMagicStats b) { - String aId = a.getName().getId(); - String bId = b.getName().getId(); - - Integer aIndex = new Integer(aId.substring(aId.lastIndexOf('.') + 1, aId.indexOf("Excellency") - 2)); - Integer bIndex = new Integer(bId.substring(bId.lastIndexOf('.') + 1, bId.indexOf("Excellency") - 2)); - return aIndex.compareTo(bIndex); - } - }); - } - return excellencies.toArray(new IMagicStats[excellencies.size()]); - } - - public abstract boolean shouldShowExcellencies(); - - public abstract IIdentifiedTraitTypeGroup[] getIdentifiedTraitTypeGroups(); - - public abstract IGenericTraitCollection getTraitCollection(); - - public boolean[] hasExcellenciesLearned(ITraitType traitType) { - IMagicStats[] excellencies = getExcellencies(); - List allLearnedMagic = character.getAllLearnedMagic(); - boolean[] excellencyLearned = new boolean[excellencies.length]; - for (int i = 0; i < excellencies.length; i++) { - final String charmId = excellencies[i].getName().getId() + "." + traitType.getId(); //$NON-NLS-1$ - excellencyLearned[i] = CollectionUtilities.getFirst(allLearnedMagic, new IPredicate() { - @Override - public boolean evaluate(IMagic value) { - return charmId.equals(value.getId()); - } - }) != null; - } - return excellencyLearned; - } - - public abstract String getExcellencyCommentKey(); - - public int getTraitMax() { - IIdentifiedTraitTypeGroup group = getIdentifiedTraitTypeGroups()[0]; - ITraitType traitType = group.getAllGroupTypes()[0]; - ITraitTemplate template = character.getTemplate().getTraitTemplateCollection().getTraitTemplate(traitType); - return template.getLimitation().getAbsoluteLimit(character); - } - - @Override - public boolean hasContent() { - return true; - } - - @Override - public abstract String getHeaderKey(); - - public String getGroupLabel(IIdentificate groupId) { - String groupIdAsString = groupId.getId(); - String resourceKey = groupId instanceof ICasteType ? "Caste." + groupIdAsString : getGroupNamePrefix() + groupIdAsString; //$NON-NLS-1$ - return getString(resourceKey); - } - - public boolean hasGroupLabel() { - return getGroupNamePrefix() == null; - } - - protected abstract String getGroupNamePrefix(); - - public String getTraitLabel(ITraitType traitType) { - return getString(getTraitTypePrefix() + traitType.getId()); - } - - protected abstract String getTraitTypePrefix(); - - public String getMobilityPenaltyText() { - return " : " + getString(getMarkerCommentKey()); //$NON-NLS-1$ - } - - public abstract String getMarkerCommentKey(); - - public String getExcellenciesComment() { - int nExcellencies = getExcellencies().length; - StringBuilder numbers = new StringBuilder(); - for (int i = 1; i <= nExcellencies; i++) { - numbers.append(Integer.toString(i)); - } - return numbers.toString() + ": " + getString(getExcellencyCommentKey()); - } -} +package net.sf.anathema.character.reporting.pdf.content.traits; + +import net.sf.anathema.character.generic.caste.ICasteType; +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.generic.character.IGenericTraitCollection; +import net.sf.anathema.character.generic.magic.IMagic; +import net.sf.anathema.character.generic.magic.IMagicStats; +import net.sf.anathema.character.generic.traits.ITraitTemplate; +import net.sf.anathema.character.generic.traits.ITraitType; +import net.sf.anathema.character.generic.traits.groups.IIdentifiedTraitTypeGroup; +import net.sf.anathema.character.reporting.pdf.content.AbstractSubBoxContent; +import net.sf.anathema.character.reporting.pdf.content.magic.GenericCharmUtilities; +import net.sf.anathema.lib.collection.CollectionUtilities; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.IPredicate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public abstract class FavorableTraitContent extends AbstractSubBoxContent { + + private IGenericCharacter character; + + public FavorableTraitContent(IGenericCharacter character, IResources resources) { + super(resources); + this.character = character; + } + + public abstract List getMarkedTraitTypes(); + + protected IGenericCharacter getCharacter() { + return character; + } + + public IMagicStats[] getExcellencies() { + List excellencies = new ArrayList(); + if (shouldShowExcellencies()) { + for (IMagicStats stats : GenericCharmUtilities.getGenericCharmStats(character)) { + String genericId = stats.getName().getId(); + if (genericId.endsWith("Excellency")) { + excellencies.add(stats); + } + } + Collections.sort(excellencies, new Comparator() { + @Override + public int compare(IMagicStats a, IMagicStats b) { + String aId = a.getName().getId(); + String bId = b.getName().getId(); + + Integer aIndex = new Integer(aId.substring(aId.lastIndexOf('.') + 1, aId.indexOf("Excellency") - 2)); + Integer bIndex = new Integer(bId.substring(bId.lastIndexOf('.') + 1, bId.indexOf("Excellency") - 2)); + return aIndex.compareTo(bIndex); + } + }); + } + return excellencies.toArray(new IMagicStats[excellencies.size()]); + } + + public abstract boolean shouldShowExcellencies(); + + public abstract IIdentifiedTraitTypeGroup[] getIdentifiedTraitTypeGroups(); + + public abstract IGenericTraitCollection getTraitCollection(); + + public boolean[] hasExcellenciesLearned(ITraitType traitType) { + IMagicStats[] excellencies = getExcellencies(); + List allLearnedMagic = character.getAllLearnedMagic(); + boolean[] excellencyLearned = new boolean[excellencies.length]; + for (int i = 0; i < excellencies.length; i++) { + final String charmId = excellencies[i].getName().getId() + "." + traitType.getId(); //$NON-NLS-1$ + excellencyLearned[i] = CollectionUtilities.getFirst(allLearnedMagic, new IPredicate() { + @Override + public boolean evaluate(IMagic value) { + return charmId.equals(value.getId()); + } + }) != null; + } + return excellencyLearned; + } + + public abstract String getExcellencyCommentKey(); + + public int getTraitMax() { + IIdentifiedTraitTypeGroup group = getIdentifiedTraitTypeGroups()[0]; + ITraitType traitType = group.getAllGroupTypes()[0]; + ITraitTemplate template = character.getTemplate().getTraitTemplateCollection().getTraitTemplate(traitType); + return template.getLimitation().getAbsoluteLimit(character); + } + + @Override + public boolean hasContent() { + return true; + } + + @Override + public abstract String getHeaderKey(); + + public String getGroupLabel(Identified groupId) { + String groupIdAsString = groupId.getId(); + String resourceKey = groupId instanceof ICasteType ? "Caste." + groupIdAsString : getGroupNamePrefix() + groupIdAsString; //$NON-NLS-1$ + return getString(resourceKey); + } + + public boolean hasGroupLabel() { + return getGroupNamePrefix() == null; + } + + protected abstract String getGroupNamePrefix(); + + public String getTraitLabel(ITraitType traitType) { + return getString(getTraitTypePrefix() + traitType.getId()); + } + + protected abstract String getTraitTypePrefix(); + + public String getMobilityPenaltyText() { + return " : " + getString(getMarkerCommentKey()); //$NON-NLS-1$ + } + + public abstract String getMarkerCommentKey(); + + public String getExcellenciesComment() { + int nExcellencies = getExcellencies().length; + StringBuilder numbers = new StringBuilder(); + for (int i = 1; i <= nExcellencies; i++) { + numbers.append(Integer.toString(i)); + } + return numbers.toString() + ": " + getString(getExcellencyCommentKey()); + } +} diff --git a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/EncoderFactory.java b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/EncoderFactory.java index 402901104d..78d3f973cb 100644 --- a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/EncoderFactory.java +++ b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/EncoderFactory.java @@ -1,15 +1,15 @@ -package net.sf.anathema.character.reporting.pdf.rendering.boxes; - -import net.sf.anathema.character.reporting.pdf.content.BasicContent; -import net.sf.anathema.character.reporting.pdf.rendering.general.box.ContentEncoder; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; - -public interface EncoderFactory extends IIdentificate { - - ContentEncoder create(IResources resources, BasicContent content); - - boolean supports(BasicContent content); - - float getPreferredHeight(EncodingMetrics metrics, float width); -} +package net.sf.anathema.character.reporting.pdf.rendering.boxes; + +import net.sf.anathema.character.reporting.pdf.content.BasicContent; +import net.sf.anathema.character.reporting.pdf.rendering.general.box.ContentEncoder; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; + +public interface EncoderFactory extends Identified { + + ContentEncoder create(IResources resources, BasicContent content); + + boolean supports(BasicContent content); + + float getPreferredHeight(EncodingMetrics metrics, float width); +} diff --git a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/ExtendedMagicEncoder.java b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/ExtendedMagicEncoder.java index 184502c4ac..7f317794df 100644 --- a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/ExtendedMagicEncoder.java +++ b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/ExtendedMagicEncoder.java @@ -1,110 +1,110 @@ -package net.sf.anathema.character.reporting.pdf.rendering.boxes.magic; - -import com.itextpdf.text.DocumentException; -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.IMagic; -import net.sf.anathema.character.generic.magic.IMagicStats; -import net.sf.anathema.character.generic.magic.IMagicVisitor; -import net.sf.anathema.character.generic.magic.ISpell; -import net.sf.anathema.character.reporting.pdf.content.ReportSession; -import net.sf.anathema.character.reporting.pdf.content.magic.AbstractMagicContent; -import net.sf.anathema.character.reporting.pdf.content.magic.GenericCharmUtilities; -import net.sf.anathema.character.reporting.pdf.content.stats.magic.CharmStats; -import net.sf.anathema.character.reporting.pdf.content.stats.magic.MultipleEffectCharmStats; -import net.sf.anathema.character.reporting.pdf.content.stats.magic.SpellStats; -import net.sf.anathema.character.reporting.pdf.rendering.extent.Bounds; -import net.sf.anathema.character.reporting.pdf.rendering.general.box.ContentEncoder; -import net.sf.anathema.character.reporting.pdf.rendering.graphics.SheetGraphics; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import java.util.ArrayList; -import java.util.List; - -public class ExtendedMagicEncoder implements ContentEncoder { - static IIdentificate KNACK = new Identificate("Knack"); - private IResources resources; - - public static List collectPrintCharms(ReportSession session) { - return collectPrintMagic(session.getCharacter(), false, true); - } - - public static List collectPrintSpells(ReportSession session) { - return collectPrintMagic(session.getCharacter(), true, false); - } - - private static List collectPrintMagic(final IGenericCharacter character, final boolean includeSpells, - final boolean includeCharms) { - final List printStats = new ArrayList(); - if (includeCharms) { - for (IMagicStats stats : GenericCharmUtilities.getGenericCharmStats(character)) { - if (GenericCharmUtilities.shouldShowCharm(stats, character)) { - printStats.add(stats); - } - } - } - - IMagicVisitor statsCollector = new IMagicVisitor() { - @Override - public void visitCharm(ICharm charm) { - if (!includeCharms) { - return; - } - if (GenericCharmUtilities.isGenericCharmFor(charm, character)) { - return; - } - if (charm.hasAttribute(KNACK)) { - return; - } - - if (character.isMultipleEffectCharm(charm)) { - String[] effects = character.getLearnedEffects(charm); - for (String effect : effects) { - printStats.add(new MultipleEffectCharmStats(charm, effect)); - } - } else { - printStats.add(new CharmStats(charm, character)); - } - } - - @Override - public void visitSpell(ISpell spell) { - if (includeSpells) { - printStats.add(new SpellStats(spell)); - } - } - }; - for (IMagic magic : character.getAllLearnedMagic()) { - magic.accept(statsCollector); - } - return printStats; - } - - private final MagicTableEncoder tableEncoder; - private final String headerKey; - - public ExtendedMagicEncoder(IResources resources, Class contentClass, boolean sectionHeaderLines, String headerKey) { - this.resources = resources; - this.tableEncoder = new MagicTableEncoder(sectionHeaderLines, contentClass); - this.headerKey = headerKey; - } - - @Override - public void encode(SheetGraphics graphics, ReportSession reportSession, Bounds bounds) throws DocumentException { - float top = bounds.getMinY(); - Bounds remainingBounds = new Bounds(bounds.getMinX(), top, bounds.getWidth(), bounds.getMaxY() - top); - tableEncoder.encodeTable(graphics, reportSession, remainingBounds); - } - - @Override - public boolean hasContent(ReportSession session) { - return true; - } - - @Override - public String getHeader(ReportSession session) { - return resources.getString("Sheet.Header." + headerKey); - } -} +package net.sf.anathema.character.reporting.pdf.rendering.boxes.magic; + +import com.itextpdf.text.DocumentException; +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.IMagic; +import net.sf.anathema.character.generic.magic.IMagicStats; +import net.sf.anathema.character.generic.magic.IMagicVisitor; +import net.sf.anathema.character.generic.magic.ISpell; +import net.sf.anathema.character.reporting.pdf.content.ReportSession; +import net.sf.anathema.character.reporting.pdf.content.magic.AbstractMagicContent; +import net.sf.anathema.character.reporting.pdf.content.magic.GenericCharmUtilities; +import net.sf.anathema.character.reporting.pdf.content.stats.magic.CharmStats; +import net.sf.anathema.character.reporting.pdf.content.stats.magic.MultipleEffectCharmStats; +import net.sf.anathema.character.reporting.pdf.content.stats.magic.SpellStats; +import net.sf.anathema.character.reporting.pdf.rendering.extent.Bounds; +import net.sf.anathema.character.reporting.pdf.rendering.general.box.ContentEncoder; +import net.sf.anathema.character.reporting.pdf.rendering.graphics.SheetGraphics; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.List; + +public class ExtendedMagicEncoder implements ContentEncoder { + static Identified KNACK = new Identificate("Knack"); + private IResources resources; + + public static List collectPrintCharms(ReportSession session) { + return collectPrintMagic(session.getCharacter(), false, true); + } + + public static List collectPrintSpells(ReportSession session) { + return collectPrintMagic(session.getCharacter(), true, false); + } + + private static List collectPrintMagic(final IGenericCharacter character, final boolean includeSpells, + final boolean includeCharms) { + final List printStats = new ArrayList(); + if (includeCharms) { + for (IMagicStats stats : GenericCharmUtilities.getGenericCharmStats(character)) { + if (GenericCharmUtilities.shouldShowCharm(stats, character)) { + printStats.add(stats); + } + } + } + + IMagicVisitor statsCollector = new IMagicVisitor() { + @Override + public void visitCharm(ICharm charm) { + if (!includeCharms) { + return; + } + if (GenericCharmUtilities.isGenericCharmFor(charm, character)) { + return; + } + if (charm.hasAttribute(KNACK)) { + return; + } + + if (character.isMultipleEffectCharm(charm)) { + String[] effects = character.getLearnedEffects(charm); + for (String effect : effects) { + printStats.add(new MultipleEffectCharmStats(charm, effect)); + } + } else { + printStats.add(new CharmStats(charm, character)); + } + } + + @Override + public void visitSpell(ISpell spell) { + if (includeSpells) { + printStats.add(new SpellStats(spell)); + } + } + }; + for (IMagic magic : character.getAllLearnedMagic()) { + magic.accept(statsCollector); + } + return printStats; + } + + private final MagicTableEncoder tableEncoder; + private final String headerKey; + + public ExtendedMagicEncoder(IResources resources, Class contentClass, boolean sectionHeaderLines, String headerKey) { + this.resources = resources; + this.tableEncoder = new MagicTableEncoder(sectionHeaderLines, contentClass); + this.headerKey = headerKey; + } + + @Override + public void encode(SheetGraphics graphics, ReportSession reportSession, Bounds bounds) throws DocumentException { + float top = bounds.getMinY(); + Bounds remainingBounds = new Bounds(bounds.getMinX(), top, bounds.getWidth(), bounds.getMaxY() - top); + tableEncoder.encodeTable(graphics, reportSession, remainingBounds); + } + + @Override + public boolean hasContent(ReportSession session) { + return true; + } + + @Override + public String getHeader(ReportSession session) { + return resources.getString("Sheet.Header." + headerKey); + } +} diff --git a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/MagicStatsFactoryVisitor.java b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/MagicStatsFactoryVisitor.java index 14e1962a1c..9d1a1b0f89 100644 --- a/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/MagicStatsFactoryVisitor.java +++ b/Character_Reporting/src/net/sf/anathema/character/reporting/pdf/rendering/boxes/magic/MagicStatsFactoryVisitor.java @@ -1,49 +1,49 @@ -package net.sf.anathema.character.reporting.pdf.rendering.boxes.magic; - -import net.sf.anathema.character.generic.character.IGenericCharacter; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.IMagicStats; -import net.sf.anathema.character.generic.magic.IMagicVisitor; -import net.sf.anathema.character.generic.magic.ISpell; -import net.sf.anathema.character.reporting.pdf.content.magic.GenericCharmUtilities; -import net.sf.anathema.character.reporting.pdf.content.stats.magic.CharmStats; -import net.sf.anathema.character.reporting.pdf.content.stats.magic.MultipleEffectCharmStats; -import net.sf.anathema.character.reporting.pdf.content.stats.magic.SpellStats; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.lib.util.Identificate; - -import java.util.List; - -public class MagicStatsFactoryVisitor implements IMagicVisitor { - private final static IIdentificate KNACK = new Identificate("Knack"); - private final IGenericCharacter character; - private final List printStats; - - public MagicStatsFactoryVisitor(IGenericCharacter character, List printStats) { - this.character = character; - this.printStats = printStats; - } - - @Override - public void visitCharm(ICharm charm) { - if (GenericCharmUtilities.isGenericCharmFor(charm, character)) { - return; - } - if (charm.hasAttribute(KNACK)) { - return; - } - if (character.isMultipleEffectCharm(charm)) { - String[] effects = character.getLearnedEffects(charm); - for (String effect : effects) { - printStats.add(new MultipleEffectCharmStats(charm, effect)); - } - } else { - printStats.add(new CharmStats(charm, character)); - } - } - - @Override - public void visitSpell(ISpell spell) { - printStats.add(new SpellStats(spell)); - } -} +package net.sf.anathema.character.reporting.pdf.rendering.boxes.magic; + +import net.sf.anathema.character.generic.character.IGenericCharacter; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.IMagicStats; +import net.sf.anathema.character.generic.magic.IMagicVisitor; +import net.sf.anathema.character.generic.magic.ISpell; +import net.sf.anathema.character.reporting.pdf.content.magic.GenericCharmUtilities; +import net.sf.anathema.character.reporting.pdf.content.stats.magic.CharmStats; +import net.sf.anathema.character.reporting.pdf.content.stats.magic.MultipleEffectCharmStats; +import net.sf.anathema.character.reporting.pdf.content.stats.magic.SpellStats; +import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.List; + +public class MagicStatsFactoryVisitor implements IMagicVisitor { + private final static Identified KNACK = new Identificate("Knack"); + private final IGenericCharacter character; + private final List printStats; + + public MagicStatsFactoryVisitor(IGenericCharacter character, List printStats) { + this.character = character; + this.printStats = printStats; + } + + @Override + public void visitCharm(ICharm charm) { + if (GenericCharmUtilities.isGenericCharmFor(charm, character)) { + return; + } + if (charm.hasAttribute(KNACK)) { + return; + } + if (character.isMultipleEffectCharm(charm)) { + String[] effects = character.getLearnedEffects(charm); + for (String effect : effects) { + printStats.add(new MultipleEffectCharmStats(charm, effect)); + } + } else { + printStats.add(new CharmStats(charm, character)); + } + } + + @Override + public void visitSpell(ISpell spell) { + printStats.add(new SpellStats(spell)); + } +} diff --git a/Character_Sidereal/src/net/sf/anathema/character/sidereal/colleges/presenter/IAstrologicalHouse.java b/Character_Sidereal/src/net/sf/anathema/character/sidereal/colleges/presenter/IAstrologicalHouse.java index d5051a0818..075645649d 100644 --- a/Character_Sidereal/src/net/sf/anathema/character/sidereal/colleges/presenter/IAstrologicalHouse.java +++ b/Character_Sidereal/src/net/sf/anathema/character/sidereal/colleges/presenter/IAstrologicalHouse.java @@ -2,9 +2,9 @@ import net.sf.anathema.character.library.trait.IFavorableDefaultTrait; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IAstrologicalHouse extends IIdentificate { +public interface IAstrologicalHouse extends Identified { IFavorableDefaultTrait[] getColleges(); diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/ByCharacterType.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/ByCharacterType.java index 595f317ff6..b898d90de1 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/ByCharacterType.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/ByCharacterType.java @@ -1,26 +1,26 @@ -package net.sf.anathema.cascades.presenter; - -import net.sf.anathema.character.generic.type.CharacterType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.Comparator; - -public class ByCharacterType implements Comparator { - - @Override - public int compare(IIdentificate o1, IIdentificate o2) { - boolean firstCharacterType = o1 instanceof ICharacterType; - boolean secondCharacterType = o2 instanceof CharacterType; - if (firstCharacterType) { - if (secondCharacterType) { - return ((ICharacterType) o1).compareTo((CharacterType) o2); - } - return -1; - } - if (secondCharacterType) { - return 1; - } - return 0; - } +package net.sf.anathema.cascades.presenter; + +import net.sf.anathema.character.generic.type.CharacterType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.lib.util.Identified; + +import java.util.Comparator; + +public class ByCharacterType implements Comparator { + + @Override + public int compare(Identified o1, Identified o2) { + boolean firstCharacterType = o1 instanceof ICharacterType; + boolean secondCharacterType = o2 instanceof CharacterType; + if (firstCharacterType) { + if (secondCharacterType) { + return ((ICharacterType) o1).compareTo((CharacterType) o2); + } + return -1; + } + if (secondCharacterType) { + return 1; + } + return 0; + } } \ No newline at end of file diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmGroupChangeListener.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmGroupChangeListener.java index d2f856ccc9..6c5d4e7832 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmGroupChangeListener.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmGroupChangeListener.java @@ -5,7 +5,7 @@ import net.sf.anathema.charmtree.presenter.CharmFilterSet; import net.sf.anathema.charmtree.presenter.view.AbstractCharmGroupChangeListener; import net.sf.anathema.charmtree.presenter.view.CharmDisplayPropertiesMap; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.platform.svgtree.document.visualizer.ITreePresentationProperties; import java.awt.Color; @@ -26,13 +26,13 @@ public CascadeCharmGroupChangeListener(ICascadeView cascadeView, CascadeCharmTre } @Override - protected final void modifyCharmVisuals(IIdentificate type) { + protected final void modifyCharmVisuals(Identified type) { viewProperties.setCharmType(type); Color color = findColor(type); cascadeView.setBackgroundColor(color); } - private Color findColor(IIdentificate type) { + private Color findColor(Identified type) { if (type instanceof ICharacterType) { ITreePresentationProperties displayProperties = getDisplayProperties((ICharacterType) type); return displayProperties.getColor(); diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTreeViewProperties.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTreeViewProperties.java index 49dfa17807..e8a4480121 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTreeViewProperties.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTreeViewProperties.java @@ -8,13 +8,13 @@ import net.sf.anathema.charmtree.presenter.view.AbstractCharmTreeViewProperties; import net.sf.anathema.charmtree.presenter.view.NullSpecialCharm; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import java.awt.Cursor; public class CascadeCharmTreeViewProperties extends AbstractCharmTreeViewProperties { - private IIdentificate type; + private Identified type; private CharmTreeIdentificateMap treeIdentificateMap; private final ICharmCache cache; private final ICharacterGenerics generics; @@ -48,7 +48,7 @@ protected ISpecialCharm getSpecialCharm(String id) { return new NullSpecialCharm(); } - public void setCharmType(IIdentificate type) { + public void setCharmType(Identified type) { this.type = type; } diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTypes.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTypes.java index e5563f5b93..d6c7b15665 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTypes.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeCharmTypes.java @@ -1,54 +1,54 @@ -package net.sf.anathema.cascades.presenter; - -import net.sf.anathema.character.generic.template.ICharacterTemplate; -import net.sf.anathema.character.generic.template.ITemplateRegistry; -import net.sf.anathema.character.generic.template.magic.ICharmTemplate; -import net.sf.anathema.character.generic.type.CharacterType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.character.presenter.magic.AbstractCharmTypes; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -public class CascadeCharmTypes extends AbstractCharmTypes { - private ITemplateRegistry templateRegistry; - - public CascadeCharmTypes(ITemplateRegistry templateRegistry) { - this.templateRegistry = templateRegistry; - } - - @Override - protected List getCurrentCharacterTypes() { - Set set = new LinkedHashSet(); - for (ICharacterType type : CharacterType.values()) { - ICharacterTemplate defaultTemplate = templateRegistry.getDefaultTemplate(type); - if (defaultTemplate == null) { - continue; - } - if (defaultTemplate.getMagicTemplate().getCharmTemplate().canLearnCharms()) { - set.add(type); - } - } - return new ArrayList(set); - } - - @Override - protected List getAdditionalCharmTypes() { - Set set = new LinkedHashSet(); - for (ICharacterType type : CharacterType.values()) { - ICharacterTemplate defaultTemplate = templateRegistry.getDefaultTemplate(type); - if (defaultTemplate == null) { - continue; - } - ICharmTemplate charmTemplate = defaultTemplate.getMagicTemplate().getCharmTemplate(); - if (!charmTemplate.hasUniqueCharms()) { - continue; - } - set.add(charmTemplate.getUniqueCharmType().getId()); - } - return new ArrayList(set); - } +package net.sf.anathema.cascades.presenter; + +import net.sf.anathema.character.generic.template.ICharacterTemplate; +import net.sf.anathema.character.generic.template.ITemplateRegistry; +import net.sf.anathema.character.generic.template.magic.ICharmTemplate; +import net.sf.anathema.character.generic.type.CharacterType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.character.presenter.magic.AbstractCharmTypes; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +public class CascadeCharmTypes extends AbstractCharmTypes { + private ITemplateRegistry templateRegistry; + + public CascadeCharmTypes(ITemplateRegistry templateRegistry) { + this.templateRegistry = templateRegistry; + } + + @Override + protected List getCurrentCharacterTypes() { + Set set = new LinkedHashSet(); + for (ICharacterType type : CharacterType.values()) { + ICharacterTemplate defaultTemplate = templateRegistry.getDefaultTemplate(type); + if (defaultTemplate == null) { + continue; + } + if (defaultTemplate.getMagicTemplate().getCharmTemplate().canLearnCharms()) { + set.add(type); + } + } + return new ArrayList(set); + } + + @Override + protected List getAdditionalCharmTypes() { + Set set = new LinkedHashSet(); + for (ICharacterType type : CharacterType.values()) { + ICharacterTemplate defaultTemplate = templateRegistry.getDefaultTemplate(type); + if (defaultTemplate == null) { + continue; + } + ICharmTemplate charmTemplate = defaultTemplate.getMagicTemplate().getCharmTemplate(); + if (!charmTemplate.hasUniqueCharms()) { + continue; + } + set.add(charmTemplate.getUniqueCharmType().getId()); + } + return new ArrayList(set); + } } \ No newline at end of file diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeGroupCollection.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeGroupCollection.java index 00764cbdcd..2d11c24d94 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeGroupCollection.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadeGroupCollection.java @@ -1,81 +1,81 @@ -package net.sf.anathema.cascades.presenter; - -import net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities; -import net.sf.anathema.character.generic.impl.magic.charm.CharmTree; -import net.sf.anathema.character.generic.impl.magic.charm.MartialArtsCharmTree; -import net.sf.anathema.character.generic.magic.charms.ICharmGroup; -import net.sf.anathema.character.generic.magic.charms.ICharmTree; -import net.sf.anathema.character.generic.template.ICharacterTemplate; -import net.sf.anathema.character.generic.template.ITemplateRegistry; -import net.sf.anathema.character.generic.template.magic.ICharmTemplate; -import net.sf.anathema.character.generic.template.magic.IUniqueCharmType; -import net.sf.anathema.character.generic.type.CharacterType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.charmtree.presenter.CharmGroupCollection; -import net.sf.anathema.lib.util.IIdentificate; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class CascadeGroupCollection implements CharmGroupCollection { - private ITemplateRegistry templateRegistry; - private CharmTreeIdentificateMap treeIdentificateMap; - - public CascadeGroupCollection(ITemplateRegistry templateRegistry, CharmTreeIdentificateMap treeIdentificateMap) { - this.templateRegistry = templateRegistry; - this.treeIdentificateMap = treeIdentificateMap; - } - - @Override - public ICharmGroup[] getCharmGroups() { - List allCharmGroups = new ArrayList(); - initCharacterTypeCharms(allCharmGroups); - initMartialArtsCharms(allCharmGroups); - return allCharmGroups.toArray(new ICharmGroup[allCharmGroups.size()]); - } - - private void initCharacterTypeCharms(List allCharmGroups) { - for (ICharacterType type : CharacterType.values()) { - ICharacterTemplate template = templateRegistry.getDefaultTemplate(type); - if (template == null) { - continue; - } - ICharmTemplate charmTemplate = template.getMagicTemplate().getCharmTemplate(); - if (charmTemplate.canLearnCharms()) { - registerTypeCharms(allCharmGroups, type, template); - registerUniqueCharms(allCharmGroups, charmTemplate); - } - } - } - - private void initMartialArtsCharms(List allCharmGroups) { - ICharacterTemplate template = templateRegistry.getDefaultTemplate(CharacterType.SIDEREAL); - ICharmTree martialArtsTree = new MartialArtsCharmTree(template.getMagicTemplate().getCharmTemplate()); - treeIdentificateMap.put(MartialArtsUtilities.MARTIAL_ARTS, martialArtsTree); - allCharmGroups.addAll(Arrays.asList(martialArtsTree.getAllCharmGroups())); - } - - private void registerUniqueCharms(List allCharmGroups, ICharmTemplate charmTemplate) { - if (!charmTemplate.hasUniqueCharms()) { - return; - } - IUniqueCharmType uniqueType = charmTemplate.getUniqueCharmType(); - ICharmTree uniqueTree = new CharmTree(charmTemplate.getUniqueCharms()); - registerGroups(allCharmGroups, uniqueType.getId(), uniqueTree); - } - - private void registerTypeCharms(List allCharmGroups, ICharacterType type, - ICharacterTemplate defaultTemplate) { - ICharmTree typeTree = new CharmTree(defaultTemplate.getMagicTemplate().getCharmTemplate()); - registerGroups(allCharmGroups, type, typeTree); - } - - private void registerGroups(List allCharmGroups, IIdentificate typeId, ICharmTree charmTree) { - ICharmGroup[] groups = charmTree.getAllCharmGroups(); - if (groups.length != 0) { - treeIdentificateMap.put(typeId, charmTree); - allCharmGroups.addAll(Arrays.asList(groups)); - } - } +package net.sf.anathema.cascades.presenter; + +import net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities; +import net.sf.anathema.character.generic.impl.magic.charm.CharmTree; +import net.sf.anathema.character.generic.impl.magic.charm.MartialArtsCharmTree; +import net.sf.anathema.character.generic.magic.charms.ICharmGroup; +import net.sf.anathema.character.generic.magic.charms.ICharmTree; +import net.sf.anathema.character.generic.template.ICharacterTemplate; +import net.sf.anathema.character.generic.template.ITemplateRegistry; +import net.sf.anathema.character.generic.template.magic.ICharmTemplate; +import net.sf.anathema.character.generic.template.magic.IUniqueCharmType; +import net.sf.anathema.character.generic.type.CharacterType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.charmtree.presenter.CharmGroupCollection; +import net.sf.anathema.lib.util.Identified; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CascadeGroupCollection implements CharmGroupCollection { + private ITemplateRegistry templateRegistry; + private CharmTreeIdentificateMap treeIdentificateMap; + + public CascadeGroupCollection(ITemplateRegistry templateRegistry, CharmTreeIdentificateMap treeIdentificateMap) { + this.templateRegistry = templateRegistry; + this.treeIdentificateMap = treeIdentificateMap; + } + + @Override + public ICharmGroup[] getCharmGroups() { + List allCharmGroups = new ArrayList(); + initCharacterTypeCharms(allCharmGroups); + initMartialArtsCharms(allCharmGroups); + return allCharmGroups.toArray(new ICharmGroup[allCharmGroups.size()]); + } + + private void initCharacterTypeCharms(List allCharmGroups) { + for (ICharacterType type : CharacterType.values()) { + ICharacterTemplate template = templateRegistry.getDefaultTemplate(type); + if (template == null) { + continue; + } + ICharmTemplate charmTemplate = template.getMagicTemplate().getCharmTemplate(); + if (charmTemplate.canLearnCharms()) { + registerTypeCharms(allCharmGroups, type, template); + registerUniqueCharms(allCharmGroups, charmTemplate); + } + } + } + + private void initMartialArtsCharms(List allCharmGroups) { + ICharacterTemplate template = templateRegistry.getDefaultTemplate(CharacterType.SIDEREAL); + ICharmTree martialArtsTree = new MartialArtsCharmTree(template.getMagicTemplate().getCharmTemplate()); + treeIdentificateMap.put(MartialArtsUtilities.MARTIAL_ARTS, martialArtsTree); + allCharmGroups.addAll(Arrays.asList(martialArtsTree.getAllCharmGroups())); + } + + private void registerUniqueCharms(List allCharmGroups, ICharmTemplate charmTemplate) { + if (!charmTemplate.hasUniqueCharms()) { + return; + } + IUniqueCharmType uniqueType = charmTemplate.getUniqueCharmType(); + ICharmTree uniqueTree = new CharmTree(charmTemplate.getUniqueCharms()); + registerGroups(allCharmGroups, uniqueType.getId(), uniqueTree); + } + + private void registerTypeCharms(List allCharmGroups, ICharacterType type, + ICharacterTemplate defaultTemplate) { + ICharmTree typeTree = new CharmTree(defaultTemplate.getMagicTemplate().getCharmTemplate()); + registerGroups(allCharmGroups, type, typeTree); + } + + private void registerGroups(List allCharmGroups, Identified typeId, ICharmTree charmTree) { + ICharmGroup[] groups = charmTree.getAllCharmGroups(); + if (groups.length != 0) { + treeIdentificateMap.put(typeId, charmTree); + allCharmGroups.addAll(Arrays.asList(groups)); + } + } } \ No newline at end of file diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadePresenter.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadePresenter.java index 0ef6a9a3cd..1ab33e7012 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadePresenter.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CascadePresenter.java @@ -10,7 +10,7 @@ import net.sf.anathema.charmtree.presenter.AbstractCascadePresenter; import net.sf.anathema.charmtree.presenter.view.CharmDisplayPropertiesMap; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class CascadePresenter extends AbstractCascadePresenter implements ICascadePresenter { @@ -39,7 +39,7 @@ protected CascadeFilterContainer getFilterContainer() { } @Override - protected GroupCharmTree getCharmTree(IIdentificate type) { + protected GroupCharmTree getCharmTree(Identified type) { return treeIdentificateMap.get(type); } } \ No newline at end of file diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmFinder.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmFinder.java index 33cdeee653..5942f6a8f2 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmFinder.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmFinder.java @@ -1,55 +1,55 @@ -package net.sf.anathema.cascades.presenter; - -import com.google.common.base.Predicate; -import net.sf.anathema.character.generic.impl.magic.persistence.ICharmCache; -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.type.CharacterType; -import net.sf.anathema.character.generic.type.ICharacterType; -import net.sf.anathema.lib.lang.ArrayUtilities; -import net.sf.anathema.lib.util.IIdentificate; - -import static net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities.MARTIAL_ARTS; - -public class CharmFinder { - - private final ICharmCache cache; - private final String id; - - public CharmFinder(ICharmCache cache, String id) { - this.cache = cache; - this.id = id; - } - - public ICharm find() { - ICharm charm = searchCharmByCharacterType(); - if (charm != null) { - return charm; - } - return searchCharmFromMartialArts(); - } - - private ICharm searchCharmByCharacterType() { - String[] idParts = id.split("\\."); //$NON-NLS-1$ - try { - ICharacterType characterTypeId = CharacterType.getById(idParts[0]); - return findCharm(characterTypeId); - } - catch (IllegalArgumentException e) { - return null; - } - } - - private ICharm searchCharmFromMartialArts() { - return findCharm(MARTIAL_ARTS); - } - - private ICharm findCharm(IIdentificate treeType) { - ICharm[] charms = cache.getCharms(treeType); - return ArrayUtilities.find(new Predicate() { - @Override - public boolean apply(ICharm candidate) { - return candidate.getId().equals(id); - } - }, charms); - } +package net.sf.anathema.cascades.presenter; + +import com.google.common.base.Predicate; +import net.sf.anathema.character.generic.impl.magic.persistence.ICharmCache; +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.type.CharacterType; +import net.sf.anathema.character.generic.type.ICharacterType; +import net.sf.anathema.lib.lang.ArrayUtilities; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.character.generic.impl.magic.MartialArtsUtilities.MARTIAL_ARTS; + +public class CharmFinder { + + private final ICharmCache cache; + private final String id; + + public CharmFinder(ICharmCache cache, String id) { + this.cache = cache; + this.id = id; + } + + public ICharm find() { + ICharm charm = searchCharmByCharacterType(); + if (charm != null) { + return charm; + } + return searchCharmFromMartialArts(); + } + + private ICharm searchCharmByCharacterType() { + String[] idParts = id.split("\\."); //$NON-NLS-1$ + try { + ICharacterType characterTypeId = CharacterType.getById(idParts[0]); + return findCharm(characterTypeId); + } + catch (IllegalArgumentException e) { + return null; + } + } + + private ICharm searchCharmFromMartialArts() { + return findCharm(MARTIAL_ARTS); + } + + private ICharm findCharm(Identified treeType) { + ICharm[] charms = cache.getCharms(treeType); + return ArrayUtilities.find(new Predicate() { + @Override + public boolean apply(ICharm candidate) { + return candidate.getId().equals(id); + } + }, charms); + } } \ No newline at end of file diff --git a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmTreeIdentificateMap.java b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmTreeIdentificateMap.java index f65c93d453..656250fb40 100644 --- a/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmTreeIdentificateMap.java +++ b/Charm_Cascades/src/net/sf/anathema/cascades/presenter/CharmTreeIdentificateMap.java @@ -1,25 +1,25 @@ package net.sf.anathema.cascades.presenter; +import net.sf.anathema.character.generic.magic.charms.ICharmTree; +import net.sf.anathema.lib.util.Identified; + import java.util.HashMap; import java.util.Map; import java.util.Set; -import net.sf.anathema.character.generic.magic.charms.ICharmTree; -import net.sf.anathema.lib.util.IIdentificate; - public class CharmTreeIdentificateMap { - Map charmTreesById = new HashMap(); + Map charmTreesById = new HashMap(); - public void put(IIdentificate id, ICharmTree tree) { + public void put(Identified id, ICharmTree tree) { charmTreesById.put(id, tree); } - public ICharmTree get(IIdentificate id) { + public ICharmTree get(Identified id) { return charmTreesById.get(id); } - public Set keySet() { + public Set keySet() { return charmTreesById.keySet(); } } \ No newline at end of file diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/model/KeywordEntryModel.java b/Charm_Entry/src/net/sf/anathema/charmentry/model/KeywordEntryModel.java index 3aa34bf3b6..e133f2287e 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/model/KeywordEntryModel.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/model/KeywordEntryModel.java @@ -8,11 +8,11 @@ import net.sf.anathema.character.library.removableentry.model.AbstractRemovableEntryModel; import net.sf.anathema.charmentry.model.data.IConfigurableCharmData; import net.sf.anathema.charmentry.presenter.model.IKeywordEntryModel; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class KeywordEntryModel extends AbstractRemovableEntryModel implements IKeywordEntryModel { - private IIdentificate keyword; + private Identified keyword; private final IConfigurableCharmData charmData; public KeywordEntryModel(IConfigurableCharmData charmData) { @@ -52,7 +52,7 @@ protected boolean isEntryAllowed() { } @Override - public void setCurrentKeyword(IIdentificate keyword) { + public void setCurrentKeyword(Identified keyword) { this.keyword = keyword; fireEntryChanged(); } @@ -65,8 +65,8 @@ public void clear() { } @Override - public IIdentificate[] getAvailableKeywords() { - return new IIdentificate[] { + public Identified[] getAvailableKeywords() { + return new Identified[] { ICharmData.ALLOWS_CELESTIAL_ATTRIBUTE, ICharmData.FORM_ATTRIBUTE, ICharmData.NO_STYLE_ATTRIBUTE, diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/KeywordEntryPage.java b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/KeywordEntryPage.java index 0f21bc5ded..2b07446ea2 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/KeywordEntryPage.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/KeywordEntryPage.java @@ -16,7 +16,7 @@ import net.sf.anathema.lib.gui.wizard.workflow.CheckInputListener; import net.sf.anathema.lib.message.IBasicMessage; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -50,20 +50,20 @@ protected void initModelListening(CheckInputListener inputListener) { @Override protected void initPageContent() { this.view = viewFactory.createKeywordEntryView(); - final IButtonControlledObjectSelectionView selectionView = view.addObjectSelectionView( + final IButtonControlledObjectSelectionView selectionView = view.addObjectSelectionView( properties.getKeywordRenderer(), properties.getKeywordLabel(), properties.getAddIcon()); selectionView.setObjects(getPageModel().getAvailableKeywords()); - selectionView.addObjectSelectionChangedListener(new ObjectValueListener() { + selectionView.addObjectSelectionChangedListener(new ObjectValueListener() { @Override - public void valueChanged(IIdentificate newValue) { + public void valueChanged(Identified newValue) { getPageModel().setCurrentKeyword(newValue); } }); - selectionView.addButtonListener(new ObjectValueListener() { + selectionView.addButtonListener(new ObjectValueListener() { @Override - public void valueChanged(IIdentificate newValue) { + public void valueChanged(Identified newValue) { getPageModel().commitSelection(); } }); diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/PrerequisitesEntryPage.java b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/PrerequisitesEntryPage.java index e2b7787169..ec7c80c7c2 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/PrerequisitesEntryPage.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/PrerequisitesEntryPage.java @@ -19,7 +19,7 @@ import net.sf.anathema.lib.gui.wizard.workflow.ICondition; import net.sf.anathema.lib.message.IBasicMessage; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class PrerequisitesEntryPage extends AbstractAnathemaWizardPage { @@ -78,14 +78,14 @@ protected void initPageContent() { } private void initPrimaryPrerequistePresentation() { - final ISelectableIntValueView primaryView = view.addSelectablePrerequisiteView( + final ISelectableIntValueView primaryView = view.addSelectablePrerequisiteView( properties.getPrimaryPrerequisiteLabel(), getPageModel().getPrimaryPrerequisiteTypes(), 1, EssenceTemplate.SYSTEM_ESSENCE_MAX); - primaryView.addSelectionChangedListener(new ISelectionIntValueChangedListener() { + primaryView.addSelectionChangedListener(new ISelectionIntValueChangedListener() { @Override - public void valueChanged(IIdentificate type, int value) { + public void valueChanged(Identified type, int value) { getPageModel().setPrimaryPrerequisite((ITraitType) type, value); } }); diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/model/IKeywordEntryModel.java b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/model/IKeywordEntryModel.java index 67f9042185..ae72640f11 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/model/IKeywordEntryModel.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/model/IKeywordEntryModel.java @@ -2,13 +2,13 @@ import net.sf.anathema.character.generic.magic.charms.ICharmAttribute; import net.sf.anathema.character.library.removableentry.presenter.IRemovableEntryModel; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IKeywordEntryModel extends IRemovableEntryModel { - void setCurrentKeyword(IIdentificate keyword); + void setCurrentKeyword(Identified keyword); void clear(); - IIdentificate[] getAvailableKeywords(); + Identified[] getAvailableKeywords(); } \ No newline at end of file diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IKeywordView.java b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IKeywordView.java index 8a59ab6abd..864210e930 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IKeywordView.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IKeywordView.java @@ -4,12 +4,12 @@ import net.sf.anathema.character.library.removableentry.presenter.IRemovableEntryView; import net.sf.anathema.framework.presenter.view.IButtonControlledObjectSelectionView; import net.sf.anathema.lib.gui.dialog.core.IPageContent; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.Icon; import javax.swing.ListCellRenderer; public interface IKeywordView extends IRemovableEntriesView, IPageContent { - IButtonControlledObjectSelectionView addObjectSelectionView(ListCellRenderer renderer, String label, Icon icon); + IButtonControlledObjectSelectionView addObjectSelectionView(ListCellRenderer renderer, String label, Icon icon); } \ No newline at end of file diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IPrerequisitesEntryView.java b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IPrerequisitesEntryView.java index 523630822e..c35eec6c9a 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IPrerequisitesEntryView.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/presenter/view/IPrerequisitesEntryView.java @@ -3,11 +3,11 @@ import net.sf.anathema.character.generic.framework.intvalue.ISelectableIntValueView; import net.sf.anathema.framework.value.IIntValueView; import net.sf.anathema.lib.gui.dialog.core.IPageContent; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface IPrerequisitesEntryView extends IPageContent { - ISelectableIntValueView addSelectablePrerequisiteView(String string, IIdentificate[] traits, int initial, int max); + ISelectableIntValueView addSelectablePrerequisiteView(String string, Identified[] traits, int initial, int max); IIntValueView addEssencePrerequisiteView(String label, int minimum, int maximum); } diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/view/KeywordView.java b/Charm_Entry/src/net/sf/anathema/charmentry/view/KeywordView.java index 92ed036099..7ebe1a058b 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/view/KeywordView.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/view/KeywordView.java @@ -1,10 +1,5 @@ package net.sf.anathema.charmentry.view; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.ListCellRenderer; - import net.disy.commons.swing.layout.grid.GridDialogLayout; import net.sf.anathema.character.library.removableentry.presenter.IRemovableEntryView; import net.sf.anathema.character.library.removableentry.view.RemovableStringView; @@ -12,7 +7,12 @@ import net.sf.anathema.charmentry.presenter.view.IKeywordView; import net.sf.anathema.framework.presenter.view.ButtonControlledObjectSelectionView; import net.sf.anathema.framework.presenter.view.IButtonControlledObjectSelectionView; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; public class KeywordView implements IKeywordView { @@ -21,11 +21,11 @@ public class KeywordView implements IKeywordView { private final JPanel entryPanel = new JPanel(new GridDialogLayout(2, false)); @Override - public IButtonControlledObjectSelectionView addObjectSelectionView( + public IButtonControlledObjectSelectionView addObjectSelectionView( ListCellRenderer renderer, String label, Icon icon) { - ButtonControlledObjectSelectionView view = new ButtonControlledObjectSelectionView( + ButtonControlledObjectSelectionView view = new ButtonControlledObjectSelectionView( renderer, icon, label); diff --git a/Charm_Entry/src/net/sf/anathema/charmentry/view/PrerequisiteEntryView.java b/Charm_Entry/src/net/sf/anathema/charmentry/view/PrerequisiteEntryView.java index 96741e522a..5b2f007cbe 100644 --- a/Charm_Entry/src/net/sf/anathema/charmentry/view/PrerequisiteEntryView.java +++ b/Charm_Entry/src/net/sf/anathema/charmentry/view/PrerequisiteEntryView.java @@ -8,7 +8,7 @@ import net.sf.anathema.framework.value.IIntValueView; import net.sf.anathema.framework.value.IntegerViewFactory; import net.sf.anathema.framework.value.NullUpperBounds; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.JComponent; import javax.swing.JLabel; @@ -24,9 +24,9 @@ public PrerequisiteEntryView(IntegerViewFactory factory) { } @Override - public ISelectableIntValueView addSelectablePrerequisiteView(String string, IIdentificate[] traits, int initial, int max) { + public ISelectableIntValueView addSelectablePrerequisiteView(String string, Identified[] traits, int initial, int max) { content.add(new JLabel(string)); - ISelectableIntValueView view = new SelectableIntValueView(factory, initial, max); + ISelectableIntValueView view = new SelectableIntValueView(factory, initial, max); view.setSelectableValues(traits); view.addTo(content); return view; diff --git a/Charm_Tree/src/net/sf/anathema/charmtree/AbstractCascadeSelectionView.java b/Charm_Tree/src/net/sf/anathema/charmtree/AbstractCascadeSelectionView.java index c987b313c2..de4ead58f8 100644 --- a/Charm_Tree/src/net/sf/anathema/charmtree/AbstractCascadeSelectionView.java +++ b/Charm_Tree/src/net/sf/anathema/charmtree/AbstractCascadeSelectionView.java @@ -10,7 +10,7 @@ import net.sf.anathema.lib.gui.action.SmartAction; import net.sf.anathema.lib.gui.widgets.ChangeableJComboBox; import net.sf.anathema.lib.gui.widgets.IChangeableJComboBox; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.platform.svgtree.presenter.view.CascadeLoadedListener; import net.sf.anathema.platform.svgtree.presenter.view.ISvgTreeView; import net.sf.anathema.platform.svgtree.presenter.view.ISvgTreeViewProperties; @@ -29,8 +29,8 @@ public abstract class AbstractCascadeSelectionView implements ICascadeSelectionView { private final JPanel selectionPanel = new JPanel(new GridDialogLayout(4, false)); - private IChangeableJComboBox groupComboBox; - private IChangeableJComboBox typeComboBox; + private IChangeableJComboBox groupComboBox; + private IChangeableJComboBox typeComboBox; private final ISvgTreeView charmTreeView; public AbstractCascadeSelectionView(ISvgTreeViewProperties treeProperties) { @@ -38,10 +38,10 @@ public AbstractCascadeSelectionView(ISvgTreeViewProperties treeProperties) { } @Override - public void addCharmTypeSelector(String title, IIdentificate[] types, ListCellRenderer renderer) { + public void addCharmTypeSelector(String title, Identified[] types, ListCellRenderer renderer) { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(new TitledBorder(title)); - typeComboBox = new ChangeableJComboBox(types, false); + typeComboBox = new ChangeableJComboBox(types, false); typeComboBox.setSelectedObject(null); typeComboBox.setRenderer(renderer); panel.add(typeComboBox.getComponent(), BorderLayout.CENTER); @@ -49,17 +49,17 @@ public void addCharmTypeSelector(String title, IIdentificate[] types, ListCellRe } @Override - public void fillCharmGroupBox(IIdentificate[] charmGroups) { + public void fillCharmGroupBox(Identified[] charmGroups) { groupComboBox.setObjects(charmGroups); } @Override - public void fillCharmTypeBox(IIdentificate[] charmGroups) { + public void fillCharmTypeBox(Identified[] charmGroups) { typeComboBox.setObjects(charmGroups); } @Override - public void addCharmTypeSelectionListener(ObjectValueListener selectionListener) { + public void addCharmTypeSelectionListener(ObjectValueListener selectionListener) { typeComboBox.addObjectSelectionChangedListener(selectionListener); } @@ -71,13 +71,13 @@ public void addCharmGroupSelector( Dimension preferredSize) { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(new TitledBorder(title)); - groupComboBox = new ChangeableJComboBox(null, false); + groupComboBox = new ChangeableJComboBox(null, false); groupComboBox.setSelectedObject(null); groupComboBox.setRenderer(renderer); groupComboBox.setPreferredSize(preferredSize); - groupComboBox.addObjectSelectionChangedListener(new ObjectValueListener() { + groupComboBox.addObjectSelectionChangedListener(new ObjectValueListener() { @Override - public void valueChanged(IIdentificate newValue) { + public void valueChanged(Identified newValue) { selectionListener.valueChanged(groupComboBox.getSelectedObject(), typeComboBox.getSelectedObject()); } }); diff --git a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/AbstractCascadePresenter.java b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/AbstractCascadePresenter.java index a97ce03340..e33c28bef0 100644 --- a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/AbstractCascadePresenter.java +++ b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/AbstractCascadePresenter.java @@ -1,232 +1,232 @@ -package net.sf.anathema.charmtree.presenter; - -import net.sf.anathema.character.generic.magic.ICharm; -import net.sf.anathema.character.generic.magic.charms.GroupCharmTree; -import net.sf.anathema.character.generic.magic.charms.ICharmGroup; -import net.sf.anathema.charmtree.filters.CharmFilterSettingsPage; -import net.sf.anathema.charmtree.filters.ICharmFilter; -import net.sf.anathema.charmtree.presenter.view.ICascadeSelectionView; -import net.sf.anathema.charmtree.presenter.view.ICharmGroupChangeListener; -import net.sf.anathema.framework.view.IdentificateSelectCellRenderer; -import net.sf.anathema.lib.compare.I18nedIdentificateSorter; -import net.sf.anathema.lib.control.ObjectValueListener; -import net.sf.anathema.lib.gui.action.SmartAction; -import net.sf.anathema.lib.gui.dialog.core.IDialogResult; -import net.sf.anathema.lib.gui.dialog.userdialog.UserDialog; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; -import net.sf.anathema.platform.svgtree.presenter.view.CascadeLoadedListener; - -import javax.swing.JComponent; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractCascadePresenter implements ICascadeSelectionPresenter { - - private final IResources resources; - protected CharmFilterSet filterSet = new CharmFilterSet(); - private ICharmGroupChangeListener changeListener; - private IIdentificate currentType; - private ICascadeSelectionView view; - private CharmDye dye; - private CharmTypes charmTypes; - protected CharmGroupCollection charmGroups; - private SpecialCharmViewPresenter specialCharmPresenter = new NullSpecialCharmPresenter(); - private AlienCharmPresenter alienPresenter = new NullAlienCharmPresenter(); - private CharmInteractionPresenter interactionPresenter = new NullInteractionPresenter(); - - public AbstractCascadePresenter(IResources resources) { - this.resources = resources; - } - - public void initPresentation() { - createCharmTypeSelector(); - listenForCascadeLoading(); - initCharmTypeSelectionListening(); - specialCharmPresenter.initPresentation(); - resetSpecialViewsAndTooltipsWhenCursorLeavesCharmArea(); - createCharmGroupSelector(); - initFilters(); - createHelpText(); - alienPresenter.initPresentation(); - interactionPresenter.initPresentation(); - view.initGui(); - } - - private void initCharmTypeSelectionListening() { - view.addCharmTypeSelectionListener(new ObjectValueListener() { - @Override - public void valueChanged(IIdentificate cascadeType) { - currentType = cascadeType; - handleTypeSelectionChange(cascadeType); - } - }); - } - - private void listenForCascadeLoading() { - view.addCascadeLoadedListener(new CascadeLoadedListener() { - @Override - public void cascadeLoaded() { - dye.setCharmVisuals(); - } - }); - view.addCascadeLoadedListener(new CascadeLoadedListener() { - @Override - public void cascadeLoaded() { - specialCharmPresenter.showSpecialViews(); - } - }); - } - - private void resetSpecialViewsAndTooltipsWhenCursorLeavesCharmArea() { - getCharmComponent().addMouseListener(new MouseAdapter() { - @Override - public void mouseExited(MouseEvent e) { - specialCharmPresenter.resetSpecialViewsAndTooltipsWhenCursorLeavesCharmArea(); - } - }); - } - - private JComponent getCharmComponent() { - return view.getCharmComponent(); - } - - protected IResources getResources() { - return resources; - } - - protected void createCharmGroupSelector() { - ICharmGroup[] allGroups = charmGroups.getCharmGroups(); - IdentificateSelectCellRenderer renderer = new IdentificateSelectCellRenderer("", getResources()); //$NON-NLS-1$ - Dimension preferredSize = net.sf.anathema.lib.gui.swing.GuiUtilities.calculateComboBoxSize(allGroups, renderer); - view.addCharmGroupSelector(getResources().getString("CardView.CharmConfiguration.AlienCharms.CharmGroup"), renderer, changeListener, preferredSize); - } - - protected void createCharmTypeSelector() { - IIdentificate[] types = charmTypes.getCurrentCharmTypes(); - view.addCharmTypeSelector(getResources().getString("CharmTreeView.GUI.CharmType"), types, - new IdentificateSelectCellRenderer("", getResources())); //$NON-NLS-1$ - } - - protected void createFilterButton(ICascadeSelectionView selectionView) { - SmartAction buttonAction = new SmartAction() { - private static final long serialVersionUID = 1L; - - @Override - protected void execute(Component parentComponent) { - CharmFilterSettingsPage page = new CharmFilterSettingsPage(getResources(), filterSet); - UserDialog userDialog = new UserDialog(parentComponent, page); - IDialogResult result = userDialog.show(); - resetOrApplyFilters(result); - reselectTypeAndGroup(result); - } - - private void reselectTypeAndGroup(IDialogResult result) { - if (result.isCanceled()) { - return; - } - handleTypeSelectionChange(currentType); - changeListener.reselect(); - } - - private void resetOrApplyFilters(IDialogResult result) { - if (result.isCanceled()) { - filterSet.resetAllFilters(); - } else { - filterSet.applyAllFilters(); - } - } - }; - selectionView.addCharmFilterButton(buttonAction, resources.getString("CharmFilters.Filters"), resources.getString("CharmFilters.Define")); - } - - private void createHelpText() { - view.addCharmCascadeHelp(resources.getString("CharmTreeView.GUI.HelpText")); - } - - private ICharmGroup[] sortCharmGroups(ICharmGroup[] originalGroups) { - ArrayList filteredGroups = new ArrayList(); - for (ICharmGroup group : originalGroups) { - boolean acceptGroup = false; - for (ICharm charm : group.getAllCharms()) { - boolean acceptCharm = filterSet.acceptsCharm(charm); - if (acceptCharm) { - acceptGroup = true; - break; - } - } - if (acceptGroup) { - filteredGroups.add(group); - } - } - ICharmGroup[] filteredGroupArray = filteredGroups.toArray(new ICharmGroup[filteredGroups.size()]); - if (!filteredGroups.isEmpty()) { - I18nedIdentificateSorter sorter = new I18nedIdentificateSorter(); - return sorter.sortAscending(filteredGroupArray, new ICharmGroup[filteredGroups.size()], resources); - } - return filteredGroupArray; - } - - protected void setSpecialPresenter(SpecialCharmViewPresenter presenter) { - this.specialCharmPresenter = presenter; - } - - protected void setView(ICascadeSelectionView view) { - this.view = view; - } - - protected void setChangeListener(ICharmGroupChangeListener charmGroupChangeListener) { - this.changeListener = charmGroupChangeListener; - } - - protected void setCharmDye(CharmDye dye) { - this.dye = dye; - } - - protected void setCharmTypes(CharmTypes types) { - this.charmTypes = types; - } - - private void handleTypeSelectionChange(IIdentificate cascadeType) { - if (cascadeType == null) { - view.fillCharmGroupBox(new IIdentificate[0]); - return; - } - GroupCharmTree charmTree = getCharmTree(cascadeType); - if (charmTree == null) { - view.fillCharmGroupBox(new IIdentificate[0]); - return; - } - ICharmGroup[] allCharmGroups = charmTree.getAllCharmGroups(); - ICharmGroup[] sortedCharmGroups = sortCharmGroups(allCharmGroups); - view.fillCharmGroupBox(sortedCharmGroups); - specialCharmPresenter.showSpecialViews(); - } - - protected abstract GroupCharmTree getCharmTree(IIdentificate type); - - private void initFilters() { - CharmFilterContainer charms = getFilterContainer(); - List charmFilters = charms.getCharmFilters(); - filterSet.init(charmFilters); - createFilterButton(view); - } - - protected abstract CharmFilterContainer getFilterContainer(); - - protected void setAlienCharmPresenter(AlienCharmPresenter presenter) { - this.alienPresenter = presenter; - } - - protected void setInteractionPresenter(CharmInteractionPresenter presenter) { - this.interactionPresenter = presenter; - } - - public void setCharmGroups(CharmGroupCollection charmGroups) { - this.charmGroups = charmGroups; - } +package net.sf.anathema.charmtree.presenter; + +import net.sf.anathema.character.generic.magic.ICharm; +import net.sf.anathema.character.generic.magic.charms.GroupCharmTree; +import net.sf.anathema.character.generic.magic.charms.ICharmGroup; +import net.sf.anathema.charmtree.filters.CharmFilterSettingsPage; +import net.sf.anathema.charmtree.filters.ICharmFilter; +import net.sf.anathema.charmtree.presenter.view.ICascadeSelectionView; +import net.sf.anathema.charmtree.presenter.view.ICharmGroupChangeListener; +import net.sf.anathema.framework.view.IdentificateSelectCellRenderer; +import net.sf.anathema.lib.compare.I18nedIdentificateSorter; +import net.sf.anathema.lib.control.ObjectValueListener; +import net.sf.anathema.lib.gui.action.SmartAction; +import net.sf.anathema.lib.gui.dialog.core.IDialogResult; +import net.sf.anathema.lib.gui.dialog.userdialog.UserDialog; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; +import net.sf.anathema.platform.svgtree.presenter.view.CascadeLoadedListener; + +import javax.swing.JComponent; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractCascadePresenter implements ICascadeSelectionPresenter { + + private final IResources resources; + protected CharmFilterSet filterSet = new CharmFilterSet(); + private ICharmGroupChangeListener changeListener; + private Identified currentType; + private ICascadeSelectionView view; + private CharmDye dye; + private CharmTypes charmTypes; + protected CharmGroupCollection charmGroups; + private SpecialCharmViewPresenter specialCharmPresenter = new NullSpecialCharmPresenter(); + private AlienCharmPresenter alienPresenter = new NullAlienCharmPresenter(); + private CharmInteractionPresenter interactionPresenter = new NullInteractionPresenter(); + + public AbstractCascadePresenter(IResources resources) { + this.resources = resources; + } + + public void initPresentation() { + createCharmTypeSelector(); + listenForCascadeLoading(); + initCharmTypeSelectionListening(); + specialCharmPresenter.initPresentation(); + resetSpecialViewsAndTooltipsWhenCursorLeavesCharmArea(); + createCharmGroupSelector(); + initFilters(); + createHelpText(); + alienPresenter.initPresentation(); + interactionPresenter.initPresentation(); + view.initGui(); + } + + private void initCharmTypeSelectionListening() { + view.addCharmTypeSelectionListener(new ObjectValueListener() { + @Override + public void valueChanged(Identified cascadeType) { + currentType = cascadeType; + handleTypeSelectionChange(cascadeType); + } + }); + } + + private void listenForCascadeLoading() { + view.addCascadeLoadedListener(new CascadeLoadedListener() { + @Override + public void cascadeLoaded() { + dye.setCharmVisuals(); + } + }); + view.addCascadeLoadedListener(new CascadeLoadedListener() { + @Override + public void cascadeLoaded() { + specialCharmPresenter.showSpecialViews(); + } + }); + } + + private void resetSpecialViewsAndTooltipsWhenCursorLeavesCharmArea() { + getCharmComponent().addMouseListener(new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + specialCharmPresenter.resetSpecialViewsAndTooltipsWhenCursorLeavesCharmArea(); + } + }); + } + + private JComponent getCharmComponent() { + return view.getCharmComponent(); + } + + protected IResources getResources() { + return resources; + } + + protected void createCharmGroupSelector() { + ICharmGroup[] allGroups = charmGroups.getCharmGroups(); + IdentificateSelectCellRenderer renderer = new IdentificateSelectCellRenderer("", getResources()); //$NON-NLS-1$ + Dimension preferredSize = net.sf.anathema.lib.gui.swing.GuiUtilities.calculateComboBoxSize(allGroups, renderer); + view.addCharmGroupSelector(getResources().getString("CardView.CharmConfiguration.AlienCharms.CharmGroup"), renderer, changeListener, preferredSize); + } + + protected void createCharmTypeSelector() { + Identified[] types = charmTypes.getCurrentCharmTypes(); + view.addCharmTypeSelector(getResources().getString("CharmTreeView.GUI.CharmType"), types, + new IdentificateSelectCellRenderer("", getResources())); //$NON-NLS-1$ + } + + protected void createFilterButton(ICascadeSelectionView selectionView) { + SmartAction buttonAction = new SmartAction() { + private static final long serialVersionUID = 1L; + + @Override + protected void execute(Component parentComponent) { + CharmFilterSettingsPage page = new CharmFilterSettingsPage(getResources(), filterSet); + UserDialog userDialog = new UserDialog(parentComponent, page); + IDialogResult result = userDialog.show(); + resetOrApplyFilters(result); + reselectTypeAndGroup(result); + } + + private void reselectTypeAndGroup(IDialogResult result) { + if (result.isCanceled()) { + return; + } + handleTypeSelectionChange(currentType); + changeListener.reselect(); + } + + private void resetOrApplyFilters(IDialogResult result) { + if (result.isCanceled()) { + filterSet.resetAllFilters(); + } else { + filterSet.applyAllFilters(); + } + } + }; + selectionView.addCharmFilterButton(buttonAction, resources.getString("CharmFilters.Filters"), resources.getString("CharmFilters.Define")); + } + + private void createHelpText() { + view.addCharmCascadeHelp(resources.getString("CharmTreeView.GUI.HelpText")); + } + + private ICharmGroup[] sortCharmGroups(ICharmGroup[] originalGroups) { + ArrayList filteredGroups = new ArrayList(); + for (ICharmGroup group : originalGroups) { + boolean acceptGroup = false; + for (ICharm charm : group.getAllCharms()) { + boolean acceptCharm = filterSet.acceptsCharm(charm); + if (acceptCharm) { + acceptGroup = true; + break; + } + } + if (acceptGroup) { + filteredGroups.add(group); + } + } + ICharmGroup[] filteredGroupArray = filteredGroups.toArray(new ICharmGroup[filteredGroups.size()]); + if (!filteredGroups.isEmpty()) { + I18nedIdentificateSorter sorter = new I18nedIdentificateSorter(); + return sorter.sortAscending(filteredGroupArray, new ICharmGroup[filteredGroups.size()], resources); + } + return filteredGroupArray; + } + + protected void setSpecialPresenter(SpecialCharmViewPresenter presenter) { + this.specialCharmPresenter = presenter; + } + + protected void setView(ICascadeSelectionView view) { + this.view = view; + } + + protected void setChangeListener(ICharmGroupChangeListener charmGroupChangeListener) { + this.changeListener = charmGroupChangeListener; + } + + protected void setCharmDye(CharmDye dye) { + this.dye = dye; + } + + protected void setCharmTypes(CharmTypes types) { + this.charmTypes = types; + } + + private void handleTypeSelectionChange(Identified cascadeType) { + if (cascadeType == null) { + view.fillCharmGroupBox(new Identified[0]); + return; + } + GroupCharmTree charmTree = getCharmTree(cascadeType); + if (charmTree == null) { + view.fillCharmGroupBox(new Identified[0]); + return; + } + ICharmGroup[] allCharmGroups = charmTree.getAllCharmGroups(); + ICharmGroup[] sortedCharmGroups = sortCharmGroups(allCharmGroups); + view.fillCharmGroupBox(sortedCharmGroups); + specialCharmPresenter.showSpecialViews(); + } + + protected abstract GroupCharmTree getCharmTree(Identified type); + + private void initFilters() { + CharmFilterContainer charms = getFilterContainer(); + List charmFilters = charms.getCharmFilters(); + filterSet.init(charmFilters); + createFilterButton(view); + } + + protected abstract CharmFilterContainer getFilterContainer(); + + protected void setAlienCharmPresenter(AlienCharmPresenter presenter) { + this.alienPresenter = presenter; + } + + protected void setInteractionPresenter(CharmInteractionPresenter presenter) { + this.interactionPresenter = presenter; + } + + public void setCharmGroups(CharmGroupCollection charmGroups) { + this.charmGroups = charmGroups; + } } \ No newline at end of file diff --git a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/CharmTypes.java b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/CharmTypes.java index 9f2b7d551b..350b54a09e 100644 --- a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/CharmTypes.java +++ b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/CharmTypes.java @@ -1,7 +1,7 @@ -package net.sf.anathema.charmtree.presenter; - -import net.sf.anathema.lib.util.IIdentificate; - -public interface CharmTypes { - IIdentificate[] getCurrentCharmTypes(); -} +package net.sf.anathema.charmtree.presenter; + +import net.sf.anathema.lib.util.Identified; + +public interface CharmTypes { + Identified[] getCurrentCharmTypes(); +} diff --git a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/AbstractCharmGroupChangeListener.java b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/AbstractCharmGroupChangeListener.java index e64ebbc6bf..8f34ebec43 100644 --- a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/AbstractCharmGroupChangeListener.java +++ b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/AbstractCharmGroupChangeListener.java @@ -6,7 +6,7 @@ import net.sf.anathema.character.generic.type.ICharacterType; import net.sf.anathema.charmtree.presenter.CharmFilterSet; import net.sf.anathema.graph.nodes.IRegularNode; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.platform.svgtree.document.visualizer.ITreePresentationProperties; import java.util.LinkedHashSet; @@ -18,7 +18,7 @@ public abstract class AbstractCharmGroupChangeListener implements ICharmGroupCha private final CharmTreeRenderer charmTreeRenderer; private final CharmFilterSet charmFilterSet; private ICharmGroup currentGroup; - private IIdentificate currentType; + private Identified currentType; private final CharmDisplayPropertiesMap displayPropertiesMap; public AbstractCharmGroupChangeListener(ICharmGroupArbitrator arbitrator, CharmFilterSet charmFilterSet, @@ -32,7 +32,7 @@ public AbstractCharmGroupChangeListener(ICharmGroupArbitrator arbitrator, CharmF @Override public final void valueChanged(Object cascade, Object type) { - loadCharmTree((ICharmGroup) cascade, (IIdentificate) type); + loadCharmTree((ICharmGroup) cascade, (Identified) type); } private Set getDisplayCharms(ICharmGroup charmGroup) { @@ -59,7 +59,7 @@ protected boolean filterAncestors(ICharm charm) { return true; } - private void loadCharmTree(ICharmGroup charmGroup, IIdentificate type) { + private void loadCharmTree(ICharmGroup charmGroup, Identified type) { boolean resetView = !(currentGroup != null && currentGroup.equals(charmGroup) && currentType != null && currentType.equals(type) ); this.currentGroup = charmGroup; this.currentType = type; @@ -87,7 +87,7 @@ public ICharmGroup getCurrentGroup() { return currentGroup; } - protected abstract void modifyCharmVisuals(IIdentificate type); + protected abstract void modifyCharmVisuals(Identified type); @Override public void reselect() { diff --git a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/ICascadeSelectionView.java b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/ICascadeSelectionView.java index 04890f54aa..8cbe254df5 100644 --- a/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/ICascadeSelectionView.java +++ b/Charm_Tree/src/net/sf/anathema/charmtree/presenter/view/ICascadeSelectionView.java @@ -2,7 +2,7 @@ import net.sf.anathema.lib.control.ObjectValueListener; import net.sf.anathema.lib.gui.action.SmartAction; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.platform.svgtree.presenter.view.CascadeLoadedListener; import javax.swing.JComponent; @@ -15,15 +15,15 @@ public interface ICascadeSelectionView { void addCascadeLoadedListener(CascadeLoadedListener listener); - void addCharmTypeSelector(String title, IIdentificate[] types, ListCellRenderer renderer); + void addCharmTypeSelector(String title, Identified[] types, ListCellRenderer renderer); - void addCharmTypeSelectionListener(ObjectValueListener selectionListener); + void addCharmTypeSelectionListener(ObjectValueListener selectionListener); void addCharmFilterButton(SmartAction action, String titleText, String buttonText); - void fillCharmGroupBox(IIdentificate[] charmGroups); + void fillCharmGroupBox(Identified[] charmGroups); - void fillCharmTypeBox(IIdentificate[] cascadeTypes); + void fillCharmTypeBox(Identified[] cascadeTypes); void addCharmGroupSelector(String title, ListCellRenderer renderer, ICharmGroupChangeListener selectionListener, Dimension preferredSize); diff --git a/GraphLayout/src/net/sf/anathema/graph/nodes/IIdentifiedRegularNode.java b/GraphLayout/src/net/sf/anathema/graph/nodes/IIdentifiedRegularNode.java index 9874514c73..43172acc78 100644 --- a/GraphLayout/src/net/sf/anathema/graph/nodes/IIdentifiedRegularNode.java +++ b/GraphLayout/src/net/sf/anathema/graph/nodes/IIdentifiedRegularNode.java @@ -1,7 +1,7 @@ package net.sf.anathema.graph.nodes; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IIdentifiedRegularNode extends IRegularNode, IIdentificate { +public interface IIdentifiedRegularNode extends IRegularNode, Identified { // Nothing to do } \ No newline at end of file diff --git a/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateComparator.java b/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateComparator.java index 1c063375e0..2cde40344c 100644 --- a/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateComparator.java +++ b/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateComparator.java @@ -1,11 +1,11 @@ package net.sf.anathema.lib.compare; -import java.util.Comparator; - import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import java.util.Comparator; -public class I18nedIdentificateComparator implements Comparator { +public class I18nedIdentificateComparator implements Comparator { private final IResources resources; @@ -14,13 +14,13 @@ public I18nedIdentificateComparator(IResources resources) { } @Override - public int compare(IIdentificate group1, IIdentificate group2) { + public int compare(Identified group1, Identified group2) { String firstGroupName = getString(group1); String secondGroupName = getString(group2); return firstGroupName.compareToIgnoreCase(secondGroupName); } - protected String getString(IIdentificate group1) { + protected String getString(Identified group1) { return resources.getString(group1.getId()); } } \ No newline at end of file diff --git a/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateSorter.java b/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateSorter.java index 6520cb7149..43916d8501 100644 --- a/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateSorter.java +++ b/Lib/src/net/sf/anathema/lib/compare/I18nedIdentificateSorter.java @@ -2,12 +2,12 @@ import com.google.common.base.Preconditions; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import java.util.Arrays; import java.util.Comparator; -public class I18nedIdentificateSorter { +public class I18nedIdentificateSorter { public T[] sortAscending(T[] originalGroup, T[] emptyArray, final IResources resources) { Preconditions.checkState(originalGroup.length == emptyArray.length, "Arrays must be of equal length"); //$NON-NLS-1$ diff --git a/Lib/src/net/sf/anathema/lib/control/legality/ValueLegalityState.java b/Lib/src/net/sf/anathema/lib/control/legality/ValueLegalityState.java index be5f627b0b..4a90bf8880 100644 --- a/Lib/src/net/sf/anathema/lib/control/legality/ValueLegalityState.java +++ b/Lib/src/net/sf/anathema/lib/control/legality/ValueLegalityState.java @@ -1,8 +1,8 @@ package net.sf.anathema.lib.control.legality; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public enum ValueLegalityState implements IIdentificate { +public enum ValueLegalityState implements Identified { Low { @Override diff --git a/Lib/src/net/sf/anathema/lib/registry/IIdentificateRegistry.java b/Lib/src/net/sf/anathema/lib/registry/IIdentificateRegistry.java index a44f24f948..d259ee8799 100644 --- a/Lib/src/net/sf/anathema/lib/registry/IIdentificateRegistry.java +++ b/Lib/src/net/sf/anathema/lib/registry/IIdentificateRegistry.java @@ -1,8 +1,8 @@ package net.sf.anathema.lib.registry; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IIdentificateRegistry extends ICollectionRegistry { +public interface IIdentificateRegistry extends ICollectionRegistry { boolean idRegistered(String id); diff --git a/Lib/src/net/sf/anathema/lib/registry/IdentificateRegistry.java b/Lib/src/net/sf/anathema/lib/registry/IdentificateRegistry.java index dabd918f12..e675975ba3 100644 --- a/Lib/src/net/sf/anathema/lib/registry/IdentificateRegistry.java +++ b/Lib/src/net/sf/anathema/lib/registry/IdentificateRegistry.java @@ -1,8 +1,8 @@ package net.sf.anathema.lib.registry; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public class IdentificateRegistry extends CollectionRegistry implements +public class IdentificateRegistry extends CollectionRegistry implements IIdentificateRegistry { @Override diff --git a/Lib/src/net/sf/anathema/lib/util/Identificate.java b/Lib/src/net/sf/anathema/lib/util/Identificate.java index 4d864815ff..df773d9716 100644 --- a/Lib/src/net/sf/anathema/lib/util/Identificate.java +++ b/Lib/src/net/sf/anathema/lib/util/Identificate.java @@ -1,6 +1,6 @@ package net.sf.anathema.lib.util; -public class Identificate implements IIdentificate { +public class Identificate implements Identified { private final String id; diff --git a/Lib/src/net/sf/anathema/lib/util/IIdentificate.java b/Lib/src/net/sf/anathema/lib/util/Identified.java similarity index 58% rename from Lib/src/net/sf/anathema/lib/util/IIdentificate.java rename to Lib/src/net/sf/anathema/lib/util/Identified.java index 2b619da13f..62b4dd976e 100644 --- a/Lib/src/net/sf/anathema/lib/util/IIdentificate.java +++ b/Lib/src/net/sf/anathema/lib/util/Identified.java @@ -1,6 +1,6 @@ package net.sf.anathema.lib.util; -public interface IIdentificate { +public interface Identified { String getId(); } \ No newline at end of file diff --git a/Lib/test/net/sf/anathema/lib/compare/I18nedIdentificateSorterTest.java b/Lib/test/net/sf/anathema/lib/compare/I18nedIdentificateSorterTest.java index 93f4af95e7..ba0f1795ff 100644 --- a/Lib/test/net/sf/anathema/lib/compare/I18nedIdentificateSorterTest.java +++ b/Lib/test/net/sf/anathema/lib/compare/I18nedIdentificateSorterTest.java @@ -1,17 +1,17 @@ -package net.sf.anathema.lib.compare; - -import net.sf.anathema.lib.util.IIdentificate; -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class I18nedIdentificateSorterTest { - - @Test - public void worksOnEmptyArrays() throws Exception { - I18nedIdentificateSorter sorter = new I18nedIdentificateSorter(); - IIdentificate[] identificates = sorter.sortAscending(new IIdentificate[0], new IIdentificate[0], null); - assertThat(identificates.length, is(0)); - } -} +package net.sf.anathema.lib.compare; + +import net.sf.anathema.lib.util.Identified; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class I18nedIdentificateSorterTest { + + @Test + public void worksOnEmptyArrays() throws Exception { + I18nedIdentificateSorter sorter = new I18nedIdentificateSorter(); + Identified[] identificates = sorter.sortAscending(new Identified[0], new Identified[0], null); + assertThat(identificates.length, is(0)); + } +} diff --git a/Lib_Gui/src/net/sf/anathema/lib/gui/list/LegalityCheckListCellRenderer.java b/Lib_Gui/src/net/sf/anathema/lib/gui/list/LegalityCheckListCellRenderer.java index a50fd336fd..0e5e074435 100644 --- a/Lib_Gui/src/net/sf/anathema/lib/gui/list/LegalityCheckListCellRenderer.java +++ b/Lib_Gui/src/net/sf/anathema/lib/gui/list/LegalityCheckListCellRenderer.java @@ -1,7 +1,7 @@ package net.sf.anathema.lib.gui.list; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; @@ -28,6 +28,6 @@ public Component getListCellRendererComponent(JList list, Object value, int inde protected abstract boolean isLegal(Object object); protected String getPrintName(IResources res, Object value) { - return res.getString(((IIdentificate) value).getId()); + return res.getString(((Identified) value).getId()); } } \ No newline at end of file diff --git a/Namegenerator/src/net/sf/anathema/namegenerator/exalted/ExaltedNameGeneratorModel.java b/Namegenerator/src/net/sf/anathema/namegenerator/exalted/ExaltedNameGeneratorModel.java index 2f75503237..e1b02e1f47 100644 --- a/Namegenerator/src/net/sf/anathema/namegenerator/exalted/ExaltedNameGeneratorModel.java +++ b/Namegenerator/src/net/sf/anathema/namegenerator/exalted/ExaltedNameGeneratorModel.java @@ -1,8 +1,8 @@ package net.sf.anathema.namegenerator.exalted; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.util.ObjectUtilities; import net.sf.anathema.namegenerator.domain.INameGenerator; import net.sf.anathema.namegenerator.domain.realm.RealmNameGenerator; @@ -17,11 +17,11 @@ public class ExaltedNameGeneratorModel implements INameGeneratorModel { public static final Identificate THRESHOLD_ID = new Identificate("Threshold"); //$NON-NLS-1$ - private final IIdentificate[] nameGeneratorTypes = new IIdentificate[] { new Identificate("Realm"), THRESHOLD_ID }; //$NON-NLS-1$ - private final Map typeModelsByType = new HashMap(); - private IIdentificate selectedGeneratorType = nameGeneratorTypes[1]; + private final Identified[] nameGeneratorTypes = new Identified[] { new Identificate("Realm"), THRESHOLD_ID }; //$NON-NLS-1$ + private final Map typeModelsByType = new HashMap(); + private Identified selectedGeneratorType = nameGeneratorTypes[1]; private final Announcer selectedGeneratorTypeListeners = Announcer.to(IChangeListener.class); - private final Map generatorsByIdentificate = new HashMap(); + private final Map generatorsByIdentificate = new HashMap(); public ExaltedNameGeneratorModel() { generatorsByIdentificate.put(nameGeneratorTypes[0], new RealmNameGenerator()); @@ -29,12 +29,12 @@ public ExaltedNameGeneratorModel() { } @Override - public IIdentificate[] getGeneratorTypes() { + public Identified[] getGeneratorTypes() { return nameGeneratorTypes; } @Override - public IGeneratorTypeModel getGeneratorTypeModel(IIdentificate type) { + public IGeneratorTypeModel getGeneratorTypeModel(Identified type) { return typeModelsByType.get(type); } @@ -44,12 +44,12 @@ public void addGeneratorTypeChangeListener(IChangeListener listener) { } @Override - public IIdentificate getSelectedGeneratorType() { + public Identified getSelectedGeneratorType() { return selectedGeneratorType; } @Override - public void setGeneratorType(IIdentificate selectedGeneratorType) { + public void setGeneratorType(Identified selectedGeneratorType) { if (ObjectUtilities.equals(selectedGeneratorType, this.selectedGeneratorType)) { return; } diff --git a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/ExaltedNameGeneratorTypePresentation.java b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/ExaltedNameGeneratorTypePresentation.java index 466663d55e..84eecac3cf 100644 --- a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/ExaltedNameGeneratorTypePresentation.java +++ b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/ExaltedNameGeneratorTypePresentation.java @@ -1,13 +1,13 @@ package net.sf.anathema.namegenerator.presenter; -import javax.swing.JComponent; +import net.sf.anathema.lib.util.Identified; -import net.sf.anathema.lib.util.IIdentificate; +import javax.swing.JComponent; public class ExaltedNameGeneratorTypePresentation implements INameGeneratorTypePresentation { @Override - public JComponent initGeneratorTypePresentation(IIdentificate generatorType) { + public JComponent initGeneratorTypePresentation(Identified generatorType) { return null; } } \ No newline at end of file diff --git a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/INameGeneratorTypePresentation.java b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/INameGeneratorTypePresentation.java index 0b9e197fa0..b9ac16e4ff 100644 --- a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/INameGeneratorTypePresentation.java +++ b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/INameGeneratorTypePresentation.java @@ -1,10 +1,10 @@ package net.sf.anathema.namegenerator.presenter; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.JComponent; public interface INameGeneratorTypePresentation { - JComponent initGeneratorTypePresentation(IIdentificate generatorType); + JComponent initGeneratorTypePresentation(Identified generatorType); } \ No newline at end of file diff --git a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/NameGeneratorPresenter.java b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/NameGeneratorPresenter.java index 825b25147a..bd48902a94 100644 --- a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/NameGeneratorPresenter.java +++ b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/NameGeneratorPresenter.java @@ -5,7 +5,7 @@ import net.sf.anathema.lib.gui.Presenter; import net.sf.anathema.lib.gui.action.SmartAction; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.namegenerator.presenter.model.INameGeneratorModel; import net.sf.anathema.namegenerator.presenter.view.INameGeneratorView; @@ -32,7 +32,7 @@ public NameGeneratorPresenter( @Override public void initPresentation() { - for (IIdentificate generatorType : model.getGeneratorTypes()) { + for (Identified generatorType : model.getGeneratorTypes()) { JComponent modelPresentation = typePresentation.initGeneratorTypePresentation(generatorType); String formattedLabel = resources.getString("NameGeneratorPresenter." + generatorType); //$NON-NLS-1$ view.addNameGeneratorType(formattedLabel, modelPresentation, generatorType); @@ -57,7 +57,7 @@ private void initSelectedGeneratorTypePresentation() { view.addGeneratorTypeChangeListener(new IChangeListener() { @Override public void changeOccurred() { - model.setGeneratorType((IIdentificate) view.getSelectedGeneratorType()); + model.setGeneratorType((Identified) view.getSelectedGeneratorType()); } }); model.addGeneratorTypeChangeListener(new IChangeListener() { diff --git a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/model/INameGeneratorModel.java b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/model/INameGeneratorModel.java index 715629e322..247468deeb 100644 --- a/Namegenerator/src/net/sf/anathema/namegenerator/presenter/model/INameGeneratorModel.java +++ b/Namegenerator/src/net/sf/anathema/namegenerator/presenter/model/INameGeneratorModel.java @@ -1,19 +1,19 @@ package net.sf.anathema.namegenerator.presenter.model; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public interface INameGeneratorModel { void addGeneratorTypeChangeListener(IChangeListener listener); - IGeneratorTypeModel getGeneratorTypeModel(IIdentificate type); + IGeneratorTypeModel getGeneratorTypeModel(Identified type); - IIdentificate[] getGeneratorTypes(); + Identified[] getGeneratorTypes(); - IIdentificate getSelectedGeneratorType(); + Identified getSelectedGeneratorType(); - void setGeneratorType(IIdentificate selectedGeneratorType); + void setGeneratorType(Identified selectedGeneratorType); String[] generateNames(int count); } \ No newline at end of file diff --git a/Platform/src/net/sf/anathema/framework/item/IItemType.java b/Platform/src/net/sf/anathema/framework/item/IItemType.java index a94594e237..705e6fd919 100644 --- a/Platform/src/net/sf/anathema/framework/item/IItemType.java +++ b/Platform/src/net/sf/anathema/framework/item/IItemType.java @@ -1,8 +1,8 @@ package net.sf.anathema.framework.item; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public interface IItemType extends IIdentificate { +public interface IItemType extends Identified { IRepositoryConfiguration getRepositoryConfiguration(); diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/EnableBetaContentPreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/EnableBetaContentPreferencesElement.java index 97cb0085bf..d11242d809 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/EnableBetaContentPreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/EnableBetaContentPreferencesElement.java @@ -1,46 +1,46 @@ -package net.sf.anathema.framework.module.preferences; - -import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.util.IIdentificate; - -import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.ENABLE_BETA_CONTENT; - -@PreferenceElement -public class EnableBetaContentPreferencesElement extends AbstractCheckBoxPreferencesElement { - - private boolean enableBetaContent = SYSTEM_PREFERENCES.getBoolean(ENABLE_BETA_CONTENT, false); - - @Override - protected boolean getBooleanParameter() { - return enableBetaContent; - } - - public static boolean enableBetaContent() { - return SYSTEM_PREFERENCES.getBoolean(ENABLE_BETA_CONTENT, false); - } - - @Override - public void savePreferences() { - SYSTEM_PREFERENCES.putBoolean(ENABLE_BETA_CONTENT, enableBetaContent); - } - - @Override - protected void setValue(boolean value) { - enableBetaContent = value; - } - - @Override - protected String getLabelKey() { - return "AnathemaCore.Tools.Preferences.EnableBetaContent"; //$NON-NLS-1$ - } - - @Override - protected void resetValue() { - enableBetaContent = SYSTEM_PREFERENCES.getBoolean(ENABLE_BETA_CONTENT, false); - } - - @Override - public IIdentificate getCategory() { - return SYSTEM_CATEGORY; - } +package net.sf.anathema.framework.module.preferences; + +import net.sf.anathema.initialization.PreferenceElement; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.ENABLE_BETA_CONTENT; + +@PreferenceElement +public class EnableBetaContentPreferencesElement extends AbstractCheckBoxPreferencesElement { + + private boolean enableBetaContent = SYSTEM_PREFERENCES.getBoolean(ENABLE_BETA_CONTENT, false); + + @Override + protected boolean getBooleanParameter() { + return enableBetaContent; + } + + public static boolean enableBetaContent() { + return SYSTEM_PREFERENCES.getBoolean(ENABLE_BETA_CONTENT, false); + } + + @Override + public void savePreferences() { + SYSTEM_PREFERENCES.putBoolean(ENABLE_BETA_CONTENT, enableBetaContent); + } + + @Override + protected void setValue(boolean value) { + enableBetaContent = value; + } + + @Override + protected String getLabelKey() { + return "AnathemaCore.Tools.Preferences.EnableBetaContent"; //$NON-NLS-1$ + } + + @Override + protected void resetValue() { + enableBetaContent = SYSTEM_PREFERENCES.getBoolean(ENABLE_BETA_CONTENT, false); + } + + @Override + public Identified getCategory() { + return SYSTEM_CATEGORY; + } } \ No newline at end of file diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/LanguagePreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/LanguagePreferencesElement.java index 30dfcea8c9..b4280f6f02 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/LanguagePreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/LanguagePreferencesElement.java @@ -1,25 +1,24 @@ package net.sf.anathema.framework.module.preferences; -import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.DEFAULT_LOCALE; -import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.LOCALE_PREFERENCE; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import net.disy.commons.swing.layout.grid.IDialogComponent; +import net.sf.anathema.framework.presenter.action.SupportedLocale; +import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; +import net.sf.anathema.initialization.PreferenceElement; +import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; import javax.swing.DefaultListCellRenderer; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; -import net.disy.commons.swing.layout.grid.IDialogComponent; -import net.sf.anathema.framework.presenter.action.SupportedLocale; -import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; -import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.DEFAULT_LOCALE; +import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.LOCALE_PREFERENCE; @PreferenceElement public class LanguagePreferencesElement implements IPreferencesElement { @@ -95,7 +94,7 @@ public boolean isDirty() { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return SYSTEM_CATEGORY; } diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/LookAndFeelPreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/LookAndFeelPreferencesElement.java index ebb1db426a..a96f775c2d 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/LookAndFeelPreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/LookAndFeelPreferencesElement.java @@ -8,7 +8,7 @@ import net.sf.anathema.initialization.PreferenceElement; import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; @@ -172,7 +172,7 @@ private static String resolveLookAndFeelClassName(String className) { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return SYSTEM_CATEGORY; } diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/MaximizePreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/MaximizePreferencesElement.java index 9cffca1e0b..4e3dfcc977 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/MaximizePreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/MaximizePreferencesElement.java @@ -1,9 +1,9 @@ package net.sf.anathema.framework.module.preferences; -import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.MAXIMIZE_PREFERENCE; - import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.MAXIMIZE_PREFERENCE; @PreferenceElement public class MaximizePreferencesElement extends AbstractCheckBoxPreferencesElement { @@ -36,7 +36,7 @@ protected void resetValue() { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return SYSTEM_CATEGORY; } } \ No newline at end of file diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/OpenPdfPreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/OpenPdfPreferencesElement.java index e01513a79d..06a016a992 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/OpenPdfPreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/OpenPdfPreferencesElement.java @@ -3,7 +3,7 @@ import net.sf.anathema.initialization.PreferenceElement; import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.OPEN_PDF_PREFERENCE; import static net.sf.anathema.framework.reporting.AbstractPrintAction.isAutoOpenSupported; @@ -50,7 +50,7 @@ protected void resetValue() { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return SYSTEM_CATEGORY; } } \ No newline at end of file diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/PageFormatPreferenceElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/PageFormatPreferenceElement.java index ef9cc13376..cf1b8fee7d 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/PageFormatPreferenceElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/PageFormatPreferenceElement.java @@ -1,79 +1,79 @@ -package net.sf.anathema.framework.module.preferences; - -import net.disy.commons.swing.layout.grid.IDialogComponent; -import net.sf.anathema.framework.reporting.pdf.PageSize; -import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; -import net.sf.anathema.framework.view.EnumSelectCellRenderer; -import net.sf.anathema.initialization.PreferenceElement; -import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import static net.sf.anathema.framework.reporting.pdf.PageSize.Letter; -import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.PAGE_FORMAT_PREFERENCE; - -@PreferenceElement -public class PageFormatPreferenceElement implements IPreferencesElement { - - private PageSize pageFormat = loadPreference(); - - private boolean dirty; - private LabelledPreferenceComboBox box; - - @Override - public void addComponent(IGridDialogPanel panel, IResources resources) { - panel.add(getComponent(resources)); - } - - private IDialogComponent getComponent(IResources resources) { - String labelText = resources.getString("AnathemaReporting.Tools.Preferences.PageFormat") + ":"; //$NON-NLS-1$ //$NON-NLS-2$ - EnumSelectCellRenderer renderer = new EnumSelectCellRenderer("PageSize.", resources); //$NON-NLS-1$ - box = new LabelledPreferenceComboBox(labelText, renderer, PageSize.values()); - box.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - PageSize selectedFormat = box.getSelectedItem(); - if (selectedFormat != pageFormat) { - pageFormat = selectedFormat; - dirty = true; - } - } - }); - box.setSelectedItem(pageFormat); - return box.getDialogComponent(); - } - - @Override - public void savePreferences() { - SYSTEM_PREFERENCES.put(PAGE_FORMAT_PREFERENCE, pageFormat.name()); - } - - public static PageSize loadPreference() { - return PageSize.valueOf(SYSTEM_PREFERENCES.get(PAGE_FORMAT_PREFERENCE, Letter.name())); - } - - @Override - public void reset() { - pageFormat = loadPreference(); - box.setSelectedItem(pageFormat); - dirty = false; - } - - @Override - public boolean isValid() { - return true; - } - - @Override - public boolean isDirty() { - return dirty; - } - - @Override - public IIdentificate getCategory() { - return SYSTEM_CATEGORY; - } -} +package net.sf.anathema.framework.module.preferences; + +import net.disy.commons.swing.layout.grid.IDialogComponent; +import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; +import net.sf.anathema.framework.reporting.pdf.PageSize; +import net.sf.anathema.framework.view.EnumSelectCellRenderer; +import net.sf.anathema.initialization.PreferenceElement; +import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.PAGE_FORMAT_PREFERENCE; +import static net.sf.anathema.framework.reporting.pdf.PageSize.Letter; + +@PreferenceElement +public class PageFormatPreferenceElement implements IPreferencesElement { + + private PageSize pageFormat = loadPreference(); + + private boolean dirty; + private LabelledPreferenceComboBox box; + + @Override + public void addComponent(IGridDialogPanel panel, IResources resources) { + panel.add(getComponent(resources)); + } + + private IDialogComponent getComponent(IResources resources) { + String labelText = resources.getString("AnathemaReporting.Tools.Preferences.PageFormat") + ":"; //$NON-NLS-1$ //$NON-NLS-2$ + EnumSelectCellRenderer renderer = new EnumSelectCellRenderer("PageSize.", resources); //$NON-NLS-1$ + box = new LabelledPreferenceComboBox(labelText, renderer, PageSize.values()); + box.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + PageSize selectedFormat = box.getSelectedItem(); + if (selectedFormat != pageFormat) { + pageFormat = selectedFormat; + dirty = true; + } + } + }); + box.setSelectedItem(pageFormat); + return box.getDialogComponent(); + } + + @Override + public void savePreferences() { + SYSTEM_PREFERENCES.put(PAGE_FORMAT_PREFERENCE, pageFormat.name()); + } + + public static PageSize loadPreference() { + return PageSize.valueOf(SYSTEM_PREFERENCES.get(PAGE_FORMAT_PREFERENCE, Letter.name())); + } + + @Override + public void reset() { + pageFormat = loadPreference(); + box.setSelectedItem(pageFormat); + dirty = false; + } + + @Override + public boolean isValid() { + return true; + } + + @Override + public boolean isDirty() { + return dirty; + } + + @Override + public Identified getCategory() { + return SYSTEM_CATEGORY; + } +} diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/RepositoryPreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/RepositoryPreferencesElement.java index 56958a0ee1..b69c1d5526 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/RepositoryPreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/RepositoryPreferencesElement.java @@ -13,8 +13,8 @@ import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; import net.sf.anathema.lib.message.Message; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import javax.swing.JButton; import javax.swing.JLabel; @@ -221,7 +221,7 @@ public boolean isDirty() { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return new Identificate("Repository"); } diff --git a/Platform/src/net/sf/anathema/framework/module/preferences/ToolTipTimePreferencesElement.java b/Platform/src/net/sf/anathema/framework/module/preferences/ToolTipTimePreferencesElement.java index 86937eb544..d96a7f143a 100644 --- a/Platform/src/net/sf/anathema/framework/module/preferences/ToolTipTimePreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/module/preferences/ToolTipTimePreferencesElement.java @@ -1,10 +1,5 @@ package net.sf.anathema.framework.module.preferences; -import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.TOOL_TIP_TIME_PREFERENCE; - -import javax.swing.JLabel; -import javax.swing.JPanel; - import net.disy.commons.swing.layout.grid.IDialogComponent; import net.sf.anathema.framework.presenter.action.preferences.IPreferencesElement; import net.sf.anathema.initialization.PreferenceElement; @@ -12,7 +7,12 @@ import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; import net.sf.anathema.lib.gui.widgets.IntegerSpinner; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import static net.sf.anathema.framework.presenter.action.preferences.IAnathemaPreferencesConstants.TOOL_TIP_TIME_PREFERENCE; @PreferenceElement public class ToolTipTimePreferencesElement implements IPreferencesElement { @@ -71,7 +71,7 @@ public boolean isDirty() { } @Override - public IIdentificate getCategory() { + public Identified getCategory() { return SYSTEM_CATEGORY; } diff --git a/Platform/src/net/sf/anathema/framework/presenter/action/preferences/IPreferencesElement.java b/Platform/src/net/sf/anathema/framework/presenter/action/preferences/IPreferencesElement.java index 93129ec312..9bfa940f95 100644 --- a/Platform/src/net/sf/anathema/framework/presenter/action/preferences/IPreferencesElement.java +++ b/Platform/src/net/sf/anathema/framework/presenter/action/preferences/IPreferencesElement.java @@ -2,8 +2,8 @@ import net.sf.anathema.lib.gui.gridlayout.IGridDialogPanel; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; import net.sf.anathema.lib.util.Identificate; +import net.sf.anathema.lib.util.Identified; import java.util.prefs.Preferences; @@ -12,7 +12,7 @@ public interface IPreferencesElement { Preferences SYSTEM_PREFERENCES = Preferences.userRoot().node(SYSTEM_PREFERENCES_NODE); - IIdentificate SYSTEM_CATEGORY = new Identificate("System"); //$NON-NLS-1$ + Identified SYSTEM_CATEGORY = new Identificate("System"); //$NON-NLS-1$ void savePreferences(); @@ -20,7 +20,7 @@ public interface IPreferencesElement { boolean isDirty(); - IIdentificate getCategory(); + Identified getCategory(); void reset(); diff --git a/Platform/src/net/sf/anathema/framework/presenter/view/IdentificateListCellRenderer.java b/Platform/src/net/sf/anathema/framework/presenter/view/IdentificateListCellRenderer.java index 3bd4e9a022..435e9b1b27 100644 --- a/Platform/src/net/sf/anathema/framework/presenter/view/IdentificateListCellRenderer.java +++ b/Platform/src/net/sf/anathema/framework/presenter/view/IdentificateListCellRenderer.java @@ -1,12 +1,11 @@ package net.sf.anathema.framework.presenter.view; -import java.awt.Component; +import net.sf.anathema.lib.resources.IResources; +import net.sf.anathema.lib.util.Identified; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; - -import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import java.awt.Component; public class IdentificateListCellRenderer extends DefaultListCellRenderer { @@ -24,8 +23,8 @@ public Component getListCellRendererComponent( int index, boolean isSelected, boolean cellHasFocus) { - if (value instanceof IIdentificate) { - String printName = resources.getString(((IIdentificate) value).getId()); + if (value instanceof Identified) { + String printName = resources.getString(((Identified) value).getId()); return super.getListCellRendererComponent(list, printName, index, isSelected, cellHasFocus); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); diff --git a/Platform/src/net/sf/anathema/framework/repository/AbstractAnathemaItem.java b/Platform/src/net/sf/anathema/framework/repository/AbstractAnathemaItem.java index 04275f2164..fff83f6d17 100644 --- a/Platform/src/net/sf/anathema/framework/repository/AbstractAnathemaItem.java +++ b/Platform/src/net/sf/anathema/framework/repository/AbstractAnathemaItem.java @@ -3,7 +3,7 @@ import com.google.common.base.Preconditions; import net.sf.anathema.framework.item.IItemType; import net.sf.anathema.lib.lang.StringUtilities; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; import net.sf.anathema.lib.util.ObjectUtilities; import org.jmock.example.announcer.Announcer; @@ -12,14 +12,14 @@ public abstract class AbstractAnathemaItem implements IItem { private String printName; private final IItemType itemType; private final RepositoryLocation repositoryLocation; - private final IIdentificate identificate; + private final Identified identificate; private final Announcer repositoryItemListeners = Announcer.to(IItemListener.class); public AbstractAnathemaItem(IItemType type) { Preconditions.checkArgument(type.supportsRepository(), "Use second constructor for non-persisted items."); //$NON-NLS-1$ this.itemType = type; this.repositoryLocation = new RepositoryLocation(this); - this.identificate = new IIdentificate() { + this.identificate = new Identified() { @Override public String getId() { return repositoryLocation.getId(); @@ -27,7 +27,7 @@ public String getId() { }; } - public AbstractAnathemaItem(IItemType type, IIdentificate identificate) { + public AbstractAnathemaItem(IItemType type, Identified identificate) { this.itemType = type; this.repositoryLocation = null; this.identificate = identificate; diff --git a/Platform/src/net/sf/anathema/framework/repository/AnathemaDataItem.java b/Platform/src/net/sf/anathema/framework/repository/AnathemaDataItem.java index e4ef10538c..13b5771ca9 100644 --- a/Platform/src/net/sf/anathema/framework/repository/AnathemaDataItem.java +++ b/Platform/src/net/sf/anathema/framework/repository/AnathemaDataItem.java @@ -5,7 +5,7 @@ import net.sf.anathema.framework.itemdata.model.IItemData; import net.sf.anathema.framework.presenter.itemmanagement.PrintNameAdjuster; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class AnathemaDataItem extends AbstractAnathemaItem { @@ -19,7 +19,7 @@ public AnathemaDataItem(IItemType type, IItemData itemData) { itemData.setPrintNameAdjuster(new PrintNameAdjuster(this)); } - public AnathemaDataItem(IItemType type, IIdentificate identificate, IItemData itemData) { + public AnathemaDataItem(IItemType type, Identified identificate, IItemData itemData) { super(type, identificate); Preconditions.checkNotNull(itemData); this.itemData = itemData; diff --git a/Platform/src/net/sf/anathema/framework/repository/AnathemaNullDataItem.java b/Platform/src/net/sf/anathema/framework/repository/AnathemaNullDataItem.java index f9b31eda44..83f96dd1f2 100644 --- a/Platform/src/net/sf/anathema/framework/repository/AnathemaNullDataItem.java +++ b/Platform/src/net/sf/anathema/framework/repository/AnathemaNullDataItem.java @@ -3,11 +3,11 @@ import net.sf.anathema.framework.item.IItemType; import net.sf.anathema.framework.itemdata.model.IItemData; import net.sf.anathema.lib.control.IChangeListener; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; public class AnathemaNullDataItem extends AbstractAnathemaItem { - public AnathemaNullDataItem(IItemType type, IIdentificate identificate) { + public AnathemaNullDataItem(IItemType type, Identified identificate) { super(type, identificate); } diff --git a/Platform/src/net/sf/anathema/framework/repository/ItemType.java b/Platform/src/net/sf/anathema/framework/repository/ItemType.java index 127f11d4b2..5aa0107794 100644 --- a/Platform/src/net/sf/anathema/framework/repository/ItemType.java +++ b/Platform/src/net/sf/anathema/framework/repository/ItemType.java @@ -2,9 +2,9 @@ import net.sf.anathema.framework.item.IItemType; import net.sf.anathema.framework.item.IRepositoryConfiguration; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public class ItemType implements IItemType, IIdentificate { +public class ItemType implements IItemType, Identified { private final String id; private final IRepositoryConfiguration repositoryConfiguration; diff --git a/Platform/src/net/sf/anathema/framework/view/IdentificateSelectCellRenderer.java b/Platform/src/net/sf/anathema/framework/view/IdentificateSelectCellRenderer.java index 7eacc344e1..03e29820ab 100644 --- a/Platform/src/net/sf/anathema/framework/view/IdentificateSelectCellRenderer.java +++ b/Platform/src/net/sf/anathema/framework/view/IdentificateSelectCellRenderer.java @@ -1,9 +1,9 @@ package net.sf.anathema.framework.view; import net.sf.anathema.lib.resources.IResources; -import net.sf.anathema.lib.util.IIdentificate; +import net.sf.anathema.lib.util.Identified; -public class IdentificateSelectCellRenderer extends AbstractSelectCellRenderer { +public class IdentificateSelectCellRenderer extends AbstractSelectCellRenderer { private static final long serialVersionUID = -108630268359225612L; private final String resourceKeyPrefix; @@ -22,7 +22,7 @@ public IdentificateSelectCellRenderer(String resourceKeyPrefix, String resourceK } @Override - protected String getCustomizedDisplayValue(IIdentificate value) { + protected String getCustomizedDisplayValue(Identified value) { StringBuilder builder = new StringBuilder(); if (resourceKeyPrefix != null) { builder.append(resourceKeyPrefix);