Quellcode durchsuchen

Merge branch 'master' of https://koljastrohm-games.com:3000/GraphDrawer/NodePlacementAnimation

Kolja Strohm vor 6 Jahren
Ursprung
Commit
0558874bab

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

@@ -5,6 +5,7 @@ The following assumptions are made for the implementation of the node placement
     \item There are no port constraints.
     \item There are no labels.
     \item There are no cross-hierarchy edges.
+    \item No edges over multiple layers (the previous phases should have added dummy nodes).
 \end{itemize}
 
 \section{Input File Format}\label{sec:inputFileFormat}

+ 12 - 12
doc/chapter/3progress.tex

@@ -1,14 +1,14 @@
-The following features are either \planned{planned}, \inprogress{under construction} or \done{done}:
+The following features are either planned (\planned), under construction (\progress) or done (\done):
 \begin{itemize}
-    \item \done{Reading from an input file as described in section~\ref{sec:inputFileFormat}.}
-    \item \done{Drawing a graph with specified node sizes and positions.}
-    \item \inprogress{Running the node placement algorithm by Brandes and Köpf~\cite{brandes_fast_2001}.}
-    \item \done{Illustrating the progress while the algorithm is running.}
-    \item \done{Running the algorithm step by step manually (by pushing a button labeled \enquote{Step}).}
-    \item \inprogress{Running the algorithm step by step with configurable delay.}
-    \item \planned{Using debugger-like commands such as \enquote{step into}, \enquote{step over}, \enquote{step out}.}
-    \item \done{Working with hierarchical graphs.}
-    \item \done{Scaling the display with the (adjustable) window size.}
-    \item \planned{Creating ElkNode~\cite{noauthor_elk:_2018} objects from LayeredNode (\ref{sec:internalGraphRepresentation}) objects}
-    \item \planned{Creating LayeredNode (\ref{sec:internalGraphRepresentation}) objects from ElkNode~\cite{noauthor_elk:_2018} objects (low priority)}
+    \item[\done] Reading from an input file as described in section~\ref{sec:inputFileFormat}.
+    \item[\done] Drawing a graph with specified node sizes and positions.
+    \item[\progress] Running the node placement algorithm by Brandes and Köpf~\cite{brandes_fast_2001}.
+    \item[\done] Illustrating the progress while the algorithm is running.
+    \item[\done] Running the algorithm step by step manually (by pushing a button labeled \enquote{Step}).
+    \item[\progress] Running the algorithm step by step with configurable delay.
+    \item[\planned] Using debugger-like commands such as \enquote{step into}, \enquote{step over}, \enquote{step out}.
+    \item[\done] Working with hierarchical graphs.
+    \item[\done] Scaling the display with the (adjustable) window size.
+    \item[\planned] Creating ElkNode~\cite{noauthor_elk:_2018} objects from LayeredNode (\ref{sec:internalGraphRepresentation}) objects
+    \item[\planned] Creating LayeredNode (\ref{sec:internalGraphRepresentation}) objects from ElkNode~\cite{noauthor_elk:_2018} objects (low priority)
 \end{itemize}

+ 19 - 4
doc/doc.tex

@@ -6,7 +6,7 @@
 \pdfsuppresswarningpagegroup=1
 % Allgemeines
 \usepackage[automark]{scrlayer-scrpage} % Kopf- und Fußzeilen
-\usepackage{amsmath,marvosym} % Mathesachen
+\usepackage{amsmath,marvosym,amssymb} % Mathesachen
 \usepackage[T1]{fontenc} % Ligaturen, richtige Umlaute im PDF
 \usepackage[utf8]{inputenc}% UTF8-Kodierung für Umlaute usw
 % Schriften
@@ -57,6 +57,22 @@
 \setlength{\abovecaptionskip}{0.2cm} % Abstand der zwischen Bild- und Bildunterschrift
 \usepackage{enumitem} % Referenzen auf Item in enumerate-Blocks
 
+% A checklist for the current progress
+\usepackage{pifont}
+\usepackage{tikz}
+\usetikzlibrary{shapes.geometric}
+\newcommand{\cmark}{\ding{51}}%
+\newcommand{\xmark}{\ding{55}}%
+\newcommand\partialsquare{%
+\begin{tikzpicture}[baseline=0]
+\draw (0,0)  rectangle (0.3,0.3);
+\fill (0.05,0.05)  rectangle (0.25,0.25);
+\end{tikzpicture}%
+}
+\newcommand{\planned}{$\square$}
+\newcommand{\done}{\rlap{$\square$}{\raisebox{2pt}{\large\hspace{1pt}\cmark}}\hspace{-2.5pt}}
+\newcommand{\progress}{\partialsquare}
+
 % \toprule and other commands
 \usepackage{booktabs}
 
@@ -83,9 +99,6 @@
 \definecolor{deepred}{rgb}{0.8,0,0}
 \definecolor{deepgreen}{rgb}{0,0.4,0}
 \definecolor{grau}{gray}{0.3}
-\newcommand{\planned}[1]{\textcolor{deepred}{#1}}
-\newcommand{\done}[1]{\textcolor{deepgreen}{#1}}
-\newcommand{\inprogress}[1]{\textcolor{deepblue}{#1}}
 % python style code
 \lstset{
 extendedchars=true,
@@ -235,6 +248,8 @@ frame=tb}
     \chapter{Current Progress}\label{ch:progress}
     \input{chapter/3progress}
 
+    \TODO{UI and visuals chapter}
+
     \chapter{Retrospection}
     \input{chapter/4retrospection}
 

+ 4 - 1
src/Algorithms/InitializeNodePositions.java

@@ -12,7 +12,10 @@ import Model.LayeredGraphNode;
  *
  */
 public class InitializeNodePositions {
-
+    /**
+     * the actual algorithm
+     * @param graph the graph where the node positions are to be set.
+     */
     public static void placeNodes( LayeredGraphNode graph ) {
         
     	RandomColorGenerator cGen = new RandomColorGenerator();

+ 10 - 1
src/Algorithms/RandomColorGenerator.java

@@ -3,15 +3,24 @@ package Algorithms;
 import java.awt.Color;
 import java.util.Random;
 
+/**
+ * generates random colors
+ * @author kolja
+ *
+ */
 public class RandomColorGenerator {
 
-	Random rand;
+	private Random rand;
 	
 	public RandomColorGenerator()
 	{
 		rand = new Random();
 	}
 	
+	/**
+	 * generate a color with random RGB values
+	 * @return the color
+	 */
 	public Color generateColor()
 	{
 		float r = rand.nextFloat();

+ 21 - 0
src/Algorithms/RandomGraphGenerator.java

@@ -3,6 +3,11 @@ package Algorithms;
 import Model.LayeredGraphNode;
 import Model.LayeredNode;
 
+/**
+ * creates random {@link LayeredGraphNode}s for testing purposes
+ * @author kolja
+ *
+ */
 public class RandomGraphGenerator {
 
     private double pSubgraph;
@@ -13,6 +18,16 @@ public class RandomGraphGenerator {
     private int maxNodePerLayer;
     private int maxDepth;
     
+    /**
+     * sets the parameters for the random graph
+     * @param pSubgraph the probability that a node contains a graph
+     * @param pEdge the probability that there is an edge between two nodes in subsequent layers
+     * @param minLayer the minimum number of layers in each graph
+     * @param maxLayer the maximum number of layers in each graph
+     * @param minNodePerLayer the minimum number of layers in each layer
+     * @param maxNodePerLayer the maximum number of layers in each layer
+     * @param maxDepth the maximum hierarchy depth
+     */
     public RandomGraphGenerator( double pSubgraph, double pEdge, int minLayer, int maxLayer, int minNodePerLayer, int maxNodePerLayer, int maxDepth )
     {
         this.pSubgraph = pSubgraph;
@@ -24,6 +39,12 @@ public class RandomGraphGenerator {
         this.maxDepth = maxDepth;
     }
     
+    /**
+     * creates a random {@link LayeredGraphNode} using the parameters given to the constructor of the {@link RandomGraphGenerator}
+     * @param parent the parent node of the nodes in the graph
+     * @param depth the current depth of the graph (used to check if the maximum depth is reached)
+     * @return the generated {@link LayeredGraphNode}
+     */
     public LayeredGraphNode createRandomNode( LayeredGraphNode parent, int depth )
     {
         LayeredGraphNode node = new LayeredNode( null, null );

+ 7 - 7
src/Algorithms/SweepCrossingMinimizer.java

@@ -7,8 +7,8 @@ import Model.LayeredGraphNode;
 
 
 /**
- * Der aus der Vorlesung bekannte Sweep Algorithmus zur Minnimierung von Kantenkreuzungen
- * Es wird immer genau ein sweep durchgeführt
+ * Der aus der Vorlesung bekannte Sweep Algorithmus zur Minimierung von Kantenkreuzungen
+ * Es wird immer genau ein sweep durchgef�hrt
  * @author kolja
  *
  */
@@ -25,7 +25,7 @@ public class SweepCrossingMinimizer {
             graph.setOrderedLayer( reduceCrossingsBetweenLayers( l1, l2, false ), i ); // minnimiere die Kreuzungen zwischen den letzten beiden Layern
         }
         for( int i = layers.size() - 2; i >= 0; i-- )
-        { // Gehe alle Layer rückwärts durch
+        { // Gehe alle Layer r�ckw�rts durch
             ArrayList<LayeredGraphNode> l1 = layers.get( i + 1 );
             ArrayList<LayeredGraphNode> l2 = layers.get( i );
             graph.setOrderedLayer( reduceCrossingsBetweenLayers( l1, l2, true ), i );  // minnimiere die Kreuzungen zwischen den letzten beiden Layern
@@ -38,13 +38,13 @@ public class SweepCrossingMinimizer {
      * @param l1 Eine geordnete Liste mit Knoten aus dem ersten Layer
      * @param l2 Eine geordnete Liste mit Knoten aus dem zweiten Layer
      * @param rev Gibt an, in welche Richtung die Kanten verlaufen (true, falls von l2 nach l1)
-     * @return Gibt eine Liste mit Gewichten zurück, nach denen die Knoten sortiert werden sollen
+     * @return Gibt eine Liste mit Gewichten zur�ck, nach denen die Knoten sortiert werden sollen
      */
     private ArrayList<Double> reduceCrossingsBetweenLayers( ArrayList<LayeredGraphNode> l1, ArrayList<LayeredGraphNode> l2, boolean rev)
     {
         ArrayList< Double > gewicht = new ArrayList< Double >();
         for( LayeredGraphNode n : l2 )
-        { // Für jeden Knoten in Layer 2
+        { // F�r jeden Knoten in Layer 2
             ArrayList< LayeredGraphEdge > edges = null;
             if( rev )
                 edges = n.getOutgoingEdges();
@@ -65,7 +65,7 @@ public class SweepCrossingMinimizer {
     }
     
     /**
-     * Zählt die Anzahl der Kantenkreuzungen in einem Graph
+     * Z�hlt die Anzahl der Kantenkreuzungen in einem Graph
      * @param layers Eine Liste mit Sortierten Layern
      * @return Die Anzahl der Kreuzungen
      */
@@ -83,7 +83,7 @@ public class SweepCrossingMinimizer {
     }
     
     /**
-     * Zählt die Anzahl der Kantenkreuzungen zwischen zwei Layern (Es wird angenommen dass alle Kanten von l1 nach l2 verlaufen)
+     * Z�hlt die Anzahl der Kantenkreuzungen zwischen zwei Layern (Es wird angenommen dass alle Kanten von l1 nach l2 verlaufen)
      * @param l1 Der erste Layer
      * @param l2 Der zweite Layer
      * @return Die Anzahl der Kreuzungen

+ 0 - 1
src/Main.java

@@ -1,7 +1,6 @@
 import Algorithms.InitializeNodePositions;
 import Algorithms.RandomGraphGenerator;
 import Algorithms.SweepCrossingMinimizer;
-import IO.Reader;
 import Model.LayeredGraphNode;
 import View.MainView;
 

+ 0 - 1
src/View/EdgeView.java

@@ -2,7 +2,6 @@ package View;
 
 import java.awt.BasicStroke;
 import java.awt.Color;
-import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Graphics2D;