當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。