private void drawBtnStyle(Graphics gfx) {
    final int initialColor = gfx.getColor();

    // draw border
    gfx.setColor(0x424242);
    gfx.drawLine(w - 1, 0, w - 1, h - 3);
    gfx.drawLine(0, h - 1, w - 1, h - 1);

    gfx.setColor(Color.BLACK);
    gfx.drawLine(w - 2, 0, w - 2, h - 2);
    gfx.drawLine(0, h - 2, w - 1, h - 2);

    gfx.setColor(initialColor);

    // corners are equal in size, so we can use just one value for both corners
    final int cornerWidth = BTN_STYLE_LEFT_CORNER.getWidth();
    final int middleWidth = w - 2 * cornerWidth - 2;

    // height is equal for all three pieces
    final int height = BTN_STYLE_LEFT_CORNER.getHeight();

    // draw left corner
    gfx.drawBitmap(0, 0, cornerWidth, height, BTN_STYLE_LEFT_CORNER, 0, 0);

    final EncodedImage middle = ImageUtils.resize(BTN_STYLE_MIDDLE, middleWidth + 1, height, false);

    // draw middle
    gfx.drawImage(cornerWidth, 0, middleWidth, height, middle, 0, 0, 0);

    // draw right corner
    gfx.drawBitmap(cornerWidth + middleWidth, 0, cornerWidth, height, BTN_STYLE_RIGHT_CORNER, 0, 0);
  }
예제 #2
0
  public UserInput() {
    super(USE_ALL_WIDTH);

    userField =
        new CustomEditField(
            FIELD_LEFT | BasicEditField.NO_NEWLINE | BasicEditField.NO_SWITCHING_INPUT);
    fontSetting.setPoint(Font.PLAIN, 7);
    userField.setFont(fontSetting.getFont());
    userField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    add(userField);

    Bitmap icon = Bitmap.getBitmapResource("icon_user.png");
    if (Variables.smallScreen()) {
      int newWidth = icon.getWidth() * 320 / 480;
      int newHeight = icon.getHeight() * 240 / 360;
      icon = ImageUtils.resizeBitmap(icon, newWidth, newHeight);
    }
    userImage = new BitmapField(icon);
    userImage.setBackground(BackgroundFactory.createSolidBackground(0xf7f7f7));
    userImage.setBorder(
        BorderFactory.createSimpleBorder(
            new XYEdges(1, 1, 1, 1),
            new XYEdges(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY),
            Border.STYLE_SOLID));
    add(userImage);
  }
  public SliderField(
      Bitmap thumb,
      Bitmap sliderBackground,
      Bitmap sliderBackgroundFocus,
      int numStates,
      int initialState,
      int xLeftBackMargin,
      int xRightBackMargin,
      long style) {
    super(style);

    if (initialState > numStates || numStates < 2) {}
    _imageThumb = thumb;
    _imageSlider = sliderBackground;
    _imageSliderFocus = sliderBackgroundFocus;
    _numStates = numStates;
    setState(initialState);

    _xLeftBackMargin = xLeftBackMargin;
    _xRightBackMargin = xRightBackMargin;

    _rop = _imageSlider.hasAlpha() ? Graphics.ROP_SRC_ALPHA : Graphics.ROP_SRC_COPY;

    _thumbWidth = thumb.getWidth();
    _thumbHeight = thumb.getHeight();

    initBitmaps();
  }
예제 #4
0
  public PassLockInput() {
    super(USE_ALL_WIDTH);

    passField =
        new CustomPasswordField("", "Password", 30, FIELD_LEFT | PasswordEditField.NO_NEWLINE);
    fontSetting.setPoint(Font.PLAIN, 7);
    passField.setFont(fontSetting.getFont());
    passField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
    add(passField);

    Bitmap icon = Bitmap.getBitmapResource("icon_lock.png");
    if (Variables.smallScreen()) {
      int newWidth = icon.getWidth() * 320 / 480;
      int newHeight = icon.getHeight() * 240 / 360;
      icon = ImageUtils.resizeBitmap(icon, newWidth, newHeight);
    }
    passImage = new BitmapField(icon);
    passImage.setBackground(BackgroundFactory.createSolidBackground(0xf7f7f7));
    passImage.setBorder(
        BorderFactory.createSimpleBorder(
            new XYEdges(1, 1, 1, 1),
            new XYEdges(Color.GRAY, Color.GRAY, Color.GRAY, Color.GRAY),
            Border.STYLE_SOLID));
    add(passImage);
  }
예제 #5
0
  /**
   * for drawing the Record with its Cell Title and Values
   *
   * @param graphics
   * @param b
   */
  private void drawRecord(Graphics graphics, boolean haveFocus) {
    // graphics.setColor(Color.BLACK);
    // graphics.fillRoundRect(10, 2, Display.getWidth() - 10, height + 5,
    // 10,
    // 10);
    // graphics.drawRoundRect(10, 2, Display.getWidth() - 10, height + 5,
    // 10,
    // 10);

    int color = Color.BLACK;
    int[] colors = drawFousLostColors;
    int[] X_PTS = {getWidth(), getWidth(), getPreferredWidth(), getPreferredWidth()};

    int[] Y_PTS = {height, getPreferredHeight(), getPreferredHeight(), height};
    if (haveFocus) {
      colors = drawFousGainColors;
      color = Color.WHITE;
    }
    graphics.drawShadedFilledPath(X_PTS, Y_PTS, null, colors, null);
    graphics.setColor(color);

    // for placing the arrow icon
    int image_height = (height / 2) - 8;
    int img_x_position = total_Width - 18;
    graphics.drawBitmap(
        img_x_position,
        image_height,
        arrowBitmap.getHeight(),
        arrowBitmap.getWidth(),
        arrowBitmap,
        0,
        0);

    int halfWidth = (getWidth() / 2) - RIGHT_MARGIN;

    int yPosition = 0;
    // Draw each cell

    for (int i = 0; i < record.getCells().size(); i++) {
      Cell cell = (Cell) record.getCells().elementAt(i);

      // Draw the title of the cell
      String text = cell.getTitle().trim();

      // take the value of the cell to draw
      String value = cell.getValue().trim();

      int numberOfRowsForTitle = drawText(text, value, graphics, 0, yPosition);

      int numberOfRowsForValue = drawText(value, value, graphics, halfWidth, yPosition);

      if (numberOfRowsForTitle == 1 && numberOfRowsForValue == 1) {
        yPosition += CELL_HEIGHT - MULTIPLE_CELLS;
      } else {
        yPosition += CELL_HEIGHT - MULTIPLE_CELLS;
        yPosition += SECOND_CELL_HEIGHT;
      }
    }
  }
 private void copy(Bitmap src, int x, int y, int width, int height, Bitmap dest) {
   int[] argbData = new int[width * height];
   src.getARGB(argbData, 0, width, x, y, width, height);
   for (int tx = 0; tx < dest.getWidth(); tx += width) {
     for (int ty = 0; ty < dest.getHeight(); ty += height) {
       dest.setARGB(argbData, 0, width, tx, ty, width, height);
     }
   }
 }
예제 #7
0
  public BitmapButtonField(Bitmap normalState, Bitmap focusState, long style) {
    super(Field.FOCUSABLE | style);

    if ((normalState.getWidth() != focusState.getWidth())
        || (normalState.getHeight() != focusState.getHeight())) {

      throw new IllegalArgumentException("Image sizes don't match");
    }

    _bitmaps = new Bitmap[] {normalState, focusState};
  }
  // Similar to TextFields layout()
  protected void layout(int width, int height) {
    if (width < 0 || height < 0) throw new IllegalArgumentException();

    // We'll take all we can get
    _totalWidth = width;

    // The largest of the two image heights
    _totalHeight = Math.max(_imageSlider.getHeight(), _imageThumb.getHeight());

    setExtent(_totalWidth, _totalHeight);
  }
예제 #9
0
 // Bitmap grey = Const.getGrey();
 public void paint(Graphics g) {
   int xPts[] = {0, 0, getPreferredWidth(), getPreferredWidth()};
   int yPts[] = {0, getPreferredHeight(), getPreferredHeight(), 0};
   g.setColor(2500134);
   g.drawFilledPath(xPts, yPts, null, null);
   // g.drawTexturedPath(xPts,yPts,null,null,0,this.getTop(),Fixed32.ONE,0,0,Fixed32.ONE,grey);
   if (focus) {
     g.drawBitmap(6, 0, button_select.getWidth(), button_select.getHeight(), button_select, 0, 0);
   } else {
     g.drawBitmap(
         6, 0, button_thumbnail.getWidth(), button_thumbnail.getHeight(), button_thumbnail, 0, 0);
   }
 }
예제 #10
0
 public void run() {
   int apa = Dialog.ask("Direction?", new String[] {"left", "up", "right", "down"}, 0);
   Bitmap bmp = null;
   if (apa == 0) {
     bmp = rotateImage(Bitmap.getBitmapResource("right.png"), 180);
   } else if (apa == 1) {
     bmp = Bitmap.getBitmapResource("up.png");
   } else if (apa == 2) {
     bmp = Bitmap.getBitmapResource("right.png");
   } else if (apa == 3) {
     bmp = rotateImage(Bitmap.getBitmapResource("up.png"), 180);
   }
   gbrfield.setGbr(bmp);
 }
  private void drawBitmap(Graphics gfx) {
    final int width = imageBmp.getWidth();
    final int height = imageBmp.getHeight();

    final int x = paddingLeft + ((desiredImgWidth - width) >> 1);
    final int y = paddingTop + ((desiredImgHeight - height) >> 1);

    gfx.drawBitmap(x, y, width, height, imageBmp, 0, 0);

    final int initialColor = gfx.getColor();
    gfx.setColor(Color.GRAY);
    gfx.drawRect(x, y, width, height);
    gfx.setColor(initialColor);
  }
예제 #12
0
 public void setUpAssets() {
   int w = Display.getWidth();
   int h = Display.getHeight();
   String res = w + "x" + h;
   System.out.println("res__________" + res);
   splash = Bitmap.getBitmapResource("img/splash_" + res + ".png");
   main = Bitmap.getBitmapResource("img/bkg_main.jpg");
   btn = Bitmap.getBitmapResource(button);
   if (splash == null) {
     splash = Bitmap.getBitmapResource(defSplash);
   }
   bkg_splash = BackgroundFactory.createBitmapBackground(splash);
   bkg_main = BackgroundFactory.createBitmapBackground(main);
 }
예제 #13
0
 public Bitmap getAvatar() {
   if (ImageCache.inCache(this.username)) {
     return ImageCache.getImage(this.username);
   } else {
     return Bitmap.getBitmapResource("img/default_avatar.gif");
   }
 }
예제 #14
0
  private void paintSliderBackground(Graphics g, Bitmap left, Bitmap middle, Bitmap right) {
    int sliderHeight = _imageSlider.getHeight();
    int sliderBackYOffset = (_totalHeight - sliderHeight) >> 1;

    // Left
    g.drawBitmap(0, sliderBackYOffset, _xLeftBackMargin, sliderHeight, left, 0, 0); // lefttop
    // Middle
    g.tileRop(
        _rop,
        _xRightBackMargin,
        sliderBackYOffset,
        _totalWidth - _xLeftBackMargin - _xRightBackMargin,
        sliderHeight,
        middle,
        0,
        0); // top
    // Right
    g.drawBitmap(
        _totalWidth - _xRightBackMargin,
        sliderBackYOffset,
        _xRightBackMargin,
        sliderHeight,
        right,
        0,
        0); // lefttop
  }
  private void addLogo() {
    Bitmap bitmap = Bitmap.getBitmapResource("res/logo.jpg");
    if (bitmap == null) {
      return;
    }

    BitmapField field = new BitmapField(bitmap, FIELD_HCENTER);
    field.setPadding(PADDING);
    add(field);
  }
예제 #16
0
  public EditorScreen(final Bitmap gbr, String path, String filename) {
    super(NO_VERTICAL_SCROLL);
    this.path = path;
    this.filename = filename;
    this.gbr = gbr;
    this.g = Graphics.create(gbr);

    UiApplication.getUiApplication().requestForeground();

    latar =
        new VerticalFieldManager(
            VERTICAL_SCROLL | HORIZONTAL_SCROLL | USE_ALL_WIDTH | USE_ALL_HEIGHT) {
          protected void paint(Graphics graphics) {
            graphics.drawBitmap(0, 0, gbr.getWidth(), gbr.getHeight(), gbr, 0, 0);
            graphics.drawRect(0, 0, gbr.getWidth(), gbr.getHeight());
            super.paint(graphics);
          }
        };

    this.gbrfield = new gbrField(gbr.getWidth(), gbr.getHeight());
    latar.add(gbrfield);
    gbrfield.setText("Jalak_Harupat");
    add(latar);

    addMenuItem(addText);
    addMenuItem(addArrow);
    addMenuItem(addimg);
    addMenuItem(addFilter);
    addMenuItem(addhelp);
    addMenuItem(saveclose);
    addMenuItem(about);
    if (DBStor.getSettings() == null) {
      UiApplication.getUiApplication()
          .invokeLater(
              new Runnable() {
                public void run() {
                  Dialog.alert("this is editor Screen, Click menu to do something.");
                }
              });
      DBStor.setSettings(new Settings());
    }
    setDirty(true);
  }
 public void setItemImage(byte[] image) {
   try {
     Bitmap temp = Bitmap.createBitmapFromBytes(image, 0, image.length, 1);
     int w = TEXT_ANCHOR - 2 * PADDING_TOP;
     this.newsImage = Utils.resizedImage(temp, w, w);
   } catch (Exception e) {
   }
   synchronized (Application.getEventLock()) {
     NewsItemButton.super.invalidate();
   }
 }
예제 #18
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);
  }
예제 #19
0
  public static Bitmap rotateImage(Bitmap oldB, int angle) {
    try {
      int w = oldB.getWidth();
      int h = oldB.getHeight();
      double angRad = (angle % 360) * (Math.PI / 180);
      Bitmap newB = new Bitmap(w, h);
      int[] oldD = new int[w * h];
      int[] newD = new int[w * h];
      oldB.getARGB(oldD, 0, w, 0, 0, w, h);

      int axisX = w / 2;
      int axisY = h / 2;

      for (int x = 0; x < oldD.length; x++) {
        int oldX = x % w;
        int oldY = x / w;
        int op = oldX - axisX;
        int adj = oldY - axisY;
        double oldT = MathUtilities.atan2(op, adj);
        double rad = Math.sqrt((op * op) + (adj * adj));
        double newT = oldT + angRad;
        int newX = (int) MathUtilities.round((rad * Math.sin(newT)) + (double) axisX);
        int newY = (int) MathUtilities.round((rad * Math.cos(newT)) + (double) axisY);
        if (newX < 0 || newY < 0 || newX >= w || newY >= h) {
          newD[x] = 0x00000000;
        } else {
          newD[x] = oldD[(newY * w) + newX];
        }
      }

      newB.setARGB(newD, 0, w, 0, 0, w, h);
      return newB;
    } catch (Exception e) {

    }
    return null;
  }
예제 #20
0
 public FacturaResumen() {
   _listaConsulResumen =
       new ListField(
           0, ListField.FIELD_HCENTER | ListField.USE_ALL_WIDTH | ListField.USE_ALL_HEIGHT);
   _listaConsulResumen.setCallback(this);
   _listaConsulResumen.setSearchable(true);
   add(
       new BitmapField(
           Bitmap.getBitmapResource("img/titulos/facturacionresumen.png"),
           BitmapField.FIELD_HCENTER));
   add(_listaConsulResumen);
   addMenuItem(_Secciones);
   llenaJerarquia();
   Sistema.addEstadistica(Cadenas.FAC_CAMPANA);
 }
예제 #21
0
 public void run() {
   int ask = -1;
   if (undo != null)
     ask =
         Dialog.ask(
             "What Filter?",
             new String[] {"GrayScale", "Negative", "Sephia", "Termal", "Undo Filter"},
             0);
   else
     ask =
         Dialog.ask(
             "What Filter?", new String[] {"GrayScale", "Negative", "Sephia", "Termal"}, 0);
   if (ask < 4) {
     undo = new int[gbr.getWidth() * gbr.getHeight()];
     gbr.getARGB(undo, 0, gbr.getWidth(), 0, 0, gbr.getWidth(), gbr.getHeight());
     FilterImg.doit(gbr, ask);
   } else if (ask == 4) {
     if (undo != null) {
       gbr.setARGB(undo, 0, gbr.getWidth(), 0, 0, gbr.getWidth(), gbr.getHeight());
       undo = null;
     }
   }
   latar.invalidate();
 }
  /**
   * 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());
    }
  }
예제 #23
0
  public void paint(Graphics g) {
    // Calculate the slider position
    int sliderHeight = _imageSlider.getHeight();
    int sliderBackYOffset = (_totalHeight - sliderHeight) >> 1;

    // Determine a Background Color for the slider
    int backgroundColor = _defaultBackgroundColour;
    if (_backgroundSelectedColours != null || _backgroundColours != null) {

      if (_selected) {
        backgroundColor =
            _backgroundSelectedColours != null
                ? _backgroundSelectedColours[getState()]
                : _defaultSelectColour;
      } else if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
        backgroundColor =
            _backgroundColours != null ? _backgroundColours[getState()] : _defaultHoverColour;
      } else {
        backgroundColor = _defaultBackgroundColour;
      }
    }
    g.setColor(backgroundColor);
    g.fillRect(1, sliderBackYOffset + 1, _totalWidth - 2, sliderHeight - 2);

    if (g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS)) {
      paintSliderBackground(
          g, _imageSliderFocusLeft, _imageSliderFocusCenter, _imageSliderFocusRight);
    } else {
      paintSliderBackground(g, _imageSliderLeft, _imageSliderCenter, _imageSliderRight);
    }

    // Calculate the thumb position
    int thumbXOffset = ((_totalWidth - _thumbWidth) * _currentState) / _numStates;

    // Draw the thumb
    g.drawBitmap(
        thumbXOffset,
        (_totalHeight - _thumbHeight) >> 1,
        _thumbWidth,
        _thumbHeight,
        _imageThumb,
        0,
        0);
  }
예제 #24
0
  /**
   * Cuts up the background image and margins you provide to make the left, center, and right
   * bitmaps
   */
  public void initBitmaps() {
    int height = _imageSlider.getHeight();

    _imageSliderLeft = new Bitmap(_xLeftBackMargin, height);
    _imageSliderCenter =
        new Bitmap(_imageSlider.getWidth() - _xRightBackMargin - _xLeftBackMargin, height);
    _imageSliderRight = new Bitmap(_xRightBackMargin, height);

    copy(_imageSlider, 0, 0, _xLeftBackMargin, height, _imageSliderLeft);
    copy(
        _imageSlider,
        _xLeftBackMargin,
        0,
        _imageSlider.getWidth() - _xRightBackMargin - _xLeftBackMargin,
        height,
        _imageSliderCenter);
    copy(
        _imageSlider,
        _imageSlider.getWidth() - _xRightBackMargin,
        0,
        _xRightBackMargin,
        height,
        _imageSliderRight);

    _imageSliderFocusLeft = new Bitmap(_xLeftBackMargin, height);
    _imageSliderFocusCenter =
        new Bitmap(_imageSlider.getWidth() - _xRightBackMargin - _xLeftBackMargin, height);
    _imageSliderFocusRight = new Bitmap(_xRightBackMargin, height);

    copy(_imageSliderFocus, 0, 0, _xLeftBackMargin, height, _imageSliderFocusLeft);
    copy(
        _imageSliderFocus,
        _xLeftBackMargin,
        0,
        _imageSlider.getWidth() - _xRightBackMargin - _xLeftBackMargin,
        height,
        _imageSliderFocusCenter);
    copy(
        _imageSliderFocus,
        _imageSlider.getWidth() - _xRightBackMargin,
        0,
        _xRightBackMargin,
        height,
        _imageSliderFocusRight);
  }
예제 #25
0
 public LessonListField(String title, String imageFile) {
   super(USE_ALL_WIDTH | FOCUSABLE);
   myCounter = counter++;
   this.title = title;
   image = Bitmap.getBitmapResource(imageFile);
   int newWidth = Display.getWidth() / 2;
   if (Variables.smallScreen()) {
     newWidth = Display.getWidth() * 4 / 10;
   }
   if (image.getWidth() > newWidth) {
     int newHeight = newWidth * image.getHeight() / image.getWidth();
     image = ImageUtils.resizeBitmap(image, newWidth, newHeight);
   }
   normalArrow = Bitmap.getBitmapResource("next_inactive_btn.png");
   focusArrow = Bitmap.getBitmapResource("next_active_btn.png");
   lock = Bitmap.getBitmapResource("small_lock.png");
   fontSetting.setPoint(Font.PLAIN, 7);
 }
예제 #26
0
  /** @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);
  }
예제 #27
0
 public BitmapField WriteWebImage(final Manager parent, final String url, final int size) {
   final BitmapField fImg =
       new BitmapField(Bitmap.getBitmapResource("img/cargandosm.png"), BitmapField.FOCUSABLE) {
         protected void layout(int width, int height) {
           setExtent(getBitmapWidth() + 3, getBitmapHeight() + 3);
         }
       };
   parent.add(fImg);
   try {
     UiApplication.getUiApplication()
         .invokeLater(
             new Runnable() {
               public void run() {
                 new AsyncDownloadImage(url, fImg, size).run();
               }
             });
   } catch (Exception e) {
     e.printStackTrace();
   }
   return fImg;
 }
  /**
   * Gets the image given a path Source: {@link
   * http://supportforums.blackberry.com/t5/Java-Development/How-to-read-display-image-from-SD-card-on-Device/m-p/621671#M129277}
   */
  public Bitmap getImage(String path) {
    StringBuffer sb = new StringBuffer(1024);
    sb.append("file:///SDCard/").append(path);
    String filename = sb.toString();
    sb = null;
    Bitmap image = null;

    FileConnection fc = null;
    InputStream input = null;
    try {
      fc = (FileConnection) Connector.open(filename, Connector.READ_WRITE);
      if (fc.exists()) {
        input = fc.openInputStream();
        byte[] data = new byte[(int) fc.fileSize()];
        input.read(data);
        image = Bitmap.createBitmapFromPNG(data, 0, data.length);
      }
    } catch (Exception e) {
    } finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
        }
      }
      if (fc != null) {
        try {
          fc.close();
        } catch (Exception e) {
        }
      }
    }

    if (image == null) {
      return getImage(DEFAULT_IMAGE); // TODO: possible recursive loop
    }
    return image;
  }
예제 #29
0
  public FreemapMainScreen() {
    super(DEFAULT_MENU);

    m_this = this;
    int size = 20;
    m_contextMenuItems = new Vector(size);
    m_MiniMenuItems = new Vector(size);
    for (int i = 0; i < size; ++i) {
      m_contextMenuItems.addElement(null);
      m_MiniMenuItems.addElement(null);
    }
    m_initial_locale = Locale.getDefaultInputForSystem();

    waiting_dialog =
        new Dialog(
            "please wait...",
            new String[] {"Hide"},
            null,
            Dialog.OK,
            Bitmap.getPredefinedBitmap(Bitmap.HOURGLASS));

    isLandscapeScreen = getVisibleWidth() > getVisibleHeight() ? 1 : 0;
  }
  public UIExampleListStyleButtonFieldScreen() {

    super(NO_VERTICAL_SCROLL | USE_ALL_HEIGHT);

    setTitle("ListStyleButtonField Example");

    Bitmap caret = Bitmap.getBitmapResource("chevron_right_black_15x22.png");

    ListStyleButtonField one = new ListStyleButtonField("Music", caret);
    one.setChangeListener(this);
    add(one);

    ListStyleButtonField two = new ListStyleButtonField("Photos", caret);
    two.setChangeListener(this);
    add(two);

    ListStyleButtonField three = new ListStyleButtonField("Extras", caret);
    three.setChangeListener(this);
    add(three);

    ListStyleButtonField four = new ListStyleButtonField("Settings", caret);
    four.setChangeListener(this);
    add(four);

    ListStyleButtonField five = new ListStyleButtonField("Shuffle Songs", 0);
    five.setChangeListener(this);
    add(five);

    _explanation = new UIExampleScreen();
    _explanation.setTitle("ListStyleButtonField Explanation");

    LabelField explanationLabel =
        new LabelField(
            "The ListStyleButtonField looks like a list row, but is just a simple button. Good for use with a small finite set of elements.");
    explanationLabel.setPadding(5, 5, 5, 5);
    _explanation.add(explanationLabel);
  }