Methods Summary |
---|
public boolean | animate()This method is called every animation cycle if there are any
active animating areas.
return false;
|
public boolean | checkEnter(int x, int y)The checkEnter method is called when the mouse is inside the
region to see if the area needs to have its enter method called.
The default implementation simply checks if the entered flag is
set and only calls enter if it is false.
if (!entered) {
entered = true;
enter(x, y);
}
return isTerminal();
|
public void | checkExit()The checkExit method is called when the mouse is outside the
region to see if the area needs to have its exit method called.
The default implementation simply checks if the entered flag is
set and only calls exit if it is true.
if (entered) {
entered = false;
exit();
}
|
public boolean | drag(int x, int y)The drag method is called when the user moves the mouse while
the button is pressed. Only those ImageAreas that were informed
of a press will be informed of the corresponding mouse movements.
return isTerminal();
|
public void | drawImage(java.awt.Graphics g, java.awt.Image img, int imgx, int imgy, int x, int y, int w, int h)This utility method draws a rectangular subset of a highlight
image.
Graphics ng = g.create();
try {
ng.clipRect(x, y, w, h);
ng.drawImage(img, imgx, imgy, this);
} finally {
ng.dispose();
}
|
public void | enter(int x, int y)The enter method is called when the mouse enters the region.
The location is supplied, but the standard implementation is
to call the overloaded method with no arguments.
enter();
|
public void | enter()The overloaded enter method is called when the mouse enters
the region. This method can be overridden if the ImageArea
does not need to know where the mouse entered.
|
public void | exit()The exit method is called when the mouse leaves the region.
|
public java.lang.String | getAppletInfo()
return "Title: ImageArea \nAuthor: Jim Graham \nThis class performs the basic functions that most ImageArea classes will need and delegates specific actions to the subclasses.";
|
public void | getMedia()This method loads any additional media that the ImageMapArea
may need for its animations.
|
public java.lang.String | getStatus(java.lang.String prevmsg)This utility method returns the status string this area wants to
put into the status bar. If no previous area (higher in the
stacking order) has yet returned a status message, prevmsg will
be null and this area will then return its own message, otherwise
it will leave the present message alone.
return (prevmsg == null) ? status : prevmsg;
|
public void | handleArg(java.lang.String s)This method handles the remainder of the argument string after
the standard initializer has parsed off the 4 rectangular
parameters. If the subclass does not override this method,
the remainder will be ignored.
|
public void | highlight(java.awt.Graphics g)This method highlights the specified area when the user enters
it with his mouse. The standard highlight method is to replace
the indicated rectangular area of the image with the primary
highlighted image.
|
public boolean | imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)This method handles the updates from drawing the images.
if (img == hlImage) {
return parent.imageUpdate(img, infoflags, x + X, y + Y,
width, height);
} else {
return (infoflags & (ALLBITS | ERROR)) == 0;
}
|
public void | init(ImageMap parent, java.lang.String args)Initialize this ImageArea as called from the applet.
If the subclass does not override this initializer, then it
will perform the basic functions of setting the parent applet
and parsing out 4 numbers from the argument string which specify
a rectangular region for the ImageArea to act on.
The remainder of the argument string is passed to the handleArg()
method for more specific handling by the subclass.
this.parent = parent;
StringTokenizer st = new StringTokenizer(args, ", ");
X = Integer.parseInt(st.nextToken());
Y = Integer.parseInt(st.nextToken());
W = Integer.parseInt(st.nextToken());
H = Integer.parseInt(st.nextToken());
if (st.hasMoreTokens()) {
handleArg(st.nextToken(","));
} else {
handleArg(null);
}
makeImages();
|
public boolean | inside(int x, int y)This method tests to see if a point is inside this ImageArea.
The standard method assumes a rectangular area as parsed by
the standard initializer. If a more complex area is required
then this method will have to be overridden by the subclass.
return (x >= X && x < (X + W) && y >= Y && y < (Y + H));
|
public boolean | isTerminal()The isTerminal method controls whether events propagate to the
areas which lie beneath this one.
return false;
|
public boolean | lift(int x, int y)The lift method is called when the user releases the mouse button.
The location is supplied, but the standard implementation is to
call the overloaded method with no arguments. Only those ImageAreas
that were informed of a press will be informed of the corresponding
release.
return lift();
|
public boolean | lift()The overloaded lift method is called when the user releases the
mouse button. This method can be overridden if the ImageArea
does not need to know the location of the release.
return isTerminal();
|
public void | makeImages()This method handles the construction of the various images
used to highlight this particular ImageArea when the user
interacts with it.
setHighlight(parent.getHighlight(X, Y, W, H));
|
public boolean | press(int x, int y)The press method is called when the user presses the mouse
button inside the ImageArea. The location is supplied, but
the standard implementation is to call the overloaded method
with no arguments.
return press();
|
public boolean | press()The overloaded press method is called when the user presses the
mouse button inside the ImageArea. This method can be overridden
if the ImageArea does not need to know the location of the press.
return isTerminal();
|
public void | repaint()The repaint method causes the area to be repainted at the next
opportunity.
parent.repaint(0, X, Y, W, H);
|
public void | setHighlight(java.awt.Image img)This method sets the image to be used to render the ImageArea
when it is highlighted.
hlImage = img;
|
public void | showDocument(java.net.URL u)This utility method tells the browser to visit a URL.
parent.getAppletContext().showDocument(u);
|
public void | showStatus(java.lang.String msg)This utility method records a string to be shown in the status bar.
status = msg;
parent.newStatus();
|