Class ConnectionValidator

java.lang.Object
com.codename1.graph.ConnectionValidator

public class ConnectionValidator extends Object

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 and differ, or takes a port past its GraphPort.getMaxConnections. Cycles are allowed unless setAllowCycles(false) is called.

  • 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.
    • canConnect

      public boolean canConnect(GraphModel model, GraphNode source, GraphPort sourcePort, GraphNode target, GraphPort targetPort)
      True when the edge may be made.