JBotSim
JBotSim copied to clipboard
Add a link painter that takes logical orientation into account
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.
What was done:
- A
JParentLinkPainterwas added that uses reflection to inspect aparentfield 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
rebased over develop.