home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-13 | 3.8 KB | 118 lines |
- /*
- * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL purposes and without
- * fee is hereby granted provided that this copyright notice
- * appears in all copies. Please refer to the file "copyright.html"
- * for further important copyright and licensing information.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- */
- /*
- * @(#)AniArea.java 1.4 95/10/13
- *
- * Copyright (c) 1994-1995 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
- * without fee is hereby granted.
- * Please refer to the file http://java.sun.com/copy_trademarks.html
- * for further important copyright and trademark information and to
- * http://java.sun.com/licensing.html for further important licensing
- * information for the Java (tm) Technology.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- *
- * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
- * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
- * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
- * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
- * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
- * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
- * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). SUN
- * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
- * HIGH RISK ACTIVITIES.
- */
-
- import java.awt.Graphics;
- import java.util.StringTokenizer;
- import java.awt.Image;
- import java.net.URL;
- import java.net.MalformedURLException;
-
- /**
- * This ImageArea provides for a button that animates when the mouse is
- * over it. The animation is specifed as a base image that contains all
- * of the animation frames and then a series of X,Y coordinate pairs that
- * define the top left corner of each new frame.
- *
- * @author Chuck McManis
- * @version 1.4, 13 Oct 1995
- */
- class AniArea extends ImageMapArea {
-
- Image sourceImage;
- int nFrames;
- int coords[];
- int currentFrame = 0;
-
- public void handleArg(String s) {
- StringTokenizer st = new StringTokenizer(s, ", ");
- int i;
- String imgName;
-
- imgName = st.nextToken();
- try {
- sourceImage = parent.getImage(
- new URL(parent.getDocumentBase(), imgName));
- } catch (MalformedURLException e) {}
-
- nFrames = 0;
- coords = new int[40];
-
- while (st.hasMoreTokens()) {
- coords[nFrames*2] = Integer.parseInt(st.nextToken());
- coords[(nFrames*2)+1] = Integer.parseInt(st.nextToken());
- nFrames++;
- if (nFrames > 19)
- break;
- }
- }
-
- public boolean animate() {
- if (entered) {
- repaint();
- }
- return entered;
- }
-
- public boolean enter() {
- currentFrame = 0;
- parent.startAnimation();
- return false;
- }
-
- public void highlight(Graphics g) {
- if (entered) {
- drawImage(g, sourceImage,
- X-coords[currentFrame*2], Y-coords[(currentFrame*2)+1],
- X, Y, W, H);
- currentFrame++;
- if (currentFrame >= nFrames)
- currentFrame = 0;
- }
- }
- }
-
-