浏览代码

Merge branch 'master' into BetterStructure

# Conflicts:
#	src/animation/PseudoCodeNode.java
#	src/bk/BKNodePlacement.java
#	src/bk/BlockCalc.java
#	src/bk/Compaction.java
#	src/graph/LayeredNode.java
#	src/lib/TextLayoutHelper.java
Eren Yilmaz 6 年之前
父节点
当前提交
1f7f63fa5a

+ 1 - 1
doc/chapter/2architecture.tex

@@ -12,7 +12,7 @@ The following assumptions are made for the implementation of the node placement
 Regarding the last assumption, we found an example where for a disconnected graph the algorithm behaved incorrectly.
 Maybe we will get rid of this assumption later, see chapter~\ref{ch:progress}.
 We are currently investigating another example, where the algorithm behaves incorrectly for a connected graph.
-These two examples are included in the appendix (figures~\ref{fig:error_disconnected_img},~\ref{fig:error_connected_img},~\ref{fig:error_disconnected}, and~\ref{fig:error_connected},).
+These two examples are included in the appendix (figures~\ref{fig:error_disconnected_img},~\ref{fig:error_connected_img},~\ref{fig:error_disconnected}, and~\ref{fig:error_connected}).
 
 
 \section{Overview}\label{sec:components}

+ 2 - 1
doc/chapter/3ui.tex

@@ -52,7 +52,8 @@ Figure~\ref{fig:originalpapergraph} compares our results to those of Brandes and
         \includegraphics[width=0.4\linewidth]{img/bk-example-ours}
         \caption[The same graph as~\ref{fig:theirs}, displayed by \appname.]{The same graph as~\ref{fig:theirs}, displayed by \appname.
         The layouts are leftmost (first column), rightmost (third column), upper (first row) and lower (third row), respectively.
-        The balanced layout is in the center.}
+        The balanced layout is in the center.
+        The narrower nodes are dummy nodes.}
         \label{fig:ours}
     \end{subfigure}\\\vspace{4mm}
     \caption[Comparison to Brandes and Köpf]{Comparison of the implementation to the results of Brandes and Köpf~\cite{brandes_fast_2001}}

+ 12 - 2
doc/chapter/4progress.tex

@@ -1,3 +1,5 @@
+\section{Features}\label{sec:features}
+
 The following features are either planned (\planned), under construction (\progress) or done (\done):
 \begin{itemize}
     \item[\done] Reading a graph from an input file as described in section~\ref{sec:inputFileFormat}.
@@ -48,6 +50,14 @@ The following features are either planned (\planned), under construction (\progr
     \item[\done] Working with hierarchical graphs.
     \item[\done] Scaling the display with the (adjustable) window size.
     \item[\planned] Working with disconnected graphs (cf.\ section~\ref{sec:assumptions}), either by modifying the algorithm or by processing the connected components one by one (low priority).
-    \item[\done] Creating ElkNode~\cite{noauthor_elk:_2018} objects from LayeredNode (\ref{sec:graph}) objects.
-    \item[\planned] Creating LayeredNode (\ref{sec:graph}) objects from ElkNode~\cite{noauthor_elk:_2018} objects (low priority).
+    \item[\done] Creating ElkNode~\cite{noauthor_elk:_2018} objects from LayeredGraphNode (\ref{sec:graph}) objects.
+    \item[\planned] Creating LayeredGraphNode (\ref{sec:graph}) objects from ElkNode~\cite{noauthor_elk:_2018} objects (low priority).
+\end{itemize}
+
+\section{Known Issues}\label{sec:knownIssues}
+The most important unsolved issues are listed here.
+For a complete list, see \url{https://koljastrohm-games.com:3000/GraphDrawer/NodeShuffler/issues}.
+\begin{itemize}
+    \item Our implementation does not behave correctly for very few graphs, see section ~\ref{sec:assumptions} and figures~\ref{fig:error_disconnected_img},~\ref{fig:error_connected_img},~\ref{fig:error_disconnected}, and~\ref{fig:error_connected}.
+    \item Swing is not thread-safe, but we are using multiple threads, so every now and then there are race conditions causing mostly \code{ArrayIndexOutOfBoundsException}s and \code{NullPointerException}s.
 \end{itemize}

+ 2 - 0
doc/chapter/appendix.tex

@@ -19,6 +19,8 @@
         Extremal layout & Defines in which order the layers are traversed and if a node is aligned with its upper or lower median. & Leftmost lower \\
         \rowcolor{gray!25}
         Automatic execution & The state of the \code{AnimationController} where it repeatedly sends step commands with a certain delay & See section~\ref{sec:userInterface} \\
+        Automatic backwards execution & Special case of automatic execution in backwards direction & See section~\ref{sec:userInterface} \\
+        \rowcolor{gray!25}
         step overrun & The state of the \code{AnimationController} where it repeatedly sends step commands, but only inserts a delay after steps whose line of pseudocode is currently unfolded in the pseudocode view. & See section~\ref{sec:userInterface} \\
         \\\\
 	\end{longtable}

二进制
doc/img/bk-example-ours.png


二进制
doc/img/example.png


二进制
doc/img/full-application-example.png


+ 3 - 1
src/animation/AnimatedAlgorithm.java

@@ -48,7 +48,9 @@ public abstract class AnimatedAlgorithm extends Thread {
             try {
                 if( processor != null )
                 {
-                    switch( ac.getNextAction() )
+                    Action action = ac.getNextAction();
+                    graph.unselectGraph();
+                    switch( action )
                     {
                     case FORWARD:
                     	status = processor.forwardStep();

+ 1 - 1
src/animation/AnimationController.java

@@ -83,8 +83,8 @@ public class AnimationController {
      */
     public void setNextAction( Action a )
     {
-        next = a;
         synchronized( this ) {
+            next = a;
             notify();
         }
     }

+ 7 - 7
src/animation/PseudoCodeNode.java

@@ -46,7 +46,7 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         breakPoint = false;
         code = line;
     }
-    
+
     public int getId()
     {
         return nodeId;
@@ -112,12 +112,12 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
     		((PseudoCodeNode)parent).expandToRoot();
         tree.expandPath( new TreePath( this.getPath() ) );
     }
-    
+
     /**
      * highlight this line of pseudocode.
      * should be called when the line is entered, as it triggers breakpoints
      * @param selected whether to select or deselect this line
-     * @return false iff a breakpoint was reached and the node was set to be selected.
+     * @return if the automatic execution should continue.
      */
     public CodeAction setSelected( boolean selected )
     {
@@ -187,14 +187,14 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
     {
         return breakPoint;
     }
-    
+
     public ControlFlow forwardStep( Memory m )
     {
         ControlFlow cf = code.runForward( m );
         cf.setJumpBack( this );
         return cf;
     }
-    
+
     public ControlFlow emptyForwardStep( Memory m )
     {
         code.actions.push( (Memory mem) -> {} ); // add empty reverse function
@@ -202,12 +202,12 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         cf.setJumpBack( this );
         return cf;
     }
-    
+
     public void backwardStep( Memory m )
     {
         code.runBackward( m );
     }
-    
+
     public String getDebugOutput( Memory m )
     {
         if( parent == null )

+ 15 - 15
src/bk/BKNodePlacement.java

@@ -36,9 +36,9 @@ public class BKNodePlacement extends AnimatedAlgorithm {
         LAYOUT4,
         COMBINE
     }
-    
+
     private State state;
-    
+
     public BKNodePlacement(AnimationController controller, LayeredGraphNode graph, JFrame view) {
         super(controller, graph, view);
         state = State.CONFLICTS;
@@ -74,10 +74,10 @@ public class BKNodePlacement extends AnimatedAlgorithm {
 				} );
 				return new ControlFlow( mainFunction );
 			}
-        	
+
         } );
         root.setSelected( true );
-    	
+
         PseudoCodeNode conflictDetectionFunction = ConflictDetection.mark_conflicts( tree );
         PseudoCodeNode calcLayout = new PseudoCodeNode( "function calcLayout( layout, graph )", vars, tree, new FunctionDefinition( vars ) );
         PseudoCodeNode combine = Combine.combine( tree );
@@ -154,12 +154,12 @@ public class BKNodePlacement extends AnimatedAlgorithm {
                 }
                 for( LayeredGraphNode n : graph.getContainedNodes() )
                 {
-                    info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getShift( type ) + "", 7 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getSink( type ).getName(), 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getRoot( type ).getName(), 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getAlign( type ).getName(), 7 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getX( type ) + "", 5 ) + 
+                    info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getShift( type ) + "", 7 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getSink( type ).getName(), 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getRoot( type ).getName(), 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getAlign( type ).getName(), 7 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( type ) + "", 5 ) +
                             "|" + TextLayoutHelper.strToLen( !n.isXUndefined( type ) + "", 8 ) + "|\n";
                 }
                 return info;
@@ -182,11 +182,11 @@ public class BKNodePlacement extends AnimatedAlgorithm {
                 LayeredGraphNode graph = m.read( "graph", MemoryType.COMPLETE_STACK );
                 for( LayeredGraphNode n : graph.getContainedNodes() )
                 {
-                    info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_LEFT ) + "", 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_RIGHT ) + "", 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 6 ) + 
-                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 6 ) + 
+                    info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_LEFT ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_RIGHT ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 6 ) +
+                            "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 6 ) +
                             "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.COMBINED ) + "", 6 ) + "|\n";
                 }
                 return info;

+ 5 - 5
src/bk/BlockCalc.java

@@ -27,7 +27,7 @@ import graph.LayeredGraphNode;
  *
  */
 public class BlockCalc {
-    
+
     public static PseudoCodeNode calculateBlockGraph( JTree tree, PseudoCodeNode claclLayout ) {
         String[] vars = { "graph", "L", "r", "neighbors", "layout", "m", "i", "k", "mids", "n" };
         @SuppressWarnings("serial")
@@ -179,8 +179,8 @@ public class BlockCalc {
         PseudoCodeNode ifMarked = new PseudoCodeNode( "if (neighbors[m],n) not conflicted and ((r < pos(neighbors[m]) and layout.contains('RIGHT')) or (r > pos(neighbors[m]) and layout.contains('LEFT'))) then", vars, tree, new IfLoop() {
             @Override
             protected boolean condition(ReadOnlyMemory m) {
-                LayeredGraphEdge e = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).findEdgeBetween( 
-                        m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) ), 
+                LayeredGraphEdge e = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).findEdgeBetween(
+                        m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) ),
                         m.read( "n", MemoryType.LOCAL ) );
                 if( e == null )
                     e = m.<LayeredGraphNode>read( "graph", MemoryType.LOCAL ).findEdgeBetween( m.read( "n", MemoryType.LOCAL ),
@@ -191,8 +191,8 @@ public class BlockCalc {
                 else
                     layerBefore = m.<ArrayList<ArrayList<LayeredGraphNode>>>read( "L", MemoryType.LOCAL ).get( m.<Integer>read( "i", MemoryType.LOCAL ) + 1 );
                 int posU = layerBefore.indexOf( m.<ArrayList<LayeredGraphNode>>read( "neighbors", MemoryType.LOCAL ).get( m.read( "m", MemoryType.LOCAL ) ) );
-                return !e.isConflicted( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ) && 
-                        ( ( m.<Double>read( "r", MemoryType.LOCAL ) < posU && m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) ) || 
+                return !e.isConflicted( LayoutType.fromString( m.read( "layout", MemoryType.LOCAL ) ) ) &&
+                        ( ( m.<Double>read( "r", MemoryType.LOCAL ) < posU && m.<String>read( "layout", MemoryType.LOCAL ).contains( "RIGHT" ) ) ||
                                 ( m.<Double>read( "r", MemoryType.LOCAL ) > posU && m.<String>read( "layout", MemoryType.LOCAL ).contains( "LEFT" ) ) );
             }
         });

+ 1 - 1
src/graph/LayeredGraphNode.java

@@ -184,7 +184,7 @@ public interface LayeredGraphNode {
   public boolean isDummyNode();
 
   /**
-   * unselects the subgraph of this node
+   * unselects recursively all contained nodes in all subgraphs of this node
    */
   public void unselectGraph();
 

+ 483 - 556
src/graph/LayeredNode.java

@@ -12,8 +12,7 @@ import bk.LayoutType;
 import view.NodeView;
 
 /**
- * Die Implementation eines Knotens in einem Layered Graph.
- * Implementiert {@link LayeredGraphNode}.
+ * Die Implementation eines Knotens in einem Layered Graph. Implementiert {@link LayeredGraphNode}.
  * 
  * @author kolja
  *
@@ -22,9 +21,8 @@ public class LayeredNode implements LayeredGraphNode {
     private ElkNode original;
     private LayeredGraphNode parent;
     private boolean dummy;
-    
-    private class LayoutInfo
-    {
+
+    private class LayoutInfo {
         public double x;
         public double y;
         public double w;
@@ -32,7 +30,7 @@ public class LayeredNode implements LayeredGraphNode {
         public Color color;
         public boolean selected;
         public boolean xUndef;
-        
+
         // Block Calculation
         public LayeredGraphNode align;
         public LayeredGraphNode root;
@@ -41,9 +39,8 @@ public class LayeredNode implements LayeredGraphNode {
         public double shift;
         private NodeView view;
     }
-    
-    private class CombinedLayoutInfo
-    {
+
+    private class CombinedLayoutInfo {
         public double x;
         public double y;
         public double w;
@@ -52,47 +49,46 @@ public class LayeredNode implements LayeredGraphNode {
         public boolean selected;
         private NodeView view;
     }
-    
+
     private LayoutInfo[] layouts;
     private CombinedLayoutInfo combined;
     private String name;
-    
+
     // for subgraph in this node
-    private ArrayList< LayeredGraphEdge > edges;
-    private ArrayList< LayeredGraphNode > nodes;
-    private ArrayList< ArrayList< LayeredGraphNode > > layers;
-    
+    private ArrayList<LayeredGraphEdge> edges;
+    private ArrayList<LayeredGraphNode> nodes;
+    private ArrayList<ArrayList<LayeredGraphNode>> layers;
+
     /**
      * Konvertiert einen Graph aus dem Elk format in einen Graph, der mehr Informationen enth�lt
-     * @param n Der Graph, welcher konvertiert werden soll
+     *
+     * @param n
+     *            Der Graph, welcher konvertiert werden soll
      * @return Ein layered Graph, welcher im wesentlichen ein Wrapper f�r den urspr�nglichen Graphen ist
      */
-    public static LayeredGraphNode convertToLayeredGraph( ElkNode n )
-    {
-        LayeredNode ln = new LayeredNode( n, null );
-        for( ElkNode node : n.getChildren() )
-            ln.addNode( convertToLayeredGraph( node ) );
-        for( ElkEdge edge : n.getContainedEdges() )
-        {
-        	// TODO n.getProperty(Properties.LAYERPOS) reads position of node n in his layer
-            ArrayList< LayeredGraphNode > sources = new ArrayList<>();
-            ArrayList< LayeredGraphNode > targets = new ArrayList<>();
+    public static LayeredGraphNode convertToLayeredGraph(ElkNode n) {
+        LayeredNode ln = new LayeredNode(n, null);
+        for (ElkNode node : n.getChildren())
+            ln.addNode(convertToLayeredGraph(node));
+        for (ElkEdge edge : n.getContainedEdges()) {
+            // TODO n.getProperty(Properties.LAYERPOS) reads position of node n in his layer
+            ArrayList<LayeredGraphNode> sources = new ArrayList<>();
+            ArrayList<LayeredGraphNode> targets = new ArrayList<>();
             EList<ElkConnectableShape> s = edge.getSources();
             EList<ElkConnectableShape> t = edge.getTargets();
-            for( ElkConnectableShape shape : s )
-                sources.add( ln.findNodeFromOriginal( shape ) );
-            for( ElkConnectableShape shape : t )
-                targets.add( ln.findNodeFromOriginal( shape ) );
-            ln.createEdge( edge, sources, targets );
+            for (ElkConnectableShape shape : s)
+                sources.add(ln.findNodeFromOriginal(shape));
+            for (ElkConnectableShape shape : t)
+                targets.add(ln.findNodeFromOriginal(shape));
+            ln.createEdge(edge, sources, targets);
         }
         return ln;
     }
-    
-    public LayeredNode( ElkNode original, LayeredGraphNode parent )
-    {
+
+    public LayeredNode(ElkNode original, LayeredGraphNode parent) {
         this.original = original;
         this.parent = parent;
-        
+
         edges = new ArrayList<>();
         nodes = new ArrayList<>();
         layers = new ArrayList<>();
@@ -121,392 +117,347 @@ public class LayeredNode implements LayeredGraphNode {
         }
         dummy = false;
         combined = new CombinedLayoutInfo();
-        if( original != null )
-        {
-	        combined.x = original.getX();
-	        combined.y = original.getX();
-	        combined.w = original.getWidth();
-	        combined.h = original.getHeight();
+        if (original != null) {
+            combined.x = original.getX();
+            combined.y = original.getX();
+            combined.w = original.getWidth();
+            combined.h = original.getHeight();
         }
         combined.color = null;
         combined.selected = false;
     }
-    
-    public void setView( NodeView view, LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].view = view;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].view = view;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].view = view;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].view = view;
-        if( layout == LayoutType.COMBINED )
+
+    public void setView(NodeView view, LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].view = view;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].view = view;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].view = view;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].view = view;
+        if (layout == LayoutType.COMBINED)
             this.combined.view = view;
     }
-    
-    public NodeView getView( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return layouts[ 0 ].view;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return layouts[ 1 ].view;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return layouts[ 2 ].view;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return layouts[ 3 ].view;
-        if( layout == LayoutType.COMBINED )
+
+    public NodeView getView(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return layouts[0].view;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return layouts[1].view;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return layouts[2].view;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return layouts[3].view;
+        if (layout == LayoutType.COMBINED)
             return combined.view;
         return null;
     }
-    
+
     @Override
-    public void setDummyNode( boolean dummy )
-    {
-    	this.dummy = dummy;
+    public void setDummyNode(boolean dummy) {
+        this.dummy = dummy;
     }
-    
+
     @Override
-    public boolean isDummyNode()
-    {
-    	return dummy;
+    public boolean isDummyNode() {
+        return dummy;
     }
 
     @Override
-    public void setShift( double shift, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].shift = shift;
-            this.layouts[ 1 ].shift = shift;
-            this.layouts[ 2 ].shift = shift;
-            this.layouts[ 3 ].shift = shift;
-        }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].shift = shift;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].shift = shift;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].shift = shift;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].shift = shift;
-    }
-    
-    @Override
-    public double getShift( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].shift;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].shift;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].shift;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].shift;
+    public void setShift(double shift, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].shift = shift;
+            this.layouts[1].shift = shift;
+            this.layouts[2].shift = shift;
+            this.layouts[3].shift = shift;
+        }
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].shift = shift;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].shift = shift;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].shift = shift;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].shift = shift;
+    }
+
+    @Override
+    public double getShift(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].shift;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].shift;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].shift;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].shift;
         return 0;
     }
 
     @Override
-    public void setSink( LayeredGraphNode sink, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].sink = sink;
-            this.layouts[ 1 ].sink = sink;
-            this.layouts[ 2 ].sink = sink;
-            this.layouts[ 3 ].sink = sink;
-        }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].sink = sink;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].sink = sink;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].sink = sink;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].sink = sink;
-    }
-    
-    @Override
-    public LayeredGraphNode getSink( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].sink;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].sink;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].sink;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].sink;
+    public void setSink(LayeredGraphNode sink, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].sink = sink;
+            this.layouts[1].sink = sink;
+            this.layouts[2].sink = sink;
+            this.layouts[3].sink = sink;
+        }
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].sink = sink;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].sink = sink;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].sink = sink;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].sink = sink;
+    }
+
+    @Override
+    public LayeredGraphNode getSink(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].sink;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].sink;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].sink;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].sink;
         return null;
     }
-    
+
     @Override
-    public boolean isXUndefined( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].xUndef;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].xUndef;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].xUndef;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].xUndef;
+    public boolean isXUndefined(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].xUndef;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].xUndef;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].xUndef;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].xUndef;
         return true;
     }
 
     @Override
-    public void setAlign( LayeredGraphNode align, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].align = align;
-            this.layouts[ 1 ].align = align;
-            this.layouts[ 2 ].align = align;
-            this.layouts[ 3 ].align = align;
+    public void setAlign(LayeredGraphNode align, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].align = align;
+            this.layouts[1].align = align;
+            this.layouts[2].align = align;
+            this.layouts[3].align = align;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].align = align;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].align = align;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].align = align;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].align = align;
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].align = align;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].align = align;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].align = align;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].align = align;
     }
 
     @Override
-    public LayeredGraphNode getAlign( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].align;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].align;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].align;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].align;
+    public LayeredGraphNode getAlign(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].align;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].align;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].align;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].align;
         return null;
     }
 
     @Override
-    public void setRoot( LayeredGraphNode root, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].root = root;
-            this.layouts[ 1 ].root = root;
-            this.layouts[ 2 ].root = root;
-            this.layouts[ 3 ].root = root;
+    public void setRoot(LayeredGraphNode root, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].root = root;
+            this.layouts[1].root = root;
+            this.layouts[2].root = root;
+            this.layouts[3].root = root;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].root = root;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].root = root;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].root = root;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].root = root;
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].root = root;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].root = root;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].root = root;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].root = root;
     }
 
     @Override
-    public LayeredGraphNode getRoot( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].root;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].root;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].root;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].root;
+    public LayeredGraphNode getRoot(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].root;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].root;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].root;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].root;
         return null;
     }
 
     @Override
-    public void setSelected( LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].selected = true;
-            this.layouts[ 1 ].selected = true;
-            this.layouts[ 2 ].selected = true;
-            this.layouts[ 3 ].selected = true;
+    public void setSelected(LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].selected = true;
+            this.layouts[1].selected = true;
+            this.layouts[2].selected = true;
+            this.layouts[3].selected = true;
             combined.selected = true;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].selected = true;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].selected = true;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].selected = true;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].selected = true;
-        if( layout == LayoutType.COMBINED )
-        	combined.selected = true;
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].selected = true;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].selected = true;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].selected = true;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].selected = true;
+        if (layout == LayoutType.COMBINED)
+            combined.selected = true;
     }
-    
+
     @Override
-    public void unselectGraph()
-    {
-        for( LayeredGraphNode n : nodes)
-        {
+    public void unselectGraph() {
+        for (LayeredGraphNode n : nodes) {
             n.unselectGraph();
         }
-        this.layouts[ 0 ].selected = false;
-        this.layouts[ 1 ].selected = false;
-        this.layouts[ 2 ].selected = false;
-        this.layouts[ 3 ].selected = false;
+        this.layouts[0].selected = false;
+        this.layouts[1].selected = false;
+        this.layouts[2].selected = false;
+        this.layouts[3].selected = false;
         combined.selected = false;
     }
 
     @Override
-    public boolean isSelected( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-        {
-            boolean tmp = layouts[ 0 ].selected;
-            layouts[ 0 ].selected = false;
-            return tmp;
+    public boolean isSelected(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT) {
+            return layouts[0].selected;
         }
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-        {
-            boolean tmp = layouts[ 1 ].selected;
-            layouts[ 1 ].selected = false;
-            return tmp;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT) {
+            return layouts[1].selected;
         }
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-        {
-            boolean tmp = layouts[ 2 ].selected;
-            layouts[ 2 ].selected = false;
-            return tmp;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT) {
+            return layouts[2].selected;
         }
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-        {
-            boolean tmp = layouts[ 3 ].selected;
-            layouts[ 3 ].selected = false;
-            return tmp;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT) {
+            return layouts[3].selected;
         }
-        if( layout == LayoutType.COMBINED )
-        {
-            boolean tmp = combined.selected;
-            combined.selected = false;
-            return tmp;
+        if (layout == LayoutType.COMBINED) {
+            return combined.selected;
         }
         return false;
     }
-    
+
     @Override
-    public void setColor( Color c, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].color = c;
-            this.layouts[ 1 ].color = c;
-            this.layouts[ 2 ].color = c;
-            this.layouts[ 3 ].color = c;
+    public void setColor(Color c, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].color = c;
+            this.layouts[1].color = c;
+            this.layouts[2].color = c;
+            this.layouts[3].color = c;
             combined.color = c;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].color = c;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].color = c;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].color = c;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].color = c;
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].color = c;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].color = c;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].color = c;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].color = c;
+        if (layout == LayoutType.COMBINED)
             combined.color = c;
     }
-    
-    private int calcClassSize( LayeredGraphNode sink, LayoutType layout )
-    {
-        if( parent == null )
+
+    private int calcClassSize(LayeredGraphNode sink, LayoutType layout) {
+        if (parent == null)
             return 1;
         int ret = 0;
-        for( LayeredGraphNode n : parent.getContainedNodes() )
-        {
-            if( n.getRoot( layout ).getSink( layout ) == sink )
+        for (LayeredGraphNode n : parent.getContainedNodes()) {
+            if (n.getRoot(layout).getSink(layout) == sink)
                 ret++;
         }
         return ret;
     }
-    
+
     @Override
-    public Color getClassColor( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[ 0 ].sink == this && calcClassSize( this, layout ) == 1 )
+    public Color getClassColor(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[ 0 ].sink == this )
-            return this.layouts[ 0 ].color;
-        else if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].sink.getClassColor( layout );
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[ 1 ].sink == this && calcClassSize( this, layout ) == 1 )
+        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].sink == this)
+            return this.layouts[0].color;
+        else if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].sink.getClassColor(layout);
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[ 1 ].sink == this )
-            return this.layouts[ 1 ].color;
-        else if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].sink.getClassColor( layout );
-        if( layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[ 2 ].sink == this && calcClassSize( this, layout ) == 1 )
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].sink == this)
+            return this.layouts[1].color;
+        else if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].sink.getClassColor(layout);
+        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[ 2 ].sink == this )
-            return this.layouts[ 2 ].color;
-        else if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].sink.getClassColor( layout );
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[ 3 ].sink == this && calcClassSize( this, layout ) == 1 )
+        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].sink == this)
+            return this.layouts[2].color;
+        else if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].sink.getClassColor(layout);
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[3].sink == this && calcClassSize(this, layout) == 1)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[ 3 ].sink == this )
-            return this.layouts[ 3 ].color;
-        else if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].sink.getClassColor( layout );
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[3].sink == this)
+            return this.layouts[3].color;
+        else if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].sink.getClassColor(layout);
+        if (layout == LayoutType.COMBINED)
             return combined.color;
         return null;
     }
-    
+
     @Override
-    public Color getColor( LayoutType layout )
-    {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[ 0 ].root == this && this.layouts[ 0 ].align == this )
+    public Color getColor(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].root == this && this.layouts[0].align == this)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[ 0 ].root != this )
-            return this.layouts[ 0 ].root.getColor( layout );
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].color;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[ 1 ].root == this && this.layouts[ 1 ].align == this )
+        if (layout == LayoutType.TOP_BOTTOM_LEFT && this.layouts[0].root != this)
+            return this.layouts[0].root.getColor(layout);
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].color;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].root == this && this.layouts[1].align == this)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[ 1 ].root != this )
-            return this.layouts[ 1 ].root.getColor( layout );
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].color;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[ 2 ].root == this && this.layouts[ 2 ].align == this )
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT && this.layouts[1].root != this)
+            return this.layouts[1].root.getColor(layout);
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].color;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].root == this && this.layouts[2].align == this)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[ 2 ].root != this )
-            return this.layouts[ 2 ].root.getColor( layout );
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].color;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[ 3 ].root == this && this.layouts[ 3 ].align == this )
+        if (layout == LayoutType.BOTTOM_TOP_LEFT && this.layouts[2].root != this)
+            return this.layouts[2].root.getColor(layout);
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].color;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[3].root == this && this.layouts[3].align == this)
             return Color.LIGHT_GRAY;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[ 3 ].root != this )
-            return this.layouts[ 3 ].root.getColor( layout );
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].color;
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT && this.layouts[3].root != this)
+            return this.layouts[3].root.getColor(layout);
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].color;
+        if (layout == LayoutType.COMBINED)
             return combined.color;
         return null;
     }
-    
+
     @Override
-    public void setName( String n ) {
-    	name = n;
+    public void setName(String n) {
+        name = n;
     }
-    
+
     @Override
-    public String getName()
-    {
-    	return name;
+    public String getName() {
+        return name;
     }
-    
+
     @Override
     public ElkNode getOriginalNode() {
         return original;
@@ -514,7 +465,7 @@ public class LayeredNode implements LayeredGraphNode {
 
     @Override
     public void remove() {
-        parent.removeNode( this );
+        parent.removeNode(this);
     }
 
     @Override
@@ -524,285 +475,267 @@ public class LayeredNode implements LayeredGraphNode {
 
     @Override
     public void setLayer(int index) {
-        parent.setNodeLayer( this, index );
+        parent.setNodeLayer(this, index);
     }
 
     @Override
     public int getLayer() {
-        return parent.getNodeLayer( this );
+        return parent.getNodeLayer(this);
     }
 
     @Override
-    public void setX(double x, boolean def, LayoutType layout ) {
-        if( layout == null )
-        {
-            layouts[ 0 ].x = x;
-            layouts[ 1 ].x = x;
-            layouts[ 2 ].x = x;
-            layouts[ 3 ].x = x;
+    public void setX(double x, boolean def, LayoutType layout) {
+        if (layout == null) {
+            layouts[0].x = x;
+            layouts[1].x = x;
+            layouts[2].x = x;
+            layouts[3].x = x;
             combined.x = x;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-        {
-            layouts[ 0 ].xUndef = !def;
-            layouts[ 0 ].x = x;
+        if (layout == LayoutType.TOP_BOTTOM_LEFT) {
+            layouts[0].xUndef = !def;
+            layouts[0].x = x;
         }
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-        {
-            layouts[ 1 ].xUndef = !def;
-            layouts[ 1 ].x = x;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT) {
+            layouts[1].xUndef = !def;
+            layouts[1].x = x;
         }
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-        {
-            layouts[ 2 ].xUndef = !def;
-            layouts[ 2 ].x = x;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT) {
+            layouts[2].xUndef = !def;
+            layouts[2].x = x;
         }
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-        {
-            layouts[ 3 ].xUndef = !def;
-            layouts[ 3 ].x = x;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT) {
+            layouts[3].xUndef = !def;
+            layouts[3].x = x;
         }
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.COMBINED)
             combined.x = x;
     }
 
     @Override
-    public void setY(double y, LayoutType layout ) {
-        if( layout == null )
-        {
-            layouts[ 0 ].y = y;
-            layouts[ 1 ].y = y;
-            layouts[ 2 ].y = y;
-            layouts[ 3 ].y = y;
+    public void setY(double y, LayoutType layout) {
+        if (layout == null) {
+            layouts[0].y = y;
+            layouts[1].y = y;
+            layouts[2].y = y;
+            layouts[3].y = y;
             combined.y = y;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            layouts[ 0 ].y = y;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            layouts[ 1 ].y = y;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            layouts[ 2 ].y = y;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            layouts[ 3 ].y = y;
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            layouts[0].y = y;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            layouts[1].y = y;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            layouts[2].y = y;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            layouts[3].y = y;
+        if (layout == LayoutType.COMBINED)
             combined.y = y;
     }
 
     @Override
-    public double getX( LayoutType layout ) {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].x;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].x;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].x;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].x;
-        if( layout == LayoutType.COMBINED )
+    public double getX(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].x;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].x;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].x;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].x;
+        if (layout == LayoutType.COMBINED)
             return combined.x;
         return 0;
     }
 
     @Override
-    public double getY( LayoutType layout ) {
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return this.layouts[ 0 ].y;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return this.layouts[ 1 ].y;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return this.layouts[ 2 ].y;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return this.layouts[ 3 ].y;
-        if( layout == LayoutType.COMBINED )
+    public double getY(LayoutType layout) {
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return this.layouts[0].y;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return this.layouts[1].y;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return this.layouts[2].y;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return this.layouts[3].y;
+        if (layout == LayoutType.COMBINED)
             return combined.y;
         return 0;
     }
 
     @Override
-    public double getWidth( LayoutType layout ) {
-        if( nodes.size() > 0 )
-        {
+    public double getWidth(LayoutType layout) {
+        if (nodes.size() > 0) {
             double max = 0;
             double min = Double.POSITIVE_INFINITY;
-            for( LayeredGraphNode n : nodes )
-            {
-                if( max < n.getX(layout) + n.getWidth(layout) + 50 )
+            for (LayeredGraphNode n : nodes) {
+                if (max < n.getX(layout) + n.getWidth(layout) + 50)
                     max = n.getX(layout) + n.getWidth(layout) + 50;
-                min = Math.min( n.getX(layout), min);
+                min = Math.min(n.getX(layout), min);
             }
-            if( layout == LayoutType.TOP_BOTTOM_LEFT )
-                return Math.max( max - min, layouts[ 0 ].w );
-            if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-                return Math.max( max - min, layouts[ 1 ].w );
-            if( layout == LayoutType.BOTTOM_TOP_LEFT )
-                return Math.max( max - min, layouts[ 2 ].w );
-            if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-                return Math.max( max - min, layouts[ 3 ].w );
-            if( layout == LayoutType.COMBINED )
-                return Math.max( max - min, combined.w );
-        }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return layouts[ 0 ].w;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return layouts[ 1 ].w;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return layouts[ 2 ].w;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return layouts[ 3 ].w;
-        if( layout == LayoutType.COMBINED )
+            if (layout == LayoutType.TOP_BOTTOM_LEFT)
+                return Math.max(max - min, layouts[0].w);
+            if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+                return Math.max(max - min, layouts[1].w);
+            if (layout == LayoutType.BOTTOM_TOP_LEFT)
+                return Math.max(max - min, layouts[2].w);
+            if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+                return Math.max(max - min, layouts[3].w);
+            if (layout == LayoutType.COMBINED)
+                return Math.max(max - min, combined.w);
+        }
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return layouts[0].w;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return layouts[1].w;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return layouts[2].w;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return layouts[3].w;
+        if (layout == LayoutType.COMBINED)
             return combined.w;
         return 0;
     }
 
     @Override
-    public double getHeight( LayoutType layout ) {
-        if( nodes.size() > 0 )
-        {
-        	double max = 0;
-        	for( LayeredGraphNode n : nodes )
-        	{
-        		if( max < n.getY(layout) + n.getHeight(layout) + 50 )
-        			max = n.getY(layout) + n.getHeight(layout) + 50;
-        	}
-            if( layout == LayoutType.TOP_BOTTOM_LEFT )
-                return Math.max( max, layouts[ 0 ].h );
-            if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-                return Math.max( max, layouts[ 1 ].h );
-            if( layout == LayoutType.BOTTOM_TOP_LEFT )
-                return Math.max( max, layouts[ 2 ].h );
-            if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-                return Math.max( max, layouts[ 3 ].h );
-            if( layout == LayoutType.COMBINED )
-                return Math.max( max, combined.h );
-        }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            return layouts[ 0 ].h;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            return layouts[ 1 ].h;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            return layouts[ 2 ].h;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            return layouts[ 3 ].h;
-        if( layout == LayoutType.COMBINED )
+    public double getHeight(LayoutType layout) {
+        if (nodes.size() > 0) {
+            double max = 0;
+            for (LayeredGraphNode n : nodes) {
+                if (max < n.getY(layout) + n.getHeight(layout) + 50)
+                    max = n.getY(layout) + n.getHeight(layout) + 50;
+            }
+            if (layout == LayoutType.TOP_BOTTOM_LEFT)
+                return Math.max(max, layouts[0].h);
+            if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+                return Math.max(max, layouts[1].h);
+            if (layout == LayoutType.BOTTOM_TOP_LEFT)
+                return Math.max(max, layouts[2].h);
+            if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+                return Math.max(max, layouts[3].h);
+            if (layout == LayoutType.COMBINED)
+                return Math.max(max, combined.h);
+        }
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            return layouts[0].h;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            return layouts[1].h;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            return layouts[2].h;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            return layouts[3].h;
+        if (layout == LayoutType.COMBINED)
             return combined.h;
         return 0;
     }
-    
+
     @Override
-    public void setWidth( double w, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].w = w;
-            this.layouts[ 1 ].w = w;
-            this.layouts[ 2 ].w = w;
-            this.layouts[ 3 ].w = w;
+    public void setWidth(double w, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].w = w;
+            this.layouts[1].w = w;
+            this.layouts[2].w = w;
+            this.layouts[3].w = w;
             combined.w = w;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].w = w;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].w = w;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].w = w;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].w = w;
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].w = w;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].w = w;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].w = w;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].w = w;
+        if (layout == LayoutType.COMBINED)
             combined.w = w;
     }
-    
+
     @Override
-    public void setHeight( double h, LayoutType layout )
-    {
-        if( layout == null )
-        {
-            this.layouts[ 0 ].h = h;
-            this.layouts[ 1 ].h = h;
-            this.layouts[ 2 ].h = h;
-            this.layouts[ 3 ].h = h;
+    public void setHeight(double h, LayoutType layout) {
+        if (layout == null) {
+            this.layouts[0].h = h;
+            this.layouts[1].h = h;
+            this.layouts[2].h = h;
+            this.layouts[3].h = h;
             combined.h = h;
         }
-        if( layout == LayoutType.TOP_BOTTOM_LEFT )
-            this.layouts[ 0 ].h = h;
-        if( layout == LayoutType.TOP_BOTTOM_RIGHT )
-            this.layouts[ 1 ].h = h;
-        if( layout == LayoutType.BOTTOM_TOP_LEFT )
-            this.layouts[ 2 ].h = h;
-        if( layout == LayoutType.BOTTOM_TOP_RIGHT )
-            this.layouts[ 3 ].h = h;
-        if( layout == LayoutType.COMBINED )
+        if (layout == LayoutType.TOP_BOTTOM_LEFT)
+            this.layouts[0].h = h;
+        if (layout == LayoutType.TOP_BOTTOM_RIGHT)
+            this.layouts[1].h = h;
+        if (layout == LayoutType.BOTTOM_TOP_LEFT)
+            this.layouts[2].h = h;
+        if (layout == LayoutType.BOTTOM_TOP_RIGHT)
+            this.layouts[3].h = h;
+        if (layout == LayoutType.COMBINED)
             combined.h = h;
     }
 
     @Override
     public void removeEdge(LayeredGraphEdge e) {
-        edges.remove( e );
+        edges.remove(e);
     }
 
     @Override
     public void removeNode(LayeredGraphNode n) {
-        for( LayeredGraphEdge e : n.getIncomingEdges() )
+        for (LayeredGraphEdge e : n.getIncomingEdges())
             e.remove();
-        for( LayeredGraphEdge e : n.getOutgoingEdges() )
+        for (LayeredGraphEdge e : n.getOutgoingEdges())
             e.remove();
-        nodes.remove( n );
-        for( ArrayList<LayeredGraphNode> l : layers )
-        {
-            l.remove( n );
+        nodes.remove(n);
+        for (ArrayList<LayeredGraphNode> l : layers) {
+            l.remove(n);
         }
     }
 
     @Override
     public void setNodeLayer(LayeredGraphNode n, int index) {
-        while( index >= layers.size() )
-            layers.add( new ArrayList<>() );
+        while (index >= layers.size())
+            layers.add(new ArrayList<>());
         int old = n.getLayer();
-        if( old >= 0 )
-            layers.get( old ).remove( n );
-        layers.get( index ).add( n );
+        if (old >= 0)
+            layers.get(old).remove(n);
+        layers.get(index).add(n);
     }
 
     @Override
     public void setOrderedLayer(ArrayList<Double> indizes, int layerIndex) {
-        ArrayList<LayeredGraphNode> l2 = layers.get( layerIndex );
+        ArrayList<LayeredGraphNode> l2 = layers.get(layerIndex);
         ArrayList<LayeredGraphNode> result = new ArrayList<LayeredGraphNode>();
-        while( indizes.size() > 0 )
-        {
+        while (indizes.size() > 0) {
             int mIndex = 0;
-            double min = indizes.get( 0 );
-            for( int i = 1; i < indizes.size(); i++ )
-            {
-                if( min > indizes.get( i ) )
-                {
+            double min = indizes.get(0);
+            for (int i = 1; i < indizes.size(); i++) {
+                if (min > indizes.get(i)) {
                     mIndex = i;
-                    min = indizes.get( i );
+                    min = indizes.get(i);
                 }
             }
-            result.add( l2.get( mIndex ) );
-            l2.remove( mIndex );
-            indizes.remove( mIndex );
+            result.add(l2.get(mIndex));
+            l2.remove(mIndex);
+            indizes.remove(mIndex);
         }
-        layers.set( layerIndex, result );
+        layers.set(layerIndex, result);
     }
-    
+
     @Override
     public ArrayList<LayeredGraphEdge> getOutgoingEdges() {
-        return parent.getOutgoingEdges( this );
+        return parent.getOutgoingEdges(this);
     }
-    
+
     @Override
     public ArrayList<LayeredGraphEdge> getSortedOutgoingEdges() {
-        return parent.getSortedOutgoingEdges( this );
+        return parent.getSortedOutgoingEdges(this);
     }
 
     @Override
     public ArrayList<LayeredGraphEdge> getIncomingEdges() {
-        return parent.getIncomingEdges( this );
+        return parent.getIncomingEdges(this);
     }
 
     @Override
     public ArrayList<LayeredGraphEdge> getSortedIncomingEdges() {
-        return parent.getSortedIncomingEdges( this );
+        return parent.getSortedIncomingEdges(this);
     }
 
     @Override
@@ -814,14 +747,12 @@ public class LayeredNode implements LayeredGraphNode {
     public ArrayList<LayeredGraphNode> getContainedNodes() {
         return nodes;
     }
-    
+
     @Override
-    public ArrayList< LayeredGraphNode > getSortedContainedNodes()
-    {
-        ArrayList< LayeredGraphNode > result = new ArrayList<>();
-        for( ArrayList<LayeredGraphNode> l : layers )
-        {
-            result.addAll( l );
+    public ArrayList<LayeredGraphNode> getSortedContainedNodes() {
+        ArrayList<LayeredGraphNode> result = new ArrayList<>();
+        for (ArrayList<LayeredGraphNode> l : layers) {
+            result.addAll(l);
         }
         return result;
     }
@@ -833,9 +764,8 @@ public class LayeredNode implements LayeredGraphNode {
 
     @Override
     public int getNodeLayer(LayeredGraphNode n) {
-        for( int i = 0; i < layers.size(); i++ )
-        {
-            if( layers.get( i ).contains( n ) )
+        for (int i = 0; i < layers.size(); i++) {
+            if (layers.get(i).contains(n))
                 return i;
         }
         return -1;
@@ -896,7 +826,7 @@ public class LayeredNode implements LayeredGraphNode {
         }
         return result;
     }
-    
+
     @Override
     public LayeredGraphEdge findEdgeBetween( LayeredGraphNode source, LayeredGraphNode target )
     {
@@ -910,15 +840,16 @@ public class LayeredNode implements LayeredGraphNode {
 
     @Override
     public LayeredGraphNode createNode(ElkNode original) {
-        LayeredGraphNode n = new LayeredNode( original, this );
-        nodes.add( n );
+        LayeredGraphNode n = new LayeredNode(original, this);
+        nodes.add(n);
         return n;
     }
 
     @Override
-    public LayeredGraphEdge createEdge(ElkEdge original, ArrayList<LayeredGraphNode> sources, ArrayList<LayeredGraphNode> targets) {
-        LayeredGraphEdge e = new LayeredEdge( original, sources, targets, this );
-        edges.add( e );
+    public LayeredGraphEdge createEdge(ElkEdge original, ArrayList<LayeredGraphNode> sources,
+            ArrayList<LayeredGraphNode> targets) {
+        LayeredGraphEdge e = new LayeredEdge(original, sources, targets, this);
+        edges.add(e);
         return e;
     }
 
@@ -926,18 +857,17 @@ public class LayeredNode implements LayeredGraphNode {
     public LayeredGraphEdge createSimpleEdge(ElkEdge original, LayeredGraphNode source, LayeredGraphNode target) {
         ArrayList<LayeredGraphNode> sources = new ArrayList<>();
         ArrayList<LayeredGraphNode> targets = new ArrayList<>();
-        sources.add( source );
-        targets.add( target );
-        LayeredGraphEdge e = new LayeredEdge( original, sources, targets, this );
-        edges.add( e );
+        sources.add(source);
+        targets.add(target);
+        LayeredGraphEdge e = new LayeredEdge(original, sources, targets, this);
+        edges.add(e);
         return e;
     }
-    
+
     @Override
     public LayeredGraphEdge findEdgeFromOriginal(Object original) {
-        for( LayeredGraphEdge e : edges )
-        {
-            if( e.getOriginalEdge() == original )
+        for (LayeredGraphEdge e : edges) {
+            if (e.getOriginalEdge() == original)
                 return e;
         }
         return null;
@@ -945,42 +875,39 @@ public class LayeredNode implements LayeredGraphNode {
 
     @Override
     public LayeredGraphNode findNodeFromOriginal(Object original) {
-        for( LayeredGraphNode n : nodes )
-        {
-            if( n.getOriginalNode() == original )
+        for (LayeredGraphNode n : nodes) {
+            if (n.getOriginalNode() == original)
                 return n;
         }
         return null;
     }
-    
+
     @Override
-    public LayeredGraphNode findNodeByName( String name )
-    {
-    	for( LayeredGraphNode n : nodes )
-        {
-            if( n.getName() != null && name != null && n.getName().equals( name ) )
+    public LayeredGraphNode findNodeByName(String name) {
+        for (LayeredGraphNode n : nodes) {
+            if (n.getName() != null && name != null && n.getName().equals(name))
                 return n;
         }
-        return null;	
+        return null;
     }
 
     @Override
     public void addNode(LayeredGraphNode n) {
-        nodes.add( n );
-        n.setParent( this );
+        nodes.add(n);
+        n.setParent(this);
     }
 
     @Override
     public void addEdge(LayeredGraphEdge e) {
-        edges.add( e );
-        e.setGraph( this );
+        edges.add(e);
+        e.setGraph(this);
     }
 
     @Override
     public void setParent(LayeredGraphNode parent) {
         this.parent = parent;
     }
-    
+
     @Override
     public String toString() {
         if( name != null )

+ 1 - 1
src/lib/TextLayoutHelper.java

@@ -62,7 +62,7 @@ public class TextLayoutHelper {
         ret += current + "</html>";
         return ret;
     }
-    
+
     public static String[] getVariables( String s )
     {
         ArrayList<String> list = new ArrayList<>();

+ 6 - 1
src/view/MainView.java

@@ -143,7 +143,12 @@ public class MainView {
         debugFrame.add( view );
         debugFrame.setSize( frame.getWidth(), frame.getHeight() );
         debugFrame.setVisible( true );
-        System.out.println( infoS );
+        if (infoS.trim().equals("")) {
+            System.out.println( "" );
+            System.out.println( "Debug info:" );
+            System.out.println( infoS );
+            System.out.println( "" );
+        }
     }
 
     public MainView( ElkNode graph )

+ 13 - 7
src/view/NodeView.java

@@ -45,18 +45,22 @@ public class NodeView extends JPanel {
     
     public int getScaledX( int x )
     {
-        double scale = Math.min( (double)super.getWidth() / (int)model.getWidth( layout ), (double)super.getHeight() / (int)model.getHeight( layout ));
+        double width_scale = super.getWidth() / model.getWidth( layout );
+        double height_scale = super.getHeight() / model.getHeight( layout );
+        double scale = Math.min( width_scale, height_scale);
         x *= scale;
-        if( scale == (double)super.getHeight() / (int)model.getHeight( layout ) )
+        if( scale < width_scale )
             x += (super.getWidth() - (model.getWidth( layout ) * scale )) / 2;
         return x;
     }
     
     public int getScaledY( int y )
     {
-        double scale = Math.min( (double)super.getWidth() / (int)model.getWidth( layout ), (double)super.getHeight() / (int)model.getHeight( layout ));
+        double width_scale = super.getWidth() / model.getWidth( layout );
+        double height_scale = super.getHeight() / model.getHeight( layout );
+        double scale = Math.min( width_scale, height_scale);
         y *= scale;
-        if( scale == (double)super.getWidth() / (int)model.getWidth( layout ) )
+        if( scale < height_scale )
             y += (super.getHeight() - (model.getHeight( layout ) * scale )) / 2;
         return y;
     }
@@ -105,15 +109,17 @@ public class NodeView extends JPanel {
     {
         if( layout == LayoutType.COMBINED && model.getColor( layout ) == null )
             return;
-        double scale = Math.min( (double)super.getWidth() / (int)model.getWidth( layout ), (double)super.getHeight() / (int)model.getHeight( layout ));
+        double width_scale = super.getWidth() / model.getWidth( layout );
+        double height_scale = super.getHeight() / model.getHeight( layout );
+        double scale = Math.min( width_scale, height_scale);
         ((Graphics2D)g).scale( scale, scale );
         int x = 0;
         int y = 0;
         int width = (int)(super.getWidth() / scale);
         int height = (int)(super.getHeight() / scale);
-        if( scale == (double)super.getWidth() / (int)model.getWidth( layout ) )
+        if( scale < height_scale )
         	y += (super.getHeight() - (model.getHeight( layout ) * scale )) / scale / 2;
-        if( scale == (double)super.getHeight() / (int)model.getHeight( layout ) )
+        if( scale < width_scale )
         	x += (super.getWidth() - (model.getWidth( layout ) * scale )) / scale / 2;
         if( model.isDummyNode() )
         {