Package com.thecoderscorner.menu.domain
Class AnalogMenuItem
- java.lang.Object
-
- com.thecoderscorner.menu.domain.MenuItem<java.lang.Integer>
-
- com.thecoderscorner.menu.domain.AnalogMenuItem
-
public class AnalogMenuItem extends MenuItem<java.lang.Integer>
Represents an analog (numeric) menu item, it is always a zero based integer when retrieved from storage, but it can have an offset and divisor, so therefore is able to represent decimal values. The offset can also be negative. Rather than directly constructing an item of this type, you can use the AnalogMenuItemBuilder.
-
-
Field Summary
-
Fields inherited from class com.thecoderscorner.menu.domain.MenuItem
eepromAddress, functionName, id, name, readOnly
-
-
Constructor Summary
Constructors Constructor Description AnalogMenuItem()AnalogMenuItem(java.lang.String name, int id, int eepromAddress, java.lang.String functionName, int maxValue, int offset, int divisor, java.lang.String unitName, boolean readOnly)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(MenuItemVisitor visitor)See the MenuItemVistor for more info.booleanequals(java.lang.Object o)intgetDivisor()The divisor used when displaying the item, for example value 50 with a divisor of 10 is 5.0intgetMaxValue()The maximum value (0 based integer) that this item can representintgetOffset()The offset from 0 that is used when displaying the item, can be negativejava.lang.StringgetUnitName()The unit name to appear directly after the value, for example a temprature item may be "oC" where as a volume control could be "dB"inthashCode()MenuState<java.lang.Integer>newMenuState(java.lang.Integer value, boolean changed, boolean active)returns a new state object that represents the current value for the menu.-
Methods inherited from class com.thecoderscorner.menu.domain.MenuItem
getEepromAddress, getFunctionName, getId, getName, hasChildren, isReadOnly, toString
-
-
-
-
Method Detail
-
getMaxValue
public int getMaxValue()
The maximum value (0 based integer) that this item can represent- Returns:
- max value
-
getOffset
public int getOffset()
The offset from 0 that is used when displaying the item, can be negative- Returns:
- the offset
-
getDivisor
public int getDivisor()
The divisor used when displaying the item, for example value 50 with a divisor of 10 is 5.0- Returns:
- the divisor used
-
getUnitName
public java.lang.String getUnitName()
The unit name to appear directly after the value, for example a temprature item may be "oC" where as a volume control could be "dB"- Returns:
- the name of the unit (if any)
-
newMenuState
public MenuState<java.lang.Integer> newMenuState(java.lang.Integer value, boolean changed, boolean active)
returns a new state object that represents the current value for the menu. Current values are held separately to the items, see MenuTree- Specified by:
newMenuStatein classMenuItem<java.lang.Integer>- Parameters:
value- the new valuechanged- if the value has changedactive- if the menu item is active, can be used for your own purposes.- Returns:
-
accept
public void accept(MenuItemVisitor visitor)
See the MenuItemVistor for more info.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-