Пример #1
0
  /**
   * Action performed on various action links(buttons).
   *
   * @param e the action.
   */
  public void actionPerformed(ActionEvent e) {
    JButton src = (JButton) e.getSource();

    if (src instanceof SIPCommButton) {
      // Load image
      int index = Integer.parseInt(src.getName());
      BufferedImage image = AvatarStackManager.loadImage(index);

      // Set the new image
      setNewImage(image);
    } else if (src.getName().equals("chooseButton")) {
      // Open the image picker
      Image currentImage = this.avatarImage.getAvatar();

      ImagePickerDialog dialog = new ImagePickerDialog(96, 96);

      byte[] bimage = dialog.showDialog(currentImage);

      if (bimage == null) return;

      // New image
      BufferedImage image = ImageUtils.getBufferedImage(new ImageIcon(bimage).getImage());

      // Store image
      if (this.nextImageIndex == MAX_STORED_IMAGES) {
        // No more place to store images
        // Pop the first element (index 0)
        AvatarStackManager.popFirstImage(MAX_STORED_IMAGES);

        this.nextImageIndex = MAX_STORED_IMAGES - 1;
      }

      // Store the new image on hard drive
      AvatarStackManager.storeImage(image, this.nextImageIndex);

      // Inform protocols about the new image
      setNewImage(image);
    } else if (src.getName().equals("removeButton")) {
      // Removes the current photo.
      setNewImage(null);
    } else if (src.getName().equals("clearButton")) {
      clearRecentImages();
    }

    setVisible(false);
  }
Пример #2
0
  /** Clear stored images. */
  private void clearRecentImages() {
    for (int i = 0; i < MAX_STORED_IMAGES; i++) {
      this.recentImagesButtons[i].setImage(null);
      this.recentImagesButtons[i].setEnabled(false);
      AvatarStackManager.deleteImage(i);
    }

    this.nextImageIndex = 0;
  }
Пример #3
0
  /** Refresh images with those stored locally. */
  public void refreshRecentImages() {
    int i;

    for (i = 0; i < MAX_STORED_IMAGES; i++) {
      BufferedImage image = AvatarStackManager.loadImage(i);
      if (image == null) break;

      this.recentImagesButtons[i].setImage(createThumbnail(image));
      this.recentImagesButtons[i].setEnabled(true);
    }

    if (i < MAX_STORED_IMAGES) {
      this.nextImageIndex = i;

      for (; i < MAX_STORED_IMAGES; i++) {
        this.recentImagesButtons[i].setImage(null);
        this.recentImagesButtons[i].setEnabled(false);
      }
    } else this.nextImageIndex = MAX_STORED_IMAGES;
  }