java.lang.Object
org.autogui.base.mapping.GuiReprValue
org.autogui.base.mapping.GuiReprValueNumberSpinner
- All Implemented Interfaces:
GuiRepresentation
a spinner text-field component for a
Number
or primitive number property
@GuiIncluded public int intProp; @GuiIncluded public byte byteProp; @GuiIncluded public short shortProp; @GuiIncluded public long longProp; @GuiIncluded public float floatProp; @GuiIncluded public double doubleProp; @GuiIncluded public Integer intObjProp; @GuiIncluded public Byte byteObjProp; @GuiIncluded public Short shortObjProp; @GuiIncluded public Long longObjProp; @GuiIncluded public Float floatObjProp; @GuiIncluded public Double doubleObjProp; @GuiIncluded public BigInteger bigIntProp; @GuiIncluded public BigDecimal bigDecimalProp;
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a comparable infinity representation, which is not a Number type, but comparable to any other types.static interface
a type information of number.static class
the number type forBigDecimal
static class
the number type forBigInteger
static class
the number type for bytestatic class
default impl.static class
the number type for doublestatic class
the number type for floatstatic class
the number type for intstatic class
the number type for longstatic class
the number type for shortNested classes/interfaces inherited from class org.autogui.base.mapping.GuiReprValue
GuiReprValue.NamedValue, GuiReprValue.ObjectSpecifier, GuiReprValue.ObjectSpecifierIndex, GuiReprValue.ObjectSpecifierNothing
Nested classes/interfaces inherited from interface org.autogui.base.mapping.GuiRepresentation
GuiRepresentation.GuiReprNone
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NumberFormat
protected GuiReprValueNumberSpinner.NumberType
Fields inherited from class org.autogui.base.mapping.GuiReprValue
NONE, NONE_WITH_CACHE
-
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionstatic int
fromHumanReadableString
(GuiMappingContext context, String str) fromJson
(GuiMappingContext context, Object target, Object json) create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents.obtains a common type for given 2 number types domains and range l,r byte short int long float double bigInteger bigDecimal byte byte short int long float double bigInteger bigDecimal short short short int long float double bigInteger bigDecimal int int int int long float double bigInteger bigDecimal long long long long long double double bigInteger bigDecimal float float float float double float double bigDecimal bigDecimal double double double double double double double bigDecimal bigDecimal bigInteger bigInteger bigInteger bigInteger bigInteger bigDecimal bigDecimal bigInteger bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimalgetType
(GuiMappingContext context) boolean
boolean
isPrimitiveNumberClass
(Class<?> retType) boolean
isRealNumberType
(Class<?> retType) boolean
isRealNumberType
(GuiMappingContext context) boolean
match
(GuiMappingContext context) match the representation with the typeElement of the context, and if succeeded, it sets this representation to the context, and it might create sub-contexts for recursive matches *boolean
matchValueType
(Class<?> cls) void
setFormat
(NumberFormat format) static BigDecimal
static BigInteger
static byte
static double
static float
toHumanReadableString
(GuiMappingContext context, Object source) method for constructing "toString" copy operations: the returned string will be separated by tabs and new-linesstatic int
toJson
(GuiMappingContext context, Object source) convert the source into JSON formatstatic long
static short
toUpdateValue
(GuiMappingContext context, Object value) called from a GUI element in order to update its value.Methods inherited from class org.autogui.base.mapping.GuiReprValue
addHistoryValue, castOrMake, checkAndUpdateSource, convertLog, createNewValue, errorWhileAddHistoryValue, fromSource, fromSourceUpdated, getNoneSupplier, getParentSource, getUpdatedSource, getUpdatedValue, getUpdatedValueWithoutNoUpdate, getValue, getValueCollectionElement, getValueCollectionSize, getValueType, getValueWithoutNoUpdate, isEditable, isFromJsonTakingMapWithContextNameEntry, isHistoryValueStored, isHistoryValueStored, isHistoryValueSupported, isHistoryValueSupported, isUpdateContextSourceByUpdateFromGui, notifyUpdateWithParentSourceNone, setSource, toParentSource, toSource, toString, unwrapNoUpdate, update, updateCollectionElement, updateFromGui, updateWithParentSource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.autogui.base.mapping.GuiRepresentation
continueCheckAndUpdateSourceForChildren, fromJsonWithNamed, isTaskRunnerUsedFor, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toJsonWithNamed, toStringHeader
-
Field Details
-
type
-
format
-
MAXIMUM
-
MINIMUM
-
INT
-
LONG
-
SHORT
-
BYTE
-
FLOAT
-
DOUBLE
-
BIG_INTEGER
-
BIG_DECIMAL
-
-
Constructor Details
-
GuiReprValueNumberSpinner
public GuiReprValueNumberSpinner() -
GuiReprValueNumberSpinner
-
-
Method Details
-
match
Description copied from interface:GuiRepresentation
match the representation with the typeElement of the context, and if succeeded, it sets this representation to the context, and it might create sub-contexts for recursive matches *- Specified by:
match
in interfaceGuiRepresentation
- Overrides:
match
in classGuiReprValue
- Parameters:
context
- the context of the repr.- Returns:
- the matching result
-
createNumberSpinner
-
matchValueType
- Overrides:
matchValueType
in classGuiReprValue
-
isPrimitiveNumberClass
-
isRealNumberType
-
isRealNumberType
-
toUpdateValue
Description copied from class:GuiReprValue
called from a GUI element in order to update its value. subclass can change to returned type and convert the value to the type. a typical use case is just down-casting and converting null to an empty object.- Overrides:
toUpdateValue
in classGuiReprValue
- Parameters:
context
- the context of the repr.value
- the current value- Returns:
- the updated value
-
toJson
Description copied from interface:GuiRepresentation
convert the source into JSON format- Specified by:
toJson
in interfaceGuiRepresentation
- Overrides:
toJson
in classGuiReprValue
- Parameters:
context
- a context holds the representationsource
- the converted object- Returns:
- Number or String (for BigInteger and BigDecimal). For null and primitive, 0. For null and object, null.
-
fromJson
Description copied from interface:GuiRepresentation
create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents. the behavior can be varied by each representation, confirmed byGuiRepresentation.isJsonSetter()
.- Specified by:
fromJson
in interfaceGuiRepresentation
- Overrides:
fromJson
in classGuiReprValue
- Parameters:
context
- a context holds the representationtarget
- the target object or nulljson
- JSON objects representing the targetString
,Number
,Boolean
,List
,Map
or null- Returns:
- created object from the json, target if provided, or null.
-
isJsonSetter
public boolean isJsonSetter()- Returns:
- true means
GuiRepresentation.fromJson(GuiMappingContext, Object, Object)
takes a target object and set json properties to the target. otherwise, the method will return a new value, thus the target can be null
-
fromHumanReadableString
- Parameters:
context
- the context of the repr.str
- a source string- Returns:
- parsed
Number
orComparable
(including "Infinity") by aNumberFormat
returned bygetFormat()
-
toHumanReadableString
Description copied from interface:GuiRepresentation
method for constructing "toString" copy operations: the returned string will be separated by tabs and new-lines- Parameters:
context
- the context of the repr.source
- aComparable
converted to string- Returns:
- formatted string by
NumberFormat
returned bygetFormat()
-
getType
-
getFormat
-
setFormat
-
getType
-
compare
-
getCommonTypeForNumbers
-
getCommonType
public static GuiReprValueNumberSpinner.NumberType getCommonType(GuiReprValueNumberSpinner.NumberType l, GuiReprValueNumberSpinner.NumberType r) obtains a common type for given 2 number typesdomains and range l,r byte short int long float double bigInteger bigDecimal byte byte short int long float double bigInteger bigDecimal short short short int long float double bigInteger bigDecimal int int int int long float double bigInteger bigDecimal long long long long long double double bigInteger bigDecimal float float float float double float double bigDecimal bigDecimal double double double double double double double bigDecimal bigDecimal bigInteger bigInteger bigInteger bigInteger bigInteger bigDecimal bigDecimal bigInteger bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal bigDecimal - Parameters:
l
- a number typer
- a number type- Returns:
- a common number type, whose value can be obtained by
GuiReprValueNumberSpinner.NumberType.convert(Object)
-
toInt
-
toByte
-
toShort
-
toLong
-
toFloat
-
toDouble
-
toBigDecimal
-
toBigInteger
-