home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-06-03 | 15.0 KB | 484 lines | [TEXT/CWIE] |
- /*
- LCD Display JAVA Applet
- ===================
-
- ⌐ 1997 by Christoph Schaffhauser
- chris@darkeagle.com
- http://www.darkeagle.com/
-
- The only conditions are that you do not alter it, manipulate or deconstruct it and
- if you want to use this applet in you homepage, you have to make a link from your homepage
- to my homepage: http://www.darkeagle.com/
-
- Thanks Chris
-
- B.T.W: I'm addicted to emails.... If you have some time write me a small note :-)
- */
-
- import java.util.*;
- import java.awt.*;
- import java.applet.*;
- import java.awt.Font;
- import java.awt.Graphics;
-
- public class LCD extends Applet implements Runnable {
-
- int Offset,index,StringNum,ScrollStateEnd,ScrollStateStart,Speed;
- String str,xstr;
- char separated[];
- char separated2[];
- Thread killme = null;
- boolean firsttime,notdraw,ScrollIn;
- Color textColor;
-
- Image buffer,buffer2;
- Dimension buffersize;
- Dimension buffersize2;
- Graphics bu,bu2;
-
-
- Color white = new Color(255,255,255);
- Color gray = new Color(166,166,166);
- Color lightgray = new Color(240,240,240);
- Color darkgray = new Color(207,207,207);
- Color middlegray = new Color(222,222,222);
- Color darkgreen = new Color( 10,43, 10);
- Color black = new Color( 0,0, 0);
- Color yellow = new Color( 255,255, 0);
- Color green = new Color( 0,255, 0);
- Color orange = new Color( 255,128, 0);
- Color red = new Color( 255,63, 63);
- Color blue = new Color( 63,63, 255);
-
- boolean A[] = new boolean[54];
- boolean B[] = new boolean[54];
- boolean C[] = new boolean[54];
- boolean D[] = new boolean[54];
- boolean E[] = new boolean[54];
- boolean F[] = new boolean[54];
- boolean G[] = new boolean[54];
- boolean H[] = new boolean[54];
- boolean I[] = new boolean[54];
- boolean J[] = new boolean[54];
- boolean K[] = new boolean[54];
- boolean L[] = new boolean[54];
- boolean M[] = new boolean[54];
- boolean N[] = new boolean[54];
- boolean O[] = new boolean[54];
- boolean P[] = new boolean[54];
- boolean Q[] = new boolean[54];
- boolean R[] = new boolean[54];
- boolean S[] = new boolean[54];
- boolean T[] = new boolean[54];
- boolean U[] = new boolean[54];
- boolean V[] = new boolean[54];
- boolean W[] = new boolean[54];
- boolean X[] = new boolean[54];
- boolean Y[] = new boolean[54];
- boolean Z[] = new boolean[54];
-
- boolean ONE[] = new boolean[54];
- boolean TWO[] = new boolean[54];
- boolean THREE[] = new boolean[54];
- boolean FOUR[] = new boolean[54];
- boolean FIVE[] = new boolean[54];
- boolean SIX[] = new boolean[54];
- boolean SEVEN[] = new boolean[54];
- boolean EIGTH[] = new boolean[54];
- boolean NINE[] = new boolean[54];
- boolean ZERO[] = new boolean[54];
-
- boolean STAR[] = new boolean[54];
- boolean POINT[] = new boolean[54];
-
- public String getAppletInfo() {
- return "LCD Display by Christoph Schaffhauser";
- }
-
- public void DrawLCDString(Graphics g, String str) {
- int i,x,y,ff;
- String Colors;
- Dimension d = size(); // of the canvas!
-
- separated = new char [str.length()];
-
-
- str.getChars(0,str.length(),separated,0);
- y=0;
- if (ScrollStateEnd<0)
- y=-(ScrollStateEnd);
-
- xstr = getParameter("MODE");
- ff = (xstr == null) ? 16 : Integer.valueOf(xstr).intValue();
- if (ff == 1) x=((d.width-10)/18)-ScrollStateEnd+1;
- else x=((d.width-10)/12)-ScrollStateEnd+1;
-
- if (x > str.length())
- x=str.length();
-
- Colors = getParameter("COLOR"+ index);
- separated2 = new char [Colors.length()];
- Colors.getChars(0,Colors.length(),separated2,0);
-
- for (i=y;i<x-1;i++){
- if (separated2[i] == 'r') textColor=red;
- if (separated2[i] == 'g') textColor=green;
- if (separated2[i] == 'o') textColor=orange;
- if (separated2[i] == 'y') textColor=yellow;
- if (separated2[i] == 'b') textColor=blue;
- if (separated2[i] == 'w') textColor=white;
- if (separated[i] == ' ') Offset += 6;
-
- if (separated[i] == '1') DrawLCDChar(g, textColor,ONE);
- if (separated[i] == '2') DrawLCDChar(g, textColor,TWO);
- if (separated[i] == '3') DrawLCDChar(g, textColor,THREE);
- if (separated[i] == '4') DrawLCDChar(g, textColor,FOUR);
- if (separated[i] == '5') DrawLCDChar(g, textColor,FIVE);
- if (separated[i] == '6') DrawLCDChar(g, textColor,SIX);
- if (separated[i] == '7') DrawLCDChar(g, textColor,SEVEN);
- if (separated[i] == '8') DrawLCDChar(g, textColor,EIGTH);
- if (separated[i] == '9') DrawLCDChar(g, textColor,NINE);
- if (separated[i] == '0') DrawLCDChar(g, textColor,ZERO);
-
- if (separated[i] == '.') DrawLCDChar(g, textColor,POINT);
- if (separated[i] == '*') DrawLCDChar(g, textColor,STAR);
- if (separated[i] == 'A') DrawLCDChar(g, textColor,A);
- if (separated[i] == 'B') DrawLCDChar(g, textColor,B);
- if (separated[i] == 'C') DrawLCDChar(g, textColor,C);
- if (separated[i] == 'D') DrawLCDChar(g, textColor,D);
- if (separated[i] == 'E') DrawLCDChar(g, textColor,E);
- if (separated[i] == 'F') DrawLCDChar(g, textColor,F);
- if (separated[i] == 'G') DrawLCDChar(g, textColor,G);
- if (separated[i] == 'H') DrawLCDChar(g, textColor,H);
- if (separated[i] == 'I') DrawLCDChar(g, textColor,I);
- if (separated[i] == 'J') DrawLCDChar(g, textColor,J);
- if (separated[i] == 'K') DrawLCDChar(g, textColor,K);
- if (separated[i] == 'L') DrawLCDChar(g, textColor,L);
- if (separated[i] == 'M') DrawLCDChar(g, textColor,M);
- if (separated[i] == 'N') DrawLCDChar(g, textColor,N);
- if (separated[i] == 'O') DrawLCDChar(g, textColor,O);
- if (separated[i] == 'P') DrawLCDChar(g, textColor,P);
- if (separated[i] == 'Q') DrawLCDChar(g, textColor,Q);
- if (separated[i] == 'R') DrawLCDChar(g, textColor,R);
- if (separated[i] == 'S') DrawLCDChar(g, textColor,S);
- if (separated[i] == 'T') DrawLCDChar(g, textColor,T);
- if (separated[i] == 'U') DrawLCDChar(g, textColor,U);
- if (separated[i] == 'V') DrawLCDChar(g, textColor,V);
- if (separated[i] == 'W') DrawLCDChar(g, textColor,W);
- if (separated[i] == 'X') DrawLCDChar(g, textColor,X);
- if (separated[i] == 'Y') DrawLCDChar(g, textColor,Y);
- if (separated[i] == 'Z') DrawLCDChar(g, textColor,Z);
- }
- }
-
-
- /*public void internetat(Graphics g, Color theColor) {
- int i;
- g.setColor(theColor);
-
- for (i=0;i<=4;i++){
- drawYellowDot(g,0+Offset,i+2);
- if (i<3) {
- drawYellowDot(g,4+Offset,2+i);
- drawYellowDot(g,1+i+Offset,1);
- drawYellowDot(g,1+i+Offset,5);
- drawYellowDot(g,1+i+Offset,7);
- drawYellowDot(g,0+i+Offset,3);
- drawYellowDot(g,2+Offset,i+3);
- }
- };
- Offset += 6;
- }*/
-
- public void DrawLCDChar(Graphics g, Color theColor,boolean Chars[]) {
- int i,j,k,x;
- byte f;
- g.setColor(theColor);
- x=0;
- for (i=0;i<=8;i++){
- for (j=0;j<=5;j++){
- if (Chars[x]) drawYellowDot(g,j+Offset,i);
- x+=1;
- }
- }
- Offset += 6;
- }
-
- public void init()
- {
- String at;
- int x,j,i,ff,addition;
-
- for (j=0;j<=8;j++){
- A[j*6+4] = A[j*6] = B[j*6] = C[j*6] = D[j*6] = E[j*6] = F[j*6] = G[j*6] = H[j*6] = H[j*6+4] = I[j*6+2] =
- J[j*6+4] = K[j*6] = L[j*6] = M[j*6] = M[j*6+4] = N[j*6] = N[j*6+4] = O[j*6] = O[j*6+4] =
- P[j*6] = Q[j*6+4] = R[j*6] = T[j*6+2] = T[j*6+2] = U[j*6] = U[j*6+4] = V[j*6] =
- V[j*6+4] = W[j*6] = W[j*6+4] = ONE[j*6+3] = true;
- }
- for (j=1;j<=3;j++)
- {
- B[j] = B[j+24] = B[j+48] = E[j+48] = G[j+48] = C[j+1] = C[j+49] = G[j+25] = H[j+24] =
- J[j+48] = N[j*6+14] = P[j] = P[j+24] = P[j*6+4] = Q[j] = Q[j+24] = Q[j*6] = R[j] =
- R[j+24] = R[j*6+4] = S[j*6] = A[30+j] = STAR[j+18] = STAR[j+30] = TWO[j+6] = TWO[j*6+10] =
- THREE[j+6] = THREE[j+48] = FIVE[24+j] = FIVE[48+j] = FIVE[j*6+28] = FIVE[j*6+6] = SIX[24+j] =
- SIX[48+j] = SIX[j*6+28] = SIX[j*6+24] = EIGTH[24+j] = EIGTH[48+j] = EIGTH[j*6+28] = EIGTH[j*6+24] =
- EIGTH[j+6] = NINE[j+6] = NINE[j+24] = NINE[j+48] = true;
- }
- for (j=0;j<=4;j++)
- {
- Z[j+8*6] = Z[j] =T[j] = I[j] = I[j+8*6] = E[j] = F[j] =G[j] =J[j] = L[j+8*6] = O[j] =
- O[j+48] = U[j+8*6] = S[j] = S[j+8*6] = STAR[j+24] = TWO[j+8*6] = FOUR[j+5*6] = FOUR[j*6+27] =
- FOUR[j*6+6] = FIVE[6+j] = SEVEN[6+j] = NINE[j*6+22] = true;
- }
-
- C[0] = C[6] = C[42] = C[48] = J[52] = O[0] = O[4] = O[48] = O[52] = U[48] = U[52] =
- S[0] = S[52] = V[42] = V[48] = V[46] = V[52] = W[48] = W[52] = A[0] = A[4] = A[6] = A[10] =
- G[0] = G[48] = STAR[26] = ONE[3] = false;
-
- X[0] = X[4] = X[6] = X[10] = X[13] = X[15] = X[19] = X[21] = X[26] = true;
- for (j=0;j<=53;j++) {
- Y[j] = X[j];
- ZERO[j] = O[j];
- }
- for (j=0;j<=4;j++)
- Y[j*6+2+24] = true;
- ZERO[1] = ZERO[2] = ZERO[3] = ZERO[6] = ZERO[10] = false;
-
-
- X[31] = X[33] = X[37] = X[39] = X[42] = X[46] = X[48] = X[52] = Z[10] = Z[15] = Z[21] =
- Z[26] = Z[31] = Z[37] = Z[42] = A[2] = A[7] = A[9] = S[25] = S[26] = S[33] = S[40] = S[46] =
- W[44] = W[49] = W[51] = V[43] = V[50] = V[45] = J[42] = C[7] = C[43] = M[7] = M[9] = M[14] =
- R[31] = R[38] = R[45] = R[52] = N[13] = N[39] = K[4] = K[10] = K[15] = K[20] = K[25] = K[32] =
- K[39] = K[46] = K[52] = E[52] = F[25] = E[25] = F[26] = E[26] = G[34] = G[40] = G[46] =
- STAR[12] = STAR[14] = STAR[16] = STAR[36] = STAR[38] = STAR[40] = ZERO[7] = ZERO[8] =
- ZERO[9] = D[1] = D[2] = D[9] = D[16] = D[22] = D[28] = D[34] = D[40] = D[45] = D[49] = D[50] =
- B[10] = B[16] = B[22] = B[34] = B[40] = B[46] = POINT[43] = POINT[44] = POINT[49] = POINT[50] =
- ONE[24] = ONE[19] = ONE[14] = ONE[50] = ONE[52] = TWO[43] = TWO[38] = TWO[33] = TWO[12] =
- SEVEN[16] = SEVEN[22] = SEVEN[27] = SEVEN[33] = SEVEN[38] = SEVEN[44] = SEVEN[49] =
- THREE[12] = THREE[16] = THREE[22] = THREE[27] = THREE[33] = THREE[40] = THREE[46] = THREE[42] =
- FIVE[42] =SIX[24] = SIX[19] = SIX[14] = SIX[9] = EIGTH[12] = EIGTH[16] = EIGTH[18] = EIGTH[22] =
- NINE[12] = NINE[16] = NINE[18] = NINE[42] = true;
-
-
-
- /*boolean ONE[] = new boolean[54];
- boolean TWO[] = new boolean[54];
- boolean THREE[] = new boolean[54];
- boolean FOUR[] = new boolean[54];
- boolean FIVE[] = new boolean[54];
- boolean SIX[] = new boolean[54];
- boolean SEVEN[] = new boolean[54];
- boolean EIGTH[] = new boolean[54];
- boolean NINE[] = new boolean[54];*/
-
-
- Dimension d = size(); // of the canvas!
- if ((buffer2 == null) ||
- (d.width != buffersize2.width) ||
- (d.height != buffersize2.height)) {
- buffer2 = createImage(d.width, d.height);
- buffersize2 = d;
-
- bu2 = buffer2.getGraphics();
- }
-
- xstr = getParameter("MODE");
- ff = (xstr == null) ? 16 : Integer.valueOf(xstr).intValue();
- if (ff == 1) addition = 11;
- else addition = 0;
-
- bu2.setColor(black);
- bu2.fillRect(5,5,d.width-10,30);
- bu2.drawLine(0,0,d.width-1,0);
- bu2.drawLine(d.width-1,0,d.width-1,28+addition);
- bu2.drawLine(d.width-1,28+addition,0,28+addition);
- bu2.drawLine(0,28+addition,0,0);
- //White drawing
- bu2.setColor(white);
- bu2.drawLine(4,24+addition,d.width-5,24+addition);
- bu2.drawLine(d.width-5,24+addition,d.width-5,4);
- bu2.drawLine(1,27+addition,1,1);
- bu2.drawLine(1,1,d.width-2,1);
- //Gray drawing
- bu2.setColor(gray);
- bu2.drawLine(d.width-6,4,4,4);
- bu2.drawLine(4,4,4,23+addition);
- bu2.drawLine(d.width-2,1,d.width-2,27+addition);
- bu2.drawLine(d.width-2,27+addition,1,27+addition);
- //Light gray drawing
- bu2.setColor(lightgray);
- bu2.drawLine(2,26+addition,2,2);
- bu2.drawLine(2,2,d.width-3,2);
- //Dark gray drawing
- bu2.setColor(darkgray);
- bu2.drawLine(d.width-3,2,d.width-3,26+addition);
- bu2.drawLine(d.width-3,26+addition,2,26+addition);
- //Middle gray drawing
- bu2.setColor(middlegray);
- bu2.drawLine(3,25+addition,3,3);
- bu2.drawLine(3,3,d.width-4,3);
- bu2.drawLine(d.width-4,3,d.width-4,25+addition);
- bu2.drawLine(d.width-4,25+addition,3,25+addition);
- //Green Dots
- bu2.setColor(darkgreen);
- if (ff == 1) {
- for (j=0;j<=(d.width-12)/3;j++){
- for (i=0;i<=8;i++){
- bu2.fillRect(6+j*3,7+i*3,2,2);
- }
- }
- }
- else {
- for (j=0;j<=(d.width-12)/2;j++){
- for (i=0;i<=8;i++){
- bu2.fillRect(6+j*2,6+i*2,1,1);
- }
- }
- }
- index=1;
- at = getParameter("NUM");
- StringNum = (at == null) ? 16 : Integer.valueOf(at).intValue();
- StringNum = StringNum+1;
- at = getParameter("SPEED");
- Speed = (at == null) ? 16 : Integer.valueOf(at).intValue();
- Offset = 0;
- //if (!DontDraw){
- // g.drawImage(picture[0], 0,0, this);
- //}
- //DontDraw = false;
- //firsttime=false;
- //Black drawing
-
-
-
-
-
- index=1;
- ScrollIn=true;
- str = getParameter("TEXT"+ index);
- ScrollStateEnd=18;
- ScrollStateStart=str.length();
- notdraw = true;
- Offset=ScrollStateEnd*6;
- firsttime=true;
- //DontDraw = false;
- //picture[0] = getImage (getCodeBase(), "../images/LCD.gif");
- }
-
- public void drawYellowDot(Graphics g,int x,int y) {
- int ff;
- xstr = getParameter("MODE");
- ff = (xstr == null) ? 16 : Integer.valueOf(xstr).intValue();
- if (ff == 1) g.fillRect(6+x*3,7+y*3,2,2);
- else g.fillRect(6+x*2,6+y*2,1,1);
- }
-
- public void paint (Graphics g)
- {
- int i,j,ff;
- int x;
- Dimension d = size(); // of the canvas!
- // create the buffer if it does not yet exist:
- if ((buffer == null) ||
- (d.width != buffersize.width) ||
- (d.height != buffersize.height)) {
- buffer = createImage(d.width, d.height);
- buffersize = d;
- bu = buffer.getGraphics();
- }
- bu.drawImage(buffer2,0,0,null);
- g.drawImage(buffer,0,0,null);
- index=1;
- ScrollIn=true;
- str = getParameter("TEXT"+ index);
- xstr = getParameter("MODE");
- ff = (xstr == null) ? 16 : Integer.valueOf(xstr).intValue();
- if (ff == 1) ScrollStateEnd=((d.width-10)/18)+1;
- else ScrollStateEnd=(d.width-10)/12+1;
- ScrollStateStart=str.length();
- notdraw = true;
- Offset=ScrollStateEnd*6;
- firsttime=true;
- }
-
- public boolean mouseUp (Event evt, int x, int y)
- {
- /*int i;
- index += 1;
- if (index == StringNum+1)
- index =1;
- repaint();*/
- return true;
- }
-
- public void start() {
- if(killme == null)
- {
- killme = new Thread(this);
- killme.start();
- }
- }
-
- public void stop() {
- killme = null;
- }
-
- public void run() {
- int x,j,i,Nummer,ff;
- Graphics g = getGraphics();
- String colorstr;
-
- Dimension d = size(); // of the canvas!
- // create the buffer if it does not yet exist:
- if ((buffer == null) ||
- (d.width != buffersize.width) ||
- (d.height != buffersize.height)) {
- buffer = createImage(d.width, d.height);
- buffersize = d;
- bu = buffer.getGraphics();
- }
-
- if ((buffer2 == null) ||
- (d.width != buffersize2.width) ||
- (d.height != buffersize2.height)) {
- buffer2 = createImage(d.width, d.height);
- buffersize2 = d;
-
- bu2 = buffer2.getGraphics();
- }
-
- while (killme != null) {
- try {Thread.sleep(Speed*10);} catch (InterruptedException e){}
-
- //if (index==0) index = 1;
- str = getParameter("TEXT"+ index);
-
- if (str.length() == -ScrollStateEnd-1){
- index += 1;
- if (index >= StringNum)
- index =1;
- str = getParameter("TEXT"+ index);
- xstr = getParameter("MODE");
- ff = (xstr == null) ? 16 : Integer.valueOf(xstr).intValue();
- if (ff == 1) ScrollStateEnd=((d.width-10)/17)+1;
- else ScrollStateEnd=(d.width-10)/12+1;
-
- ScrollStateStart=str.length();
- notdraw = true;
- }
- bu.drawImage(buffer2,0,0,null);
-
- firsttime=false;
- Offset=ScrollStateEnd*6;
- if (Offset<0) Offset=0;
- DrawLCDString(bu, str);
- g.drawImage(buffer,0,0,null);
-
- ScrollStateEnd-=1;
- }
- killme = null;
- }
-
-
-
- }