/** * */ 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�rn Strobel
* University of Cooperative Education Stuttgart, * Campus Horb
* Department of Information Technology
* it2003
*/ public abstract class TextAreaextends JTextArea{ /** The text area's scroll pane. */ protected JScrollPane scrollPane; /** The log element list where the text area gets the log elements. */ protected LogElementListlogList; /** * 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(LogElementListlogList){ 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(LogElementListlogList){ 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(""); } }