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


Java MediaTracker类代码示例

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


MediaTracker类属于java.awt包,在下文中一共展示了MediaTracker类的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: 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

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

示例4: loadimages

import java.awt.MediaTracker; //导入依赖的package包/类
static private void loadimages() {
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final MediaTracker mediatracker = new MediaTracker(app);
    dnload += 8;
    try {
        for (int i = 0; i < idts.length; i++) {
            idts[i].cons.accept(Files.readAllBytes(new File(Madness.fpath + "data/images/" + idts[i].fileName).toPath()), mediatracker, toolkit);
        }
        
        dnload += 2;
        
    } catch (final Exception exception) {
        System.err.println("Error Loading Images: " + exception);
    }
    System.gc();
}
 
开发者ID:uwx,项目名称:OpenNFMM,代码行数:17,代码来源:xtGraphics.java

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

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

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

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

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

示例10: DuplicateAudioDevice

import java.awt.MediaTracker; //导入依赖的package包/类
DuplicateAudioDevice() {
	super("");
	
	putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttDuplicateAudioDevice"));
	
	try {
		URL url = ClassLoader.getSystemClassLoader().getResource (
			"org/jsampler/view/classic/res/icons/Copy16.gif"
		);
		
		ImageIcon icon = new ImageIcon(url);
		if(icon.getImageLoadStatus() == MediaTracker.COMPLETE)
			putValue(Action.SMALL_ICON, icon);
	} catch(Exception x) {
		CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
	}
	
	setEnabled(false);
}
 
开发者ID:lxlxlo,项目名称:LS-jsampler,代码行数:20,代码来源:AudioDevicesPage.java

示例11: RemoveAudioDevice

import java.awt.MediaTracker; //导入依赖的package包/类
RemoveAudioDevice() {
	super("");
	
	putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttRemoveAudioDevice"));
	
	try {
		URL url = ClassLoader.getSystemClassLoader().getResource (
			"org/jsampler/view/classic/res/icons/Delete16.gif"
		);
		
		ImageIcon icon = new ImageIcon(url);
		if(icon.getImageLoadStatus() == MediaTracker.COMPLETE)
			putValue(Action.SMALL_ICON, icon);
	} catch(Exception x) {
		CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
	}
	
	setEnabled(false);
}
 
开发者ID:lxlxlo,项目名称:LS-jsampler,代码行数:20,代码来源:AudioDevicesPage.java

示例12: AudioDeviceProps

import java.awt.MediaTracker; //导入依赖的package包/类
AudioDeviceProps() {
	super("");
	
	putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttAudioDeviceProps"));
	
	try {
		URL url = ClassLoader.getSystemClassLoader().getResource (
			"org/jsampler/view/classic/res/icons/Properties16.gif"
		);
		
		ImageIcon icon = new ImageIcon(url);
		if(icon.getImageLoadStatus() == MediaTracker.COMPLETE)
			putValue(Action.SMALL_ICON, icon);
	} catch(Exception x) {
		CC.getLogger().log(Level.INFO, HF.getErrorMessage(x), x);
	}
	
	setEnabled(false);
}
 
开发者ID:lxlxlo,项目名称:LS-jsampler,代码行数:20,代码来源:AudioDevicesPage.java

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

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

示例15: drawMap

import java.awt.MediaTracker; //导入依赖的package包/类
/** 
 * Creates a 2D map at a given center point.
 * @param newCenter the new center location
 */
public void drawMap(Coordinates newCenter) {
	if ((newCenter != null) && (!newCenter.equals(currentCenter))) {
		mapImage = createMapImage(newCenter);

		MediaTracker mt = new MediaTracker(displayArea);
		mt.addImage(mapImage, 0);
		try {
			mt.waitForID(0);
		} 
		catch (InterruptedException e) {
			logger.log(Level.SEVERE,Msg.getString("CannedMarsMap.log.mediaTrackerInterrupted") + e); //$NON-NLS-1$
		}
		mapImageDone = true;
		currentCenter = new Coordinates(newCenter);
	}
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:21,代码来源:CannedMarsMap.java


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