Skip to content

Commit

Permalink
Support nodeNode spacing property
Browse files Browse the repository at this point in the history
spacing.nodeNode is now considered when constructing outline nodes in
addition to any existing node margins.
  • Loading branch information
Eddykasp committed Oct 12, 2023
1 parent 45a4edc commit 21ba60a
Showing 1 changed file with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@
public class RelativeXPlacer implements ILayoutPhase<YconstreeLayoutPhases, ElkNode> {


private IElkProgressMonitor pm;
//TODO remove unused or get value from property and actually use it
private double spacingNodeNode = 0.0;
private IElkProgressMonitor myProgressMonitor;
private double spacingNodeNode;

// TODO remove magic number, make const or property
// a constant for moving every Outline to a minimal y-pos
private double minimalY = -100.0;

@Override
public void process(final ElkNode graph, final IElkProgressMonitor progressMonitor) {
// TODO Auto-generated method stub
pm = progressMonitor;
pm.begin("XPlacer", 1);
myProgressMonitor = progressMonitor;
myProgressMonitor.begin("XPlacer", 1);

spacingNodeNode = graph.getProperty(CoreOptions.SPACING_NODE_NODE);

Expand All @@ -65,7 +63,7 @@ public void process(final ElkNode graph, final IElkProgressMonitor progressMonit
e.printStackTrace();
}

pm.done();
myProgressMonitor.done();
}

private double outlineDistance(final OutlineNode outline1, final OutlineNode outline2) {
Expand Down Expand Up @@ -146,8 +144,6 @@ private double outlineDistance(final OutlineNode outline1, final OutlineNode out
*/
private void yConsTreeStep(final ElkNode graph) {

ElkMargin margins = graph.getProperty(CoreOptions.MARGINS);

makeSimpleOutlines(graph);

if (!graph.getOutgoingEdges().isEmpty()) {
Expand Down Expand Up @@ -189,8 +185,7 @@ private void yConsTreeStep(final ElkNode graph) {
double betterMoveRoot = (children.get(0).getX() + children.get(children.size() - 1).getX()
+ children.get(children.size() - 1).getWidth() - graph.getWidth()) / 2.0 - graph.getX();
double newMoveRoot;

//if better moveRoote is left of moveRoot

if (betterMoveRoot < moveRoot) {
OutlineNode rol;
double rolX, posX;
Expand All @@ -215,8 +210,7 @@ private void yConsTreeStep(final ElkNode graph) {
}
moveRoot = betterMoveRoot;
}

//if better moveRoote is right of moveRoot

if (betterMoveRoot > moveRoot) {
OutlineNode lol;
double lolX, posX;
Expand Down Expand Up @@ -277,9 +271,7 @@ private void yConsTreeStep(final ElkNode graph) {

}
}




private void alternativeYConsTreeStep(final ElkNode graph) {

makeSimpleOutlines(graph);
Expand Down Expand Up @@ -419,22 +411,30 @@ private void makeSimpleOutlines(final ElkNode graph) {

// set the properties for left and right outlines
OutlineNode endpart;
endpart = new OutlineNode(0.0, graph.getY() + graph.getHeight() + margins.bottom,
new OutlineNode(graph.getWidth() / 2.0, graph.getY() + graph.getHeight() + margins.bottom, null));
graph.setProperty(InternalProperties.LEFT_OUTLINE, new OutlineNode((-margins.left)
+ graph.getWidth() / 2.0, graph.getY() - margins.top, new OutlineNode(-graph.getWidth() / 2.0,
graph.getY() - margins.top, endpart)));
endpart = new OutlineNode(0.0, graph.getY() + graph.getHeight() + margins.bottom, new OutlineNode(
-graph.getWidth() / 2.0, graph.getY() + graph.getHeight() + margins.bottom, null));
endpart = new OutlineNode(0.0, graph.getY() + graph.getHeight() + margins.bottom + spacingNodeNode / 2,
new OutlineNode(graph.getWidth() / 2.0,
graph.getY() + graph.getHeight() + margins.bottom + spacingNodeNode / 2, null));

graph.setProperty(InternalProperties.LEFT_OUTLINE, new OutlineNode((-margins.left - spacingNodeNode / 2)
+ graph.getWidth() / 2.0, graph.getY() - margins.top - spacingNodeNode / 2,
new OutlineNode(-graph.getWidth() / 2.0, graph.getY() - margins.top, endpart)));

endpart = new OutlineNode(0.0, graph.getY() + graph.getHeight() + margins.bottom,
new OutlineNode(-graph.getWidth() / 2.0,
graph.getY() + graph.getHeight() + margins.bottom + spacingNodeNode / 2, null));

graph.setProperty(InternalProperties.RIGHT_OUTLINE, new OutlineNode(graph.getWidth() / 2.0
+ margins.right, graph.getY() - margins.top, new OutlineNode(graph.getWidth() / 2.0, graph.getY()
- margins.top, endpart)));
+ margins.right + spacingNodeNode / 2, graph.getY() - margins.top,
new OutlineNode(graph.getWidth() / 2.0, graph.getY() - margins.top - spacingNodeNode / 2, endpart)));

// TODO double check whether this is the best way and place to calculate this
// set min and max values
graph.setProperty(InternalProperties.MIN_X, graph.getX() - margins.left);
graph.setProperty(InternalProperties.MAX_X, graph.getX() + margins.right + graph.getWidth());
graph.setProperty(InternalProperties.MAX_X,
graph.getX() + margins.right + spacingNodeNode / 2 + graph.getWidth());
graph.setProperty(InternalProperties.MIN_Y, graph.getY() - margins.top);
graph.setProperty(InternalProperties.MAX_Y, graph.getY() + margins.bottom + graph.getHeight());
graph.setProperty(InternalProperties.MAX_Y,
graph.getY() + margins.bottom + spacingNodeNode / 2 + graph.getHeight());
graph.setProperty(InternalProperties.OUTLINE_MAX_DEPTH, graph.getProperty(InternalProperties.LEFT_OUTLINE)
.getNext().getNext().getAbsoluteY());

Expand Down Expand Up @@ -516,14 +516,10 @@ private void bundleChildren(final ElkNode leftSubtree, final ElkNode a, final El
b.setProperty(InternalProperties.OUTLINE_MAX_DEPTH, a.getProperty(InternalProperties.OUTLINE_MAX_DEPTH));
}
}

/* (non-Javadoc)
* @see org.eclipse.elk.core.alg.ILayoutPhase#getLayoutProcessorConfiguration(java.lang.Object)
*/

@Override
public LayoutProcessorConfiguration<YconstreeLayoutPhases, ElkNode>
getLayoutProcessorConfiguration(ElkNode graph) {
// TODO Auto-generated method stub
getLayoutProcessorConfiguration(final ElkNode graph) {
return null;
}

Expand Down

0 comments on commit 21ba60a

Please sign in to comment.