Package com.nomagic.magicdraw.properties
Class NumberProperty
java.lang.Object
com.nomagic.magicdraw.properties.Property
com.nomagic.magicdraw.properties.NumberProperty
- All Implemented Interfaces:
PropertyVisitorAcceptor
,Cloneable
The property for storing and editing some number value in Double, Float or Int formats.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Number type is double.static final int
Number type is float.static final int
Number type is integer.static final int
Number type is long.static final String
Patters which is used to format the number.Fields inherited from class com.nomagic.magicdraw.properties.Property
DEFAULT_PROPERTY_RESOURCE_PROVIDER, EDITABLE, NULL, NULL_ID_PROPERTY_RESOURCE_PROVIDER, TO, UNDEFINED, VALUE, VALUE_ANNOTATIONS
-
Constructor Summary
ConstructorDescriptionDefault constructor for INT property.NumberProperty
(String id, double value, double low, double high) The property constructor.NumberProperty
(String id, float value, double low, double high) The property constructor.NumberProperty
(String id, int value, double low, double high) The property constructor.NumberProperty
(String id, long value, double low, double high) The property constructor.NumberProperty
(String id, Double value, int type, double low, double high) The property constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Accepts the given visitor.clone()
Clones the property.Returns property class type.double
Returns value as double (primitive type).Returns value as Double object.float
getFloat()
Returns value as float (primitive type).double
Returns the highest range of the value.int
Returns value as int (primitive type).long
getLong()
Returns value as long (primitive type).double
Returns the lowest range of the number value.int
Returns type of the number.static String
getPattern
(Property property) static String
getStringRepresentation
(int type, Double value) static String
getStringRepresentation
(int type, Double value, String pattern) getValue()
Returns properties value.Returns value's string representation.static String
hasError
(NumberProperty property, String newNumber) boolean
protected boolean
isValueCompatible
(Object value) void
setHighRange
(double range) Returns the highest range of the value.void
setLowRange
(double range) Returns the lowest range of the value.void
setNumberType
(int type) Sets type of the number.void
setSoftRange
(boolean softRange) void
setValue
(double value) Sets value as primitive double type.void
setValue
(float value) Sets value as primitive float type.void
setValue
(int value) Sets value as primitive integer.void
Sets new property value.static Double
Methods inherited from class com.nomagic.magicdraw.properties.Property
_getValue, _isFrozen, _setFrozen, _setValue, addAnnotation, addPropertyChangeListener, addSource, addSources, areEqualByValue, areValuesEqual, checkFrozen, checkFrozen, createCellEditor, createTableCellRenderer, equals, firePropertyChange, generateDefaultDescriptionID, getAdditionalProperties, getAdditionalProperty, getAnnotation, getAnnotations, getDescription, getDescriptionID, getFirstElementFromSources, getGroup, getID, getIntroductoryVersion, getName, getNonEditableReason, getProjectFromSourcesOrActive, getPureDescription, getResourceProvider, getResourceProviderID, getSortableValueStringRepresentation, getSourceAsElement, getSources, getSourcesAsStream, getUndefinedString, getUndefinedString, hashCode, isEditable, isUndefinedState, removeAnnotation, removePropertyChangeListener, setAdditionalProperties, setAdditionalProperty, setAnnotations, setDescription, setDescriptionID, setEditable, setGroup, setID, setIntroductoryVersion, setNonEditableReason, setResourceProvider, setResourceProviderID, setSources, setUndefinedState, toString
-
Field Details
-
PATTERN
Patters which is used to format the number. This pattern should be set to the additional properties of NumberProperty- See Also:
-
INT
public static final int INTNumber type is integer.- See Also:
-
DOUBLE
public static final int DOUBLENumber type is double.- See Also:
-
FLOAT
public static final int FLOATNumber type is float.- See Also:
-
LONG
public static final int LONGNumber type is long.- See Also:
-
-
Constructor Details
-
NumberProperty
public NumberProperty()Default constructor for INT property. Value of the property will be 0. ID will be empty string. -
NumberProperty
The property constructor.- Parameters:
id
- the ID of property.value
- the number value of the property.type
- the number type (INT, DOUBLE or FLOAT).low
- lowest range of the number.high
- highest range of the number.
-
NumberProperty
The property constructor. Type of number will be INT.- Parameters:
id
- the ID of property.value
- the value of the property.low
- lowest range of the number.high
- highest range of the number.
-
NumberProperty
The property constructor. Type of number will beFLOAT
.- Parameters:
id
- the ID of property.value
- the value of the property.low
- lowest range of the number.high
- highest range of the number.
-
NumberProperty
The property constructor. Type of number will be DOUBLE.- Parameters:
id
- the ID of property.value
- the value of the property.low
- lowest range of the number.high
- highest range of the number.
-
NumberProperty
The property constructor. Type of number will be LONG.- Parameters:
id
- the ID of property.value
- the value of the property.low
- lowest range of the number.high
- highest range of the number.
-
-
Method Details
-
getValueStringRepresentation
Returns value's string representation.- Overrides:
getValueStringRepresentation
in classProperty
- Returns:
- the string representation of the number.
-
getPattern
-
getStringRepresentation
-
getStringRepresentation
-
toDouble
-
accept
Description copied from class:Property
Accepts the given visitor.- Specified by:
accept
in interfacePropertyVisitorAcceptor
- Overrides:
accept
in classProperty
- Parameters:
v
- the PropertyVisitor.- Throws:
Exception
-
getInteger
public int getInteger()Returns value as int (primitive type).- Returns:
- property value as int. 0 if value is null
-
getLong
public long getLong()Returns value as long (primitive type).- Returns:
- property value as long. 0 if value is null
-
getDouble
public double getDouble()Returns value as double (primitive type).- Returns:
- property value as double. 0 if value is null
-
getFloat
public float getFloat()Returns value as float (primitive type).- Returns:
- property value as float. 0 if value is null
-
getDoubleObject
Returns value as Double object.- Returns:
- property value as Double.
-
setValue
public void setValue(int value) Sets value as primitive integer.- Parameters:
value
- a new integer value.
-
setValue
public void setValue(double value) Sets value as primitive double type.- Parameters:
value
- a new double value.
-
setValue
public void setValue(float value) Sets value as primitive float type.- Parameters:
value
- a new float value.
-
setValue
Description copied from class:Property
Sets new property value. Will fire aPropertyChangeEvent
with propertyName - property ID, newValue and oldValue. -
isValueCompatible
- Overrides:
isValueCompatible
in classProperty
- Returns:
- true if given object can be assigned as value to this property
-
getValue
Description copied from class:Property
Returns properties value. -
getClassType
Returns property class type.- Specified by:
getClassType
in interfacePropertyVisitorAcceptor
- Overrides:
getClassType
in classProperty
- Returns:
- PropertyID.NUMBER_PROPERTY
- See Also:
-
getNumberType
public int getNumberType()Returns type of the number.- Returns:
- number type - INT, DOUBLE or FLOAT.
-
setNumberType
public void setNumberType(int type) Sets type of the number.- Parameters:
type
- the number type - INT, DOUBLE or FLOAT.
-
getLowRange
public double getLowRange()Returns the lowest range of the number value.- Returns:
- lowest range.
-
getHighRange
public double getHighRange()Returns the highest range of the value.- Returns:
- highest range.
-
setLowRange
public void setLowRange(double range) Returns the lowest range of the value.- Parameters:
range
- the lowest range.
-
setHighRange
public void setHighRange(double range) Returns the highest range of the value.- Parameters:
range
- the highest range.
-
hasError
@CheckForNull public static String hasError(NumberProperty property, String newNumber) throws NumberFormatException - Throws:
NumberFormatException
-
isSoftRange
public boolean isSoftRange()- Returns:
- Property is not allowed to cross the range boundaries.
-
setSoftRange
public void setSoftRange(boolean softRange) - Parameters:
softRange
- Property is allowed to cross the range boundaries. Default is false.
-
clone
Description copied from class:Property
Clones the property. Clone is not deep, the clone will have the same instance of value. The clone will not have registered PropertyChangeListeners.
-