Package net.sf.freecol.common.option
Class RangeOption
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.FreeColSpecObject
-
- net.sf.freecol.common.option.AbstractOption<java.lang.Integer>
-
- net.sf.freecol.common.option.IntegerOption
-
- net.sf.freecol.common.option.SelectOption
-
- net.sf.freecol.common.option.RangeOption
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<FreeColObject>
,ObjectWithId
,Option<java.lang.Integer>
public class RangeOption extends SelectOption
Represents an option where the valid choice is an integer and the choices are represented by strings. In general, these strings are localized by looking up the key of the choice, which consists of the identifier of the AbstractObject followed by a "." followed by the value of the option string. RangeOption differs from SelectOption, as the value being selected represents a numeric measurement, defined by a bounded range of comparable values. As the graphical component rendering a range option only works with a conventional index, this implies to manage a fixed rank for each possible values.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger
static java.lang.String
TAG
-
Fields inherited from class net.sf.freecol.common.option.SelectOption
localizedLabels
-
Fields inherited from class net.sf.freecol.common.option.AbstractOption
ACTION_TAG, DEFAULT_VALUE_TAG, isDefined
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description RangeOption(java.lang.String id, Specification specification)
Creates a newRangeOption
.RangeOption(Specification specification)
Creates a newRangeOption
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getValueRank()
Gets the rank of the current selected value in the list of values of thisRangeOption
.java.lang.String
getXMLItemElementTagName()
Gets the tag name of the contained object.java.lang.String
getXMLTagName()
Get the serialization tag for this object.void
setValueRank(int rank)
Sets the value through the rank in the list of values of thisRangeOption
.-
Methods inherited from class net.sf.freecol.common.option.SelectOption
addItemValue, clearItemValues, getItemValues, getName, localizeLabels, readAttributes, readChild, readChildren, setValue, toString, writeAttributes, writeChildren
-
Methods inherited from class net.sf.freecol.common.option.IntegerOption
cloneOption, getMaximumValue, getMinimumValue, getStepSize, getValue, limitValue, setMaximumValue, setMinimumValue, setValue
-
Methods inherited from class net.sf.freecol.common.option.AbstractOption
generateChoices, getEnabledBy, getGroup, isNullValueOK, readOption, setGroup, setValues
-
Methods inherited from class net.sf.freecol.common.model.FreeColSpecObject
copyIn, getSpecification, setSpecification
-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hashCode, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, toXML, toXML, toXMLPartial, toXMLPartial
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.freecol.common.ObjectWithId
getId
-
Methods inherited from interface net.sf.freecol.common.option.Option
readFromXML, toXML
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RangeOption
public RangeOption(Specification specification)
Creates a newRangeOption
.- Parameters:
specification
- TheSpecification
to refer to.
-
RangeOption
public RangeOption(java.lang.String id, Specification specification)
Creates a newRangeOption
.- Parameters:
id
- The object identifier.specification
- TheSpecification
to refer to.
-
-
Method Detail
-
getValueRank
public int getValueRank()
Gets the rank of the current selected value in the list of values of thisRangeOption
.- Returns:
- The value.
-
setValueRank
public void setValueRank(int rank)
Sets the value through the rank in the list of values of thisRangeOption
.- Parameters:
rank
- The rank of the value to be set.
-
getXMLItemElementTagName
public java.lang.String getXMLItemElementTagName()
Gets the tag name of the contained object.- Overrides:
getXMLItemElementTagName
in classSelectOption
- Returns:
- "rangeValue".
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Overrides:
getXMLTagName
in classSelectOption
- Returns:
- The tag.
-
-