Skip to content

Commit

Permalink
Cascade the sequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
calvertdw committed Oct 15, 2024
1 parent a175f15 commit 890a86c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ else if (actionSequenceNode != null && actionNodeDefinition.getExecuteAfterBegin
svgGraphics2D.drawString("%s".formatted(getTypeName(node.getDefinition())), x, y);

x = originX + 80;
y = originY + 30;
}

public int getHeight()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package us.ihmc.behaviors.behaviorTree;

import org.jfree.svg.SVGGraphics2D;
import us.ihmc.behaviors.sequence.ActionSequenceState;
import us.ihmc.log.LogTools;

import java.io.FileWriter;
Expand All @@ -14,20 +15,31 @@ public class BehaviorTreeSVGWriter
private int i = 0;
private int x = 100;
private int y = 100;
private int actionSequenceX = x;
private int actionSequenceY = y;
private final ArrayList<BehaviorTreeSVGNode> svgNodes = new ArrayList<>();

public BehaviorTreeSVGWriter(BehaviorTreeNodeState node)
{
double documentSize = 2000.0;
SVGGraphics2D svgGraphics2D = new SVGGraphics2D(documentSize, documentSize);


BehaviorTreeTools.runForSubtreeNodes(node, child ->
{
if (child instanceof ActionSequenceState)
{
actionSequenceX = x;
actionSequenceY = y;
}

BehaviorTreeSVGNode svgNode = new BehaviorTreeSVGNode(svgGraphics2D, child, svgNodes, i, x, y);
svgNodes.add(svgNode);

int verticalSpacing = 10;
y += svgNode.getHeight() + verticalSpacing;
y += svgNode.getHeight();

if (svgNodes.size() % 12 == 0)
y = actionSequenceY + 30;

++i;
});
Expand Down

0 comments on commit 890a86c

Please sign in to comment.