|
Steps adding a new file reader/writer
|
< < |
- Implement
shiva.io.ReaderWriter.
- Create a
shiva.io.DocFilter. The easiest way is using the following template.
|
> > |
- Implement
shiva.io.ReaderWriter.
- Create a
shiva.io.DocFilter. The easiest way is using the following template.
|
|
/** file filter description */
private final static String m_descript = "Analyze(tm) 7.5";
/** file extensions for file filter */
|
< < |
private final static String[] m_exts = { ".hdr", ".img", ".img.gz", ".img.z" };
|
> > |
private final static String[] m_exts =
{ ".hdr", ".img", ".img.gz", ".img.z" };
|
|
/** we only need one instance running */
private final static AnalyzeReader m_reader = new AnalyzeReader ();
/** the file filter */
|
< < |
private final static DocFilter m_filter = new DocFilter (m_reader, VolumeBuffer.class, m_descript, m_exts);
|
> > |
private final static DocFilter m_filter =
new DocFilter (m_reader, VolumeBuffer.class, m_descript, m_exts);
|
|
|
< < |
To create a fansier shiva.io.DocFilter, check source code for
|
> > |
To create a fancier DocFilter, check source code for
|
|
shiva.plugins.volumefilefilter.VolumeFileFilter.
|
< < |
- Register the reader/writer to
shiva.docManager:
|
> > |
- Register the reader/writer to
shiva.Main.docManager:
|
|
DocManager manager = Main.docManager;
manager.addReadFilter (m_filter);
manager.addWriteFilter (m_filter);
|
< < |
Note that not all shiva.io.ReaderWriter have to implement both reader and writer.
|
> > |
Note that not all ReaderWriters have to implement both reader and writer.
Creating a ReaderWriter for VolumeBuffer.class
Besides the requirement above, file reader is welcome to provide a mechanism pre-viewing the properties
of an image volume input file. To do so, the reader class needs to implement shiva.io.VolumeInfoReader.
For specific mechanism of how shiva.io.VolumeInfoReader works, see shiva.plugins.volumepreview.VolumePreview.
In general, VolumeBuffer.class readers should internally have a class that implements shiva.interfaces.VolumeReader.
This is not required, but a recommandation. It simplifies the actual reader/writer class implementation.
Show Progress
In general, most image volumes are fairly big and take a while to load. It is desirable to show the progress bar while loading. Shiva provides two ways displaying progress.
- The input stream based progress is useful for reading large files through stream. The following example
shows how typically it is used. When the inputstream is closed, the progress bar also hides.
InputStream is = new FileInputStream (imgName);
InputStreamProgress progress = new InputStreamProgress (is);
progress.getProgress ().setTitle (file.getPath ());
is = progress;
try
{
// some code
}
finally
{
is.close ();
}
- For more control, one can use the following way:
Progress prog = shiva.Main.progressReport.newProgress(0, 0);
prog.setTitle(file.getPath());
try
{
// some code
}
finally
{
prog.close ();
}
and manually update the progress min/max and hide it.
When multiple threads requests progress, their progress bars will be stacked.
|
|
|