本文整理汇总了Java中net.sf.freecol.common.model.WorkLocation.Suggestion类的典型用法代码示例。如果您正苦于以下问题:Java Suggestion类的具体用法?Java Suggestion怎么用?Java Suggestion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Suggestion类属于net.sf.freecol.common.model.WorkLocation包,在下文中一共展示了Suggestion类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSuggestion
import net.sf.freecol.common.model.WorkLocation.Suggestion; //导入依赖的package包/类
private void addSuggestion(Map<UnitType, Suggestion> suggestions,
UnitType expert, Suggestion suggestion) {
if (suggestion == null || expert == null) return;
Suggestion now = suggestions.get(expert);
if (now == null || now.amount < suggestion.amount) {
suggestions.put(expert, suggestion);
}
}
示例2: unitButtons
import net.sf.freecol.common.model.WorkLocation.Suggestion; //导入依赖的package包/类
private List<JButton> unitButtons(final Map<UnitType, Suggestion> suggestions,
List<UnitType> have, Colony colony) {
final String cac = colony.getId();
List<JButton> result = new ArrayList<>();
final Comparator<UnitType> buttonComparator
= Comparator.comparing(ut -> suggestions.get(ut),
Suggestion.descendingAmountComparator);
for (UnitType type : sort(suggestions.keySet(), buttonComparator)) {
boolean present = have.contains(type);
Suggestion suggestion = suggestions.get(type);
String label = Integer.toString(suggestion.amount);
ImageIcon icon
= new ImageIcon(this.lib.getTinyUnitImage(type, false));
StringTemplate tip = (suggestion.oldType == null)
? stpld("report.colony.wanting")
.addName("%colony%", colony.getName())
.addNamed("%unit%", type)
.addStringTemplate("%location%",
suggestion.workLocation.getLabel())
.addNamed("%goods%", suggestion.goodsType)
.addAmount("%amount%", suggestion.amount)
: stpld("report.colony.improving")
.addName("%colony%", colony.getName())
.addNamed("%oldUnit%", suggestion.oldType)
.addNamed("%unit%", type)
.addStringTemplate("%location%",
suggestion.workLocation.getLabel())
.addNamed("%goods%", suggestion.goodsType)
.addAmount("%amount%", suggestion.amount);
JButton b = newButton(cac, label, icon,
(present) ? cGood : cPlain, tip);
if (present) b.setFont(b.getFont().deriveFont(Font.BOLD));
result.add(b);
}
return result;
}