Class NodeConnection
java.lang.Object
com.marginallyclever.nodegraphcore.Connection
public class NodeConnection
extends java.lang.Object
Describes the connection between two
NodeVariable
s in different Node
s.- Since:
- 2022-02-01
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_RADIUS
radius of connection points at either end. -
Constructor Summary
Constructors Constructor Description NodeConnection()
public Constructor for subclasses to call.NodeConnection(NodeConnection another)
Construct thisNodeConnection
to match another.NodeConnection(Node inNode, int inVariableIndex, Node outNode, int outVariableIndex)
Construct thisNodeConnection
with the given parameters. -
Method Summary
Modifier and Type Method Description void
apply()
Send the value of upstream variables to downstream variables, dirty or not.void
applyIfDirty()
Send the value of upstream variables to downstream variables if the upstream is dirty.void
disconnectAll()
Disconnects from allNode
s.boolean
equals(java.lang.Object o)
Node
getInNode()
java.awt.Point
getInPosition()
NodeVariable<?>
getInVariable()
int
getInVariableIndex()
Node
getOutNode()
java.awt.Point
getOutPosition()
NodeVariable<?>
getOutVariable()
int
getOutVariableIndex()
int
hashCode()
boolean
isConnectedTo(Node node)
Returns true if thisNodeConnection
is attached at either end to a givenNode
.boolean
isInputValid()
boolean
isOutputValid()
boolean
isValidDataType()
void
set(NodeConnection connection)
Sets the contents of thisNodeConnection
to match that of another.void
setInput(Node n, int variableIndex)
Sets the input of thisNodeConnection
.void
setOutput(Node n, int variableIndex)
Sets the output of thisNodeConnection
.java.lang.String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
DEFAULT_RADIUS
public static final double DEFAULT_RADIUSradius of connection points at either end. Used for generating bounds and testing intersections.- See Also:
- Constant Field Values
-
-
Constructor Details
-
NodeConnection
public NodeConnection()public Constructor for subclasses to call. -
NodeConnection
Construct thisNodeConnection
with the given parameters.- Parameters:
inNode
- the inputNode
inVariableIndex
- theNodeVariable
indexoutNode
- the outputNode
outVariableIndex
- the outputNodeVariable
index
-
NodeConnection
Construct thisNodeConnection
to match another.- Parameters:
another
- the source to match.
-
-
Method Details
-
applyIfDirty
public void applyIfDirty()Send the value of upstream variables to downstream variables if the upstream is dirty. -
apply
public void apply()Send the value of upstream variables to downstream variables, dirty or not. -
isValidDataType
public boolean isValidDataType()- Returns:
- true if the data type at both ends is a valid match.
-
getInNode
- Returns:
- the
Node
connected on the input side. May be null.
-
getOutNode
- Returns:
- the
Node
connected on the output side. May be null.
-
isInputValid
public boolean isInputValid()- Returns:
- true if the input side of this connection is sane.
-
isOutputValid
public boolean isOutputValid()- Returns:
- true if the output side of this connection is sane.
-
setInput
Sets the input of thisNodeConnection
. Does not perform a validity check.- Parameters:
n
- the connectingNode
variableIndex
- the connecting node index.
-
setOutput
Sets the output of thisNodeConnection
. Does not perform a validity check.- Parameters:
n
- the connectingNode
variableIndex
- the connecting node index.
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getInPosition
public java.awt.Point getInPosition()- Returns:
- The position of this
NodeConnection
's input connection point.
-
getOutPosition
public java.awt.Point getOutPosition()- Returns:
- The position of this
NodeConnection
's output connection point.
-
isConnectedTo
Returns true if thisNodeConnection
is attached at either end to a givenNode
.- Parameters:
node
- the subject being tested.- Returns:
- true if this
NodeConnection
is attached at either end to a givenNode
.
-
disconnectAll
public void disconnectAll()Disconnects from allNode
s. -
set
Sets the contents of thisNodeConnection
to match that of another.- Parameters:
connection
- theNodeConnection
to match.
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
getInVariableIndex
public int getInVariableIndex()- Returns:
- the index of the input
Node
variable to which thisNodeConnection
is attached. Assumes there is a valid connection.
-
getOutVariableIndex
public int getOutVariableIndex()- Returns:
- the index of the output
Node
variable to which thisNodeConnection
is attached. Assumes there is a valid connection.
-
getInVariable
- Returns:
- the
NodeVariable
at this input, or null.
-
getOutVariable
- Returns:
- the
NodeVariable
at this output, or null.
-