📄 splashscreen.java
字号:
/*
* Copyright (C) 2005-2006 Leopardo.f
*
* This file is part of M-SuDoKu, a J2ME version of SuDoKu.
*
* M-SuDoKu 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.
*
* M-SuDoKu 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 M-SuDoKu; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. Or, visit http://www.gnu.org/copyleft/gpl.html
*/
package MSuDoKu;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.*;
import java.io.IOException;
/**
* Class implementing splash screen
* @see App
* @author Leopardo.f
*/
public class SplashScreen extends Canvas
//public class PorcoDio extends FullCanvas
{
private static final String sBack = "sfondo.PNG", sLogo = "logo4.png";
private Display dCurrent;
private Displayable dbleNext;
private Timer tShow;
private Image iBack, iLogo;
private int nTime2Show;
private byte yCount;
private SplashScreen pdThis;
public SplashScreen (Display d, Displayable dble, int nT)
{
dCurrent = d;
dbleNext =dble;
nTime2Show = nT;
tShow = new Timer();
pdThis = this;
try
{
iBack = Image.createImage ("/MSuDoKu/" + sBack);
iLogo = Image.createImage ("/MSuDoKu/" + sLogo);
} catch (IOException ioe)
{
// ioe.printStackTrace();
// System.out.println ("Img not found: " + sBack + ", " + sLogo);
iBack = null;
iLogo = null;
nTime2Show = 0;
}
dCurrent.setCurrent (this);
}
protected void paint (Graphics g)
{
int yDim, xDim, xDimImg, yDimImg, x, y;
xDim = getWidth();
yDim = getHeight();
if (iBack != null)
{
xDimImg = iBack.getWidth();
yDimImg = iBack.getHeight();
for (x = 0; x < xDim; x += xDimImg)
for (y = 0; y < yDim; y += yDimImg)
g.drawImage (iBack, x, y, Graphics.TOP|Graphics.LEFT);
}
if (iLogo != null)
{
g.setClip ((xDim - iLogo.getWidth()) / 2, (yDim - iLogo.getHeight()) / 2, iLogo.getWidth(), iLogo.getHeight());
g.drawImage (iLogo, xDim / 2, yDim / 2, Graphics.VCENTER | Graphics.HCENTER);
g.setClip (0, 0, xDim, yDim);
}
}
protected void keyPressed (int nCode)
{
hide();
}
protected void pointerPressed (int nCode)
{
hide();
}
private void hide()
{
tShow.cancel();
dCurrent.setCurrent (dbleNext);
}
protected void showNotify()
{
if (nTime2Show > 0)
tShow.schedule (new TimerTask ()
{
public void run()
{
pdThis.hide();
}
}, nTime2Show, nTime2Show);
else
pdThis.hide();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -