home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.multimedia;
-
- import java.awt.Canvas;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
-
- public class NervousText extends Canvas implements Runnable {
- char[] separated;
- String text;
- boolean paused = false;
- Thread jitter;
-
- public NervousText() {
- this.setText("text");
- }
-
- public void addNotify() {
- super.addNotify();
- this.jitter = new Thread(this);
- this.jitter.start();
- }
-
- public synchronized void removeNotify() {
- if (this.jitter != null) {
- this.jitter.stop();
- this.jitter = null;
- }
-
- super.removeNotify();
- }
-
- public synchronized void show() {
- super.show();
- if (((Component)this).isVisible() && this.jitter != null) {
- this.jitter.resume();
- }
-
- }
-
- public synchronized void hide() {
- super.hide();
- if (!((Component)this).isVisible() && this.jitter != null) {
- this.jitter.suspend();
- }
-
- }
-
- public void setText(String var1) {
- this.text = var1;
- this.separated = new char[this.text.length()];
- this.text.getChars(0, this.text.length(), this.separated, 0);
- }
-
- public String getText() {
- return this.text;
- }
-
- public void run() {
- while(true) {
- if (!this.paused) {
- try {
- Thread.sleep(150L);
- } catch (Exception var1) {
- }
-
- ((Component)this).repaint();
- }
- }
- }
-
- public void pause(boolean var1) {
- this.paused = var1;
- }
-
- public boolean isPaused() {
- return this.paused;
- }
-
- public void setPaused(boolean var1) {
- this.paused = var1;
- }
-
- public void paint(Graphics var1) {
- Dimension var2 = ((Component)this).size();
- var1.clipRect(0, 0, var2.width, var2.height);
-
- for(int var3 = 0; var3 < this.text.length(); ++var3) {
- int var4 = (int)(Math.random() * (double)10.0F + (double)(20 * var3));
- int var5 = (int)(Math.random() * (double)10.0F + (double)36.0F);
- var1.drawChars(this.separated, var3, 1, var4, var5);
- }
-
- }
- }
-