Skip to content

Commit

Permalink
Refactor unclear variable names
Browse files Browse the repository at this point in the history
change rol and lol to right and left outline in vars and comments
  • Loading branch information
Eddykasp committed Oct 23, 2023
1 parent d024b5d commit 9afabc1
Showing 1 changed file with 28 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,22 @@ private void yConsTreeStep(final ElkNode graph) {
double newMoveRoot;

if (betterMoveRoot < moveRoot) {
OutlineNode rol;
double rolX, posX;
OutlineNode rightOutline;
double rightOutlineX, posX;
for (int i = 0; i < maxDepthStartPos; i++) {
for (int j = i + 1; j < maxDepthStartPos + 1; j++) {
rol = children.get(i).getProperty(InternalProperties.RIGHT_OUTLINE);
rolX = children.get(i).getX() + rol.getRelativeX();
rightOutline = children.get(i).getProperty(InternalProperties.RIGHT_OUTLINE);
rightOutlineX = children.get(i).getX() + rightOutline.getRelativeX();
posX = children.get(j).getX() + children.get(j).getWidth() / 2.0;
while (rol != null && rol.getAbsoluteY() < maxDepth) {
// new moveRoot
newMoveRoot = posX - graph.getWidth() / 2.0 + (posX - rolX) * ((graph.getY()
+ graph.getHeight()) - maxDepth) / (maxDepth - rol.getAbsoluteY());
while (rightOutline != null && rightOutline.getAbsoluteY() < maxDepth) {

newMoveRoot = posX - graph.getWidth() / 2.0 + (posX - rightOutlineX) * ((graph.getY()
+ graph.getHeight()) - maxDepth) / (maxDepth - rightOutline.getAbsoluteY());
betterMoveRoot = Math.max(betterMoveRoot, newMoveRoot);

// update Rol and RolX
rol = rol.getNext();
if (rol != null) {
rolX += rol.getRelativeX();

rightOutline = rightOutline.getNext();
if (rightOutline != null) {
rightOutlineX += rightOutline.getRelativeX();
}
}
}
Expand All @@ -209,23 +208,22 @@ private void yConsTreeStep(final ElkNode graph) {
}

if (betterMoveRoot > moveRoot) {
OutlineNode lol;
double lolX, posX;
OutlineNode leftOutline;
double leftOutlineX, posX;
for (int i = pos; i < children.size(); i++) {
for (int j = pos - 1; j < i; j++) {
lol = children.get(i).getProperty(InternalProperties.LEFT_OUTLINE);
lolX = children.get(i).getX() + lol.getRelativeX();
leftOutline = children.get(i).getProperty(InternalProperties.LEFT_OUTLINE);
leftOutlineX = children.get(i).getX() + leftOutline.getRelativeX();
posX = children.get(j).getX() + children.get(j).getWidth() / 2.0;
while (lol != null && lol.getAbsoluteY() < maxDepth) {
// new moveRoot
newMoveRoot = posX - graph.getWidth() / 2.0 + (posX - lolX) * ((graph.getY()
+ graph.getHeight()) - maxDepth) / (maxDepth - lol.getAbsoluteY());
while (leftOutline != null && leftOutline.getAbsoluteY() < maxDepth) {

newMoveRoot = posX - graph.getWidth() / 2.0 + (posX - leftOutlineX) * ((graph.getY()
+ graph.getHeight()) - maxDepth) / (maxDepth - leftOutline.getAbsoluteY());
betterMoveRoot = Math.min(betterMoveRoot, newMoveRoot);

// update Rol and RolX
lol = lol.getNext();
if (lol != null) {
lolX += lol.getRelativeX();
leftOutline = leftOutline.getNext();
if (leftOutline != null) {
leftOutlineX += leftOutline.getRelativeX();
}
}
}
Expand All @@ -239,13 +237,13 @@ private void yConsTreeStep(final ElkNode graph) {


double newX;
// lol update
// left outline update
newX = children.get(0).getX() + children.get(0).getProperty(InternalProperties.LEFT_OUTLINE).getRelativeX()
- graph.getProperty(InternalProperties.LEFT_OUTLINE).getRelativeX();
graph.getProperty(InternalProperties.LEFT_OUTLINE).getNext().getNext().getNext().setNext(
new OutlineNode(newX, children.get(0).getProperty(InternalProperties.LEFT_OUTLINE).getAbsoluteY(),
children.get(0).getProperty(InternalProperties.LEFT_OUTLINE).getNext()));
// rol update
// right outline update
newX = children.get(children.size() - 1).getX()
+ children.get(children.size() - 1).getProperty(InternalProperties.RIGHT_OUTLINE).getRelativeX()
- graph.getProperty(InternalProperties.RIGHT_OUTLINE).getRelativeX();
Expand Down Expand Up @@ -338,7 +336,7 @@ private void alternativeYConsTreeStep(final ElkNode graph) {

double newX;
OutlineNode newOutlinepart;
// lol update
// left outline update
newX = children.get(0).getX() + children.get(0).getProperty(InternalProperties.LEFT_OUTLINE).getRelativeX()
- graph.getProperty(InternalProperties.LEFT_OUTLINE).getRelativeX();
newOutlinepart = new OutlineNode(0.0, children.get(0).getProperty(InternalProperties.LEFT_OUTLINE)
Expand Down Expand Up @@ -458,7 +456,7 @@ private void bundleChildren(final ElkNode leftSubtree, final ElkNode a, final El
lastL = lastL.getNext();
lAbsX += lastL.getRelativeX();
}
// find fiting position in the lol of b
// find fiting position in the left outline of b
OutlineNode bItterator = new OutlineNode(b.getProperty(InternalProperties.LEFT_OUTLINE).getRelativeX(),
MINIMAL_Y, b.getProperty(InternalProperties.LEFT_OUTLINE).getNext());
double rAbsX = bItterator.getRelativeX() + b.getX();
Expand Down Expand Up @@ -491,7 +489,7 @@ private void bundleChildren(final ElkNode leftSubtree, final ElkNode a, final El
lastB = lastB.getNext();
rAbsX += lastB.getRelativeX();
}
// find fitting position in the rol of a
// find fitting position in the right outline of a
OutlineNode aItterator = new OutlineNode(a.getProperty(InternalProperties.RIGHT_OUTLINE).getRelativeX(),
MINIMAL_Y, a.getProperty(InternalProperties.RIGHT_OUTLINE).getNext());
double aAbsX = aItterator.getRelativeX() + a.getX();
Expand Down

0 comments on commit 9afabc1

Please sign in to comment.