Skip to content

Commit

Permalink
Extract property
Browse files Browse the repository at this point in the history
make layer distance property
add descriptions to properties
  • Loading branch information
Eddykasp committed Oct 12, 2023
1 parent 2da37e1 commit fdacded
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,36 @@ algorithm yconstree(YconstreeLayoutProvider) {
supports org.eclipse.elk.edgeLabels.inline = false
// Common node micro layout
supports org.eclipse.elk.omitNodeMicroLayout
supports org.eclipse.elk.margins
// Algorithm specific properties
supports verticalConstraint
supports layoutStrategy
supports org.eclipse.elk.margins
supports layerDistance

}


option verticalConstraint: double {
label "Fixed vertical position"
description
"The Y position that the node should be fixed at."
targets nodes
}


option layoutStrategy: EdgeRoutingStrategy {
label "Strategy for the layout of it's children. 'straight' for straight line drawings, 'bend' for a possible bend"
label "Edge layout strategy"
description
"Strategy for the layout of the children. 'straight' for straight line drawings, 'bend' for a possible bend"
targets nodes
default = EdgeRoutingStrategy.STRAIGHT
}

option layerDistance: double {
label "Layer distance"
description
"The distance to use between nodes of different layers if no vertical constraints are set."
targets parents
default = 50.0
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
*
*/
public class NodeYPlacer implements ILayoutPhase<YconstreeLayoutPhases, ElkNode> {

// TODO change this to a property
private final double STANDARD_DISTANCE = 50.0;

private double layerDistance;
private IElkProgressMonitor myProgressMonitor;

@Override
Expand All @@ -34,6 +33,7 @@ public void process(final ElkNode graph, final IElkProgressMonitor progressMonit
myProgressMonitor = progressMonitor;
myProgressMonitor.begin("YPlacer", 1);

layerDistance = graph.getProperty(YconstreeOptions.LAYER_DISTANCE);

if (!graph.getChildren().isEmpty()) {
ElkNode parent = graph.getProperty(InternalProperties.ROOT_NODE);
Expand All @@ -56,7 +56,7 @@ private void setYLevels(final ElkNode node, double minHeight) {
minHeight = node.getProperty(YconstreeOptions.VERTICAL_CONSTRAINT);
}
node.setY(minHeight);
double newMinHeight = minHeight + STANDARD_DISTANCE + node.getHeight();
double newMinHeight = minHeight + layerDistance + node.getHeight();
for (int i = 0; i < node.getOutgoingEdges().size(); i++) {
ElkNode child = (ElkNode) node.getOutgoingEdges().get(i).getTargets().get(0);
setYLevels(child, newMinHeight);
Expand Down

0 comments on commit fdacded

Please sign in to comment.