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 int
DEFAULT_HEIGHT
Dimensions used for bounds calculations and intersection tests.static int
DEFAULT_WIDTH
Dimensions used for bounds calculations and intersection tests.protected boolean
hasInput
does this variable have an input?protected boolean
hasOutput
does this variable have an output?protected boolean
isDirty
is this variable dirty?protected java.lang.String
name
The name of this variable.protected java.awt.Rectangle
rectangle
bounding rectangle of this variable.protected java.lang.Class<T>
type
The type of the value stored in this variable.protected T
value
The value within this variable -
Method Summary
Modifier and Type Method Description NodeVariable<T>
createInverse()
Creates a copy of thisNodeVariable
, while flipping hasInput and hasOutputboolean
getHasInput()
Returns true if this variable has an inputboolean
getHasOutput()
Returns true if this variable has an outputjava.awt.Point
getInPosition()
Returns the center of the input connection point of this variableboolean
getIsDirty()
Returns the dirty state.java.lang.String
getName()
Returns the namejava.awt.Point
getOutPosition()
Returns the center of the output connection point of this variablejava.awt.Rectangle
getRectangle()
Returns the bounding rectangle.java.lang.Class<T>
getTypeClass()
Returns the class of this value type.java.lang.String
getTypeName()
Returns the simple name of the class of this value type.T
getValue()
Returns the value.boolean
isValidType(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.void
setIsDirty(boolean state)
Sets the dirty state.void
setValue(java.lang.Object arg0)
Sets the value.java.lang.String
toString()
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:
toString
in 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
-