2022-04-14 06:38:49 +02:00
|
|
|
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
import java.awt.Image;
|
|
|
|
import java.awt.Toolkit;
|
2022-06-02 02:44:06 +02:00
|
|
|
import java.awt.MediaTracker;
|
|
|
|
import java.awt.Graphics;
|
|
|
|
import java.awt.Component;
|
|
|
|
import java.awt.image.ImageObserver;
|
|
|
|
import java.awt.image.BufferedImage;
|
2022-04-14 06:38:49 +02:00
|
|
|
import java.net.URL;
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
|
|
|
interface
|
|
|
|
ImageApi {
|
|
|
|
|
|
|
|
public static Image
|
|
|
|
local(String name)
|
|
|
|
{
|
2022-05-06 09:05:01 +02:00
|
|
|
String path = "graphics/" + name + ".png";
|
|
|
|
URL url = ImageApi.class.getResource(path);
|
2022-04-14 06:38:49 +02:00
|
|
|
if (url == null) return null;
|
|
|
|
return new ImageIcon(url).getImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Image
|
|
|
|
remote(String urlr)
|
|
|
|
{
|
2022-05-06 09:05:01 +02:00
|
|
|
try
|
|
|
|
{
|
2022-04-14 06:38:49 +02:00
|
|
|
URL url = new URL(urlr);
|
|
|
|
Toolkit TK = Toolkit.getDefaultToolkit();
|
|
|
|
return TK.createImage(url);
|
|
|
|
}
|
2022-05-06 09:05:01 +02:00
|
|
|
catch (MalformedURLException eMu)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ImageIcon
|
|
|
|
iconRemote(String urlr)
|
|
|
|
{
|
|
|
|
if (urlr == null) return null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ImageIcon(new URL(urlr));
|
|
|
|
}
|
|
|
|
catch (MalformedURLException eMu)
|
|
|
|
{
|
2022-04-14 06:38:49 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|