Table of contents:
The TiffyApplet and SwingTiffy of the TIFFY Toolkit for Java demonstrate, how to implement a modern, platform-independent viewer with printing capabilities for the following formats: TIFF, BMP, GIF, JPG and PNG. It can be used on any system for that a Java capable browser and/or a Java Virtual Machine is available, e.g. Windows, MacOS, Solaris and Linuc.
Using the latest speed optimized JIT Virtual Machine (VM) technology (e.g. jview coming together with MS Internet Explorer), viewers developed using the TIFFY Toolkit for Java catch up with high speed image processors like TIFFY Pro that is available for DOS since several years. The new version now runs as a 32 Bit application, taking advantage of the operating systems graphic subsystems and printer drivers.
A functionally enhanced software that supports for example comfortable preview and slideshow functions as applet and standalone application with its own frame, menu bar etc. is distributed by the author as enduser product TIFFY View. Please refer to the product description to learn more about supported features and unique characteristics of that implementation based on the power of the TIFFY toolkit for Java.
Usable as applet or as standalone application conform to the "100% pure Java concept", TIFFY gives you best safety for your investment in a modern information infrastructure. It extends any Java capable web browser with a powerful component for electronic document management based on standard Internet/Intranet technology .
The TiffyApplet and TIFFY View can be run with VMs conforming to the Java 1.0 standard with partial functionality. To make use of all functions you will need at least a Java 1.4 compatible VM (links to recommended VMs you will find at the installation instructions). SwingTiffy requires at least a Java 1.1 compatible VM in combination with the JFC/Swing class library or a JDK 1.2 compatible VM (supporting Swing by default).To enable also browsers that have no JFC classes preinstalled to run SwingTiffy you might have to place the swing.jar class library on the webserver or in the local classes directory of your browser . If you are using at least a Java 2 (JDK 1.2) compatible VM, no additional Swing/JFC class libraries are required.
The TIFFY toolkit for Java consists of a set of classes for reading image file formats (TIFF, BMP, optionally PNG) additionally to the formats supported in standard Java (JPG and GIF). For enhanced memory management (e.g. keeping image data packed in memory) an extension of the MemoryImageSource class comes with the toolkit which also provides some further functions like fast inversion, rotation, cropping and scaling. A SmartScrollPane class provides comfortable handling of images bigger than the display area and is still compatible with the AWT based on JDK 1.0x. To give your application the capability of printing images, a comfortable PrintDialog is part of the toolkit as well. The classes are available in Java byte code with documentation created with JavaDoc.
To assist you in putting the ends together, a well documented framework of classes (TiffyApplet.java, SwingTiffy.java, ImagePanel.Java, DemoLocal.java, JTiffyToolBar.java and ImageInfo.java) is delivered in source code.
For further information about pricing and licensing the toolkit please refer to http://www.tiffy.de/tiffye/Tiffy.html#prices (English) or http://www.tiffy.de/tiffyd/Tiffy.html#prices (German).
Installation on a web server for use as a Java applet in the Internet/Intranet:
The TiffyApplet and SwingTiffy can be run as "Applet" from an HTML-page. Based on Internet/Intranet-technology a powerful information infrastructure can be set up including file formats like TIFF. All you need is a Java capable web browser on client side like Netscape Navigator (version 3.0 or higher), Microsoft Internet Explorer (version 3.02 or higher).
This is an example, how to include an Applet-Tag into an HTML-page (refer to the section with commandline/parameter options for details):
<p><applet codebase="./" code="TiffyApplet.class" archive="TiffyApplet.jar,TiffyJAI.jar" id="TiffyApplet" width="640" height="400" > <param name="cabbase" value="TiffyApplets.cab"> <param name=Filename value="[image filename]"> <param name=options value="[options]"> Sorry, your browser is not capable of running java applets. </applet> </p>
<param name="useslibrary" value="Tiffy">
Latest versions of Java virtual machines are available from:
Please read the installation instructions in the section 'installation'. Simply open the HTML-Page that contains the applet-tag in your browser. SwingTiffy can be started as standalone application as well (see below).
Optional startup parameters:
The following parameters can be passed to the demo applets on your web page (examples are shown in the section 'installation'):
The SwingTiffy applet can be run standalone (e.g. from the command line) as well. In this case you may specify the parameters listed above without parameter-name.
Example (may depend on the runtime environment):
javaw SwingTiffy /fw images/00441.tif
Instead of an image filename you may specify an URL (starting with http://) as well.
When the TiffyApplet or SwingTiffy is executed using a Java VM version 1.1 or higher, printing is availabe. You may print the image 1:1 with original measurement or the current visible area as well. In a print preview dialog that follows after the operating systems standard dialog you can control the paper settings, size, orientation and printable area.
The examples delivered by the author are digitally signed with a certificate issued by Thawte in order to allow printing from a web browser as well. If you developed your own applets based on the Tiffy libraries you will have to sign your archives (JAR and/or CAB files) with your own certificate to be able to request extended access rights like printing. Class 3 certificates are issued by certificate authorities like Verisign, Thawte. To sign applets for Netscapes "object signing" with the signing tool, please refer to http://developer.netscape.com/docs/manuals/index.html?content=java.html. In order to sign applets for Microsofts "Authenticode", please download Microsofts Java SDK at http://www.microsoft.com/java. You may also find article Q193877 of Microsofts knowledgebase helpful ( http://support.microsoft.com/default.aspx?scid=kb;en-us;Q193877 ).
We experienced different printing qualities depending on the Java Virtual Machine (JVM). Older JVM implementations provide printing from applets only at approx. 72 dpi regardless the resolution of the image and the printer's physical resolution. Since version 2.0.1 TIFFY allows to print at resolutions higher than 72 dpi with Microsofts JVM. The resolution (e.g. 300 dpi) can be selected in TIFFY's print dialog. Be careful with high values as this consumes a lot of system memory during printing. Sun's JDK 1.1.x already printed at full resolution but crashed with huge images. If running in a JDK 1.2 (or higher) environment, Tiffy uses the new print classes (PrinterJob) provided by that implementation which allows also tiled printing (an image can be spread accross several pages) but consumes more memory. If you run very large print jobs with multiple pages, you might run out of memory. For that purpose, Tiffy provides an option in the print dialog "JDK 1.1 compatible printing" (and by providing the parameter /lightprint) which is less memory intensive. Otherwise you should increase heap memory settings (e.g. -mx768M for Java 1 and -Xmx768M for JDK/JRE 1.2 and higher).
For applets running in a web browser you have the option to install a Java Plugin from Oracle (formerly provided by Sun; http://java.sun.com/products/plugin/index.html). Older Plugin implementations required a modification of the HTML-page in order to use the Java Plugin instead of the browsers own Java VM. Sun provided a "HTML-Converter" tool for that purpose.
The button panel provides functions that control the scaling of the image and the display quality. Additional functions are availabe as keyboard commands:
Smooth scaling improves the display quality significantly when line drawings or scanned text documents are scaled down. For black/white (bilevel) images this is the default display setting as TIFFY contains a special high-speed algorithm for antialising bilevel images.
Tiffy supports the display and editing of annotations ("redlining"). As there are several formats in the market for document management systems, we decided to implement our own format as well but with focus on easy conversion to and from other formats. Tiffy uses an XML-based format. Unless you specified the /noannotations parameter, Tiffy will automatically try to load annotations by using the same URL/path as specified for the image but with an filename extension replaced by ".xml". An example (provided together with image 'images/00441.tif') shall give you an impression how it looks like:
<ANNOTATIONS> <PAGE> <TEXT X=0.0415 Y=0.2255 TEXTCOLOR=blue FONT=SansSerif.bolditalic SIZE=0.05>Annotations!</TEXT> <RECTANGLE X=0.3005 Y=0.2859 WIDTH=0.1407 HEIGHT=0.0287 OUTLINECOLOR=none FILLCOLOR=yellow MODE=XOR></RECTANGLE> <POLYGON OUTLINECOLOR=blue FILLCOLOR=orange>0.7158 0.2200 0.6804 0.2200 0.6620 0.2356 0.6620 0.2623 0.7134 0.2623 0.7164 0.2603 0.7193 0.2574 0.7203 0.2538 0.7198 0.2497 0.7187 0.2482 0.7158 0.2455 0.7121 0.2428 0.7087 0.2392 0.7074 0.2347 0.7071 0.2302 0.7082 0.2263 0.7095 0.2243 0.7108 0.2225 0.7126 0.2216 0.7158 0.2200</POLYGON> <TEXT X=0.66 Y=0.2715 TEXTCOLOR=blue FONT=SansSerif SIZE=0.018>Polygon + Freehand</TEXT> <MEMO X=0.64 Y=0.02 WIDTH=0.11 HEIGHT=0.09 OUTLINECOLOR=black FILLCOLOR=yellow TEXTCOLOR=black FONT=Serif.bold SIZE=0.024>Memo (remo- vable ;-)</MEMO> <ELLIPSE X=0.6275 Y=0.1420 WIDTH=0.0476 HEIGHT=0.0341 OUTLINECOLOR=red FILLCOLOR=none></ELLIPSE> <ELLIPSE X=0.395 Y=0.465 WIDTH=0.04 HEIGHT=0.035 OUTLINECOLOR=none FILLCOLOR=magenta MODE=XOR></ELLIPSE> <IMAGE X=0.2994 Y=0.0080 WIDTH=0.2116 HEIGHT=0.0782>images/approved.gif</IMAGE> </PAGE>
Here is a list of supported XML-tags:
(The syntax has changed slightly from version 2.x, e.g. the tags <rect> and <fillrect> are replaced now with <rectangle>. Annotation files created for earlier version are still displayed correctly to keep backward compatibility)
Coordinates are normalized floating values between 0 and 1, where 0 is the left or upper border and 1 is the right or lower boarder of the image. This results in the ability to store annotations independent of the images resoltion. Text is located so that the upper left edge of the bounding box meets the x,y-position given for the text.
The following color attributes are available:
Platform independent (logical) font names are:
Integration into your web application
Tiffy already contains an interactive annotation editor. For an easy integration into your web application, the TiffyApplet (or to be more precise the ImagePanel class) provides an interface to get/set annotations from your own Java classes. Additionally you can link your own annotation saving routine into the Tiffy Applet through the AnnotationSaver Interface. This makes it possible to implement your application specific server upload or download mechanism like WebDav or a multipart http post request or any other transfer mechanims like RMI communication with a database. For details please consult the API documentation for class ImagePanel and interface class AnnotationSaver.
Currently an inversion function and 90, 180 and 270 degree rotations are available. Additionally you can mirror the image horizontally or vertically.
The help button opens a window with a summary of available keyboard shortcuts.
The classes which are available in Java byte code are documented in JavaDoc style here.
To assist you in putting the ends together, a well documented framework of example classes (TiffyApplet.java, SwingTiffy.java, ImagePanel.Java, DemoLocal.java, JTiffyToolBar.java, ImageInfo.java, Gauge.java) is delivered in source code. The basic concept of loading an image is:
You specify the image's filename or URL in imgName or imgURL in class ImageInfo. The further steps can be seen at method loadImage() in class ImagePanel. This method calls setAsynchronousTools() and createImageProducer() of class ImageInfo (as seperate Thread via the run() method). The calling class (which must implement the ImgProdObserver interface like ImagePanel) will be informed that the image loading process has finished (or aborted with an error) through a callback to method imageProducerUpdate().
Alternatively you may use on a lower level the image file decoders (TiffImageProducer, BMPImageProducer and PNGImageProducer) like the standard ImageProducers for GIF and JPEG which are shipped in the standard Java libraries and create standard Image objects through the createImage method. In order to understand the concept of Java Images, ImageProducers and ImageConsumers in more detail, please consult the JDK reference documentation for the standard Java classes.
If you still consider a TIFFY based problem, it might already got an answer in the Tiffy FAQ.
If you want to use the ImagePanel in a swing based application, you can modify the source code of class ImagePanel in order to be used as a lightweight component. Please follow the instructions given in the header of the file ImagePanel.java.
Creating a JBuilder project
When you recompile the source files shipped with the Tiffy Toolkit for Java for example in a development environment like "Borland JBuilder", you may encounter error messages like certain classes of the package com.ms.security or netscape.security not found. When running as browser applet, the TIFFY toolkit classes try to request enhanced privileges (e.g. for printing). The code refers to browser specific packages which must be included in your Java project in the development environment. The Netscape packages can be found in the directory where you installed the Navigator program files in a subdirectory 'java\classes', e.g.
If you installed the MS Internet Explorer including the Microsoft Java Virtual Machine (MS JVM), the MS Security package can be found in the directory java\Classes below the Windows directory, e.g.
If you do not find this file but have the MS JVM installed, please run 'clspack -auto' from the commandline in order to create the file classes.zip.
In order to include the Tiffy class libraries into a JBuilder 5
project, please note also the following hints:
Furthermore JB5 recompiles all classes that are provided as source code with the
Tiffy toolkit. In the classpath created by JB5, these classes are found
before accessing the Tiffy JAR libraries. Now the JDK 1.3 (and higher)
runtime environment recognizes that the applet contains classes which are not signed with the same certificate as the rest of the package
(the new compiled classes are not signed at all).
Step-by-step example how to create a JBuilder project using the Tiffy toolkit libraries:
Forcing a permanent installation of the Java classes with MS Internet Explorer (if you still have installed the MS JVM)
Since version 4.01, MS Internet Explorer contains a package manager which allows to download Java packages to the local client machine. The CAB archive originally delivered with Tiffy is created using Microsofts distribution unit tool (dubuild.exe) which adds an OSD-file to the archive. In order to allow downloading of the required packages, you can add the following parameters inside the applet tag of an HTML-page:
<param name="useslibrary" value="Tiffy">
The first time a user requests the applet page, a dialog will ask the user to allow downloading and installation of a Java package. This package will be stored in %windir%\java\Packages.