classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extended peers


From: Dalibor Topic
Subject: Re: extended peers
Date: Wed, 10 Sep 2003 17:16:43 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312

Hallo Sascha,

Sascha Brawer wrote:
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?

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]