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

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

?? popup.java

?? 這是一個較好的RPG手機游戲,值得學習與參考
?? JAVA
字號:


package popup;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

public class Popup implements Runnable
{

  public static final char[][] ALT_OK;
  public static final char[][] ALT_YES_NO;


  static
  {
    ALT_OK = new char[1][];
    ALT_OK[0] = "確定".toCharArray();
    ALT_YES_NO = new char[2][];
    ALT_YES_NO[0] = "是".toCharArray();
    ALT_YES_NO[1] = "否".toCharArray();
  }

  protected char[] text;
  protected byte alternatives;
  protected char[][] altTexts;
  protected byte timeOut;
  protected byte timeOutAlt;
  protected byte curAlt;
  protected PopupListener listener;
  protected volatile boolean active = false;
  protected int w;
  protected int h;
  protected int[][] breakTextData;
  protected int visibleLines;
  protected int curLine;
  protected int maxLine;
  protected int yoffset;
  protected long endTime;
  protected Font font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,
      Font.SIZE_LARGE);
  protected int fontHeight = font.getHeight(); 
  protected int borderColor = 0xdd0000;
  protected int backgroundColor = 0xcc000000;
  protected int textColor = 0xFFFFFF;
  protected int alternativeColor = 0xff2200;
  protected int selectedAlternativeColor = 0xffffff;
  protected static int[] rgbData;
  protected static final int OFFSET_POPUP = 8;
  protected static final int OFFSET_TEXT = 2;
  protected static final int OFFSET_ALT = 4;
  protected static final int SB_WIDTH = 5;
  protected static final char[] TEXTBREAKS =
    { ' ', '?', ';', ',', '.', '!',
      ':', '-', '=', '(', ')', '[', ']' };
  protected static final char NEWLINE = '\n';
  public Popup() {}
  public void init(char[] text, char[][] altTexts, byte timeOut,
      byte defaultAlt, byte timeOutAlt, PopupListener listener, int width,
      int height)
  {
    this.text = text;
    this.altTexts = altTexts;
    if (altTexts != null)
    {
      alternatives = (byte) altTexts.length;
    }
    else
    {
      alternatives = 0;
    }
    this.timeOut = timeOut;
    this.timeOutAlt = timeOutAlt;
    this.listener = listener;
    curAlt = defaultAlt;
    w = width - (OFFSET_POPUP << 1);
    h = height - (OFFSET_POPUP << 1);
    active = true;
    if (timeOut > 0)
    {
      endTime = System.currentTimeMillis() + (timeOut * 1000);
    }
    else if (alternatives > 0)
    {
      endTime = 0;
    }
    else
    {
      endTime = System.currentTimeMillis();
    }

    visibleLines =
      Math.max(1, ((h - (OFFSET_TEXT << 1)) / fontHeight) - 1);
    int w = this.w - (OFFSET_TEXT << 1) - (SB_WIDTH << 1);
    curLine = 0;

    breakTextData = breakString(text, w);

    yoffset = 0;
    maxLine = breakTextData.length - visibleLines + 1;
    if (breakTextData.length < visibleLines)
    {
      int newH = breakTextData.length * fontHeight;
      if (alternatives > 0)
        newH += fontHeight;
      newH += OFFSET_TEXT + OFFSET_ALT;
      yoffset = (h - newH) >> 1;
      h = newH;
    }

    if (rgbData == null || rgbData.length != this.w * 8)
    {
      rgbData = new int[this.w * 8];
      for (int i = 0; i < rgbData.length; i++)
      {
        rgbData[i] = backgroundColor;
      }
    }

    new Thread(this).start();
  }
  protected int[][] breakString(char[] text, int width)
  {
    int offset = 0;
    int lines = 0;
    int newOffset;

    while (offset < text.length)
    {
      newOffset = 
        findNextBreak(text, offset, text.length - offset, width, font);
      offset = newOffset;
      lines++;
    }

    int[][] indices = new int[lines][2];

    lines = 0;
    offset = 0;
    while (offset < text.length)
    {
      newOffset =
        findNextBreak(text, offset, text.length - offset, width, font);
      indices[lines][0] = offset;
      indices[lines][1] = newOffset - offset;
      lines++;
      offset = newOffset;
    }

    return indices;
  }

  public int findNextBreak(char[] text, int offset, int len, int w, Font f)
  {
    int breakOffset = offset;
    int textW = 0;
    int niceB = -1;
    char c;
    charLoop: while (breakOffset <= offset + len && textW < w)
    {
      if (breakOffset == offset + len)
        c = TEXTBREAKS[0]; 
      else
        c = text[breakOffset];
      if (c == NEWLINE)
      {
        niceB = breakOffset;
        break charLoop;
      }

      breakCharLoop:
      for (int i = TEXTBREAKS.length - 1; i >= 0; i--)
      {
        if (c == TEXTBREAKS[i])
        {
          niceB = breakOffset;
          break breakCharLoop;
        }
      }
      if (breakOffset == offset + len - 1)
      {
        niceB = breakOffset + 1;
      }
      breakOffset++;
      textW += f.charWidth(c);
    }
    if (niceB > offset && niceB < offset + len - 2 && (text[niceB + 1] == ' '))
      return niceB + 2;        
    else if (niceB > offset && niceB < offset + len)
      return niceB + 1;        
    else if (breakOffset > offset + 1)
      return breakOffset - 1; 
    else if (breakOffset == offset)
      return breakOffset + 1; 
    else
      return breakOffset;     
  }
  public void paint(Graphics g)
  {
    if (active)
    {
      for (int y = OFFSET_POPUP + yoffset; y < OFFSET_POPUP + yoffset + h; y += 8)
      {
        g.drawRGB(rgbData, 0, w, OFFSET_POPUP, y, w, Math.min(8,
            OFFSET_POPUP + yoffset + h - y), true);
      }
      g.setColor(borderColor);
      g.drawRect(OFFSET_POPUP, OFFSET_POPUP + yoffset, w, h);
      g.setColor(textColor);
      g.setFont(font);
      int y = OFFSET_POPUP + OFFSET_TEXT + yoffset;
      int maxLine =
        Math.min(curLine + visibleLines, breakTextData.length);
      for (int i = curLine; i < maxLine; i++)
      {
        int offset = breakTextData[i][0];
        int len = breakTextData[i][1];
        if (len == 1 && text[offset] == NEWLINE)
        {
          y += fontHeight;
        }
        else
        {
          if (text[offset + len - 1] == NEWLINE)
          {
            len--;
          }
          g.drawChars(text, offset, len, OFFSET_POPUP + OFFSET_TEXT
              + (w >> 1), y, Graphics.TOP | Graphics.HCENTER);
          y += fontHeight;
        }
      }

      if (visibleLines < breakTextData.length)
      {
        int sbh = visibleLines * fontHeight;   // Scrollbar max height
        int sbstep = ((sbh - 4) << 8) / maxLine; // Scrollbar height * 256
        int sbX =
          OFFSET_POPUP + w - SB_WIDTH - (SB_WIDTH >> 1); // Scrollbar x-coordinate
        g.setColor(textColor);
        g.fillRect(sbX, OFFSET_POPUP + OFFSET_TEXT + ((curLine * sbstep) >> 8),
          SB_WIDTH, 4 + (sbstep >> 8));
      }

      if (alternatives > 0)
      {
        y =
          OFFSET_POPUP + OFFSET_TEXT + h + yoffset - OFFSET_TEXT - fontHeight;
        int dx = (w / (alternatives + 1));
        int x = OFFSET_POPUP + OFFSET_TEXT;
        for (int i = 0; i < alternatives; i++)
        {
          char[] t = altTexts[i];
          x += dx;
          int xx = x - (font.charsWidth(t, 0, t.length) >> 1);
          if (curAlt != i)
          {
            g.setColor(alternativeColor);
            g.drawChars(t, 0, t.length, xx, y, Graphics.TOP | Graphics.LEFT);
          } 
          else
          {
            g.setColor(alternativeColor);
            g.drawChars(t, 0, t.length, xx + 1, y + 1,
                Graphics.TOP | Graphics.LEFT);
            g.setColor(selectedAlternativeColor);
            g.drawChars(t, 0, t.length, xx, y, Graphics.TOP | Graphics.LEFT);
          }
        }
      }
    }
  }

  public void keyPressed(int keyCode, int gameCode)
  {
    if (active)
    {
      if (alternatives < 1)
      {
        active = false;
        if (listener != null)
          listener.selectedChoice(curAlt, false);
      }
      else
      {
        switch (gameCode)
        {
        case Canvas.DOWN:
        {
          curLine++;
          if (curLine >= maxLine)
            curLine = 0;
          break;
        }
        case Canvas.UP:
        {
          if (maxLine > 0)
            curLine--;
          if (curLine < 0)
            curLine = maxLine - 1;
          break;
        }
        case Canvas.RIGHT:
        {
          curAlt++;
          if (curAlt >= alternatives)
            curAlt = 0;
          break;
        }
        case Canvas.LEFT:
        {
          curAlt--;
          if (curAlt < 0)
            curAlt = (byte) (alternatives - 1);
          break;
        }
        case Canvas.FIRE:
        {

          if (curAlt >= 0)
          {
            active = false;
            if (listener != null)
              listener.selectedChoice(curAlt, false);
          }
          break;
        }
        case -11:
        {
          active = false;
          if (listener != null)
            listener.selectedChoice(timeOutAlt, false);
          break;
        }
        }
      }
    }
  }

  /**
   * Disposes all resources held by this popup and closes it.
   */
  public void dispose()
  {
    active = false;
    text = null;
    altTexts = null;
    listener = null;
    breakTextData = null;
    System.gc();
  }

  /**
   * Returns whether this popup is active or not.
   * 
   * @return true if active, false otherwise.
   */
  public boolean isActive()
  {
    return active;
  }

  /**
   * Returns alternative index on timeout
   * 
   * @return timeout alternative
   */
  public byte getTimeOutChoice()
  {
    return timeOutAlt;
  }

  /**
   * Called by framework to check if popup reached its' timeout.
   * 
   * @return true if timeout, false otherwise.
   */
  protected boolean pollTimeout()
  {
    if (active)
    {
      if (endTime > 0 && System.currentTimeMillis() > endTime)
      {
        active = false;
        if (listener != null)
        {
          listener.selectedChoice(timeOutAlt, true);
          return true;
        }
      }
    }
    return false;
  }

  // Runnable impl to poll this popup
  public void run()
  {
    while (isActive())
    {
      // Poll popup timeout
      try
      {
        Thread.sleep(1000);
        pollTimeout();
      } catch (InterruptedException e) {}
    }
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色噜噜偷拍精品综合在线| 亚洲精品国产一区二区三区四区在线| 欧美国产精品v| 国产精品自产自拍| 欧美xfplay| 日本在线不卡视频| 国产sm精品调教视频网站| 精品不卡在线视频| 麻豆精品一二三| 久久久久久**毛片大全| 午夜电影一区二区| 欧美一区二区三区在线视频 | 精品av综合导航| 国产一区二区三区在线观看免费| 国产传媒一区在线| 欧美色图激情小说| 一区二区三区在线观看网站| 欧美日韩免费不卡视频一区二区三区| 亚洲欧美一区二区三区久本道91| 91麻豆自制传媒国产之光| 国产日韩欧美综合在线| 99精品国产一区二区三区不卡| 国产精品久久久久久久久免费樱桃| 成人国产精品免费观看| 亚洲一级片在线观看| 日韩美一区二区三区| 国产夫妻精品视频| 一级特黄大欧美久久久| www激情久久| 欧美在线播放高清精品| 午夜视频在线观看一区二区三区| 久久中文字幕电影| 91精品国产色综合久久久蜜香臀| 久久精品噜噜噜成人88aⅴ| 中文字幕国产一区二区| 欧美一区午夜精品| 成人av网址在线| 韩国欧美一区二区| 亚洲小说春色综合另类电影| 久久免费电影网| 91精品国产综合久久久久久久| 国产v综合v亚洲欧| 久久超碰97中文字幕| 日韩和的一区二区| 午夜精品久久久久久久| 亚洲一二三四久久| 亚洲精品福利视频网站| 久久综合九色综合97_久久久| 国模一区二区三区白浆 | 蜜桃免费网站一区二区三区| 日本一区免费视频| 欧美国产一区二区在线观看| 久久久精品影视| 欧美激情艳妇裸体舞| 国产精品免费看片| 精品日韩99亚洲| 精品久久久久99| 国产精品全国免费观看高清| 综合久久国产九一剧情麻豆| 亚洲日本青草视频在线怡红院| 国产人妖乱国产精品人妖| 欧美一区二区三区四区在线观看| 欧美另类变人与禽xxxxx| 日韩欧美你懂的| 国产精品久久久久久久久免费相片| 亚洲人被黑人高潮完整版| 亚洲伊人色欲综合网| 国产精品电影一区二区三区| 欧美韩日一区二区三区四区| 天天av天天翘天天综合网色鬼国产| 国产一区二区三区av电影| 91蝌蚪porny九色| 天天操天天色综合| 成人毛片视频在线观看| 91一区二区三区在线观看| 日韩三级电影网址| 亚洲chinese男男1069| 99久久免费精品| 精品国产一区二区三区av性色| 亚洲精品高清视频在线观看| 国产精品一色哟哟哟| 欧美va亚洲va香蕉在线| 日韩国产欧美三级| 美女尤物国产一区| 日韩不卡手机在线v区| 国产91精品一区二区麻豆亚洲| 欧美精品粉嫩高潮一区二区| 一区二区三区日本| 在线精品视频小说1| 亚洲一区二区综合| 欧美日韩国产综合一区二区三区| 亚洲欧美另类久久久精品2019| 成人av在线影院| 亚洲精品综合在线| 欧美伊人久久久久久午夜久久久久| 亚洲欧美区自拍先锋| 色94色欧美sute亚洲13| 午夜电影久久久| 久久精品人人做| 国产精品99久久久久久久vr| 精品国产91久久久久久久妲己| 免费久久99精品国产| 在线影院国内精品| 免费成人在线影院| 国产精品网站一区| 欧美一区二区三级| 91免费版在线看| 99综合影院在线| 国产乱码精品一区二区三区av| 一区二区三区视频在线观看| 久久精品日产第一区二区三区高清版| 欧美日韩性生活| 在线视频你懂得一区| 色综合久久久久| 色综合天天综合网天天看片| 久久国产人妖系列| 久久国产精品无码网站| 日本女人一区二区三区| 中文字幕一区在线观看| 精品剧情v国产在线观看在线| 欧美日韩一区久久| 8v天堂国产在线一区二区| 欧美三级欧美一级| 欧美日韩亚洲综合在线| 丁香另类激情小说| av中文字幕在线不卡| 在线观看日韩电影| 欧美日韩在线播放| 欧美不卡123| 国产精品三级av在线播放| 一区二区在线观看视频在线观看| 亚洲欧美区自拍先锋| 日本大胆欧美人术艺术动态| 久久99热狠狠色一区二区| 国产一区二区不卡在线| 91国内精品野花午夜精品| 91麻豆精品国产综合久久久久久| 日韩美女在线视频| 亚洲婷婷国产精品电影人久久| 亚洲国产毛片aaaaa无费看| 国产乱子伦一区二区三区国色天香| 国产一区视频导航| 欧美群妇大交群中文字幕| 中文字幕不卡在线| 老司机精品视频导航| 色8久久精品久久久久久蜜| 欧美精品一区二区三区蜜桃视频| 亚洲丝袜另类动漫二区| 国产美女视频91| 日韩一区二区免费在线观看| 一区二区三区在线观看国产| 麻豆免费精品视频| 日韩精品最新网址| 青草av.久久免费一区| 欧美日韩三级在线| 亚洲免费看黄网站| www.激情成人| 国产亚洲精品中文字幕| 亚洲18色成人| 欧美日韩一区二区三区免费看 | 久久精品国产99久久6| 欧美一区二视频| 麻豆一区二区99久久久久| 欧美mv日韩mv国产| 寂寞少妇一区二区三区| 亚洲国产精品成人久久综合一区| 国产一区91精品张津瑜| 成人av网站在线| 一区二区三区在线观看国产| 色婷婷国产精品综合在线观看| 亚洲日本成人在线观看| 在线欧美日韩国产| 久久精品国产99国产| 国产精品青草综合久久久久99| 在线视频欧美精品| 精品在线播放午夜| 一区二区三区精品| 精品福利av导航| 在线视频亚洲一区| 国内欧美视频一区二区| 亚洲欧美韩国综合色| 欧美www视频| 欧美性感一类影片在线播放| 国产东北露脸精品视频| 洋洋av久久久久久久一区| 国产亚洲欧美激情| 欧美一区二区免费观在线| 国产a视频精品免费观看| 日韩精品免费专区| 亚洲精品视频免费看| 久久理论电影网| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 国产精品家庭影院| 日韩三级免费观看| 欧美一区二区免费观在线| 欧美久久婷婷综合色| 91蜜桃在线免费视频| 成人v精品蜜桃久久一区| 国产成人精品午夜视频免费| 麻豆国产精品一区二区三区 |