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 Details

    • DEFAULT_RADIUS

      public static final double DEFAULT_RADIUS
      radius 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

      public NodeConnection​(Node inNode, int inVariableIndex, Node outNode, int outVariableIndex)
      Construct this NodeConnection with the given parameters.
      Parameters:
      inNode - the input Node
      inVariableIndex - the NodeVariable index
      outNode - the output Node
      outVariableIndex - the output NodeVariable index
    • NodeConnection

      public NodeConnection​(NodeConnection another)
      Construct this NodeConnection 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

      public Node getInNode()
      Returns:
      the Node connected on the input side. May be null.
    • getOutNode

      public Node 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

      public void setInput​(Node n, int variableIndex)
      Sets the input of this NodeConnection. Does not perform a validity check.
      Parameters:
      n - the connecting Node
      variableIndex - the connecting node index.
    • setOutput

      public void setOutput​(Node n, int variableIndex)
      Sets the output of this NodeConnection. Does not perform a validity check.
      Parameters:
      n - the connecting Node
      variableIndex - the connecting node index.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.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

      public boolean isConnectedTo​(Node node)
      Returns true if this NodeConnection is attached at either end to a given Node.
      Parameters:
      node - the subject being tested.
      Returns:
      true if this NodeConnection is attached at either end to a given Node.
    • disconnectAll

      public void disconnectAll()
      Disconnects from all Nodes.
    • set

      public void set​(NodeConnection connection)
      Sets the contents of this NodeConnection to match that of another.
      Parameters:
      connection - the NodeConnection to match.
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • getInVariableIndex

      public int getInVariableIndex()
      Returns:
      the index of the input Node variable to which this NodeConnection is attached. Assumes there is a valid connection.
    • getOutVariableIndex

      public int getOutVariableIndex()
      Returns:
      the index of the output Node variable to which this NodeConnection is attached. Assumes there is a valid connection.
    • getInVariable

      public NodeVariable<?> getInVariable()
      Returns:
      the NodeVariable at this input, or null.
    • getOutVariable

      public NodeVariable<?> getOutVariable()
      Returns:
      the NodeVariable at this output, or null.