Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class ConnectionValidator
- Object
- ConnectionValidator
Decides whether an edge may be made. Extend it for rules of your own and
call super.canConnect to keep these.
By default an edge is refused when it connects a node to itself, repeats
an edge that exists, leaves an input port or enters an output port, joins
two ports whose types are both set, differ and were not paired with
allowType, or takes a port past its
GraphPort.getMaxConnections. Cycles are allowed unless
setAllowCycles(false) is called.
Constructors
public ConnectionValidator() |
Methods
public boolean isAllowCycles() | True, the default, when an edge may close a cycle. |
public void setAllowCycles(boolean allowCycles) | Refuses edges that would close a cycle when false. |
public boolean isAllowSelfLoops() | False, the default, when a node may not connect to itself. |
public void setAllowSelfLoops(boolean allowSelfLoops) | Allows a node to connect to itself. |
public void allowType(String outputType, String inputType) | Lets an output of one type feed an input of another, for instance allowType("int", "number"). |
public boolean isTypeAllowed(String outputType, String inputType) | True when an output of the first type may feed an input of the second: either is null, they are equal, or allowType named the pair. |
public boolean canConnect(GraphModel model, GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort) | True when the edge may be made. |
Inherited methods
Constructor details
ConnectionValidator
public ConnectionValidator()Method details
isAllowCycles
public boolean isAllowCycles()True, the default, when an edge may close a cycle.
setAllowCycles
public void setAllowCycles(boolean allowCycles)Refuses edges that would close a cycle when false.
isAllowSelfLoops
public boolean isAllowSelfLoops()False, the default, when a node may not connect to itself.
setAllowSelfLoops
public void setAllowSelfLoops(boolean allowSelfLoops)Allows a node to connect to itself.
allowType
public void allowType(String outputType, String inputType)Lets an output of one type feed an input of another, for instance
allowType("int", "number"). Equal types always connect.isTypeAllowed
public boolean isTypeAllowed(String outputType, String inputType)True when an output of the first type may feed an input of the second:
either is null, they are equal, or
allowType named the pair.canConnect
public boolean canConnect(GraphModel model, GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort)True when the edge may be made.