jfig.utils
Class PresentationBuilder

java.lang.Object
  extended byjfig.utils.PresentationBuilder

public class PresentationBuilder
extends java.lang.Object


Field Summary
(package private)  java.util.Vector allFiles
           
(package private)  java.io.File baseDir
           
(package private)  boolean debug
           
(package private)  java.util.Vector figFiles
           
(package private)  java.util.zip.ZipOutputStream ZOS
           
 
Constructor Summary
PresentationBuilder()
           
 
Method Summary
 void addFigFilesToZip()
           
 void closeZipOutputStream()
           
 void copyAllFilesFromZipArchive(java.lang.String filename)
          copy all files from the JAR/ZIP archive "filename" to our ZipOutputStream.
 void copySingleFile(java.lang.String zipname, java.lang.String filename)
          copy a single file "filename" under the new name "zipname" to the ZipOutputStream.
 void createMainClassManifestEntry()
          add a default META-INF/MANIFEST.MF manifest file with a Main-Class: jfig.gui.PresentationViewer attribute to our ZipOutputStream.
 void createZipOutputStream(java.lang.String filename)
           
 void findAllFiles(java.lang.String dirname)
           
 void findAndAddFiles(java.lang.String dirname)
           
 void findFigOrImageFiles(java.io.File directory)
          search all FIG (.fig) and image (.gif, .jpg, .png, .xbm) files in the specified 'directory' and its subdirectories.
 void findPSFiles(java.io.File directory)
          search all Postscript (.ps, .eps) files in the specified 'directory' and its subdirectories.
 java.lang.String generateJpt()
          generate jpt index data from the contents of the figFiles vector.
 java.lang.String generateTeX()
          generate a TeX slidelist for 'skript.tex' from the figFiles vector, which, despite its name, should contain a list of Postscript .ps files created by calling findPSFiles.
 java.lang.String getChapterName(java.io.File file)
          try to construct a useful JPT chapter name from a given filename.
 java.lang.String getRelativeFilename(java.io.File file)
           
static void main(java.lang.String[] args)
          main: parse the command line arguments, then do the work.
 void setBaseDir(java.io.File _dir)
           
static void usage()
          print a usage message, then exit
 void writeJptZipEntry()
          this method writes the list of all slides in this presentation into the file "00presentation.jpt", then adds this file to the ZipOutputStream.
 void writeZipEntry_OLD(java.lang.String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZOS

java.util.zip.ZipOutputStream ZOS

baseDir

java.io.File baseDir

figFiles

java.util.Vector figFiles

allFiles

java.util.Vector allFiles

debug

boolean debug
Constructor Detail

PresentationBuilder

public PresentationBuilder()
Method Detail

createZipOutputStream

public void createZipOutputStream(java.lang.String filename)
                           throws java.lang.Exception
Throws:
java.lang.Exception

closeZipOutputStream

public void closeZipOutputStream()
                          throws java.lang.Exception
Throws:
java.lang.Exception

setBaseDir

public void setBaseDir(java.io.File _dir)

findFigOrImageFiles

public void findFigOrImageFiles(java.io.File directory)
                         throws java.lang.Exception
search all FIG (.fig) and image (.gif, .jpg, .png, .xbm) files in the specified 'directory' and its subdirectories.

All found FIG files are added to the figFiles Vector, which is later used to construct the .jpt index file. Also, all FIG files and all image files are added to the allFiles Vector, which is later used to select the files to be included in the output JAR archive.

Throws:
java.lang.Exception

findAndAddFiles

public void findAndAddFiles(java.lang.String dirname)
                     throws java.lang.Exception
Throws:
java.lang.Exception

findAllFiles

public void findAllFiles(java.lang.String dirname)
                  throws java.lang.Exception
Throws:
java.lang.Exception

findPSFiles

public void findPSFiles(java.io.File directory)
                 throws java.lang.Exception
search all Postscript (.ps, .eps) files in the specified 'directory' and its subdirectories.

All found files are added to the figFiles Vector.

Throws:
java.lang.Exception

writeZipEntry_OLD

public void writeZipEntry_OLD(java.lang.String filename)
                       throws java.io.IOException
Throws:
java.io.IOException

addFigFilesToZip

public void addFigFilesToZip()
                      throws java.lang.Exception
Throws:
java.lang.Exception

getRelativeFilename

public java.lang.String getRelativeFilename(java.io.File file)

getChapterName

public java.lang.String getChapterName(java.io.File file)
try to construct a useful JPT chapter name from a given filename. First, this method strips of the filename, then all root directories except the last subdirectory, which is then used and returned as the chapter name. If no subdirectories are found, this method returns the empty "" String.


writeJptZipEntry

public void writeJptZipEntry()
                      throws java.lang.Exception
this method writes the list of all slides in this presentation into the file "00presentation.jpt", then adds this file to the ZipOutputStream. public void writeJptZipEntry() throws Exception { String s = generateJpt(); StringBufferInputStream SBIS = new StringBufferInputStream( s ); ZipEntry ZE = new ZipEntry( "00presentation.jpt" ); ZOS.putNextEntry( ZE ); byte buffer[] = new byte[1024]; int length = 0; while( (length = SBIS.read( buffer, 0, buffer.length )) >= 0) { ZOS.write( buffer, 0, length ); } ZOS.closeEntry(); }

Throws:
java.lang.Exception

generateJpt

public java.lang.String generateJpt()
generate jpt index data from the contents of the figFiles vector.

Instead of directly writing to some OutputStream, this method creates and returns a (possibly long) String with the complete jpt file data.

This method tries to be clever and will generate chapter jpt entries for each subdirectory with .fig files.


generateTeX

public java.lang.String generateTeX()
generate a TeX slidelist for 'skript.tex' from the figFiles vector, which, despite its name, should contain a list of Postscript .ps files created by calling findPSFiles.


copyAllFilesFromZipArchive

public void copyAllFilesFromZipArchive(java.lang.String filename)
                                throws java.io.IOException
copy all files from the JAR/ZIP archive "filename" to our ZipOutputStream. This method prefers simplicity over performance, so we just decompress all entries of the source archive, then compress them back...

Throws:
java.io.IOException

copySingleFile

public void copySingleFile(java.lang.String zipname,
                           java.lang.String filename)
                    throws java.io.IOException
copy a single file "filename" under the new name "zipname" to the ZipOutputStream.

Throws:
java.io.IOException

createMainClassManifestEntry

public void createMainClassManifestEntry()
                                  throws java.io.IOException
add a default META-INF/MANIFEST.MF manifest file with a Main-Class: jfig.gui.PresentationViewer attribute to our ZipOutputStream.

Throws:
java.io.IOException

usage

public static void usage()
print a usage message, then exit


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
main: parse the command line arguments, then do the work.

Currently, this class supports three different uses:

Start the program without arguments for a detailed usage() message.

Throws:
java.lang.Exception