package application.fxobjects.graph.cell;

import application.fxobjects.graph.Graph;

import java.util.List;

/**
 * Created by Arthur on 4/27/16.
 */
public class BaseLayout extends CellLayout {
    private int offset;
    private Graph graph;
    private int currentX;
    private int currentY;
    private CellType lastType;
    private int cellCount = 0;

    /**
     * Class constructor.
     * @param graph A given graph.
     * @param offset Offset to be added on execute() call.
     */
    public BaseLayout(Graph graph, int offset) {
        this.currentX = 20;
        this.currentY = 200;
        this.lastType = null;
        this.offset = offset;
        this.graph = graph;
    }

    /**
     * This method aligns every node.
     */
    public void execute() {
        List<Cell> cells = graph.getModel().getAllCells();


        for (Cell cell : cells) {
            switch (cell.getType()) {
                case RECTANGLE:
                    if (lastType != CellType.TRIANGLE) {
                        currentX += offset;
                    }
                    cell.relocate(currentX, 200);
                    currentY = 200;
                    cellCount = 0;
                    break;
                case TRIANGLE:
                    if(cellCount%2==0) {
                            currentY += (cellCount+2)*(cellCount)* offset;
                        }
                    else {
                            currentY -= (cellCount)*(cellCount+1) * offset;
                            //currentY -= offset * 2;
                        }

                    currentX += offset;
                    cellCount++;

                    cell.relocate(currentX, currentY);
                        //currentY += offset * 2;
                    break;
                default:
                    break;
            }
            lastType = cell.getType();
        }
    }
}
@@ -1261,16 +1261,17 @@
       if
+ 
 (cellCou
@@ -1276,21 +1276,21 @@
 ount
-%252
+ %25 2 
 ==
+ 
 0) %7B%0A
-    
     
@@ -1321,17 +1321,16 @@
 entY += 
-(
 cellCoun
@@ -1334,23 +1334,9 @@
 ount
-+2)*(cellCount)
+ 
 * of
@@ -1365,41 +1365,17 @@
     
-    %7D%0A                   
+%7D
  else %7B%0A
     
@@ -1370,20 +1370,16 @@
  else %7B%0A
-    
         
@@ -1410,21 +1410,8 @@
  -= 
-(cellCount)*(
 cell
@@ -1419,11 +1419,8 @@
 ount
-+1)
  * o
@@ -1430,66 +1430,8 @@
 et;%0A
-                            //currentY -= offset * 2;%0A    
     
@@ -1582,58 +1582,8 @@
 Y);%0A
-                        //currentY += offset * 2;%0A
     

Remove exponential stacked node drawing