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

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

?? listcanvas.java

?? 一個在手機上實現RSS閱讀器功能的程序代碼
?? JAVA
字號:
package display;

import java.util.Vector;

import javax.microedition.lcdui.*;

/**
 * <p>
 * <code>ListCanvas</code> represents a scrollable display of
 * items. Items consist of short text, which is shown
 * on this screen, long text, which is shown on a detail screen,
 * and extra text, which is not shown but is accessible.
 * <code>ListCanvas</code> supports scrolling up and down. Pressing
 * on the right arrow displays a detail screen for the
 * selected item. Items in the <code>ListCanvas</code> can also be
 * marked by pressing on the fire button.
 * </p>
 * <p>
 * As of PeekAndPick 2.0, <code>ListCanvas</code> also
 * supports the <code>ProgressDisplay</code> interface
 * with a simple animated progress indicator in the footer.
 * </p>
 *
 * @see display.ProgressDisplay
 * @author Jonathan Knudsen
 */
public class ListCanvas
    extends Canvas
    implements Runnable, ProgressDisplay {
  private Display mDisplay;
  
  // The data we display.
  private Vector mItems, mMarks;
  private int mSelection;
  
  // Helpers for marking.
  private boolean mMarkingAllowed = true;
  private static final Boolean kFalse = new Boolean(false);
  private static final Boolean kTrue = new Boolean(true);
  
  // General information.
  private int mWidth, mHeight;
  private int mHeaderHeight, mFooterHeight;
  private Font mFont;
  private int mLineHeight;
  private int mLeftMargin;
  
  // Cancel command.
  private Command mCancelCommand;
  
  // For progress display.
  private int mProgress;
  
  // Variables for paging.
  private int mScroll, mLastVisible, mPageSize;
  
  // Useful images.
  protected static Image kSelectionImage,
      kUpImage, kDownImage, kLeftImage, kRightImage,
      kMarkImage, kProgressImage;
  
  private static void loadImages() {
    try {
      kSelectionImage = Image.createImage("/selection.png");
      kUpImage = Image.createImage("/up.png");
      kDownImage = Image.createImage("/down.png");
      kLeftImage = Image.createImage("/left.png");
      kRightImage = Image.createImage("/right.png");
      kMarkImage = Image.createImage("/mark.png");
      kProgressImage = Image.createImage("/progress.png");
    }
    catch (java.io.IOException ioe) { System.out.println(ioe); }
  }
  
  /**
   * Creates a new ListCanvas.
   *
   * @param display the application's <code>Display</code>
   * @param cancel a cancel command that is shown at the
   *     same time as the progress indicator
   */
  public ListCanvas(Display display, Command cancel) {
    if (kSelectionImage == null) loadImages();
    mDisplay = display;
    mCancelCommand = cancel;

    mHeaderHeight = kUpImage.getHeight();
    mFooterHeight = kDownImage.getHeight();
    mLeftMargin = kSelectionImage.getWidth() + kMarkImage.getWidth();

    mWidth = getWidth();
    mHeight = getHeight();
    setFontSize("Small");

    clear();
    
    Thread t = new Thread(this);
    t.start();
  }
  
  /**
   * Determines whether marking is allowed.
   */
  public void setMarkingAllowed(boolean markingAllowed) {
    mMarkingAllowed = markingAllowed;
  }
  
  /**
   * returns the number of items in this list.
   */
  public int size() { return mItems.size(); }
  
  /**
   * Removes all items from the list.
   */
  public void clear() {
    mItems = new Vector();
    mMarks = new Vector();
    mSelection = 0;
    mScroll = 0;
  }
  
  /**
   * Sets the font size that is used to display items.
   *
   * @param size valid values are &quot;Small&quot;,
   *     &quot;Medium&quot;, and &quot;Large&quot;
   */
  public void setFontSize(String size) {
    int s = Font.SIZE_SMALL;
    if (size.equals("Small")) s = Font.SIZE_SMALL;
    else if (size.equals("Medium")) s = Font.SIZE_MEDIUM;
    else if (size.equals("Large")) s = Font.SIZE_LARGE;
    
    mFont = Font.getFont(Font.FACE_PROPORTIONAL,
        Font.STYLE_PLAIN, s);
    mLineHeight = mFont.getHeight();
  }
  
  private DisplayItem getItem(int i) {
    return (DisplayItem)mItems.elementAt(i);
  }
  
  /**
   * Returns the short text for the item at the specified
   * index.
   */
  public String getShortText(int i) {
    DisplayItem item = (DisplayItem)mItems.elementAt(i);
    return item.getShortText();
  }

  /**
   * Returns the long text for the item at the specified
   * index.
   */
  public String getLongText(int i) {
    DisplayItem item = (DisplayItem)mItems.elementAt(i);
    return item.getLongText();
  }

  /**
   * Returns the extra text for the item at the specified
   * index.
   */
  public String getExtra(int i) {
    DisplayItem item = (DisplayItem)mItems.elementAt(i);
    return item.getExtra();
  }

  /**
   * Tells whether the item at the specified index has
   * been marked.
   */
  public boolean isMarked(int i) {
    return (mMarks.elementAt(i) == kTrue);
  }

  /**
   * Returns true if any of the items have been
   * marked.
   */
  public boolean hasMarks() {
    boolean hasMarks = false;
    for (int i = 0; i < size(); i++) {
      if (isMarked(i) == true) {
        hasMarks = true;
        break;
      }
    }
    return hasMarks;
  }

  /**
   * Adds a new item to the list.
   *
   * @param shortText the short text for the new item
   * @param longText the long text for the new item
   * @param extra the extra text for the new item
   */
  public void addItem(String shortText, String longText,
      String extra) {
    DisplayItem item = new DisplayItem(shortText, longText,
        extra);
    mItems.addElement(item);
    mMarks.addElement(kFalse); // Default to unmarked.
    repaint();
  }
  
  /**
   * Shows the details screen for the current item.
   */
  public void details() {
    DisplayItem item = (DisplayItem)mItems.elementAt(mSelection);
    ItemCanvas itemCanvas = new ItemCanvas(mDisplay, this, mFont, item);
    mDisplay.setCurrent(itemCanvas);
  }
  
  /**
   * Toggles the mark for the current item.
   */
  public void mark() {
    if (mMarkingAllowed == true) {
      if (mMarks.elementAt(mSelection) == kFalse)
        mMarks.setElementAt(kTrue, mSelection);
      else
        mMarks.setElementAt(kFalse, mSelection);
      repaint();
    }
  }
  
  /**
   * Toggles the display of the progress bar and
   * the presence of the <b>Cancel</b> command.
   *
   * @param b If <code>b</code> is <code>true</code>, the
   *     progress bar is shown and the cancel command is
   *     added. Otherwise, the progress bar is removed
   *     and the cancel command is removed.
   */
  public void setProgress(boolean b) {
    if (b == true) {
      mProgress = 1;
      addCommand(mCancelCommand);
    }
    else {
      mProgress = 0;
      removeCommand(mCancelCommand);
      repaint();
    }
  }
  
  /**
   * Called internally. Runs a loop to animate the
   * progress indicator.
   */
  public void run() {
    while (true) {
      try { Thread.sleep(125); }
      catch (InterruptedException ie) {}
      if (mProgress != 0) {
        mProgress++;
        repaint();
      }
    }
  }
  
  /**
   * Paints the item list.
   */
  public void paint(Graphics g) {
    // Clear the screen.
    g.setColor(255, 255, 255);
    g.fillRect(0, 0, mWidth, mHeight);
    
    // Set defaults.
    g.setColor(0, 0, 0);
    g.setFont(mFont);
    
    // Draw the header if appropriate.
    paintHeader(g);
    
    // Draw as many items as will fit between the header and the footer.
    paintBody(g);
    
    // Draw footer.
    paintFooter(g);
  }
  
  private void paintHeader(Graphics g) {
    if (mScroll != 0)
      g.drawImage(kUpImage, mWidth / 2, 0,
          Graphics.HCENTER | Graphics.TOP);
  }
  
  private void paintBody(Graphics g) {
    int y = mHeaderHeight;
    boolean trucking = true;
    int index = mScroll;
    while (trucking) {
      if (index >= mItems.size()) trucking = false;
      else if (y + mLineHeight >= (mHeight - mFooterHeight)) trucking = false;
      else {
        // Draw the item.
        DisplayItem item = (DisplayItem)mItems.elementAt(index);
        String shortText = item.getShortText();
        g.drawString(shortText, mLeftMargin, y,
            Graphics.TOP | Graphics.LEFT);
        // If it's too wide, or if there is long text
        // available, show a right arrow.
        if (mFont.stringWidth(shortText) >
            (mWidth - mLeftMargin) ||
            item.getLongText() != null) {
          // Clear the area.
          int oldColor = g.getColor();
          g.setColor(255, 255, 255);
          g.fillRect(mWidth - kRightImage.getWidth(), y,
              kRightImage.getWidth(), mLineHeight);
          g.setColor(oldColor);
          // Draw the right arrow.
          g.drawImage(kRightImage, mWidth, y + mLineHeight / 2,
              Graphics.VCENTER | Graphics.RIGHT);
        }
        
        // Draw the mark.
        if (mMarks.elementAt(index) == kTrue)
          g.drawImage(kMarkImage, mLeftMargin, y + mLineHeight / 2,
              Graphics.VCENTER  | Graphics.RIGHT);

        // Draw the highlight.
        if (index == mSelection)
          g.drawImage(kSelectionImage, 0, y + mLineHeight / 2,
              Graphics.VCENTER  | Graphics.LEFT);
        
        index++;
        y += mLineHeight;
      }
    }
    
    // Set the last visible item index.
    mLastVisible = index - 1;
  }
  
  private void paintFooter(Graphics g) {
    // Determine the dimensions of the progress indicator.
    int w = mWidth - 8;
    int h = mFooterHeight;
    int x = 4;
    int y = mHeight - h;
    // Find out the width of the image, and tile if
    // necessary.
    int pw = kProgressImage.getWidth();
    if (mProgress != 0) {
      // Draw the framing rectangle.
      g.drawRect(x, y, w - 1, h - 1);
      // Save the old clip.
      int cx = g.getClipX();
      int cy = g.getClipY();
      int cw = g.getClipWidth();
      int ch = g.getClipHeight();
      // Set the clip.
      g.setClip(x + 1, y + 1, w - 2, h - 2);
      // Calculate the animation offset.
      int offset = -7 + mProgress % 8;
      // Tile the image.
      for (int ix = 0; ix + offset < w; ix += pw) { 
        g.drawImage(kProgressImage,
          x + ix + offset, y,
          Graphics.LEFT | Graphics.TOP);
      }
      // Restore the clip.
      g.setClip(cx, cy, cw, ch);
    }
    
    // Draw down arrow.
    if (mLastVisible < (mItems.size() - 1)) {
      g.drawImage(kDownImage, mWidth / 2, mHeight - mFooterHeight,
          Graphics.HCENTER | Graphics.TOP);
    }
  }
  
  /**
   * Responds to key presses.
   */
  protected void keyPressed(int keyCode) {
    int gameAction = getGameAction(keyCode);
    switch(gameAction) {
      case UP:
        if (mSelection > 0) {
          mSelection--;
          // Page up if necessary.
          if (mSelection < mScroll) {
            mScroll -= mPageSize;
            if (mScroll < 0) mScroll = 0;
          }
          repaint();
        }
        break;
      case DOWN:
        if (mSelection < (mItems.size() - 1)) {
          mSelection++;
          // Page down if necessary.
          if (mSelection > mLastVisible) {
            if (mPageSize == 0) mPageSize = mLastVisible + 1;
            mScroll = mSelection;
          }
          repaint();
        }
        break;
      case RIGHT:
        details();
        break;
      case FIRE:
        mark();
        break;
    }
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人动漫在线观看| 日本电影亚洲天堂一区| 专区另类欧美日韩| 国产亚洲综合在线| 亚洲欧洲在线观看av| 亚洲大片免费看| 久久精品国产网站| 懂色av中文字幕一区二区三区 | 国产精品精品国产色婷婷| 成人欧美一区二区三区1314| 精品一区二区影视| 色偷偷久久人人79超碰人人澡| 欧美三级电影网站| 精品国产1区2区3区| 亚洲男女一区二区三区| 精品一区二区三区视频 | 欧美精品久久久久久久久老牛影院| 6080国产精品一区二区| 国产精品久久免费看| 综合久久久久久| 极品尤物av久久免费看| 欧洲一区二区三区在线| 国产精品麻豆欧美日韩ww| 免费视频最近日韩| 色婷婷av一区二区三区之一色屋| 日本高清无吗v一区| 亚洲欧洲一区二区在线播放| 国产一区二区剧情av在线| 欧美卡1卡2卡| 亚洲午夜久久久| 国产乱子轮精品视频| 欧美日韩免费视频| 亚洲sss视频在线视频| caoporn国产精品| 欧美α欧美αv大片| 免费精品视频在线| 欧美午夜不卡在线观看免费| 日本美女一区二区| 久久久久国产成人精品亚洲午夜| 欧美日韩免费一区二区三区视频| 视频一区视频二区中文| 国产人久久人人人人爽| 欧美日韩精品一二三区| 色哟哟一区二区三区| 国产精品素人一区二区| 日韩免费看网站| 欧洲精品一区二区| 91超碰这里只有精品国产| 色一区在线观看| 欧美高清在线一区二区| 国产精品69毛片高清亚洲| 欧美国产一区二区在线观看| 国产精品资源在线观看| 欧美videossexotv100| 日本美女视频一区二区| 日韩一级片网址| 久久精品国产第一区二区三区| 久久久久久一二三区| 久久国产欧美日韩精品| 日韩三级电影网址| 国产福利一区在线| 国产精品女人毛片| 色诱视频网站一区| 一区二区不卡在线视频 午夜欧美不卡在 | 亚洲国产激情av| 亚洲黄色av一区| 91精品欧美福利在线观看| 免费xxxx性欧美18vr| 日韩精品一区在线观看| 成人av动漫网站| 亚洲美女淫视频| 欧美天天综合网| 韩国毛片一区二区三区| 欧美韩日一区二区三区| www.66久久| 日韩电影一二三区| 中文字幕免费不卡| 色婷婷精品久久二区二区蜜臂av| 久久婷婷国产综合精品青草| av亚洲精华国产精华精| 一区二区三区在线影院| 日韩一区二区电影| 在线中文字幕不卡| 捆绑调教美女网站视频一区| 日本一区二区三区四区在线视频| 精品视频在线视频| 国产精品小仙女| 亚洲欧美日韩国产成人精品影院| 在线不卡a资源高清| 国产精品1区2区| 国产精品福利在线播放| 日本高清不卡视频| 成人精品鲁一区一区二区| 亚洲综合一区二区三区| 久久精品亚洲一区二区三区浴池| 欧美精品一二三四| 成人久久18免费网站麻豆| 午夜影院久久久| 中文字幕一区av| 日韩精品在线网站| 欧美性生活影院| 国产乱码精品一区二区三区忘忧草| 亚洲精品日日夜夜| 久久久久99精品一区| 成人在线综合网站| 国产在线一区观看| 人妖欧美一区二区| 亚洲精品久久久蜜桃| 国产欧美一区二区三区在线看蜜臀 | 一本在线高清不卡dvd| 老司机免费视频一区二区三区| 国产精品免费人成网站| 欧美不卡一区二区三区四区| 欧美日韩国产综合一区二区| a级精品国产片在线观看| 蜜臀va亚洲va欧美va天堂 | 婷婷成人激情在线网| 亚洲精品乱码久久久久| 中文字幕精品—区二区四季| 精品区一区二区| 91精品国产综合久久福利| 欧美视频日韩视频| 在线精品亚洲一区二区不卡| 韩国一区二区三区| 国内精品久久久久影院薰衣草 | 日韩三级视频在线看| 日韩一级片在线观看| 在线播放欧美女士性生活| 欧美性猛交xxxxxx富婆| 丁香桃色午夜亚洲一区二区三区| 另类小说综合欧美亚洲| 全国精品久久少妇| 亚洲精品中文在线影院| 亚洲va国产天堂va久久en| 亚洲成人一二三| 一区二区在线观看视频| 天天影视涩香欲综合网| 日韩高清不卡一区二区三区| 婷婷亚洲久悠悠色悠在线播放| 亚洲综合图片区| 日韩高清不卡一区二区三区| 免费在线观看精品| 日韩精品1区2区3区| 国产真实精品久久二三区| 国产麻豆视频一区二区| 国产福利一区在线| 欧洲精品在线观看| 欧美一区二区三区爱爱| 日韩视频一区二区在线观看| 久久久久久**毛片大全| 中文字幕va一区二区三区| 亚洲理论在线观看| 一区二区三区精品视频| 久久精品国产秦先生| 国产乱子伦视频一区二区三区| 91亚洲精品久久久蜜桃| 欧美电影免费观看高清完整版在 | 视频在线观看91| 国产福利一区在线观看| 欧美日韩一区小说| 久久久青草青青国产亚洲免观| 一区二区久久久久久| 国产精品亚洲第一区在线暖暖韩国| 色国产精品一区在线观看| 欧美v日韩v国产v| 亚洲自拍偷拍av| 国产高清一区日本| 欧美一区二区三区影视| 中文字幕亚洲电影| 国产曰批免费观看久久久| 欧美性色黄大片手机版| 欧美激情中文字幕| 久久不见久久见中文字幕免费| 色丁香久综合在线久综合在线观看| 欧美xxxxx裸体时装秀| 午夜精品久久久久久久99樱桃| 国产.欧美.日韩| 欧美一区二区观看视频| 亚洲男人的天堂网| 成人av网站大全| 精品国产乱码久久久久久1区2区| 夜夜嗨av一区二区三区| 波多野结衣一区二区三区| 欧美成人精品福利| 日韩精品91亚洲二区在线观看| 一本到不卡精品视频在线观看 | 亚洲天堂福利av| 国产资源在线一区| 日韩一级二级三级精品视频| 亚洲图片有声小说| 色偷偷久久一区二区三区| 国产精品传媒入口麻豆| 国产成人精品午夜视频免费| 欧美精品一区二区三区蜜桃视频| 午夜精品久久久久久久蜜桃app| 欧美亚洲动漫精品| 亚洲国产日韩在线一区模特| 色一情一伦一子一伦一区| 亚洲视频免费看| 色诱视频网站一区|