📄 splashscreen.java
字号:
/*
* YALE - Yet Another Learning Environment
* Copyright (C) 2001-2004
* Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,
* Katharina Morik, Oliver Ritthoff
* Artificial Intelligence Unit
* Computer Science Department
* University of Dortmund
* 44221 Dortmund, Germany
* email: yale-team@lists.sourceforge.net
* web: http://yale.cs.uni-dortmund.de/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
package edu.udo.cs.yale.gui;
import edu.udo.cs.yale.tools.Tools;
import java.awt.Color;
import java.awt.Paint;
import java.awt.Image;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import javax.swing.JWindow;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
public class SplashScreen extends InfoBox implements MouseListener {
private Image logo;
private static Image javaLogo;
private static final Paint MAIN_PAINT = Color.lightGray;
private double logoHeight = 1;
private double dropSpeed;
private JWindow window = new JWindow();
private String message = "Starting up.";
static {
try {
javaLogo = ImageIO.read(Tools.getResource("java_cup_logo.gif"));
} catch (IOException e) {
e.printStackTrace();
}
}
public SplashScreen(String productName, String version, Image logo) {
super(400,300, (logo == null) ? 50 : (int)(logo.getHeight(null)*1.2),
productName, 48, version, 36);
this.logo = logo;
if (logo != null)
addMouseListener(this);
window.getContentPane().add(this);
window.pack();
window.setLocation((int)(Toolkit.getDefaultToolkit().getScreenSize().getWidth()/2-window.getWidth()/2),
(int)(Toolkit.getDefaultToolkit().getScreenSize().getHeight()/2-window.getHeight()/2));
}
public void showSplashScreen() {
window.show();
}
public void dispose() {
window.dispose();
}
protected void drawNorth(Graphics2D g) {
super.drawNorth(g);
if (logo != null) {
Graphics2D scaled = (Graphics2D)g.create(getWidth() - logo.getWidth(null) - PRODUCT_NAME_X,
(int)(logo.getHeight(null)*0.1) + (int)((1.0-logoHeight)*logo.getHeight(null)),
logo.getWidth(null), logo.getHeight(null));
scaled.scale(1, logoHeight);
scaled.drawImage(logo, 0, 0, null);
scaled.dispose();
}
}
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.black);
g.drawRect(0, 0, getWidth()-1, getHeight()-1);
}
public void drawMain(Graphics2D g) {
g.setPaint(MAIN_PAINT);
g.fillRect(0, 0, getWidth(), getMainHeight());
g.setPaint(NORTH_PAINT);
g.setFont(new java.awt.Font("LucidaSans", java.awt.Font.BOLD, 12));
g.drawString("YALE - Yet Another Learning Environment", 10, 20);
g.setFont(new java.awt.Font("LucidaSans", java.awt.Font.BOLD, 10));
g.drawString(message, 10,35);
g.setFont(new java.awt.Font("LucidaSans", java.awt.Font.PLAIN, 10));
g.drawString("Copyright (C) 2001-2004 by", 10, 100);
g.drawString("Simon Fischer, Ralf Klinkenberg,", 10, 113);
g.drawString("Ingo Mierswa, Katharina Morik, and Oliver Ritthoff", 10, 126);
g.drawString("Use is subject to the GNU General Public License", 10, 139);
if (javaLogo != null)
g.drawImage(javaLogo, 335, 85, null);
}
public void mouseClicked(MouseEvent e) {
int lx = getWidth() - logo.getWidth(null) - PRODUCT_NAME_X;
int ly = (int)(logo.getHeight(null)*0.1);
if ((e.getX() >= lx) &&
(e.getX() >= ly) &&
(e.getX() < lx + logo.getWidth(null)) &&
(e.getY() < ly + logo.getHeight(null))) {
new Thread() {
public void run() {
setPriority(Thread.MIN_PRIORITY);
dropSpeed = 0.01;
while (logoHeight > 0) {
logoHeight -= dropSpeed;
dropSpeed += 0.01;
repaint();
try {
Thread.sleep(50);
} catch (InterruptedException e) {}
}
}
}.start();
}
}
public void mousePressed(MouseEvent param1) {}
public void mouseReleased(MouseEvent param1) {}
public void mouseEntered(MouseEvent param1) {}
public void mouseExited(MouseEvent param1) {}
public void setMessage(String message) {
this.message = message;
repaint();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -