home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / ingzp26a / flashinglocation.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.6 KB  |  69 lines

  1. /* $Id: flashingLocation.java,v 1.2 1996/03/31 11:43:02 djun Exp djun $
  2.  
  3.    File: flashingLocation.java
  4.  
  5.    Extension of class Location - defines a location which flashes on
  6.    the graphical image of the map.
  7.  
  8.    Author: Djun M. Kim
  9.    Copyright (c) 1996 Djun M. Kim.  All rights reserved.
  10.  
  11. */
  12.  
  13. import java.awt.*;
  14.  
  15. public class flashingLocation extends Location implements Runnable {
  16.  
  17.     private boolean is_on = true;
  18.     private int interval = 0;
  19.     Thread runner;
  20.  
  21.     flashingLocation(Map parent, Location loc, int interval) {
  22.     super(parent, loc.getBase());
  23.     this.interval = interval;
  24.     super.parent = parent;
  25.     super.base = loc.getBase();
  26.     super.region = loc.getRegion();
  27.     super.name = loc.getName();
  28.     super.url = loc.getURL();
  29.     super.detail = loc.getDetailMap();
  30.     super.entrances = loc.getEntrances();
  31.     super.exits = loc.getExits();
  32.     super.mapimg = loc.getMapimg();
  33.     super.infotext = loc.getInfoText();
  34.     super.keywords = loc.getKeywords();
  35.     super.displayable = loc.isDisplayable();
  36.     }
  37.  
  38.     public void start() {
  39.     if (runner == null) {
  40.         runner = new Thread(this);
  41.         runner.start();
  42.     }
  43.     }
  44.  
  45.     public void stop() {
  46.     if (runner != null) {
  47.         runner.stop();
  48.         runner = null;
  49.     }
  50.     }
  51.  
  52.     // flash the location at point loc in the hidden graphics
  53.     public void run (){
  54.     while (true) {
  55.         try { Thread.currentThread().sleep(interval); } 
  56.         catch (InterruptedException e) { }
  57.         is_on = false;
  58.         try { Thread.currentThread().sleep(interval); } 
  59.         catch (InterruptedException e) { }
  60.         is_on = true;
  61.     }
  62.     }
  63.  
  64.     // flash the location at point loc in the hidden graphics
  65.     public boolean is_on(){
  66.     return is_on;
  67.     }
  68. }
  69.