WebÞing

HyperLens

Lens API

A HyperLens Lens class serves to display, and optionally to edit or otherwise manipulate, data in a HyperLens lens. A lens class extends class webthing.hyperlens.lens.gLens, or some subclass of it.

A lens is always under the control of the user, who can open, close, move and resize it. These functions, together with the initial loading and management of the lenses, are managed by HyperLens. The Lens class

Required Methods

These methods must be implemented by every Lens class

public abstract void init(String name, StringTokenizer st, Image baseimg)

init() is called when the lens is first loaded, and is used to initialise.

  • name is the name of the lens. It can be ignored for most lenses, but may be required if, for example, your lens offers its own editor, or a complex printout function.
  • st contains the lens parameters, from the HyperLens Definition File. The format of the parameters is defined by each Lens class, and may contain a complete definition of the Lens (e.g. where the lens is a simple filter on the base image), or one or more filename or URL from which init() will read the definition.
  • baseimg is the HyperLens Base image on which the lens is displayed. Where the lens is not a filter, baseimg may normally be ignored.

public abstract synchronized void validate()

Analagous to the validate() method of AWT components. Called when the lens is initialised, and each time it is moved or resized. Displays the lens contents within the lens.

Commonly used methods

public synchronized void invalidate()

Analagous to AWT invalidate(). Called asynchronously while the lens is being moved or dragged, and enables it to update the contents displayed in real time.

public void save() throws Exception()

Save the lens's contents. This does not include the lens definition (which is managed by the Editor), but is required to save any external resources, such as Images or Object Files, used by the Lens.

public int printkey(Graphics g, int x, int y, int w)

Called during a HyperLens printout, to print any textual information about the lens (for example, a key to colours/classifications in a lens showing a classification). Not normally required.

  • g Graphics context for printing
  • x, y Coordinates of top-left of printing area available to print in
  • w Width (pixels) of area available to print in
  • Return value - the actual vertical space used by the lens to print in.

public boolean hasTools()

Return true if the lens has associated tools (typically a window that pops up when the lens is opened). Default: false.

public dFrame getTools()

A method to create any associated tools. Should get called if and only if hasTools() returns true.

public void Edit(gFrame f)

Open an Editor for the Lens. The Editor must be implemented by the Lens class. If this method is not defined, users will get a default "No editor for this class" if they select Edit.

[About] [Tutorial] [Manual] [Applications] [API] [Applet] [Download]