當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaTracker.isErrorID方法代碼示例

本文整理匯總了Java中java.awt.MediaTracker.isErrorID方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaTracker.isErrorID方法的具體用法?Java MediaTracker.isErrorID怎麽用?Java MediaTracker.isErrorID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.MediaTracker的用法示例。


在下文中一共展示了MediaTracker.isErrorID方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import java.awt.MediaTracker; //導入方法依賴的package包/類
public void init() {
    Button b = new Button("Start");
    b.addActionListener(this);
    setLayout(new BorderLayout());
    add(b, BorderLayout.NORTH);
    add(p = new Panel(), BorderLayout.CENTER);
    p.setLayout(null);
    String imgName = getParameter("imagefile");
    if (imgName == null) imgName = "duke.gif";
    img = getImage(getCodeBase(), imgName);
    MediaTracker mt = new MediaTracker(this);
    mt.addImage(img, 0);
    try {
        mt.waitForID(0);
    } catch(InterruptedException e) {
        throw new IllegalArgumentException(
            "InterruptedException while loading image " + imgName);
    }
    if (mt.isErrorID(0)) {
        throw new IllegalArgumentException(
            "Couldn't load image " + imgName);
    }
    v = new Vector<Sprite>(); // multithreaded, use Vector
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:25,代碼來源:Bounce.java

示例2: createSystemImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
public Image createSystemImage(URL url) throws IOException {
	java.awt.Image resultImage = Toolkit.getDefaultToolkit().createImage(url);

	// TODO not elegant solution, maybe use ImageObserver in
	// image.getWitdth(..) instead
	MediaTracker mediaTracker = new MediaTracker(new java.awt.Canvas());
	mediaTracker.addImage(resultImage, 0);
	try {
		mediaTracker.waitForID(0);
	} catch (InterruptedException ex) {
	}
	if (mediaTracker.isErrorID(0)) {
		throw new IOException();
	}

	return new J2SEImmutableImage(resultImage);
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:18,代碼來源:J2SEDeviceDisplay.java

示例3: readImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 * load the image, waiting for it to be fully downloaded
 * 
 * @param fnm
 * @return
 */
private Image readImage(String fnm) {
	Image image = Toolkit.getDefaultToolkit().getImage(
			getClass().getClassLoader().getResource(IMAGE_DIR + fnm));
	MediaTracker imageTracker = new MediaTracker(new JPanel());

	imageTracker.addImage(image, 0);
	try {
		imageTracker.waitForID(0);
	} catch (InterruptedException e) {
		return null;
	}
	if (imageTracker.isErrorID(0))
		return null;
	return image;
}
 
開發者ID:nhydock,項目名稱:revert,代碼行數:22,代碼來源:ImagesLoader.java

示例4: loadImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 * loads the image of this object
 * 
 * @param textField the textField-instance
 * @param location the location to use
 * @return the image if successfull, null otherwise
 */
private Image loadImage(AbstractTextField textField,URL location) {
	Image img = null;
	MediaTracker mt = new MediaTracker(textField);
	try {
		img = Toolkit.getDefaultToolkit().getImage(location);
		
		mt.addImage(img,0);
		mt.waitForAll();
	}
	catch(InterruptedException e) {
		
	}
	
	return mt.isErrorID(0) ? null : img;
}
 
開發者ID:script-solution,項目名稱:BBCodeEditor,代碼行數:23,代碼來源:SecImage.java

示例5: readImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
@Override
public Image readImage(byte[] bytes) throws JRException
{
	Image image = Toolkit.getDefaultToolkit().createImage(bytes);

	MediaTracker tracker = new MediaTracker(new Panel());
	tracker.addImage(image, 0);
	try
	{
		tracker.waitForID(0);
	}
	catch (Exception e)
	{
		//image = null;
		throw new JRException(e);
	}

	if(tracker.isErrorID(0)) 
	{
		throw 
		new JRException(
			EXCEPTION_MESSAGE_KEY_IMAGE_READ_FAILED,
			(Object[])null);
	}

	return image;
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:28,代碼來源:JRJdk13ImageReader.java

示例6: getImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
public Image getImage(String imageSource) {
  try {
    URL sourceURL = new URL(imageSource);
    if (sourceURL.getProtocol().equals("file") &&
        !(new File(sourceURL.getPath())).exists()) {
      ErrorDialog.showError(this, "File not found: " + imageSource);
      return null;
    }
    
    Image other = Toolkit.getDefaultToolkit().createImage(sourceURL);
    MediaTracker tracker = new MediaTracker(this);
    int imageId = 0;
    tracker.addImage(other, imageId);
    
    tracker.waitForID(0);
    boolean isError = tracker.isErrorID(imageId);
    if (isError) {
      ErrorDialog.showError(this, 
          "There were problems reading the background image: " + 
              imageSource);
      return null;
    }
    
    return other;
  } catch (IOException e) {
    throw new OntopiaRuntimeException(e);
  } catch (InterruptedException ie) {
    throw new OntopiaRuntimeException("InterruptedException caused during" +
        " wallpaper_image error check.", ie);
  }
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:32,代碼來源:ExtendedTGPanel.java

示例7: toBufferedImageUsingToolkit

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 * Create image from bytes using AWT toolkit.
 * Seems to be faster than ImageIO... 
 * @param cover image bytes
 * @return buffered image
 */
BufferedImage toBufferedImageUsingToolkit(byte[] bytes) throws IOException {
	if (TOOLKIT == null) {
		return null;
	}
	Image image = TOOLKIT.createImage(bytes);
	MediaTracker mediaTracker = new MediaTracker(new Component() {
		private static final long serialVersionUID = 1L;
	});
	mediaTracker.addImage(image, 0);
	try {
		mediaTracker.waitForID(0, 0);
	} catch (InterruptedException e) {
		return null;
	}
	if (mediaTracker.isErrorID(0)) { // error -> use ImageIO
		throw new IOException("Failed to load toolkit image");
	} else {
		BufferedImage bufferedImage =
				new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
           Graphics2D g2d = bufferedImage.createGraphics();
           g2d.drawImage(image, 0, 0, null);
           g2d.dispose();
           image.flush();
           return bufferedImage;
	}
}
 
開發者ID:beckchr,項目名稱:musicmount,代碼行數:33,代碼來源:AudioInfoAssetParser.java

示例8: load

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
    * Loading an image via a MediaTracker
    * 
    * @param image
    * @throws InterruptedException
    * @throws IOException
    */
   public static void load(Image image) throws InterruptedException,
    IOException {
MediaTracker tracker = new MediaTracker(new Label()); // any component
						      // will do
tracker.addImage(image, 0);
tracker.waitForID(0);
if (tracker.isErrorID(0))
    throw new IOException("error loading image");
   }
 
開發者ID:visit,項目名稱:spark-svn-mirror,代碼行數:17,代碼來源:GraphicUtils.java

示例9: getImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
private Image getImage(InputStream is) throws IOException {
	byte[] imageBytes = new byte[1024];
	int num;
	ByteArrayOutputStream ba = new ByteArrayOutputStream();
	while ((num = is.read(imageBytes)) != -1) {
		ba.write(imageBytes, 0, num);
	}

	java.awt.Image image = Toolkit.getDefaultToolkit().createImage(ba.toByteArray());

	ImageFilter filter = null;
	if (isColor()) {
		if (backgroundColor.getRed() != 255 || backgroundColor.getGreen() != 255
				|| backgroundColor.getBlue() != 255 || foregroundColor.getRed() != 0
				|| foregroundColor.getGreen() != 0 || foregroundColor.getBlue() != 0) {
			filter = new RGBImageFilter();
		}
	} else {
		if (numColors() == 2) {
			filter = new BWImageFilter();
		} else {
			filter = new GrayImageFilter();
		}
	}
	java.awt.Image resultImage;
	if (filter != null) {
		FilteredImageSource imageSource = new FilteredImageSource(image.getSource(), filter);
		resultImage = Toolkit.getDefaultToolkit().createImage(imageSource);
	} else {
		resultImage = image;
	}

	// TODO not elegant solution, maybe use ImageObserver in
	// image.getWitdth(..) instead
	MediaTracker mediaTracker = new MediaTracker(new java.awt.Canvas());
	mediaTracker.addImage(resultImage, 0);
	try {
		mediaTracker.waitForID(0);
	} catch (InterruptedException ex) {
	}
	if (mediaTracker.isErrorID(0)) {
		throw new IOException();
	}

	return new J2SEImmutableImage(resultImage);
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:47,代碼來源:J2SEDeviceDisplay.java


注:本文中的java.awt.MediaTracker.isErrorID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。