Java 类javax.swing.GrayFilter 实例源码

项目:incubator-netbeans    文件:BiFeatureNode.java   
@Override
public java.awt.Image getIcon( int type ){        
    if( biFeature instanceof BiFeature.Descriptor  && biAnalyser.isNullDescriptor() ) {
        //setIconBase( biFeature.getIconBase(true));
        return GrayFilter.createDisabledImage(super.getIcon(type));
    }
    if( ( biFeature instanceof BiFeature.Property || biFeature instanceof BiFeature.IdxProperty ) && biAnalyser.isNullProperties() ) {
        //setIconBase( biFeature.getIconBase(true));
        return GrayFilter.createDisabledImage(super.getIcon(type));
    }
    if( biFeature instanceof BiFeature.EventSet && biAnalyser.isNullEventSets() ) {
        //setIconBase( biFeature.getIconBase(true));
        return GrayFilter.createDisabledImage(super.getIcon(type));
    }
    if( biFeature instanceof BiFeature.Method && biAnalyser.isNullMethods() ) {
        //setIconBase( biFeature.getIconBase(true));
        return GrayFilter.createDisabledImage(super.getIcon(type));
    }
    //setIconBase( biFeature.getIconBase(false));
    return super.getIcon(type);
}
项目:geomapapp    文件:Icons.java   
public static XBIcon getDisabledIcon(int which, boolean selected) {
    if( which<0 || which>=disIcons.length ) return getDefaultIcon(selected);
    int i = selected ? 1 : 0;
    if( disIcons[which][i]!=null )return disIcons[which][i];
    int i1 = (i+1)%2;
    if( disIcons[which][i1]!=null ) {
        disIcons[which][i] = new XBIcon(disIcons[which][i1].getImage(), selected);
        return disIcons[which][i];
    }

    try {
        if( loader==null ) {
            loader = org.geomapapp.util.Icons.class.getClassLoader();
        }
        String path = "org/geomapapp/resources/icons/" +names[which];
        java.net.URL url = loader.getResource(path);
        BufferedImage im = ImageIO.read(url);
        Image im1 = GrayFilter.createDisabledImage(im);
        Graphics g = im.createGraphics();
        g.drawImage(im1,0,0, new JPanel() );
        disIcons[which][i] = new XBIcon(im, selected);
    } catch(Exception ex) {
        return getDefaultIcon(selected);
    }
    return disIcons[which][i];
}
项目:scelight    文件:LRIcon.java   
@Override
public Image getGrayedImage( final boolean cache ) {
    Image grayedImage = this.grayedImage;
    if ( grayedImage == null ) {
        grayedImage = GrayFilter.createDisabledImage( get( cache ).getImage() );
        if ( cache )
            this.grayedImage = grayedImage;

        // The Java image API uses asynchronous image processing, wait for the grayed image to complete
        // in order to avoid empty images being displayed!
        final int id = ID_GENERATOR.getAndIncrement();
        MEDIA_TRACKER.addImage( grayedImage, id );
        try {
            MEDIA_TRACKER.waitForID( id );
        } catch ( final InterruptedException ie ) {
            LEnv.LOGGER.warning( "Image conversion (graying) interrupted!", ie );
        } finally {
            MEDIA_TRACKER.removeImage( grayedImage, id );
        }
    }

    return grayedImage;
}
项目:AppWoksUtils    文件:ImageProvider.java   
/**
 * Uses the uimanager to get a grayscaled disabled Icon
 * 
 * @param icon
 * @return
 */
public static Icon getDisabledIcon(Icon icon) {
    if (icon == null) { return null; }
    synchronized (ImageProvider.LOCK) {
        final MinTimeWeakReference<Icon> cache = ImageProvider.DISABLED_ICON_CACHE.get(icon);
        Icon ret = cache == null ? null : cache.get();
        if (ret != null) {
            //
            return ret;
        }
        if (!(icon instanceof ImageIcon)) {
            // getDisabledIcon only works for imageicons
            icon = ImageProvider.toImageIcon(icon);
        }
        ret = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));

        ImageProvider.DISABLED_ICON_CACHE.put(icon, new MinTimeWeakReference<Icon>(ret, ImageProvider.MIN_LIFETIME, "disabled icon"));
        return ret;
    }
}
项目:OCRaptor    文件:GUITemplate.java   
/**
 *
 *
 * @param icon
 * @return
 */
protected javafx.scene.image.Image getGreyscaleIcon(Icon icon) {
  javafx.scene.image.Image fxImage = null;
  try {
    BufferedImage bf = ImageIO.read(this.getClass().getResource(icon.getFileName()));

    ImageFilter filter = new GrayFilter(true, 70);
    ImageProducer producer = new FilteredImageSource(bf.getSource(), filter);
    Image mage = Toolkit.getDefaultToolkit().createImage(producer);
    fxImage = createImage(mage);
  } catch (Exception e) {
    // TODO: logging
    e.printStackTrace();
  }
  return fxImage;
}
项目:incubator-netbeans    文件:BiNode.java   
@Override
public java.awt.Image getIcon( int type ){
    if( key == BiFeature.Descriptor.class && biAnalyser.isNullDescriptor() )
        return GrayFilter.createDisabledImage(super.getIcon(type));
    if( key == BiFeature.Property.class && biAnalyser.isNullProperties() )
        return GrayFilter.createDisabledImage(super.getIcon(type));
    if( key == BiFeature.EventSet.class && biAnalyser.isNullEventSets() )
        return GrayFilter.createDisabledImage(super.getIcon(type));
    if( key == BiFeature.Method.class && biAnalyser.isNullMethods() )
        return GrayFilter.createDisabledImage(super.getIcon(type));

    return super.getIcon(type);
}
项目:incubator-netbeans    文件:BiNode.java   
@Override
public java.awt.Image getOpenedIcon( int type ){
    if( key == BiFeature.Descriptor.class && biAnalyser.isNullDescriptor() )
        return GrayFilter.createDisabledImage(super.getIcon(type));
    if( key == BiFeature.Property.class && biAnalyser.isNullProperties() )
        return GrayFilter.createDisabledImage(super.getIcon(type));
    if( key == BiFeature.EventSet.class && biAnalyser.isNullEventSets() )
        return GrayFilter.createDisabledImage(super.getIcon(type));
    if( key == BiFeature.Method.class && biAnalyser.isNullMethods() )
        return GrayFilter.createDisabledImage(super.getIcon(type));

    return super.getOpenedIcon(type);
}
项目:OpenJSharp    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:jdk8u-jdk    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:openjdk-jdk10    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:openjdk-jdk10    文件:MultiResolutionDisabledImageTest.java   
private static void testMRDisabledImage(Image image) throws Exception {

        Image disabledImage = GrayFilter.createDisabledImage(image);
        MediaTracker mediaTracker = new MediaTracker(new JLabel());
        mediaTracker.addImage(disabledImage, 0);
        mediaTracker.waitForID(0);

        BufferedImage buffImage = new BufferedImage(IMAGE_SIZE,
                                                    IMAGE_SIZE,
                                                    BufferedImage.TYPE_INT_RGB);

        int x = IMAGE_SIZE / 2;
        int y = IMAGE_SIZE / 2;

        Graphics2D g = buffImage.createGraphics();

        g.scale(1, 1);
        g.drawImage(disabledImage, 0, 0, null);
        int rgb1x = buffImage.getRGB(x, y);

        g.scale(2, 2);
        g.drawImage(disabledImage, 0, 0, null);
        int rgb2x = buffImage.getRGB(x, y);

        g.dispose();

        if (rgb1x == rgb2x) {
            throw new RuntimeException("Disabled image is the same for the base"
                    + "image and the resolution variant");
        }

    }
项目:openjdk9    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:Java8CN    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:fmj-sourceforge-mirror    文件:Utility.java   
/** 
 * Create a disabled icon using a gray filter.
 */
public static Icon createDisabledIcon(ImageIcon imageIcon) {
    Image i =
        GrayFilter.createDisabledImage(
            imageIcon.getImage() );

    return new ImageIcon(i);
}
项目:jdk8u_jdk    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:jdk8u_jdk    文件:MultiResolutionDisabledImageTest.java   
private static void testMRDisabledImage(Image image) throws Exception {

        Image disabledImage = GrayFilter.createDisabledImage(image);
        MediaTracker mediaTracker = new MediaTracker(new JLabel());
        mediaTracker.addImage(disabledImage, 0);
        mediaTracker.waitForID(0);

        BufferedImage buffImage = new BufferedImage(IMAGE_SIZE,
                                                    IMAGE_SIZE,
                                                    BufferedImage.TYPE_INT_RGB);

        int x = IMAGE_SIZE / 2;
        int y = IMAGE_SIZE / 2;

        Graphics2D g = buffImage.createGraphics();

        g.scale(1, 1);
        g.drawImage(disabledImage, 0, 0, null);
        int rgb1x = buffImage.getRGB(x, y);

        g.scale(2, 2);
        g.drawImage(disabledImage, 0, 0, null);
        int rgb2x = buffImage.getRGB(x, y);

        g.dispose();

        if (rgb1x == rgb2x) {
            throw new RuntimeException("Disabled image is the same for the base"
                    + "image and the resolution variant");
        }

    }
项目:lookaside_java-1.8.0-openjdk    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:SquaresInteractive    文件:SquintGUI.java   
/**
 * Draw an image onto the room
 * 
 * @param imageFile     The path to the image file
 * @param x_coord       the x coordinate of the top left corner where the image should be drawn (it is drawn from there to the bottom right)
 * @param y_coord       the y coordinate of the top left corner where the image should be drawn
 * @param g             the graphics object that we are drawing the image onto
 * @param isShading     whether or not the image is being used to add shading
 * @param scaleImage    whether or not to scale the image to fit inside a tile dimension (used to make scale player avatars)
 */
private void drawImageToGrid(File imageFile, int x_coord, int y_coord, Graphics g, boolean isShading, boolean scaleImage) {
    Image img = null;
    BufferedImage bimg = null;  // Used if the image needs to be scaled
    try {
        img = ImageIO.read(imageFile);
        bimg = ImageIO.read(imageFile);
    } catch (IOException e) {
        e.printStackTrace();
        System.out.println("Failed to read image file");
    }
    if (img == null) {
        return;
    }
    if (isShading) {            
        // Go through each shade level, represented by a unique color, and
        // replace the color with a specified opacity level
        Color shadeLevelOneColor = new Color(0x000000);
        Color shadeLevelTwoColor = new Color(0x7F007F);
        Color shadeLevelThreeColor = new Color(0xff00ff);
        img = Transparency.makeColorTransparent(img, shadeLevelOneColor, 0x65);
        img = Transparency.makeColorTransparent(img, shadeLevelTwoColor, 0x40);
        img = Transparency.makeColorTransparent(img, shadeLevelThreeColor, 0x20);
        // Once all colors have had their opacity modified, convert the image to a black grayscale
        ImageFilter filter = new GrayFilter(true, 0);  
        ImageProducer producer = new FilteredImageSource(img.getSource(), filter);  
        img = Toolkit.getDefaultToolkit().createImage(producer);  
    }
    if (scaleImage) {
        Dimension scaledSize = ImageEditor.getScaledDimension(new Dimension(bimg.getWidth(), bimg.getHeight()), new Dimension(MAP_DIM, MAP_DIM), true);
        img = resizeToBig(img, scaledSize.width, scaledSize.height);
    }
    Graphics2D g2d = (Graphics2D) g;
    g2d.drawImage(img, x_coord, y_coord, null);
}
项目:infobip-open-jdk-8    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:jdk8u-dev-jdk    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:jdk7-jdk    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:openjdk-source-code-learn    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:OLD-OpenJDK8    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:openjdk-jdk7u-jdk    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:IBMDataMovementTool    文件:RGBGrayFilter.java   
/**
 * Returns an icon with a disabled appearance. This method is used
 * to generate a disabled icon when one has not been specified.
 *
 * @param component the component that will display the icon, may be null.
 * @param icon the icon to generate disabled icon from.
 * @return disabled icon, or null if a suitable icon can not be generated.
 */
public static Icon getDisabledIcon(JComponent component, Icon icon) {
    if (   (icon == null)
        || (component == null)
        || (icon.getIconWidth() == 0)
        || (icon.getIconHeight() == 0)) {
        return null;
    }
    Image img;
    if (icon instanceof ImageIcon) {
        img = ((ImageIcon) icon).getImage();
    } else {
        img = new BufferedImage(
                icon.getIconWidth(),
                icon.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
        icon.paintIcon(component, img.getGraphics(), 0, 0);
    }
    if (   !Options.isHiResGrayFilterEnabled()
        || (Boolean.FALSE.equals(component.getClientProperty(Options.HI_RES_DISABLED_ICON_CLIENT_KEY)))) {
        return new ImageIcon(GrayFilter.createDisabledImage(img));
    }

    ImageProducer producer =
        new FilteredImageSource(img.getSource(), new RGBGrayFilter());

    return new ImageIcon(component.createImage(producer));
}
项目:openjdk-icedtea7    文件:NimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:JRLib    文件:OpaqueNimbusLookAndFeel.java   
@Override
public Icon getDisabledIcon(JComponent component, Icon icon) {
    if (icon instanceof SynthIcon) {
        SynthIcon si = (SynthIcon)icon;
        BufferedImage img = EffectUtils.createCompatibleTranslucentImage(
                si.getIconWidth(), si.getIconHeight());
        Graphics2D gfx = img.createGraphics();
        si.paintIcon(component, gfx, 0, 0);
        gfx.dispose();
        return new ImageIconUIResource(GrayFilter.createDisabledImage(img));
    } else {
        return super.getDisabledIcon(component, icon);
    }
}
项目:incubator-netbeans    文件:Utils.java   
private static Icon disabledIcon(Icon icon) {
    return new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon)icon).getImage()));
}
项目:incubator-netbeans    文件:ProjectsSelector.java   
private static Icon disabledIcon(Icon icon) {
    return new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon)icon).getImage()));
}
项目:BrainControl    文件:Art.java   
public static void init(GraphicsConfiguration gc) {
        try 
        {           
            //System.out.println("Image Directory: " + img);
            // System.out.println(curDir);

            level = cutImage(gc, "mapsheet.png", 16, 16);           //level graphics
            bg = cutImage(gc, "bgsheet.png", 520, 256);             //background graphics
            //map = cutImage(gc, "worldmap.png", 16, 16);               //TODO: obsolete graphics?
            enemies = cutImage(gc, "enemysheet.png", 16, 32);
            items = cutImage(gc, "itemsheet.png", 16, 16);
            particles = cutImage(gc, "particlesheet.png", 8, 8);
            waiting = cutImage(gc, "gearsSmall.png", 16,16);

//          play = cutImage(gc, "play128.png",16,16);
//          pause = cutImage(gc, "pause128.png",16,16);
            //logo = getImage(gc, "logo.gif");
            //titleScreen = getImage(gc, "title.gif");
            //font = cutImage(gc, "font.gif", 8, 8);
            //endScene = cutImage(gc, "endscene.gif", 96, 96);
            //gameOver = cutImage(gc, "gameovergost.gif", 96, 64);

            camera = cutImage(gc, "camera.png", 50, 50);
            computer = cutImage(gc, "computer.png", 50, 50);
            microphone = cutImage(gc, "microphone.png", 50, 50);
            dreamCatcher = cutImage(gc, "dreamCatcherSmall.png", 50, 50);
            Maria = cutImage(gc, "Maria_M_Enditem.png", 50, 50);

            cursor = cutImage(gc, "cursor.png", 20, 20);

            clark = cutImage(gc, "clark_sheet.png", 32, 32);
            smallClark = cutImage(gc, "clark_small_sheet.png", 32, 32);
            bulbClark = cutImage(gc, "clark_bulb_sheet.png", 32, 32);

            jay = cutImage(gc, "jay_sheet.png", 32, 32);
            smallJay = cutImage(gc, "jay_small_sheet.png", 32, 32);
            bulbJay = cutImage(gc, "jay_bulb_sheet.png", 32, 32);           

            peter = cutImage(gc, "peter_sheet.png", 32, 32);
            smallPeter = cutImage(gc, "peter_small_sheet.png", 32, 32);
            bulbPeter = cutImage(gc, "peter_bulb_sheet.png", 32, 32);

            bruce = cutImage(gc, "bruce_sheet.png", 32, 32);
            smallBruce = cutImage(gc, "bruce_small_sheet.png", 32, 32);
            bulbBruce = cutImage(gc, "bruce_bulb_sheet.png", 32, 32);


            String path = ResourceStream.DIR_WORLD_RESOURCES+"/engine/resources/play32.png";
            play = ImageIO.read(ResourceStream.getResourceStream(path));
//          play = createResizedCopy(img,24, 24, true);
            path =  ResourceStream.DIR_WORLD_RESOURCES+"/engine/resources/pause32.png";
            pause = ImageIO.read(ResourceStream.getResourceStream(path));

            path =  ResourceStream.DIR_WORLD_RESOURCES+"/engine/resources/speaker32.png";
            speaker = ImageIO.read(ResourceStream.getResourceStream(path));

            path =  ResourceStream.DIR_WORLD_RESOURCES+"/engine/resources/mute32.png";
            mute = ImageIO.read(ResourceStream.getResourceStream(path));

            health = getImage(gc, "health.png");
            grayHealth = GrayFilter.createDisabledImage(health);
            curiosity = getImage(gc, "curiosity.png");
            grayCuriosity = GrayFilter.createDisabledImage(curiosity);
            progress = getImage(gc, "progress.png");
            grayProgress = GrayFilter.createDisabledImage(progress);
            energy = getImage(gc, "energy.png");
            grayEnergy = GrayFilter.createDisabledImage(energy);


            System.out.println("Done loading arts");
        } 
        catch (Exception e) 
        {
            e.printStackTrace();
        }

    }
项目:WorldGrower    文件:ImageInfoReader.java   
private BufferedImage createGhostImage(Image image) {
    ImageFilter filter = new GrayFilter(true, 50);  
    ImageProducer producer = new FilteredImageSource(image.getSource(), filter);  
    Image toolkitImage = Toolkit.getDefaultToolkit().createImage(producer);  
    return ImageUtils.toBufferedImage(toolkitImage);
}
项目:birt    文件:ImageUtil.java   
public static Image compare(BufferedImage golden, BufferedImage actual, Map<ImageCompParam, Integer> p) {

        Map<ImageCompParam, Integer> params = mergeDefaultCompParams(p);

        // prepare image for indicating potential mismatched blocks
        BufferedImage noMatch = imageToBufferedImage(actual);
        Graphics2D gc = noMatch.createGraphics();
        gc.setColor(Color.RED);

        // convert to gray images
        golden = imageToBufferedImage(GrayFilter.createDisabledImage(golden));
        actual = imageToBufferedImage(GrayFilter.createDisabledImage(actual));

        // get block size
        int goldenBlockXSize = (int)(golden.getWidth() / params.get(ImageCompParam.XBLOCKS));
        int goldenBlockYSize = (int)(golden.getHeight() / params.get(ImageCompParam.YBLOCKS));
        int actualBlockXSize = (int)(actual.getWidth() / params.get(ImageCompParam.XBLOCKS));
        int actualBlockYSize = (int)(actual.getHeight() / params.get(ImageCompParam.YBLOCKS));

        boolean match = true;

        // traverse and compare respective blocks of both images
        for (int y = 0; y < params.get(ImageCompParam.YBLOCKS); y++) {
            if (params.get(ImageCompParam.DEBUG) > 0) System.out.print("|");
            for (int x = 0; x < params.get(ImageCompParam.XBLOCKS); x++) {
                int goldenBrightness = getAverageBrightness(golden.getSubimage(x*goldenBlockXSize, y*goldenBlockYSize, goldenBlockXSize - 1, goldenBlockYSize - 1), params);
                int actualBrightness = getAverageBrightness(actual.getSubimage(x*actualBlockXSize, y*actualBlockYSize, actualBlockXSize - 1, actualBlockYSize - 1), params);
                int diff = Math.abs(goldenBrightness - actualBrightness);
                if (diff > params.get(ImageCompParam.TOLERANCE)) {
                    // the difference in a certain region has passed the threshold value
                    // draw an indicator on the change image to show where the change was detected
                    gc.drawRect(x*actualBlockXSize, y*actualBlockYSize, actualBlockXSize - 1, actualBlockYSize - 1);
                    match = false;
                }
                if (params.get(ImageCompParam.DEBUG) == 1) System.out.print((diff > params.get(ImageCompParam.TOLERANCE) ? "X" : " "));
                if (params.get(ImageCompParam.DEBUG) == 2) System.out.print(diff + (x < params.get(ImageCompParam.XBLOCKS) - 1 ? "," : ""));
            }
            if (params.get(ImageCompParam.DEBUG) > 0) System.out.println("|");
        }

        return match ? null : noMatch;
    }
项目:spring-rich-client    文件:ShadowedIcon.java   
public ShadowedIcon(Icon icon) {
    this.icon = icon;
    shadow = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));
}
项目:spring-richclient    文件:ShadowedIcon.java   
public ShadowedIcon(Icon icon) {
    this.icon = icon;
    shadow = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon).getImage()));
}
项目:NAMControllerCompiler    文件:MyCheckTreeCellRenderer.java   
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus){
        Component renderer = delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
        PatternNode visibleNode = ((PatternNode) value);

        AbstractButton button = checkBox;
        TreePath path = tree.getPathForRow(row); 
        if(path!=null) {
            TristateButtonModel tristateModel = checkBox.getTristateModel();
            /*
             * Important! Only the GUI reverses the selection logic, which means
             * that a visible selected check box actually represents an
             * unselected check box, whereas an unselected check box stands for
             * a selected one. Indeterminate stays indeterminate. This is a hack
             * to avoid recoding of the entire model, but may be cleaned up in
             * the future.
             */
            if(selectionModel.isPathSelected(path)) {
//              tristateModel.setSelected(true);
                tristateModel.setSelected(false);
            } else if (selectionModel.isPartiallySelected(path)) {
                tristateModel.setIndeterminate();
                button = radioButton;
            } else {
//                tristateModel.setSelected(false); 
                tristateModel.setSelected(true); 
            }
        } 
        removeAll();

        button.setEnabled(enabledDisabledButtons || !visibleNode.isDisabled());
        renderer.setEnabled(enabledDisabledButtons || !visibleNode.isDisabled());
        if (visibleNode.isDisabled()) {
            JLabel label = (JLabel) renderer;
            Icon icon = label.getIcon();
            Icon disabledIcon;
            // only set disabled icon, if icon is not null
            if (icon != null) {
                if (disabledIconsMap.containsKey(icon)) {
                    disabledIcon = disabledIconsMap.get(icon);
                } else {
                    Image img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
                    icon.paintIcon(new JPanel(), img.getGraphics(), 0, 0);
                    disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(img));
                    disabledIconsMap.put(icon, disabledIcon);
                }
                label.setDisabledIcon(disabledIcon);
            }
        }
        add(button, BorderLayout.WEST);
        add(renderer, BorderLayout.CENTER);
        return this; 
    }
项目:rapidminer    文件:ScaledImageIcon.java   
/**
 * Creates a grayed out version of this icon.
 *
 * @return the disabled icon
 */
public ScaledImageIcon createDisabledIcon() {
    Image grayImage = GrayFilter.createDisabledImage(super.getImage());
    return new ScaledImageIcon(grayImage, height, width);
}
项目:rapidminer-studio    文件:ScaledImageIcon.java   
/**
 * Creates a grayed out version of this icon.
 *
 * @return the disabled icon
 */
public ScaledImageIcon createDisabledIcon() {
    Image grayImage = GrayFilter.createDisabledImage(super.getImage());
    return new ScaledImageIcon(grayImage, height, width);
}