home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / HighlightArea.java < prev    next >
Text File  |  1997-07-30  |  3KB  |  93 lines

  1. // $Header: z:/admin/metro_examples/java/demo/ImageMap/rcs/HighlightArea.java 1.1 1997/02/06 00:30:14 IPGIntel-2 Exp $ 
  2. /*
  3.  * @(#)HighlightArea.java    1.5 96/12/06
  4.  *
  5.  * Copyright (c) 1994-1996 Sun Microsystems, Inc. All Rights Reserved.
  6.  *
  7.  * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
  8.  * modify and redistribute this software in source and binary code form,
  9.  * provided that i) this copyright notice and license appear on all copies of
  10.  * the software; and ii) Licensee does not utilize the software in a manner
  11.  * which is disparaging to Sun.
  12.  *
  13.  * This software is provided "AS IS," without a warranty of any kind. ALL
  14.  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
  15.  * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
  16.  * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
  17.  * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
  18.  * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
  19.  * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
  20.  * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
  21.  * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
  22.  * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
  23.  * POSSIBILITY OF SUCH DAMAGES.
  24.  *
  25.  * This software is not designed or intended for use in on-line control of
  26.  * aircraft, air traffic, aircraft navigation or aircraft communications; or in
  27.  * the design, construction, operation or maintenance of any nuclear
  28.  * facility. Licensee represents and warrants that it will not use or
  29.  * redistribute the Software for such purposes.
  30.  */
  31.  
  32. import java.awt.Graphics;
  33. import java.net.URL;
  34. import java.net.MalformedURLException;
  35.  
  36. /**
  37.  * An area highlighting ImageArea class.
  38.  * This class extends the basic ImageArea Class to highlight an area of
  39.  * the base image when the mouse enters the area.
  40.  *
  41.  * @author     Jim Graham
  42.  * @version     1.5, 12/06/96
  43.  */
  44. class HighlightArea extends ImageMapArea {
  45.     int hlmode;
  46.     int hlpercent;
  47.  
  48.     /**
  49.      * The argument string is the highlight mode to be used.
  50.      */
  51.     public void handleArg(String arg) {
  52.     if (arg == null) {
  53.         hlmode = parent.hlmode;
  54.         hlpercent = parent.hlpercent;
  55.     } else {
  56.         if (arg.startsWith("darker")) {
  57.         hlmode = parent.DARKER;
  58.         arg = arg.substring("darker".length());
  59.         } else {
  60.         hlmode = parent.BRIGHTER;
  61.         if (arg.startsWith("brighter")) {
  62.             arg = arg.substring("brighter".length());
  63.         }
  64.         }
  65.         hlpercent = Integer.parseInt(arg);
  66.     }
  67.     }
  68.  
  69.     public void makeImages() {
  70.     setHighlight(parent.getHighlight(X, Y, W, H, hlmode, hlpercent));
  71.     }
  72.  
  73.     public void highlight(Graphics g) {
  74.     if (entered) {
  75.         g.drawImage(hlImage, X, Y, this);
  76.     }
  77.     }
  78.  
  79.     /**
  80.      * The area is repainted when the mouse enters.
  81.      */
  82.     public void enter() {
  83.     repaint();
  84.     }
  85.  
  86.     /**
  87.      * The area is repainted when the mouse leaves.
  88.      */
  89.     public void exit() {
  90.     repaint();
  91.     }
  92. }
  93.