当前位置: 首页>>代码示例>>Java>>正文


Java GrayFilter类代码示例

本文整理汇总了Java中javax.swing.GrayFilter的典型用法代码示例。如果您正苦于以下问题:Java GrayFilter类的具体用法?Java GrayFilter怎么用?Java GrayFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GrayFilter类属于javax.swing包,在下文中一共展示了GrayFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BiFeatureNode.java

示例2: getDisabledIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
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];
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:27,代码来源:Icons.java

示例3: getGrayedImage

import javax.swing.GrayFilter; //导入依赖的package包/类
@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;
}
 
开发者ID:icza,项目名称:scelight,代码行数:24,代码来源:LRIcon.java

示例4: getDisabledIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:friedlwo,项目名称:AppWoksUtils,代码行数:26,代码来源:ImageProvider.java

示例5: getGreyscaleIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
/**
 *
 *
 * @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;
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:22,代码来源:GUITemplate.java

示例6: getIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:BiNode.java

示例7: getOpenedIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
@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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:BiNode.java

示例8: getDisabledIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:NimbusLookAndFeel.java

示例9: testMRDisabledImage

import javax.swing.GrayFilter; //导入依赖的package包/类
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");
        }

    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:MultiResolutionDisabledImageTest.java

示例10: createDisabledIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
/** 
 * Create a disabled icon using a gray filter.
 */
public static Icon createDisabledIcon(ImageIcon imageIcon) {
    Image i =
        GrayFilter.createDisabledImage(
            imageIcon.getImage() );

    return new ImageIcon(i);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:11,代码来源:Utility.java

示例11: drawImageToGrid

import javax.swing.GrayFilter; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:jordanywhite,项目名称:SquaresInteractive,代码行数:45,代码来源:SquintGUI.java

示例12: getDisabledIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:javachen,项目名称:IBMDataMovementTool,代码行数:36,代码来源:RGBGrayFilter.java

示例13: disabledIcon

import javax.swing.GrayFilter; //导入依赖的package包/类
private static Icon disabledIcon(Icon icon) {
    return new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon)icon).getImage()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:Utils.java

示例14: init

import javax.swing.GrayFilter; //导入依赖的package包/类
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();
		}

	}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:78,代码来源:Art.java

示例15: createGhostImage

import javax.swing.GrayFilter; //导入依赖的package包/类
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);
}
 
开发者ID:WorldGrower,项目名称:WorldGrower,代码行数:7,代码来源:ImageInfoReader.java


注:本文中的javax.swing.GrayFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。