com.isti.util.gui
Class TextAreaOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.isti.util.gui.TextAreaOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class TextAreaOutputStream
extends java.io.OutputStream

Class TextAreaOutputStream is an extension of 'OutputStream' that sends its output to a 'JTextArea' object.


Field Summary
static int DEF_MAXNL_SEARCH
          Max # of chars to search for newline after trim (400).
static int DEF_TEXTSIZE_LIMIT
          Default text size limit, in characters (8000000).
static int DEF_TEXTTRIM_SIZE
          Number of characters to trim when over limit (8000).
 
Constructor Summary
TextAreaOutputStream(javax.swing.JTextArea textAreaObj)
          Creates an 'OutputStream' extension that sends its output to a 'TextArea' object.
TextAreaOutputStream(javax.swing.JTextArea textAreaObj, boolean setupTextObjFlag)
          Creates an 'OutputStream' extension that sends its output to a 'TextArea' object.
 
Method Summary
 void doSetupTextAreaObj()
          Sets up the text area object to be not-editable while still having a visible caret and text cursor.
 void doWrite(byte[] byteArr, int offsetVal, int numChars)
          Sends a portion of an array of bytes to the text area.
 void doWrite(int val)
          Sends the specified character value to the text area.
 int getMaxNewLineSearch()
          Returns the text size limit.
 int getTextSizeLimit()
          Returns the maximum number of characters to search for a newline after a trim.
 int getTextTrimSize()
          Returns the text trim size.
 void setTextSizeLimitValues(int textSizeLimit, int textTrimSize)
          Sets the text size limit values.
 void setTextSizeLimitValues(int textSizeLimit, int textTrimSize, int maxNewLineSearch)
          Sets the text size limit values.
 void setupTextAreaObj()
          Sets up the text area object to be not-editable while still having a visible caret and text cursor.
 void write(byte[] byteArr, int offsetVal, int numChars)
          Sends a portion of an array of bytes to the text area.
 void write(int val)
          Sends the specified character value to the text area.
 
Methods inherited from class java.io.OutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_TEXTSIZE_LIMIT

public static final int DEF_TEXTSIZE_LIMIT
Default text size limit, in characters (8000000).

See Also:
Constant Field Values

DEF_TEXTTRIM_SIZE

public static final int DEF_TEXTTRIM_SIZE
Number of characters to trim when over limit (8000).

See Also:
Constant Field Values

DEF_MAXNL_SEARCH

public static final int DEF_MAXNL_SEARCH
Max # of chars to search for newline after trim (400).

See Also:
Constant Field Values
Constructor Detail

TextAreaOutputStream

public TextAreaOutputStream(javax.swing.JTextArea textAreaObj)
Creates an 'OutputStream' extension that sends its output to a 'TextArea' object. The 'setupTextAreaObj()' method is called to setup the given text area object.

Parameters:
textAreaObj - 'TextArea' object

TextAreaOutputStream

public TextAreaOutputStream(javax.swing.JTextArea textAreaObj,
                            boolean setupTextObjFlag)
Creates an 'OutputStream' extension that sends its output to a 'TextArea' object.

Parameters:
textAreaObj - 'TextArea' object
setupTextObjFlag - if true then 'setupTextAreaObj()' is called to setup the given text area object.
Method Detail

setupTextAreaObj

public void setupTextAreaObj()
Sets up the text area object to be not-editable while still having a visible caret and text cursor. If the thread calling this method is not the event-dispatch thread then the action is queued and invoked later by the event-dispatch thread.


doSetupTextAreaObj

public void doSetupTextAreaObj()
Sets up the text area object to be not-editable while still having a visible caret and text cursor.


write

public void write(int val)
           throws java.io.IOException
Sends the specified character value to the text area. Non-printable values are ignored. If the thread calling this method is not the event-dispatch thread then the action is queued and invoked later by the event-dispatch thread.

Specified by:
write in class java.io.OutputStream
Parameters:
val - the character value.
Throws:
java.io.IOException - if an I/O error occurs (in particular, an IOException may be thrown if the output stream has been closed).

write

public void write(byte[] byteArr,
                  int offsetVal,
                  int numChars)
           throws java.io.IOException
Sends a portion of an array of bytes to the text area. Non-printable values are ignored. If the thread calling this method is not the event-dispatch thread then the action is queued and invoked later by the event-dispatch thread.

Overrides:
write in class java.io.OutputStream
Parameters:
byteArr - array of characters.
offsetVal - offset from which to start writing characters.
numChars - number of characters to write.
Throws:
java.io.IOException - if an I/O error occurs.

doWrite

public void doWrite(int val)
             throws java.io.IOException
Sends the specified character value to the text area. Non-printable values are ignored.

Parameters:
val - the character value.
Throws:
java.io.IOException - if an I/O error occurs (in particular, an IOException may be thrown if the output stream has been closed).

doWrite

public void doWrite(byte[] byteArr,
                    int offsetVal,
                    int numChars)
             throws java.io.IOException
Sends a portion of an array of bytes to the text area. Non-printable values are ignored.

Parameters:
byteArr - array of characters.
offsetVal - offset from which to start writing characters.
numChars - number of characters to write.
Throws:
java.io.IOException - if an I/O error occurs.

setTextSizeLimitValues

public void setTextSizeLimitValues(int textSizeLimit,
                                   int textTrimSize,
                                   int maxNewLineSearch)
Sets the text size limit values. When the number of characters in the text area is greater than 'textSizeLimit' then 'textTrimSize' number of characters will be removed from the beginning of the text area (repeatedly if needed). After the trim, the characters up to the next newline will also be removed (up to 'maxNewLineSearch' number of characters).

Parameters:
textSizeLimit - text size limit, in characters.
textTrimSize - number of character to trim when over limit.
maxNewLineSearch - maximum number of characters to search for a newline after a trim, or 0 or no search.

setTextSizeLimitValues

public void setTextSizeLimitValues(int textSizeLimit,
                                   int textTrimSize)
Sets the text size limit values. When the number of characters in the text area is greater than 'textSizeLimit' then 'textTrimSize' number of characters will be removed from the beginning of the text area (repeatedly if needed). After the trim, the characters up to the next newline will also be removed (up to 'maxNewLineSearch' number of characters).

Parameters:
textSizeLimit - text size limit, in characters.
textTrimSize - number of character to trim when over limit.

getTextTrimSize

public int getTextTrimSize()
Returns the text trim size. When the number of characters in the text area is greater than 'textSizeLimit' then 'textTrimSize' number of characters will be removed from the beginning of the text area (repeatedly if needed).

Returns:
The text trim size.

getMaxNewLineSearch

public int getMaxNewLineSearch()
Returns the text size limit. When the number of characters in the text area is greater than 'textSizeLimit' then 'textTrimSize' number of characters will be removed from the beginning of the text area (repeatedly if needed).

Returns:
The text size limit.

getTextSizeLimit

public int getTextSizeLimit()
Returns the maximum number of characters to search for a newline after a trim. When the number of characters in the text area is greater than 'textSizeLimit' then 'textTrimSize' number of characters will be removed from the beginning of the text area (repeatedly if needed). After the trim, the characters up to the next newline will also be removed (up to 'maxNewLineSearch' number of characters).

Returns:
The maximum number of characters to search for a newline after a trim, or 0 or no search.