diff options
Diffstat (limited to 'gnu/java/awt/ClasspathToolkit.java')
-rw-r--r-- | gnu/java/awt/ClasspathToolkit.java | 206 |
1 files changed, 3 insertions, 203 deletions
diff --git a/gnu/java/awt/ClasspathToolkit.java b/gnu/java/awt/ClasspathToolkit.java index 5fb444f98..1d25cc1da 100644 --- a/gnu/java/awt/ClasspathToolkit.java +++ b/gnu/java/awt/ClasspathToolkit.java @@ -92,14 +92,6 @@ public abstract class ClasspathToolkit extends Toolkit { /** - * A map from URLs to previously loaded images, used by {@link - * #getImage(java.net.URL)}. For images that were loaded via a path - * to an image file, the map contains a key with a file URL. - */ - private HashMap imageCache; - - - /** * Returns a shared instance of the local, platform-specific * graphics environment. * @@ -109,59 +101,6 @@ public abstract class ClasspathToolkit */ public abstract GraphicsEnvironment getLocalGraphicsEnvironment(); - - /** - * Determines the current size of the default, primary screen. - * - * @throws HeadlessException if the local graphics environment is - * headless, which means that no screen is attached and no user - * interaction is allowed. - */ - public Dimension getScreenSize() - { - DisplayMode mode; - - // getDefaultScreenDevice throws HeadlessException if the - // local graphics environment is headless. - mode = GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDisplayMode(); - - return new Dimension(mode.getWidth(), mode.getHeight()); - } - - - /** - * Determines the current color model of the default, primary - * screen. - * - * @see GraphicsEnvironment#getDefaultScreenDevice() - * @see java.awt.GraphicsDevice#getDefaultConfiguration() - * @see java.awt.GraphicsConfiguration#getColorModel() - * - * @throws HeadlessException if the local graphics environment is - * headless, which means that no screen is attached and no user - * interaction is allowed. - */ - public ColorModel getColorModel() - { - // getDefaultScreenDevice throws HeadlessException if the - // local graphics environment is headless. - return GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDefaultConfiguration() - .getColorModel(); - } - - /** - * Retrieves the metrics for rendering a font on the screen. - * - * @param font the font whose metrics are requested. - */ - public FontMetrics getFontMetrics(Font font) - { - return ((ClasspathFontPeer) font.getPeer ()).getFontMetrics (font); - } - - /** * Acquires an appropriate {@link ClasspathFontPeer}, for use in * classpath's implementation of {@link java.awt.Font}. @@ -185,8 +124,8 @@ public abstract class ClasspathToolkit * Creates a {@link Font}, in a platform-specific manner. * * The default implementation simply constructs a {@link Font}, but some - * toolkits may wish to override this, to return {@link Font} subclasses which - * implement {@link java.awt.font.OpenType} or + * toolkits may wish to override this, to return {@link Font} subclasses + * which implement {@link java.awt.font.OpenType} or * {@link java.awt.font.MultipleMaster}. */ public Font getFont (String name, Map attrs) @@ -194,7 +133,6 @@ public abstract class ClasspathToolkit return new Font (name, attrs); } - /** * Creates a font, reading the glyph definitions from a stream. * @@ -223,137 +161,6 @@ public abstract class ClasspathToolkit */ public abstract Font createFont(int format, InputStream stream); - - /** - * Returns an image from the specified file, which must be in a - * recognized format. The set of recognized image formats may vary - * from toolkit to toolkit. - * - * <p>This method maintains a cache for images. If an image has been - * loaded from the same path before, the cached copy will be - * returned. The implementation may hold cached copies for an - * indefinite time, which can consume substantial resources with - * large images. Users are therefore advised to use {@link - * #createImage(java.lang.String)} instead. - * - * <p>The default implementation creates a file URL for the - * specified path and invokes {@link #getImage(URL)}. - * - * @param path A path to the image file. - * - * @return IllegalArgumentException if <code>path</code> does not - * designate a valid path. - */ - public Image getImage(String path) - { - try - { - return getImage(new File(path).toURL()); - } - catch (MalformedURLException muex) - { - throw (IllegalArgumentException) new IllegalArgumentException(path) - .initCause(muex); - } - } - - - /** - * Loads an image from the specified URL. The image data must be in - * a recognized format. The set of recognized image formats may vary - * from toolkit to toolkit. - * - * <p>This method maintains a cache for images. If an image has been - * loaded from the same URL before, the cached copy will be - * returned. The implementation may hold cached copies for an - * indefinite time, which can consume substantial resources with - * large images. Users are therefore advised to use {@link - * #createImage(java.net.URL)} instead. - * - * @param url the URL from where the image is read. - */ - public Image getImage(URL url) - { - Image result; - - synchronized (this) - { - // Many applications never call getImage. Therefore, we lazily - // create the image cache when it is actually needed. - if (imageCache == null) - imageCache = new HashMap(); - else - { - result = (Image) imageCache.get(url); - if (result != null) - return result; - } - - // The createImage(URL) method, which is specified by - // java.awt.Toolkit, is not implemented by this abstract class - // because it is platform-dependent. Once Classpath has support - // for the javax.imageio package, it might be worth considering - // that toolkits provide native stream readers. Then, the class - // ClasspathToolkit could provide a general implementation that - // delegates the image format parsing to javax.imageio. - result = createImage(url); - - // It is not clear whether it would be a good idea to use weak - // references here. The advantage would be reduced memory - // consumption, since loaded images would not be kept - // forever. But on VMs that frequently perform garbage - // collection (which includes VMs with a parallel or incremental - // collector), the image might frequently need to be re-loaded, - // possibly over a slow network connection. - imageCache.put(url, result); - - return result; - } - } - - - /** - * Returns an image from the specified file, which must be in a - * recognized format. The set of recognized image formats may vary - * from toolkit to toolkit. - * - * <p>A new image is created every time this method gets called, - * even if the same path has been passed before. - * - * <p>The default implementation creates a file URL for the - * specified path and invokes {@link #createImage(URL)}. - * - * @param path A path to the file to be read in. - */ - public Image createImage(String path) - { - try - { - // The abstract method createImage(URL) is defined by - // java.awt.Toolkit, but intentionally not implemented by - // ClasspathToolkit because it is platform specific. - return createImage(new File(path).toURL()); - } - catch (MalformedURLException muex) - { - throw (IllegalArgumentException) new IllegalArgumentException(path) - .initCause(muex); - } - } - - /** - * Creates an ImageProducer from the specified URL. The image is assumed - * to be in a recognised format. If the toolkit does not implement the - * image format or the image format is not recognised, null is returned. - * This default implementation is overriden by the Toolkit implementations. - * - * @param url URL to read image data from. - */ - public ImageProducer createImageProducer(URL url) - { - return null; - } - public abstract RobotPeer createRobot (GraphicsDevice screen) throws AWTException; @@ -365,15 +172,8 @@ public abstract class ClasspathToolkit */ public abstract EmbeddedWindowPeer createEmbeddedWindow (EmbeddedWindow w); - /** - * Used to register ImageIO SPIs provided by the toolkit. - */ - - public void registerImageIOSpis(IIORegistry reg) - { - } - public abstract boolean nativeQueueEmpty(); public abstract void wakeNativeQueue(); public abstract void iterateNativeQueue(EventQueue locked, boolean block); } + |