Class FileViewer

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible

public class FileViewer extends JPanel implements Observer
UI for viewing the contents of very large files efficiently. Pieces of a file are read in using the ChunkReader, which are then displayed line-by-line in FVTable. As users scroll up/down, new sections of the file are swapped in as appropriate.

Notes:

  1. The viewer consists of a simple JTable and a custom JSlider. The table displays lines of text described by Chunk objects. The number of chunks visible at any given time is restricted by the ChunkModel.MAX_VISIBLE_CHUNKS property.
  2. Because only part of the file is loaded into the viewable table at any given time, the built-in scrollbar associated with the scroll pane cannot be used. We want the scroll bar maximum size to reflect the total size of the file, not just what's in view at the time. So we use our own slider implementation (FVSlider) and manage the size/position ourselves. If you're asking why a JSlider is used instead of a JScrollPane, it's because the former is more easily configuration for what we need.
  3. Communication between modules (the table, the slider, the viewport utility, etc...) is done almost exclusively via events, using the custom FVEvent framework.
See Also:
  • Constructor Details

    • FileViewer

      public FileViewer(ChunkReader reader, ChunkModel model, FVEventListener eventListener) throws IOException
      Constructor.
      Parameters:
      reader - the log file reader
      model - the reader's data model
      eventListener - the event listener; the hub through which this API communicates
      Throws:
      IOException - if there is an issue reading the log file
  • Method Details