Class NodeVariable<T>
java.lang.Object
com.marginallyclever.nodegraphcore.NodeVariable<T>
public class NodeVariable<T>
extends java.lang.Object
Describes an input or output connection with for a
Node and stores the value at that connection.- Since:
- 2022-02-01
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_HEIGHTDimensions used for bounds calculations and intersection tests.static intDEFAULT_WIDTHDimensions used for bounds calculations and intersection tests.protected booleanhasInputdoes this variable have an input?protected booleanhasOutputdoes this variable have an output?protected booleanisDirtyis this variable dirty?protected java.lang.StringnameThe name of this variable.protected java.awt.Rectanglerectanglebounding rectangle of this variable.protected java.lang.Class<T>typeThe type of the value stored in this variable.protected TvalueThe value within this variable -
Method Summary
Modifier and Type Method Description NodeVariable<T>createInverse()Creates a copy of thisNodeVariable, while flipping hasInput and hasOutputbooleangetHasInput()Returns true if this variable has an inputbooleangetHasOutput()Returns true if this variable has an outputjava.awt.PointgetInPosition()Returns the center of the input connection point of this variablebooleangetIsDirty()Returns the dirty state.java.lang.StringgetName()Returns the namejava.awt.PointgetOutPosition()Returns the center of the output connection point of this variablejava.awt.RectanglegetRectangle()Returns the bounding rectangle.java.lang.Class<T>getTypeClass()Returns the class of this value type.java.lang.StringgetTypeName()Returns the simple name of the class of this value type.TgetValue()Returns the value.booleanisValidType(java.lang.Object arg0)Returns true if the given item is an instance of this value's type.static <T> NodeVariable<T>newInstance(java.lang.String name, java.lang.Class<T> clazz, T startingValue, boolean hasInput, boolean hasOutput)Called to create a new instance of a NodeVariable.voidsetIsDirty(boolean state)Sets the dirty state.voidsetValue(java.lang.Object arg0)Sets the value.java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTHDimensions used for bounds calculations and intersection tests.- See Also:
- Constant Field Values
-
DEFAULT_HEIGHT
public static final int DEFAULT_HEIGHTDimensions used for bounds calculations and intersection tests.- See Also:
- Constant Field Values
-
value
The value within this variable -
type
The type of the value stored in this variable. -
name
protected java.lang.String nameThe name of this variable. Change this value in production and serialization will break! -
hasInput
protected boolean hasInputdoes this variable have an input? -
hasOutput
protected boolean hasOutputdoes this variable have an output? -
isDirty
protected boolean isDirtyis this variable dirty? -
rectangle
protected final java.awt.Rectangle rectanglebounding rectangle of this variable.
-
-
Method Details
-
newInstance
public static <T> NodeVariable<T> newInstance(java.lang.String name, java.lang.Class<T> clazz, T startingValue, boolean hasInput, boolean hasOutput)Called to create a new instance of a NodeVariable.- Type Parameters:
T- the class type.- Parameters:
name- the variable nameclazz- the variable typestartingValue- the starting valuehasInput- does this variable have an input?hasOutput- does this variable have an input?- Returns:
- the new instance.
-
createInverse
Creates a copy of thisNodeVariable, while flipping hasInput and hasOutput- Returns:
- an inverted copy of this
NodeVariable.
-
getRectangle
public java.awt.Rectangle getRectangle()Returns the bounding rectangle.- Returns:
- the bounding rectangle.
-
getName
public java.lang.String getName()Returns the name- Returns:
- the name
-
setValue
public void setValue(java.lang.Object arg0)Sets the value. Casts to this variable's type.- Parameters:
arg0- the new value to set.
-
getTypeClass
Returns the class of this value type.- Returns:
- the class of this value type.
-
getTypeName
public java.lang.String getTypeName()Returns the simple name of the class of this value type.- Returns:
- the simple name of the class of this value type.
-
isValidType
public boolean isValidType(java.lang.Object arg0)Returns true if the given item is an instance of this value's type.- Parameters:
arg0- the given item- Returns:
- true if the given item is an instance of this value's type.
-
getValue
Returns the value.- Returns:
- the value.
-
setIsDirty
public void setIsDirty(boolean state)Sets the dirty state.- Parameters:
state- the new dirty state.
-
getIsDirty
public boolean getIsDirty()Returns the dirty state.- Returns:
- the dirty state.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getHasOutput
public boolean getHasOutput()Returns true if this variable has an output- Returns:
- true if this variable has an output
-
getHasInput
public boolean getHasInput()Returns true if this variable has an input- Returns:
- true if this variable has an input
-
getInPosition
public java.awt.Point getInPosition()Returns the center of the input connection point of this variable- Returns:
- the center of the input connection point of this variable
-
getOutPosition
public java.awt.Point getOutPosition()Returns the center of the output connection point of this variable- Returns:
- the center of the output connection point of this variable
-