com.isti.util.gui
Class TextAreaWriter

java.lang.Object
  extended byjava.io.Writer
      extended bycom.isti.util.gui.TextAreaWriter

public class TextAreaWriter
extends java.io.Writer

Class TextAreaWriter is an extension of 'Writer' 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).
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TextAreaWriter(javax.swing.JTextArea textAreaObj)
          Creates an 'Writer' extension that sends its output to a 'TextArea' object.
TextAreaWriter(javax.swing.JTextArea textAreaObj, boolean setupTextObjFlag)
          Creates an 'Writer' extension that sends its output to a 'TextArea' object.
 
Method Summary
 void close()
          Closes the stream; does nothing in this implementation.
 void doSetupTextAreaObj()
          Sets up the text area object to be not-editable while still having a visible caret and text cursor.
 void doWrite(char[] charsArr, int offsetVal, int numChars)
          Sends a portion of an array of characters to the text area.
 void flush()
          Flushes the stream; does nothing in this implementation.
 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(char[] charsArr, int offsetVal, int numChars)
          Sends a portion of an array of characters to the text area.
 
Methods inherited from class java.io.Writer
write, write, write, 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

TextAreaWriter

public TextAreaWriter(javax.swing.JTextArea textAreaObj)
Creates an 'Writer' 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

TextAreaWriter

public TextAreaWriter(javax.swing.JTextArea textAreaObj,
                      boolean setupTextObjFlag)
Creates an 'Writer' 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(char[] charsArr,
                  int offsetVal,
                  int numChars)
           throws java.io.IOException
Sends a portion of an array of characters 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.

Parameters:
charsArr - 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(char[] charsArr,
                    int offsetVal,
                    int numChars)
             throws java.io.IOException
Sends a portion of an array of characters to the text area. Non-printable values are ignored.

Parameters:
charsArr - 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.

flush

public void flush()
Flushes the stream; does nothing in this implementation.


close

public void close()
Closes the stream; does nothing in this implementation.


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.