ProjektGraph/visualisation/TextArea.java
2024-07-02 21:13:30 +02:00

122 lines
2.7 KiB
Java
Raw Blame History

/**
*
*/
package visualisation;
import logging.LogElement;
import logging.LogElementList;
import javax.swing.*;
import java.awt.*;
/**
* 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
* @see LogElement
* @see LogElementList
* @see DrawArea
* @see HybridWindow
* @see ParameterArea
* @see TextArea
* @see JTextArea
* @author Bj<42>rn Strobel<br><small>
* 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("");
}
}