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


Java MediaTracker.waitForAll方法代码示例

本文整理汇总了Java中java.awt.MediaTracker.waitForAll方法的典型用法代码示例。如果您正苦于以下问题:Java MediaTracker.waitForAll方法的具体用法?Java MediaTracker.waitForAll怎么用?Java MediaTracker.waitForAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.MediaTracker的用法示例。


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

示例1: convertToBufferedImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
private BufferedImage convertToBufferedImage(Image image) throws IOException {
    if (image instanceof BufferedImage) {
        return (BufferedImage)image;

    } else {
        MediaTracker tracker = new MediaTracker(new Component(){}); // not sure if this is the right thing to do.
        tracker.addImage(image, 0);
        try {
            tracker.waitForAll();
        } catch (InterruptedException e) {
            throw new IOException(e.getMessage());
        }
        BufferedImage bufImage = new BufferedImage(
                image.getWidth(null),
                image.getHeight(null),
                BufferedImage.TYPE_INT_ARGB);

        Graphics g = bufImage.createGraphics();
        g.drawImage(image, 0, 0, null);
        return bufImage;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:RuntimeBuiltinLeafInfoImpl.java

示例2: fetchImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
public Image fetchImage( URL imageLocation ) throws IOException {
    Image image = null;
    try {
        if ( imageLocation == null ) {
            throw new IOException( "Image resource not found: Null imagelocation URL" );
        }
        else {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            image = toolkit.createImage( imageLocation );
            MediaTracker tracker = new MediaTracker( this );
            tracker.addImage( image, 0 );
            tracker.waitForAll();
        }
    }
    catch ( InterruptedException e ) {
    }
    return image;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:ImageLoader.java

示例3: getImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
/**
 * Get Image from path provided
 *
 * @param url location of the image
 * @return the Image file
 */
public Image getImage(URL url) {
	try {
		MediaTracker tracker = new MediaTracker(this);
		
		Image image = super.getImage(url);

		// wait for image to load
		tracker.addImage(image, 0);
        tracker.waitForAll();

        // if no errors return image
        if (!tracker.isErrorAny()) {
        	return image;
        }
	} catch (Exception e) {
		/* */
	}
	
	return null;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:AppletLoader.java

示例4: Splash

import java.awt.MediaTracker; //导入方法依赖的package包/类
public Splash(Frame parent, String imagefilename, boolean dialog)
   {
if (dialog)
    {
               m_window = new MyDialog(parent);
    }
else
    {
               m_window = new MyWindow(parent);
    }
javax.swing.ImageIcon icon = new javax.swing.ImageIcon(getClass().getResource(imagefilename));
m_splashImage = icon.getImage();
MediaTracker loader = new MediaTracker(m_window);
loader.addImage(m_splashImage, 0);
try { 
           loader.waitForAll(); 
} catch (Exception e) {}
   }
 
开发者ID:BisonSchweizAG,项目名称:JSmooth,代码行数:19,代码来源:Splash.java

示例5: loadImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
/**
 * Asks the user to select an image and then it loads it up into an Image
 * object and returns it to the calling class.
 *
 * @return java.awt.Image img the loaded image
 */
private static Image loadImage() {
  System.out.println("Select the map");
  final String mapName = new FileOpen("Select The Map", mapFolderLocation, ".gif", ".png").getPathString();
  if (mapName != null) {
    final Image img = Toolkit.getDefaultToolkit().createImage(mapName);
    final MediaTracker tracker = new MediaTracker(new Panel());
    tracker.addImage(img, 1);
    try {
      tracker.waitForAll();
      return img;
    } catch (final InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  return null;
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:23,代码来源:ReliefImageBreaker.java

示例6: loadImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
/**
 * java.awt.Image loadImage()
 * Asks the user to select an image and then it loads it up into an Image
 * object and returns it to the calling class.
 *
 * @return java.awt.Image img the loaded image
 */
private static Image loadImage() {
  System.out.println("Select the map");
  final String mapName = new FileOpen("Select The Map", mapFolderLocation, ".gif", ".png").getPathString();
  if (mapName != null) {
    final Image img = Toolkit.getDefaultToolkit().createImage(mapName);
    final MediaTracker tracker = new MediaTracker(new Panel());
    tracker.addImage(img, 1);
    try {
      tracker.waitForAll();
      return img;
    } catch (final InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  return null;
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:24,代码来源:TileImageBreaker.java

示例7: CustomButton

import java.awt.MediaTracker; //导入方法依赖的package包/类
/**
 * Instantiates a new custom button.
 * 
 * @param toolTip
 *            the message that is displayed when hovering over the button
 *            with the mouse.
 * @param pathToDefaultImage
 *            the path to image representing the unpressed state of the
 *            button.
 * @param pathToPressedImage
 *            the path to image representing the pressed state of the
 *            button.
 * @param actionCommand
 *            the action command
 */
public CustomButton(String toolTip, String pathToDefaultImage, String pathToPressedImage, String actionCommand) {
	super();
	this.setToolTipText(toolTip);
	URL urlDefault = Main.class.getResource(pathToDefaultImage);
	URL urlPressed = Main.class.getResource(pathToPressedImage);

	this.imgDefault = null;
	this.imgPressed = null;
	Toolkit tk = Toolkit.getDefaultToolkit();
	try {
		MediaTracker m = new MediaTracker(this);
		this.imgDefault = tk.getImage(urlDefault);
		m.addImage(this.imgDefault, 0);
		this.imgPressed = tk.getImage(urlPressed);
		m.addImage(this.imgPressed, 0);
		m.waitForAll();
	} catch (Exception e) {
		e.printStackTrace();
	}

	// }
	this.setActionCommand(actionCommand);
	this.setLayout(new GridLayout(1, 1));
	this.setPreferredSize(new Dimension(imgDefault.getWidth(this), imgDefault.getHeight(this)));
}
 
开发者ID:enguerrand,项目名称:xdat,代码行数:41,代码来源:CustomButton.java

示例8: makeBackgroundImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
public static JLabel makeBackgroundImage(Graphwar graphwar, BufferedReader read) throws InterruptedException, IOException
{
	MediaTracker tracker = new MediaTracker(graphwar);
	
	Image image = ImageIO.read(graphwar.getClass().getResource(GraphUtil.nextLine(read)));	
	tracker.addImage(image, 0);		
	tracker.waitForAll();		
	
	int x = Integer.parseInt(GraphUtil.nextLine(read));
	int y = Integer.parseInt(GraphUtil.nextLine(read));
	
	JLabel imagePanel = new JLabel(new ImageIcon(image));
	imagePanel.setBounds(x, y, image.getWidth(null), image.getHeight(null));
	
	return imagePanel;
	
}
 
开发者ID:catabriga,项目名称:graphwar,代码行数:18,代码来源:GraphUtil.java

示例9: makeButton

import java.awt.MediaTracker; //导入方法依赖的package包/类
public static GraphButton makeButton(Graphwar graphwar, BufferedReader read) throws InterruptedException, IOException
{
	MediaTracker tracker = new MediaTracker(graphwar);
	
	Image normal = ImageIO.read(graphwar.getClass().getResource(GraphUtil.nextLine(read)));
	tracker.addImage(normal, 0);
	Image over = ImageIO.read(graphwar.getClass().getResource(GraphUtil.nextLine(read)));
	tracker.addImage(over, 1);
	Image tempImg = ImageIO.read(graphwar.getClass().getResource(GraphUtil.nextLine(read)));
	tracker.addImage(tempImg, 2);
	tracker.waitForAll();
	
	
	BufferedImage mask = new BufferedImage(tempImg.getWidth(null), tempImg.getHeight(null), BufferedImage.TYPE_3BYTE_BGR);			
	mask.getGraphics().drawImage(tempImg, 0, 0, null);
	
	int x = Integer.parseInt(GraphUtil.nextLine(read));
	int y = Integer.parseInt(GraphUtil.nextLine(read));
			
	GraphButton graphButton = new GraphButton(normal, over, mask);
	graphButton.setBounds(x, y, normal.getWidth(null), normal.getWidth(null));
	
	return graphButton;
}
 
开发者ID:catabriga,项目名称:graphwar,代码行数:25,代码来源:GraphUtil.java

示例10: startSplashScreen

import java.awt.MediaTracker; //导入方法依赖的package包/类
public static void startSplashScreen() {
        int width = 275, height = 148;
        Window win = new Window(new Frame());
        win.pack();
        BshCanvas can = new BshCanvas();
        can.setSize(width, height); // why is this necessary?
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension dim = tk.getScreenSize();
        win.setBounds(dim.width / 2 - width / 2, dim.height / 2 - height / 2, width, height);
        win.add("Center", can);
        Image img = tk.getImage(Interpreter.class.getResource("/bsh/util/lib/splash.gif"));
        MediaTracker mt = new MediaTracker(can);
        mt.addImage(img, 0);
        try {
                mt.waitForAll();
        } catch (Exception e) {
        }
        Graphics gr = can.getBufferedGraphics();
        gr.drawImage(img, 0, 0, can);
        win.setVisible(true);
        win.toFront();
        splashScreen = win;
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:24,代码来源:Util.java

示例11: startSplashScreen

import java.awt.MediaTracker; //导入方法依赖的package包/类
public static void startSplashScreen()
    {
        Image img = getIcon("beast/app/draw/icons/beauti.png").getImage();
        int width=2 * img.getWidth(null), height=img.getHeight(null);
        Window win=new Window( new Frame() );
        win.pack();
        can = new Canvas();
        can.setSize( width, height ); // why is this necessary?
        Toolkit tk=Toolkit.getDefaultToolkit();
        Dimension dim=tk.getScreenSize();
        win.setBounds(
                dim.width/2-width/2, dim.height/2-height/2, width, height );
        win.add("Center", can);
//        Image img=tk.getImage(
//                Utils.class.getResource("beast.png") ); //what
        MediaTracker mt=new MediaTracker(can);
        mt.addImage(img,0);
        try { mt.waitForAll(); } catch ( Exception e ) { }
        Graphics gr=can.getBufferedGraphics();
        gr.drawImage(img, width / 4, 0, can);
        win.setVisible(true);
        win.toFront();
        splashScreen = win;
    }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:25,代码来源:Utils6.java

示例12: DirectSprite

import java.awt.MediaTracker; //导入方法依赖的package包/类
public DirectSprite(byte[] data, Component component) {
	try {
		Image image = Toolkit.getDefaultToolkit().createImage(data);
		MediaTracker mediaTracker = new MediaTracker(component);
		mediaTracker.addImage(image, 0);
		mediaTracker.waitForAll();
		width = image.getWidth(component);
		height = image.getHeight(component);
		resizeWidth = width;
		resizeHeight = height;
		horizontalOffset = 0;
		verticalOffset = 0;
		raster = new int[width * height];
		PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, height, raster, 0, width);
		grabber.grabPixels();
	} catch (Exception ex) {
		System.out.println("Error converting jpg");
	}
}
 
开发者ID:atomicint,项目名称:aj8,代码行数:20,代码来源:DirectSprite.java

示例13: decodeImage

import java.awt.MediaTracker; //导入方法依赖的package包/类
private void decodeImage(String name) throws InterruptedException {
	final Image im = createImage(name);
	final BufferedImage bim = new BufferedImage(EXP_WIDTH, EXP_HEIGHT,
			BufferedImage.TYPE_INT_RGB);
	final Frame f = new Frame();
	final MediaTracker t = new MediaTracker(f);

	t.addImage(im, 0);
	t.waitForAll();

	assertEquals(EXP_WIDTH, im.getWidth(null));
	assertEquals(EXP_HEIGHT, im.getHeight(null));

	bim.getGraphics().drawImage(im, 0, 0, null);
	int rgbVal = bim.getRGB(0, 0);
	assertEquals(0xFFFFFFFF, rgbVal);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:BufferedImageTest.java

示例14: prepareImages

import java.awt.MediaTracker; //导入方法依赖的package包/类
public void prepareImages() {
    if (prepared) {
        return;
    }

    MediaTracker mt = new MediaTracker(this);
    for (int i = 0; i < images.length; i++) {
        mt.addImage(images[i], i);
    }
    try {
        mt.waitForAll();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    for (int i = 0; i < images.length; i++) {
        mt.removeImage(images[i], i);
    }

    if (params.scaleFactor != 1) {
        // TODO: scale if needed
        logger.unimplemented("image_scaling");
    }

    prepared = true;
}
 
开发者ID:ShiftMediaProject,项目名称:libbluray,代码行数:26,代码来源:ImageFrameAccurateAnimation.java

示例15: getInstance

import java.awt.MediaTracker; //导入方法依赖的package包/类
public static ImagePainter getInstance(Component component, String name)
/*    */   {
/* 20 */     Toolkit toolkit = component.getToolkit();
/* 21 */     if (toolkit == null) throw new NullPointerException();
/* 22 */     if (toolkit != currentToolkit) cache = new HashMap(5);
/* 23 */     Object cached = cache.get(name);
/* 24 */     if (cached != null) return ((ImagePainter)cached);
/*    */ 
/* 26 */     URL url = ImagePainter.class.getResource(name);
/* 27 */     if (url == null) return new ImagePainter(null);
/* 28 */     Image img = toolkit.createImage(url);
/* 29 */     ImagePainter newPainter = new ImagePainter(img);
/* 30 */     MediaTracker mt = new MediaTracker(component);
/* 31 */     mt.addImage(img, 0);
/*    */     try {
/* 33 */       mt.waitForAll();
/*    */     }
/*    */     catch (InterruptedException e) {
/* 36 */       e.printStackTrace();
/*    */     }
/* 38 */     cache.put(name, newPainter);
/* 39 */     return newPainter;
/*    */   }
 
开发者ID:IMAGINARY,项目名称:morenaments-euc,代码行数:24,代码来源:ImagePainter.java


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