• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RangeOption类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中net.sf.freecol.common.option.RangeOption的典型用法代码示例。如果您正苦于以下问题:Java RangeOption类的具体用法?Java RangeOption怎么用?Java RangeOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RangeOption类属于net.sf.freecol.common.option包,在下文中一共展示了RangeOption类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: RangeOptionUI

点赞 3

import net.sf.freecol.common.option.RangeOption; //导入依赖的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);
}
 

开发者ID:FreeCol,
项目名称:freecol,
代码行数:33,
代码来源:RangeOptionUI.java

示例2: RangeOptionUI

点赞 3

import net.sf.freecol.common.option.RangeOption; //导入依赖的package包/类
/**
 * Creates a new <code>RangeOptionUI</code> for the given
 * <code>RangeOption</code>.
 *
 * @param option The <code>RangeOption</code> to make a user interface for
 * @param editable boolean whether user can modify the setting
 */
public RangeOptionUI(GUI gui, final RangeOption option, boolean editable) {
    super(gui, option, editable);

    JSlider slider = getComponent();

    slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0, 0, option.getItemValues().size() - 1));

    Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>();
    int index = 0;
    for (String string : option.getItemValues().values()) {
        if (option.localizeLabels()) {
            labels.put(index, new JLabel(Messages.message(string)));
        } else {
            labels.put(index, new JLabel(string));
        }
        index++;
    }

    slider.setLabelTable(labels);
    slider.setValue(option.getValueRank());
    slider.setMajorTickSpacing(1);
    slider.setSnapToTicks(true);
}
 

开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:31,
代码来源:RangeOptionUI.java

示例3: getOptionUI

点赞 2

import net.sf.freecol.common.option.RangeOption; //导入依赖的package包/类
/**
 * Get an option UI for a given option.
 *
 * @param gui The {@code GUI} to use.
 * @param option The {@code Option} to check.
 * @param editable Should the result be editable.
 * @return A suitable {@code OptionUI}, or null if none found.
 */
public static OptionUI getOptionUI(GUI gui, Option option, boolean editable) {
    if (option instanceof BooleanOption) {
        return new BooleanOptionUI((BooleanOption)option, editable);
    } else if (option instanceof FileOption) {
        return new FileOptionUI(gui, (FileOption)option, editable);
    } else if (option instanceof PercentageOption) {
        return new PercentageOptionUI((PercentageOption)option, editable);
    } else if (option instanceof RangeOption) {
        return new RangeOptionUI((RangeOption)option, editable);
    } else if (option instanceof SelectOption) {
        return new SelectOptionUI((SelectOption)option, editable);
    } else if (option instanceof IntegerOption) {
        return new IntegerOptionUI((IntegerOption)option, editable);
    } else if (option instanceof StringOption) {
        return new StringOptionUI((StringOption)option, editable);
    } else if (option instanceof LanguageOption) {
        return new LanguageOptionUI((LanguageOption)option, editable);
    } else if (option instanceof AudioMixerOption) {
        return new AudioMixerOptionUI(gui, (AudioMixerOption)option, editable);
    } else if (option instanceof FreeColAction) {
        return new FreeColActionUI((FreeColAction)option, editable);
    } else if (option instanceof AbstractUnitOption) {
        return new AbstractUnitOptionUI((AbstractUnitOption)option, editable);
    } else if (option instanceof ModOption) {
        return new ModOptionUI((ModOption)option, editable);
    } else if (option instanceof UnitListOption) {
        return new ListOptionUI<>(gui, (UnitListOption)option, editable);
    } else if (option instanceof ModListOption) {
        return new ListOptionUI<>(gui, (ModListOption)option, editable);
    } else if (option instanceof TextOption) {
        return new TextOptionUI((TextOption)option, editable);
    } else {
        return null;
    }
}
 

开发者ID:FreeCol,
项目名称:freecol,
代码行数:44,
代码来源:OptionUI.java

示例4: getOptionUI

点赞 2

import net.sf.freecol.common.option.RangeOption; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static OptionUI getOptionUI(GUI gui, Option option, boolean editable) {
    if (option instanceof BooleanOption) {
        return new BooleanOptionUI(gui, (BooleanOption) option, editable);
    } else if (option instanceof FileOption) {
        return new FileOptionUI(gui, (FileOption) option, editable);
    } else if (option instanceof PercentageOption) {
        return new PercentageOptionUI(gui, (PercentageOption) option, editable);
    } else if (option instanceof RangeOption) {
        return new RangeOptionUI(gui, (RangeOption) option, editable);
    } else if (option instanceof SelectOption) {
        return new SelectOptionUI(gui, (SelectOption) option, editable);
    } else if (option instanceof IntegerOption) {
        return new IntegerOptionUI(gui, (IntegerOption) option, editable);
    } else if (option instanceof StringOption) {
        return new StringOptionUI(gui, (StringOption) option, editable);
    } else if (option instanceof LanguageOption) {
        return new LanguageOptionUI(gui, (LanguageOption) option, editable);
    } else if (option instanceof AudioMixerOption) {
        return new AudioMixerOptionUI(gui, (AudioMixerOption) option, editable);
    } else if (option instanceof FreeColAction) {
        return new FreeColActionUI(gui, (FreeColAction) option, editable);
    } else if (option instanceof AbstractUnitOption) {
        return new AbstractUnitOptionUI(gui, (AbstractUnitOption) option, editable);
    } else if (option instanceof ModOption) {
        return new ModOptionUI(gui, (ModOption) option, editable);
    } else if (option instanceof UnitListOption) {
        return new ListOptionUI(gui, (UnitListOption) option, editable);
    } else if (option instanceof ModListOption) {
        return new ListOptionUI(gui, (ModListOption) option, editable);
    } else {
        return null;
    }
}
 

开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:35,
代码来源:OptionUI.java

示例5: fixClientOptions

点赞 2

import net.sf.freecol.common.option.RangeOption; //导入依赖的package包/类
/**
 * Perform backward compatibility fixups on new client options as
 * they are introduced.  Annotate with introduction version so we
 * can clean these up as they become standard.
 */
public void fixClientOptions() {
    // @compact 0.11.0
    addBooleanOption(MINIMAP_TOGGLE_BORDERS,
        ClientOptions.GUI, true);
    addBooleanOption(MINIMAP_TOGGLE_FOG_OF_WAR,
        ClientOptions.GUI, true);
    addTextOption(AUTO_SAVE_PREFIX,
        ClientOptions.SAVEGAMES, "Autosave");
    addTextOption(LAST_TURN_NAME,
        ClientOptions.SAVEGAMES, "last-turn");
    addTextOption(BEFORE_LAST_TURN_NAME,
        ClientOptions.SAVEGAMES, "before-last-turn");
    // end @compact 0.11.0

    // @compat 0.11.1
    addBooleanOption(STOCK_ACCOUNTS_FOR_PRODUCTION,
        ClientOptions.WAREHOUSE, false);
    // end @compat 0.11.1

    // @compat 0.11.3
    addBooleanOption(AUTOLOAD_SENTRIES,
        ClientOptions.OTHER, false);
    try { // Zoom range was increased
        RangeOption ro = getOption(DEFAULT_MINIMAP_ZOOM,
                                   RangeOption.class);
        if (ro.getItemValues().size() != 6) {
            Integer value = ro.getValue();
            ro.clearItemValues();
            ro.addItemValue(1, "1");
            ro.addItemValue(2, "2");
            ro.addItemValue(3, "3");
            ro.addItemValue(4, "4");
            ro.addItemValue(5, "5");
            ro.addItemValue(6, "6");
            ro.setValue(value); // Make sure the value is valid
        }
    } catch (Exception e) {
        logger.log(Level.WARNING, "Failed to fix " + DEFAULT_MINIMAP_ZOOM
            + " option", e);
    }
    // end @compat 0.11.3

    // @compat 0.11.6
    addBooleanOption(SHOW_REGION_NAMING, ClientOptions.MESSAGES, true);

    // These have computed keys in ModelMessage.MessageType
    addBooleanOption("model.option.guiShowCombatResult",
                     ClientOptions.MESSAGES, true);
    addBooleanOption("model.option.guiShowUnitRepaired",
                     ClientOptions.MESSAGES, true);
    addBooleanOption("model.option.guiShowArrived",
                     ClientOptions.MESSAGES, true);
    addBooleanOption("model.option.guiShowDisasters",
                     ClientOptions.MESSAGES, true);
    addBooleanOption("model.option.useOpenGL2D",
                     ClientOptions.GUI, true);
    // end @compat 0.11.6
}
 

开发者ID:FreeCol,
项目名称:freecol,
代码行数:64,
代码来源:ClientOptions.java

示例6: getRangeOption

点赞 1

import net.sf.freecol.common.option.RangeOption; //导入依赖的package包/类
/**
 * Returns the <code>RangeOption</code> with the given ID. Throws an
 * IllegalArgumentException if the ID is null, or if no such Type can be
 * retrieved.
 *
 * @param Id a <code>String</code> value
 * @return an <code>RangeOption</code> value
 */
public RangeOption getRangeOption(String Id) {
    return (RangeOption) getOption(Id);
}
 

开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:12,
代码来源:Specification.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)