当前位置: 首页>>代码示例>>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;未经允许,请勿转载。