本文整理汇总了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;
}
}
示例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;
}
示例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;
}
}
示例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");
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}