예제 #1
0
 public Font GetFont(String opt1, String opt2, Font previous) {
   Font newfont = previous;
   int actual = -1;
   int pstyle = previous.getStyle();
   int psize = previous.getHeight();
   FontFamily fontFamily[] = FontFamily.getFontFamilies();
   for (int x = 0; x < fontFamily.length; x++) {
     if (fontFamily[x].getName().equalsIgnoreCase(opt1)) {
       actual = x;
       break;
     }
   }
   if (actual == -1) {
     for (int x = 0; x < fontFamily.length; x++) {
       if (fontFamily[x].getName().equalsIgnoreCase(opt2)) {
         actual = x;
         break;
       }
     }
   }
   if (actual == -1) {
     newfont = Font.getDefault().derive(pstyle, psize);
   } else {
     newfont = fontFamily[actual].getFont(pstyle, psize);
   }
   return newfont;
 }
예제 #2
0
 /**
  * Check the text and returns the position up to which we can draw in that given width
  *
  * @param text
  * @param halfWidth
  * @return
  */
 private int getIndexEnoughToFitIn(String text, int width) {
   Font font = Font.getDefault();
   int index = text.length();
   while (font.getAdvance(text.substring(0, index)) >= width) {
     index--;
   }
   return index;
 }
  public ChildrenListField() {
    super();
    Font defaultFont = Font.getDefault();
    titleFont = defaultFont.derive(Font.PLAIN, 3, Ui.UNITS_mm);
    rowFont = defaultFont.derive(Font.PLAIN, 3, Ui.UNITS_mm);

    screenWidth = Display.getWidth();
    firstRowPosition = (screenWidth) - (screenWidth - 4 - ((titleFont.getHeight() * 4) - 4));
    secondRowPosition = firstRowPosition + 20;
  }
  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);

  }
예제 #5
0
  /**
   * For calculating the Height of the field based on no.of cells and their text length
   *
   * @return
   */
  private int calculateHeight() {
    Font font = Font.getDefault();
    int height = 0;
    int width = total_Width;
    int halfWidth = (width / 2) - RIGHT_MARGIN;
    boolean hasMultipleCells = false;
    if (record.getCells().size() > 1) {
      hasMultipleCells = true;
      MULTIPLE_CELLS = 10;
    }
    for (int i = 0; i < record.getCells().size(); i++) {
      Cell cell = (Cell) record.getCells().elementAt(i);
      String title = cell.getTitle().trim();
      String value = cell.getValue().trim();

      if (value == null || value.trim().length() == 0) {

        boolean titleFitsInHalfWidth = font.getAdvance(title) <= total_Width - RIGHT_MARGIN;
        // for checking if value did not contain any value
        if (titleFitsInHalfWidth) {
          height += CELL_HEIGHT - MULTIPLE_CELLS;
        } else {
          // We need height for two rows
          height += CELL_HEIGHT - MULTIPLE_CELLS;
          height += SECOND_CELL_HEIGHT;
          // We will ignore anything that does not fit in two rows...
        }

      } else {
        // for checking for both title and value
        // Check if title fits in half width

        boolean titleFitsInHalfWidth = font.getAdvance(title) <= halfWidth;
        boolean valueFitsInHalfWidth = font.getAdvance(value) <= halfWidth;
        if (titleFitsInHalfWidth && valueFitsInHalfWidth) {
          height += CELL_HEIGHT - MULTIPLE_CELLS;
        } else {
          // We need height for two rows
          height += CELL_HEIGHT - MULTIPLE_CELLS;
          height += SECOND_CELL_HEIGHT;
          // We will ignore anything that does not fit in two rows...
        }
      }
    }
    return height;
  }
  /** @see net.rim.device.api.openvg.VGField#initialize(VG) */
  protected void initialize(final VG g) {
    final VG11 vg = (VG11) g;
    vg.vgSetfv(VG10.VG_CLEAR_COLOR, 4, MY_CLEAR_COLOR, 0);

    final XYRect rect = new XYRect();

    // Create the bitmap from bundled resource "icons.png"
    final Bitmap bitmap = Bitmap.getBitmapResource("icons.png");

    // Create the image for all the icons
    for (int i = 0; i < _imageHandles.length; i++) {
      // Update the XYRect in which the image will be displayed
      updateRect(rect, i);

      _imageHandles[i] =
          VGUtils.vgCreateImage(vg, bitmap, true, VG10.VG_IMAGE_QUALITY_BETTER, rect);
    }

    // Get the default font and its FontSpec
    final Font font = Font.getDefault();
    final FontSpec fontSpec = font.getFontSpec();

    // Create text image
    _textImage =
        VGUtils.vgCreateTextAsImage(vg, fontSpec, "Tap or click to swap screens", null, null);

    // Set up the animation. The animation will animate a scalar float value
    // (_mainRotation) from 360 to 0 over 3 seconds and will repeat
    // indefinitely.
    _animator = new Animator(0);
    final Animation animation =
        _animator.addAnimationFromTo(
            _mainRotation,
            AnimatedScalar.ANIMATION_PROPERTY_SCALAR,
            360.0f,
            0.0f,
            Animation.EASINGCURVE_LINEAR,
            3000L);
    animation.setRepeatCount(Animation.REPEAT_COUNT_INDEFINITE);

    _animator.begin(0L);
  }
예제 #7
0
public class Constants {

  public Constants() {}

  public static String DATELABELVALUE =
      new SimpleDateFormat("dd-MMM-yyyy").formatLocal(System.currentTimeMillis());

  public static Font font = Font.getDefault().derive(Font.PLAIN, 6, Ui.UNITS_pt);
  public static Font fontVerySmall = Font.getDefault().derive(Font.PLAIN, 5, Ui.UNITS_pt);
  public static Font fontBold = Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt);
  public static Font fontBold6 = Font.getDefault().derive(Font.BOLD, 6, Ui.UNITS_pt);
  public static Font fontBold5 = Font.getDefault().derive(Font.BOLD, 5, Ui.UNITS_pt);

  public static int hbgColor = 0x000072BC;

  public static final long Jiyo_Befikar_ID = 0xecbd43db0a2424cfL;
  public static ApplicationIcon mIcon;

  public static final String IMEI = ImeiClass.INSTANCE.getIMEINumber();

  public static final String AUTHENTICATIONURL = "http://web7.bajajallianz.com/BagicWap/BagicWap";
  public static final String AUTHENTICATIONSOAPACTION = "BagicWapPortType";
  public static final String AUTHENTICATIONMETHOD = "validateCustomerPortal";
  public static final String AUTHENTICATIONNAMESPACE = "http://com.bajajallianz/BagicWap.xsd";

  public static final String AUTHENTICATIONParamUserName = "******";
  public static final String AUTHENTICATIONParamPassword = "******";
  public static final String AUTHENTICATIONParamIMEI = "pImeiNo";

  public static final String FundValueMETHOD = "customerPortalFundVal";
  public static final String FundValuePolicyNo = "pPolicyNo";
  public static final String FundValueIMEI = "pImeiNo";

  public static final String navMETHOD = "customerPortalNav";
  public static final String navPolicyNo = "pPolicyNo";
  public static final String navIMEI = "pImeiNo";

  public static final String FundAccDetailsMETHOD = "customerPortalFundAccDtls";
  public static final String FundAccDetailsPolicyNo = "pPolicyNo";
  public static final String FundAccDetailsIMEI = "pImeiNo";

  public static final String PolicyStatusMETHOD = "customerPortalPolStatus";
  public static final String PolicyStatusPolicyNo = "pPolicyNo";
  public static final String PolicyStatusIMEI = "pImeiNo";

  public static final String PolicyInformationMETHOD = "customerPortalPolInfo";
  public static final String PolicyInformationPolicyNo = "pPolicyNo";
  public static final String PolicyInformationIMEI = "pImeiNo";

  public static final String PremiumCalenderMETHOD = "customerPortalPremCal";
  public static final String PremiumCalenderPolicyNo = "pPolicyNo";
  public static final String PremiumCalenderIMEI = "pImeiNo";

  public static final long GUID = 0x2051fd67b72d11L;

  public static final String APP_NAME = "BajajAllianz";

  public static boolean connectTCP = true;
  public static boolean connectBIS = false;

  public static String[] policyArray;

  public static String firstTimeLogin = "******";

  public static String UserName = "";
  public static String RegisteredPolicyNo = "";
  public static String RegisteredPoliciyWSnumber = "";

  public static String persistID = "id";
  public static String persistPASSWORD = "******";

  public static final String newAppDownloadAppendURL = "/CustomerApp/BlackBerry/JiyoBefikar.jad";

  public static String persistFlag = "";

  public static int width = 0;

  public static final String SMSFLAG = "smsflag";

  public static final String AGREEFLAG = "agreeflag";
}
예제 #8
0
public class ProfileDetails extends Field {

  private final int width = Display.getWidth();
  private int height;
  private int label_height;
  private static final int h_offset = 5;
  private static final int v_correction = 20;

  String name;
  String status;
  String location;
  String designation;
  String airlines;
  String aboutMe;
  private Vector lines;

  String[] labels = {"Name", "Status", "Location", "Designation", "Airlines", "About Me"};
  String[] values = {"Kristine Jacob", "Online", "Dubai, UAE", "Cabin Crew", "Emirates", ""};
  String descp =
      "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium,";
  private static final Font font = Font.getDefault().derive(Font.PLAIN, 20, Ui.UNITS_px);

  public ProfileDetails() {
    super();
    setFont(font);
    lines = wrap(descp, width);
    label_height = labels.length * font.getHeight();
    height = label_height + lines.size() * font.getHeight() + v_correction;
  }

  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);
    }
  }

  protected void layout(int _width, int _height) {
    setExtent(width, height);
  }

  private Vector wrap(String text, int width) {
    Vector result = new Vector();
    if (text == null) return result;

    boolean hasMore = true;

    // The current index of the cursor
    int current = 0;

    // The next line break index
    int lineBreak = -1;

    // The space after line break
    int nextSpace = -1;

    while (hasMore) {
      // Find the line break
      while (true) {
        lineBreak = nextSpace;
        if (lineBreak == text.length() - 1) {
          // We have reached the last line
          hasMore = false;
          break;
        } else {
          nextSpace = text.indexOf(' ', lineBreak + 1);
          if (nextSpace == -1) nextSpace = text.length() - 1;
          int linewidth = font.getAdvance(text, current, nextSpace - current);
          // If too long, break out of the find loop
          if (linewidth > width) break;
        }
      }
      String line = text.substring(current, lineBreak + 1);
      result.addElement(line);
      current = lineBreak + 1;
    }
    return result;
  }
}
예제 #9
0
  public SearchView(HomeScreen homeScreen) {
    this.homeScreen = homeScreen;
    manager =
        new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL) {
          public boolean keyChar(char c, int status, int time) {
            if (!searchField.isFocus()) {
              String oldText = searchField.getText();
              searchField.setFocus();
              String newText = c == Keypad.KEY_DELETE ? oldText : oldText + c;
              searchField.setText(newText.trim());
              return true;
            } else if (c == Keypad.KEY_ESCAPE) {
              if (searchField.getText().length() > 0) {
                searchField.setText("");
                return true;
              }
            }
            return super.keyChar(c, status, time);
          }
        };
    searchField =
        new BasicEditField(Field.USE_ALL_WIDTH) {
          public boolean navigationClick(int status, int time) {
            if (getText().trim().length() > 0) {
              SearchView.this.homeScreen.fireActionSearch();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public boolean keyChar(char c, int status, int time) {
            if (c == Keypad.KEY_ENTER) {
              if (getText().trim().length() > 0) {
                SearchView.this.homeScreen.fireActionSearch();
                return true;
              }
            } else if (getText().length() == 0 && c == Keypad.KEY_SPACE) {
              return true;
            }
            return super.keyChar(c, status, time);
          }

          public void paint(Graphics g) {
            if (getText().length() == 0) {
              g.setColor(0xbbbbbb);
              g.drawText(" Search", 0, 0);
            } else {
              g.setColor(0);
              super.paint(g);
            }
          }
        };

    // int defaultFontHeight = Font.getDefault().getHeight();
    // searchField.setFont(Font.getDefault().derive(Font.PLAIN, defaultFontHeight+8));
    Border border = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4));
    searchField.setBorder(border);
    searchField.setBackground(BackgroundFactory.createSolidBackground(0xffffff));
    manager.add(searchField);
    manager.add(new SeparatorField());

    // manager.setBackground(HomeScreen.mainBackground);
    listField =
        new ListField(0, Manager.USE_ALL_HEIGHT) {
          public boolean navigationClick(int status, int time) {
            if (SearchView.this.listData.size() > 0) {
              int index = getSelectedIndex();
              if (isMoreButton(index)) {
                increaseListFieldSize();
                invalidate();
                return true;
              }
              ProgramData data = (ProgramData) SearchView.this.listData.elementAt(index);
              data.isFavorite = !data.isFavorite;
              if (data.isFavorite) {
                FavoritePersistent.addFavorite(data.id);
                PIMEvent.addEvent(data);
              } else {
                FavoritePersistent.removeFavorite(data.id);
                PIMEvent.removeEvent(data);
              }
              invalidate();
              return true;
            }
            return super.navigationClick(status, time);
          }

          public void paint(Graphics g) {
            int ty = getContentTop() + getContentHeight() / 2 - g.getFont().getHeight() / 2;
            if (ThaiTVSchedule.isFetching()) {
              ThaiTVSchedule.paintFetching(g, ty);
            } else if (this.getSize() < 1) {
              g.setColor(0);
              int x = (getWidth() - g.getFont().getAdvance("No data")) / 2;
              g.drawText("No data", x, ty);
            } else {
              super.paint(g);
            }
          }

          public boolean isFocusable() {
            return !ThaiTVSchedule.isFetching();
          }
        };
    // listField.setBackground(HomeScreen.mainBackground);
    listField.setRowHeight(ScheduleScreen.LIST_HEIGHT);
    listField.setCallback(this);
    listData = new Vector();
    listField.setSize(0);
    listField.setFont(Font.getDefault().derive(Font.PLAIN, 20));
    VerticalFieldManager _vfm =
        new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    _vfm.add(listField);
    manager.add(_vfm);

    // autoFocus();
  }
예제 #10
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);
    }
  }