當前位置: 首頁>>代碼示例>>Java>>正文


Java Suggestion類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:9,代碼來源:ReportCompactColonyPanel.java

示例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;
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:37,代碼來源:ReportCompactColonyPanel.java


注:本文中的net.sf.freecol.common.model.WorkLocation.Suggestion類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。