/** * NavigatorTicker --Copyright Ahmed Abdelhady 1996 ahady@idsc.gov.eg
* A live Hypertext java applets. * * Permission to use, copy, modify and distribute this software and its * documentation without fee for NON-COMMERCIAL purposes is hereby granted * provided that this notice with a reference to the original source and * the author appears in all copies or derivatives of this software. * * All other rights are resevred. * * THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THIS SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY ANYBODY AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import java.awt.*; import java.lang.*; import java.net.*; import java.util.*; public class NavigatorTicker extends java.applet.Applet implements Runnable { /** index for the active message */ public int messageIndex=0; /** TOtal no of messages */ public int messageCount=1; /** The message to be displayed. */ public String message; /** The messages Vector. */ public Vector msgs=new Vector(); /** The Font to be displayed. */ public Font messageF; /** x-position of message. */ public int messageX; /** y-position of message. */ public int messageY; /** Length of the Active message. */ public int messageW = 0; /** Messages Lengths Vector */ public Vector msgsW= new Vector(); /** URL to switch to */ public URL url_ = null; /** Target URLs Vector */ public Vector msgsURL=new Vector(); /** How far to skip across the screen. */ int speed; /** The animating thread. */ public Thread t = null; /** State of the applet. */ public boolean active = false; /** The Text-color. */ public Color txtCo; /** The Link-color. */ public Color linkCo; /** The backgroundcolor. */ public Color bgCo; /** The Size used to calc the Font. */ public Dimension lastS = new Dimension(1,1); /** The offscreen image. */ Image im = null; /** The offscreen Graphics context */ Graphics gr = null; /* A flag that indicate mouse movement over the Applet */ boolean display_URL=false; /* Mouse x Position */ int mouseX=0; /** * Initialize: Read Parameters * */ public void init () { String at; messageCount=((at = getParameter("count")) == null) ? 0 : (Integer.valueOf(at).intValue()); for (int i = 0; i > 1)+fm.getAscent(); for(int i=0; i messageX ){ // clicking Nonempty area x-=messageX; // compute displacement relative to start of the message for(int i =0; i< messageCount; i++){ currX+=((Integer) msgsW.elementAt(i)).intValue(); // compare to acumulated widths to get clicked message index. if ( x < currX ) { messageIndex=i; break;} } // end for } // end if (mouse... showStatus((String) msgsURL.elementAt(messageIndex) ); } // draw the text gr.setColor(txtCo); gr.setFont(messageF); int disp=0; for(int i=0;i