本文整理汇总了Java中net.sf.freecol.client.gui.panel.Utility类的典型用法代码示例。如果您正苦于以下问题:Java Utility类的具体用法?Java Utility怎么用?Java Utility使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Utility类属于net.sf.freecol.client.gui.panel包,在下文中一共展示了Utility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RangeOptionUI
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* Creates a new {@code RangeOptionUI} for the given
* {@code RangeOption}.
*
* @param option The {@code RangeOption} to make a user interface for
* @param editable boolean whether user can modify the setting
*/
public RangeOptionUI(final RangeOption option, boolean editable) {
super(option, editable);
JSlider slider = getComponent();
slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0,
0, option.getItemValues().size()-1));
Hashtable<Integer, JComponent> labels
= new Hashtable<>();
int index = 0;
for (String string : option.getItemValues().values()) {
if (option.localizeLabels()) {
labels.put(index, Utility.localizedLabel(string));
} else {
labels.put(index, new JLabel(string));
}
index++;
}
slider.setLabelTable(labels);
slider.setValue(option.getValueRank());
slider.setMajorTickSpacing(1);
slider.setSnapToTicks(true);
}
示例2: buildGameMenu
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
private void buildGameMenu() {
// --> Game
JMenu menu = Utility.localizedMenu("menuBar.game");
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_G);
menu.add(getMenuItem(NewAction.id));
menu.add(getMenuItem(NewEmptyMapAction.id));
menu.addSeparator();
menu.add(getMenuItem(OpenAction.id));
menu.add(getMenuItem(SaveAction.id));
menu.add(getMenuItem(StartMapAction.id));
menu.addSeparator();
menu.add(getMenuItem(PreferencesAction.id));
menu.addSeparator();
menu.add(getMenuItem(ShowMainAction.id));
menu.add(getMenuItem(QuitAction.id));
add(menu);
}
示例3: buildViewMenu
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
private void buildViewMenu() {
// --> View
JMenu menu = Utility.localizedMenu("menuBar.view");
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_V);
menu.add(getCheckBoxMenuItem(MapControlsAction.id));
menu.add(getCheckBoxMenuItem(DisplayGridAction.id));
menu.add(getCheckBoxMenuItem(ChangeWindowedModeAction.id));
menu.addSeparator();
ButtonGroup tileTextGroup = new ButtonGroup();
for (DisplayText type : DisplayText.values()) {
menu.add(getRadioButtonMenuItem(DisplayTileTextAction.id + type.getKey(),
tileTextGroup));
}
menu.addSeparator();
menu.add(getMenuItem(ZoomInAction.id));
menu.add(getMenuItem(ZoomOutAction.id));
add(menu);
}
示例4: ReportReligiousPanel
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* The constructor that will add the items to this panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public ReportReligiousPanel(FreeColClient freeColClient) {
super(freeColClient, "reportReligionAction");
final Font font = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
FontLibrary.FontSize.SMALLER, Font.BOLD,
freeColClient.getGUI().getImageLibrary().getScaleFactor());
final Player player = getMyPlayer();
final Specification spec = getSpecification();
reportPanel.setLayout(new MigLayout("wrap 6, fill", "center"));
for (GoodsType gt : spec.getImmigrationGoodsTypeList()) {
JLabel crosses = Utility.localizedLabel(gt);
crosses.setFont(font);
reportPanel.add(crosses, SPAN_SPLIT_2);
FreeColProgressBar progressBar = new FreeColProgressBar(gt, 0,
player.getImmigrationRequired(), player.getImmigration(),
player.getTotalImmigrationProduction());
reportPanel.add(progressBar, "span");
for (Colony colony : freeColClient.getMySortedColonies()) {
WorkLocation wl = first(colony.getWorkLocationsForProducing(gt));
if (wl instanceof Building) {
reportPanel.add(createColonyButton(colony),
"split 2, flowy");
BuildingPanel bp = new BuildingPanel(getFreeColClient(),
(Building)wl);
bp.initialize();
reportPanel.add(bp);
}
}
}
}
示例5: BlinkingLabel
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
BlinkingLabel() {
super(getHumanKeyStrokeText(keyStroke), JLabel.CENTER);
setOpaque(false);
setBorder(Utility.TRIVIAL_LINE_BORDER);
addKeyListener(this);
addMouseListener(this);
}
示例6: SliderOptionUI
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* Creates a new {@code SliderOptionUI} for the given
* {@code IntegerOption}.
*
* @param option The {@code IntegerOption} to make a user
* interface for.
* @param editable boolean whether user can modify the setting
*/
public SliderOptionUI(final T option, boolean editable) {
super(option, editable);
slider.setBorder(Utility.localizedBorder(super.getJLabel().getText(),
Color.BLACK));
slider.setOrientation(JSlider.HORIZONTAL);
slider.setPreferredSize(new Dimension(500, 50));
slider.setPaintLabels(true);
slider.setPaintTicks(true);
slider.setExtent(0);
initialize();
}
示例7: AbstractUnitOptionUI
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* Creates a new {@code AbstractUnitOptionUI} for the given
* {@code AbstractUnitOption}.
*
* @param option The {@code AbstractUnitOption} to make a
* user interface for
* @param editable boolean whether user can modify the setting
*/
public AbstractUnitOptionUI(final AbstractUnitOption option,
final boolean editable) {
super(option, editable);
this.panel = new MigPanel();
this.panel.setLayout(new MigLayout());
IntegerOption numberOption = option.getNumber();
UnitTypeOption typeOption = option.getUnitType();
StringOption roleOption = option.getRole();
boolean numberEditable = editable
&& (numberOption.getMaximumValue() > numberOption.getMinimumValue());
this.numberUI = new IntegerOptionUI(numberOption, numberEditable);
Utility.localizeToolTip(this.numberUI.getComponent(), "number");
this.panel.add(this.numberUI.getComponent(), "width 30%");
boolean typeEditable = editable
&& typeOption.getChoices().size() > 1;
this.typeUI = new UnitTypeOptionUI(typeOption, typeEditable);
Utility.localizeToolTip(this.typeUI.getComponent(), "unitType");
this.typeUI.getComponent().addItemListener(this);
this.panel.add(this.typeUI.getComponent(), "width 35%");
roleEditable = editable
&& roleOption.getChoices().size() > 1;
this.roleUI = new StringOptionUI(roleOption, roleEditable);
Utility.localizeToolTip(this.roleUI.getComponent(), "model.role.name");
this.roleUI.getComponent().setRenderer(new RoleRenderer());
this.panel.add(this.roleUI.getComponent(), "width 35%");
initialize();
}
示例8: installLookAndFeel
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void installLookAndFeel(String fontName) throws FreeColException {
FreeColLookAndFeel fclaf = new FreeColLookAndFeel();
FreeColLookAndFeel.install(fclaf);
Font font = FontLibrary.createMainFont(
fontName, imageLibrary.getScaleFactor());
FreeColLookAndFeel.installFont(font);
Utility.initStyleContext(font);
}
示例9: confirm
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean confirm(Tile tile, StringTemplate template,
String okKey, String cancelKey) {
return canvas.showConfirmDialog(tile,
Utility.localizedTextArea(template), null, okKey, cancelKey);
}
示例10: initialize
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* Initialize this label.
*/
private void initialize() {
final Goods goods = getGoods();
final Location location = goods.getLocation();
final Player player = (location instanceof Ownable)
? ((Ownable) location).getOwner()
: null;
final GoodsType type = goods.getType();
final Specification spec = goods.getGame().getSpecification();
if (getAmount() < GoodsContainer.CARGO_SIZE) setPartialChosen(true);
if (player == null
|| !type.isStorable()
|| player.canTrade(type)
|| (location instanceof Colony
&& spec.getBoolean(GameOptions.CUSTOM_IGNORE_BOYCOTT)
&& ((Colony) location).hasAbility(Ability.EXPORT))) {
Utility.localizeToolTip(this, goods.getLabel(true));
} else {
Utility.localizeToolTip(this, goods.getLabel(false));
setIcon(getDisabledIcon());
}
setForeground(getColor(type, goods.getAmount(), location));
setText(String.valueOf(goods.getAmount()));
}
示例11: addBorder
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* Wrap the label with a border.
*
* @return This {@code MarketLabel}.
*/
public MarketLabel addBorder() {
setBorder(Utility.TOPCELLBORDER);
setVerticalTextPosition(JLabel.BOTTOM);
setHorizontalTextPosition(JLabel.CENTER);
return this;
}
示例12: addIndianSettlement
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
/**
* Adds an indian settlement entry to this popup.
*
* @param is The {@code IndianSettlement} that will be
* represented on the popup.
*/
private void addIndianSettlement(final IndianSettlement is) {
StringTemplate name
= is.getLocationLabelFor(freeColClient.getMyPlayer());
JMenuItem menuItem = Utility.localizedMenuItem(name);
menuItem.setFont(FontLibrary.createFont(FontLibrary.FontType.NORMAL,
FontLibrary.FontSize.TINY, Font.BOLD,
gui.getImageLibrary().getScaleFactor()));
menuItem.addActionListener((ActionEvent ae) -> {
gui.showIndianSettlement(is);
});
add(menuItem);
hasAnItem = true;
}
示例13: buildToolsMenu
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
private void buildToolsMenu() {
// --> Tools
JMenu menu = Utility.localizedMenu("menuBar.tools");
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_T);
menu.add(getMenuItem(ScaleMapAction.id));
menu.add(getMenuItem(DetermineHighSeasAction.id));
add(menu);
}
示例14: buildColopediaMenu
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
protected void buildColopediaMenu() {
// --> Colopedia
JMenu menu = Utility.localizedMenu("menuBar.colopedia");
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_C);
for (PanelType type : PanelType.values()) {
menu.add(getMenuItem(ColopediaAction.id + type.getKey()));
}
menu.addSeparator();
menu.add(getMenuItem(AboutAction.id));
add(menu);
}
示例15: buildGameMenu
import net.sf.freecol.client.gui.panel.Utility; //导入依赖的package包/类
private void buildGameMenu() {
// --> Game
JMenu menu = Utility.localizedMenu("menuBar.game");
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_G);
menu.add(getMenuItem(NewAction.id));
menu.add(getMenuItem(OpenAction.id));
menu.add(getMenuItem(SaveAction.id));
menu.addSeparator();
menu.add(getMenuItem(PreferencesAction.id));
menu.add(getMenuItem(ReconnectAction.id));
menu.addSeparator();
menu.add(getMenuItem(ChatAction.id));
menu.add(getMenuItem(DeclareIndependenceAction.id));
menu.add(getMenuItem(EndTurnAction.id));
menu.addSeparator();
menu.add(getMenuItem(ShowMainAction.id));
menu.add(getMenuItem(ReportHighScoresAction.id));
menu.add(getMenuItem(RetireAction.id));
menu.add(getMenuItem(SaveAndQuitAction.id));
menu.add(getMenuItem(QuitAction.id));
add(menu);
}