示例#1
0
  public void drawListRow(ListField list, Graphics g, int index, int y, int w) {

    Font font = g.getFont();
    int xPos = 30;
    int yPos = y + (list.getRowHeight() - imagee1.getHeight()) / 2;
    int yPosTxt = y + (list.getRowHeight() - font.getHeight()) / 2;

    if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
      g.setBackgroundColor(0x005A6971);
      // g.setBackgroundColor(0x005A6971);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
      g.clear();
    } else {
      g.setColor(Color.WHITE);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
    }

    for (int i = 0; i < bit.length; i++) {
      image = bit[index];
      g.drawBitmap(5, yPos + 3, image.getWidth(), image.getHeight(), image, 0, 0);
    }

    g.setFont(Constants.fontBold);
    xPos = xPos + image.getWidth();
    String text = (String) listElements.elementAt(index);
    g.drawText(text, xPos, yPosTxt);
    g.setFont(Constants.fontVerySmall);

    //		for (int i = 0; i < bit.length; i++) {
    //			xPos = 30 + image.getWidth();
    //			String textSubText = Constants.selectedBranch;
    //			g.drawText(textSubText, xPos, yPosTxt + 25);
    //		}

    xPos = 30 + image.getWidth();

    switch (index) {
      case 0:
        String textSubText = Constants.selectedBranch;
        g.drawText(textSubText, xPos, yPosTxt + 25);
        break;

      case 1:
        String textProcessText = Constants.selectedProcess;
        g.drawText(textProcessText, xPos, yPosTxt + 25);
        break;

      case 2:
        String textLocationText = Constants.selectedLocation;
        g.drawText(textLocationText, xPos, yPosTxt + 25);
        break;
    }

    g.drawBitmap(580, yPos + 3, arrowImage.getWidth(), arrowImage.getHeight(), arrowImage, 0, 0);
  }
  private void drawDummyPhoto(Graphics graphics) {
    graphics.setColor(0xcccccc);
    int w = TEXT_ANCHOR - 2 * PADDING_TOP;
    graphics.fillRoundRect(PADDING_LEFT, PADDING_TOP, w, w, 10, 10);

    graphics.setFont(Utils.getFont(5));
    graphics.setColor(0x999999);
    graphics.drawText(
        "NO PHOTO",
        (TEXT_ANCHOR - graphics.getFont().getAdvance("NO PHOTO")) / 2,
        (TEXT_ANCHOR - graphics.getFont().getHeight()) / 2);
  }
示例#3
0
 protected void paint(Graphics g) {
   g.setFont(fontSetting.getFont());
   boolean focus = g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS);
   int textColor = Color.BLACK;
   if (focus) {
     g.setColor(Color.GREEN);
     g.fillRect(0, 0, 5, getHeight());
   }
   if (locked) {
     textColor = Color.GRAY;
     g.drawBitmap(
         getWidth() - 5 - lock.getWidth(),
         (getHeight() - lock.getHeight()) / 2,
         lock.getWidth(),
         lock.getHeight(),
         lock,
         0,
         0);
   } else {
     if (focus) {
       g.drawBitmap(
           getWidth() - 5 - focusArrow.getWidth(),
           (getHeight() - focusArrow.getHeight()) / 2,
           focusArrow.getWidth(),
           focusArrow.getHeight(),
           focusArrow,
           0,
           0);
     } else {
       g.drawBitmap(
           getWidth() - 5 - normalArrow.getWidth(),
           (getHeight() - normalArrow.getHeight()) / 2,
           normalArrow.getWidth(),
           normalArrow.getHeight(),
           normalArrow,
           0,
           0);
     }
   }
   g.drawBitmap(
       25,
       (getHeight() - image.getHeight()) / 2,
       image.getWidth(),
       image.getHeight(),
       image,
       0,
       0);
   g.setColor(textColor);
   g.drawText(title, 5 + 20 + image.getWidth() + 20, (getHeight() - g.getFont().getHeight()) / 2);
 }
  protected void paint(Graphics gfx) {
    // Logger.debug(this, "paint: entered for '" + label + '\'');

    final int fontHeight = gfx.getFont().getHeight();

    if (label != null) {
      drawLabel(gfx, fontHeight);
    }

    if (imgUrl != null) {

      if (imageBmp != null) {
        drawBitmap(gfx);

      } else {

        if (errorLoadingImage) {
          drawError(gfx, fontHeight);

        } else {
          if (!isLoadingImage) {
            desiredImgHeight = h - labelToImageGap - labelHeight - totalPaddingY;
            desiredImgWidth = w - totalPaddingX;
            isLoadingImage = true;

            BitmapLoader.requestLoading(bitmapLoading);
          }

          if (isLoadingImage) {
            drawLoading(gfx, fontHeight);
          }
        }
      }
    }

    if (drawBtnStyle) {
      drawBtnStyle(gfx);
    }
    // Logger.debug(this, "paint: passed");
  }
示例#5
0
  public void drawListRow(ListField list, Graphics g, int index, int y, int w) {

    Font font = g.getFont();
    int xPos = 30;
    //		int yPos = y + (list.getRowHeight() - bit[1].getHeight()) / 2;
    int yPos = y + (list.getRowHeight() - imagee2.getHeight()) / 2;
    int yPosTxt = y + (list.getRowHeight() - font.getHeight()) / 2;

    // Bitmap imageBackground = Bitmap
    // .getBitmapResource("button_for_thumbnails_inactive.png");
    // if (list.getSelectedIndex() != index) {
    // g.drawBitmap(0, 0, 640, 80, imageBackground, 0, 0);
    // }

    if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
      g.setBackgroundColor(0x005A6971);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
      g.clear();
    } else {
      g.setColor(Color.WHITE);
      // g.drawRoundRect(0, 0, 630, 80, 15, 15);
    }

    //		for (int i = 0; i < bit.length; i++) {
    //			image = bit[index];
    //			g.drawBitmap(5, yPos + 3, image.getWidth(), image.getHeight(),
    //					image, 0, 0);
    //		}

    g.drawBitmap(5, yPos + 3, imagee2.getWidth(), imagee2.getHeight(), imagee2, 0, 0);

    xPos = xPos + imagee2.getWidth();
    String text = (String) listElements.elementAt(index);
    g.drawText(text, xPos, yPosTxt + 3);

    g.drawBitmap(580, yPos + 7, arrowImage.getWidth(), arrowImage.getHeight(), arrowImage, 0, 0);
  }
  protected void paint(Graphics g) {
    int oldColor = g.getColor();
    Font oldFont = g.getFont();
    try {
      // Left Bitmap
      if (this.leftIcon != null) {
        g.drawBitmap(
            ListStyleField.HPADDING,
            ListStyleField.VPADDING,
            this.leftIcon.getWidth(),
            this.leftIcon.getHeight(),
            this.leftIcon,
            0,
            0);
      }

      // Animated Bitmap
      if (this.animate == true && this.progressBitmap != null) {
        g.drawBitmap(
            getWidth() - (this.frameWidth + ListStyleField.HPADDING),
            (getHeight() - this.actionIcon.getHeight()) / 2,
            this.frameWidth,
            this.progressBitmap.getHeight(),
            this.progressBitmap,
            this.frameWidth * this.currentFrame,
            0);
        this.currentFrame++;
        if (this.currentFrame >= this.numFrames) {
          this.currentFrame = 0;
        }
      }

      // Right (Action) Bitmap
      else if (this.actionIcon != null) {
        g.drawBitmap(
            getWidth() - (this.actionIcon.getWidth() + ListStyleField.HPADDING),
            (getHeight() - this.actionIcon.getHeight()) / 2,
            this.actionIcon.getWidth(),
            this.actionIcon.getHeight(),
            this.actionIcon,
            0,
            0);
      }

      int labelWidth = this.labelWidth;
      labelHeight = this.lableFont.getHeight();

      if (this.badgeIcon != null) {
        labelWidth -= this.badgeIcon.getWidth();
      }

      // Left Label Text
      int leftPos = this.labelLeft;
      g.setColor(this.fontColor);
      g.setFont(this.lableFont);

      if (labelWidth < this.lableFont.getAdvance(this.labelText)
          && g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
        int currentChar = textOffsetScalar.getInt();
        String currentText = this.labelText;
        if (currentChar < currentText.length()) {
          currentText = currentText.substring(currentChar);
        }

        if (this.lableFont.getAdvance(this.labelText) < labelWidth) {
          this.textAnimation.end(0);
        }

        g.drawText(currentText, leftPos, this.labelTop, DrawStyle.ELLIPSIS, labelWidth);
      } else {
        g.drawText(this.labelText, leftPos, this.labelTop, DrawStyle.ELLIPSIS, labelWidth);
      }
      leftPos += labelWidth;

      // Badge icon (to the left of Action bitmap)
      if (this.badgeIcon != null) {
        g.drawBitmap(
            leftPos,
            (getHeight() - this.badgeIcon.getHeight()) / 2,
            this.badgeIcon.getWidth(),
            this.badgeIcon.getHeight(),
            this.badgeIcon,
            0,
            0);
      }
    } finally {
      g.setColor(oldColor);
      g.setFont(oldFont);
    }
  }
  protected void paint(Graphics g) {
    g.setColor(TITLE_COLOR);
    Font titleFont = Utils.getFontBold(FONT_SIZE);
    g.setFont(titleFont);

    int textWidht = Display.getWidth() - TEXT_ANCHOR - PADDING_RIGHT;

    if (title == null) {
      title = TextUtils.wrapText(newsItem.getTitle(), textWidht, titleFont);
    }
    int yOff = 0;
    for (int i = 0; i < title.size(); i++) {
      if (title.size() > 2 && i == 1) {
        g.drawText(
            title.elementAt(i).toString() + "...",
            TEXT_ANCHOR,
            PADDING_TOP + i * titleFont.getHeight());
        yOff += g.getFont().getHeight();
        break;
      } else {
        g.drawText(
            title.elementAt(i).toString(), TEXT_ANCHOR, PADDING_TOP + i * titleFont.getHeight());
        yOff += g.getFont().getHeight();
      }
    }

    Font textFont = Utils.getFont(FONT_SIZE);
    g.setColor(PRETEXT_COLOR);
    g.setFont(textFont);

    if (text == null) {
      text = TextUtils.wrapText(newsItem.getBody(), textWidht, textFont);
    }

    int titleHeight = PADDING_TOP + title.size() * titleFont.getHeight();
    int contentHeight = getPreferredHeight() - (PADDING_TOP);

    for (int i = 0; i < text.size(); i++) {
      if (yOff + g.getFont().getHeight() >= getPreferredHeight() - 2 * PADDING_TOP) {
        g.drawText(
            (String) text.elementAt(i) + "...",
            TEXT_ANCHOR,
            titleHeight + i * textFont.getHeight());
      } else {
        g.drawText((String) text.elementAt(i), TEXT_ANCHOR, titleHeight + i * textFont.getHeight());
      }

      yOff += g.getFont().getHeight();
      if (yOff >= getPreferredHeight() - 2 * PADDING_TOP) {
        break;
      }
    }

    if (newsImage != null) {
      try {
        g.drawBitmap(
            PADDING_LEFT,
            PADDING_TOP,
            newsImage.getWidth(),
            newsImage.getHeight(),
            newsImage,
            0,
            0);
      } catch (Exception e) {
        drawDummyPhoto(g);
      }
    } else {
      drawDummyPhoto(g);
    }
  }