From dec65166d2726dd4f1b0120a62ec5c9b7936ed44 Mon Sep 17 00:00:00 2001 From: Jonathan-Kalmbach Date: Wed, 10 Jul 2024 05:52:46 +0000 Subject: [PATCH] Dateien nach "logging" hochladen --- logging/Algorithm.java | 80 ++++++++++++++++++++++++++++++++++++ logging/GraphLogElement.java | 52 +++++++++++++++++++++++ logging/LogElement.java | 76 ++++++++++++++++++++++++++++++++++ logging/LogElementList.java | 56 +++++++++++++++++++++++++ logging/NewLogElement.java | 24 +++++++++++ 5 files changed, 288 insertions(+) create mode 100644 logging/Algorithm.java create mode 100644 logging/GraphLogElement.java create mode 100644 logging/LogElement.java create mode 100644 logging/LogElementList.java create mode 100644 logging/NewLogElement.java diff --git a/logging/Algorithm.java b/logging/Algorithm.java new file mode 100644 index 0000000..2ffffa9 --- /dev/null +++ b/logging/Algorithm.java @@ -0,0 +1,80 @@ +package logging; + +import visualization.ParameterArea; + +/** + * This class provides the basic algorithm. + * Use it in assoziation with packages logging and visualization. + * Extend it by the members you need and overwrite LogElementListrun() which contains the specific algorithmic procedures. + * Therein you should fill a LogElementList and return it. + * Parameters for algorithm processing are read from member parameterArea that ist part of the user interface. + * @see LogElement + * @see LogElementList + * @see visualization.HybridWindow + * @see visualization.ParameterArea + * @author Björn Strobel
+ * University of Cooperative Education Stuttgart, + * Campus Horb
+ * Department of Information Technology
+ * it2003
+ */ +public abstract class Algorithm { + + /**Algorithm title.*/ + protected String title; + /**Algorithm parameter area from which the algorithm gets its parameters.*/ + protected PARAM parameterArea; + + /**Standard constructor.*/ + public Algorithm() { + super(); + // TODO Auto-generated constructor stub + } + + /**Creates algorithm with specified title and parameter area.*/ + public Algorithm(PARAM parameterArea,String title){ + this.parameterArea=parameterArea; + this.title=title; + } + + /** + * Runs the algorithm with parameters specified in parameterArea. + * Returns the LogElementList produced by the algorithm processing. + * To use this class you will have to overwrite this method. + * @return a LogElementList containing the algorithm processings single steps + */ + public abstract LogElementListrun(); + //return new LogElementList() + + /** + * Returns the algorithm title. + * @return the algorithm title. + */ + public String getTitle(){ + return title; + } + + /** + * Sets the algorithm's title. + * @param title the algorithm's title + */ + public void setTitle(String title){ + this.title=title; + } + + /** + * Sets the algorithm's parameter area. + * @param parameterArea the algorithm's parameter area + */ + public void setParameterArea(PARAM parameterArea){ + this.parameterArea=parameterArea; + } + + /** + * Returns the algorithm's parameter area. + * @return the algorithm's parameter area + */ + public PARAM getParameterArea(){ + return parameterArea; + } +} diff --git a/logging/GraphLogElement.java b/logging/GraphLogElement.java new file mode 100644 index 0000000..5cb37da --- /dev/null +++ b/logging/GraphLogElement.java @@ -0,0 +1,52 @@ +package logging; + +import graph.VertexMarking; +import visualizationElements.Edge; +import visualizationElements.Vertex; + +import java.awt.Color; +import java.util.List; +import java.util.Map; + +public class GraphLogElement extends LogElement { + private List visualVertices; + private List visualEdges; + private Map visualVertexColors; + + + public GraphLogElement(int step, String description, List vertices, List edges, Map vertexColors) { + super(step, description); + this.visualVertices = vertices; + this.visualEdges = edges; + this.visualVertexColors = vertexColors; + } + + public List getVisualVertices() { + return visualVertices; + } + + public List getVisualEdges() { + return visualEdges; + } + + public Map getVisualVertexColors() { + return visualVertexColors; + } + + // Optional: Darstellung des Graphen im LogElement + @Override + public String toString() { + return super.toString() + ", vertices=" + visualVertices + ", edges=" + visualEdges + ", vertexColors=" + visualVertexColors; + } + + public static visualizationElements.Vertex transformToVisualVertex(graph.MarkedVertex markedVertex) { + return new visualizationElements.Vertex( + markedVertex.getX(), + markedVertex.getY(), + markedVertex.getName(), + markedVertex.getColor() + ); + } + +} + diff --git a/logging/LogElement.java b/logging/LogElement.java new file mode 100644 index 0000000..066c090 --- /dev/null +++ b/logging/LogElement.java @@ -0,0 +1,76 @@ +package logging; + +/** + * This class provides the basic log list element. + * Use it in assoziation with packages logging and visualization. + * It is used to store all relevant information about a algorithm processing'S single step. + * Extend it by the members you need. + * @see logging.Algorithm + * @see LogElementList + * @see visualization.HybridWindow + * @author Björn Strobel
+ * University of Cooperative Education Stuttgart, + * Campus Horb
+ * Department of Information Technology
+ * it2003
+ */ +public class LogElement { + + /** The step number of the single step within a algorithm's log element list.*/ + protected int step; + /** Description of the single step's process.*/ + protected String description; + + + /** + * Standard constructor. + * Creates a log element with step number 0 and "No description available." as description. + */ + public LogElement() { + super(); + step=0; + description="No description available."; + } + + /** + * Creates a log element with the specified step number and description. + * @param step step number + * @param description step description + */ + public LogElement(int step,String description){ + this.step=step; + this.description=description; + } + + /** + * Returns the step's step number. + * @return the step's step number + */ + public int getStep(){ + return step; + } + + /** + * Sets the step's step number. + * @param step the step's step number + */ + public void setStep(int step){ + this.step=step; + } + + /** + * Returns the step's description. + * @return the step's description + */ + public String getDescription(){ + return description; + } + + /** + * Sets the step's description. + * @param description the step's description + */ + public void setDescription(String description){ + this.description=description; + } +} diff --git a/logging/LogElementList.java b/logging/LogElementList.java new file mode 100644 index 0000000..82beea3 --- /dev/null +++ b/logging/LogElementList.java @@ -0,0 +1,56 @@ +package logging; + +import java.util.Vector; + +public final class LogElementList extends Vector { + private int actual; + private boolean initialized; + + public LogElementList() { + super(); + actual = -1; + initialized = false; + } + + public LOG get() { + return get(actual); + } + + public boolean isInitialized() { + return initialized; + } + + public void clear() { + super.clear(); + actual = -1; + initialized = false; + } + + public void prev() { + if (actual > 0) { + actual--; + } else { + actual = 0; + } + initialized = true; + } + + public void next() { + if (actual < size() - 1) { + actual++; + } else { + actual = size() - 1; + } + initialized = true; + } + + public void first() { + actual = 0; + initialized = true; + } + + public void last() { + actual = size() - 1; + initialized = true; + } +} \ No newline at end of file diff --git a/logging/NewLogElement.java b/logging/NewLogElement.java new file mode 100644 index 0000000..b1fd45b --- /dev/null +++ b/logging/NewLogElement.java @@ -0,0 +1,24 @@ +package logging; + +import visualizationElements.Edge; +import visualizationElements.Vertex; + +public class NewLogElement extends LogElement +{ + visualizationElements.Graph g; + + + public NewLogElement(){ + super(); + } + + public NewLogElement(int step, visualizationElements.Graph g){ + this.g = g; + this.step = step; + } + + public visualizationElements.Graph getGraph(){ + return this.g; + } + +}