org.webswing.applet.WebAppletContext Maven / Gradle / Ivy
package org.webswing.applet;
import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AudioClip;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import org.webswing.toolkit.util.Logger;
import org.webswing.toolkit.util.Util;
import sun.awt.image.URLImageSource;
import sun.misc.Ref;
@SuppressWarnings({ "restriction", "deprecation" })
public class WebAppletContext implements AppletContext {
private static Map imageRefs = new HashMap();
private AppletContainer container;
public WebAppletContext(AppletContainer appletContainer) {
this.container = appletContainer;
}
@Override
public AudioClip getAudioClip(URL url) {
return null;// not supported
}
public Image getImage(URL paramURL) {
return ((Image) getCachedImageRef(paramURL).get());
}
static AppletImageRef getCachedImageRef(URL url) {
synchronized (imageRefs) {
AppletImageRef imageRef = (AppletImageRef) imageRefs.get(url);
if (imageRef == null) {
imageRef = new AppletImageRef(url);
imageRefs.put(url, imageRef);
}
return imageRef;
}
}
@Override
public Applet getApplet(String name) {
throw null;
}
@Override
public Enumeration