gnu.java.awt

Class ClasspathToolkit

Known Direct Subclasses:
GtkToolkit, HeadlessToolkit, QtToolkit, SwingToolkit, XToolkit, XToolkit

public abstract class ClasspathToolkit
extends Toolkit

An abstract superclass for Classpath toolkits.

There exist some parts of AWT and Java2D that are specific to the underlying platform, but for which the Toolkit class does not provide suitable abstractions. Examples include some methods of Font or GraphicsEnvironment. Those methods use ClasspathToolkit as a central place for obtaining platform-specific functionality.

In addition, ClasspathToolkit implements some abstract methods of Toolkit that are not really platform-specific, such as the maintenance of a cache of loaded images.

Thread Safety: The methods of this class may safely be called without external synchronization. This also hold for any inherited Toolkit methods. Subclasses are responsible for the necessary synchronization.

Field Summary

Fields inherited from class java.awt.Toolkit

Object>(), desktopProperties, desktopPropsSupport

Method Summary

protected DesktopPeer
createDesktopPeer(Desktop target)
abstract EmbeddedWindowPeer
createEmbeddedWindow(EmbeddedWindow w)
Creates an embedded window peer, and associates it with an EmbeddedWindow object.
abstract Font
createFont(int format, InputStream stream)
Creates a font, reading the glyph definitions from a stream.
abstract RobotPeer
createRobot(GraphicsDevice screen)
Creates a RobotPeer on a given GraphicsDevice.
abstract ClasspathFontPeer
getClasspathFontPeer(String name, Map attrs)
Acquires an appropriate ClasspathFontPeer, for use in classpath's implementation of Font.
Font
getFont(String name, Map<K,V> attrs)
Creates a Font, in a platform-specific manner.
abstract GraphicsEnvironment
getLocalGraphicsEnvironment()
Returns a shared instance of the local, platform-specific graphics environment.
int
getMouseNumberOfButtons()
Returns the number of mouse buttons.
void
registerImageIOSpis(IIORegistry reg)
Used to register ImageIO SPIs provided by the toolkit.

Methods inherited from class java.awt.Toolkit

addAWTEventListener, addPropertyChangeListener, beep, checkImage, createButton, createCanvas, createCheckbox, createCheckboxMenuItem, createChoice, createComponent, createCustomCursor, createDesktopPeer, createDialog, createDragSourceContextPeer, createFileDialog, createFrame, createImage, createImage, createImage, createImage, createImage, createLabel, createList, createMenu, createMenuBar, createMenuItem, createPanel, createPopupMenu, createScrollPane, createScrollbar, createTextArea, createTextField, createWindow, extends DragGestureRecognizer> T createDragGestureRecognizer, getAWTEventListeners, getAWTEventListeners, getBestCursorSize, getColorModel, getDefaultToolkit, getDesktopProperty, getFontList, getFontMetrics, getFontPeer, getImage, getImage, getLockingKeyState, getMaximumCursorColors, getMenuShortcutKeyMask, getMouseInfoPeer, getNativeContainer, getPrintJob, getPrintJob, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getScreenInsets, getScreenResolution, getScreenSize, getSystemClipboard, getSystemEventQueue, getSystemEventQueueImpl, getSystemSelection, initializeDesktopProperties, isDynamicLayoutActive, isDynamicLayoutSet, isFrameStateSupported, isModalExclusionTypeSupported, isModalityTypeSupported, lazilyLoadDesktopProperty, loadSystemColors, mapInputMethodHighlight, prepareImage, removeAWTEventListener, removePropertyChangeListener, setDesktopProperty, setDynamicLayout, setLockingKeyState, sync

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

createDesktopPeer

protected DesktopPeer createDesktopPeer(Desktop target)
            throws HeadlessException
Overrides:
createDesktopPeer in interface Toolkit

createEmbeddedWindow

public abstract EmbeddedWindowPeer createEmbeddedWindow(EmbeddedWindow w)
Creates an embedded window peer, and associates it with an EmbeddedWindow object.
Parameters:
w - The embedded window with which to associate a peer.

createFont

public abstract Font createFont(int format,
                                InputStream stream)
Creates a font, reading the glyph definitions from a stream.

This method provides the platform-specific implementation for the static factory method Font.createFont(int,InputStream).

Parameters:
format - the format of the font data, such as Font.TRUETYPE_FONT. An implementation may ignore this argument if it is able to automatically recognize the font format from the provided data.
stream - an input stream from where the font data is read in. The stream will be advanced to the position after the font data, but not closed.
Throws:
IllegalArgumentException - if format is not supported.

createRobot

public abstract RobotPeer createRobot(GraphicsDevice screen)
            throws AWTException
Creates a RobotPeer on a given GraphicsDevice.

getClasspathFontPeer

public abstract ClasspathFontPeer getClasspathFontPeer(String name,
                                                       Map attrs)
Acquires an appropriate ClasspathFontPeer, for use in classpath's implementation of Font.
Parameters:
name - The logical name of the font. This may be either a face name or a logical font name, or may even be null. A default implementation of name decoding is provided in ClasspathFontPeer, but may be overridden in other toolkits.
attrs - Any extra TextAttribute attributes this font peer should have, such as size, weight, family name, or transformation.

getFont

public Font getFont(String name,
                    Map<K,V> attrs)
Creates a Font, in a platform-specific manner. The default implementation simply constructs a Font, but some toolkits may wish to override this, to return Font subclasses which implement OpenType or MultipleMaster.

getLocalGraphicsEnvironment

public abstract GraphicsEnvironment getLocalGraphicsEnvironment()
Returns a shared instance of the local, platform-specific graphics environment.

This method is specific to GNU Classpath. It gets called by the Classpath implementation of GraphicsEnvironment.getLocalGraphcisEnvironment().


getMouseNumberOfButtons

public int getMouseNumberOfButtons()
Returns the number of mouse buttons. (used by java.awt.MouseInfo). This dummy implementation returns -1 (no mouse). toolkit implementors should overload this method if possible.
Since:
1.5

registerImageIOSpis

public void registerImageIOSpis(IIORegistry reg)
Used to register ImageIO SPIs provided by the toolkit. Our default implementation does nothing.

ClasspathToolkit.java -- Abstract superclass for Classpath toolkits. Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.