2024-06-15 19:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2024-07-02 19:13:30 +00:00
|
|
|
|
package visualisation;
|
2024-06-15 19:55:30 +00:00
|
|
|
|
|
|
|
|
|
import logging.LogElement;
|
|
|
|
|
import logging.LogElementList;
|
|
|
|
|
|
2024-07-02 19:13:30 +00:00
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
2024-06-15 19:55:30 +00:00
|
|
|
|
/**
|
|
|
|
|
* This class provides the basic text output area for a HybridWindow.
|
|
|
|
|
* Use it in assoziation with packages logging and visualization.
|
|
|
|
|
* Just overwrite the print method to get a textual output of a log list element.
|
|
|
|
|
* Parameters for algorithm processing are read from member parameterArea that ist part of the user interface.
|
|
|
|
|
* @see logging.Algorithm
|
2024-07-02 19:13:30 +00:00
|
|
|
|
* @see LogElement
|
|
|
|
|
* @see LogElementList
|
|
|
|
|
* @see DrawArea
|
|
|
|
|
* @see HybridWindow
|
|
|
|
|
* @see ParameterArea
|
|
|
|
|
* @see TextArea
|
|
|
|
|
* @see JTextArea
|
|
|
|
|
* @author Bj<EFBFBD>rn Strobel<br><small>
|
2024-06-15 19:55:30 +00:00
|
|
|
|
* University of Cooperative Education Stuttgart,
|
|
|
|
|
* Campus Horb<br>
|
|
|
|
|
* Department of Information Technology<br>
|
|
|
|
|
* it2003<br></small>
|
|
|
|
|
*/
|
|
|
|
|
public abstract class TextArea<LOG extends LogElement>extends JTextArea{
|
|
|
|
|
|
|
|
|
|
/** The text area's scroll pane. */
|
|
|
|
|
protected JScrollPane scrollPane;
|
|
|
|
|
/** The log element list where the text area gets the log elements. */
|
|
|
|
|
protected LogElementList<LOG>logList;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Standard constructor.
|
|
|
|
|
* Creates an empty text area with scroll pane.
|
|
|
|
|
*/
|
|
|
|
|
public TextArea() {
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
scrollPane=new JScrollPane(this);
|
|
|
|
|
|
|
|
|
|
setBackground(Color.black);
|
|
|
|
|
setForeground(Color.green);
|
|
|
|
|
setEditable(false);
|
|
|
|
|
setColumns(25);
|
|
|
|
|
setRows(5);
|
|
|
|
|
setFont(new Font("Monospaced",Font.PLAIN,12));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an empty text area with scroll pane and sets the specified log list.
|
|
|
|
|
* @param logList the text area's log list
|
|
|
|
|
*/
|
|
|
|
|
public TextArea(LogElementList<LOG>logList){
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
scrollPane=new JScrollPane(this);
|
|
|
|
|
|
|
|
|
|
setBackground(Color.black);
|
|
|
|
|
setForeground(Color.green);
|
|
|
|
|
setEditable(false);
|
|
|
|
|
setColumns(25);
|
|
|
|
|
setRows(5);
|
|
|
|
|
setFont(new Font("Monospaced",Font.PLAIN,12));
|
|
|
|
|
|
|
|
|
|
this.logList=logList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the text area's scroll pane.
|
|
|
|
|
* @return the text area's scroll pane
|
|
|
|
|
*/
|
|
|
|
|
public JScrollPane getScrollPane(){
|
|
|
|
|
return scrollPane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the text area's logList.
|
|
|
|
|
* @param logList the text area's logList
|
|
|
|
|
*/
|
|
|
|
|
public void setLogList(LogElementList<LOG>logList){
|
|
|
|
|
this.logList=logList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provided for convenience. Calls print();
|
|
|
|
|
*/
|
|
|
|
|
public void printStep(){
|
|
|
|
|
print();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prints the actual algorithm step's description.
|
|
|
|
|
* It is suggested to overwrite this method.
|
|
|
|
|
*/
|
|
|
|
|
//public void print(){
|
|
|
|
|
public boolean print(){
|
|
|
|
|
LogElement logElement=(LogElement)logList.get();
|
|
|
|
|
if(getText().equals("")){
|
|
|
|
|
//setText(logElement.getDescription());
|
|
|
|
|
append(logElement.getDescription());
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
setText(getText()+"\n"+logElement.getDescription());
|
|
|
|
|
append("\n"+logElement.getDescription());
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clears the text area
|
|
|
|
|
*/
|
|
|
|
|
public void clear(){
|
|
|
|
|
setText("");
|
|
|
|
|
}
|
|
|
|
|
}
|