@@ -129,7 +129,7 @@ public class Graph {
129129 protected static HashSet <Node > _interpolators = new HashSet <Node >();
130130
131131 // Custom render
132- protected HashMap <Integer , BiConsumer <Graph , Node >> _functors ;
132+ protected HashMap <Integer , BiConsumer <Graph , Node >> _behaviors ;
133133
134134 // offscreen
135135 protected int _upperLeftCornerX , _upperLeftCornerY ;
@@ -385,7 +385,7 @@ protected void _init(Object context, int width, int height, Node eye, Type type)
385385 _irays = _i1rays ;
386386 // dummy
387387 _orays = _i2rays ;
388- _functors = new HashMap <Integer , BiConsumer <Graph , Node >>();
388+ _behaviors = new HashMap <Integer , BiConsumer <Graph , Node >>();
389389 if (eye == null ) {
390390 throw new RuntimeException ("Error eye shouldn't be null" );
391391 }
@@ -1634,7 +1634,6 @@ public void fit(Node node) {
16341634 * @see #fitFOV()
16351635 * @see #fitFOV(float)
16361636 */
1637- //TODO needs testing with flock
16381637 public void fit (Node node , float duration ) {
16391638 if (duration <= 0 ) {
16401639 _eye .set (node );
@@ -2518,11 +2517,11 @@ public void closeContext() {
25182517
25192518 /**
25202519 * Renders the node tree onto the {@link #context()} from the {@link #eye()} viewpoint.
2521- * Calls {@link #setVisit (Node, BiConsumer)} on each visited node (refer to the {@link Node} documentation).
2520+ * Calls {@link #addBehavior (Node, BiConsumer)} on each visited node (refer to the {@link Node} documentation).
25222521 * Same as {@code render(null)}.
25232522 *
25242523 * @see #render(Node)
2525- * @see #setVisit (Node, BiConsumer)
2524+ * @see #addBehavior (Node, BiConsumer)
25262525 * @see Node#cull
25272526 * @see Node#bypass()
25282527 * @see Node#setShape(Consumer)
@@ -2541,10 +2540,11 @@ public void render() {
25412540 * within {@link #openContext()} and {@link #closeContext()}.
25422541 *
25432542 * <p>
2544- * Note that the rendering algorithm calls {@link #setVisit(Node, BiConsumer)} on each visited node
2543+ * Note that the rendering algorithm executes the custom behavior (set with
2544+ * {@link #addBehavior(Node, BiConsumer)}) on each rendered node.
25452545 * (refer to the {@link Node} documentation).
25462546 *
2547- * @see #setVisit (Node, BiConsumer)
2547+ * @see #addBehavior (Node, BiConsumer)
25482548 * @see Node#cull
25492549 * @see Node#bypass()
25502550 * @see Node#setShape(Consumer)
@@ -2575,7 +2575,8 @@ public void render(Node subtree) {
25752575 }
25762576
25772577 /**
2578- * Sets a custom node visit for the {@link #render()} algorithm.
2578+ * Adds a custom node behavior to be executed for this scene
2579+ * {@link #render()} algorithm.
25792580 * <p>
25802581 * Bypassing the node rendering and/or performing hierarchical culling, i.e.,
25812582 * culling of the node and its children, should be done here.
@@ -2584,57 +2585,57 @@ public void render(Node subtree) {
25842585 * {@code
25852586 * Graph scene = new Graph(context, width, height);
25862587 * Node space = new Node();
2587- * public void visit (Graph graph, Node node) {
2588+ * public void behavior (Graph graph, Node node) {
25882589 * if (graph.cullingCondition) {
25892590 * node.cull = true;
25902591 * }
25912592 * else if (bypassCondition) {
25922593 * node.bypass();
25932594 * }
25942595 * }
2595- * scene.setVisit (space, visit );
2596+ * scene.addBehavior (space, behavior );
25962597 * }
25972598 * </pre>
25982599 * Note that the graph culling condition may be set from
25992600 * {@link #ballVisibility(Vector, float)} or {@link #boxVisibility(Vector, Vector)}.
26002601 *
2601- * @see #setVisit (Node, Consumer)
2602- * @see #resetVisit (Node)
2602+ * @see #addBehavior (Node, Consumer)
2603+ * @see #resetBehavior (Node)
26032604 * @see #render(Node)
2604- * @see Node#setVisit (Graph, BiConsumer)
2605- * @see Node#setVisit (Graph, Consumer)
2605+ * @see Node#setBehavior (Graph, BiConsumer)
2606+ * @see Node#setBehavior (Graph, Consumer)
26062607 * @see Node#bypass()
26072608 * @see Node#cull
26082609 */
2609- public void setVisit (Node node , BiConsumer <Graph , Node > functor ) {
2610- _functors .put (node .id (), functor );
2610+ public void addBehavior (Node node , BiConsumer <Graph , Node > behavior ) {
2611+ _behaviors .put (node .id (), behavior );
26112612 }
26122613
26132614 /**
2614- * Same as {@code setVisit (node, (g, n) -> functor .accept(n))}.
2615+ * Same as {@code setBehavior (node, (g, n) -> behavior .accept(n))}.
26152616 *
2616- * @see #setVisit (Node, BiConsumer)
2617- * @see #resetVisit (Node)
2617+ * @see #addBehavior (Node, BiConsumer)
2618+ * @see #resetBehavior (Node)
26182619 * @see #render(Node)
2619- * @see Node#setVisit (Graph, BiConsumer)
2620- * @see Node#setVisit (Graph, Consumer)
2620+ * @see Node#setBehavior (Graph, BiConsumer)
2621+ * @see Node#setBehavior (Graph, Consumer)
26212622 * @see Node#bypass()
26222623 * @see Node#cull
26232624 */
2624- public void setVisit (Node node , Consumer <Node > functor ) {
2625- setVisit (node , (g , n ) -> functor .accept (n ));
2625+ public void addBehavior (Node node , Consumer <Node > behavior ) {
2626+ addBehavior (node , (g , n ) -> behavior .accept (n ));
26262627 }
26272628
26282629 /**
2629- * Resets the node custom visit set with {@link #setVisit (Node, BiConsumer)}.
2630+ * Resets the node custom behavior which is set with {@link #addBehavior (Node, BiConsumer)}.
26302631 *
2631- * @see #setVisit (Node, BiConsumer)
2632+ * @see #addBehavior (Node, BiConsumer)
26322633 * @see #render(Node)
26332634 * @see Node#bypass()
26342635 * @see Node#cull
26352636 */
2636- public void resetVisit (Node node ) {
2637- _functors .remove (node .id ());
2637+ public void resetBehavior (Node node ) {
2638+ _behaviors .remove (node .id ());
26382639 }
26392640
26402641 /**
@@ -2644,10 +2645,16 @@ protected void _render(Node node) {
26442645 _matrixHandler .pushMatrix ();
26452646 node ._execute (this );
26462647 _matrixHandler .applyTransformation (node );
2647- // TODO should go before pushMatrix ???
2648- BiConsumer <Graph , Node > functor = _functors .get (node .id ());
2649- if (functor != null ) {
2650- functor .accept (this , node );
2648+ // TODO ordering of operations is a bit experimental.
2649+ // For instance should the visits go before pushMatrix?
2650+ // I believe it belongs here, i.e., current node culling
2651+ // condition may require local geometry operations.
2652+ // On the oder hand, timing stuff (node_execute) may only
2653+ // be executed once it's known for sure the node is not
2654+ // culled :-/
2655+ BiConsumer <Graph , Node > behavior = _behaviors .get (node .id ());
2656+ if (behavior != null ) {
2657+ behavior .accept (this , node );
26512658 }
26522659 if (!node .cull ) {
26532660 if (node ._bypass != _frameCount ) {
0 commit comments