public int getPreferredHeight() {
   switch (Display.getWidth()) {
     case 480:
       _height = 60;
       break;
     case 360:
       _height = 120;
       break;
     default:
       _height = 120;
       break;
   }
   return _height;
 }
 /**
  * Field implementation.
  *
  * @see net.rim.device.api.ui.Field#layout(int, int)
  */
 protected void layout(int width, int height) {
   int wid = Display.getWidth();
   switch (wid) {
     case 480:
       _height = 70;
       break;
     case 360:
       _height = 120;
       break;
     default:
       _height = 120;
       break;
   }
   setExtent(wid, _height);
 }
示例#3
0
    public GameThread(SurfaceHolder surfaceHolder, Context context, Handler handler) {
      mGameSurfaceHolder = surfaceHolder;
      mGameContext = context;

      Resources res = context.getResources();

      mBackgroundImage = BitmapFactory.decodeResource(res, R.drawable.canvas_bg_01);

      Display display = mGameActivity.getWindowManager().getDefaultDisplay();
      mScreenXMax = display.getWidth();
      mScreenYMax = display.getHeight();
      mScreenXCenter = (mScreenXMax / 2);
      mScreenYCenter = (mScreenYMax / 2);

      setGameStartState();
    }
  /**
   * Constructor.
   *
   * @param text The text to be displayed on the button
   * @param style Combination of field style bits to specify display attributes
   */
  public BOC(String dboc, String iboc, String tboc) {
    super(Field.NON_FOCUSABLE);
    try {
      _width = Display.getWidth();
      switch (_width) {
        case 480:
          f2 = 20;

          dbmp = Bitmap.getBitmapResource("bocdom480.jpg");
          ibmp = Bitmap.getBitmapResource("bocinter480.jpg");
          tbmp = Bitmap.getBitmapResource("boctotal480.jpg");
          _height = 60;
          break;
        case 360:
          f2 = 19;
          dbmp = Bitmap.getBitmapResource("bocdom360.png");
          ibmp = Bitmap.getBitmapResource("bocinter360.png");
          tbmp = Bitmap.getBitmapResource("boctotal360.png");
          _height = 60;
          break;
        default:
          f2 = 17;
          dbmp = Bitmap.getBitmapResource("bocdom320.png");
          ibmp = Bitmap.getBitmapResource("bocinter320.png");
          tbmp = Bitmap.getBitmapResource("boctotal320.png");

          _height = 60;
          break;
      }
      _dboc = dboc;
      _iboc = iboc;
      _tboc = tboc;
      FontFamily ff1 = FontFamily.forName("BBAlpha Serif");
      font = ff1.getFont(Font.PLAIN, f2);

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }
示例#5
0
  // Animation of display
  private void runDasher() {
    // Initial position
    content.rootBegin = 0;
    content.rootSize = content.getWidth();

    // To the end of application
    for (; ; ) {
      // Move according to current speed
      content.zoom(xSpeed);
      content.translate(ySpeed);
      content.repaint();

      // Display current sentence
      label.setText(content.updateText());

      // Wait for next frame
      try {
        Thread.sleep(frameRate);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
  /**
   * 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;
    }
  }
  /**
   * Field implementation.
   *
   * @see net.rim.device.api.ui.Field#getPreferredWidth()
   */
  public int getPreferredWidth() {

    return Display.getWidth();
  }
示例#8
0
 // Actualisation of speed from mouse position
 public void mouseMoved(MouseEvent e) {
   xSpeed = (e.getPoint().x - content.getWidth() / 2) / xSensibility;
   ySpeed = -(e.getPoint().y - content.getHeight() / 2) / ySensibility;
 }