コード例 #1
0
ファイル: SplashScreen.java プロジェクト: gusti91/instantme
  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);
    }
  }
コード例 #2
0
ファイル: AboutScreen.java プロジェクト: raghulj/btis
  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;
    }
  }
コード例 #3
0
  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);
  }
コード例 #4
0
ファイル: MyToolsScreen.java プロジェクト: m1kc/justpaint
  /** 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, "Отмена");
  }
コード例 #5
0
ファイル: TrackTile.java プロジェクト: keyeMyria/bbTracker
  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);
  }
コード例 #6
0
ファイル: MapView.java プロジェクト: heroyuy/systar
 private void drawDialog(Graphics g) {
   Painter.drawDialog(
       g,
       0,
       gd.screenHeight - g.getFont().getHeight() * 3 - 20,
       gd.screenWidth,
       g.getFont().getHeight() * 3 + 20,
       Painter.DIALOG_DEEP);
   g.setFont(Const.Font.FONTSMALL_PLAIN);
   // 对话人
   Painter.drawString(
       g, gd.dialog_name + ":", 10, gd.screenHeight - g.getFont().getHeight() * 3 - 10, 0xffffff);
   // 两行对话内容
   Painter.drawString(
       g,
       gd.dialog_content[gd.dialog_index],
       10,
       gd.screenHeight - g.getFont().getHeight() * 2 - 10,
       0xffffff);
   if (gd.dialog_index + 1 < gd.dialog_content.length) {
     Painter.drawString(
         g,
         gd.dialog_content[gd.dialog_index + 1],
         10,
         gd.screenHeight - g.getFont().getHeight() - 10,
         0xffffff);
   }
 }
コード例 #7
0
ファイル: Label.java プロジェクト: biddyweb/J2ME-UI
  public void paint(Graphics g) {
    if (isDirty() && isVisible()) {
      g.setFont(Component.getDefaultFont());
      this.setDirty(false);

      System.out.println("Paint label: " + text);

      if (!transparent) {
        g.setColor(bgColor);
        g.fillRect(getX(), getY(), getWidth(), getHeight());
      }
      g.setFont(Component.getDefaultFont());
      g.setColor(this.fgColor);
      g.drawString(this.text, getX(), getY(), 20);

      if (isFocus()) this.paintFocus(g);
    }
  }
コード例 #8
0
ファイル: CatcherCanvas.java プロジェクト: tc-/Catcher
 protected final void paint(Graphics g) {
   g.setFont(sysFont);
   if (modal != null) {
     modal.paint(g);
   } else {
     paintView(g);
     paintStatusBar(g);
   }
 }
コード例 #9
0
ファイル: BBStyleString.java プロジェクト: solkin/tcuilitelib
 public void paint(Graphics g, int x, int y) {
   if (style != null) {
     g.setFont(style.font);
     g.setColor(style.color);
   }
   if (string != null) {
     g.drawString(string, x + local_x, y + local_y, Graphics.TOP | Graphics.LEFT);
   } else if (smileLink != null) {
     smileLink.updateLocation(x + local_x, y + local_y);
     Smiles.smiles[smileLink.smileIndex].paint(g, smileLink.x, smileLink.y, smileLink.frameIndex);
     smileLink.analyzeFrame();
   }
 }
コード例 #10
0
ファイル: KetrisMap.java プロジェクト: hzbiao/yzKetris
 private void paintScore(Graphics g) {
   // 清除记分牌
   g.setColor(KetrisCanvas.BACKGROUD);
   g.fillRect(
       KetrisCanvas.GAMEAREA_X + 12 * KetrisCanvas.BRICK_WIDTH,
       KetrisCanvas.GAMEAREA_Y + 6 * KetrisCanvas.BRICK_WIDTH,
       KetrisCanvas.BRICK_WIDTH * 4,
       KetrisCanvas.BRICK_WIDTH * 4);
   // 计分
   g.setColor(0, 255, 0);
   g.setFont(SCOREFONT);
   g.drawString(
       "" + score,
       KetrisCanvas.GAMEAREA_X + 14 * KetrisCanvas.BRICK_WIDTH,
       KetrisCanvas.GAMEAREA_Y + 8 * KetrisCanvas.BRICK_WIDTH,
       Graphics.BASELINE | Graphics.HCENTER);
 }
コード例 #11
0
ファイル: CWindow.java プロジェクト: mcav/j2me.js
  /**
   * Second Pass: We sweep through the layers from the bottom to the top and paint each one that is
   * marked as dirty
   *
   * <p>Note, that the painting for copied layers is done here to not hold the layers lock during
   * the painting.
   *
   * @param g The graphics object to use to paint this window.
   * @param refreshQ The custom queue which holds the set of refresh regions needing to be blitted
   *     to the screen
   */
  private void paintLayers(Graphics g, CGraphicsQ refreshQ) {
    if (CGraphicsQ.DEBUG) {
      System.err.println("[Paint dirty layers]");
    }

    for (int i = 0; i < dirtyCount; i++) {
      CLayer l = dirtyLayers[i];

      // Prepare relative dirty region coordinates
      // of the current layer
      int dx = l.dirtyBoundsCopy[X];
      int dy = l.dirtyBoundsCopy[Y];
      int dw = l.dirtyBoundsCopy[W];
      int dh = l.dirtyBoundsCopy[H];

      // Before we call into the layer to paint, we
      // translate the graphics context into the layer's
      // coordinate space
      g.translate(l.boundsCopy[X], l.boundsCopy[Y]);

      if (CGraphicsQ.DEBUG) {
        System.err.println("Painting Layer: " + l);
        System.err.println("\tClip: " + dx + ", " + dy + ", " + dw + ", " + dh);
      }

      // Clip the graphics to only contain the dirty region of
      // the layer (if the dirty region isn't set, clip to the
      // whole layer contents).
      g.clipRect(dx, dy, dw, dh);
      refreshQ.queueRefresh(l.boundsCopy[X] + dx, l.boundsCopy[Y] + dy, dw, dh);
      l.paint(g);

      // We restore our graphics context to prepare
      // for the next layer
      g.translate(-g.getTranslateX(), -g.getTranslateY());
      g.translate(tranX, tranY);

      // We reset our clip to this window's bounds again.
      g.setClip(bounds[X], bounds[Y], bounds[W], bounds[H]);

      g.setFont(font);
      g.setColor(color);
    } // for
  }
コード例 #12
0
ファイル: LabeledSeparator.java プロジェクト: x-clone/Xfolite
  // protected void paint(Graphics g, int w, int h) {
  protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
    final int c = y + contentHeight / 2;

    g.setColor(0x949494);
    g.setFont(this.font);

    if (displayString == null || displayString.length() == 0) {
      g.drawLine(leftBorder, c, rightBorder, c);
      return;
    }

    int totalStringWidth = this.font.stringWidth(displayString) + this.linePadding;
    if (this.isLayoutCenter) {
      totalStringWidth += this.linePadding;
    }

    int lineLen = rightBorder - leftBorder - totalStringWidth;
    if (this.isLayoutCenter) {
      lineLen /= 2;
    }

    if (this.isLayoutCenter || this.isLayoutRight) {
      g.drawLine(leftBorder, c, leftBorder + lineLen, c);
    } else {
      g.drawLine(leftBorder + totalStringWidth, c, leftBorder + totalStringWidth + lineLen, c);
    }

    g.setColor(this.fontColor);
    if (this.isLayoutCenter) {
      g.drawString(
          displayString, leftBorder + lineLen + this.linePadding, y, Graphics.LEFT | Graphics.TOP);
    } else if (this.isLayoutRight) {
      g.drawString(displayString, rightBorder, y, Graphics.RIGHT | Graphics.TOP);
    } else {
      g.drawString(displayString, leftBorder, y, Graphics.LEFT | Graphics.TOP);
    }
    if (this.isLayoutCenter) {
      g.setColor(0x949494);
      g.drawLine(leftBorder + lineLen + totalStringWidth, c, rightBorder, c);
    }
  }
コード例 #13
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
 }
コード例 #14
0
ファイル: BagView.java プロジェクト: heroyuy/systar
  private void paint_Main(Graphics g) {

    int th = 50; // 标题栏高度
    int ih = 80; // 介绍栏高度
    int ch = gd.screenHeight - th - ih; // 中间列表区域高度
    int gap = 10; // 间距
    int cellW = 160, cellH = 30;
    /** 标题 */
    Painter.drawDialog(g, 0, 0, gd.screenWidth, th, Painter.DIALOG_DEEP);
    g.setFont(Const.Font.FONTLARGE_BOLD);
    g.setColor(Const.Color.GREEN);
    g.drawString("背 包", gd.screenWidth / 2, (th - g.getFont().getHeight()) / 2, Const.Anchor.HT);
    /** 列表 */
    // 底框
    Painter.drawDialog(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_DEEP);
    // 选项卡
    Painter.drawTab(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_LIGHT, gd.bag_tabIndex, tabItems);
    // 列表
    gd.bag_showNum = (ch - 5 * gap) / cellH; // 可显示技能数量
    int space = ch - 3 * gap - gd.bag_showNum * cellH; // 总的竖向剩余空间
    space = space / (gd.bag_showNum + 1); // 间距
    g.setColor(Const.Color.BLACK);
    g.setFont(Const.Font.FONTSMALL_PLAIN);
    Painter.drawTable(
        g,
        (gd.screenWidth - cellW) / 2 - gap / 2,
        th + 3 * gap,
        cellW,
        cellH,
        gd.bag_showNum,
        space,
        gd.bag_tabIndex == 0 ? gd.items : gd.equips,
        Const.Color.BLACK,
        gd.bag_topIndex,
        gd.bag_curIndex,
        Const.Anchor.HV,
        Painter.NODIALOG,
        Painter.CELL_DEEP);

    /** 介绍 */
    Painter.drawDialog(g, 0, th + ch, gd.screenWidth, ih, Painter.DIALOG_DEEP);
    if (gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length > 0
        && gd.player.bag.get(
                gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
            != null) {
      Painter.drawWordWrapString(
          g,
          gd.player.bag.get(
                  gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                  gd.player
                      .bag
                      .getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
              .intro,
          gap / 2,
          th + ch + gap / 2,
          gd.screenWidth - gap,
          ih - gap,
          Const.Color.WHITE);
    }
    /** 滚动条 */
    Painter.drawScrollbar(
        g,
        Painter.SCROLLBAR_VERTICAL,
        (gd.screenWidth - cellW) / 2 + cellW + gap / 2,
        th + 3 * gap + space,
        th + ch - space,
        gd.bag_topIndex,
        gd.bag_showNum,
        gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length);
  }
コード例 #15
0
  public void paint(Graphics g) {
    g.setFont(inputFont);
    g.setColor(0xffffff);
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(0x000000);

    int x = getCursorX();
    int y = getCursorY();

    translationX = caretLeft - (getWidth() - 5);

    // if(isUp)
    // {
    translationY = y * inputHeight - (getHeight() - 40);
    // }
    // else if(isDown)
    // {
    // 	translationY = y*inputHeight - (getHeight() - 40);
    // }
    // etc

    if (translationX > 0) {
      g.translate(-translationX, 0);
    }

    if (translationY > 0) {
      g.translate(0, -translationY);

      displayLines(g, y - linesOnScreen);
    } else {
      displayLines(g, 0);
    }

    if (caretBlinkOn && goToNextChar) {
      displayCursor(g);
    }

    if (translationX > 0) {
      g.translate(translationX, 0);
    }

    if (translationY > 0) {
      g.translate(0, translationY);
    }

    if (currentState == EditorState.Commands) {
      if (!goToNextChar) {
        displayCharacterMap(g);
      } else {
        displayCurrentCommand(g);
      }
    } else if (currentState == EditorState.Input) {
      if (!goToNextChar) {
        displayCharacterMap(g);
      } else if (isViewStatus) {
        displayStatus(g);
      }
    }

    if (isViewScrollBar) {
      displayScrollBar(g);
    }
  }
コード例 #16
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

  }
コード例 #17
0
ファイル: CheckBox.java プロジェクト: solo123/mm-reader
  public void paint(Graphics g) {
    // g.setClip(0, 0, this.ui.xWForm.getWidth(), this.ui.xWForm.getWidth());
    if (inBox) {
      posX = (ui.xmlForm.frm_Width - width) / 2;
      posY = (ui.xmlForm.frm_Height - height) / 2;
    } else {
      posX = x + ui.offsetX;
      posY = y + ui.offsetY;
      /*
      if(focus){
      	if(height<=ui.xWForm.frm_Height-60)
      		if(posY+height+itemHeight-10>ui.xWForm.frm_Height-30){
      			ui.offsetY=ui.offsetY-(ui.xWForm.frm_Height/2);
      			ui.xWForm.repaint();
      		}
      }*/
      if (title != null) {
        //				System.out.println("title==="+title);
        if (posX + smallHeavryFont.stringWidth(title) > ui.xmlForm.frm_Width) {
          x = 0;
          y = posY + smallHeavryFont.getHeight() + 5;
        }
        posY = y + ui.offsetY + smallHeavryFont.getHeight() + 5;
        posX = x + ui.offsetX + 10;
      }
    }
    if (title != null) {

      g.setColor(0);
      g.setFont(smallHeavryFont);
      g.drawString(title + ":", x + ui.offsetX, y + ui.offsetY, 0);
    }
    //		if (focus) {

    /*if(items.size()==0){
    	height=0;
    }
    if(height!=0)*/
    /*int h=0;
    if(richmode){
    	h=title!=null?height-smallFont.getHeight()+5:0;
    }else{
    	h=height+smallFont.getHeight()-10;
    }*/
    ImageDiv.drawJiuGong(
        g,
        UIManager.select_bright,
        posX - 3,
        posY - 3,
        width + 10,
        title != null ? height - smallFont.getHeight() + 5 : height);

    //
    //		}
    //		g.setColor(bgTricolorR, bgTricolorG, bgTricolorB);
    //			g.setColor(125);
    //		g.fillRect(posX, posY, width, height-(title!=null?smallFont.getHeight()-5:0));
    g.setFont(DisplaySetting.TEXT_FONT);
    if ((onShowSelectedItemNum + 2) * itemHeight > height) {
      offsetY = (onShowSelectedItemNum + 2) * itemHeight - height;
    } else {
      offsetY = 0;
    }
    /*if(focus)
    if (onShowSelectedItemNum + 1 >= 0) {
    	ImageDiv.drawJiuGong(g, UIManager.connect_bg, posX, posY
    			+ (onShowSelectedItemNum + 1) * itemHeight - offsetY,
    			width, itemHeight);
    }*/
    int clipx = g.getClipX();
    int clipy = g.getClipY();
    int clipwidth = g.getClipWidth();
    int clipheight = g.getClipHeight();
    g.setClip(posX, posY, width, height);
    //		g.setColor(Attribute.);
    // g.setFont(font);
    g.setFont(smallFont);
    g.setColor(ColorAttribute.label_context);
    int length = items.size();
    for (int i = 0; i < length; i++) {
      g.setClip(posX, posY, width, height);
      if (i == onShowSelectedItemNum + 1 && focus) {
        g.setColor(0, 220, 247);
        if (posY + (onShowSelectedItemNum + 1) * itemHeight - offsetY
            > ui.xmlForm.frm_Height - 40) {
          ui.offsetY -= 20;
          ui.xmlForm.repaint();
          System.out.println("draw it");
        } else if (posY + (onShowSelectedItemNum + 1) * itemHeight - offsetY < 20) {
          ui.offsetY += 20;
          ui.xmlForm.repaint();
          System.out.println("draw it");
        }
        //				System.out.println("draw it");
      } else {
        g.setColor(0);
      }
      if (items.elementAt(i) != null) {
        g.drawString(
            items.elementAt(i).toString(),
            posX + 5 + (UIManager.select_block.getWidth() >> 2) + 2,
            posY + i * itemHeight - offsetY,
            Graphics.LEFT | Graphics.TOP);
      }
      if (!hasNonItem)
        ImageBuilder.drawSmallImage(
            g,
            UIManager.select_block,
            posX + 5,
            posY + i * itemHeight - offsetY + 2,
            (UIManager.select_block.getWidth() >> 2),
            UIManager.select_block.getHeight(),
            selector.elementAt(i).equals(new Integer(1))
                ? (UIManager.select_block.getWidth() >> 2) * 0
                : (UIManager.select_block.getWidth() >> 2) * 1,
            0);
    }
    if (inBox) {
      g.drawImage(
          UIManager.select_bright,
          posX + width - 1,
          posY + (height * (onShowSelectedItemNum + 1) / length),
          Graphics.RIGHT | Graphics.TOP);
    }
    g.setClip(clipx, clipy, clipwidth, clipheight);
    /*if(posY+ (onShowSelectedItemNum + 1)* itemHeight - offsetY>ui.xWForm.frm_Height-40){
    	ui.offsetY-=20;
    	ui.xWForm.repaint();
    }else if(posY+ (onShowSelectedItemNum + 1)* itemHeight - offsetY<20){
    	ui.offsetY+=20;
    }*/

  }
コード例 #18
0
ファイル: BenchmarkScreen.java プロジェクト: petrch/XCTrack
  protected void paint(Graphics g) {
    int w = getWidth();
    int h = getHeight();
    if (_phase == 0) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 10000; i++) g.drawLine(0, i % 150, 149, 149 - i % 150);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 1) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 10000; i++) g.drawLine(0, i % h, w - 1, h - 1 - i % h);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 2) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 1000; i++) g.fillRect(0, 0, 150, 150);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 3) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 1000; i++) g.fillRect(0, 0, w, h);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 4) {
      Image img = Image.createImage(150, 150);
      img.getGraphics().setColor(0x456789);
      img.getGraphics().setFont(Font.getDefaultFont());
      img.getGraphics().drawString("ahoj", 0, 0, Graphics.LEFT | Graphics.TOP);
      long t = System.currentTimeMillis();
      for (int i = 0; i < 1000; i++) g.drawImage(img, 0, 0, Graphics.LEFT | Graphics.TOP);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 5) {
      long t = System.currentTimeMillis();
      GeneralFont f = GeneralFont.SystemFontsBold[0];
      for (int i = 0; i < 1000; i++) f.drawString(g, "0123", 0, 0, Graphics.TOP | Graphics.LEFT);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 6) {
      long t = System.currentTimeMillis();
      GeneralFont f = GeneralFont.NumberFonts[0];
      for (int i = 0; i < 1000; i++) f.drawString(g, "0123", 0, 0, Graphics.TOP | Graphics.LEFT);
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 7) {
      long t = System.currentTimeMillis();
      double a, b, c;
      for (int i = 0; i < 10000; i++) {
        a = Math.cos(Math.sin(Math.floor(1.1 + i)));
        b = Math.sqrt(a);
        c = (a * b + a * b + a * b) % (1 + b * b);
        _times[_phase] = (long) c;
      }
      _times[_phase++] = System.currentTimeMillis() - t;
    } else if (_phase == 8) {
      long t = System.currentTimeMillis();
      for (int i = 0; i < 10000; i++) {
        //				Earth.atan2(i*0.001, (i+1)*0.001);
        Earth.gg2lat(Earth.lat2gg(50));
      }
      _times[_phase++] = System.currentTimeMillis() - t;
    }

    Font f = Font.getDefaultFont();
    int y = 0;
    g.setColor(0);
    g.fillRect(0, 0, w, h);
    g.setColor(0xffffff);
    g.setFont(f);
    for (int i = 0; i < _phase; i++) {
      g.drawString(_tests[i] + ": " + _times[i] + "ms", 0, y, Graphics.LEFT | Graphics.TOP);
      y += f.getHeight();
    }
    if (_phase < _tests.length) {
      g.drawString("<testing...>", 0, y, Graphics.LEFT | Graphics.TOP);
      new Thread() {
        public void run() {
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {
          }
          repaint();
        }
      }.start();
    } else g.drawString("<done>", 0, y, Graphics.LEFT | Graphics.TOP);
  }
コード例 #19
0
ファイル: DateTimeRow.java プロジェクト: naveen/j2me-hacking
  public void paint(Graphics g) {

    int strHeight = FireScreen.defaultTickerFont.getHeight();

    int xpos = PADLEFT;
    int ypos = PADTOP;
    int selColor = FireScreen.defaultPointerColor;
    if (FireScreen.selectedLinkBgColor != null)
      selColor = FireScreen.selectedLinkBgColor.intValue();

    if (label != null) {
      g.setFont(label.getFont());
      g.setColor(0x00000000);
      Vector lines = label.getFormatedText();
      int rowHeight = label.getRowHeight();

      for (int i = 0; i < lines.size(); ++i) {
        String str = (String) lines.elementAt(i);
        g.drawString(
            str,
            xpos,
            ypos + (i * (rowHeight + FString.LINE_DISTANCE)),
            Graphics.TOP | Graphics.LEFT);
      }

      ypos += label.getHeight() + PADTOP;
    }

    g.setFont(FireScreen.defaultTickerFont);
    // day
    g.setColor(0xFFFFFFFF);
    g.fillRect(xpos, ypos, dayWidth, strHeight);
    if (pointer == DAY) g.setColor(selColor);
    else g.setColor(0x00000000);

    int d = date.get(Calendar.DAY_OF_MONTH) + 1;
    String day;
    if (d < 10) day = "0" + d;
    else day = d + "";
    g.drawString(day, xpos + 1, ypos + 1, Graphics.TOP | Graphics.LEFT);
    g.setColor(0x00000000);
    g.drawRect(xpos, ypos, dayWidth, strHeight);

    xpos += dayWidth + 2;
    g.drawString("/", xpos, ypos + 1, Graphics.TOP | Graphics.LEFT);
    xpos += SPACER;

    // month
    g.setColor(0xFFFFFFFF);
    g.fillRect(xpos, ypos, monthWidth, strHeight);
    if (pointer == MONTH) g.setColor(selColor);
    else g.setColor(0x00000000);
    int m = date.get(Calendar.MONTH) + 1;
    String month;
    if (m < 10) month = "0" + m;
    else month = m + "";
    g.drawString(month, xpos + 1, ypos + 1, Graphics.TOP | Graphics.LEFT);
    g.drawRect(xpos, ypos, monthWidth, strHeight);

    xpos += monthWidth + 2;
    g.drawString("/", xpos, ypos + 1, Graphics.TOP | Graphics.LEFT);
    xpos += SPACER;

    // year
    g.setColor(0xFFFFFFFF);
    g.fillRect(xpos, ypos, yearWidth, strHeight);
    if (pointer == YEAR) g.setColor(selColor);
    else g.setColor(0x00000000);
    g.drawString(date.get(Calendar.YEAR) + "", xpos + 1, ypos + 1, Graphics.TOP | Graphics.LEFT);
    g.drawRect(xpos, ypos, yearWidth, strHeight);

    xpos += yearWidth;

    if (showTime) {
      xpos += SPACER + SPACER;
      int h = 0;
      m = 0;

      try {
        h = date.get(Calendar.HOUR_OF_DAY);
        m = date.get(Calendar.MINUTE);
      } catch (Throwable e) {
        try {
          date.set(Calendar.HOUR_OF_DAY, 0);
          date.set(Calendar.MINUTE, 0);
        } catch (Throwable ee) {
        }
      }

      String hour;
      if (h < 10) hour = "0" + h;
      else hour = h + "";

      // hour
      g.setColor(0xFFFFFFFF);
      g.fillRect(xpos, ypos, hourWidth, strHeight);
      if (pointer == HOUR) g.setColor(selColor);
      else g.setColor(0x00000000);
      g.drawString(hour, xpos + 1, ypos + 1, Graphics.TOP | Graphics.LEFT);
      g.drawRect(xpos, ypos, hourWidth, strHeight);

      xpos += hourWidth + 2;
      g.drawString(":", xpos, ypos + 1, Graphics.TOP | Graphics.LEFT);
      xpos += SPACER;

      String min;
      if (m < 10) min = "0" + m;
      else min = m + "";

      // minute
      g.setColor(0xFFFFFFFF);
      g.fillRect(xpos, ypos, minuteWidth, strHeight);
      if (pointer == MINUTE) g.setColor(selColor);
      else g.setColor(0x00000000);
      g.drawString(min, xpos + 1, ypos + 1, Graphics.TOP | Graphics.LEFT);
      g.drawRect(xpos, ypos, minuteWidth, strHeight);

      xpos += minuteWidth;
    }

    if (isSelected()) {
      if (FireScreen.selectedLinkBgColor != null) {
        g.setColor(FireScreen.selectedLinkBgColor.intValue());
      } else {
        g.setColor(FireScreen.linkColor);
      }
      g.drawRect(PADLEFT, ypos, xpos - PADLEFT, strHeight);
    }
  }
コード例 #20
0
ファイル: LCD.java プロジェクト: 2cool/MobNav1
  public void paint(Graphics g) {

    if (init == false) init(MyCanvas.max_x, MyCanvas.max_y);

    g.setFont(f);
    g.setColor(0xffffff);
    g.fillRect(0, 0, MAX_X, MAX_Y);

    drawSpeed(g, 0, 0, (GGA.fixQuality != 0) ? BTGPS.speed4A() * 3.6 : -1);

    /////// 1
    Time time;
    if (BTGPS.isOn()) {
      time = NMEA.time;
    } else {
      Date date = new Date();
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(date);
      double dtime = 3600 * calendar.get(Calendar.HOUR_OF_DAY);
      dtime += 60 * calendar.get(Calendar.MINUTE);
      dtime += calendar.get(Calendar.SECOND);
      dtime *= 1000;
      time = new Time(dtime);
    }
    drawTime(g, 1, 0, time, true, false);
    // 2
    time = new Time(BTGPS.moving_timeMsec());
    drawTime(g, 0, 1, time, false, true);

    // 3
    time = new Time(BTGPS.stoped_timeMsec());
    drawTime(g, 0, 2, time, false, true);
    // 4
    double odom = BTGPS.getDistance();
    drawDist(g, 0, 3, odom);
    drawSpeed(g, 1, 1, (GGA.fixQuality != 0) ? BTGPS.averageSpeed() * 3.6 : -1);

    g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
    g.setColor(0);
    g.drawString("Speed", 4, 0, 0); // 00
    g.drawString("Time", (MAX_X >> 1) + 4, 0, 0); // 10
    g.drawString("Moving Time", 4, step_y, 0); // 01
    g.drawString("Stoped", 4, step_y + step_y, 0); // 02
    g.drawString("Trip Odom", 4, step_y * 3, 0); // 03
    g.drawString("Moving Avg", (MAX_X >> 1) + 4, step_y, 0); // 03
    g.setColor(0x777777);

    g.fillRect((MAX_X >> 1) - 1, 0, 2, MAX_Y);
    for (int y = step_y - 1; y < MAX_Y - step_y; y += step_y) g.fillRect(0, y - 1, MAX_X, 2);

    //	int x=(MAX_X>>1)+(((MAX_X>>1)-(4*24+6))>>1);
    // g.drawString(time.get(":"),x,y,0);

    // drawTime(g,1,2,BTGPS.moving_time*0.001);//BTGPS.nmea.time.msec()*0.001);

    // drawDigit(g, 0, 24, '8', true);
    // drawDigit(g, 24, 24, '8', false);

    // if (BTGPS.isOn()==false)
    // synchronized(MyCanvas.update){
    //   MyCanvas.update.notify();
    //   }

  }
コード例 #21
0
ファイル: GameMenu.java プロジェクト: zyz913614263/fishman
 public void setFont(int size) {
   Font font = Font.getFont(Font.FACE_SYSTEM, 0, size);
   g.setFont(font);
 }
コード例 #22
0
  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
  }
コード例 #23
0
  public void paintItem(
      AbstractListView view, Graphics g, int offset, Rectangle itemClientArea, Object itemObject) {

    Station station = (Station) itemObject;

    boolean isSelected = view.isItemSelected(offset);
    int listFontSecondSelectedColor =
        view.getTheme()
            .getColor(
                isSelected
                    ? ThemeConstants.WIDGET_LIST_FONT_SECOND_SELECTED
                    : ThemeConstants.WIDGET_LIST_FONT_SECOND)
            .intValue();

    if (isSelected) {
      Color listFontSelectedColor =
          view.getTheme().getColor(ThemeConstants.WIDGET_LIST_FONT_SELECTED);
      g.setColor(listFontSelectedColor.intValue());
    } else {
      Color listFontColor = view.getTheme().getColor(ThemeConstants.WIDGET_LIST_FONT);
      g.setColor(listFontColor.intValue());
    }
    if (!station.open) {
      Color listErrorColor = view.getTheme().getColor(ThemeConstants.WIDGET_LIST_ERROR);
      g.setColor(listErrorColor.intValue());
    }

    int x = itemClientArea.location.x;
    int y = itemClientArea.location.y;

    g.setFont(FontUtil.SMALL_BOLD);

    int addToXPos = BASE_LEFT_POS;
    int addToYPos = PADDING_TOP;
    if (station.number > 0) {
      String stationNumber = String.valueOf(station.number);
      g.drawString(stationNumber, x + addToXPos, y + addToYPos, Graphics.LEFT | Graphics.TOP);
      addToXPos += FontUtil.SMALL_BOLD.stringWidth(stationNumber);
      g.drawString(stationSeparator, x + addToXPos, y + addToYPos, Graphics.LEFT | Graphics.TOP);
      addToXPos += stationSeparatorStrWidthSmallBold;
    }

    String stationName =
        station.name != null ? station.name : view.getMessage("renderer.station.no.name");
    g.drawString(stationName, x + addToXPos, y + addToYPos, Graphics.LEFT | Graphics.TOP);

    addToXPos = BASE_LEFT_POS;
    addToYPos += LINE_SPACING + smallFontHeight;
    if (station.fullAddress.length() > 0) {

      g.setColor(listFontSecondSelectedColor);
      g.setFont(FontUtil.SMALL);
      g.drawString(station.fullAddress, x + addToXPos, y + addToYPos, Graphics.LEFT | Graphics.TOP);

      addToYPos += LINE_SPACING + smallFontHeight;
    }

    if (station.zipCode.length() > 0 || station.city.length() > 0) {
      String secondaryStationInfo =
          (station.zipCode.length() > 0
                  ? (station.zipCode + stationSeparator)
                  : stationSeparatorEmpty)
              + (station.city.length() > 0 ? station.city : "");

      g.setColor(listFontSecondSelectedColor);
      g.setFont(FontUtil.SMALL);
      g.drawString(
          secondaryStationInfo, x + addToXPos, y + addToYPos, Graphics.LEFT | Graphics.TOP);
    }
  }