Dateien nach "logging" hochladen

This commit is contained in:
Jonathan-Kalmbach 2024-07-10 05:52:46 +00:00
parent 825e55803a
commit dec65166d2
5 changed files with 288 additions and 0 deletions

80
logging/Algorithm.java Normal file
View File

@ -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 LogElementList<LOG>run() 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<br><small>
* University of Cooperative Education Stuttgart,
* Campus Horb<br>
* Department of Information Technology<br>
* it2003<br></small>
*/
public abstract class Algorithm <PARAM extends ParameterArea,LOG extends LogElement> {
/**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 LogElementList<LOG>run();
//return new LogElementList<LOG>()
/**
* 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;
}
}

View File

@ -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<Vertex> visualVertices;
private List<Edge> visualEdges;
private Map<Vertex, Color> visualVertexColors;
public GraphLogElement(int step, String description, List<Vertex> vertices, List<Edge> edges, Map<Vertex, Color> vertexColors) {
super(step, description);
this.visualVertices = vertices;
this.visualEdges = edges;
this.visualVertexColors = vertexColors;
}
public List<Vertex> getVisualVertices() {
return visualVertices;
}
public List<Edge> getVisualEdges() {
return visualEdges;
}
public Map<Vertex, Color> 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<VertexMarking> markedVertex) {
return new visualizationElements.Vertex(
markedVertex.getX(),
markedVertex.getY(),
markedVertex.getName(),
markedVertex.getColor()
);
}
}

76
logging/LogElement.java Normal file
View File

@ -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<br><small>
* University of Cooperative Education Stuttgart,
* Campus Horb<br>
* Department of Information Technology<br>
* it2003<br></small>
*/
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;
}
}

View File

@ -0,0 +1,56 @@
package logging;
import java.util.Vector;
public final class LogElementList<LOG extends LogElement> extends Vector<LOG> {
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;
}
}

View File

@ -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;
}
}