Parcourir la source

restructure packages :P

Eren Yilmaz il y a 6 ans
Parent
commit
642bd42b81

+ 6 - 5
doc/chapter/2architecture.tex

@@ -51,7 +51,7 @@ The internal representation of graphs is further explained in the section~\ref{s
 \begin{figure}[htp]
 \begin{figure}[htp]
     \centering
     \centering
     \includegraphics[width=\linewidth,trim=0 20cm 0 0,clip]{img/io.pdf}
     \includegraphics[width=\linewidth,trim=0 20cm 0 0,clip]{img/io.pdf}
-    \caption[Class diagram of the \enquote{io} package]{Class diagram of the \enquote{io} package, containing utilities for reading and writing graphs.}
+    \caption[Class diagram of the \enquote{graph.io} package]{Class diagram of the \enquote{graph.io} package, containing utilities for reading and writing graphs.}
     \label{fig:io}
     \label{fig:io}
 \end{figure}
 \end{figure}
 
 
@@ -83,7 +83,7 @@ The internal representation of graphs is further explained in the section~\ref{s
     \label{fig:json-example}
     \label{fig:json-example}
 \end{figure}
 \end{figure}
 
 
-\section{Internal graph representation, \enquote{model}}\label{sec:model}
+\section{Internal graph representation, \enquote{graph}}\label{sec:model}
 One feature that is important to us, is to be able to work with hierarchical graphs (cf.\ chapter~\ref{ch:progress}).
 One feature that is important to us, is to be able to work with hierarchical graphs (cf.\ chapter~\ref{ch:progress}).
 Therefore a node not only has edges to other nodes, but also it can contain other nodes and edges.
 Therefore a node not only has edges to other nodes, but also it can contain other nodes and edges.
 So far this is similar to what we described in section~\ref{sec:inputFileFormat}.
 So far this is similar to what we described in section~\ref{sec:inputFileFormat}.
@@ -102,12 +102,12 @@ Similarly, edges have additional attributes:
     \item \enquote{bindPoints} is a list of bend points for the edge, including the beginning and end point of the edge.
     \item \enquote{bindPoints} is a list of bend points for the edge, including the beginning and end point of the edge.
 \end{itemize}
 \end{itemize}
 
 
-A class diagram of the package \enquote{model} is displayed in figure~\ref{fig:model}.
+A class diagram of the package \enquote{graph} is displayed in figure~\ref{fig:model}.
 
 
 \begin{figure}[htp]
 \begin{figure}[htp]
     \centering
     \centering
     \includegraphics[width=\linewidth,trim=0 6cm 0 0,clip]{img/model.pdf}
     \includegraphics[width=\linewidth,trim=0 6cm 0 0,clip]{img/model.pdf}
-    \caption{Class diagram of the \enquote{model} package.}
+    \caption{Class diagram of the \enquote{graph} package.}
     \label{fig:model}
     \label{fig:model}
 \end{figure}
 \end{figure}
 
 
@@ -151,6 +151,7 @@ This works the following:
     \item The algorithm potentially calls the step function of other alogrithms while executing one step.
     \item The algorithm potentially calls the step function of other alogrithms while executing one step.
 \end{enumerate}
 \end{enumerate}
 
 
+\TODO{outdated}
 \begin{figure}[htp]
 \begin{figure}[htp]
     \centering
     \centering
     \includegraphics[width=\linewidth,trim=0 9cm 0 0,clip]{img/algorithms_animated.pdf}
     \includegraphics[width=\linewidth,trim=0 9cm 0 0,clip]{img/algorithms_animated.pdf}
@@ -167,5 +168,5 @@ The distinguish two kinds of views:
     \item The main window displays four regions for the different extremal layouts while also forwarding keyboard commands to the AnimationController.
     \item The main window displays four regions for the different extremal layouts while also forwarding keyboard commands to the AnimationController.
     For this we use a JFrame from the Swing library.
     For this we use a JFrame from the Swing library.
     \item \enquote{EdgeView} and \enquote{NodeView} are JPanels, which means they can be drawn onto the JFrame.
     \item \enquote{EdgeView} and \enquote{NodeView} are JPanels, which means they can be drawn onto the JFrame.
-    For this they have to know about which part of the model and which layout they belong to.
+    For this they have to know about which part of the graph and which layout they belong to.
 \end{itemize}
 \end{itemize}

+ 0 - 31
src/algorithms/RandomColorGenerator.java

@@ -1,31 +0,0 @@
-package algorithms;
-
-import java.awt.Color;
-import java.util.Random;
-
-/**
- * generates random colors
- * @author kolja
- *
- */
-public class RandomColorGenerator {
-
-	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();
-		float g = rand.nextFloat();
-		float b = rand.nextFloat();
-		return new Color( r, g, b );
-	}
-}

+ 1 - 1
src/algorithms/animated/Action.java → src/animation/Action.java

@@ -1,4 +1,4 @@
-package algorithms.animated;
+package animation;
 
 
 /**
 /**
  * An action some kind of command that can be send to the {@link AnimatedAlgorithm} from the {@link AnimationController}.
  * An action some kind of command that can be send to the {@link AnimatedAlgorithm} from the {@link AnimationController}.

+ 2 - 2
src/algorithms/animated/AlgorithmStage.java → src/animation/AlgorithmStage.java

@@ -1,6 +1,6 @@
-package algorithms.animated;
+package animation;
 
 
-import algorithms.animated.bk.BlockCalc;
+import bk.BlockCalc;
 
 
 /**
 /**
  * Represents a specific stage of the algorithm.
  * Represents a specific stage of the algorithm.

+ 2 - 2
src/algorithms/animated/AnimatedAlgorithm.java → src/animation/AnimatedAlgorithm.java

@@ -1,6 +1,6 @@
-package algorithms.animated;
+package animation;
 
 
-import model.LayeredGraphNode;
+import graph.LayeredGraphNode;
 
 
 public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage {
 public abstract class AnimatedAlgorithm extends Thread implements AlgorithmStage {
 
 

+ 1 - 1
src/algorithms/animated/AnimationController.java → src/animation/AnimationController.java

@@ -1,4 +1,4 @@
-package algorithms.animated;
+package animation;
 
 
 public class AnimationController {
 public class AnimationController {
 	
 	

+ 1 - 1
src/algorithms/animated/BackwardAction.java → src/animation/BackwardAction.java

@@ -1,4 +1,4 @@
-package algorithms.animated;
+package animation;
 
 
 /**
 /**
  * An action that reverts another Action.
  * An action that reverts another Action.

+ 5 - 5
src/algorithms/animated/bk/BKNodePlacement.java → src/bk/BKNodePlacement.java

@@ -1,9 +1,9 @@
-package algorithms.animated.bk;
+package bk;
 
 
-import algorithms.animated.AlgorithmStage;
-import algorithms.animated.AnimatedAlgorithm;
-import algorithms.animated.AnimationController;
-import model.LayeredGraphNode;
+import animation.AlgorithmStage;
+import animation.AnimatedAlgorithm;
+import animation.AnimationController;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * The main stage of the BK node placement algorithm.
  * The main stage of the BK node placement algorithm.

+ 6 - 6
src/algorithms/animated/bk/BlockCalc.java → src/bk/BlockCalc.java

@@ -1,14 +1,14 @@
-package algorithms.animated.bk;
+package bk;
 
 
 import java.awt.Color;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Collections;
 
 
-import algorithms.animated.AlgorithmStage;
-import algorithms.animated.BackwardAction;
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
-import model.LayeredGraphEdge;
-import model.LayeredGraphNode;
+import animation.AlgorithmStage;
+import animation.BackwardAction;
+import bk.ExtremalLayoutCalc.LayoutType;
+import graph.LayeredGraphEdge;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * The stage of the BK node placement algorithm where the blocks are computed.
  * The stage of the BK node placement algorithm where the blocks are computed.

+ 3 - 3
src/algorithms/animated/bk/Combine.java → src/bk/Combine.java

@@ -1,7 +1,7 @@
-package algorithms.animated.bk;
+package bk;
 
 
-import algorithms.animated.AlgorithmStage;
-import model.LayeredGraphNode;
+import animation.AlgorithmStage;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * The stage of the combination of the four extremal layouts.
  * The stage of the combination of the four extremal layouts.

+ 5 - 5
src/algorithms/animated/bk/Compaction.java → src/bk/Compaction.java

@@ -1,11 +1,11 @@
-package algorithms.animated.bk;
+package bk;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
-import algorithms.animated.AlgorithmStage;
-import algorithms.animated.BackwardAction;
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
-import model.LayeredGraphNode;
+import animation.AlgorithmStage;
+import animation.BackwardAction;
+import bk.ExtremalLayoutCalc.LayoutType;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * The stage of compacting the layout.
  * The stage of compacting the layout.

+ 5 - 5
src/algorithms/animated/bk/ConflictDetection.java → src/bk/ConflictDetection.java

@@ -1,11 +1,11 @@
-package algorithms.animated.bk;
+package bk;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
-import algorithms.animated.AlgorithmStage;
-import algorithms.animated.BackwardAction;
-import model.LayeredGraphEdge;
-import model.LayeredGraphNode;
+import animation.AlgorithmStage;
+import animation.BackwardAction;
+import graph.LayeredGraphEdge;
+import graph.LayeredGraphNode;
 
 
 public class ConflictDetection implements AlgorithmStage {
 public class ConflictDetection implements AlgorithmStage {
 
 

+ 3 - 3
src/algorithms/animated/bk/ExtremalLayoutCalc.java → src/bk/ExtremalLayoutCalc.java

@@ -1,7 +1,7 @@
-package algorithms.animated.bk;
+package bk;
 
 
-import algorithms.animated.AlgorithmStage;
-import model.LayeredGraphNode;
+import animation.AlgorithmStage;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * The stage where the for extremal layouts are computed.
  * The stage where the for extremal layouts are computed.

+ 5 - 7
src/algorithms/InitializeNodePositions.java → src/graph/InitializeNodePositions.java

@@ -1,9 +1,9 @@
-package algorithms;
+package graph;
 
 
+import java.awt.Color;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
-import model.LayeredGraphNode;
+import bk.ExtremalLayoutCalc.LayoutType;
 
 
 
 
 /**
 /**
@@ -18,11 +18,9 @@ public class InitializeNodePositions {
      * @param graph the graph where the node positions are to be set.
      * @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();
-        for( LayeredGraphNode n : graph.getContainedNodes() )
+    	for( LayeredGraphNode n : graph.getContainedNodes() )
         {
         {
-            n.setColor( cGen.generateColor(), null );
+            n.setColor( new Color((int)(Math.random() * 0x1000000)), null );
             placeNodes( n );
             placeNodes( n );
         }
         }
         int curY = 0;
         int curY = 0;

+ 2 - 2
src/model/LayeredEdge.java → src/graph/LayeredEdge.java

@@ -1,11 +1,11 @@
-package model;
+package graph;
 
 
 import java.awt.Point;
 import java.awt.Point;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
 import org.eclipse.elk.graph.ElkEdge;
 import org.eclipse.elk.graph.ElkEdge;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
+import bk.ExtremalLayoutCalc.LayoutType;
 
 
 /**
 /**
  * Die Implementation einer Kante aus einem Layered Graphen.
  * Die Implementation einer Kante aus einem Layered Graphen.

+ 2 - 2
src/model/LayeredGraphEdge.java → src/graph/LayeredGraphEdge.java

@@ -1,11 +1,11 @@
- package model;
+ package graph;
 
 
 import java.awt.Point;
 import java.awt.Point;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
 import org.eclipse.elk.graph.ElkEdge;
 import org.eclipse.elk.graph.ElkEdge;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
+import bk.ExtremalLayoutCalc.LayoutType;
 
 
 /**
 /**
  * Ein Interface, welches die Methoden einer Kante aus einem gelayerten Graphen beschreibt
  * Ein Interface, welches die Methoden einer Kante aus einem gelayerten Graphen beschreibt

+ 2 - 2
src/model/LayeredGraphNode.java → src/graph/LayeredGraphNode.java

@@ -1,4 +1,4 @@
-package model;
+package graph;
 
 
 import java.awt.Color;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -6,7 +6,7 @@ import java.util.ArrayList;
 import org.eclipse.elk.graph.ElkEdge;
 import org.eclipse.elk.graph.ElkEdge;
 import org.eclipse.elk.graph.ElkNode;
 import org.eclipse.elk.graph.ElkNode;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
+import bk.ExtremalLayoutCalc.LayoutType;
 
 
 /**
 /**
  * Ein Interface, welches die Methoden eines Knotens aus einem gelayerten Graphen beschreibt (Ein Knoten kann dabei auch einen weiteren Graphen beinhalten)
  * Ein Interface, welches die Methoden eines Knotens aus einem gelayerten Graphen beschreibt (Ein Knoten kann dabei auch einen weiteren Graphen beinhalten)

+ 2 - 2
src/model/LayeredNode.java → src/graph/LayeredNode.java

@@ -1,4 +1,4 @@
-package model;
+package graph;
 
 
 import java.awt.Color;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -8,7 +8,7 @@ import javax.swing.SwingUtilities;
 import org.eclipse.elk.graph.ElkEdge;
 import org.eclipse.elk.graph.ElkEdge;
 import org.eclipse.elk.graph.ElkNode;
 import org.eclipse.elk.graph.ElkNode;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
+import bk.ExtremalLayoutCalc.LayoutType;
 import view.MainView;
 import view.MainView;
 
 
 /**
 /**

+ 1 - 4
src/algorithms/RandomGraphGenerator.java → src/graph/RandomGraphGenerator.java

@@ -1,7 +1,4 @@
-package algorithms;
-
-import model.LayeredGraphNode;
-import model.LayeredNode;
+package graph;
 
 
 /**
 /**
  * creates random {@link LayeredGraphNode}s for testing purposes
  * creates random {@link LayeredGraphNode}s for testing purposes

+ 4 - 4
src/io/Reader.java → src/graph/io/Reader.java

@@ -1,4 +1,4 @@
-package io;
+package graph.io;
 
 
 import java.io.BufferedReader;
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.FileReader;
@@ -9,9 +9,9 @@ import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONObject;
 
 
-import model.LayeredGraphEdge;
-import model.LayeredGraphNode;
-import model.LayeredNode;
+import graph.LayeredGraphEdge;
+import graph.LayeredGraphNode;
+import graph.LayeredNode;
 
 
 /**
 /**
  * reads a {@link LayeredGraphNode} from a JSON file
  * reads a {@link LayeredGraphNode} from a JSON file

+ 3 - 3
src/io/Writer.java → src/graph/io/Writer.java

@@ -1,4 +1,4 @@
-package io;
+package graph.io;
 
 
 import java.io.BufferedWriter;
 import java.io.BufferedWriter;
 import java.io.FileWriter;
 import java.io.FileWriter;
@@ -9,8 +9,8 @@ import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONObject;
 
 
-import model.LayeredGraphEdge;
-import model.LayeredGraphNode;
+import graph.LayeredGraphEdge;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * Writes a {@link LayeredGraphNode} to a JSON file.
  * Writes a {@link LayeredGraphNode} to a JSON file.

+ 3 - 3
src/algorithms/SweepCrossingMinimizer.java → src/lib/SweepCrossingMinimizer.java

@@ -1,9 +1,9 @@
-package algorithms;
+package lib;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
-import model.LayeredGraphEdge;
-import model.LayeredGraphNode;
+import graph.LayeredGraphEdge;
+import graph.LayeredGraphNode;
 
 
 
 
 /**
 /**

+ 5 - 5
src/main/Main.java

@@ -1,9 +1,9 @@
 package main;
 package main;
-import algorithms.InitializeNodePositions;
-import algorithms.RandomGraphGenerator;
-import algorithms.SweepCrossingMinimizer;
-import io.Reader;
-import model.LayeredGraphNode;
+import graph.InitializeNodePositions;
+import graph.LayeredGraphNode;
+import graph.RandomGraphGenerator;
+import graph.io.Reader;
+import lib.SweepCrossingMinimizer;
 import view.MainView;
 import view.MainView;
 
 
 /**
 /**

+ 2 - 2
src/view/EdgeView.java

@@ -10,8 +10,8 @@ import java.util.ArrayList;
 
 
 import javax.swing.JPanel;
 import javax.swing.JPanel;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
-import model.LayeredGraphEdge;
+import bk.ExtremalLayoutCalc.LayoutType;
+import graph.LayeredGraphEdge;
 
 
 /**
 /**
  * A drawable representation of an edge.
  * A drawable representation of an edge.

+ 7 - 7
src/view/MainView.java

@@ -12,13 +12,13 @@ import javax.swing.JFrame;
 import javax.swing.JLayeredPane;
 import javax.swing.JLayeredPane;
 import javax.swing.JPanel;
 import javax.swing.JPanel;
 
 
-import algorithms.animated.Action;
-import algorithms.animated.AnimationController;
-import algorithms.animated.bk.BKNodePlacement;
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
-import io.Writer;
-import model.LayeredGraphEdge;
-import model.LayeredGraphNode;
+import animation.Action;
+import animation.AnimationController;
+import bk.BKNodePlacement;
+import bk.ExtremalLayoutCalc.LayoutType;
+import graph.LayeredGraphEdge;
+import graph.LayeredGraphNode;
+import graph.io.Writer;
 
 
 /**
 /**
  * The main window of the application.
  * The main window of the application.

+ 2 - 2
src/view/NodeView.java

@@ -11,8 +11,8 @@ import java.awt.Point;
 import javax.swing.*;
 import javax.swing.*;
 import javax.swing.border.Border;
 import javax.swing.border.Border;
 
 
-import algorithms.animated.bk.ExtremalLayoutCalc.LayoutType;
-import model.LayeredGraphNode;
+import bk.ExtremalLayoutCalc.LayoutType;
+import graph.LayeredGraphNode;
 
 
 /**
 /**
  * A drawable representation of a node.
  * A drawable representation of a node.