gui.multisource
Class MultisourceViewer

java.lang.Object
  extended by gui.multisource.MultisourceViewer
All Implemented Interfaces:
Viewable

public class MultisourceViewer
extends java.lang.Object
implements Viewable

A MultisourceViewer displays multisource text and displays the sources of lines of text as color codes on the left of the text. A multisource viewer has a special source identified as MultisourceDocument.USER that represents the user of the program. The last line of the viewer can be freely edited by the user. It is committed automatically when the user enters a linefeed (return) character. When committed, the line is forwared to a text consumer that is attached to the viewer and it color code is set to the color code for USER.


Constructor Summary
MultisourceViewer()
          new MultisourceViewer() returns a new MultisourceViewer with a do-nothing text consumer.
MultisourceViewer(TextConsumer tc)
          new MultisourceViewer(tc) returns a new MultisourceViewer with text consumer tc.
 
Method Summary
 void addText(java.lang.String s, java.lang.Object src)
          mv.addText(s, src) adds s at the start-new-text point of mv and advances the start-new-text point past the added text.
 void clear()
          mv.clear() removes all text from mv.
 javax.swing.JTextPane getViewComponent()
          mv.getViewComponent() returns the text pane for mv.
 void setEditable(boolean ed)
          mv.setEditable(ed) sets the editability of mv to ed.
 void setFontSize(int sz)
          mv.setFontSize(sz) sets the font size of mv to sz.
 void setSourceColor(java.lang.Object src, java.awt.Color c)
          mv.setSourceColor(src, c) sets the source color of source identified by src in mv to c.
 void setTextConsumer(TextConsumer tc)
          mv.setTextConsumer(tc) sets tc as the text consumer for mv.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultisourceViewer

public MultisourceViewer()
new MultisourceViewer() returns a new MultisourceViewer with a do-nothing text consumer.


MultisourceViewer

public MultisourceViewer(TextConsumer tc)
new MultisourceViewer(tc) returns a new MultisourceViewer with text consumer tc.

Method Detail

getViewComponent

public javax.swing.JTextPane getViewComponent()
mv.getViewComponent() returns the text pane for mv.

Specified by:
getViewComponent in interface Viewable
Returns:
the view component

setFontSize

public void setFontSize(int sz)
mv.setFontSize(sz) sets the font size of mv to sz.


setSourceColor

public void setSourceColor(java.lang.Object src,
                           java.awt.Color c)
mv.setSourceColor(src, c) sets the source color of source identified by src in mv to c.


setTextConsumer

public void setTextConsumer(TextConsumer tc)
mv.setTextConsumer(tc) sets tc as the text consumer for mv.


setEditable

public void setEditable(boolean ed)
mv.setEditable(ed) sets the editability of mv to ed.


addText

public void addText(java.lang.String s,
                    java.lang.Object src)
mv.addText(s, src) adds s at the start-new-text point of mv and advances the start-new-text point past the added text. The source of the text is indicated by src. The text is added by the event handler thread, allowing the method to be invoked by other threads.


clear

public void clear()
mv.clear() removes all text from mv.