TiffyApplet
/ SwingTiffy Demo
|
filename=<URL(s) of the image file(s)>
|
options=<view-options, commands>
|
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 (using Microsofts Java VM 'jview' which can be replaced e.g. by 'java' or 'jre' depending on the runtime environment you are using):
jview SwingTiffy /fw images/00441.tif
If you are using a VM version JDK 1.1 or earlier, please make sure that the CLASSPATH environment variable contains also the path to JFC/Swing user interface classes version 1.1.x (e.g. 'swing.jar') or add the library path as classpath-commandline parameter for your VM loader. An example (again using Microsofts 'jview') could look like:
jview cp:p swing.jar 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). At the time of this writing, many applets provide printing with Microsofts JVM (JView and MS Internet Explorer) and Sun's JDK 1.2.2 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 printed at full resolution but crashed with huge images. Sun's JDK 1.3.0-C prints at high resolution but sometimes the images are split and/or truncated due to a bug in that implementation. Later JDK/JRE versions should do well. Very good printing results with standalone applications were achieved with IBM's JDK 1.1.8 (http://www.ibm.com/java). 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 Sun (use at least release 1.3 because 1.2.2 also has a limited printing quality; http://java.sun.com/products/plugin/index.html). in this case the HTML-page needs to be modified in order to use the Java Plugin instead of the browsers own Java VM. Sun provides 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:
Scaling functions | key / mouse action | |
---|---|---|
standard 1:1 view | 1 | |
proportional scale to window | 0 | |
scale to window | ||
zoom in | + | |
zoom out | - | |
zoom to user selected area | draw rectangle with the mouse | |
smooth scaling (with antialiasing) | # | |
P | ||
Page control | key | |
page forward (multi page TIFF file) | > | |
page back (multi page TIFF file) | < | |
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.
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>
</ANNOTATIONS>
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.
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.
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.
c:\WinNT\java\Classes\classes.zip
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:
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.1.5 is the current version of
the applet, you would replace this placeholder by "3,1,5,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.