📄 intro.java
字号:
import java.awt.*;import java.awt.event.*;import java.awt.image.BufferedImage;import java.awt.font.*;import javax.swing.*;import java.util.List;import java.util.Arrays;
public class intro extends JPanel{
static BufferedImage bimg;
static intro myintro;
public drawThread thread ;
static Image img;
static String info1[]={"工具栏使用说明",
"缩小地图:","将当前显示的地图长宽缩小为原来的0.83倍",
"放大地图:","将当前显示的地图长宽放大为原来的1.20倍",
"显示地图:","显示当前选中的地图(支持多选)",
"打开文件:","打开Gum格式文件(支持一次打开多个文件)",
"拖动: ","当按钮为 蓝色 时表示当前处于拖动状态,按住鼠标左键可以拖动地图",
"选择放大:","当按钮为 蓝色 时表示当前处于选择放大状态,按住鼠标左键可以选中区域放大",
"说明 :","当这两个按钮都不选中时表示当前状态为选择状态,单击鼠标左键可以选中当前元素",
"功能设置:","设置一些参数和配置",
"关于程序:","关于这个程序的一点说明"};
static Font fonts[]={new Font("宋体", Font.BOLD , 18),
new Font("宋体", Font.PLAIN, 16)};
static Color colors[]={Color.black,Color.gray ,new Color(0,0,102)};
public intro()
{
img=getImage();
thread=new drawThread();
}
public void start()
{
if( thread!=null)
thread.start();
}
public void stop()
{
if( thread!=null)
thread.stop();
}
public void restart()
{
stop();
thread=new drawThread();
thread.start();
}
public void paint(Graphics g)
{
super.paint(g);
if(bimg!=null)
g.drawImage((Image)bimg,0,0,this);
}
public Image getImage() { Image img = this.getToolkit().createImage(getClass().getResource(".\\resources\\images\\cupanim.gif")); MediaTracker tracker = new MediaTracker(this); tracker.addImage(img, 0); try { tracker.waitForID(0); if (tracker.isErrorAny()) { System.out.println("Error loading image " ); } } catch (Exception ex) { ex.printStackTrace(); } return img; }
public static void main(String args[])
{
myintro=new intro(); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) {System.exit(0);} public void windowDeiconified(WindowEvent e) { myintro.start(); } public void windowIconified(WindowEvent e) { myintro.stop(); } }; JFrame f = new JFrame("Intro"); f.addWindowListener(l); f.getContentPane().add("Center", myintro); f.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int w = 720; int h = 510; f.setLocation(screenSize.width/2 - w/2, screenSize.height/2 - h/2); f.setSize(w, h); f.setVisible(true);
myintro.start();
}
class drawThread extends Thread
{
private Rectangle currrect,rect1, rect2;
public void run()
{
currrect=intro.myintro.getVisibleRect();
intro.bimg=(BufferedImage) createImage(currrect.width,currrect.height);
Graphics2D g2 = intro.bimg.createGraphics();
g2.setBackground(Color.white);
rect1=new Rectangle(20,0,40,0);
rect2=new Rectangle(0,20,0,40);
for(int i=0;i<=50;i++)
{
g2.clearRect(0, 0, currrect.width , currrect.height);
currrect=intro.myintro.getVisibleRect();
rect2.x=currrect.width*(50-i)/50;
rect2.width =currrect.width*i/50;
g2.setColor(Color.green);
g2.fillRect(rect2.x,rect2.y,rect2.width,rect2.height);
rect1.y=currrect.height*(50-i)/50;
rect1.height=currrect.height*i/50;
g2.setColor(Color.red);
g2.fillRect(rect1.x,rect1.y,rect1.width,rect1.height);
g2.drawImage(intro.img,30,30,null);
intro.myintro.repaint();
try{
sleep(20);
}
catch(Exception ex){}
}
g2.setFont(fonts[0]);
g2.setColor(colors[0]);
for(int i=1;i<=intro.info1[0].length();i++)
{
g2.drawString(intro.info1[0].substring(0,i),100,100);
intro.myintro.repaint();
try{
sleep(10);
}
catch(Exception ex){}
}
g2.setFont(fonts[1]);
for(int j=1;j<intro.info1.length;j+=2)
{
for(int i=1;i<=intro.info1[j].length();i++)
{
g2.setColor(colors[1]);
g2.drawString(intro.info1[j].substring(0,i),120,150+j*16);
intro.myintro.repaint();
try{
sleep(10);
}
catch(Exception ex){}
}
for(int i=1;i<=intro.info1[j+1].length();i++)
{
g2.setColor(colors[2]);
g2.drawString(intro.info1[j+1].substring(0,i),200,150+j*16);
intro.myintro.repaint();
try{
sleep(10);
}
catch(Exception ex){}
}
}
g2.setFont(new Font("serif", Font.PLAIN, 26));
g2.setColor(Color.orange );
String thx="Thank you for using!";
for(int i=1;i<=thx.length();i++)
{
g2.drawString(thx.substring(0,i),250,500);
intro.myintro.repaint();
try{
sleep(10);
}
catch(Exception ex){}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -