com.elixirtech.glint.viewer
Interface IViewerCanvas

All Superinterfaces:
com.elixirtech.ui.INavigation
All Known Implementing Classes:
GlintCanvas, TextCanvas, ViewerCanvas

public interface IViewerCanvas
extends com.elixirtech.ui.INavigation

IViewerCanvas is the viewing interface for graphical data. Implementations will support the reading and display of data that conforms to a specific mime type. The model (the data to be viewed) may be loaded from an object, a file or a stream. This is a paged viewer, so each model may contain more than one page and the interface allows a navigator to control what page is shown.


Method Summary
 void addChangeListener(javax.swing.event.ChangeListener cl)
          Register interest in changes to the viewer.
 javax.swing.JComponent getCanvasComponent()
          Get the component that shows the view.
 int getPageCount()
          Get the number of pages in the model
 int getPageNo()
          Get the current page number
 void read(java.io.File f)
          Read the model from a file
 void read(java.io.InputStream is)
          Read the model from a stream
 void removeChangeListener(javax.swing.event.ChangeListener cl)
          Remove the change listener
 void setObject(java.lang.Object o)
          Set an object as the model for the viewer.
 void setPageNo(int no)
          Show a specific page (in the range 1<=no<=getPageCount())
 void update()
          Recalculates the dimensions of the view and repaints.
 
Methods inherited from interface com.elixirtech.ui.INavigation
first, gotoPage, last, next, previous
 

Method Detail

addChangeListener

void addChangeListener(javax.swing.event.ChangeListener cl)
Register interest in changes to the viewer. This includes changes to the current page

Parameters:
cl - The change listener

removeChangeListener

void removeChangeListener(javax.swing.event.ChangeListener cl)
Remove the change listener

Parameters:
cl - The change listener

setObject

void setObject(java.lang.Object o)
Set an object as the model for the viewer. The kind of object supported varies with each implementation of the interface

Parameters:
o - The object to view

read

void read(java.io.File f)
          throws java.io.IOException
Read the model from a file

Parameters:
f - The file to read
Throws:
java.io.IOException - if the file is invalid for this viewer, or doesn't exist

read

void read(java.io.InputStream is)
          throws java.io.IOException
Read the model from a stream

Parameters:
is - The input stream
Throws:
java.io.IOException - if the stream is invalid for this viewer

update

void update()
Recalculates the dimensions of the view and repaints. This should be called after any changes to the model, eg. calls to setObject(...) or read(...) when ready to display.


getPageCount

int getPageCount()
Get the number of pages in the model

Specified by:
getPageCount in interface com.elixirtech.ui.INavigation
Returns:
The number of pages in the model

setPageNo

void setPageNo(int no)
Show a specific page (in the range 1<=no<=getPageCount())

Parameters:
no - The page to show (1-based)

getPageNo

int getPageNo()
Get the current page number

Specified by:
getPageNo in interface com.elixirtech.ui.INavigation
Returns:
The current page (in the range 1<=no<=getPageCount())

getCanvasComponent

javax.swing.JComponent getCanvasComponent()
Get the component that shows the view. Wrap this with a scrollpane if you want it scrollable.

Returns:
the component that shows the view