ArrowMultiIcon(ImageIcon icon) {
   this.icon = icon;
   if (icon != null) {
     disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(icon.getImage()));
   }
   arrow = new ArrowIcon();
 }
示例#2
0
 // compare the two images in this object.
 public void compare() {
   // setup change display image
   imgc = imageToBufferedImage(img1);
   Graphics2D gc = imgc.createGraphics();
   gc.setColor(Color.RED);
   // convert to gray images.
   img1 = imageToBufferedImage(GrayFilter.createDisabledImage(img1));
   img2 = imageToBufferedImage(GrayFilter.createDisabledImage(img2));
   // how big are each section
   int blocksx = (int) (img1.getWidth() / comparex);
   int blocksy = (int) (img1.getHeight() / comparey);
   // set to a match by default, if a change is found then flag non-match
   this.match = true;
   // loop through whole image and compare individual blocks of images
   for (int y = 0; y < comparey; y++) {
     if (debugMode > 0) System.out.print("|");
     for (int x = 0; x < comparex; x++) {
       int b1 =
           getAverageBrightness(
               img1.getSubimage(x * blocksx, y * blocksy, blocksx - 1, blocksy - 1));
       int b2 =
           getAverageBrightness(
               img2.getSubimage(x * blocksx, y * blocksy, blocksx - 1, blocksy - 1));
       int diff = Math.abs(b1 - b2);
       if (diff
           > factorA) { // the difference in a certain region has passed the threshold value of
                        // factorA
         // draw an indicator on the change image to show where change was detected.
         gc.drawRect(x * blocksx, y * blocksy, blocksx - 1, blocksy - 1);
         this.match = false;
       }
       if (debugMode == 1) System.out.print((diff > factorA ? "X" : " "));
       if (debugMode == 2) System.out.print(diff + (x < comparex - 1 ? "," : ""));
     }
     if (debugMode > 0) System.out.println("|");
   }
 }
示例#3
0
 private static ImageIcon makeGrayImageIcon3(Image img) {
   // GrayFilter1
   return new ImageIcon(GrayFilter.createDisabledImage(img));
 }
示例#4
0
  /**
   * This method returns the disabled icon. The disabled icon is painted when the label is disabled.
   * If the disabled icon is null and the active icon is an ImageIcon, this method returns a grayed
   * version of the icon. The grayed version of the icon becomes the disabledIcon.
   *
   * @return The disabled icon.
   */
  public Icon getDisabledIcon() {
    if (disabledIcon == null && icon instanceof ImageIcon)
      disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));

    return disabledIcon;
  }
 private static Icon generateDisabledIcon(Icon icon) {
   return new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));
 }