亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? postcardcanvas.java

?? J2ME MIDP_Example_Applications
?? JAVA
字號:
// Copyright 2002 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.


package example.postcard;

import javax.microedition.lcdui.*;
import java.util.Random;
import java.util.Vector;


// The main canvas of the MIDlet. It contains text and a floating
// animation, and plays a tune (Smart Messaging Ringing Tone format).

class PostcardCanvas
    extends Canvas
    implements CommandListener, Runnable
{
    private static final int BORDER = 2;
    private static final int SLIDER_WIDTH = 4;
    private static final Font FONT = Font.getFont(Font.FACE_MONOSPACE,
        Font.STYLE_PLAIN, Font.SIZE_SMALL);

    private final PostcardMIDlet midlet;
    private final Command exitCommand;
    private final Command silentCommand;
    private final Command playCommand;
    private final ContinuousTunePlayer player;

    private final int lineHeight, lineWidth, maxLines;
    private final Vector textLines = new Vector();

    private int topLine = 0;
    private volatile Thread animationThread = null;
    private Animation animation = null;
    private boolean isUpPressed = false;
    private boolean isDownPressed = false;
    private boolean firstPlayRequest = true;
    private volatile boolean isPlaying = false;


    // The constructor for the PostcardCanvas:
    // 'midlet' is the parent MIDlet, used for callbacks such as exit requests.
    // 'message' is the text message to be displayed.
    // 'tune' is a hexadecimal representation of the tune to be played.
    //     The bytes are in Smart Messaging Ringing Tone format.
    // 'animationSequence' is the sequence of animation images.
    //     It may be null. In that case, no animation is
    //     performed and just the text and tune are used.

    PostcardCanvas(PostcardMIDlet midlet, String message, String tune,
        AnimationSequence animationSequence)
    {
        this.midlet = midlet;

        lineWidth = getWidth() - (2 * BORDER) - SLIDER_WIDTH;
        lineHeight = FONT.getHeight();
        maxLines = (getHeight() - (2 * BORDER)) / lineHeight;


        // Split the message into multiple lines of text.
        // The approach used isn't very smart. It doesn't do word
        // splitting or word wrapping, to keep this example simple.
        if (FONT.stringWidth(message) < lineWidth)
        {
            // the message fits in a single line of text
            textLines.addElement(message);
        }
        else
        {
            // multiple lines of text are needed
            int offset = 0;
            int len = 1;
            while((offset + len) <= message.length())
            {
                while(((offset + len) <= message.length()) &&
                     (FONT.substringWidth(message, offset, len) <= lineWidth))
                {
                    len++;
                }
                textLines.addElement(message.substring(offset,
                                                       offset + len - 1));
                offset += (len - 1);
                len = 1;
            }
        }


        // create the animation sequence
        if (animationSequence != null)
        {
            try
            {
                animation = new Animation(animationSequence, BORDER, BORDER,
                                          (getWidth() - SLIDER_WIDTH - BORDER),
                                          (getHeight() - BORDER));
            }
            catch(Exception e)
            {
                // By default, animation is null.
            }
        }


        // create the tune player
        player = makeContinuousTunePlayer();
        if (tune != null)
        {
            try
            {
                player.setTune(tune);
            }
            catch(Exception e)
            {
                // There is some problem with the setting (e.g. invalid
                // hexadecimal data, invalide tune data) or playing the tune.
                // A tune will not be played in this case.
            }
        }


        // add the screen's commands
        exitCommand = new Command("Exit", Command.EXIT, 1);
        addCommand(exitCommand);
        if (player.hasSoundSupport())
        {
            playCommand = new Command("Play", Command.SCREEN, 2);
            silentCommand = new Command("Silent", Command.SCREEN, 2);
            addCommand(playCommand);
        }
        else
        {
            playCommand = null;
            silentCommand = null;
        }
        setCommandListener(this);
    }


    synchronized void start()
    {
        animationThread = new Thread(this);
        animationThread.start();

        player.restart();
    }


    synchronized void stop()
    {
        animationThread = null;

        player.stop();
    }


    public void run()
    {
        int millisPerTick = 100;

        Thread currentThread = Thread.currentThread();

        try
        {
            // This ends when animationThread is set to null, or when
            // it is subsequently set to a new thread; either way, the
            // current thread should terminate
            while (currentThread == animationThread)
            {
                long startTime = System.currentTimeMillis();

                // No animation progress if we are hidden by a system screen.
                if (isShown())
                {
                    tick();

                    repaint(0, 0, getWidth(), getHeight());
                    serviceRepaints();
                }

                long timeTaken = System.currentTimeMillis() - startTime;
                if (timeTaken < millisPerTick)
                {
                    synchronized (this)
                    {
                        wait(millisPerTick - timeTaken);
                    }
                }
                else
                {
                    currentThread.yield();
                }
            }
        }
        catch (InterruptedException e)
        {
        }
    }


    private void tick()
    {
        if (isUpPressed)
        {
            if ((topLine - 1) < 0)
            {
                topLine = 0;
            }
            else
            {
                topLine--;
            }
        }
        else if (isDownPressed)
        {
            if (textLines.size() > 0)
            {
                if ((topLine + maxLines) < textLines.size())
                {
                    topLine++;
                }
            }
        }

        if (animation != null)
        {
            animation.tick();
        }
    }


    public void paint(Graphics g)
    {
        // wipe the entire canavas clean
        g.setColor(0xffffff); // WHITE
        g.fillRect(0, 0, getWidth(), getHeight());

        // draw the animation

        g.setColor(0x000000); // BLACK
        g.setFont(FONT);
        int ix=0;
        for (ix=0; ((ix < maxLines) && ((topLine + ix) < textLines.size()));
             ix++)
        {
            g.drawString((String)textLines.elementAt(topLine + ix),
                         BORDER, (BORDER + (lineHeight * ix)),
                         (Graphics.TOP | Graphics.LEFT));
        }

        // Add a 'slider' in case the number of text lines
        // is longer than fits on one display.
        if (textLines.size() > maxLines)
        {
            drawSlider(g, topLine, textLines.size());
        }

        animation.draw(g);
    }


    public void keyPressed(int keyCode)
    {
        int action = getGameAction(keyCode);
        if (action == UP)
        {
            isUpPressed = true;
            isDownPressed = false;
            if (topLine > 0)
            {
                topLine--;
            }
        }
        else if (action == DOWN)
        {
            isDownPressed = true;
            isUpPressed = false;
            if((topLine + maxLines) < textLines.size())
            {
                topLine++;
            }
        }
    }


    public void keyReleased(int keyCode)
    {
        int action = getGameAction(keyCode);
        if (action == UP)
        {
            isUpPressed = false;
        }
        else if (action == DOWN)
        {
            isDownPressed = false;
        }
    }


    // If the number of text lines exceeds the amount that can
    // be displayed in one screen, then a text slider is drawn
    // to indicate the position of the displayed text within
    // the entire text message.

    private void drawSlider(Graphics g, int index, int length)
    {
        int x = getWidth() - SLIDER_WIDTH;
        int y = 0;
        // The text slider is drawn in the area from
        // {x, y} = {x, 0} to {x + SLIDER_WIDTH, getHeight()}

        int sy = 2; // initial slider y-position
        int sh = 6; // slider height in pixels

        // Leave a 2 pixel offset at the top and bottom, for the slider's rail
        // to protrude past the slider. The rail's length = full canvas height.
        int syMax = getHeight() - sh - 2 - 2;

        if ((index == 0) || (length == 0))
        {
            sy = 2;
        }
        else
        {
            sy = 2 + ((syMax * index) / length);
        }

                                               // (x+0 is empty space)
        g.setColor(0x000000);                  // BLACK
        g.drawLine(x+1, sy, x+1, sy+sh);       //   slider
        g.drawLine(x+2, 0,  x+2, getHeight()); //   rail
        g.drawLine(x+3, sy, x+3, sy+sh);       //   slider
        g.setColor(0xffffff);                  // WHITE
        g.drawLine(x+2, sy, x+2, sy+sh);       //   slider
    }


    public void commandAction(Command c, Displayable d)
    {
        if (c == exitCommand)
        {
            stop();
            midlet.exitRequested();
        }
        else if (player.hasSoundSupport() && (c == silentCommand))
        {
            setIsPlaying(false);
            player.stop();
            removeCommand(silentCommand);
            addCommand(playCommand);
        }
        else if (player.hasSoundSupport() && (c == playCommand))
        {
            setIsPlaying(true);
            if (firstPlayRequest)
            {
                firstPlayRequest = false;
                player.playContinuously();
            }
            else
            {
                player.restart();
            }
            removeCommand(playCommand);
            addCommand(silentCommand);
        }
    }


    private synchronized void setIsPlaying(boolean isPlaying)
    {
        this.isPlaying = isPlaying;
    }


    public void hideNotify()
    {
        setIsPlaying(false);
        player.stop();

        // We aren't sure which commands are currently available;
        // we remove both to be safe and add the play command so
        // it's available when the MIDlet is visible again.
        // Rather than using 'showNotify' to resume playing, allow
        // a manually requested resume using the 'Play' command.
        removeCommand(playCommand);
        removeCommand(silentCommand);
        addCommand(playCommand);
    }


    private static ContinuousTunePlayer makeContinuousTunePlayer()
    {
       // Other types of ContinuousTunePlayers could be
       // added here in the future if needed.

       ContinuousTunePlayer player;
       try
       {
           // Throw an exception if no Nokia UI API available.
           Class.forName("com.nokia.mid.sound.Sound");
           Class clas = Class.forName(
               "example.postcard.NokiaContinuousTunePlayer");
           player = (ContinuousTunePlayer)(clas.newInstance());
       }
       catch (Exception e)
       {
           player = new ContinuousTunePlayer();
       }

       return player;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丝袜美腿亚洲综合| av不卡免费电影| 亚洲大型综合色站| 亚洲国产日韩在线一区模特 | 国产精品沙发午睡系列990531| 欧美一级专区免费大片| 91精品国产麻豆国产自产在线| 欧美另类z0zxhd电影| 欧美一区二区三区小说| 日韩欧美三级在线| 精品日韩在线观看| 国产精品拍天天在线| 亚洲日本va午夜在线电影| 一区二区三区四区视频精品免费| 亚洲国产欧美一区二区三区丁香婷| 亚洲成国产人片在线观看| 日韩精品乱码av一区二区| 精品一区二区三区av| 国模套图日韩精品一区二区| 成人久久18免费网站麻豆| 91黄色激情网站| 91精品黄色片免费大全| 精品国产麻豆免费人成网站| 中文字幕一区二区三区视频| 一区二区三区在线免费视频| 日韩电影免费一区| 丁香另类激情小说| 欧美最猛黑人xxxxx猛交| 精品嫩草影院久久| 一区二区三区在线视频观看| 久久99精品国产91久久来源| 成人免费观看av| 欧美高清一级片在线| 国产视频一区不卡| 亚洲国产欧美在线| 成人免费毛片aaaaa**| 日本大香伊一区二区三区| 日韩美女一区二区三区四区| 亚洲视频一二三区| 激情偷乱视频一区二区三区| 色香色香欲天天天影视综合网| 欧美大片一区二区三区| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 91最新地址在线播放| 欧美精品在线一区二区| 国产欧美一二三区| 爽好多水快深点欧美视频| 国产精品456露脸| 欧美老肥妇做.爰bbww| 亚洲天堂网中文字| 国产91精品一区二区麻豆网站| 欧美猛男超大videosgay| 亚洲欧美日韩国产综合| 国产精品1区2区3区| 欧美成人免费网站| 天堂资源在线中文精品| 91国模大尺度私拍在线视频| 久久久亚洲高清| 精品一区二区三区视频| 欧美日韩国产另类不卡| 亚洲综合色网站| 成人免费视频国产在线观看| 久久婷婷成人综合色| 麻豆91在线播放免费| 欧美一区二区三区人| 午夜精品久久久久久久| 欧美色综合网站| 亚洲成人免费看| 欧美调教femdomvk| 亚洲成a人在线观看| 在线中文字幕一区二区| 一区二区三区中文字幕在线观看| jlzzjlzz亚洲日本少妇| 欧美国产日韩精品免费观看| 国产一区999| 欧美国产日本视频| 99久久免费精品| 亚洲伦在线观看| 欧美中文字幕久久| 日产精品久久久久久久性色| 欧美一级爆毛片| 精品一区二区在线看| 欧美精品一区二区久久久| 精品一区二区三区av| 国产欧美一区二区三区在线看蜜臀 | 国产99久久久久| 宅男噜噜噜66一区二区66| 中文字幕日韩av资源站| 色哟哟一区二区在线观看| 一区二区三区精品| 色狠狠一区二区三区香蕉| 日韩1区2区3区| 欧美性一二三区| 亚洲国产成人av网| 91精品久久久久久久久99蜜臂| 免费在线欧美视频| 久久久久亚洲综合| 91麻豆国产香蕉久久精品| 亚洲超丰满肉感bbw| 日韩精品一区二区三区在线| 国产中文字幕精品| 亚洲欧美日韩中文字幕一区二区三区 | 91亚洲精华国产精华精华液| 中文字幕第一页久久| 99v久久综合狠狠综合久久| 一区二区国产视频| 777午夜精品视频在线播放| 蜜臀av性久久久久av蜜臀妖精| 2023国产精品自拍| 91成人国产精品| 老色鬼精品视频在线观看播放| 久久久久亚洲综合| 欧美亚洲精品一区| 国产成人精品一区二区三区网站观看| 国产精品传媒入口麻豆| 日韩免费高清视频| 在线免费亚洲电影| 国产美女精品在线| 亚洲成人动漫精品| 中文字幕日韩一区二区| 精品免费一区二区三区| 欧美综合一区二区| 成人免费高清在线观看| 激情综合色播五月| 天天做天天摸天天爽国产一区| 中文一区在线播放| 日韩三级在线观看| 色天天综合久久久久综合片| 国产精品小仙女| 日本系列欧美系列| 香蕉影视欧美成人| 伊人婷婷欧美激情| 国产精品久久久久久久久快鸭| 日韩欧美国产高清| 欧美区在线观看| 色婷婷精品久久二区二区蜜臀av | 欧美性xxxxxx少妇| 粉嫩嫩av羞羞动漫久久久| 日韩国产欧美在线视频| 中文字幕一区二区三区不卡在线| 日韩免费高清视频| 欧美一区二区三区四区在线观看 | 欧美亚一区二区| 粉嫩嫩av羞羞动漫久久久| 日本不卡一区二区三区高清视频| 艳妇臀荡乳欲伦亚洲一区| 国产精品美女久久久久久| 欧美精品一区二区在线播放| 538prom精品视频线放| 欧美三级一区二区| 欧美色欧美亚洲另类二区| 91美女片黄在线观看| 99精品国产视频| www.成人在线| 91亚洲精品乱码久久久久久蜜桃| 99国产精品视频免费观看| 一本久久a久久精品亚洲| 99久久久国产精品免费蜜臀| av不卡免费电影| 色偷偷88欧美精品久久久| 色狠狠一区二区| 色94色欧美sute亚洲线路一ni| 在线一区二区观看| 欧美视频中文一区二区三区在线观看| 91免费视频网| 欧美羞羞免费网站| 日韩一区二区免费在线电影| 精品国产一区二区精华| 欧美精品一区二区三区蜜桃视频| 久久久青草青青国产亚洲免观| 久久精品无码一区二区三区| 国产欧美一区二区三区沐欲 | 在线精品视频免费观看| 色琪琪一区二区三区亚洲区| 91精品国产综合久久久久久漫画| 亚洲精品在线三区| 自拍偷拍亚洲综合| 日韩二区三区四区| 久久97超碰色| 91欧美一区二区| 91麻豆精品国产91久久久久久久久| 在线播放91灌醉迷j高跟美女 | 中文字幕国产一区二区| 一区二区在线观看视频在线观看| 一区精品在线播放| 免费看日韩精品| 暴力调教一区二区三区| 欧美日韩亚洲丝袜制服| 精品久久久久久亚洲综合网| 中文字幕精品一区| 免费在线欧美视频| 麻豆久久久久久| 在线免费av一区| 久久综合九色欧美综合狠狠| 亚洲视频一二三| 全部av―极品视觉盛宴亚洲| 国产盗摄女厕一区二区三区| 欧美日韩在线播放三区四区| 26uuu色噜噜精品一区| 亚洲视频在线一区观看|