Parcourir la source

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

Kolja Strohm il y a 6 ans
Parent
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 port constraints.
     \item There are no labels.
     \item There are no labels.
     \item There are no cross-hierarchy edges.
     \item There are no cross-hierarchy edges.
+    \item No edges over multiple layers (the previous phases should have added dummy nodes).
 \end{itemize}
 \end{itemize}
 
 
 \section{Input File Format}\label{sec:inputFileFormat}
 \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}
 \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}
 \end{itemize}

+ 19 - 4
doc/doc.tex

@@ -6,7 +6,7 @@
 \pdfsuppresswarningpagegroup=1
 \pdfsuppresswarningpagegroup=1
 % Allgemeines
 % Allgemeines
 \usepackage[automark]{scrlayer-scrpage} % Kopf- und Fußzeilen
 \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[T1]{fontenc} % Ligaturen, richtige Umlaute im PDF
 \usepackage[utf8]{inputenc}% UTF8-Kodierung für Umlaute usw
 \usepackage[utf8]{inputenc}% UTF8-Kodierung für Umlaute usw
 % Schriften
 % Schriften
@@ -57,6 +57,22 @@
 \setlength{\abovecaptionskip}{0.2cm} % Abstand der zwischen Bild- und Bildunterschrift
 \setlength{\abovecaptionskip}{0.2cm} % Abstand der zwischen Bild- und Bildunterschrift
 \usepackage{enumitem} % Referenzen auf Item in enumerate-Blocks
 \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
 % \toprule and other commands
 \usepackage{booktabs}
 \usepackage{booktabs}
 
 
@@ -83,9 +99,6 @@
 \definecolor{deepred}{rgb}{0.8,0,0}
 \definecolor{deepred}{rgb}{0.8,0,0}
 \definecolor{deepgreen}{rgb}{0,0.4,0}
 \definecolor{deepgreen}{rgb}{0,0.4,0}
 \definecolor{grau}{gray}{0.3}
 \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
 % python style code
 \lstset{
 \lstset{
 extendedchars=true,
 extendedchars=true,
@@ -235,6 +248,8 @@ frame=tb}
     \chapter{Current Progress}\label{ch:progress}
     \chapter{Current Progress}\label{ch:progress}
     \input{chapter/3progress}
     \input{chapter/3progress}
 
 
+    \TODO{UI and visuals chapter}
+
     \chapter{Retrospection}
     \chapter{Retrospection}
     \input{chapter/4retrospection}
     \input{chapter/4retrospection}
 
 

+ 4 - 1
src/Algorithms/InitializeNodePositions.java

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

+ 10 - 1
src/Algorithms/RandomColorGenerator.java

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

+ 21 - 0
src/Algorithms/RandomGraphGenerator.java

@@ -3,6 +3,11 @@ package Algorithms;
 import Model.LayeredGraphNode;
 import Model.LayeredGraphNode;
 import Model.LayeredNode;
 import Model.LayeredNode;
 
 
+/**
+ * creates random {@link LayeredGraphNode}s for testing purposes
+ * @author kolja
+ *
+ */
 public class RandomGraphGenerator {
 public class RandomGraphGenerator {
 
 
     private double pSubgraph;
     private double pSubgraph;
@@ -13,6 +18,16 @@ public class RandomGraphGenerator {
     private int maxNodePerLayer;
     private int maxNodePerLayer;
     private int maxDepth;
     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 )
     public RandomGraphGenerator( double pSubgraph, double pEdge, int minLayer, int maxLayer, int minNodePerLayer, int maxNodePerLayer, int maxDepth )
     {
     {
         this.pSubgraph = pSubgraph;
         this.pSubgraph = pSubgraph;
@@ -24,6 +39,12 @@ public class RandomGraphGenerator {
         this.maxDepth = maxDepth;
         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 )
     public LayeredGraphNode createRandomNode( LayeredGraphNode parent, int depth )
     {
     {
         LayeredGraphNode node = new LayeredNode( null, null );
         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
  * @author kolja
  *
  *
  */
  */
@@ -25,7 +25,7 @@ public class SweepCrossingMinimizer {
             graph.setOrderedLayer( reduceCrossingsBetweenLayers( l1, l2, false ), i ); // minnimiere die Kreuzungen zwischen den letzten beiden Layern
             graph.setOrderedLayer( reduceCrossingsBetweenLayers( l1, l2, false ), i ); // minnimiere die Kreuzungen zwischen den letzten beiden Layern
         }
         }
         for( int i = layers.size() - 2; i >= 0; i-- )
         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> l1 = layers.get( i + 1 );
             ArrayList<LayeredGraphNode> l2 = layers.get( i );
             ArrayList<LayeredGraphNode> l2 = layers.get( i );
             graph.setOrderedLayer( reduceCrossingsBetweenLayers( l1, l2, true ), i );  // minnimiere die Kreuzungen zwischen den letzten beiden Layern
             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 l1 Eine geordnete Liste mit Knoten aus dem ersten Layer
      * @param l2 Eine geordnete Liste mit Knoten aus dem zweiten 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)
      * @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)
     private ArrayList<Double> reduceCrossingsBetweenLayers( ArrayList<LayeredGraphNode> l1, ArrayList<LayeredGraphNode> l2, boolean rev)
     {
     {
         ArrayList< Double > gewicht = new ArrayList< Double >();
         ArrayList< Double > gewicht = new ArrayList< Double >();
         for( LayeredGraphNode n : l2 )
         for( LayeredGraphNode n : l2 )
-        { // Für jeden Knoten in Layer 2
+        { // F�r jeden Knoten in Layer 2
             ArrayList< LayeredGraphEdge > edges = null;
             ArrayList< LayeredGraphEdge > edges = null;
             if( rev )
             if( rev )
                 edges = n.getOutgoingEdges();
                 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
      * @param layers Eine Liste mit Sortierten Layern
      * @return Die Anzahl der Kreuzungen
      * @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 l1 Der erste Layer
      * @param l2 Der zweite Layer
      * @param l2 Der zweite Layer
      * @return Die Anzahl der Kreuzungen
      * @return Die Anzahl der Kreuzungen

+ 0 - 1
src/Main.java

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

+ 0 - 1
src/View/EdgeView.java

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