Skip to content

Commit

Permalink
cleanup VisualizationHelpers
Browse files Browse the repository at this point in the history
* do not make the decision whether to render a node/edge depend on the parent (in most cases DefaultVisualizationHelper) because the helpers themselves make this decision.
  • Loading branch information
mtf90 committed Oct 23, 2023
1 parent b7c4e38 commit 7527f3d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ public VisualizationHelper<Node, Node> getVisualizationHelper() {

@Override
public boolean getNodeProperties(Node node, Map<String, String> properties) {
if (!super.getNodeProperties(node, properties)) {
return false;
}
super.getNodeProperties(node, properties);

if (node instanceof InnerNode) {
final InnerNode<?, ?> n = (InnerNode<?, ?>) node;
Expand All @@ -192,9 +190,7 @@ public boolean getNodeProperties(Node node, Map<String, String> properties) {

@Override
public boolean getEdgeProperties(Node src, Node edge, Node tgt, Map<String, String> properties) {
if (!super.getEdgeProperties(src, edge, tgt, properties)) {
return false;
}
super.getEdgeProperties(src, edge, tgt, properties);

if (src instanceof InnerNode) {
final InnerNode<?, ?> n = (InnerNode<?, ?>) src;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,16 @@ public boolean getEdgeProperties(HState<I, O, SP, TP> src,
HTransition<I, O, SP, TP> edge,
HState<I, O, SP, TP> tgt,
Map<String, String> properties) {
if (!super.getEdgeProperties(src, edge, tgt, properties)) {
return false;
}
super.getEdgeProperties(src, edge, tgt, properties);

properties.put(EdgeAttrs.LABEL, String.valueOf(edge.getSymbol()));
if (edge.isTree()) {
properties.put(EdgeAttrs.STYLE, EdgeStyles.BOLD);
}

return true;
}
};
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,18 @@ public boolean getEdgeProperties(TTTState<I, D> src,
TTTEdge<I, D> edge,
TTTState<I, D> tgt,
Map<String, String> properties) {
super.getEdgeProperties(src, edge, tgt, properties);

properties.put(EdgeAttrs.LABEL, String.valueOf(edge.transition.getInput()));
if (edge.transition.isTree()) {
properties.put(EdgeAttrs.STYLE, EdgeStyles.BOLD);
} else if (edge.transition.getDTTarget().isInner()) {
properties.put(EdgeAttrs.STYLE, EdgeStyles.DOTTED);
}

return true;
}

};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ public VisualizationHelper<N, Entry<O, N>> getVisualizationHelper() {

@Override
public boolean getNodeProperties(N node, Map<String, String> properties) {
if (!super.getNodeProperties(node, properties)) {
return false;
}
super.getNodeProperties(node, properties);

if (node.isLeaf()) {
properties.put(NodeAttrs.SHAPE, NodeShapes.BOX);
properties.put(NodeAttrs.LABEL, String.valueOf(node.getData()));
Expand All @@ -268,15 +267,16 @@ public boolean getNodeProperties(N node, Map<String, String> properties) {
properties.put(NodeAttrs.SHAPE, NodeShapes.OVAL);
properties.put(NodeAttrs.LABEL, d.toString());
}

return true;
}

@Override
public boolean getEdgeProperties(N src, Entry<O, N> edge, N tgt, Map<String, String> properties) {
if (!super.getEdgeProperties(src, edge, tgt, properties)) {
return false;
}
super.getEdgeProperties(src, edge, tgt, properties);

properties.put(EdgeAttrs.LABEL, String.valueOf(edge.getKey()));

return true;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ public TP getTransitionProperty(PTATransition<S> transition) {
}

@Override
public UniversalGraph<S, TransitionEdge<Integer, PTATransition<S>>, SP, Property<Integer, TP>> transitionGraphView(Collection<? extends Integer> inputs) {
public UniversalGraph<S, TransitionEdge<Integer, PTATransition<S>>, SP, Property<Integer, TP>> transitionGraphView(
Collection<? extends Integer> inputs) {
return new UniversalAutomatonGraphView<S, Integer, PTATransition<S>, SP, TP, BasePTA<S, SP, TP>>(this, inputs) {

@Override
Expand All @@ -260,18 +261,21 @@ public boolean getEdgeProperties(S src,
TransitionEdge<Integer, PTATransition<S>> edge,
S tgt,
Map<String, String> properties) {
if (!super.getEdgeProperties(src, edge, tgt, properties)) {
return false;
}
super.getEdgeProperties(src, edge, tgt, properties);

final Integer input = edge.getInput();
properties.put(EdgeAttrs.LABEL, input + " / " + src.getTransProperty(input));

return true;
}

@Override
public boolean getNodeProperties(S node, Map<String, String> properties) {
super.getNodeProperties(node, properties);

properties.put(NodeAttrs.LABEL, Objects.toString(node.getProperty()));
return super.getNodeProperties(node, properties);

return true;
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public boolean getNodeProperties(@Nullable ReuseNode<S, I, O> node, Map<String,
}

super.getNodeProperties(node, properties);

if (node.hasSystemStates()) {
properties.put(NodeAttrs.COLOR, "black");
properties.put(NodeAttrs.STYLE, "filled");
properties.put(NodeAttrs.SHAPE, "diamond");
properties.put("fontcolor", "white");
}
properties.put(NodeAttrs.LABEL, String.valueOf(node.getId()));

return true;
}

Expand All @@ -72,6 +74,7 @@ public boolean getEdgeProperties(@Nullable ReuseNode<S, I, O> src,
labelBuilder.append(output);
}
properties.put(EdgeAttrs.LABEL, labelBuilder.toString());

return true;
}
}

0 comments on commit 7527f3d

Please sign in to comment.