Class ConnectionValidator
java.lang.Object
com.codename1.graph.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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLets an output of one type feed an input of another, for instanceallowType("int", "number").booleancanConnect(GraphModel model, GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort) True when the edge may be made.booleanTrue, the default, when an edge may close a cycle.booleanFalse, the default, when a node may not connect to itself.booleanisTypeAllowed(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, orallowTypenamed the pair.voidsetAllowCycles(boolean allowCycles) Refuses edges that would close a cycle when false.voidsetAllowSelfLoops(boolean allowSelfLoops) Allows a node to connect to itself.
-
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
-
isTypeAllowed
-
canConnect
public boolean canConnect(GraphModel model, GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort) True when the edge may be made.
-