JBotSim icon indicating copy to clipboard operation
JBotSim copied to clipboard

Add a link painter that takes logical orientation into account

Open acasteigts opened this issue 4 years ago • 2 comments

JBotSim already has a JDirectedLinkPainter for drawing directed links. However, in many cases, one has to visualize another kind of orientation that stems from the content of the node's variables. The typical example is a parent/child relation in a tree, where the links are undirected. It would be good to have such a painter, for instance based on the value a parent field in the nodes.

acasteigts avatar Oct 16 '21 08:10 acasteigts

What was done:

  • A JParentLinkPainter was added that uses reflection to inspect a parent field on the endpoint nodes.
  • If the link being drawn corresponds to such a relation (i.e. one of the endpoint has the other as parent, or both have each other as parent), then the link is drawn as an arrow.
  • Graphically, this painter behaves in the same way as a JDirectedLinkPainter, of which it is inherited.

An alternative to reflection was to rely on an explicit interface for exposing the parent field of a node. However:

  • We do not want that the algorithm designer needs to know about this interface
  • The existing algorithms that use a parent field should preferably not need to be modified

acasteigts avatar Oct 17 '21 13:10 acasteigts

rebased over develop.

remikey avatar Nov 04 '21 21:11 remikey