HwVisualUserPlugIn Class


A plug-in for a visual module must also subclass methods of the HwVisualUserPlugIn class, specified in the source file HwVisualUserPlugIn.java.

package kinetix.hyperc1.runtime;

import kinetix.hyperc1.runtime.*;

import java.awt.Rectangle;
import java.awt.Graphics;
import java.awt.Event;
import java.awt.Point;


public class HwVisualUserPlugIn extends HwVisualPlugIn
{
	public boolean piIsVisual()
		{
		return true;
		}
Description: This class implements the plug-in�s visual interface. You need to implement only those methods that are critical to the operation of your plug-in. For example, a mouse move might mean nothing to your plug-in but a mouse click would be significant. Your plug-in package can include other classes.

See "Java Plug-In Code" for an overall description of the interface to Hyperwire.

piEventAboutToShow

Prototype:

public void piEventAboutToShow(int why)
	throws HwException;

Parameter:
why The reason the plug-in is becoming visible.

Description: The Hyperwire runtime calls this method just before it makes the plug-in visible. This occurs when the entire containment chain from the plug-in module up to the applet becomes visible. "Visible" in this case is a logical notion: the module might actually be clipped, obscured by another window, and so on.

The why parameter indicates the reason for the state change:
why == BasicRunPlugIn.E_THIS The plug-in is being turned on.
why == BasicRunPlugIn.E_ANCESTOR An ancestor of the plug-in is being turned on.
why == BasicRunPlugIn.E_ROOT The root—that is, the applet or window—is being turned on.

piEventAboutToHide

Prototype:

public void piEventAboutToHide(int why)
	throws HwException;

Parameter:
why The reason the plug-in is being hidden.

Description: The Hyperwire runtime calls this method just before it hides the plug-in. This occurs when the module itself is hidden or when a visual parent container of the module is hidden.

The why parameter indicates the reason for the state change:
why == BasicRunPlugIn.E_THIS The plug-in is being turned off.
why == BasicRunPlugIn.E_ANCESTOR An ancestor of the plug-in is being turned off.
why == BasicRunPlugIn.E_ROOT The root—that is, the applet or window—is being turned off.

piContainsPoint

Prototype:

public boolean piContainsPoint(Point aPoint);

Returns:
boolean true if aPoint is within the clickable region of the plug-in, false otherwise.

Parameter:
aPoint A point within the applet window.

Description: You need to override this method only if the clickable region of your visual module has an irregular shape or transparent, nonclickable areas. The default implementation uses the module�s bounding rectangle to decide whether the point is clickable or not.

piEventDragTranslate

Prototype:

public Rectangle piEventDragTranslate(int xOffset, int yOffset)
	throws HwException;

Returns:
Rectangle The area bounding the area whose appearance has changed.

Parameters:
xOffset How far the mouse dragged in the X direction.
yOffset How far the mouse dragged in the Y direction.

Description: The Hyperwire runtime calls this method when the user drags the mouse with the button initially down within the module�s area, indicating a move. It calls the method before it translates the plug-in�s bounding rectangle. This method should update the module�s internal state as necessary. It should not update the module�s appearance.

This method must return a rectangle that bounds the area whose appearance must change. The Hyperwire runtime uses the rectangle to repaint the window. Return Rectangle(0, 0, 0, 0) if the appearance doesn't need to change.

piDraw

Prototype:

public void piDraw(Graphics aGraphic, Rectangle aClipRect)
	throws HwException;

Parameters:
aGraphic The abstract windows toolkit (AWT) graphics context.
aClipRect The clipping rectangle.

Description: The Hyperwire runtime calls this method when the plug-in needs to redraw itself. This method should call the visual run-service method siGetAbsRect() to get its bounding box relative to the applet. It can repaint the entire bounding box area, or it can calculate the intersection of the bounding box and the clipping rectangle aClipRect, and repaint only the overlapping area. (The second method requires more computation but improves performance if the plug-in uses large images.)

piGetAbsRectComplete

Prototype:

public Rectangle piGetAbsRectComplete();

Returns:
Rectangle The bounding rectangle relative to the surrounding applet.

Description: The default implementation simply returns siGetAbsRect(). The only reason you might change this implementation is if the module draws outside its default bounding rectangle; for example, by thickening the border of the module.

piGetVisualRunService

Prototype:

public VisualRunService piGetVisualRunService();

Returns:
VisualRunService The handle to the Hyperwire runtime visual run service.

Description: Don�t change the default implementation of this method, which returns (VisualRunService) piGetRunService(), casting the BasicRunService reference to a VisualRunService.

piMouseEntered

Prototype:

public piMouseEntered(Event evt, int x, int y)
	throws HwException;

Parameters:
evt The handle of the mouse-entry event.
x The X location of the mouse at entry.
y The Y location of the mouse at entry.

Description: The Hyperwire runtime calls this method when the user moves the mouse with button up into the plug-in�s bounding rectangle. The plug-in must update its appearance and internal state as necessary.

piMouseLeft

Prototype:

public void piMouseLeft(Event evt, int x, int y)
	throws HwException;

Parameters:
evt The handle of the mouse-leave event.
x The X location of the mouse at exit.
y The Y location of the mouse at exit.

Description: The Hyperwire runtime calls this method when the user moves the mouse with button up out of the plug-in�s bounding rectangle. The plug-in must update its appearance and internal state as necessary.

piSetAbsRect

Prototype:

public void piSetAbsRect(Rectangle aRect)
	throws HwException;

Parameter:
aRect The plug-in's new bounding rectangle.

Description: In most cases, only visual plug-ins that use dialog widgets from the Java abstract windows toolkit (AWT) need to implement this method.

The Hyperwire runtime calls this method when the plug-in�s bounding rectangle is about to change, relative to the applet. The plug-in must update its appearance and internal state as needed. This method is primarily for plug-ins that don�t rely on the visual method piDraw() to draw themselves.

piIsOccluding

Prototype:

public boolean piIsOccluding();

Description: The Hyperwire runtime calls this method to find whether the plug-in completely obscures the background within its bounding rectangle. If the plug-in does not completely fill the rectangle, or if it has transparent pixels, it should return false (the default implementation). If the plug-in does completely fill the rectangle, it should return true. This enables the runtime to optimize drawing and improve performance.

Continue to "BasicRunService Interface"

Return to Contents