com.ccg.swing
Class TailViewer

java.lang.Object
  extended by com.ccg.swing.TailViewer

public class TailViewer
extends Object

Swing tool capable of browsing the contents of large ASCII text files.

This class helps one construct a Swing component that can be used to efficiently view (not edit) VERY large ASCII files. To use this class, follow these basic guidelines:

Take a look at Tail.java to see how to make use of this class.

This object will take care of the following for you:

It should be noted, that this object does not automate the process of checking for file updates (it just receives notifications when a update occurs). You will probably want to use the setUpdateMillis method - or periodically invoke the tailUpdate method on the FileLineIndex object you associate with this object.

In addition, there is a static main method provided (mainly for test purposes), but it allows you to try it out (so you can see how the component behaves). You run the test program in the following manner:

 java com.ccg.swing.TailViewer FILE
 

If the FILE specified is modified (while you are viewing it), your display should automatically update to the new end of the file (unless you've started scrolling - or paused the display).

Since:
1.0
Version:
$Revision: 1.5 $
Author:
$Author: pkb $
See Also:
Tail.java, FileLineIndex

Constructor Summary
TailViewer()
           
 
Method Summary
 JComponent getComponent()
          Get the visible JComponent which allows the user to view the displayed area.
 FileLineIndex getFileLineIndex()
          Get the indexed file to view in the component.
 long getLineCount()
          Get the number of lines available to be shown (number of lines in the file).
 boolean isLineInfoShown()
          Indicates whether tool tips are shown to indicate the position in the file.
 boolean isPaused()
          Is the display in a "paused" state set?
static void main(String[] args)
          Main entry point into the test application.
 void setFileLineIndex(FileLineIndex val)
          Set the indexed file to view in the component.
 void setLineInfoShown(boolean val)
          Set tool tips shown to indicate the position in the file?.
 void setPaused(boolean val)
          Set the display in a "paused" state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TailViewer

public TailViewer()
Method Detail

setFileLineIndex

public void setFileLineIndex(FileLineIndex val)
Set the indexed file to view in the component.

Parameters:
val - The FileLineIndex value to assign (must NOT be null).

getFileLineIndex

public FileLineIndex getFileLineIndex()
Get the indexed file to view in the component.

Returns:
Current FileLineIndex value assigned - will be null until set.
See Also:
setFileLineIndex(com.ccg.io.FileLineIndex)

getLineCount

public long getLineCount()
Get the number of lines available to be shown (number of lines in the file).

Returns:
The number of lines availble in the file.
Since:
1.0

setPaused

public void setPaused(boolean val)
Set the display in a "paused" state. This method is used to control whether the display automatically updates to the live end of the

Parameters:
val - Pass true if you want to "pause" the text displayed, pass false if you want to return to a "live" update of the tail of the file.
See Also:
isPaused()

isPaused

public boolean isPaused()
Is the display in a "paused" state set?

Returns:
Current boolean value assigned.
See Also:
setPaused(boolean)

setLineInfoShown

public void setLineInfoShown(boolean val)
Set tool tips shown to indicate the position in the file?.

Parameters:
val - New boolean value to assign.
See Also:
isLineInfoShown()

isLineInfoShown

public boolean isLineInfoShown()
Indicates whether tool tips are shown to indicate the position in the file.

Returns:
Current boolean value assigned.
See Also:
setLineInfoShown(boolean)

main

public static void main(String[] args)
Main entry point into the test application.

This method allows you to try the class out from the command line (to see how it behaves). To use, invoke from the command line via:

 java com.ccg.swing.TailViewer FILE
 

If the FILE specified is modified (while you are viewing it), your display should automatically update to the new end of the file (unless you've started scrolling - or paused the display).

Parameters:
args - Array of command line arguments.

getComponent

public JComponent getComponent()
                        throws IllegalStateException
Get the visible JComponent which allows the user to view the displayed area.

Returns:
The JComponent value assosicated with the object.
Throws:
IllegalStateException - If you forget to set the file to be viewed prior to invoking this method.


Copyright 1998-1998-2006 null. All Rights Reserved.