Java 8 MediaTracker - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MediaTracker class.

This code example shows how to use the following methods:addImage, removeImage, waitForID
     */ 
    public BackgroundPainter(Image image, boolean fixed, boolean tile) {
        m_img = image;
         
        // make sure the image is completely loaded 
        MediaTracker mt = new MediaTracker(new Container());
        mt.addImage(m_img, 0);
        try { 
            mt.waitForID(0);
        } catch ( Exception e ) { e.printStackTrace(); }
        mt.removeImage(m_img, 0);
         
        m_fixed = fixed;
        m_tiled = tile;
    } 
     
    /** 
     * Paint the background. 
     * @see prefuse.util.display.PaintListener#prePaint(prefuse.Display, java.awt.Graphics2D) 
     */ 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, isErrorAny, waitForAll
            System.out.println("Couldn't load image " + file);
            return null; 
        } 
 
 
        MediaTracker mt = new MediaTracker(comp);
        try { 
            mt.addImage(img, 0);
            mt.waitForAll();
        } catch (Exception e) {
            System.out.println("Couldn't load image " + file);
            System.out.println(e);
            return null; 
        } 
        if (mt.isErrorAny()) {
            System.out.println("Couldn't load image " + file);
            return null; 
        } 
 
//         ImageObserver observer = new ImageObserver() { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, removeImage, waitForID
     * Wait for an image to load. 
     * @param image the image to wait for 
     */ 
    protected void waitForImage(Image image) {
        int id = ++nextTrackerID;
        tracker.addImage(image, id);
        try { 
            tracker.waitForID(id, 0);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } 
        tracker.removeImage(image, id);
    } 
     
    /** 
     * Scales an image to fit within the current size thresholds. 
     * @param img the image to scale 
     * @return the scaled image 
     */ 
    protected Image getScaledImage(Image img) {     
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, isErrorAny, removeImage, waitForAll
                           RenderingHints.VALUE_ANTIALIAS_ON);
        // 
        // Load Image 
        // 
        Image image = Toolkit.getDefaultToolkit().createImage("test-resources/org/apache/batik/svggen/resources/vangogh.jpg");
        MediaTracker tracker = new MediaTracker(new Button(""));
        tracker.addImage(image, 0);
        try{ 
            tracker.waitForAll();
        }catch(InterruptedException e){
            tracker.removeImage(image);
            image = null;
        }finally { 
            if(image != null)
                tracker.removeImage(image);
            if(tracker.isErrorAny())
                image = null;
            if(image != null){
                if(image.getWidth(null)<0 ||
                   image.getHeight(null)<0)
                    image = null;
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, waitForID
This code example shows how to use the following methods:addImage, isErrorAny, waitForID
        super(owner);
        this.splashImage = splashImage;
 
 
        // Load the image 
        MediaTracker mt = new MediaTracker(this);
        mt.addImage(splashImage,0);
        try { 
            mt.waitForID(0);
        } catch(InterruptedException ie){}
         
        // If there was an error loading the image, it doesn't 
        // matter if paint gets called or not, because no 
        // image is ever going to show. 
        if(mt.isErrorAny()) {
            paintCalled = true;
        } 
 
        // Center the window on the screen, and force the image to have a size, 
        // otherwise paint will never be called. 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, waitForAll
    private static BufferedImage convertToBufferedImage(Image image) throws IOException {
        if (image instanceof BufferedImage) {
            return (BufferedImage)image;
        } else { 
            /*not sure how this is used*/ 
            MediaTracker tracker = new MediaTracker(null);
            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_RGB);
            Graphics g = bufImage.createGraphics();
            g.drawImage(image, 0, 0, null);
            return bufImage;
        } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, waitForID
import net.yacy.document.parser.images.icoParser; 
 
public class ImageParser { 
 
    public static final Image parse(final String filename, final byte[] source) {
        final MediaTracker mediaTracker = new MediaTracker(new Container());
        Image image;
        if (((filename.endsWith(".ico")) || (filename.endsWith(".bmp"))) && (bmpParser.isBMP(source))) {
            // parse image with BMP parser 
            image = bmpParser.parse(source).getImage();
            if (image == null) return null;
        } else if ((filename.endsWith(".ico")) && (icoParser.isICO(source))) {
            // parse image with ICO parser 
            icoParser icoparser;
            try { 
                icoparser = new icoParser(source);
                image = icoparser.getImage(0);
            } catch (final Throwable e) {
                image = null;
            } 

5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addImage, waitForID
This code example shows how to use the following methods:addImage, waitForAll
 
    public TestImage2D(String[] args) throws Exception {
        super(args);
        setName("Images2D"); 
 
        MediaTracker t = new MediaTracker(this);
        image = ImageHandler.getImage("images/transparent-image.gif",
                TestImage2D.class); 
        t.addImage(image, 0);
        try { 
            t.waitForAll();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } 
         
        image1 = new BufferedImage(image.getWidth(this), image.getHeight(this),
                BufferedImage.TYPE_INT_RGB);
        image1.createGraphics().drawImage(image, 0, 0, this);
         
        image2 = new BufferedImage(image.getWidth(this), image
5
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 MediaTracker Methods: