public class MessageTreeNode extends MidicaTreeNode implements IMessageType
This class represents a node for a MidicaTree
containing MIDI message types.
It implements IMessageType
so that it’s content can be displayed in the message detail panel. Therefore it contains methods to store and retrieve message detail information.
Modifier and Type | Field and Description |
---|---|
private java.util.HashMap<java.lang.Integer,java.util.TreeSet<java.lang.Comparable<?>>> |
distinctOptions
stores multiple values of the same ID
|
private java.util.HashMap<java.lang.Integer,java.lang.Comparable<?>> |
maxOptions
stores the maximum custom node options
|
private java.util.HashMap<java.lang.Integer,java.lang.Comparable<?>> |
minOptions
stores the minimum custom node options
|
private java.util.HashMap<java.lang.Integer,java.lang.Object> |
options
can be used to store custom node options
|
private static long |
serialVersionUID |
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
OPT_CHANNEL, OPT_CONTROLLER, OPT_LEAF_NODE, OPT_LENGTH, OPT_MESSAGE, OPT_META_TYPE, OPT_MSG_NUM, OPT_NRPN, OPT_RPN, OPT_STATUS_BYTE, OPT_SUB_ID_1, OPT_SUB_ID_2, OPT_SUMMARY, OPT_SYSEX_CHANNEL, OPT_TEMPO_BPM, OPT_TEMPO_MPQ, OPT_TEXT, OPT_TICK, OPT_TRACK, OPT_VENDOR_ID, OPT_VENDOR_NAME, OPTIONS
Constructor and Description |
---|
MessageTreeNode()
Creates a new node with an empty name.
|
MessageTreeNode(java.lang.String name)
Creates a new node with the given text but without a number.
|
MessageTreeNode(java.lang.String name,
java.lang.String number)
Creates a new node with the given text and number.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDistinctOptions(int id)
Returns all distinct options that have been added with the given ID.
|
java.lang.String |
getDistinctOptions(int id,
java.lang.String separator)
Returns all distinct options that have been added with the given ID.
|
java.lang.Object |
getOption(int id)
Returns the custom node option that has been set with the last call to
setOption(int, Object) with the given ID. |
java.lang.String |
getRange(int id)
Returns the range of values that has been set by calling
setOption(int, Object) with the given ID. |
void |
setDistinctOption(int id,
java.lang.Comparable<?> value)
Sets options to be stored permanently.
|
void |
setOption(int id,
java.lang.Object value)
Sets custom node options.
|
addAndOrIncrement, addChildren, attachToToolTip, getId, getName, getNumber, getToolTip, increment, initChildren, setId, setName, setNumber, toString
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
private static final long serialVersionUID
private java.util.HashMap<java.lang.Integer,java.lang.Object> options
can be used to store custom node options
private java.util.HashMap<java.lang.Integer,java.lang.Comparable<?>> minOptions
stores the minimum custom node options
private java.util.HashMap<java.lang.Integer,java.lang.Comparable<?>> maxOptions
stores the maximum custom node options
private java.util.HashMap<java.lang.Integer,java.util.TreeSet<java.lang.Comparable<?>>> distinctOptions
stores multiple values of the same ID
public MessageTreeNode(java.lang.String name, java.lang.String number)
Creates a new node with the given text and number.
name
- Main text to be displayed.number
- MIDI number representing this node.public MessageTreeNode(java.lang.String name)
Creates a new node with the given text but without a number.
name
- Main text to be displayed.public MessageTreeNode()
Creates a new node with an empty name.
This constructor is used indirectly from the MidicaTreeModel
and from MidicaTreeNode
by calling newInstance() on the class object. So the node name or number must be set later with MidicaTreeNode.setName(String)
or MidicaTreeNode.setNumber(String)
.
public void setOption(int id, java.lang.Object value)
Sets custom node options.
If the option value is comparable, remembers the minimum and maximum of all calls to this method with the same id.
These values can be retrieved later with getOption(int)
.
id
- The option ID.value
- The option value.public java.lang.Object getOption(int id)
Returns the custom node option that has been set with the last call to setOption(int, Object)
with the given ID.
Returns null, if no option of the given ID exists.
getOption
in interface IMessageType
id
- The option ID.public java.lang.String getRange(int id)
Returns the range of values that has been set by calling setOption(int, Object)
with the given ID.
Returns null, if no values have been set or the values are not Comparable
.
Returns only one value, if the minimum and maximum values are identical.
Otherwise: Returns the range in the form min - max.
getRange
in interface IMessageType
id
- The option ID.public void setDistinctOption(int id, java.lang.Comparable<?> value)
Sets options to be stored permanently.
If this method is called several times with the same ID, the according value is only stored if not yet done.
The values can be retrieved later with getDistinctOptions(int)
The following data types are allowed for the value:
String
Byte
Integer
Long
id
- The option ID.value
- The option value (must be a string or a number object).public java.lang.String getDistinctOptions(int id)
Returns all distinct options that have been added with the given ID.
Returns null, if no distinct options with this ID have been added.
Same as getDistinctOptions(int, String)
using "**, **" as the separator.
getDistinctOptions
in interface IMessageType
id
- The option ID.public java.lang.String getDistinctOptions(int id, java.lang.String separator)
Returns all distinct options that have been added with the given ID.
Returns null, if no distinct options with this ID have been added.
getDistinctOptions
in interface IMessageType
id
- The option ID.separator
- The string to be used in order to separate the values.