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


Java MediaTracker.waitForID方法代碼示例

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


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

示例1: testToolkitMultiResolutionImageLoad

import java.awt.MediaTracker; //導入方法依賴的package包/類
static void testToolkitMultiResolutionImageLoad(Image image) throws Exception {

        MediaTracker tracker = new MediaTracker(new JPanel());
        tracker.addImage(image, 0);
        tracker.waitForID(0);
        if (tracker.isErrorAny()) {
            throw new RuntimeException("Error during image loading");
        }
        tracker.removeImage(image, 0);

        testImageLoaded(image);

        int w = image.getWidth(null);
        int h = image.getHeight(null);

        Image resolutionVariant = ((MultiResolutionImage) image)
                .getResolutionVariant(2 * w, 2 * h);

        if (image == resolutionVariant) {
            throw new RuntimeException("Resolution variant is not loaded");
        }

        testImageLoaded(resolutionVariant);
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:MultiResolutionImageTest.java

示例2: testToolkitMultiResolutionImageLoad

import java.awt.MediaTracker; //導入方法依賴的package包/類
static void testToolkitMultiResolutionImageLoad(Image image)
    throws Exception {

    MediaTracker tracker = new MediaTracker(new JPanel());
    tracker.addImage(image, 0);
    tracker.waitForID(0);
    if (tracker.isErrorAny()) {
        throw new RuntimeException("Error during image loading");
    }
    tracker.removeImage(image, 0);

    testImageLoaded(image);

    int w = image.getWidth(null);
    int h = image.getHeight(null);

    Image resolutionVariant = ((MultiResolutionImage) image)
        .getResolutionVariant(2 * w, 2 * h);

    if (image == resolutionVariant) {
        throw new RuntimeException("Resolution variant is not loaded");
    }

    testImageLoaded(resolutionVariant);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:MultiResolutionImageTest.java

示例3: setCommandContext

import java.awt.MediaTracker; //導入方法依賴的package包/類
public void setCommandContext(String verb, DataHandler dh)
  throws IOException
{
  // Read image into a byte array
  InputStream in = dh.getInputStream();
  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  byte[] buf = new byte[4096];
  for (int len = in.read(buf); len != -1; len = in.read(buf))
    bytes.write(buf, 0, len);
  in.close();
  // Create and prepare the image
  Toolkit toolkit = getToolkit();
  Image img = toolkit.createImage(bytes.toByteArray());
  try
    {
      MediaTracker tracker = new MediaTracker(this);
      tracker.addImage(img, 0);
      tracker.waitForID(0);
    }
  catch (InterruptedException e)
    {
    }
  toolkit.prepareImage(img, -1, -1, this);
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:25,代碼來源:ImageViewer.java

示例4: 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

示例5: getFileAsImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
public Image getFileAsImage(String pathName, String[] retFileNameOrError) {
  if (!haveDisplay) {
    retFileNameOrError[0] = "no display";
    return null;
  }
  Image image = fileManager.getFileAsImage(pathName, retFileNameOrError);
  if (image == null)
    return null;
  MediaTracker tracker = new MediaTracker(display);
  tracker.addImage(image, 0);
  try {
    tracker.waitForID(0);
  } catch (InterruptedException e) {
    // Got to do something?
  }
  return image;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:18,代碼來源:Viewer.java

示例6: run

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 *
 */
public void run() throws JRException
{
	long start = System.currentTimeMillis();
	//Preparing parameters
	Image image = Toolkit.getDefaultToolkit().createImage("dukesign.jpg");
	MediaTracker traker = new MediaTracker(new Panel());
	traker.addImage(image, 0);
	try
	{
		traker.waitForID(0);
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
	
	Map<String, Object> parameters = new HashMap<String, Object>();
	parameters.put("ReportTitle", "The First Jasper Report Ever");
	parameters.put("MaxOrderID", new Integer(10500));
	parameters.put("SummaryImage", image);
	
	JasperRunManager.runReportToPdfFile("build/reports/FirstJasper.jasper", parameters, getDemoHsqldbConnection());
	System.err.println("PDF running time : " + (System.currentTimeMillis() - start));
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:28,代碼來源:JasperApp.java

示例7: setImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 * Set Image
 * 
 * @param image image
 */
public void setImage(final Image image)
{
	m_image = image;
	if (m_image == null)
		return;

	MediaTracker mt = new MediaTracker(this);
	mt.addImage(m_image, 0);
	try
	{
		mt.waitForID(0);
	}
	catch (Exception e)
	{
	}
	Dimension dim = new Dimension(m_image.getWidth(this), m_image.getHeight(this));
	this.setPreferredSize(dim);
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:24,代碼來源:Attachment.java

示例8: JpegEncoder

import java.awt.MediaTracker; //導入方法依賴的package包/類
public JpegEncoder(Image image, int quality, OutputStream out) {
	MediaTracker tracker = new MediaTracker(this);
	tracker.addImage(image, 0);
	try {
		tracker.waitForID(0);
	} catch (InterruptedException e) {
		// Got to do something?
	}
	/*
	 * Quality of the image. 0 to 100 and from bad image quality, high
	 * compression to good image quality low compression
	 */
	Quality = quality;

	/*
	 * Getting picture information It takes the Width, Height and RGB scans of
	 * the image.
	 */
	JpegObj = new JpegInfo(image);

	imageHeight = JpegObj.imageHeight;
	imageWidth = JpegObj.imageWidth;
	outStream = new BufferedOutputStream(out);
	dct = new DCT(Quality);
	Huf = new Huffman(imageWidth, imageHeight);
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:27,代碼來源:JpegEncoder.java

示例9: imageToBufferedImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 * Méthode qui convertit une image en BufferedImage.
 *
 * @param im l'image à convertir
 * @return une BufferedImage créée à partir de l'image passée en paramètre
 */
public static BufferedImage imageToBufferedImage(Image im) {
    if(im==null) {return null;}
    if(im instanceof BufferedImage) {return (BufferedImage) im;}//On tente un simple Cast
    //On vérifie que l'image est bien chargée
    if(im.getWidth(null)==-1 || im.getHeight(null)==-1) {
        MediaTracker tracker = new MediaTracker(new Component(){});
        tracker.addImage(im, 0);
        try {
            tracker.waitForID(0);
        } catch (InterruptedException ex1) {
            Logger.getLogger(ImageTools.class.getName()).log(Level.SEVERE, null, ex1);
            if(im.getWidth(null)==-1 || im.getHeight(null)==-1) return null;
        }
    }
    //On dessine l'image dans un buffer
    BufferedImage bi = new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_4BYTE_ABGR);
    Graphics bg = bi.createGraphics();
    bg.drawImage(im, 0, 0, null);
    bg.dispose();
    return bi;
}
 
開發者ID:Sharcoux,項目名稱:MathEOS,代碼行數:28,代碼來源:ImageTools.java

示例10: traker

import java.awt.MediaTracker; //導入方法依賴的package包/類
private void traker() {
	try {
		tracker = new MediaTracker(this);
		tracker.addImage(image, 0);
		tracker.waitForID(0);
		width = image.getWidth(null);
		height = image.getHeight(null);
		bi = new BufferedImage(width, height,
				BufferedImage.TYPE_INT_RGB);
		Graphics gg = bi.getGraphics();
		gg.drawImage(image, 0, 0, this);
		gg.dispose();
		repaint();
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
開發者ID:anyjava,項目名稱:FiveStonesGame,代碼行數:18,代碼來源:GameRoomGui.java

示例11: StatusSprite

import java.awt.MediaTracker; //導入方法依賴的package包/類
public StatusSprite(Component component){
    this.component = component;

    MediaTracker mediaTracker = new MediaTracker(component);
    try {
        
        lightGreenBarImage = Toolkit.getDefaultToolkit().getImage("image/sprites/lightgreen_status.gif");
        mediaTracker.addImage(lightGreenBarImage, 0);

        greenBarImage = Toolkit.getDefaultToolkit().getImage("image/sprites/green_status.gif");
        mediaTracker.addImage(greenBarImage, 0);

        multiBulletImage = Toolkit.getDefaultToolkit().getImage("image/sprites/multibullet.gif");
        mediaTracker.addImage(multiBulletImage, 0);

        shieldImage = Toolkit.getDefaultToolkit().getImage("image/sprites/shield.gif");
        mediaTracker.addImage(shieldImage, 0);

        livesImage = Toolkit.getDefaultToolkit().getImage("image/sprites/lives.gif");
        mediaTracker.addImage(livesImage, 0);

        mediaTracker.waitForID(0);
    }catch (InterruptedException e) {
        System.out.println(e);
    }
}
 
開發者ID:rituparnakashyap,項目名稱:StarWars,代碼行數:27,代碼來源:StatusSprite.java

示例12: MainPanel

import java.awt.MediaTracker; //導入方法依賴的package包/類
public MainPanel() {
    // �p�l���̐����T�C�Y��ݒ�Apack()����Ƃ��ɕK�v
    setPreferredSize(new Dimension(WIDTH, HEIGHT));

    // �C���[�W��ǂݍ���
    image = Toolkit.getDefaultToolkit().getImage(
            getClass().getResource("image.gif"));

    // MediaTracker�ɓo�^
    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(image, 0);
    // �C���[�W�ǂݍ��݊����܂őҋ@
    try {
        tracker.waitForID(0);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
開發者ID:aidiary,項目名稱:javagame,代碼行數:19,代碼來源:MainPanel.java

示例13: loadPreviewImage

import java.awt.MediaTracker; //導入方法依賴的package包/類
public void loadPreviewImage(Entity entity, Image camo, int tint, BufferedPanel bp) {
Image base = mechTileset.imageFor(entity, comp);
EntityImage entityImage = new EntityImage(base, tint, camo, bp);
Image preview = entityImage.loadPreviewImage();

BackGroundDrawer bgdPreview = new BackGroundDrawer(preview);
bp.removeBgDrawers();
bp.addBgDrawer(bgdPreview);

MediaTracker tracker = new MediaTracker(comp);
tracker.addImage(preview, 0);
try {
	tracker.waitForID(0);
} catch (InterruptedException e) {
	;
}

  }
 
開發者ID:SpoonLabs,項目名稱:gumtree-spoon-ast-diff,代碼行數:19,代碼來源:right_TilesetManager_1.23.java

示例14: SplashScreen

import java.awt.MediaTracker; //導入方法依賴的package包/類
public SplashScreen(URL filename) {
	// Get Image
	MediaTracker mt = new MediaTracker(this);
	image = Toolkit.getDefaultToolkit().getImage(filename);
	mt.addImage(image,0);
	try {
		mt.waitForID(0);
	} catch(InterruptedException ie){}

	// Set size of image
	setSize(image.getWidth(null),image.getHeight(null));
	
	// Center Window
	Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
	Rectangle winDim = getBounds();
	setLocation((screenDim.width - winDim.width) / 2,(screenDim.height - winDim.height) / 2);
	
	setVisible(true);
}
 
開發者ID:hashrock,項目名稱:JOutliner,代碼行數:20,代碼來源:SplashScreen.java

示例15: ImageModeCanvas

import java.awt.MediaTracker; //導入方法依賴的package包/類
/**
 * Creates new form ImageModeCanvas
 */
public ImageModeCanvas(ImageModeModel model) {
    initComponents();
    this.model = model;
    MediaTracker tracker = new MediaTracker(this);
    this.image = Toolkit.getDefaultToolkit().createImage(this.model.getImage());
    tracker.addImage(image, 0);
    try {
        tracker.waitForID(0);
    } catch (InterruptedException ex) {
        Logger.getLogger(ImageModeCanvas.class.getName()).log(Level.SEVERE, null, ex);
    }
    this.painter = new ResizePainter((ResizeImageMode)model, image.getWidth(null), image.getHeight(null));
    this.addMouseListener(painter);
    this.addMouseMotionListener(painter);
}
 
開發者ID:relu91,項目名稱:niftyeditor,代碼行數:19,代碼來源:ImageModeCanvas.java


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