The Duke: the Java mascot. ©Sun Corp.

kVnP-Applet: View and point

Currently I offer a tiny applet for viewing a picture and pointing at some targets in it. It is very simple (just 250 lines of code), lightweight and needs no privileges; it runs under Java Version 1.1. Here is an example: Drag the picture or call up a menu by right clicking into the picture.
 
FUNCTION   The applet displays a (background) image, mostly this is a jpg-image. Additionally it can do the following:
  • If the image is larger than the applet window, the user can scroll it by dragging it with the primary mouse button. In this case the mouse pointer has the shape of an east-west-, a north-south- or a four direction cursor, indicating the possible directions.
  • A list of "targets" may be provided in the hosting HTML-page. The user may select one of the targets and the applet displays another image (a pointer image) on top of the background at a location which is specified for this target. The pointer image is usually a gif-image, including some transparent regions.
  • A pointer image may also be caused to be displayed from a JavaScript or another applet in the same page.
  • Optionally a pointer image may be used as a link: When the mouse pointer is in the region covered by the pointer image (including the transparent regions) it becomes a hand-cursor and by clicking the user may display the linked page.
  • The hosting HTML-page may specify a hint-text, which is displayed during the applet's initialisation (when the page is displayed the first time or reloaded); the foreground and the background color of this label may also be specified.
To do list:
  • Currently the background image is centered at startup; in the future the applet shall display a (too large) image at a position to be defined with an optional parameter.
  • The applet shall be extended to display full 360°-panoramas.
 
    A text, a pointer image specification, a location (x, y) and, optionally, an URL is to be specified for each target which may be pointed at. A list of targets may be specified as parameter list for the applet: In this case the user may call a popup menu in the applet and may choose one of the targets (or -no pointer-). Or a target may be specified from a JavaScript program by calling the function pointAt with the parameters text, pointer-file, x and y.
 
<APPLET>-Tag   The <applet ...>-tag of the example mentioned above is similar to the following:
<applet code="kVnP.class" archive="kVnP.jar" width="770" height="400">
<param name="BackGround" value="PLungh1.jpg">
<param name="Target1" value="Piz Grevasalvas=kVnPtr1.gif,108,20">
<param name="Target2" value="Lägh dal Lunghin=kVnPtr1.gif,416,304">
<param name="Target3" value="Piz Surlej=kVnPtr2.gif,532,112">
...and so on; optional:
<param name="TipString" value="text of the tip">;
<param name="TipFgdColor" value="#FFFFFF">;
<param name="TipBgdColor" value="#025E49">;
</applet>
If you store the jar-file in the same directory as the rest of the page the archive-attribute is ok; otherwise you must specify the codepath. The file specifications for the background image and the pointer image(s) are relative to the codepath. So the above example assumes all files (kVnP.jar, PLungh1.jpg, kVnPtr1.gif and kVnPtr2.gif in this case) to be located in the same directory as the HTML-file. It's easy.
The BackGround parameter specifies, as might be expected, the background image.
 
TARGETs   The targets are listed as parameters "Targeti". The numbers i must count from 1 consecutively up; the first "missing" i defines the end of the list. The values of these parameters are of the form
text=pointer file,x,y[,URL]opt.
The text identifies the target; it is displayed in the popup menu and in the status line of the browser (IE has its own ideas on what to display in the status line).
The pointer files specify the pointer image(s). More than one targets may use the same pointer image, but also different pointer images may be used for different targets. x and y are the location of the upper left corner of the pointer image relative to the upper left corner of the background image (x from 0 on ascending to the right, y downwards). As the "hot spot" of the pointer usually is not in the upper left corner of its image some offsets must be taken into account when writing the parameters.
The URL is usually an address, which could also be used as a href in an HTML-anchor element. It is delivered to the browser without change. If the URL is not specified the pointer image isn't a link.
 
JAVA-SCRIPT   The applet exports the function pointAt, which can be called from JavaScript lines:
window.document.applets["name"].pointAt (text, pointer file, x, y);
Use a name in the applet tag (e.g. <applet name="PLungh" code=...) which is used to identify the applet's instance in the applets-array. The parameters are similar to the ones in the Targeti parameters. It is recommended not to use a Targeti-list within the applet tag when targets are "called" from a JavaScript. A link cannot be specified within a JavaScript.
 
TIP TEXT   The applet displays a tip near the bottom of its window which may be specified with the 3 <applet>-parameters TipString, TipFgdColor and TipBgdColor. The tip disappears when the user scrolls the picture or selects a target to be highlighted.
 
DON'T...   The applet is not designed to check for errors which can easily be avoided by the HTML-designer (in fact, some of the errors would not be easy to be detected and would increase the code size). Images, which are not found, are simply not displayed. Thoroughly adjust the applet window's size to the size of the background image; having an image which is smaller than the applet (in any direction) yields ugly gray frames. Making the applet window only few pixels smaller than the background image (in any direction) allows the user to scroll it for some pixels; this makes no sense. Make sure that the pointer images fit completely into the background image.
Do not mix targets by specifying some in the parameter list (in the <applet...>-tag) and specifying the same ones or others via JavaScript-calls. It would confuse the user. Note: A target is checked in the popup menu when it is selected via the popup menu, but not when it is selected via a JavaScript-call.
 
SECURITY   This applet just loads graphics files from the same codepath as it was loaded from and displays them; it asks the browser to display other information. It does nothing else and therefore may run in the sandbox, the most restricted environment. The applet is therefore not signed.
 
I18N   Currently the java archive contains texts in German (de) and English (default); if anybody would like to submit texts in other languages: Please contact me, you would be welcome! I would send you a source file and you translate about 20 short phrases (no Java knowledge necessary) and send it back. It's easy!
 
KNOWN ISSUES   A displayed pointer doesn't print very well (with IE6): The transparent areas are rendered opaque. This is, as I know, not a kVnP-problem, but an IE-problem. Netscape (6.2) doesn't print the Applet at all. Scrolling doesn't work with NS-Comm. 4.7 and I don't know why. The cursor management in the about-window doesn't work properly with IE (Java 1.1), but this is not a severe problem.
 
BUGFIX   April 1st 2005: There was a reasonable Problem with Firefox: Clicking with the right button not only opened the desired target menu of the applet but also the standard context menu of the browser. This bug is fixed now.
 
DOWNLOAD   Here are the ►kVnP.jar file and the ►sources. Version 2.3 of April 1st 2005.
 
COPYRIGHT
NO WARRANTY
  ©2002 Helmut Stettmaier  All rights reserved.
This software is made available under the GNU General Public License. This means you may (and are welcome to) use, redistribute or make additions to this software under certain conditions, which are listed in the ►GNU General Public License definition. This also means that this software comes with ABSOLUTELY NO WARRANTY.
 
   
2005/04/01
  ►Homepage