Esempio n. 1
0
  @Override
  protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g.create();

    if (activityType == ActivityType.SHOW) {
      if (themeColor == ThemeColors.RED)
        g2.setColor(new Color(0x517800)); // new Color(0x8ff069));//new Color(0xde594c));
      else g2.setColor(new Color(0x43ba71)); // 0x32e632));//0xffff33));
      // Draw rectangle
      g2.fillRect(0, 0, getWidth(), getHeight());
      this.setBorder(BorderFactory.createLineBorder(new Color(0x999999)));

    } else if (activityType == ActivityType.SHARE) {
      // set color
      if (themeColor == ThemeColors.RED)
        g2.setColor(
            new Color(0x7d4374)); // new Color(0xf069bc));//(0xd84837));//(0xc74245));//(0x4268af));
      else g2.setColor(new Color(0x9843ba)); // 0xaa32e6));//0x99ccff));//2fb9f5));

      // Draw rectangle
      g2.fillRect(0, 0, getWidth(), getHeight());
      this.setBorder(BorderFactory.createLineBorder(new Color(0x999999)));
    } else {
      // set color
      if (themeColor == ThemeColors.RED)
        g2.setColor(new Color(0x7474b5)); // (new Color(0x6aa5ef));//(0xf59e13));
      else g2.setColor(new Color(0x4379ba)); // 0x32aae6));//0x99ff33));

      // Draw rectangle
      g2.fillRect(0, 0, getWidth(), getHeight());
      this.setBorder(BorderFactory.createLineBorder(new Color(0x999999)));
    }

    // Draw app icon
    int minDimension = Math.min(getWidth(), getHeight());
    BufferedImage resizedImage = resizeTrick(programIcon, minDimension, minDimension);
    BufferedImage transparentImage = ImageUtils.makeColorTransparent(resizedImage, Color.BLACK);
    g2.drawImage(transparentImage, 0, 0, null);
    // Draw device icon
    if (sharedDevice == SharedDevice.SHAREDDISPLAY) {
      BufferedImage resizedDeviceIcon = resizeTrick(deviceIcon, minDimension, minDimension);
      if (minDimension == getWidth()) {
        g.drawImage(resizedDeviceIcon, 0, getHeight() / 2, null);
      } else {
        g.drawImage(resizedDeviceIcon, getWidth() - 2 * minDimension, 0, null);
      }
    }
    if (activityIcon != null) {
      BufferedImage resizedActivityIcon;
      if (activityType == ActivityType.SHOW || activityType == ActivityType.SHARE)
        resizedActivityIcon = resize(activityIcon, minDimension, minDimension);
      else resizedActivityIcon = resizeTrick(activityIcon, minDimension, minDimension);
      if (minDimension == getWidth()) {
        g.drawImage(resizedActivityIcon, 0, getHeight(), null);
      } else {
        g.drawImage(resizedActivityIcon, getWidth() - minDimension, 0, null);
      }
    }
  }
Esempio n. 2
0
  public ShowShareBox(
      String iconPath,
      String bgPath,
      ActivityType activityType,
      ThemeColors selectedThemeColor,
      SharedDevice sharedDevice) {
    super();
    this.appIconPath = iconPath;
    this.programIcon = ImageUtils.loadImage(iconPath);
    this.themeColor = selectedThemeColor;
    this.sharedDevice = sharedDevice;

    if (bgPath == null || bgPath == "") this.activityIcon = null;
    else this.activityIcon = ImageUtils.loadImage(bgPath);
    this.activityType = activityType;
    if (sharedDevice == SharedDevice.SHAREDDISPLAY) {
      deviceIcon = ImageUtils.loadImage("res/sharedDisplay2.gif");
    }
  }
Esempio n. 3
0
 @Override
 public BufferedImage transform(BufferedImage image) {
   BufferedImage original = ImageUtils.copyImage(image);
   try {
     image = nnSkinFilter.filterSkinPixels(image);
     regions = blobDetector.localize(image);
     Graphics2D g2 = original.createGraphics();
     g2.setColor(Color.GREEN);
     iterator = regions.iterator();
     while (iterator.hasNext()) {
       Region region = iterator.next();
       g2.draw(region);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return original;
 }