Eren Yilmaz vor 6 Jahren
Ursprung
Commit
c27c5a70a6

+ 12 - 0
src/animation/PseudoCodeNode.java

@@ -46,16 +46,28 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         super.add( node );
     }
     
+    /**
+     * 
+     * @return the tree that this node belongs to
+     */
     public JTree getTree()
     {
         return tree;
     }
     
+    /**
+     * checks if this node should be highlighted
+     * @return true if it should, false otherwise
+     */
     public boolean isSelected()
     {
         return selected;
     }
     
+    /**
+     * checks if one of the subnodes of this node is selected.
+     * @return true if one is, false otherwise
+     */
     public boolean hasSelectedSubnode()
     {
     	if( children != null )

+ 6 - 2
src/bk/ExtremalLayoutCalc.java

@@ -15,7 +15,12 @@ import lib.TextLayoutHelper;
  *
  */
 public class ExtremalLayoutCalc implements AlgorithmStage {
-
+    /**
+     * There are four types of layouts, based on iteration order and median alignment.
+     * Additionally there is one layout for the combined coordinates.
+     * @author kolja
+     *
+     */
     public enum LayoutType{
         TOP_BOTTOM_LEFT,
         TOP_BOTTOM_RIGHT,
@@ -40,7 +45,6 @@ public class ExtremalLayoutCalc implements AlgorithmStage {
     private boolean inside;
     private LayeredGraphNode graph;
 
-
     public ExtremalLayoutCalc( LayoutType typ, LayeredGraphNode graph )
     {
         this.graph = graph;

+ 5 - 0
src/graph/LayeredGraphNode.java

@@ -423,6 +423,11 @@ public interface LayeredGraphNode {
    */
   public LayeredGraphNode findNodeFromOriginal(Object original);
 
+  /**
+   * Find a node with a given name whose parent node is this node.
+   * @param name the name to search for
+   * @return the node or {@code null} if no node was found.
+   */
   public LayeredGraphNode findNodeByName(String name);
 
   /**

+ 7 - 0
src/graph/RandomGraphGenerator.java

@@ -90,6 +90,13 @@ public class RandomGraphGenerator {
         return node;
     }
     
+    /**
+     * Checks if the graph is valid regarding our assumptions.
+     * Currently this only means checking if it is connected.
+     * Does not recurse to subgraphs.
+     * @param graph the graph to validate
+     * @return true if it is valid
+     */
     public static boolean validate( LayeredGraphNode graph )
     {
         if( graph.getContainedNodes().size() == 0 )

+ 12 - 4
src/lib/TextLayoutHelper.java

@@ -1,14 +1,22 @@
 package lib;
 
 public class TextLayoutHelper {
-    public static String strToLen( String s, int l )
+    /**
+     * Modifies the given string such that its lenght matches the given length.
+     * If the string is too small, whitespace is appended on both sides equally.
+     * Then, if the string is too large, it is cut off on the right.
+     * @param s the string
+     * @param lenght the target length
+     * @return the modified string
+     */
+    public static String strToLen( String s, int lenght )
     {
-        while( s.length() < l )
+        while( s.length() < lenght )
         {
             s = " " + s + " ";
         }
-        if( s.length() > l )
-            return s.substring( 0, l );
+        if( s.length() > lenght )
+            return s.substring( 0, lenght );
         return s;
     }
 }

+ 5 - 0
src/view/MainView.java

@@ -149,6 +149,11 @@ public class MainView {
 
     /**
      * Initialize the window and its contents.
+     * There is good reason not to split up this method to smaller methods:
+     * Imagine a tree with a fixed number of nodes, but limited degree of branching.
+     * The the height of the tree is at least inversely proportional to the degree of branching.
+     * This means halving the maximum method size by splitting methods would make the call stack twice as high
+     * and this way debugging twice as time-consuming.
      * @param graph the graph that is displayed in this window.
      */
     public MainView( LayeredGraphNode graph )