/*
*
* ktn.java
* @author: Rajesh Dhawan and Tarique Sani
*
*
*/
/*
*
*/
import java.awt.*;
import java.awt.image.*;
import java.applet.*;
import java.util.*;
import java.net.*;
public class ktn extends java.applet.Applet implements Runnable{
String items[]=new String[25];
String tags[]=new String[25];
String frm[]=new String[25];
URL page[]=new URL[25];
int nItems=0;
int current=0;
int y=0;
int x=0;
Image img[]=new Image[25];
Image mirror[]=new Image[25];
AppletContext ac=null;
int delay=5;
Image arrow=null;
int w,h;
Color BLUE=new Color(0,0,0x80);
public void init(){
setLayout(null);
setBackground(BLUE);
getParent().setBackground(BLUE);
Graphics gr=getParent().getGraphics();
String welcome=getParameter("welcome");
gr.setColor(Color.white);
gr.setFont(new Font("Helvetica",Font.PLAIN,18));
w=size().width;
h=size().height/2;
gr.drawString(welcome,10,h);
gr.drawLine(0,h+5,w,h+5);
ac=getAppletContext();
try{
for (nItems=0;nItems<25;nItems++){
StringTokenizer st=new StringTokenizer(getParameter("item"+(nItems)),"+");
items[nItems]=st.nextToken();
page[nItems]=new URL(getDocumentBase(),st.nextToken());
tags[nItems]=st.nextToken();
if (st.hasMoreTokens()) frm[nItems]=st.nextToken();
else frm[nItems]="_top";
if (items[nItems]==null) break;
}
}catch (Exception e){
}
delay=Integer.parseInt(getParameter("delay"))*1000;
Font fnt=new Font("Helvetica",Font.BOLD,30);
FontMetrics fm=getFontMetrics(fnt);
int xp[]=new int[3];
int yp[]=new int[3];
xp[0]=0+4;yp[0]=0+2;
xp[1]=0+4;yp[1]=20+2;
xp[2]=10+4;yp[2]=10+2;
Polygon pp=new Polygon(xp,yp,3);
arrow=createImage(25,25);
Graphics g=arrow.getGraphics();
g.setColor(new Color(0x80,0x80,0x80));
g.fill3DRect(0,0,25,25,true);
g.setColor(new Color(0,0xff,0));
g.fillPolygon(pp);
for (int i=0;i>16;
g=(c&0xff00)>>8;
b=c&0xff;
if (r!=0){
r-=40;
g-=40;
b-=40;
}
return ((0xff000000)|(r<<16)|(g<<8)|b);
}
public void update(Graphics g){
paint(g);
}
boolean selected=false;
public void paint(Graphics g){
g.drawImage(img[index],0,0,w,h,this);
if (selected) {
g.setColor(new Color(0,0xff,0));
g.drawLine(0,h-1,w,h-1);
for (int i=0;i<5;i++){
int hh=5*(i+1);
g.drawImage(arrow,10,h-20-hh/2,25,hh,this);
try{Thread.sleep(50);
}catch (InterruptedException e){
}
}
g.setColor(BLUE);
g.fillRect(0,h,w,h);
g.setFont(new Font("TimesRoman",Font.BOLD,14));
g.setColor(Color.white);
g.drawString(tags[index],10,h+18);
}else{
g.drawImage(mirror[index],0,h,w,h,this);
}
}
public String getAppletInfo(){
return (new String("(C) Copyright 1997 Rajesh Dhawan and Tarique Sani, \n "));
}
Thread t=null;
public void start(){
if (t==null){
t=new Thread(this);
t.start();
}else{
t.resume();
}
}
public void stop(){
if (t!=null){
t.suspend();
}
}
public void destroy(){
t.stop();
t=null;
}
int index=0;
int old=0;
public void run(){
while (true){
try {
Thread.sleep(delay);
}catch (InterruptedException e){
}
index++;
if (index>=nItems) index=0;
repaint();
}
}
public boolean mouseDown(Event evt,int x,int y){
ac.showDocument(page[index],frm[index]);
return true;
}
public boolean mouseEnter(Event evt,int x,int y){
selected=true;
t.suspend();
repaint();
return true;
}
public boolean mouseExit(Event evt,int x,int y){
selected=false;
t.resume();
repaint();
return true;
}
}