protected void beforeMyProfile(Form f) {
    Myprofile = f;
    Label l1 = (Label) findByName("propic", f);
    name = (TextField) findByName("name", Myprofile);
    index = (TextField) findByName("index", Myprofile);
    tel = (TextField) findByName("tel", Myprofile);
    addr = (TextField) findByName("addr", Myprofile);
    email = (TextField) findByName("email", Myprofile);
    group = (TextField) findByName("group", Myprofile);
    try {

      String userde[] = Splitter.Split(new String(record.getRecord(4)), "-");

      name.setText(userde[0]);
      index.setText(userde[1]);
      tel.setText(userde[2]);
      addr.setText(userde[3]);
      email.setText(userde[4]);
      group.setText(userde[5]);

      if (new String(record.getRecord(2)).equals("no")) {
        l1.setIcon(Image.createImage("/no_user.png").scaledHeight(72));

      } else {
        l1.setIcon(Image.createImage(new String(record.getRecord(2))).scaledHeight(72));
      }

      System.gc();
    } catch (Exception e) {
    }
    super.beforeMyProfile(f);
  }
  public Form getSupportMe() {
    if (frmSupportMe == null) {
      // ---------------------------------------------
      // Form f = ...
      frmSupportMe = new Form("Support Me");
      frmSupportMe.setLayout(new BorderLayout());

      Image bimage = null;
      try {
        bimage = Image.createImage("/images/metaLabSmall.png");
      } catch (IOException ex) {
        ex.printStackTrace();
      }

      Label bottomText = new Label(bimage);
      bottomText.setAlignment(Component.CENTER);
      bottomText.setText("Our Logo");
      bottomText.setTextPosition(Component.BOTTOM);

      Container buttonBar = new Container(new BoxLayout(BoxLayout.X_AXIS));
      buttonBar.addComponent(new Button("Add"));
      buttonBar.addComponent(new Button("Remove"));
      buttonBar.addComponent(new Button("Edit"));
      buttonBar.addComponent(new Button("Send"));
      buttonBar.addComponent(new Button("Exit"));

      frmSupportMe.addComponent(BorderLayout.CENTER, bottomText);
      frmSupportMe.addComponent(BorderLayout.SOUTH, buttonBar);
      frmSupportMe.addCommand(mBackCommand);
      frmSupportMe.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier.
    }
    return frmSupportMe;
  }
  protected void beforeDepartments(Form f) {
    department = f;
    Label l = (Label) findByName("Label2", f);
    try {
      HttpCon con12 =
          new HttpCon(
              String.valueOf(departmentPerson) + "-p",
              PropertyClass.ServerUrl + "DepartmentOffiecer");
      con12.SetContype(true, true, true);
      Thread t = new Thread(con12);
      synchronized (t) {
        t.start();
        t.wait();
      }

      String a[] = Splitter.Split(con12.getValue().toString(), "-");
      ((Label) findByName("Label3", f)).setText(a[4]);
      ((TextArea) findByName("aboutDepartmentt", f)).setText(a[0]);
      ((Label) findByName("name", f)).setText("Head Dept: " + a[1]);
      ((Label) findByName("Label7", f)).setText(a[2]);
      ((Label) findByName("Label8", f)).setText("Tel : " + a[3]);

      switch (departmentPerson) {
        case 1:
          l.setIcon(Image.createImage("/ceo.png").scaledHeight(78));

          break;
        case 2:
          l.setIcon(Image.createImage("/div1.png").scaledHeight(78));
          break;
        case 3:
          l.setIcon(Image.createImage("/div2.png").scaledHeight(78));
          break;
        case 4:
          l.setIcon(Image.createImage("/div3.png").scaledHeight(78));
          break;
        default:
          l.setIcon(Image.createImage("no_user.png").scaledHeight(78));
          break;
      }
      departmentPerson = 0;
      super.beforeDepartments(f);
      System.gc();
    } catch (Exception e) {
    }
  }
Пример #4
0
 protected Image createImage(String path) {
   try {
     return Image.createImage(path);
   } catch (IOException ex) {
     ex.printStackTrace();
   }
   return null;
 }
  public WallpaperListRenderer() {
    try {
      setName("wallpaperIcon");
      setSmoothScrolling(true);
      InputStream inputStream = getClass().getResourceAsStream("/res/images/surahlistbard.png");
      surahUnselect = Image.createImage(inputStream);
      inputStream = getClass().getResourceAsStream("/res/images/surahselect.png");
      surahSelect = Image.createImage(inputStream);
      getStyle().setAlignment(CENTER);
      getSelectedStyle().setAlignment(CENTER);
      getStyle().setBgTransparency(0);
      getStyle().setBgImage(surahUnselect);
      getSelectedStyle().setBgTransparency(100);
      getSelectedStyle().setBgImage(surahSelect);

    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
  /** @return the bitmapFont */
  public Font getBitmapFont() {
    Font bitmapFont = Font.getBitmapFont(lookupFont);
    if (bitmapFont != null) {
      return bitmapFont;
    }

    BufferedImage image = new BufferedImage(5000, 50, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = (Graphics2D) image.getGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g2d.setRenderingHint(
        RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, bitmapAntialiasing);
    g2d.setColor(Color.BLACK);
    g2d.fillRect(0, 0, image.getWidth(), image.getHeight());
    g2d.setColor(new Color(0xff0000));
    g2d.setFont(java.awt.Font.decode(lookupFont.split(";")[0]));
    FontMetrics metrics = g2d.getFontMetrics();
    FontRenderContext context = g2d.getFontRenderContext();
    int height = (int) Math.ceil(metrics.getMaxDescent() + metrics.getMaxAscent());
    int baseline = (int) Math.ceil(metrics.getMaxAscent());
    String charsetStr = bitmapCharset;
    int[] offsets = new int[charsetStr.length()];
    int[] widths = new int[offsets.length];
    int currentOffset = 0;
    for (int iter = 0; iter < charsetStr.length(); iter++) {
      offsets[iter] = currentOffset;
      String currentChar = charsetStr.substring(iter, iter + 1);
      g2d.drawString(currentChar, currentOffset, baseline);
      Rectangle2D rect = g2d.getFont().getStringBounds(currentChar, context);
      widths[iter] = (int) Math.ceil(rect.getWidth());

      // max advance works but it makes a HUGE image in terms of width which
      // occupies more ram
      if (g2d.getFont().isItalic()) {
        currentOffset += metrics.getMaxAdvance();
      } else {
        currentOffset += widths[iter] + 1;
      }
    }

    g2d.dispose();
    BufferedImage shrunk = new BufferedImage(currentOffset, height, BufferedImage.TYPE_INT_RGB);
    g2d = (Graphics2D) shrunk.getGraphics();
    g2d.drawImage(image, 0, 0, null);
    g2d.dispose();

    int[] rgb = new int[shrunk.getWidth() * shrunk.getHeight()];
    shrunk.getRGB(0, 0, shrunk.getWidth(), shrunk.getHeight(), rgb, 0, shrunk.getWidth());
    com.sun.lwuit.Image bitmap =
        com.sun.lwuit.Image.createImage(rgb, shrunk.getWidth(), shrunk.getHeight());

    return com.sun.lwuit.Font.createBitmapFont(lookupFont, bitmap, offsets, widths, charsetStr);
  }
Пример #7
0
 private Vector parseWallpaperThumbnailJSON(String response, List cmp) {
   Vector resultVector = new Vector();
   Image blank = Image.createImage(50, 50);
   try {
     JSONObject jSONObject = new JSONObject(response);
     System.out.println(jSONObject);
     Enumeration e = jSONObject.keys();
     while (e.hasMoreElements()) {
       String key = (String) e.nextElement();
       //                System.out.println(key + " : " + jSONObject.getString(key));
       if (key.equalsIgnoreCase("wallpapers")) {
         JSONArray jSONArray = jSONObject.getJSONArray(key);
         for (int i = 0; i < jSONArray.length(); i++) {
           JSONObject wallpaper = jSONArray.getJSONObject(i);
           if (wallpaper.has("image_thumb_url")
               && wallpaper.has("image_category")
               && wallpaper.has("image_url")
               && wallpaper.has("wallpaper_price")) {
             // download the thumbnail and display it.
             Hashtable hashtable = new Hashtable();
             hashtable.put("wallpaperThumbnailURL", wallpaper.getString("image_thumb_url"));
             hashtable.put("wallpaperURL", wallpaper.get("image_url"));
             hashtable.put("wallpaperPrice", "Price: " + wallpaper.get("wallpaper_price"));
             hashtable.put("wallpaperIcon", blank);
             resultVector.addElement(hashtable);
             final ImageDownloadService ids =
                 new ImageDownloadService(
                     wallpaper.getString("image_thumb_url"),
                     cmp,
                     resultVector.size() - 1,
                     "wallpaperIcon") {
                   protected void handleException(Exception err) {
                     if (err instanceof NullPointerException) {
                       System.out.println("NULL POINTER EXCEPTION CAUGHT");
                       return;
                     }
                     super.handleException(
                         err); // To change body of generated methods, choose Tools | Templates.
                   }
                 };
             NetworkManager.getInstance().addToQueue(ids);
           }
         }
       }
     }
   } catch (Exception ex) {
     System.out.println("error downloading images.");
     ex.printStackTrace();
     Dialog.show(null, "error downloading images", "OK", null);
   }
   return resultVector;
 }
  protected void beforeUserprofile(Form f) {
    try {
      ((Label) findByName("Label2", f)).setIcon(Image.createImage("/no_user.png").scaledHeight(72));
      HttpCon con12 = new HttpCon(frndid + "-p", PropertyClass.ServerUrl + "Frends");
      con12.SetContype(true, true, true);
      Thread t = new Thread(con12);
      synchronized (t) {
        t.start();
        t.wait();
      }
      String frnd[] = Splitter.Split(con12.getValue().toString(), "-");
      ((Label) findByName("Label4", f)).setText(frnd[0]);
      ((Label) findByName("Label6", f)).setText(frnd[1]);
      ((Label) findByName("tel", f)).setText("Tel   " + frnd[2]);
      ((Label) findByName("Label81", f)).setText("Address   " + frnd[3]);
      ((Label) findByName("Label7", f)).setText("email   " + frnd[4]);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    super.beforeUserprofile(f);
  }
Пример #9
0
  public void startApp() {
    Display.init(this);

    ImageGrid imageGrid = new ImageGrid();
    try {
      Image[] images = new Image[6];
      images[0] = Image.createImage("/image1.jpg");
      images[1] = Image.createImage("/image2.jpg");
      images[2] = Image.createImage("/image3.jpg");
      images[3] = Image.createImage("/image4.jpg");
      images[4] = Image.createImage("/image5.jpg");
      images[5] = Image.createImage("/image6.jpg");
      for (int i = 0; i < images.length; i++) {
        ImageCell imageCell = new ImageCell(images[i]);
        imageGrid.addComponent(imageCell);
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    }
    imageGrid.show();
  }
Пример #10
0
 static {
   try {
     imgLoading = Image.createImage("/images/loading.png");
   } catch (IOException e) {
   }
 }
Пример #11
0
    public Component getListCellRendererComponent(
        List list, Object value, int index, boolean isSelected) {
      if (value != null) {
        addressEntry = (AddressBookEntry) value;

        Log.v(TAG, "AddressBookEntry: " + addressEntry);

        Log.v(TAG, "Index is:" + index);
        onFocusLbl.getStyle().setBgTransparency(20, true);

        Container namephnumContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        namephnumContainer.getStyle().setPadding(Component.LEFT, 3, true);
        namephnumContainer.getStyle().setPadding(Component.TOP, 5, true);
        namephnumContainer.getStyle().setPadding(Component.BOTTOM, 8, true);

        Label contactName = new Label(addressEntry.getName());
        contactName.getStyle().setBgTransparency(0, true);
        contactName.getStyle().setFgColor(ColorCodes.selectContactNameGrey, true);
        contactName.getStyle().setPadding(Component.BOTTOM, 0, true);

        contactName.getSelectedStyle().setFont(Fonts.MONO_MEDIUM, true);
        contactName.getStyle().setFont(Fonts.MONO_MEDIUM, true);
        contactName.getSelectedStyle().setBorder(null, true);
        contactName.setPreferredSize(
            new Dimension(
                (Display.getInstance().getDisplayWidth() - inviteImage.getWidth() - 25), 30));

        Label phoneNum = new Label(addressEntry.getMsisdn());
        phoneNum.getStyle().setBgTransparency(0, true);
        phoneNum.getStyle().setPadding(Component.TOP, 0, true);
        phoneNum.getSelectedStyle().setBorder(null, true);
        phoneNum.getSelectedStyle().setFont(Fonts.MONO_SMALL, true);
        phoneNum.getStyle().setFont(Fonts.MONO_SMALL, true);
        phoneNum.getStyle().setFgColor(ColorCodes.selectContactNumberGrey);

        namephnumContainer.addComponent(contactName);
        namephnumContainer.addComponent(phoneNum);

        inviteButton = new Button(inviteImage);
        inviteButton.getStyle().setBgTransparency(0, true);
        inviteButton.getSelectedStyle().setBgTransparency(0, true);
        inviteButton.getPressedStyle().setBgTransparency(0, true);
        inviteButton.getPressedStyle().setBorder(null, true);
        inviteButton.getStyle().setBorder(null, true);
        inviteButton.getSelectedStyle().setBorder(null, true);
        inviteButton.getStyle().setAlignment(CENTER);

        tickMark = new Label(sentInviteImage);
        tickMark.getStyle().setAlignment(Component.CENTER);
        tickMark.getStyle().setBgTransparency(0, true);
        tickMark.getSelectedStyle().setBgTransparency(0, true);
        tickMark.getPressedStyle().setBgTransparency(0, true);
        tickMark.getPressedStyle().setBorder(null, true);
        tickMark.getStyle().setBorder(null, true);
        tickMark.getSelectedStyle().setBorder(null, true);
        tickMark.getStyle().setAlignment(CENTER);
        tickMark.getStyle().setPadding(Component.RIGHT, 30, true);

        mainContainer = new Container(new BorderLayout());
        mainContainer
            .getStyle()
            .setBorder(
                Border.createCompoundBorder(
                    null,
                    Border.createEtchedRaised(
                        ColorCodes.selectContactSeperator, ColorCodes.selectContactSeperatorShadow),
                    null,
                    null),
                true);

        mainContainer.addComponent(BorderLayout.WEST, namephnumContainer);
        if (inviteButton.getParent() == null) {
          mainContainer.addComponent(BorderLayout.EAST, inviteButton);
        }

        getStyle().setPadding(Component.RIGHT, 0, true);
        getUnselectedStyle().setPadding(Component.RIGHT, 0, true);
        getPressedStyle().setPadding(Component.RIGHT, 0, true);
        getSelectedStyle().setPadding(Component.RIGHT, 0, true);

        if (addressEntry.isInvited()) {
          mainContainer.removeComponent(inviteButton);
          mainContainer.addComponent(BorderLayout.EAST, tickMark);
        }
      }

      return mainContainer;
    }