Package mgui.interfaces.variables
Class VectorInt<T extends MguiNumber>
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.variables.VariableInt<T>
mgui.interfaces.variables.VectorInt<T>
- All Implemented Interfaces:
AttributeObject
,InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
,IconObject
public class VectorInt<T extends MguiNumber> extends VariableInt<T>
Represents an array of numeric values.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields inherited from class mgui.interfaces.variables.VariableInt
attributes, batch, listeners, updated
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description java.util.ArrayList<T>
getAsList()
Returns this variable as a single list of values.java.util.ArrayList<java.lang.Integer>
getDimensions()
int
getN()
javax.swing.Icon
getObjectIcon()
Returns theIcon
associated with this object.VectorInt<T>
getPart(int start, int end)
Returns a part of this vector, between and including indicesstart
andend
.VectorInt<T>
getPart(java.lang.String name, int start, int end)
Returns a part of this vector, between and including indicesstart
andend
.VectorInt<T>
getPart(java.lang.String name, java.lang.String part)
Parsespart
to return a part of this variable.int
getSize()
Returns the total size (number of elements) of this variable.T
getValue(int i)
protected T
getValue(java.util.List<java.lang.Integer> indices)
Returns the value at the given indices; throws an exception if they are out of bounds.boolean
setStringValue(java.util.List<java.lang.Integer> indices, java.lang.String value)
Sets the value at the given indices as aString
; throws an exception if they are out of bounds, this variable is not editable, orvalue
is an inappropriate value.boolean
setValue(java.util.List<java.lang.Integer> indices, T value)
Sets the value at the given indices; throws an exception if they are out of bounds, this variable is not editable, orvalue
is an inappropriate value.void
setValues(java.util.List<T> values)
Sets the values for this vector.java.lang.String
toString()
Methods inherited from class mgui.interfaces.variables.VariableInt
addListener, fireListeners, getAttribute, getAttributes, getAttributeValue, getDTD, getLocalName, getName, getPart, getShortXML, getType, getValueAt, getXML, getXML, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, init, isEditable, isNumeric, removeListener, setAttribute, setAttributes, setBatch, setEditable, setName, setTreeNode, writeXML, writeXML, writeXML
Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, getTreeLabel, isDestroyed, issueTreeNode, updateTreeNodes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
elements
-
-
Constructor Details
-
VectorInt
public VectorInt(java.lang.String name, int n) -
VectorInt
-
VectorInt
-
-
Method Details
-
setValues
Sets the values for this vector.- Parameters:
values
-
-
getAsList
Description copied from class:VariableInt
Returns this variable as a single list of values.- Specified by:
getAsList
in classVariableInt<T extends MguiNumber>
- Returns:
-
getSize
public int getSize()Description copied from class:VariableInt
Returns the total size (number of elements) of this variable.- Specified by:
getSize
in classVariableInt<T extends MguiNumber>
- Returns:
-
getPart
Returns a part of this vector, between and including indicesstart
andend
.- Parameters:
name
-start
-end
-- Returns:
-
getPart
Returns a part of this vector, between and including indicesstart
andend
.- Parameters:
name
-start
-end
-- Returns:
-
getPart
Description copied from class:VariableInt
Parsespart
to return a part of this variable. Syntax for n dimensions is: "x_start,y_start,..,n_start:x_start,y_start,..,n_start
". E.g., "1,2:20,2
". Use asterisk, "*" to indicate last element in a dimension. E.g,, "1,2:*,*
".- Specified by:
getPart
in classVariableInt<T extends MguiNumber>
- Returns:
-
setValue
public boolean setValue(java.util.List<java.lang.Integer> indices, T value) throws VariableExceptionDescription copied from class:VariableInt
Sets the value at the given indices; throws an exception if they are out of bounds, this variable is not editable, orvalue
is an inappropriate value.- Specified by:
setValue
in classVariableInt<T extends MguiNumber>
- Returns:
- object at the given indices
- Throws:
VariableException
-
setStringValue
public boolean setStringValue(java.util.List<java.lang.Integer> indices, java.lang.String value) throws VariableExceptionDescription copied from class:VariableInt
Sets the value at the given indices as aString
; throws an exception if they are out of bounds, this variable is not editable, orvalue
is an inappropriate value.- Specified by:
setStringValue
in classVariableInt<T extends MguiNumber>
- Returns:
- object at the given indices
- Throws:
VariableException
-
getDimensions
public java.util.ArrayList<java.lang.Integer> getDimensions()- Specified by:
getDimensions
in classVariableInt<T extends MguiNumber>
-
getValue
Description copied from class:VariableInt
Returns the value at the given indices; throws an exception if they are out of bounds. If the indices are of a lower dimension than the variable dimension, the returned object is handled by the subclass method. As a general policy, this object should represent the remaining dimensions in some way.- Specified by:
getValue
in classVariableInt<T extends MguiNumber>
- Returns:
- object at the given indices
- Throws:
VariableException
-
getObjectIcon
public javax.swing.Icon getObjectIcon()Description copied from interface:IconObject
Returns theIcon
associated with this object.- Specified by:
getObjectIcon
in interfaceIconObject
- Overrides:
getObjectIcon
in classVariableInt<T extends MguiNumber>
- Returns:
-
getValue
- Throws:
VariableException
-
getN
public int getN() -
toString
public java.lang.String toString()- Overrides:
toString
in classVariableInt<T extends MguiNumber>
-