📄 luminous.java
字号:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.StringTokenizer;
import java.util.Vector;
public class luminous extends Applet
implements Runnable
{
int w_width = 0;
int w_height = 0;
Image bgi = null;
Image backimage = null;
Image backi = null;
Image textimage = null;
Image tim = null;
Graphics bgg = null;
Graphics backig = null;
Graphics tgg = null;
Thread mythread = null;
int delay = 0;
int step = 0;
Color bgcolor = null;
Color textcolor = null;
MediaTracker mt = null;
Font font = null;
FontMetrics fm = null;
String text = null;
boolean done = false;
String fontname = null;
int fontsize = 0;
int fontstyle = 0;
URL link = null;
String target = null;
int ntext = 0;
PixelGrabber pgtext = null;
PixelGrabber pgbg = null;
int textpixels[] = null;
int bgpixels[] = null;
int pixx[] = null;
int pixy[] = null;
int maxstep = 0;
final int BLAST = 0;
final int FADE = 1;
final int SPIN = 2;
final int ROLL = 3;
int mode = 0;
int frommode = 0;
int tomode = 0;
public boolean mouseUp(Event event, int i, int j)
{
if(link != null)
{
getAppletContext().showDocument(link, target);
return true;
}
else
{
return false;
}
}
public boolean mouseEnter(Event event, int i, int j)
{
if(link != null)
showStatus(link.toString());
return true;
}
public boolean mouseExit(Event event, int i, int j)
{
if(link != null)
showStatus("");
return true;
}
int getParameter(String s1, int s2)
{
String s = getParameter(s1) ;
return (s != null) ? Integer.parseInt(s) : s2 ;
}
String getParameter(String s1, String s2)
{
String s = getParameter(s1) ;
return (s != null) ? s : s2 ;
}
Color getParameter(String s1, Color s2)
{
String s = getParameter(s1);
return (s != null)?new Color(Integer.parseInt(s, 16)):s2 ;
}
public luminous()
{
fontname = "TimesRoman";
fontsize = 14;
fontstyle = 1;
target = "_self";
maxstep = 10;
mode = 1;
frommode = 1;
tomode = 1;
}
public void init()
{
w_width = getSize().width;
w_height = getSize().height;
textcolor = new Color(0);
bgi = createImage(w_width, w_height);
bgg = bgi.getGraphics();
backi = createImage(w_width, w_height);
backig = backi.getGraphics();
delay = getParameter("DELAY",200);
bgcolor = getParameter("BGCOLOR",Color.white);
String s = getParameter("BGIMAGE","");
if(s != null)
{
backimage = getImage(getDocumentBase(), s);
mt = new MediaTracker(this);
mt.addImage(backimage, 0);
mt.checkAll(true);
}
font = new Font(fontname, fontstyle, fontsize);
bgg.setFont(font);
fm = bgg.getFontMetrics();
textimage = createImage(w_width, w_height);
tgg = textimage.getGraphics();
textpixels = new int[w_width * w_height];
bgpixels = new int[w_width * w_height];
nextText();
}
public void parsetag(String s)
{
s = s.trim();
for(StringTokenizer stringtokenizer=new StringTokenizer(s);
StringTokenizer.hasMoreTokens();)
{
String s1 = stringtokenizer.nextToken();
if(s1.toLowerCase().startsWith("color="))
try
{
textcolor = new Color(
Integer.parseInt(s1.substring(s1.indexOf("=")+
1, s1.length()), 16));
}
catch(NumberFormatException _ex) { }
if(s1.toLowerCase().startsWith("size"))
try
{
fontsize = Integer.parseInt(
s1.substring(s1.indexOf("=") +
1, s1.length()), 16);
}
catch(NumberFormatException _ex) { }
if(s1.toLowerCase().startsWith("style"))
try
{
fontstyle = Integer.parseInt(
s1.substring(s1.indexOf("=") +
1, s1.length()), 16);
}
catch(NumberFormatException _ex) { }
if(s1.toLowerCase().startsWith("font"))
fontname = s1.substring(s1.indexOf("=") +
1, s1.length());
if(s1.toLowerCase().startsWith("link"))
{
String s2 = s1.substring(s1.indexOf("=") +
1, s1.length());
if(s2.equalsIgnoreCase("null"))
link = null;
else
try
{
link = new URL(getDocumentBase(), s2);
}
catch(MalformedURLException _ex) { }
}
if(s1.toLowerCase().startsWith("target"))
target = s1.substring(s1.indexOf("=") +
1, s1.length());
if(s1.toLowerCase().startsWith("start"))
{
String s3 = s1.substring(s1.indexOf("=") +
1, s1.length()).toUpperCase().trim();
frommode = 0;
if(s3.equals("FADE"))
frommode = 1;
if(s3.equals("SPIN"))
frommode = 2;
if(s3.equals("ROLL"))
frommode = 3;
}
if(s1.toLowerCase().startsWith("end"))
{
String s4 = s1.substring(s1.indexOf("=") +
1, s1.length()).toUpperCase().trim();
tomode = 0;
if(s4.equals("FADE"))
tomode = 1;
if(s4.equals("SPIN"))
tomode = 2;
if(s4.equals("ROLL"))
tomode = 3;
}
}
}
public String parsetext(String s)
{
for(s = s.trim();
s.startsWith("|") && s.indexOf("|", 1) != -1;)
{
String s1 = s.substring(1, s.indexOf("|", 1));
parsetag(s1);
if(s.indexOf("|", 1) + 1 < s.length())
s = s.substring(s.indexOf("|", 1) + 1, s.length());
else
s = "";
}
font = new Font(fontname, fontstyle, fontsize);
bgg.setFont(font);
if((fontstyle & 0x2) != 0)
fm = bgg.getFontMetrics(
new Font(fontname, fontstyle & 0xfffffffd, fontsize));
else
fm = bgg.getFontMetrics();
return s.trim();
}
public void nextText()
{
text = getParameter("TEXT" + ntext,"END OF DATA");
if(text == "END OF DATA")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -