The Class Gui2InfoFactory provides character related information on various facade objects. The information is displayed to the user via the new user interface.
| 129 | * |
| 130 | */ |
| 131 | public class Gui2InfoFactory implements InfoFactory |
| 132 | { |
| 133 | /** A default return value for an invalid request. */ |
| 134 | private static final String EMPTY_STRING = ""; //$NON-NLS-1$ |
| 135 | private static final NumberFormat ADJ_FMT = new DecimalFormat("+0;-0"); //$NON-NLS-1$ |
| 136 | private static final NumberFormat COST_FMT = new DecimalFormat("#,##0.##"); //$NON-NLS-1$ |
| 137 | |
| 138 | /** Constant for 2 spaces in HTML */ |
| 139 | private static final String TWO_SPACES = " "; //$NON-NLS-1$ |
| 140 | /** Constant for HTML bold start tag */ |
| 141 | private static final String BOLD = "<b>"; //$NON-NLS-1$ |
| 142 | /** Constant for HTML bold end tag */ |
| 143 | private static final String END_BOLD = "</b>"; //$NON-NLS-1$ |
| 144 | |
| 145 | private final PlayerCharacter pc; |
| 146 | private final CharacterDisplay charDisplay; |
| 147 | |
| 148 | /** |
| 149 | * Create a new Gui2InfoFactory instance for the character. |
| 150 | * @param pc The character |
| 151 | */ |
| 152 | public Gui2InfoFactory(PlayerCharacter pc) |
| 153 | { |
| 154 | this.pc = pc; |
| 155 | this.charDisplay = pc == null ? null : pc.getDisplay(); |
| 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public String getFavoredClass(Race race) |
| 160 | { |
| 161 | String[] favClass = Globals.getContext().unparseSubtoken(race, "FAVCLASS"); |
| 162 | return StringUtil.join(favClass, ", "); |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public String getHTMLInfo(Race race) |
| 167 | { |
| 168 | final HtmlInfoBuilder infoText = new HtmlInfoBuilder(); |
| 169 | |
| 170 | if (!race.isUnselected()) |
| 171 | { |
| 172 | infoText.appendTitleElement(OutputNameFormatting.piString(race)); |
| 173 | |
| 174 | infoText.appendLineBreak(); |
| 175 | RaceType rt = race.get(ObjectKey.RACETYPE); |
| 176 | if (rt != null) |
| 177 | { |
| 178 | infoText.appendI18nElement("in_irInfoRaceType", rt.toString()); //$NON-NLS-1$ |
| 179 | } |
| 180 | |
| 181 | List<RaceSubType> rst = race.getListFor(ListKey.RACESUBTYPE); |
| 182 | if (rst != null) |
| 183 | { |
| 184 | infoText.appendSpacer(); |
| 185 | infoText.appendI18nElement("in_irInfoSubType", StringUtil.join(rst, ", ")); //$NON-NLS-1$ |
| 186 | } |
| 187 | if (!race.getType().isEmpty()) |
| 188 | { |
nothing calls this directly
no outgoing calls
no test coverage detected