TiffyApplet / SwingTiffy Demo
for TIFFY Toolkit for Java

Version 3.3.0

Table of contents:

Introduction / Download / Licensing

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.

Download an English trial version of the TIFFY Toolkit for Java here.
Download a German trial version of the TIFFY Toolkit for Java here.

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).

Back to TOC


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>

Note 1:
Some appletviewers (e.g. MS IE) support percentage values for the width and height attributes. If the applet is executed from a path different from the current active directory, please specify the codebase-attribute according to that location. The parameter "cabbase" is only required if you want to use the digitally signed version of that applet for Microsoft Internet Explorer.

Note 2:
For some special functions like decoding of LZW encoded TIFF images Tiffy uses the Java Advanced Imaging (JAI) libraries. These are automatically postinstalled when the Tiffy Applet is executed the first time and when the libraries were not already preinstalled earlier. On some operating systems / Java runtime environments you may need administrative permissions in order to install the library extensions. For more information about JAI please refer to http://jai.dev.java.net. If you want to suppress the postinstallation of JAI libraries, please remove the TiffyJAI.jar attribute in the applet tag.

Note 3:
In order to allow a permanent download of the applet class packages with MS Internet Explorer (with MS JVM installed), you may add the following parameter lines inside the applet tags:

<param name="useslibrary" value="Tiffy">
<param name="useslibrarycodebase" value="Tiffy.cab">
<param name="useslibraryversion" value="[AppletVersionCommaSeparated]">
where [AppletVersionCommaSeparated] is to be replaced by the current version of the applet. For example if 3.3.0 is the current version of the applet, you would replace this placeholder by "3,3,0,0".

Latest versions of Java virtual machines are available from:

Back to TOC

Starting the Applet, Command Line Options

Using TiffyApplet and SwingTiffy as applet in the Internet/Intranet:

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).

Applets are usually running in a "sandbox" that prohibits access to local ressources. To enable file access and printing for applets please refer to the section file and printing functions.

Optional startup parameters:

The following parameters can be passed to the demo applets on your web page (examples are shown in the section 'installation'):

filename=<URL(s) of the image file(s)>

The program will start directly showing the given image file on the screen. You may specify a sequence of filenames separated by semicolons (';'). If SwingTiffy is runing standalone, names of files in your filesystem can be specified as well.

If the image data are generated dynamically (e.g. using a CGI-/ASP-/JSP-script) by a HTTP GET request, please make sure that the URL contains a suffix according to the file type of the expected image data. This can usually be done by adding a parameter separator char (usually the question mark for GET requests) and a further parameter (e.g. "suffix=.jpg") which should be ignored by the server side script. The client applet will use this suffix in order to detect the format of the image data following to that request.

If you want to load images from a file share, you can specify either relative paths or a filename parameter value like "file:///D:/Tiffy/images/00441.tif" (in this case for an image on drive D: in directory \Tiffy\images. This should work for UNC paths as well.

options=<view-options, commands>

The following options are supported:

/fh      : fit horizontal in window
/fw      : fit in window completely (default)
/f1      : start with 1:1 scaling
/i       : inverted view
/nogauge : do not show gauge (progress indicator) during image loading
/noannotations : disable automatic loading of annotations
/nothumbnails  : disable thumbnail preview catalog
/noprint : disable printing
/noautorotate  : disable automatic rotation of images while printing
/save    : enable saving (downloading) of images (disabled by default)
/r<n>    : rotate multiples of 90 degree (1=90 deg., 2=180 deg., 3=270 deg.)
/page<p> : Page number for multi document images,
           where <p> is the page number to view or
           slide index in a sequence given as filenames
/print   : Load image and open print dialog immediately;
           (closes standalone application after printout automatically)
/lightprint : printmode consuming less memory (recommended for printing multiple pages)
/heavyprint : force newer printer classes (needs Java 1.2 or higher, allows tiled printing)
/quickprint : prints imediately with standard settings without showing TIFFY's print dialog
/150dpi  : sets default print resolution to 150 dpi (instead of 300 dpi)
/smooth  : activate smooth scaling (antialiasing) already at startup
/slidedelay<n> : switch to automatic sliding mode where each image is displayed n milliseconds
/blend   : activate blending (fading) between images (default for fullscreen slidehow mode)
/bgcolor<r,g,b> : Set background color of image display area as specified
                  with red, green and blue componen values (0..255)
/buttons[...]   : Controls visibility of toolbar buttons, e.g. /buttons1010 hides 2nd and 4th button
                  (hint: seperators are counted as well. Remaining buttons will be visible by default)
/bottomtoolbar  : shows an alternate, modern style toolbar on the bottom

If more than one option is passed using the "option"-prefix, the parameters must be separated by blanks and all together enclosed with quotes.

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.

Back to TOC

Printing Functions

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 demo applets come with a digital (class 3) signature from the author for Netscape's code signing which allows the applet to request privileges for local printer access. The certificate was issued by Thawte and can still be used for current JREs.
  • For Microsoft's Internet Explorer the applet contains a MS Authenticode signature in order to allow the applet to acces the printer.

Back to TOC

View Functions

The button panel provides functions that control the scaling of the image and the display quality. Additional functions are availabe as keyboard commands:

Scaling functions   key / mouse action
standard 1:1 view   1
proportional scale to window   0
zoom in   +
zoom out   -
zoom to user selected area   draw rectangle with the mouse
Fullscreen / Slideshow   F
smooth scaling (with antialiasing)   #
print   P
Page control   key
page forward   >
page back   <
toggle auto-play / pause   spacebar
Scrolling functions   key
pan visible area   cursor keys
move visible area pagewise      ScrUp/ScrDown, Ctrl+cursor keys
Jump to top / bottom / left / right margin   Ctrl+ScrUp/Down, Pos1/End

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.

Back to TOC


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:

    <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
    <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 +
    <MEMO X=0.64 Y=0.02 WIDTH=0.11 HEIGHT=0.09 OUTLINECOLOR=black 
          FILLCOLOR=yellow TEXTCOLOR=black FONT=Serif.bold
vable ;-)</MEMO>
    <ELLIPSE X=0.6275 Y=0.1420 WIDTH=0.0476 HEIGHT=0.0341 
    <ELLIPSE X=0.395 Y=0.465 WIDTH=0.04 HEIGHT=0.035 
    <IMAGE X=0.2994 Y=0.0080 WIDTH=0.2116 

Here is a list of supported XML-tags:

Tagname Description Attributes Tag content
<annotations> document tag   embeds the annotations
<page> page separator. Separates elements for multi-page images (e.g. allowed for TIFF format)    
<text> simple text x-position (x=...), y-position (y=...), character size (size=...), optional color (textcolor=...) and font / style (font=...). The style (bold / italic / bolditalic) is appended to the font name separated with a dot. Optionally the element can be painted in XOR mode (mode=XOR) text (also several lines of text possible). The linebreaks contained in the XML file will be used for display
<memo> text "memo"-style x-position (x=...), y-position (y=...), width (width=...) and height (height=...) of the bounding "memo paper". Optional text color (textcolor=...), fill color (fillcolor=...) and border color (outlinecolor=...). Character size (size=...) and optional font / style (font=...). text (also several lines of text possible). The linebreaks contained in the XML file will be used for display
<rectangle> rectangle x-position (x=...), y-position (y=...), width (width=...), height (height=...). Optional fill color (fillcolor=...), border color (outlinecolor=...) and XOR paint mode (mode=XOR).  
<polygon> filled polygon optional fill color (fillcolor=...), border color (outlinecolor=...) and XOR paint mode (mode=XOR). x- and y-coordinates of the points separated by blanks
<ellipse> oval x-position (x=...), y-position (y=...), width (width=...) and height (height=...) of the bounding rectangle, optional fill color (fillcolor=...), border color (outlinecolor=...) and XOR paint mode (mode=XOR).  
<image> image to be used as overlay (e.g. as stamp). All Tiffy supported file formats are allowed. Transparency (e.g. in GIF images) is supported
x-position (x=...), y-position (y=...), width (width=...) and height (height=...)
URL for the image file. A relative path (relative to the document base) can be used. Alternatively you can specify a http:,  https: oder file: URL. The file: URL allows loading of images stored in the local file system or from a file server. The image date itself are not embedded in the annotation file, just the link. Display will work later only if the image file is still available in the specified location.

(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:
red, green, blue, cyan, magenta, yellow, pink, orange, lightgray, darkgray, black, white

Platform independent (logical) font names are:
Monospaced, Serif, SansSerif, Symbol
You may also use font face names but it is not guaranteed that these are available across all platforms. Additionally the font styles bold, italic and bolditalic are supported. The style can be appended to the font name separated with a dot.

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.

Back to TOC


Currently an inversion function and 90, 180 and 270 degree rotations are available. Additionally you can mirror the image horizontally or vertically.

Back to TOC

Getting Help

The help button opens a window with a summary of available keyboard shortcuts.

Back to TOC

Developer Documentation / FAQ

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.

c:\program files\Netscape\Communicator\Program\java\classes\java40.jar

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:
If you compile based on the classes given with the ZIP archive, JB5's dependency check will first delete all class files and start recompiling afterwards. Now it finds only some java source files and fails to compile them as other required classes are not found anymore.
Solution: Add a library (e.g. named TiffyLib inside JBuilders library management) containing the paths to TiffyApplet.jar and SwingTiffy.jar to the project.

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).
Solution: Backup the original JAR files of the Tiffy library and remove the signing-information from the jar archives. Inside the archive, this information is stored in the files manifest.mf, zigbert.rsa and zigbert.sf. You can remove this e.g. using WinZip which can open the jar files as well. Alternatively you can unpack the jar archives using Sun's jar tool and create new (unsigned) jar archives.

As any modification to the applet code requires signing the new code with your own certificate anyway, stripping the original signing information from the classes is not a problem - it is mandatory.

Step-by-step example how to create a JBuilder project using the Tiffy toolkit libraries:

  1. Make a backup copy of library files TiffyApplet.jar and SwingTiffy.jar
  2. Delete the signing information (files the files manifest.mf, zigbert.rsa and zigbert.sf) from both libraries. The libraries can be opened e.g. using WinZip or extracted and re-created using the JAR tool from the JDK.
  3. Open a new project in JBuilder.
    • Give it a project name as you like (e.g. MyTiffyApplet)
    • As root path specify the directory where you unzipped the toolkit (e.g. c:\java\tiffytoolkit)
    • Leave the field 'Project directory name' empty or uncheck the checkbox 'Project directory is parent to source and output directories'
    • Leave the fields 'Source directory name' and 'Output directory name' empty
    • As 'Required Libraries' add a new library (e.g. called "TiffyLib"). Add new library paths to the modified JAR archives TiffyApplet.jar and SwingTiffy.jar, Microsofts classes.zip found in C:\WinNT\java\classes (created with 'clspack -auto'; path may vary depending on your Windows installation) and Netscape's java40.jar found in c:\program files\Netscape\Communicator\Program\java\classes\java40.jar (path may vary depending on your Netscape installation).
  4. Add the example file "TiffyApplet.html" to the project
  5. Right-click the file TiffyApplet.html in order to carry out a test compilation. If JBuilder throws lots of errors during the compilation, try compiling a second time - now it should work (don't ask me why...).

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">
<param name="useslibrarycodebase" value="Tiffy.cab">
<param name="useslibraryversion" value="[AppletVersionCommaSeparated]">
where [AppletVersionCommaSeparated] is to be replaced by the current version of the applet. For example if 3.3.0 is the current version of the applet, you would replace this placeholder by "3,3,0,0". For details regarding distribution units, please consult Microsofts SDK documentation using the key word 'dubuild'.

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.

Back to TOC

Art&Computer Hackbarth
Hellgrund 84
D-22880 Wedel (Germany)
TEL: +49 (0)1803 551884338
FAX: +49 (0)1803 551884339
E-Mail: info@tiffy.de
URL: http://www.tiffy.de

Copyright 2010 H.Hackbarth. All rights reserverd.
Technical details are subject to change without prior note.
The Microsoft Logo and Internet Explorer are registered trademarks of Microsoft Inc. Java (TM) is a registered trademark of Oracle (formerly Sun Microsystems Inc). All other products and companies listed are trademarks or registered trademarks of the corresponding licensee.