home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.StringTokenizer;
-
- public class SerifMarquee extends Applet implements Runnable {
- Thread m_SerifMarquee;
- Image m_backBuffer;
- Animation m_animation = new Animation();
- boolean m_haveMouse;
- int m_mx;
- int m_my;
- private String m_Global = "LENGTH:10;FPS:20;BACKGROUND:0,0,0";
- private String m_Event1 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 1;FONT:ARIAL;STYLE:BOLD;COLOUR:255,64,64;MOTION:LSLIDEIN;";
- private String m_Event2 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 2;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event3 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 3;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event4 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 4;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event5 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 5;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event6 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 6;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event7 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 7;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event8 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 8;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event9 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 9;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private String m_Event10 = "TYPE:TEXT;STARTIME:0;TEXT:TEXTSHOW 10;FONT:ARIAL;STYLE:BOLD;MOTION:LSLIDEIN;";
- private final String PARAM_Global = "Global";
- private final String PARAM_Event1 = "Event1";
- private final String PARAM_Event2 = "Event2";
- private final String PARAM_Event3 = "Event3";
- private final String PARAM_Event4 = "Event4";
- private final String PARAM_Event5 = "Event5";
- private final String PARAM_Event6 = "Event6";
- private final String PARAM_Event7 = "Event7";
- private final String PARAM_Event8 = "Event8";
- private final String PARAM_Event9 = "Event9";
- private final String PARAM_Event10 = "Event10";
-
- public void stop() {
- if (this.m_SerifMarquee != null) {
- this.m_SerifMarquee.stop();
- this.m_SerifMarquee = null;
- }
-
- }
-
- public boolean mouseEnter(Event evt, int x, int y) {
- this.m_haveMouse = true;
- this.m_mx = x;
- this.m_my = y;
- return true;
- }
-
- public boolean mouseExit(Event evt, int x, int y) {
- this.m_haveMouse = false;
- return true;
- }
-
- public void paint(Graphics g) {
- g.drawImage(this.m_backBuffer, 0, 0, (ImageObserver)null);
- }
-
- public boolean mouseUp(Event evt, int x, int y) {
- String urlStr = this.m_animation.getUrl(x, y);
- if (urlStr == null) {
- return false;
- } else {
- try {
- URL url = new URL(urlStr);
- ((Applet)this).getAppletContext().showDocument(url);
- ((Applet)this).getAppletContext().showStatus("");
- } catch (MalformedURLException var7) {
- }
-
- return true;
- }
- }
-
- public String[][] getParameterInfo() {
- String[][] info = new String[][]{{"Global", "String", "Global Animation Parameters"}, {"Event1", "String", "First Animation Event"}, {"Event2", "String", "Second Animation Event"}, {"Event3", "String", "Third Animation Event"}, {"Event4", "String", "Fourth Animation Event"}, {"Event5", "String", "Fifth Animation Event"}, {"Event6", "String", "Sixth Animation Event"}, {"Event7", "String", "Seventh Animation Event"}, {"Event8", "String", "Eighth Animation Event"}, {"Event9", "String", "Ninth Animation Event"}, {"Event10", "String", "Tenth Animation Event"}};
- return info;
- }
-
- public void destroy() {
- }
-
- public AnimationEvent initEvent(String params) {
- StringTokenizer st = new StringTokenizer(params, ";");
- String szToken = st.nextToken();
- int nColon = szToken.indexOf(58);
- if (nColon != -1) {
- String szName = szToken.substring(0, nColon).toUpperCase();
- String szValue = szToken.substring(nColon + 1);
- if (szName.equals("TYPE") && szValue.equals("TEXT")) {
- return this.initTextEvent(params);
- }
- }
-
- return null;
- }
-
- public void update(Graphics g) {
- this.paint(g);
- }
-
- public void start() {
- if (this.m_SerifMarquee == null) {
- this.m_SerifMarquee = new Thread(this);
- this.m_SerifMarquee.start();
- }
-
- }
-
- public String getAppletInfo() {
- return "Name: SerifMarquee\r\n" + "Author: Paul Hempstock for Serif (Europe) Ltd.";
- }
-
- void initEvents() {
- String param = ((Applet)this).getParameter("Event1");
- if (param != null) {
- this.m_Event1 = param;
- AnimationEvent event = this.initEvent(this.m_Event1);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event2");
- if (param != null) {
- this.m_Event2 = param;
- event = this.initEvent(this.m_Event2);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event3");
- if (param != null) {
- this.m_Event3 = param;
- event = this.initEvent(this.m_Event3);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event4");
- if (param != null) {
- this.m_Event4 = param;
- event = this.initEvent(this.m_Event4);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event5");
- if (param != null) {
- this.m_Event5 = param;
- event = this.initEvent(this.m_Event5);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event6");
- if (param != null) {
- this.m_Event6 = param;
- event = this.initEvent(this.m_Event6);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event7");
- if (param != null) {
- this.m_Event7 = param;
- event = this.initEvent(this.m_Event7);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event8");
- if (param != null) {
- this.m_Event8 = param;
- event = this.initEvent(this.m_Event8);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event9");
- if (param != null) {
- this.m_Event9 = param;
- event = this.initEvent(this.m_Event9);
- this.m_animation.addEvent(event);
- param = ((Applet)this).getParameter("Event10");
- if (param != null) {
- this.m_Event10 = param;
- event = this.initEvent(this.m_Event10);
- this.m_animation.addEvent(event);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- public void run() {
- int sleepPerFrame = 1000 / this.m_animation.m_fps;
-
- while(true) {
- try {
- this.m_animation.drawFrame(this.m_backBuffer);
- this.m_animation.incFrame();
- ((Component)this).repaint();
- if (this.m_haveMouse) {
- String urlStr = this.m_animation.getUrl(this.m_mx, this.m_my);
- ((Applet)this).getAppletContext().showStatus(urlStr);
- }
-
- Thread.sleep((long)sleepPerFrame);
- } catch (InterruptedException var4) {
- return;
- }
- }
- }
-
- public void init() {
- Rectangle rec = ((Component)this).bounds();
- this.m_backBuffer = ((Component)this).createImage(rec.width, rec.height);
- this.m_animation.setSize(rec);
- String param = ((Applet)this).getParameter("Global");
- if (param != null) {
- this.m_Global = param;
- this.m_animation.initFromParams(param);
- }
-
- this.initEvents();
- this.m_animation.drawFrame(this.m_backBuffer);
- }
-
- public AnimationEvent initTextEvent(String params) {
- TextEvent event = new TextEvent(this, this.m_animation);
- event.initFromParams(params);
- return event;
- }
-
- public boolean mouseMove(Event evt, int x, int y) {
- this.m_mx = x;
- this.m_my = y;
- return true;
- }
- }
-