Class NodeConnection
java.lang.Object
com.marginallyclever.nodegraphcore.Connection
public class NodeConnection
extends java.lang.Object
Describes the connection between two 
NodeVariables in different Nodes.- Since:
 - 2022-02-01
 
- 
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_RADIUSradius of connection points at either end. - 
Constructor Summary
Constructors Constructor Description NodeConnection()public Constructor for subclasses to call.NodeConnection(NodeConnection another)Construct thisNodeConnectionto match another.NodeConnection(Node inNode, int inVariableIndex, Node outNode, int outVariableIndex)Construct thisNodeConnectionwith the given parameters. - 
Method Summary
Modifier and Type Method Description voidapply()Send the value of upstream variables to downstream variables, dirty or not.voidapplyIfDirty()Send the value of upstream variables to downstream variables if the upstream is dirty.voiddisconnectAll()Disconnects from allNodes.booleanequals(java.lang.Object o)NodegetInNode()java.awt.PointgetInPosition()NodeVariable<?>getInVariable()intgetInVariableIndex()NodegetOutNode()java.awt.PointgetOutPosition()NodeVariable<?>getOutVariable()intgetOutVariableIndex()inthashCode()booleanisConnectedTo(Node node)Returns true if thisNodeConnectionis attached at either end to a givenNode.booleanisInputValid()booleanisOutputValid()booleanisValidDataType()voidset(NodeConnection connection)Sets the contents of thisNodeConnectionto match that of another.voidsetInput(Node n, int variableIndex)Sets the input of thisNodeConnection.voidsetOutput(Node n, int variableIndex)Sets the output of thisNodeConnection.java.lang.StringtoString()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 thisNodeConnectionwith the given parameters.- Parameters:
 inNode- the inputNodeinVariableIndex- theNodeVariableindexoutNode- the outputNodeoutVariableIndex- the outputNodeVariableindex
 - 
NodeConnection
Construct thisNodeConnectionto 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 
Nodeconnected on the input side. May be null. 
 - 
getOutNode
- Returns:
 - the 
Nodeconnected 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 connectingNodevariableIndex- the connecting node index.
 - 
setOutput
Sets the output of thisNodeConnection. Does not perform a validity check.- Parameters:
 n- the connectingNodevariableIndex- the connecting node index.
 - 
toString
public java.lang.String toString()- Overrides:
 toStringin 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 thisNodeConnectionis attached at either end to a givenNode.- Parameters:
 node- the subject being tested.- Returns:
 - true if this 
NodeConnectionis attached at either end to a givenNode. 
 - 
disconnectAll
public void disconnectAll()Disconnects from allNodes. - 
set
Sets the contents of thisNodeConnectionto match that of another.- Parameters:
 connection- theNodeConnectionto match.
 - 
equals
public boolean equals(java.lang.Object o)- Overrides:
 equalsin classjava.lang.Object
 - 
hashCode
public int hashCode()- Overrides:
 hashCodein classjava.lang.Object
 - 
getInVariableIndex
public int getInVariableIndex()- Returns:
 - the index of the input 
Nodevariable to which thisNodeConnectionis attached. Assumes there is a valid connection. 
 - 
getOutVariableIndex
public int getOutVariableIndex()- Returns:
 - the index of the output 
Nodevariable to which thisNodeConnectionis attached. Assumes there is a valid connection. 
 - 
getInVariable
- Returns:
 - the 
NodeVariableat this input, or null. 
 - 
getOutVariable
- Returns:
 - the 
NodeVariableat this output, or null. 
 
 -