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


Java MediaTracker.ERRORED屬性代碼示例

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


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

示例1: getGifFromUrl

/**
 * Loads a GIF from the given URL, fixing FPS, or just creates an ImageIcon
 * directly if it's not a valid GIF.
 * 
 * @param url The URL (local or internet) to get the image data from
 * @return The created ImageIcon, or null if an error occured creating the
 * image
 * @throws Exception When an error occured loading the image
 */
public static ImageIcon getGifFromUrl(URL url) throws Exception {
    try (InputStream input = url.openStream()) {
        // Use readAllBytes() because GifDecoder doesn't handle streams well
        byte[] imageData = readAllBytes(input);
        ImageIcon image = null;
        try {
            //System.out.println(hash(imageData)+" "+url);
            image = fixGifFps(imageData);
        } catch (Exception ex) {
            /**
             * If not a GIF, or another error occured, just create the image
             * normally.
             */
            image = new ImageIcon(imageData);
        }
        
        if (image.getImageLoadStatus() == MediaTracker.ERRORED) {
            return null;
        }
        return image;
    }
}
 
開發者ID:chatty,項目名稱:chatty,代碼行數:31,代碼來源:GifUtil.java

示例2: doInBackground

@Override
protected ImageIcon doInBackground() throws Exception {
    ImageIcon icon = loadEmote();
    
    /**
     * If an error occured, return null.
     */
    if (icon == null) {
        return null;
    }
    /**
     * Only doing this on ERRORED, waiting for COMPLETE would not allow
     * animated GIFs to load
     */
    if (icon.getImageLoadStatus() == MediaTracker.ERRORED) {
        icon.getImage().flush();
        return null;
    }
    if (icon.getIconWidth() > width || icon.getIconHeight() > height) {
        LOGGER.warning("Scaled emote: "+code+" ("+icon.getIconWidth()+"x"
                +icon.getIconHeight()+" -> "+width+"x"+height+")");
        Image scaled = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
        icon.setImage(scaled);
    }
    return icon;
}
 
開發者ID:partouf,項目名稱:Chatty-Twitch-Client,代碼行數:26,代碼來源:Emoticon.java

示例3: LoadImageIcon

/**
*** Load ImageIcon from File
**/
public static ImageIcon LoadImageIcon(File file)
{
    try {
        if (file == null) {
            Print.logWarn("Specified File is null");
            return null;
        } else
        if (!file.isFile()) {
            Print.logWarn("File does not exist: " + file);
            return null;
        } else {
            ImageIcon icon = new ImageIcon(file.toString());
            if (icon.getImageLoadStatus() == MediaTracker.ERRORED) {
                Print.logWarn("Error loading ImageIcon");
            }
            return icon;
        }
    } catch (Throwable th) { // X11 Window error
        Print.logWarn("Unable to create ImageIcon: " + th);
        return null;
    }
}
 
開發者ID:ASalieri,項目名稱:OpenGTS,代碼行數:25,代碼來源:PushpinIcon.java

示例4: _init

private void _init(ImageIcon icon, int xOfs, int yOfs, int xSiz, int ySiz, int fontPt, String fontName) {
    this.frameOffset_x  = xOfs;
    this.frameOffset_y  = yOfs;
    this.frameWidth     = xSiz;
    this.frameHeight    = ySiz;
    this.fontSize       = (fontPt > 0)? (double)fontPt : 8.0;
    this.fontName       = StringTools.blankDefault(fontName, DEFAULT_TEXT_FONT);
    this.imageIcon      = icon;
    if (this.imageIcon == null) {
        Print.logWarn("Specified ImageIcon is null");
    } else {
        int loadStat = this.imageIcon.getImageLoadStatus();
        if (loadStat == MediaTracker.ABORTED) {
            Print.logWarn("ImageIcon loading aborted");
        } else
        if (loadStat == MediaTracker.ERRORED) {
            Print.logWarn("ImageIcon load error");
        }
    }
}
 
開發者ID:ASalieri,項目名稱:OpenGTS,代碼行數:20,代碼來源:PushpinIcon.java

示例5: loadImage

public static Image loadImage(String filename, Component watcher, URL url) {
    Image image = null;

    if (url == null) {
        System.err.println("loadImage() could not find \"" + filename + "\"");
    } else {
        image = watcher.getToolkit().getImage(url);
        if (image == null) {
            System.err.println("loadImage() getImage() failed for \"" + filename + "\"");
        } else {
            MediaTracker tracker = new MediaTracker(watcher);

            try {
                tracker.addImage(image, 0);
                tracker.waitForID(0);
            } catch (InterruptedException e) {
                System.err.println("loadImage(): " + e);
            } finally {
                boolean isError = tracker.isErrorAny();
                if (isError) {
                    System.err.println("loadImage() failed to load \"" + filename + "\"");
                    int flags = tracker.statusAll(true);

                    boolean loading = 0 != (flags & MediaTracker.LOADING);
                    boolean aborted = 0 != (flags & MediaTracker.ABORTED);
                    boolean errored = 0 != (flags & MediaTracker.ERRORED);
                    boolean complete = 0 != (flags & MediaTracker.COMPLETE);
                    System.err.println("loading: " + loading);
                    System.err.println("aborted: " + aborted);
                    System.err.println("errored: " + errored);
                    System.err.println("complete: " + complete);
                }
            }
        }
    }

    return image;
}
 
開發者ID:addertheblack,項目名稱:myster,代碼行數:38,代碼來源:Util.java

示例6: setImageFile

private void setImageFile(File imageFile) {
	// Temporal image
	image = null;

	if (imageFile != null) {
		// Test if need to be loaded with JAI libraries (different
		// format than JPG, PNG and GIF)
		if (TFileUtils.isJAIRequired(imageFile)) {
			// Load it with JAI class
			RenderedOp src = JAI.create("fileload", imageFile
					.getAbsolutePath());
			BufferedImage bufferedImage = src.getAsBufferedImage();
			image = new ImageIcon(bufferedImage);				
		} else {
			// Create it as usual
			image = new ImageIcon(imageFile.getAbsolutePath());
		}

		if (image.getImageLoadStatus() == MediaTracker.ERRORED){
			setText(TLanguage.getString("TIGThumbImageDialog.TEXT"));
			this.setIcon(null);
		}
		else
			setText("");
		this.setIcon(image);
	}		
}
 
開發者ID:ProgettoRadis,項目名稱:ArasuiteIta,代碼行數:27,代碼來源:TIGThumbImage.java

示例7: getIcon

/**
 * Loads the icon from the given url.
 * 
 * @param url The URL to load the icon from
 * @return The loaded icon or {@literal null} if no URL was specified or the
 * icon couldn't be loaded
 */
private ImageIcon getIcon(URL url) {
    if (url == null) {
        return null;
    }
    //ImageIcon icon = new ImageIcon(url);
    ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(url));
    if (icon.getImageLoadStatus() != MediaTracker.ERRORED) {
        return icon;
    } else {
        LOGGER.warning("Could not load icon: " + url);
    }
    return null;
}
 
開發者ID:partouf,項目名稱:Chatty-Twitch-Client,代碼行數:20,代碼來源:Usericon.java

示例8: createImageWidget

public static BackgroundImageWidget createImageWidget(Scene scene, File file) throws Exception
{
    BackgroundImageWidget img = new BackgroundImageWidget(scene, new javax.swing.ImageIcon(file.getPath()) );
    if (img.getImg().getImageLoadStatus() == MediaTracker.ERRORED)
    {
        throw new Exception("Error loading image");
    }
    return img;
}
 
開發者ID:JockiHendry,項目名稱:ireport-fork,代碼行數:9,代碼來源:BackgroundImageUtilities.java

示例9: getIcon

public static ImageIcon getIcon(String iconConfigId){
	String path = GuiLoader.getProperty("image_path")+
		GuiLoader.getProperty(iconConfigId);
	
	ImageIcon icon = new ImageIcon(path);
	if (icon.getImageLoadStatus()==MediaTracker.ERRORED){
		System.err.println("Image path ERROR: " + path);
	}
	
	return new ImageIcon(path);
}
 
開發者ID:BestPeerPlus,項目名稱:BestPeer-src,代碼行數:11,代碼來源:GuiHelper.java

示例10: getImage

public iiuf.xmillum.Image getImage(URL imageURL) throws IOException {
  ImageIcon icon = new ImageIcon(imageURL);
  if (icon.getImageLoadStatus() == MediaTracker.ERRORED) {
    context.setStatus("Unable to load image "+imageURL);
    return null;
  }
  return new JavaImage(icon.getImage());
}
 
開發者ID:tamirhassan,項目名稱:pdfxtk,代碼行數:8,代碼來源:JavaImageFactory.java


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