Splash.java
/*
* Copyright © 2012 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners.
* See LICENSE.TXT for license information.
*/
package com.nokia.example.paint.views;
import com.nokia.example.paint.helpers.ImageLoader;
import com.nokia.example.paint.views.components.Button;
import com.nokia.example.paint.views.components.ProjectsButton;
import com.nokia.example.paint.views.components.ProjectsButtonS60;
import com.nokia.example.paint.views.components.StartButton;
import com.nokia.example.paint.views.components.StartButtonS60;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
public class Splash
extends GameCanvas {
private Image infoImg;
private Button startBtn;
private Button projectsBtn;
public Splash() {
super(false);
setFullScreenMode(true);
ImageLoader il = ImageLoader.getInstance();
int horizontalCenter = getWidth() / 2;
int verticalCenter = getHeight() / 2;
if (getWidth() > 240) {
infoImg = il.loadImage("/info_view_large.png");
startBtn = new StartButtonS60();
startBtn.setPosition(horizontalCenter - startBtn.getWidth() / 2, verticalCenter + 103);
projectsBtn = new ProjectsButtonS60();
projectsBtn.setPosition(horizontalCenter - projectsBtn.getWidth() / 2, verticalCenter + 227);
}
else {
infoImg = il.loadImage("/info_view_small.png");
startBtn = new StartButton();
startBtn.setPosition(horizontalCenter - startBtn.getWidth() / 2, verticalCenter + 56);
projectsBtn = new ProjectsButton();
projectsBtn.setPosition(horizontalCenter - projectsBtn.getWidth() / 2, verticalCenter + 107);
}
}
protected void render() {
Graphics g = getGraphics();
g.drawImage(infoImg, getWidth() / 2, getHeight() / 2, Graphics.HCENTER | Graphics.VCENTER);
startBtn.render(g);
projectsBtn.render(g);
flushGraphics();
}
protected void showNotify() {
render();
}
protected void pointerPressed(int x, int y) {
startBtn.pressed(x, y);
projectsBtn.pressed(x, y);
render();
}
protected void pointerReleased(int x, int y) {
startBtn.unpressed(x, y);
projectsBtn.unpressed(x, y);
render();
}
}