コード例 #1
0
ファイル: HomeList.java プロジェクト: RadhikaRR/LocNat
  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);
  }
  public void drawListRow(ListField listField, Graphics graphics, int index, int y, int width) {
    Object[] childImagePair = (Object[]) this.get(listField, index);
    Child child = (Child) childImagePair[0];
    Bitmap image = (Bitmap) childImagePair[1];

    drawStatusBox(listField, graphics, index, child);

    drawChildImage(graphics, listField, index, image);

    graphics.setColor(Color.BLACK);

    graphics.setFont(titleFont);

    // Takes 5 params 1:display text, 2:horizontal position,
    // 3: vertical position, 4: flags, 5: text display width
    graphics.drawText(
        (String) child.getField("name"),
        firstRowPosition,
        y,
        (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP),
        screenWidth - firstRowPosition - 4);

    int yStartForText = y + (this.getFont()).getHeight() + 1;
    drawFieldRow(graphics, width, child, yStartForText, "age");

    yStartForText = yStartForText + (this.getFont()).getHeight() + 1;
    drawFieldRow(
        graphics, width - secondRowPosition - 4, child, yStartForText, "last_known_location");

    yStartForText = yStartForText + (this.getFont()).getHeight() + 1;
    graphics.drawLine(
        0, (index * listField.getRowHeight()), width, (index * listField.getRowHeight()));
  }
 private void drawFieldRow(
     Graphics graphics, int width, Child child, int yStartForText, String field) {
   graphics.setFont(rowFont);
   graphics.drawText(
       (String) child.getField(field),
       secondRowPosition,
       yStartForText,
       (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP),
       width);
 }
コード例 #4
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);
  }
コード例 #5
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);
 }
コード例 #6
0
  /**
   * Field implementation.
   *
   * @see net.rim.device.api.ui.Field#paint(Graphics)
   */
  protected void paint(Graphics graphics) {
    // First draw the background colour and picture

    switch (Display.getWidth()) {
      case 480:
        graphics.drawBitmap(12, 10, dbmp.getWidth(), dbmp.getHeight(), dbmp, 0, 0);
        graphics.drawBitmap(167, 10, ibmp.getWidth(), ibmp.getHeight(), ibmp, 0, 0);
        graphics.drawBitmap(324, 10, tbmp.getWidth(), tbmp.getHeight(), tbmp, 0, 0);
        graphics.setFont(font);
        graphics.setColor(Color.DARKSLATEGRAY);
        graphics.drawText(_dboc, 18, 40);
        graphics.drawText(_iboc, 173, 40);
        graphics.drawText(_tboc, 330, 40);
        break;
      case 360:
        graphics.drawBitmap(15, 10, dbmp.getWidth(), dbmp.getHeight(), dbmp, 0, 0);
        graphics.drawBitmap(185, 10, ibmp.getWidth(), ibmp.getHeight(), ibmp, 0, 0);
        graphics.setFont(font);
        graphics.setColor(Color.DARKSLATEGRAY);
        graphics.drawText(_dboc, 28, 40);
        graphics.drawText(_iboc, 198, 40);
        graphics.drawBitmap(15, 65, tbmp.getWidth(), tbmp.getHeight(), tbmp, 0, 0);
        graphics.drawText(_tboc, 130, 95);
        break;
      default:
        graphics.drawBitmap(15, 9, dbmp.getWidth(), dbmp.getHeight(), dbmp, 0, 0);
        graphics.drawBitmap(166, 10, ibmp.getWidth(), ibmp.getHeight(), ibmp, 0, 0);
        graphics.setFont(font);
        graphics.setColor(Color.DARKSLATEGRAY);
        graphics.drawText(_dboc, 18, 40);
        graphics.drawText(_iboc, 172, 40);
        graphics.drawBitmap(15, 65, tbmp.getWidth(), tbmp.getHeight(), tbmp, 0, 0);
        graphics.drawText(_tboc, 110, 95);
        break;
    }
  }
コード例 #7
0
  protected void paint(Graphics graphics) {
    //     super.paint(graphics);
    // draw and underscore
    graphics.setColor(net.rim.device.api.ui.Color.LIGHTGREY);
    graphics.setFont(Font.getDefault());

    //   graphics.drawRect(this.getFont().getAdvance(getLabel())  , 0, getWidth(), getHeight());
    graphics.drawRoundRect(
        this.getFont().getAdvance(getLabel()) + 3, 0, getWidth(), getHeight(), 5, 5);
    graphics.setColor(net.rim.device.api.ui.Color.DARKGRAY);
    graphics.drawRoundRect(
        this.getFont().getAdvance(getLabel()) + 4, 1, getWidth() - 2, getHeight() - 2, 5, 5);
    graphics.setColor(net.rim.device.api.ui.Color.BLACK);
    graphics.drawRoundRect(
        this.getFont().getAdvance(getLabel()) + 4, 1, getWidth() - 3, getHeight() - 3, 5, 5);
    String text = getText();
    String label = getLabel();
    if (label != null) {
      if (label.length() > 0) {
        graphics.drawText(label, 2, 2);
      }
      graphics.drawText(text, this.getFont().getAdvance(label) + 6, 2);
    } else {
      graphics.drawText(text, 6, 2);
    }

    if (hasFocus) {
      int x = Font.getDefault().getAdvance(getLabel()) + this.getFont().getAdvance(getText()) + 4;
      int y = Font.getDefault().getLeading();
      Font font = Font.getDefault().derive(Font.BOLD);
      graphics.setFont(font);
      graphics.drawText("|", x, y);
    }
    //   drawHighlightRegion(graphics,this.HIGHLIGHT_SELECT,true,2, 2, 2,5);

  }
コード例 #8
0
ファイル: ProfileDetails.java プロジェクト: rubics/jpt12341
 protected void paint(Graphics graphics) {
   graphics.setFont(font);
   for (int i = 0; i < labels.length; i++) {
     graphics.setColor(0xF57000);
     graphics.drawText(labels[i], h_offset, font.getHeight() * i);
     graphics.setColor(Color.GRAY);
     graphics.drawText(
         "\t" + values[i], font.getAdvance(labels[i]), font.getHeight() * i, DrawStyle.ELLIPSIS);
   }
   for (int i = 0; i < lines.size(); i++) {
     graphics.drawText(
         (String) lines.elementAt(i),
         h_offset,
         label_height + i * font.getHeight() + 5,
         DrawStyle.HCENTER | DrawStyle.ELLIPSIS);
   }
 }
  private void drawStatusBox(ListField listField, Graphics graphics, int index, Child child) {

    String childStatusString = child.childStatus().getStatusString();
    int boxHeight = getFont().getHeight() + 4;
    int boxWidth = getFont().getAdvance(childStatusString) + 4;
    int boxX = screenWidth - 10 - boxWidth;
    int boxY = ((index) * listField.getRowHeight()) + getFont().getHeight() + 2;

    graphics.setColor(child.childStatus().getStatusColor());
    graphics.drawRoundRect(boxX, boxY, boxWidth, boxHeight, 10, 10);
    graphics.fillRoundRect(boxX, boxY, boxWidth, boxHeight, 10, 10);

    graphics.setColor(16777215);
    graphics.setFont(rowFont);
    graphics.drawText(
        childStatusString,
        boxX,
        boxY + 2,
        (DrawStyle.HCENTER | DrawStyle.ELLIPSIS | DrawStyle.TOP),
        boxWidth);
  }
コード例 #10
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);
    }
  }
コード例 #11
0
  public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
    if (isMoreButton(index)) {
      Font bold = Font.getDefault().derive(Font.BOLD);
      g.setFont(bold);
      String strMore = "More";
      int xx = (width - bold.getAdvance(strMore)) / 2;
      int yy = y + (ScheduleScreen.LIST_HEIGHT - bold.getHeight()) / 2;
      if (listField.getSelectedIndex() == index) {
        g.setColor(0);
        g.drawText(strMore, xx + 1, yy + 1);
        g.setColor(0xffffff);
        g.drawText(strMore, xx, yy);
      } else {
        g.setColor(0);
        g.drawText(strMore, xx, yy);
      }
      return;
    }
    ProgramData data = (ProgramData) listData.elementAt(index);
    //		if(!listField.isFocus() || index!=listField.getSelectedIndex()){
    //			for(int x=0; x<Display.getWidth(); x+= ScheduleScreen.LIST_BACKGROUND.getWidth())
    //				g.drawBitmap(x, y, ScheduleScreen.LIST_BACKGROUND.getWidth(),
    // ScheduleScreen.LIST_BACKGROUND.getHeight(), ScheduleScreen.LIST_BACKGROUND, 0, 0);
    //		}
    if (!listField.isFocus() || index != listField.getSelectedIndex()) {
      for (int x = 0; x < Display.getWidth(); x += ScheduleScreen.LIST_BACKGROUND.getWidth())
        g.drawBitmap(
            x,
            y,
            ScheduleScreen.LIST_BACKGROUND.getWidth(),
            ScheduleScreen.LIST_BACKGROUND.getHeight(),
            ScheduleScreen.LIST_BACKGROUND,
            0,
            0);
    }
    Bitmap thumb = TVApi.getChannelThumbnail(data.channelId);
    if (thumb != null) {
      int padding = (ScheduleScreen.LIST_HEIGHT - thumb.getHeight()) / 2;
      int ty = y + padding;
      int tx = padding;
      g.drawBitmap(tx, ty, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
      g.setColor(0);
      g.drawText(data.beginTime + " - " + data.endTime, tx + thumb.getWidth() + tx, ty);
      Bitmap favorite =
          data.isFavorite ? ScheduleScreen.LIST_FAVORITE_ON : ScheduleScreen.LIST_FAVORITE_OFF;
      int titleMaxWidth = width - thumb.getWidth() - favorite.getWidth() - (padding * 4);
      g.drawText(
          data.title,
          tx + thumb.getWidth() + tx,
          ty + thumb.getHeight(),
          DrawStyle.BASELINE | DrawStyle.ELLIPSIS,
          titleMaxWidth);

      g.drawBitmap(
          width - padding - favorite.getWidth(),
          y + (ScheduleScreen.LIST_HEIGHT - favorite.getHeight()) / 2,
          favorite.getWidth(),
          favorite.getHeight(),
          favorite,
          0,
          0);
    }
  }
コード例 #12
0
  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);
    }
  }