graydon hoare <address@hidden> wrote on Wed, 10 Sep 2003 01:36:53 -0400:
I would like to attach some extra methods to a singleton object of
some sort -- something like Toolkit or GraphicsEnvironment, or a
classpath-specific subclass of these -- to produce peer or peer-like
(native-assisted subclass) objects for use in java2d.
I think this is an excellent idea. I guess it comes to the following:
- gnu.java.awt.peer -- abstract, platform-independent classes
- gnu.java.awt.peer.gtk -- your GTK/Cairo implementation
- gnu.java.awt.peer.(xxx) -- other implementations
package gnu.java.awt.peer;
abstract class GeneralGraphicsEnvironment
// should this be "ClasspathGraphicsEnvironment"?
// "CPGraphicsEnvironment"? "GNUGraphicsEnvironment"?
extends java.awt.GraphicsEnvironment
{
abstract GeneralFontPeer createFontPeer(java.awt.Font awtFont, double
size, ...);
}
package gnu.java.awt.peer.foo;
class FooGraphicsEnvironment
extends gnu.java.awt.peer.GeneralGraphicsEnvironment
{
GeneralFontPeer createFontPeer(...) { return new FooFontPeer(...); }
}
By the way, there are now some GDK/GTK-related classes in
gnu.java.awt.image. Could/should these move to gnu.java.awt.peer.gtk as well?
How will methods like java.awt.GraphicsEnvironment.getLocalEnvironment()
know about the right peers?