Esempio n. 1
0
  protected void paint(Graphics g) {

    g.setColor(COLOR_WHITE);
    g.fillRect(0, 0, getWidth(), getHeight());

    Font f1 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE);
    Font f2 = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);

    int px = getWidth() / 2;

    g.setColor(COLOR_BLUE);
    g.setFont(f1);
    g.drawString(
        Locale.getInst().getStr(Locale.SPLASH_TOP), px, 0, Graphics.TOP | Graphics.HCENTER);

    g.setFont(f2);
    g.drawString(
        Locale.getInst().getStr(Locale.SPLASH_BOTTOM),
        px,
        getHeight(),
        Graphics.BOTTOM | Graphics.HCENTER);

    if (logo != null) {
      g.drawImage(logo, getWidth() / 2, getHeight() / 2, Graphics.HCENTER | Graphics.VCENTER);
    }
  }
Esempio n. 2
0
  protected void doPaintAxis(final Graphics g) {
    if (scaleSizeInPixel == 0 || mapBackground != null) {
      return;
    }

    final Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
    g.setFont(font);
    g.setColor(0x00000000);

    final int textBottom = height - 4 - SCALE_HEIGTH;
    int left = 0;
    for (int i = 0; i < scaleConfiguration.labelLocation.length; i++) {
      final float location = scaleConfiguration.labelLocation[i];
      final float value = scaleConfiguration.labelValue[i];
      String label = Utils.floatToString(value, true);
      if (location == 0) {
        left = (font.stringWidth(label) / 2) + 2;
      } else if (location == 1) {
        label += " " + scaleConfiguration.unit;
      }
      g.drawString(
          label,
          left + (int) (scaleSizeInPixel * location),
          textBottom,
          Graphics.BOTTOM | Graphics.HCENTER);
    }
    g.drawRect(left, height - 2 - SCALE_HEIGTH, scaleSizeInPixel, SCALE_HEIGTH);
    g.fillRect(left, height - 2 - SCALE_HEIGTH, scaleSizeInPixel / 2, SCALE_HEIGTH);
  }
Esempio n. 3
0
  public ExtendedTextField() {
    setFullScreenMode(true);

    setCommandListener(this);

    exit = new Command("Exit", Command.EXIT, 1);
    open = new Command("Open", Command.ITEM, 1);
    newFile = new Command("New", Command.ITEM, 2);
    save = new Command("Save", Command.ITEM, 3);
    saveAs = new Command("Save As", Command.ITEM, 4);
    eval = new Command("Eval", Command.ITEM, 5);
    output = new Command("Output", Command.ITEM, 6);
    cls = new Command("Clear", Command.ITEM, 7);

    addCommand(exit);
    addCommand(newFile);
    addCommand(open);
    addCommand(save);
    addCommand(saveAs);
    addCommand(eval);
    addCommand(output);
    addCommand(cls);

    new Thread(this).start();

    // TODO: change font size?
    inputFont = Font.getDefaultFont();
    inputWidth = getWidth();
    inputHeight = inputFont.getHeight();
    linesOnScreen = getHeight() / inputHeight;

    addNewLine(0);
  }
Esempio n. 4
0
 /** Initialize the graphic elements needed for this item. */
 protected void initContent(int firstLineWidth, int availWidth, int availHeight) {
   if (this.font == null) {
     this.font = Font.getDefaultFont();
     this.fontColor = 0x000000;
   }
   contentHeight = font.getHeight() + this.linePadding;
   contentWidth = availWidth;
 }
Esempio n. 5
0
 public Image colImage(int color) {
   Image img =
       Image.createImage(Font.getDefaultFont().getHeight(), Font.getDefaultFont().getHeight());
   Graphics g = img.getGraphics();
   g.setColor(color);
   g.fillRect(0, 0, img.getWidth(), img.getHeight());
   return img;
 }
Esempio n. 6
0
  protected void paint(Graphics g) {
    int width = this.getWidth();

    // Fill in the background White
    g.setColor(0xFFFFFF); // White
    g.fillRect(0, 0, width, this.getHeight());

    int y = yPos;
    y += MARGIN;

    if (this.logo != null) {
      g.drawImage(this.logo, width / 2, y, Graphics.TOP | Graphics.HCENTER);
      y += logo.getHeight() + MARGIN;
    }

    g.setColor(0x0); // Black

    // Write the title "About"
    final Font titleFont =
        Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD | Font.STYLE_UNDERLINED, Font.SIZE_LARGE);

    /*
     * TODO: currently paints ALL the text, even if there is (a lot) more
     * than can fit on the screen. (must do this first time to assess
     * 'height', but shouldn't need to do it for any other repaint
     */
    for (int i = 0; i < TITLES.length; i++) {
      final int basicFontHeight = DEFAULT_SIMPLE_FONT.getHeight();
      final int titleFontHeight = titleFont.getHeight();
      // Write out the 'message' heading
      g.setFont(titleFont);
      final String title = TITLES[i];
      int stringWidth = g.getFont().stringWidth(title);
      g.drawString(title, (width - stringWidth) / 2, y, 0);
      y += titleFontHeight;

      // Write out the 'message' text.
      g.setFont(DEFAULT_SIMPLE_FONT);
      for (int j = 0; j < this.formattedMessages[i].length; j++) {
        final String message = this.formattedMessages[i][j];
        stringWidth = g.getFont().stringWidth(message);
        g.drawString(message, (width - stringWidth) / 2, y, 0);
        y += basicFontHeight;
      }
      y += basicFontHeight;
    }

    // Set the total-Height the first time
    if (firstTime) {
      totalHeight = y + MARGIN;
      firstTime = false;
    }
  }
  protected void paint(Graphics g) {
    g.setColor(0xFAFAFA);
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(0xDDDDDD);
    g.setStrokeStyle(Graphics.SOLID);
    g.drawLine(0, 0, getWidth(), 0);

    if (!pressedField) {
      g.setColor(0xE5E5E5);
    } else {
      pressedField = false;
      g.setColor(0xBCBCBC);
    }

    if (selected == Main.STATION_LIST_VIEW) {
      g.fillRect(0, 1, getWidth() / 2, getHeight() / 2);
    } else if (selected == Main.FAVORITE_LIST_VIEW) {
      g.fillRect(getWidth() / 2 + 1, 1, getWidth(), getHeight() / 2);
    } else if (selected == Main.MAP_SEARCH_VIEW) {
      g.fillRect(0, getHeight() / 2 + 1, getWidth() / 2, getHeight());
    } else if (selected == Main.GEOCODING_SEARCH_VIEW) {
      g.fillRect(getWidth() / 2 + 1, getHeight() / 2 + 1, getWidth(), getHeight());
    }

    g.setColor(0x000000);
    g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
    g.drawImage(imageStationListView, 60, 40, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.STATION_LIST_VIEW_TITLE, 60, 80, Graphics.HCENTER | Graphics.TOP);
    g.drawImage(imageFavoriteListView, 180, 40, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.FAVORITE_LIST_VIEW_TITLE, 180, 80, Graphics.HCENTER | Graphics.TOP);
    g.drawImage(imageMapSearchView, 60, 160, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.MAP_SEARCH_VIEW_TITLE, 60, 200, Graphics.HCENTER | Graphics.TOP);
    g.drawImage(imageGeocodingSearchView, 180, 160, Graphics.HCENTER | Graphics.VCENTER);
    g.drawString(Main.GEOCODING_SEARCH_VIEW_TITLE, 180, 200, Graphics.HCENTER | Graphics.TOP);
  }
  public int getVWidth() {
    // g.setColor(0);
    if (width > 0) return width; // cached

    int w = 0;
    int imgWidth = imgWidth();

    for (int index = 0; index < elementCount; index++) {
      Object ob = elementData[index];
      if (ob != null) {

        if (ob instanceof String) {
          // string element
          w += font.stringWidth((String) ob);
        } else if ((ob instanceof Integer) && imageList != null) {
          // image element or color
          int i = (((Integer) ob).intValue());
          switch (i & 0xff000000) {
            case IMAGE:
              w += imgWidth;
              break;
          }
        } // Integer
      } // if ob!=null
    } // for
    return width = w;
  }
Esempio n. 9
0
  void displayCharacterMap(Graphics g) {
    if (currentChars != null) {
      g.setColor(0xffffff);
      g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
      g.setColor(0x000000);
      g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
      for (int i = 0; i < currentChars.length; i++) {
        char ch = currentChars[i];
        if (isUppercase) {
          ch = String.valueOf(currentChars[i]).toUpperCase().charAt(0);
        }

        // TODO: if i*12 > getWidth() ?

        g.drawChar(ch, i * 12, getHeight() - inputHeight, Graphics.LEFT | Graphics.TOP);
        if (currentChars[currentKeyStep] == currentChars[i]) {
          g.drawRect(
              i * 12 - 2,
              getHeight() - inputHeight - 2,
              inputFont.charWidth(ch) + 4,
              inputHeight + 4);
        }
      }
    }
  }
Esempio n. 10
0
 private void showStartChoice(Graphics g) {
   g.drawImage(Resource.loadImage(Resource.PIC_ID_CHOICE_BG), 0, 0, 0);
   choiceCursor.show(
       g,
       Resource.POS_SEIGNEUR_CHOICE[choiceIndex][0],
       Resource.POS_SEIGNEUR_CHOICE[choiceIndex][1]);
   String info =
       Resource.STR_SEIGNEUR_NAME[choiceIndex]
           + "  城池X"
           + Resource.NUM_SEIGNEUR_CITYS[choiceIndex]
           + "  武将X"
           + Resource.NUM_SEIGNEUR_GENERALS[choiceIndex];
   g.setColor(0XFFFFFF);
   Font font = g.getFont();
   g.drawString(info, (engine.getScreenWidth() - font.stringWidth(info)) >> 1, 456, 0);
 }
Esempio n. 11
0
  private int next() {
    int i = position;
    int lastBreak = -1;

    int length = buffer.length();

    for (int charsWidth = 0;
        i < length && (charsWidth += font.charWidth(buffer.charAt(i))) <= width;
        i++) {
      if (buffer.charAt(i) == ' ') {
        lastBreak = i;
      } else if (buffer.charAt(i) == '\n') {
        lastBreak = i;
        break;
      }
    }

    if (i == length) {
      position = i;
    } else if (lastBreak == position) {
      position++;
    } else if (lastBreak < position) {
      position = i;
    } else {
      position = lastBreak;
    }

    return position;
  }
Esempio n. 12
0
 public static void init(int MAX_X, int MAX_Y) {
   init = true;
   LCD.MAX_X = MAX_X;
   LCD.MAX_Y = MAX_Y;
   f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
   step_y = MAX_Y / 5;
   step_x = MAX_X >> 1;
 }
Esempio n. 13
0
  public boolean hasMoreElements() {
    // return (position < (buffer.length()-1));

    int actualWidth = 0;
    for (int i = 0, stop = buffer.length();
        i < stop;
        actualWidth += font.charWidth(buffer.charAt(i++))) ;

    return (actualWidth > width);
  }
Esempio n. 14
0
  void displayLines(Graphics g, int yStart) {
    // (1 + 2, depends on font size)

    if (isSelection && (xStartSelection != xEndSelection || yStartSelection != yEndSelection)) {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        String currentLine = vectorLines.elementAt(y).toString();
        int width = 0;

        for (int x = 0; x < currentLine.length(); x++) {
          int previousWidth = (x == 0) ? 0 : inputFont.charWidth(currentLine.charAt(x - 1));
          width += previousWidth;

          if (isSelected(x, y)) {
            g.setColor(0x000000);
            g.fillRect(
                width, y * inputHeight, inputFont.charWidth(currentLine.charAt(x)), inputHeight);

            g.setColor(0xffffff);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          } else {
            g.setColor(0x000000);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          }
        }

        if (currentLine.length() == 0) {
          if (isSelected(0, y)) {
            g.setColor(0x000000);
            g.fillRect(0, y * inputHeight, 5, inputHeight);
          }
        }
      }
    } else {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        g.drawString(
            vectorLines.elementAt(y).toString(), 0, y * inputHeight, Graphics.LEFT | Graphics.TOP);
      }
    }
  }
Esempio n. 15
0
 /**
  * Returns the font of the style. If the font of the style is null return the default font.
  *
  * @return the font
  */
 public Font getFont() {
   if (this.font == null) {
     if (this.style != null) {
       this.font = this.style.getFont();
     }
     if (this.font == null) {
       this.font = Font.getDefaultFont();
     }
   }
   return this.font;
 }
Esempio n. 16
0
 public static final boolean MoreGame_Paint(Graphics g) {
   if (GameMIDlet.GetInstance() != null) {
     GameMIDlet.GetInstance().notifyDestroyed();
     return true;
   }
   // #if MOREGAME=="TRUE" && MODEL!="D608" && MODEL!="D508"
   Image last = cCP.GetImage(IDX_LAST);
   if (Info == null) {
     // #if SCREENWIDTH>=176
     Info = new String[] {"更多精彩游戏", "尽在游戏频道", "Wap.xjoys.com", "确定", "退出"};
     // #else
     Info = new String[] {"更多精彩游戏", "尽在游戏频道", "Wap.xjoys.com", "确定", "退出"};
     // #endif
   }
   if (last != null) {
     g.drawImage(last, SCR_W >> 1, SCR_H >> 1, Graphics.VCENTER | Graphics.HCENTER);
   }
   if (Info != null) {
     g.setFont(MyFont);
     g.setColor(0xFFFFFF);
     /** 去掉 确定 退出 所占的2 */
     int ContextHeight = MyFont.getHeight() * ((Info.length - 2));
     int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
     int i = 0, loop_end = Info.length - 2;
     while (i < loop_end) {
       g.drawString(
           Info[i], SCR_W >> 1, Y + (i * MyFont.getHeight()), Graphics.HCENTER | Graphics.TOP);
       i++;
     }
     /** 左右软键,可以用宏,处理那些对调的机型,-3 为让基线下的文字显示出来 */
     g.drawString(Info[Info.length - 2], 0, SCR_H - 3, Graphics.LEFT | Graphics.BOTTOM);
     g.drawString(Info[Info.length - 1], SCR_W, SCR_H - 3, Graphics.RIGHT | Graphics.BOTTOM);
   }
   return false;
   // #else
   return true;
   // #endif
 }
Esempio n. 17
0
 public static final boolean QuitConfirm_Paint(Graphics g) {
   //		Image last = cCP.GetImage(IDX_LAST);
   if (ConfirmInfo == null) {
     // #if SCREENWIDTH>=176
     ConfirmInfo = new String[] {"确定退出?", "确定", "返回"};
     // #else
     ConfirmInfo = new String[] {"确定退出?", "确定", "返回"};
     // #endif
   }
   //		if (last!=null)
   //		{
   //			g.drawImage(last,SCR_W>>1,SCR_H>>1,Graphics.VCENTER|Graphics.HCENTER);
   //		}
   if (ConfirmInfo != null) {
     g.setColor(0x000000);
     g.fillRect(0, 0, SCR_W, SCR_H);
     g.setColor(0xffffff);
     /** 去掉 确定 退出 所占的2 */
     int ContextHeight = MyFont.getHeight() * ((ConfirmInfo.length - 2));
     int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
     int i = 0, loop_end = ConfirmInfo.length - 2;
     while (i < loop_end) {
       g.drawString(
           ConfirmInfo[i],
           SCR_W >> 1,
           Y + (i * MyFont.getHeight()),
           Graphics.HCENTER | Graphics.TOP);
       i++;
     }
     /** 左右软键,可以用宏,处理那些对调的机型,-3 为让基线下的文字显示出来 */
     g.drawString(
         ConfirmInfo[ConfirmInfo.length - 2], 0, SCR_H - 3, Graphics.LEFT | Graphics.BOTTOM);
     g.drawString(
         ConfirmInfo[ConfirmInfo.length - 1], SCR_W, SCR_H - 3, Graphics.RIGHT | Graphics.BOTTOM);
   }
   return false;
 }
 public int getVHeight() {
   if (height != 0) return height;
   for (int i = 0; i < elementCount; i++) {
     int h = 0;
     Object o = elementData[i];
     if (o == null) continue;
     if (o instanceof String) {
       h = font.getHeight();
     } else if (o instanceof Integer) {
       int a = ((Integer) o).intValue();
       if ((a & 0xff000000) == 0) {
         h = imageList.getWidth();
       }
     } else if (o instanceof VirtualElement) {
       h = ((VirtualElement) o).getVHeight();
     }
     if (h > height) height = h;
   }
   return height;
 }
Esempio n. 19
0
  /**
   * Takes an array of messages and a 'Screen-width' and returns the same messages, but any string
   * in that that is wider than 'width' will be split up into 2 or more Strings that will fit on the
   * screen 'Spliting' up a String is done on the basis of Words, so if a single WORD is longer than
   * 'width' it will be on a Line on it's own, but that line WILL be WIDER than 'width'
   *
   * @param message
   * @param width the maximum width a string may be before being split up.
   * @return
   */
  private String[] formatMessage(String[] message, int width) {
    Vector result = new Vector(message.length);
    for (int i = 0; i < message.length; i++) {
      if (DEFAULT_SIMPLE_FONT.stringWidth(message[i]) <= width) {
        result.addElement(message[i]);
      } else {
        String[] splitUp =
            StringUtil.chopStrings(message[i], " ", AboutScreen.DEFAULT_SIMPLE_FONT, width);
        for (int j = 0; j < splitUp.length; j++) {
          result.addElement(splitUp[j]);
        }
      }
    }

    String[] finalResult = new String[result.size()];
    for (int i = 0; i < finalResult.length; i++) {
      finalResult[i] = (String) result.elementAt(i);
    }
    return finalResult;
  }
Esempio n. 20
0
 public static Vector parseMessage(String value, int availWidth, Font font) {
   Vector lines = new Vector(0);
   char[] valueChars = value.toCharArray();
   int startPos = 0;
   int lastSpacePos = -1;
   int lastSpacePosLength = 0;
   int currentLineWidth = 0;
   int len = valueChars.length;
   char c;
   for (int i = 0; i < len; i++) {
     c = valueChars[i];
     currentLineWidth += font.charWidth(c);
     if (c == '\r') {
     } else if (c == '\n') {
       lines.addElement(new String(valueChars, startPos, i - startPos));
       lastSpacePos = -1;
       startPos = i + 1;
       currentLineWidth = 0;
     } else if (currentLineWidth >= availWidth && i > 0) {
       if (lastSpacePos == -1) {
         i--;
         lines.addElement(new String(valueChars, startPos, i - startPos));
         startPos = i;
         currentLineWidth = 0;
       } else {
         currentLineWidth -= lastSpacePosLength;
         lines.addElement(new String(valueChars, startPos, lastSpacePos - startPos));
         startPos = lastSpacePos + 1;
         lastSpacePos = -1;
       }
     } else if (c == ' ' || c == '\t') {
       lastSpacePos = i;
       lastSpacePosLength = currentLineWidth;
     }
   }
   // last string
   lines.addElement(new String(valueChars, startPos, valueChars.length - startPos));
   valueChars = null;
   return lines;
 }
Esempio n. 21
0
  /**
   * Konstruktor obiektu klasy MainCanvas
   *
   * @throws IOException
   */
  public MainCanvas() throws IOException {
    super(true);

    soundPlayer = new SoundPlayer(); // uruchomienie watku odpowiedzialnego za odtwarzanie dzwiekow
    new Thread(soundPlayer).start();

    screenWidth = getWidth();
    screenHeight = getHeight();
    fontHeight = Font.getDefaultFont().getHeight();

    mediaLibrarySelectedItemOnScreen = 0;
    mediaLibraryItemsNumberOnScreen = (screenHeight - 16) / (fontHeight + 5);

    buttonsLocation = 70;

    loadResources(); // utworzenie obiektow warstwy tla i tekstur

    bluetoothPlayer = new BluetoothPlayer();
    Thread appThread =
        new Thread(this); // uruchomienie watku odpowiedzialnego za wyswietlanie grafiki
    appThread.start();
  }
Esempio n. 22
0
  public void validate() {
    int w = getWidth();
    int h = (FireScreen.defaultTickerFont.getHeight()) + (2 * PADTOP);
    if (label != null) {
      label.format(w, false);
      h += label.getHeight() + PADTOP;
    }
    if (h < getMinHeight()) h = getMinHeight();
    setHeight(h);

    Font f = FireScreen.defaultTickerFont;

    dayWidth = f.stringWidth("33") + 2;
    monthWidth = f.stringWidth("22") + 2;
    yearWidth = f.stringWidth("20088") + 2;
    hourWidth = f.stringWidth("44") + 2;
    minuteWidth = f.stringWidth("66") + 2;
    pointer = DAY;
  }
Esempio n. 23
0
 public void setFont(int size) {
   Font font = Font.getFont(Font.FACE_SYSTEM, 0, size);
   g.setFont(font);
 }
Esempio n. 24
0
  /**
   * Metoda wyswietlajaca biblioteke muzyczna na wyswietlaczu
   *
   * @param g Referencja do obiektu klasy Graphics, ktory pozwala na wyswietlenie tekstu
   * @param player Referencja do obiektu klasy odtwarzacza muzycznego
   * @param screenSelectedItemIndex Indeks wybranego elementu na wyswietlaczu
   * @param screenNumberOfItems Liczba elementow wyswietlonych na wyswietlaczu
   */
  public void showMediaLibrary(
      Graphics g, BluetoothPlayer player, int screenSelectedItemIndex, int screenNumberOfItems) {
    int color = g.getColor(); // przechowanie uzywanego koloru
    int textPos = 0;
    String text;

    g.setColor(255, 255, 255); // biala czcionka

    for (int i = 0; i < screenNumberOfItems; i++) {
      text =
          bluetoothPlayer
              .getMediaLibrary()
              .getItem(
                  bluetoothPlayer.getMediaLibrary().getMediaLibrarySelectedItem()
                      - screenSelectedItemIndex
                      + i,
                  g);

      if (text != null) {
        // jesli zmienil sie wybrany tekst
        if ((screenSelectedItemIndex == i) && (text.equals(mediaLibraryLastText) == false)) {
          mediaLibraryLastText = text;
          mediaLibraryTextPos = 0;
          mediaLibraryWaitTimeText = SCROLL_TIME_WAIT;
        }
        textPos = mediaLibraryTextPos;

        // if whole text can be displayed at once
        if (Font.getDefaultFont().stringWidth(text) <= screenWidth - 32) {
          g.setColor(255, 255, 255); // biala czcionka
          g.drawString(text, 10, i * (fontHeight + 5) + 8, Graphics.TOP | Graphics.LEFT);
        }
        // if text doesn't fit into the screen
        else {
          String leftTextTmp = "";
          int j = 0;

          // cut text from the left as long as it doesn't fit to the screen (only for selected item)
          if (screenSelectedItemIndex == i)
            while (Font.getDefaultFont().stringWidth(leftTextTmp) < textPos) {
              leftTextTmp = text.substring(0, ++j);
            }

          String textTmp = text.substring(j, text.length());

          boolean textRightCut = false;
          // cut text from the right as long as it doesn't fit to the screen
          while (Font.getDefaultFont().stringWidth(textTmp) > screenWidth - 24) {
            textTmp = textTmp.substring(0, textTmp.length() - 1);
            textRightCut = true;
          }

          g.setColor(255, 255, 255); // biala czcionka
          g.drawString(textTmp, 10, i * (fontHeight + 5) + 8, Graphics.TOP | Graphics.LEFT);

          g.setColor(BACKGROUND_COLOR); // zamazanie tekstu po bokach
          g.fillRect(screenWidth - 10, i * (fontHeight + 5) + 8, 5, fontHeight);

          if (screenSelectedItemIndex == i) {
            if ((textRightCut == false)
                && (mediaLibraryWaitTimeText == 0)) // jesli tekst przewinal sie do konca
            mediaLibraryWaitTimeText = SCROLL_TIME_WAIT;

            if (mediaLibraryWaitTimeText == 0) mediaLibraryTextPos += 2; // przewiniecie tekstu
            // if text is going to be displayed statically (without scrolling it)
            else {
              mediaLibraryWaitTimeText--;
              // if wait time has ended, start scrolling from the beginning
              if ((mediaLibraryWaitTimeText == 0) && (mediaLibraryTextPos != 0)) {
                mediaLibraryWaitTimeText = SCROLL_TIME_WAIT;
                mediaLibraryTextPos = 0;
              }
            }
          }
        }
      }
    }

    g.setColor(255, 255, 255);

    // obwodka dla podswietlonego elementu
    if (screenNumberOfItems > 0)
      g.drawRect(
          7, screenSelectedItemIndex * (fontHeight + 5) + 6, screenWidth - 16, fontHeight + 1);

    g.setColor(color);
  }
Esempio n. 25
0
  /**
   * Metoda sluzaca do wypisania tekstu na ekranie w podanej linii
   *
   * @param g Referencja do obiektu klasy Graphics, ktory pozwala na wyswietlenie tekstu
   * @param text Tekst, ktory ma zostac wypisany
   * @param line Numer linii, w ktorej ma zostac wypisany tekst
   * @return <code>true</code> jesli wypisanie tekstu powiodlo sie, <code>false</code> w przeciwnym
   *     razie
   */
  public boolean drawText(Graphics g, String text, int line) {
    int color = g.getColor(); // przechowanie uzywanego koloru
    int textPos = 0;

    g.setColor(BACKGROUND_COLOR); // zamazanie starego tekstu
    g.fillRect(16, 16 + line * (fontHeight + 3), screenWidth - 32, fontHeight);

    if (line == 0) {
      // if displayed text had changed
      if (text.equals(lastText0) == false) {
        lastText0 = text;
        textPos0 = 0;
        waitTimeText0 = SCROLL_TIME_WAIT;
      }
      textPos = textPos0;
    } else if (line == 1) {
      // if displayed text had changed
      if (text.equals(lastText1) == false) {
        lastText1 = text;
        textPos1 = 0;
        waitTimeText1 = SCROLL_TIME_WAIT;
      }
      textPos = textPos1;
    }
    // if whole text can be displayed at once
    if (Font.getDefaultFont().stringWidth(text) <= screenWidth - 32) {
      g.setColor(255, 255, 255); // biala czcionka
      g.drawString(text, 16, 16 + line * (fontHeight + 3), Graphics.TOP | Graphics.LEFT);
    }
    // if text doesn't fit into the screen
    else {
      String leftTextTmp = "";
      int i = 0;

      // cut text from the left as long as it doesn't fit to the screen
      while (Font.getDefaultFont().stringWidth(leftTextTmp) < textPos) {
        leftTextTmp = text.substring(0, ++i);
      }

      String textTmp = text.substring(i, text.length());

      boolean textRightCut = false;
      // cut text from the right as long as it doesn't fit to the screen
      while (Font.getDefaultFont().stringWidth(textTmp) > screenWidth - 32) {
        textTmp = textTmp.substring(0, textTmp.length() - 1);
        textRightCut = true;
      }

      g.setColor(255, 255, 255); // biala czcionka
      g.drawString(textTmp, 16, 16 + line * (fontHeight + 3), Graphics.TOP | Graphics.LEFT);

      g.setColor(BACKGROUND_COLOR); // zamazanie tekstu po bokach
      g.fillRect(screenWidth - 16, 16 + line * (fontHeight + 3), 11, fontHeight);
      // g.fillRect(5, 16 + line*(fontHeight + 3), 11, fontHeight);

      if (line == 0) {
        if ((textRightCut == false) && (waitTimeText0 == 0)) // jesli tekst przewinal sie do konca
        waitTimeText0 = SCROLL_TIME_WAIT;

        if (waitTimeText0 == 0) textPos0 += 2; // przewiniecie tekstu
        // if text is going to be displayed statically (without scrolling it)
        else {
          waitTimeText0--;
          // if wait time has ended, start scrolling from the beginning
          if ((waitTimeText0 == 0) && (textPos0 != 0)) {
            waitTimeText0 = SCROLL_TIME_WAIT;
            textPos0 = 0;
          }
        }
      } else if (line == 1) {
        if ((textRightCut == false) && (waitTimeText1 == 0)) // jesli tekst przewinal sie do konca
        waitTimeText1 = SCROLL_TIME_WAIT;

        if (waitTimeText1 == 0) textPos1 += 2; // przewiniecie tekstu
        // if text is going to be displayed statically (without scrolling it)
        else {
          waitTimeText1--;
          // if wait time has ended, start scrolling from the beginning
          if ((waitTimeText1 == 0) && (textPos1 != 0)) {
            waitTimeText1 = SCROLL_TIME_WAIT;
            textPos1 = 0;
          }
        }
      }
    }

    g.setColor(color);
    return true;
  }
Esempio n. 26
0
/** @author Makc */
public class MyToolsScreen extends Canvas {
  Vector myTools = new Vector();
  int se = 0;

  Font f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);

  /** constructor */
  public MyToolsScreen() {
    setFullScreenMode(true);
  }

  /** paint */
  public void paint(Graphics g) {
    g.setFont(MainCanvas.nameFont);

    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());
    UIPainter.paintBackground(g);

    int i;
    for (i = 0; i < myTools.size(); i++) {
      if (se == i) {
        g.setColor(0, 0, 0);
        g.fillRect(
            0, i * MainCanvas.nameFont.getHeight(), getWidth(), MainCanvas.nameFont.getHeight());
        g.setColor(255, 255, 255);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      } else {
        g.setColor(0, 0, 0);
        g.drawString(
            "" + JustPaint.c.brs[((Integer) myTools.elementAt(i)).intValue()],
            5,
            i * MainCanvas.nameFont.getHeight(),
            Graphics.LEFT | Graphics.TOP);
      }
    }

    UIPainter.paintLeftSoft(g, "Добавить");
    UIPainter.paintRightSoft(g, "Отмена");
  }

  /** Called when a key is pressed. */
  protected void keyPressed(int keyCode) {
    if ((keyCode == KEY_NUM2) || (keyCode == -1)) se--;
    if ((keyCode == KEY_NUM8) || (keyCode == -2)) se++;
    if (se < 0) se = myTools.size() - 1;
    if (se >= myTools.size()) se = 0;

    if ((keyCode == -5) || (keyCode == KEY_NUM5)) {
      JustPaint.c.brush = (((Integer) myTools.elementAt(se)).intValue());
      JustPaint.display.setCurrent(JustPaint.c);
    }

    // if (keyCode==KEY_NUM0) JustPaint.display.setCurrent(JustPaint.nf);
    if (keyCode == -6) {
      JustPaint.display.setCurrent(JustPaint.nmt);
    }

    if (keyCode == -7) {
      JustPaint.display.setCurrent(JustPaint.mm);
    }

    if (keyCode == -8) {
      myTools.removeElementAt(se);
      if (se >= myTools.size()) se--;
      if (se < 0) se = 0;
    }

    repaint();
  }
}
Esempio n. 27
0
  private void showRank(Graphics g) {

    Image title = Resource.loadImage(Resource.PIC_ID_RANK_TITLE);
    Image item = Resource.loadImage(Resource.PIC_ID_RANK_ITEM);
    Image foot = Resource.loadImage(Resource.PIC_ID_RANK_FOOT);

    int titleX = (engine.getScreenWidth() - title.getWidth()) >> 1;
    int titleY = 30;
    g.drawImage(title, titleX, titleY, 20);

    Font font = g.getFont();
    int itemX = titleX + ((title.getWidth() - item.getWidth()) >> 1);
    int itemY = titleY + title.getHeight();
    int deltaH = (item.getHeight() - font.getHeight()) >> 1;
    int sx = 0, sy = 0;
    String ss = null;
    int rankX = 43 - 20, idX = 43 + 80, scoresX = 188 + 50, seiX = 309 + 30, timeX = 467 + 10;
    for (int i = 0; i < 11; ++i) {
      g.drawImage(item, itemX, itemY, 20);
      sy = itemY + deltaH;
      itemY += item.getHeight();
      if (i == 0) {
        /*显示表头*/
        rankX += itemX;
        idX += itemX;
        scoresX += itemX;
        seiX += itemX;
        timeX += itemX;

        g.setColor(165, 173, 64);
        g.drawString("游戏排名", rankX, sy, 20);
        g.drawString("用户ID", idX, sy, 20);
        g.drawString("积分", scoresX, sy, 20);
        g.drawString("所用主公", seiX, sy, 20);
        g.drawString("统一时间", timeX, sy, 20);

        /*计算表数据坐标*/
        rankX += font.stringWidth("游戏") - 2;
        idX += ((font.stringWidth("用户ID") - font.stringWidth("0234**98")) >> 1);
        scoresX += ((font.stringWidth("积分") - font.stringWidth("34567")) >> 1);
        seiX += ((font.stringWidth("所用主公") - font.stringWidth("曹操")) >> 1);
        timeX += ((font.stringWidth("统一时间") - font.stringWidth("2012-03-24 23:58")) >> 1);
      } else {
        if (rankingList != null) {
          if (i <= rankingList.length) {
            g.setColor(0XFFFF00);
            g.drawString(Integer.toString(rankingList[i - 1].getRanking()), rankX, sy, 20);
            g.setColor(0XFFFFFF);
            String userId = rankingList[i - 1].getUserId();
            int userIdLen = userId.length();
            g.drawString(
                userId.substring(0, 4) + "**" + userId.substring(userIdLen - 2), idX, sy, 20);
            g.drawString(Integer.toString(rankingList[i - 1].getScores()), scoresX, sy, 20);
            String remark = rankingList[i - 1].getRemark();
            g.drawString(remark.substring(0, remark.indexOf(";")), seiX, sy, 20);
            String time = rankingList[i - 1].getTime();
            g.drawString(time.substring(0, time.length() - 3), timeX, sy, 20);
          }
        }
      }
    }

    int footX = titleX + ((title.getWidth() - foot.getWidth()) >> 1);
    int footY = itemY;
    g.drawImage(foot, footX, footY, 20);
    g.setColor(0XFFFF00);
    if (attainment != null) {
      ss = Integer.toString(attainment.getRanking());
    } else {
      ss = "榜上无名";
    }
    sx = footX + 175 + ((98 - font.stringWidth(ss)) >> 1);
    sy = footY + 9 + ((33 - font.getHeight()) >> 1);
    g.drawString(ss, sx, sy, 20);

    sx = footX + 508;
    sy = footY + 6;
    DrawUtil.drawRect(g, sx, sy, 89, 39, 3);
  }
Esempio n. 28
0
  // #endif
  public static boolean SuggestionPaint(Graphics g, String[] str) {
    // #if REVIEW=="FALSE" && EDUCATION =="TRUE"
    if (SugRunTime++ > totaltime) {
      return true;
    }
    if (SugInfo == null) {
      SugInfo = str;
    }
    // #if SCREENWIDTH>=176
    if (SugInfo != null) {
      g.setColor(0, 0, 0);
      g.fillRect(0, 0, SCR_W, SCR_H);
      // #if SCREENWIDTH<176
      g.setFont(MyFont);
      // #endif
      g.setColor(0xFFFFFF);
      /** 去掉 确定 退出 所占的2 */
      int ContextHeight = MyFont.getHeight() * ((SugInfo.length));
      int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
      int i = 0, loop_end = SugInfo.length;
      while (i < loop_end) {
        g.drawString(
            SugInfo[i], SCR_W >> 1, Y + (i * MyFont.getHeight()), Graphics.HCENTER | Graphics.TOP);
        i++;
      }
    }
    // #else
    if (SugInfo != null) {
      g.setColor(0, 0, 0);
      g.fillRect(0, 0, SCR_W, SCR_H);
      // #if SCREENWIDTH<176
      g.setFont(MyFont);
      // #endif
      g.setColor(0xFFFFFF);
      /** 去掉 确定 退出 所占的2 */
      int ContextHeight = MyFont.getHeight() * ((SugInfo.length >> 1));
      int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
      int i = 0, loop_end = SugInfo.length >> 1;
      if (SugRunTime <= (totaltime >> 1)) {
        while (i <= loop_end) {
          g.drawString(
              SugInfo[i],
              SCR_W >> 1,
              Y + (i * MyFont.getHeight()),
              Graphics.HCENTER | Graphics.TOP);
          i++;
        }
      } else {
        while (i < loop_end) {
          g.drawString(
              SugInfo[i + (SugInfo.length >> 1) + 1],
              SCR_W >> 1,
              Y + (i * MyFont.getHeight()),
              Graphics.HCENTER | Graphics.TOP);
          i++;
        }
      }
    }
    // #endif
    return false;
    // #else
    return true;
    // #endif

  }
Esempio n. 29
0
public class cCP {
  public static int SoundOn = 0;
  // #expand public static int SCR_W = %SCREENWIDTH%;
  public static int SCR_W = 240;
  // #expand public static int SCR_H = %SCREENHEIGHT%;
  public static int SCR_H = 320;
  // #expand public static final int FPSLIMIT = %FPSLIMIT%;
  public static final int FPSLIMIT = 10;
  public static final int FRAME_DT = 1000 / FPSLIMIT;
  public static boolean HasSound = true;
  // 图像资料定义
  public static final int IDX_BG = 0;
  public static final int IDX_BLUR1 = 1 + IDX_BG;
  public static final int IDX_BLUR2 = 1 + IDX_BLUR1;
  public static final int IDX_BLUR3 = 1 + IDX_BLUR2;
  public static final int IDX_CNM = 1 + IDX_BLUR3;
  public static final int IDX_CNM_2 = 1 + IDX_CNM;
  public static final int IDX_CNM_3 = 1 + IDX_CNM_2;
  public static final int IDX_CP = 1 + IDX_CNM_3;
  public static final int IDX_FIRSTLOGO = 1 + IDX_CP;
  public static final int IDX_GAME = 1 + IDX_FIRSTLOGO;
  public static final int IDX_LAST = 1 + IDX_GAME;
  public static final int IDX_LINE = 1 + IDX_LAST;
  public static final int IDX_NO = 1 + IDX_LINE;
  public static final int IDX_SOUND = 1 + IDX_NO;
  public static final int IDX_YES = 1 + IDX_SOUND;
  public static final int IDX_CPYL = 1 + IDX_YES;
  public static final int IDX_MAX = 1 + IDX_CPYL;
  public static Image[] Images = new Image[IDX_MAX];
  // 文件名,与IDX系列顺序相同
  public static final String[] Imgnames = {
    "/sp/bg.png",
    "/sp/blur1.png",
    "/sp/blur2.png",
    "/sp/blur3.png",
    "/sp/cnm.png",
    "/sp/cnm_2.png",
    "/sp/cnm_3.png",
    "/spg/cp.png",
    "/spg/firstlogo.png",
    "/spg/game.png",
    "/sp/last.png",
    "/sp/line.png",
    "/sp/no.png",
    "/sp/sound.png",
    "/sp/yes.png",
    "/spg/cp_yl.png",
  };

  private static final Image GetImage(int id) {
    Image retV = Images[id];
    try {
      if (retV == null) {
        retV = Images[id] = Image.createImage(Imgnames[id]);
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return retV;
  }

  private static final void FreeImage(int id) {
    Images[id] = null;
  }

  private static final void FreeAllImage() {
    for (int i = Images.length - 1; i >= 0; i--) Images[i] = null;
  }

  public static final void SetScreenSize(int w, int h) {
    SCR_W = w;
    SCR_H = h;
    // #if ENABLE_TOUCH=="TRUE"
    cTouch.SetScreenSize(w, h);
    // #endif
  }

  // public static boolean IsTigerOver = false;
  public static final void cCPdrawCleanScreen(Graphics g, int c) {
    g.setColor(c);
    g.fillRect(0, 0, SCR_W, SCR_H);
  }

  public cCP() {}
  /**
   * *************************************************************\ |** 老虎机 Tiger
   * \**************************************************************
   */
  // #if (TIGER=="TRUE")
  public static int runTime = 0;
  // #if SCREENWIDTH>=176
  public static int TIGER_DURING = 6000;
  // #else
  public static int TIGER_DURING = 6000;
  // #endif
  public static Image logo[];
  // #if SCREENWIDTH>=176
  public static final int[] PicIdx = {
    IDX_BG, IDX_CNM, IDX_CNM_2, IDX_CNM_3, IDX_BLUR2, IDX_BLUR3, IDX_BLUR1, IDX_CP, IDX_GAME
  };
  // #else
  public static final int[] PicIdx = {IDX_CNM, IDX_CP, IDX_GAME};
  // #endif
  public static boolean Tiger_Finished = false;

  public static Player SoundPlayer;
  // #endif
  public static void Tiger_Sound_Play() {
    // #if (TIGER=="TRUE")
    String tempName;
    tempName = "/sound/tiger.mid";
    InputStream isSound = Utils.getResourceAsStream(tempName);
    try {
      SoundPlayer = Manager.createPlayer(isSound, "audio/midi");
      isSound = null;
      SoundPlayer.realize();
      SoundPlayer.prefetch();
      SoundPlayer.setLoopCount(1);
      SoundPlayer.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
    // #endif
  }

  public static final void Tiger_Sound_Final() {
    // #if (TIGER=="TRUE")
    if (SoundPlayer != null) {
      if (SoundPlayer.getState() == Player.STARTED) {
        try {
          SoundPlayer.stop();
        } catch (Exception e) {
        }
      }
      SoundPlayer.deallocate();
      SoundPlayer.close();
      SoundPlayer = null;
    }
    ;
    // #endif
  }

  public static final boolean Tiger_Paint(Graphics g) {
    // #if !(TIGER=="TRUE")
    return true;
    // #else
    // #if SCREENWIDTH>=176
    return Tiger_Paint_Big(g);
    // #else
    return Tiger_Paint_Small(g);
    // #endif
    // #endif
  }

  private static final boolean Tiger_Paint_Small(Graphics g) {
    // #if !(TIGER=="TRUE")
    return true;
    // #else
    if (logo == null) {

      logo = new Image[PicIdx.length];
      for (int i = PicIdx.length - 1; i >= 0; i--) logo[i] = GetImage(PicIdx[i]);
      if (SoundOn != 0) Tiger_Sound_Play();
    }

    if (++runTime >= TIGER_DURING / FRAME_DT) {
      logo = null;
      FreeAllImage();
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.ClearBtns();
      // #endif
      Tiger_Finished = true;
      Tiger_Sound_Final();
      return true;
    } else {
      cCPdrawCleanScreen(g, 0x0); // 清屏
      if (runTime < (TIGER_DURING / 3) / FRAME_DT) {
        g.drawImage(logo[0], (SCR_W >> 1), (SCR_H >> 1), Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 2 / 3) / FRAME_DT) {
        g.drawImage(logo[1], (SCR_W >> 1), (SCR_H >> 1), Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < TIGER_DURING / FRAME_DT) {
        g.drawImage(logo[2], (SCR_W >> 1), (SCR_H >> 1), Graphics.HCENTER | Graphics.VCENTER);
      }
      return false;
    }
    // #endif
  }

  public static final boolean Tiger_Paint_Big(Graphics g) {
    // #if !(TIGER=="TRUE")
    return true;
    // #else
    if (logo == null) {
      logo = new Image[PicIdx.length];
      for (int i = PicIdx.length - 1; i >= 0; i--) logo[i] = GetImage(PicIdx[i]);
      if (SoundOn != 0) Tiger_Sound_Play();
    }
    if (++runTime >= TIGER_DURING / FRAME_DT) {
      // #if MODEL=="N73"
      if (SoundPlayer == null || SoundPlayer.getMediaTime() == 0) { // 不播放声音或者判断声音播放完毕时
        // #endif
        logo = null;
        FreeAllImage();
        // #if ENABLE_TOUCH=="TRUE"
        cTouch.ClearBtns();
        // #endif
        Tiger_Finished = true;
        Tiger_Sound_Final();
        return true;
        // #if MODEL=="N73"
      } else {
        return false;
      }
      // #endif
    } else {
      //			System.out.println("程序执行到此处");
      // cCPdrawCleanScreen(g, 0x0);//清屏
      g.drawImage(logo[0], SCR_W >> 1, SCR_H >> 1, Graphics.HCENTER | Graphics.VCENTER);

      if (runTime < (TIGER_DURING * 1 / 8) / FRAME_DT) {
        g.drawImage(
            logo[2], (SCR_W >> 1) - 2, (SCR_H >> 1) - 12, Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[1],
            (SCR_W >> 1) - logo[2].getWidth() - 2,
            (SCR_H >> 1) - 12,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[3],
            (SCR_W >> 1) - 4 + logo[2].getWidth() + 2,
            (SCR_H >> 1) - 12 + 1,
            Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 2 / 8) / FRAME_DT) {
        g.drawImage(
            logo[4 + runTime % 3],
            SCR_W >> 1,
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 3 / 8) / FRAME_DT) {
        g.drawImage(
            logo[4 + runTime % 3],
            SCR_W >> 1,
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[4 + (runTime + 2) % 3],
            (SCR_W >> 1) - logo[2].getWidth() - 2,
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 4 / 8) / FRAME_DT) {
        g.drawImage(
            logo[4 + runTime % 3],
            SCR_W >> 1,
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[4 + (runTime + 2) % 3],
            (SCR_W >> 1) - logo[2].getWidth() - 2,
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[4 + (runTime + 2) % 3],
            (SCR_W >> 1) + logo[2].getWidth(),
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 5 / 8) / FRAME_DT) {
        g.drawImage(logo[1], SCR_W >> 1, (SCR_H >> 1) - 10, Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[4 + (runTime + 2) % 3],
            (SCR_W >> 1) - logo[2].getWidth() - 2,
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[4 + (runTime + 2) % 3],
            (SCR_W >> 1) + logo[2].getWidth(),
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 6 / 8) / FRAME_DT) {
        g.drawImage(logo[1], SCR_W >> 1, (SCR_H >> 1) - 10, Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[7],
            (SCR_W >> 1) + 1 - logo[2].getWidth() - 2,
            (SCR_H >> 1) - 12,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[4 + (runTime + 2) % 3],
            (SCR_W >> 1) + logo[2].getWidth(),
            (SCR_H >> 1) - 10,
            Graphics.HCENTER | Graphics.VCENTER);
      } else if (runTime < (TIGER_DURING * 8 / 8) / FRAME_DT) {
        g.drawImage(logo[1], SCR_W >> 1, (SCR_H >> 1) - 10, Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[7],
            (SCR_W >> 1) + 1 - logo[2].getWidth() - 2,
            (SCR_H >> 1) - 12,
            Graphics.HCENTER | Graphics.VCENTER);
        g.drawImage(
            logo[8],
            (SCR_W >> 1) - 1 + logo[2].getWidth(),
            (SCR_H >> 1) - 12,
            Graphics.HCENTER | Graphics.VCENTER);
      }
      return false;
    }
    // #endif
  }

  public static final boolean Tiger_Update(int keycode) {
    // #if !(TIGER=="TRUE")
    return true;
    // #else
    return Tiger_Finished;
    // #endif
  }

  // 键值定义
  public static final int L = 0;
  public static final int R = 1 + L;
  public static int[] KeyValue = new int[] {DevConfig.KEY_LSK, DevConfig.KEY_RSK};
  /**
   * *************************************************************\ |** SoundOnOff 声音选项状态 *|
   * \**************************************************************
   */
  ////	#if SOUNDONOFF=="TRUE"
  public static final int LINESPACE = 3;
  /** 返回 true表示,本状态结束 */
  public static int SoundOnOffPaintCount = 0;

  public static int SoundOnOffTotalFrame = 30;
  public static boolean BtnSoundOnOffInited = false;
  public static boolean SoundOnOffisFinished = false;
  //// #endif
  public static final void SetKeyValue(int[] k) {
    //// #if SOUNDONOFF=="TRUE"
    KeyValue = k;
    //// #endif
  }

  public static final void SetHasSound(boolean On) {
    //// #if SOUNDONOFF=="TRUE"
    HasSound = On;
    //// #endif
  }

  public static final boolean SoundOnOff_paint(Graphics g) {
    // #if SCREENWIDTH<176 || MODEL=="D508" || MODEL=="KG90n" || MODEL=="D608"|| MODEL=="E398" ||
    // MODEL=="L7" || MODEL=="K1"|| MODEL=="S700"
    return SoundOnOff_paint_small(g);
    // #else
    return SoundOnOff_paint_big(g);
    // #endif
  }

  public static long TotalTime = 0;

  public static final boolean SoundOnOff_paint_small(Graphics g) {
    cCPdrawCleanScreen(g, 0);
    Image Img_firstLogo = GetImage(IDX_FIRSTLOGO);
    Image Img_CNM = GetImage(IDX_CNM);
    g.drawImage(
        Img_firstLogo,
        DevConfig.SCR_W >> 1,
        Img_firstLogo.getHeight() >> 1,
        Graphics.HCENTER | Graphics.VCENTER);
    g.drawImage(
        Img_CNM, cCP.SCR_W >> 1, Img_firstLogo.getHeight(), Graphics.HCENTER | Graphics.TOP);
    //		TotalTime += GLLib.s_Tick_Paint_FrameDT;

    if (TotalTime++ > 20) {
      GameMIDlet.SetSoundOnOff(false);
      return true;
    } else {
      return false;
    }
  }

  public static final boolean SoundOnOff_paint_big(Graphics g) {
    cCPdrawCleanScreen(g, 0);
    if (!BtnSoundOnOffInited) {
      // #if MODEL != "G12_Review"
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.InitVirtualKeysForLRSK(SCR_W, SCR_H);
      // #endif
      // #endif
      BtnSoundOnOffInited = true;
    }
    int FontHeight = g.getFont().getHeight();
    if (!HasSound) {
      if ((++SoundOnOffPaintCount) > SoundOnOffTotalFrame) {
        FreeAllImage();
        // #if ENABLE_TOUCH=="TRUE"
        cTouch.ClearBtns();
        cTouch.TargetCanvas = null;
        // #endif
        SoundOnOffisFinished = true;
        return true;
      }
    }
    // 读取资源
    // #if SOUNDONOFF=="TRUE"
    Image Img_firstLogo = GetImage(IDX_FIRSTLOGO);
    // #endif
    Image Img_sound = GetImage(IDX_SOUND);
    Image Img_line = GetImage(IDX_LINE);
    Image Img_yes = GetImage(IDX_YES);
    Image Img_no = GetImage(IDX_NO);
    Image Img_cp = GetImage(IDX_CP);

    Image Img_CNM = GetImage(IDX_CNM);
    // #if CHANNEL_NAME=="SHYL"
    Image Img_CPYL = GetImage(IDX_CPYL);
    // #endif
    // 开始绘制
    int height = SCR_H;
    if (HasSound) {
      // 绘制左右软键
      g.drawImage(Img_yes, 0, height, Graphics.LEFT | Graphics.BOTTOM);
      g.drawImage(Img_no, SCR_W, height, Graphics.RIGHT | Graphics.BOTTOM);
      height -= Img_yes.getHeight();
      height -= LINESPACE;
      // 绘制线条
      height -= Img_line.getHeight();
      g.drawImage(Img_line, SCR_W >> 1, height, Graphics.HCENTER | Graphics.TOP);
      height -= LINESPACE;

      // 绘制  是否开启声音
      height -= Img_sound.getHeight();
      g.drawImage(Img_sound, SCR_W >> 1, height, Graphics.HCENTER | Graphics.TOP);
      height -= LINESPACE;
    }
    // #if CHANNEL_NAME=="SHYL"
    g.drawImage(Img_CPYL, SCR_W >> 1, height >> 1, Graphics.VCENTER | Graphics.HCENTER);
    // #endif
    // #if SOUNDONOFF=="TRUE"
    // #if LOGO=="TRUE"
    // 绘制CNM Logo
    height -= Img_CNM.getHeight();
    g.drawImage(Img_CNM, SCR_W >> 1, height, Graphics.HCENTER | Graphics.TOP);
    height -= LINESPACE;
    // #endif

    // 绘制  游戏 Logo
    // 这正是剩余的高度,将FirstLogo 放到正中
    g.drawImage(Img_firstLogo, SCR_W >> 1, height >> 1, Graphics.HCENTER | Graphics.VCENTER);
    // #endif
    // #if SHOWGAMENAME=="TRUE"
    // 画游戏名字
    // #endif
    return false;
  };
  /** 返回 true表示,本状态结束 */
  public static final boolean SoundOnOff_Update(int keycode) {

    //// #if SOUNDONOFF=="TRUE"
    int idx = -1;
    boolean retV = false;
    // #if SCREENWIDTH<176 || MODEL=="D508" || MODEL=="KG90n" || MODLE=="D608"|| MODEL=="E398" ||
    // MODEL=="L7"
    // #else
    if (!HasSound) {
      return SoundOnOffisFinished;
    }
    for (int i = KeyValue.length - 1; i >= 0; i--) {
      if (KeyValue[i] == keycode) {
        idx = i;
        break;
      }
    }
    if (idx < 0) return false;

    switch (idx) {
      case L:
        SoundOn = -1;

        GameMIDlet.SetSoundOnOff(true);

        retV = true;
        break;
      case R:
        SoundOn = 0;
        GameMIDlet.SetSoundOnOff(false);
        retV = true;
        break;
    }
    if (retV) {
      FreeAllImage();
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.ClearBtns();
      // cTouch.TargetCanvas = null;
      // #endif
    }
    // #endif
    return retV;
    //// #else
    //		return true;
    //// #endif
  }
  // #if ENABLE_TOUCH=="TRUE"
  public static final void SoundOnOff_pointerPressed(int x, int y) {
    //// #if SOUNDONOFF=="TRUE"
    cTouch.pointerPressed(x, y);
    //// #endif
  }

  public static final void SoundOnOff_pointerReleased(int x, int y) {
    //// #if SOUNDONOFF=="TRUE"
    cTouch.pointerPressed(x, y);
    //// #endif
  }
  // #endif

  /**
   * ******************************************************************\ MoreGame QuitConfirm 部分
   * \*******************************************************************
   */
  public static String[] Info = null;

  public static String[] ConfirmInfo = null;
  // #expand	public static final String url_moreGame = "%URL_MOREGAME%" + "?" + "%CPID%" + "&" +
  // "%CONTENTID%";
  //	public static final String url_moreGame = "%URL_MOREGAME%";
  // #if SCREENWIDTH>=176
  public static Font MyFont = Font.getFont(Font.FACE_PROPORTIONAL, 0, Font.SIZE_SMALL);
  // #else
  public static Font MyFont = Font.getFont(Font.FACE_PROPORTIONAL, 0, Font.SIZE_LARGE);
  // #endif

  public static final boolean MoreGame_Paint(Graphics g) {
    if (GameMIDlet.GetInstance() != null) {
      GameMIDlet.GetInstance().notifyDestroyed();
      return true;
    }
    // #if MOREGAME=="TRUE" && MODEL!="D608" && MODEL!="D508"
    Image last = cCP.GetImage(IDX_LAST);
    if (Info == null) {
      // #if SCREENWIDTH>=176
      Info = new String[] {"更多精彩游戏", "尽在游戏频道", "Wap.xjoys.com", "确定", "退出"};
      // #else
      Info = new String[] {"更多精彩游戏", "尽在游戏频道", "Wap.xjoys.com", "确定", "退出"};
      // #endif
    }
    if (last != null) {
      g.drawImage(last, SCR_W >> 1, SCR_H >> 1, Graphics.VCENTER | Graphics.HCENTER);
    }
    if (Info != null) {
      g.setFont(MyFont);
      g.setColor(0xFFFFFF);
      /** 去掉 确定 退出 所占的2 */
      int ContextHeight = MyFont.getHeight() * ((Info.length - 2));
      int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
      int i = 0, loop_end = Info.length - 2;
      while (i < loop_end) {
        g.drawString(
            Info[i], SCR_W >> 1, Y + (i * MyFont.getHeight()), Graphics.HCENTER | Graphics.TOP);
        i++;
      }
      /** 左右软键,可以用宏,处理那些对调的机型,-3 为让基线下的文字显示出来 */
      g.drawString(Info[Info.length - 2], 0, SCR_H - 3, Graphics.LEFT | Graphics.BOTTOM);
      g.drawString(Info[Info.length - 1], SCR_W, SCR_H - 3, Graphics.RIGHT | Graphics.BOTTOM);
    }
    return false;
    // #else
    return true;
    // #endif
  }

  public static final boolean QuitConfirm_Paint(Graphics g) {
    //		Image last = cCP.GetImage(IDX_LAST);
    if (ConfirmInfo == null) {
      // #if SCREENWIDTH>=176
      ConfirmInfo = new String[] {"确定退出?", "确定", "返回"};
      // #else
      ConfirmInfo = new String[] {"确定退出?", "确定", "返回"};
      // #endif
    }
    //		if (last!=null)
    //		{
    //			g.drawImage(last,SCR_W>>1,SCR_H>>1,Graphics.VCENTER|Graphics.HCENTER);
    //		}
    if (ConfirmInfo != null) {
      g.setColor(0x000000);
      g.fillRect(0, 0, SCR_W, SCR_H);
      g.setColor(0xffffff);
      /** 去掉 确定 退出 所占的2 */
      int ContextHeight = MyFont.getHeight() * ((ConfirmInfo.length - 2));
      int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
      int i = 0, loop_end = ConfirmInfo.length - 2;
      while (i < loop_end) {
        g.drawString(
            ConfirmInfo[i],
            SCR_W >> 1,
            Y + (i * MyFont.getHeight()),
            Graphics.HCENTER | Graphics.TOP);
        i++;
      }
      /** 左右软键,可以用宏,处理那些对调的机型,-3 为让基线下的文字显示出来 */
      g.drawString(
          ConfirmInfo[ConfirmInfo.length - 2], 0, SCR_H - 3, Graphics.LEFT | Graphics.BOTTOM);
      g.drawString(
          ConfirmInfo[ConfirmInfo.length - 1], SCR_W, SCR_H - 3, Graphics.RIGHT | Graphics.BOTTOM);
    }
    return false;
  }

  public static final int MOREGAME_NULL = 0;
  public static final int MOREGAME_OPENED = 1;
  public static final int MOREGAME_CANCEL = 2;

  public static final int MoreGame_Update(MIDlet midlet, int keycode) {
    // #if MOREGAME=="TRUE" && MODEL!="D608" && MODEL!="D508"
    int idx = -1;
    int retV = MOREGAME_NULL;
    for (int i = KeyValue.length - 1; i >= 0; i--) {
      if (KeyValue[i] == keycode) {
        idx = i;
        break;
      }
    }
    if (idx < 0) return MOREGAME_NULL;

    switch (idx) {
      case L:
        MoreGame_DoOpen(midlet);
        retV = MOREGAME_OPENED;
        break;
      case R:
        retV = MOREGAME_CANCEL;
        break;
    }
    if (retV != MOREGAME_NULL) {
      FreeAllImage();
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.ClearBtns();
      // #endif
    }
    return retV;
    // #else
    return MOREGAME_CANCEL;
    // #endif
  }

  public static final int QuitConfirm_Update(int keycode) {
    int idx = -1;
    int retV = MOREGAME_NULL;
    for (int i = KeyValue.length - 1; i >= 0; i--) {
      if (KeyValue[i] == keycode) {
        idx = i;
        break;
      }
    }
    if (idx < 0) return MOREGAME_NULL;

    switch (idx) {
      case L:
        // MoreGame_DoOpen(midlet);
        retV = MOREGAME_CANCEL;
        GameMIDlet.GetInstance().notifyDestroyed();
        break;
      case R:
        retV = MOREGAME_NULL;
        break;
    }
    if (retV != MOREGAME_NULL) {
      FreeAllImage();
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.ClearBtns();
      // #endif
    }
    return retV;
  }

  private static final void MoreGame_DoOpen(MIDlet midlet) {
    try {
      midlet.platformRequest(url_moreGame);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public static final int PAUSE_NULL = 0;
  public static final int PAUSE_OPENED = 1;
  public static final int PAUSE_CANCEL = 2;

  public static final boolean Pause_Paint(Graphics g) {
    return false;
  }

  public static final int Pause_Update(int keyCode) {
    switch (keyCode) {
      case DevConfig.KEY_LSK:
        return PAUSE_OPENED;
      case DevConfig.KEY_RSK:
        return PAUSE_CANCEL;
      default:
        return PAUSE_NULL;
    }
  }

  public static int Paint_Index = 0;
  /** 区别黑字白字 用法:H>>6黑字 H原值白字 */
  public static final void String_Splash_Paint(Graphics g, String str, int W, int H) {
    if (Paint_Index++ % 10 < 5) {
      if (H > 1000) { // 区别黑字白字
        g.setColor(0x000000);
        g.drawString(str, W >> 1, H >> 7, Graphics.TOP | Graphics.HCENTER);
      } else {
        g.setColor(0xFFFFFF);
        g.drawString(str, W >> 1, H >> 1, Graphics.TOP | Graphics.HCENTER);
      }
    }
  }

  public static String[] SugInfo = null;
  public static int SugRunTime = 0;
  /**
   * 教育类提示屏
   *
   * @param g
   * @param str
   * @return
   */
  //	//#if SCREENWIDTH>=176
  //	public static int totaltime = 50;
  //	//#else
  //	public static int totaltime = 100;
  //	//#endif
  //	public static boolean SuggestionPaint(Graphics g,String[] str){
  //// #if REVIEW!="FALSE"
  //		if(SugRunTime++>totaltime){
  //			return true;
  //		}
  //		if(SugInfo == null){
  //			SugInfo = str;
  //		}
  //		//#if SCREENWIDTH>=176
  //		if(SugInfo != null){
  //			g.setColor(0, 0, 0);
  //			g.fillRect(0, 0, SCR_W, SCR_H);
  //			//#if SCREENWIDTH<176
  //			g.setFont(MyFont);
  //			//#endif
  //			g.setColor(0xFFFFFF);
  //			/** 去掉  确定 退出 所占的2 */
  //			int ContextHeight = MyFont.getHeight() * ((SugInfo.length));
  //			int Y = (SCR_H - MyFont.getHeight() - ContextHeight)>> 1;
  //			int i = 0,loop_end = SugInfo.length;
  //			while (i<loop_end)
  //			{
  //				g.drawString(SugInfo[i], SCR_W>>1, Y + (i*MyFont.getHeight()),
  // Graphics.HCENTER|Graphics.TOP);
  //				i++;
  //			}
  //		}
  //		//#else
  //		if(SugInfo != null){
  //			g.setColor(0, 0, 0);
  //			g.fillRect(0, 0, SCR_W, SCR_H);
  //			//#if SCREENWIDTH<176
  //			g.setFont(MyFont);
  //			//#endif
  //			g.setColor(0xFFFFFF);
  //			/** 去掉  确定 退出 所占的2 */
  //			int ContextHeight = MyFont.getHeight() * ((SugInfo.length>>1));
  //			int Y = (SCR_H - MyFont.getHeight() - ContextHeight)>> 1;
  //			int i = 0,loop_end = SugInfo.length>>1;
  //			if(SugRunTime<=(totaltime>>1)){
  //				while (i<loop_end)
  //				{
  //					g.drawString(SugInfo[i], SCR_W>>1, Y + (i*MyFont.getHeight()),
  // Graphics.HCENTER|Graphics.TOP);
  //					i++;
  //				}
  //			}else{
  //				while (i<loop_end)
  //				{
  //					g.drawString(SugInfo[i+(SugInfo.length>>1)], SCR_W>>1, Y + (i*MyFont.getHeight()),
  // Graphics.HCENTER|Graphics.TOP);
  //					i++;
  //				}
  //			}
  //		}
  //		//#endif
  //		return false;
  //// #else
  //		return true;
  //// #endif
  //
  //	}
  // #if SCREENWIDTH>=176
  public static int totaltime = 50;
  // #else
  public static int totaltime = 100;
  // #endif
  public static boolean SuggestionPaint(Graphics g, String[] str) {
    // #if REVIEW=="FALSE" && EDUCATION =="TRUE"
    if (SugRunTime++ > totaltime) {
      return true;
    }
    if (SugInfo == null) {
      SugInfo = str;
    }
    // #if SCREENWIDTH>=176
    if (SugInfo != null) {
      g.setColor(0, 0, 0);
      g.fillRect(0, 0, SCR_W, SCR_H);
      // #if SCREENWIDTH<176
      g.setFont(MyFont);
      // #endif
      g.setColor(0xFFFFFF);
      /** 去掉 确定 退出 所占的2 */
      int ContextHeight = MyFont.getHeight() * ((SugInfo.length));
      int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
      int i = 0, loop_end = SugInfo.length;
      while (i < loop_end) {
        g.drawString(
            SugInfo[i], SCR_W >> 1, Y + (i * MyFont.getHeight()), Graphics.HCENTER | Graphics.TOP);
        i++;
      }
    }
    // #else
    if (SugInfo != null) {
      g.setColor(0, 0, 0);
      g.fillRect(0, 0, SCR_W, SCR_H);
      // #if SCREENWIDTH<176
      g.setFont(MyFont);
      // #endif
      g.setColor(0xFFFFFF);
      /** 去掉 确定 退出 所占的2 */
      int ContextHeight = MyFont.getHeight() * ((SugInfo.length >> 1));
      int Y = (SCR_H - MyFont.getHeight() - ContextHeight) >> 1;
      int i = 0, loop_end = SugInfo.length >> 1;
      if (SugRunTime <= (totaltime >> 1)) {
        while (i <= loop_end) {
          g.drawString(
              SugInfo[i],
              SCR_W >> 1,
              Y + (i * MyFont.getHeight()),
              Graphics.HCENTER | Graphics.TOP);
          i++;
        }
      } else {
        while (i < loop_end) {
          g.drawString(
              SugInfo[i + (SugInfo.length >> 1) + 1],
              SCR_W >> 1,
              Y + (i * MyFont.getHeight()),
              Graphics.HCENTER | Graphics.TOP);
          i++;
        }
      }
    }
    // #endif
    return false;
    // #else
    return true;
    // #endif

  }
};
  public void drawItem(Graphics g, int offset, boolean selected, boolean drawsec) {
    // g.setColor(0);
    boolean ralign = false;
    boolean underline = false;

    // #if NICK_COLORS
    // # 	boolean nick=false;
    // #endif

    int w = offset;
    int dw;
    int imageYOfs = ((getVHeight() - imgHeight()) >> 1);
    // #if ALCATEL_FONT
    // #         int fontYOfs=(( getVHeight()-font.getHeight() )>>1) +1;
    // #else
    int fontYOfs = ((getVHeight() - font.getHeight()) >> 1);
    // #endif
    int imgWidth = imgWidth();

    g.setFont(font);
    for (int index = 0; index < elementCount; index++) {
      Object ob = elementData[index];
      if (ob != null) {

        if (ob instanceof String) {
          // string element
          String s = (String) ob;
          // #if NICK_COLORS
          // #                     if (nick) {
          // #                         int color=g.getColor();
          // #                         dw=0;
          // #                         int p1=0;
          // #                         while (p1<s.length()) {
          // #                             int p2=p1;
          // #                             char c1=s.charAt(p1);
          // #                             //processing the same cp
          // #                             while (p2<s.length()) {
          // #                                 char c2=s.charAt(p2);
          // #                                 if ( (c1&0xff00) != (c2 &0xff00) ) break;
          // #                                 p2++;
          // #                             }
          // #                             g.setColor( (c1>255) ? ColorScheme.strong(color) :
          // color);
          // #                             dw=font.substringWidth(s, p1, p2-p1);
          // #                             if (ralign) w-=dw;
          // #                             g.drawSubstring( s, p1, p2-p1,
          // #                                     w,fontYOfs,Graphics.LEFT|Graphics.TOP);
          // #                             if (!ralign) w+=dw;
          // #                             p1=p2;
          // #                         }
          // #
          // #                         g.setColor(color);
          // #                     } else {
          // #endif
          dw = font.stringWidth(s);
          if (ralign) w -= dw;
          g.drawString(s, w, fontYOfs, Graphics.LEFT | Graphics.TOP);
          if (underline) {
            int y = getVHeight() - 1;
            g.drawLine(w, y, w + dw, y);
            underline = false;
          }
          if (!ralign) w += dw;
          // #if NICK_COLORS
          // #                     }
          // #endif

        } else if ((ob instanceof Integer)) {
          // image element or color
          int i = ((Integer) ob).intValue();
          switch (i & 0xff000000) {
            case IMAGE:
              if (imageList == null) break;
              if (ralign) w -= imgWidth;
              imageList.drawImage(g, ((Integer) ob).intValue(), w, imageYOfs);
              if (!ralign) w += imgWidth;
              break;
            case COLOR:
              g.setColor(0xFFFFFF & i);
              break;
            case RALIGN:
              ralign = true;
              w = g.getClipWidth() - 1;
              break;
            case UNDERLINE:
              underline = true;
              break;
              // #if NICK_COLORS
              // #                         case NICK_ON:
              // #                             nick=true;
              // #                             break;
              // #                         case NICK_OFF:
              // #                             nick=false;
              // #                             break;
              // #endif
          }
        } /* Integer*/ else if (ob instanceof VirtualElement) {
          int clipw = g.getClipWidth();
          int cliph = g.getClipHeight();
          ((VirtualElement) ob).drawItem(g, 0, false, false);
          g.setClip(g.getTranslateX(), g.getTranslateY(), clipw, cliph);
          // TODO: рисование не с нулевой позиции и вычисление ширины
        }
      } // if ob!=null
    } // for
  }