Sascha Brawer wrote:
graydon hoare <[EMAIL PROTECTED]> 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?
What about having Classpath Graphics Environments that support the font peer factory interface imlement such an interface?
package gnu.java.awt.peer;
/* Here goes documentation about the FontPeerFactory interface */ public interface FontPeerFactory { GeneralFontPeer createFontPeer(java.awt.Font awtFont, double size, ...); }
import gnu.java.awt.peer.FontPeerFactory;
package gnu.java.awt.peer; abstract class GeneralGraphicsEnvironment // should this be "ClasspathGraphicsEnvironment"? // "CPGraphicsEnvironment"? "GNUGraphicsEnvironment"? extends java.awt.GraphicsEnvironment implements FontPeerFactory { }
Then getLocalEnvironment() could check if a GraphicsEnvironment instanceof FontPeerFactory.
cheers, dalibor topic
_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath