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 classa comparable infinity representation, which is not a Number type, but comparable to any other types.static interfacea type information of number.static classthe number type forBigDecimalstatic classthe number type forBigIntegerstatic classthe number type for bytestatic classdefault impl.static classthe number type for doublestatic classthe number type for floatstatic classthe number type for intstatic classthe number type for longstatic classthe number type for shortNested classes/interfaces inherited from class org.autogui.base.mapping.GuiReprValue
GuiReprValue.NamedValue, GuiReprValue.ObjectSpecifier, GuiReprValue.ObjectSpecifierIndex, GuiReprValue.ObjectSpecifierNothingNested classes/interfaces inherited from interface org.autogui.base.mapping.GuiRepresentation
GuiRepresentation.GuiReprNone, GuiRepresentation.TreeString, GuiRepresentation.TreeStringComposite, GuiRepresentation.TreeStringValue -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NumberFormatprotected GuiReprValueNumberSpinner.NumberTypeFields inherited from class org.autogui.base.mapping.GuiReprValue
NONE, NONE_WITH_CACHE -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionstatic intfromHumanReadableString(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) booleanbooleanisPrimitiveNumberClass(Class<?> retType) booleanisRealNumberType(Class<?> retType) booleanisRealNumberType(GuiMappingContext context) booleanmatch(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 *booleanmatchValueType(Class<?> cls) voidsetFormat(NumberFormat format) static BigDecimalstatic BigIntegerstatic bytestatic doublestatic floattoHumanReadableStringTree(GuiMappingContext context, Object source) static inttoJson(GuiMappingContext context, Object source) convert the source into JSON formatstatic longstatic shorttoUpdateValue(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, updateWithParentSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.autogui.base.mapping.GuiRepresentation
continueCheckAndUpdateSourceForChildren, fromJsonWithNamed, isTaskRunnerUsedFor, matchAndSetNotifiersAsInit, setNotifiersTree, shutdown, toHumanReadableString, 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:GuiRepresentationmatch 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:
matchin interfaceGuiRepresentation- Overrides:
matchin classGuiReprValue- Parameters:
context- the context of the repr.- Returns:
- the matching result
-
createNumberSpinner
-
matchValueType
- Overrides:
matchValueTypein classGuiReprValue
-
isPrimitiveNumberClass
-
isRealNumberType
-
isRealNumberType
-
toUpdateValue
Description copied from class:GuiReprValuecalled 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:
toUpdateValuein classGuiReprValue- Parameters:
context- the context of the repr.value- the current value- Returns:
- the updated value
-
toJson
Description copied from interface:GuiRepresentationconvert the source into JSON format- Specified by:
toJsonin interfaceGuiRepresentation- Overrides:
toJsonin 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:GuiRepresentationcreate 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:
fromJsonin interfaceGuiRepresentation- Overrides:
fromJsonin classGuiReprValue- Parameters:
context- a context holds the representationtarget- the target object or nulljson- JSON objects representing the targetString,Number,Boolean,List,Mapor 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
NumberorComparable(including "Infinity") by aNumberFormatreturned bygetFormat()
-
toHumanReadableStringTree
public GuiRepresentation.TreeString toHumanReadableStringTree(GuiMappingContext context, Object source) - Parameters:
context- the context of the repr.source- aComparableconverted to string- Returns:
- formatted string by
NumberFormatreturned 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
-