Initial
This commit is contained in:
94
java/IPLED/IPLED~1.JAV
Normal file
94
java/IPLED/IPLED~1.JAV
Normal file
@@ -0,0 +1,94 @@
|
||||
import java.awt.*;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Color;
|
||||
import java.util.Date;
|
||||
import java.awt.Frame;
|
||||
import java.awt.image.*;
|
||||
|
||||
public class IPLed extends java.applet.Applet implements Runnable
|
||||
{
|
||||
Thread mThread;
|
||||
final int smImageCount=12;
|
||||
Image[] mLedImages=new Image[smImageCount];
|
||||
String mStrParam;
|
||||
|
||||
public void init()
|
||||
{
|
||||
mLedImages[0]=getImage(getCodeBase(),"image/zero.gif");
|
||||
mLedImages[1]=getImage(getCodeBase(),"image/one.gif");
|
||||
mLedImages[2]=getImage(getCodeBase(),"image/two.gif");
|
||||
mLedImages[3]=getImage(getCodeBase(),"image/three.gif");
|
||||
mLedImages[4]=getImage(getCodeBase(),"image/four.gif");
|
||||
mLedImages[5]=getImage(getCodeBase(),"image/five.gif");
|
||||
mLedImages[6]=getImage(getCodeBase(),"image/six.gif");
|
||||
mLedImages[7]=getImage(getCodeBase(),"image/seven.gif");
|
||||
mLedImages[8]=getImage(getCodeBase(),"image/eight.gif");
|
||||
mLedImages[9]=getImage(getCodeBase(),"image/nine.gif");
|
||||
mLedImages[10]=getImage(getCodeBase(),"image/dash.gif");
|
||||
mLedImages[11]=getImage(getCodeBase(),"image/blank.gif");
|
||||
mStrParam=new String(getParameter("address"));
|
||||
if(null==mStrParam)mStrParam="255.255.255.255";
|
||||
MediaTracker mediaTracker=new MediaTracker(this);
|
||||
for(int imageIndex=0;imageIndex<smImageCount;imageIndex++)mediaTracker.addImage(mLedImages[imageIndex],imageIndex);
|
||||
try(mediaTracker.waitForAll());
|
||||
catch(InterruptedException ie){;}
|
||||
repaint();
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
public void start()
|
||||
{
|
||||
if(mThread==null){mThread=new Thread(this);mThread.start();}
|
||||
}
|
||||
public void stop()
|
||||
{
|
||||
if(null!=mThread){mThread.stop();mThread=null;}
|
||||
}
|
||||
public void paint(Graphics graphics)
|
||||
{
|
||||
drawLEDString(mStrParam,graphics);
|
||||
}
|
||||
public void drawLEDString(String strLED,Graphics graphics)
|
||||
{
|
||||
int strLength=strLED.length();
|
||||
int imageWidth;
|
||||
int imageHeight;
|
||||
Point ptLoc;
|
||||
|
||||
ptLoc=new Point(4,4);
|
||||
imageWidth=mLedImages[0].getWidth(this);
|
||||
imageHeight=mLedImages[0].getHeight(this);
|
||||
for(int strIndex=0;strIndex<strLength;strIndex++)
|
||||
{
|
||||
char strChar=strLED.charAt(strIndex);
|
||||
|
||||
if('0'==strChar)graphics.drawImage(mLedImages[0],ptLoc.x,ptLoc.y,this);
|
||||
else if('1'==strChar)graphics.drawImage(mLedImages[1],ptLoc.x,ptLoc.y,this);
|
||||
else if('2'==strChar)graphics.drawImage(mLedImages[2],ptLoc.x,ptLoc.y,this);
|
||||
else if('3'==strChar)graphics.drawImage(mLedImages[3],ptLoc.x,ptLoc.y,this);
|
||||
else if('4'==strChar)graphics.drawImage(mLedImages[4],ptLoc.x,ptLoc.y,this);
|
||||
else if('5'==strChar)graphics.drawImage(mLedImages[5],ptLoc.x,ptLoc.y,this);
|
||||
else if('6'==strChar)graphics.drawImage(mLedImages[6],ptLoc.x,ptLoc.y,this);
|
||||
else if('7'==strChar)graphics.drawImage(mLedImages[7],ptLoc.x,ptLoc.y,this);
|
||||
else if('8'==strChar)graphics.drawImage(mLedImages[8],ptLoc.x,ptLoc.y,this);
|
||||
else if('9'==strChar)graphics.drawImage(mLedImages[9],ptLoc.x,ptLoc.y,this);
|
||||
else if('.'==strChar)graphics.drawImage(mLedImages[10],ptLoc.x,ptLoc.y,this);
|
||||
else graphics.drawImage(mLedImages[11],ptLoc.x,ptLoc.y,this);
|
||||
ptLoc.x+=imageWidth;
|
||||
}
|
||||
graphics.setColor(new Color(48,64,0));
|
||||
graphics.drawLine(3,3,ptLoc.x,3);
|
||||
graphics.drawLine(3,3,3,imageHeight+4);
|
||||
graphics.setColor(new Color(175,192,224));
|
||||
graphics.drawLine(3,imageHeight+4,ptLoc.x,imageHeight+4);
|
||||
graphics.drawLine(ptLoc.x,3,ptLoc.x,imageHeight+4);
|
||||
graphics.setColor(new Color(96,143,208));
|
||||
graphics.drawRect(2,2,(ptLoc.x+1)-2,imageHeight+3);
|
||||
graphics.setColor(new Color(175,192,224));
|
||||
graphics.drawLine(1,1,ptLoc.x+2,1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user