SplashView.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.racer.views;

import com.nokia.example.racer.Main;
import com.nokia.example.racer.helpers.ImageLoader;
import java.io.IOException;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class SplashView
    extends View {

    private Image splash, splashLandscape;

    /**
     * SplashView constructor. Loads the needed resources.
     */
    public SplashView() {
        super();
        try {
            splash = ImageLoader.getInstance().loadImage("/splash_screen.png");
            splashLandscape = ImageLoader.getInstance().loadImage(
                "/splash_screen_landscape.png");
        }
        catch (IOException io) {
        }
    }

    /**
     * Paints the splash screen image (landscape image if in landscape mode)
     *
     * @param g Graphics object
     */
    public void paint(Graphics g) {
        if (Main.landscape) {
            g.drawImage(splashLandscape, 0, 0, g.TOP | g.LEFT);
        }
        else {
            g.drawImage(splash, 0, -40, g.TOP | g.LEFT);
        }
    }

    protected void pointerPressed(int x, int y) {
    }

    protected void pointerReleased(int x, int y) {
    }
}