http://www.eteks.com

com.eteks.awt
Class PJAToolkit

java.lang.Object
  |
  +--java.awt.Toolkit
        |
        +--com.eteks.awt.PJAToolkit

public class PJAToolkit
extends java.awt.Toolkit

Pure Java AWT Toolkit implementation. This toolkit enables to draw in offscreen images with all the Graphics methods, even if no X11 or other device display is available. Its main purpose is for servlets returning graphics and runing on servers with no display. Java programs using AWT and compliant with any Java version, will work directly on this toolkit with the following modification.
To enable automatic switch to this toolkit, the system property awt.toolkit must be changed to this class name com.eteks.awt.PJAToolkit, using either ways :

If JDK version if greater or equal to 1.2 and no Display is available the two next properties must be also set, using one of the previous ways (see also PJAGraphicsEnvironment) :

Images can't be created using one of the three ways :

With JDK 1.1 or if Java2D can't work, fonts are loaded from files with the ".pjaf" (Pure Java AWT Font) extension, either in the current directory, or in the directory kept in the System property "java.awt.fonts". For example, if you want to set this directory to be your servlet directory, you may use :

  prop.put ("java.awt.fonts", getServletContext ().getRealPath ("/servlet"));
 

These optional fonts must be captured on a computer on which JDK AWT can work (a PC, Mac or UNIX/X11 machine with an available DISPLAY), with the PJA Font capture utility (main () method of the com.eteks.awt.PJAFontPeer class).
If no fonts are available, all Graphics drawing methods that don't use Font will work. Depending on the available fonts, default font name is set to the following one, in that priority order :

  1. SansSerif
  2. Helvetica
  3. First font in the file system order.

PJAToolkit allows to get a Graphics instance for an image initialized with a producer, contrary to Java default Toolkit behavior which throws an IllegalAccessError exception in that case. This allows to create transparent images from scratch and sending transparent GIF from servlets. To create an intially transparent image execute Toolkit.getDefaultToolkit ().createImage (new java.awt.image.MemoryImageSource (width, height, new int [width * height], 0, width));

See the source of the main () method of the class ToolkitDemo to have a test example of all the Java 1.1 Graphics methods. You may also try com.eteks.servlet.TeksSurveyPie servlet class.

From PJA version 1.1, the .pjaf font files loading methods and some other methods were moved to the class PJAGraphicsManager, to be able to use PJA even if no Toolkit instance is available.

PJAToolkit and depending files are Java 1.0 compliant but needs Java 1.2 library or higher to compile (for Java 1.1 compilers, this can be done using any Java 2 rt.jar library instead of classes.zip in classpath at compile time).

Since:
PJA1.0
Version:
2.2
Author:
Emmanuel Puybaret
See Also:
ToolkitDemo, PJAFontPeer, PJAGraphics, PJAGraphicsManager, PJAServlet

Fields inherited from class java.awt.Toolkit
desktopProperties, desktopPropsSupport
 
Constructor Summary
PJAToolkit()
           
 
Method Summary
 void beep()
          java.awt.Toolkit implementation.
 int checkImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
          java.awt.Toolkit implementation.
 java.awt.peer.ButtonPeer createButton(java.awt.Button target)
          java.awt.Toolkit implementation.
 java.awt.peer.CanvasPeer createCanvas(java.awt.Canvas target)
          java.awt.Toolkit implementation.
 java.awt.peer.CheckboxPeer createCheckbox(java.awt.Checkbox target)
          java.awt.Toolkit implementation.
 java.awt.peer.CheckboxMenuItemPeer createCheckboxMenuItem(java.awt.CheckboxMenuItem target)
          java.awt.Toolkit implementation.
 java.awt.peer.ChoicePeer createChoice(java.awt.Choice target)
          java.awt.Toolkit implementation.
 java.awt.peer.LightweightPeer createComponent(java.awt.Component target)
          java.awt.Toolkit implementation.
 java.awt.peer.DialogPeer createDialog(java.awt.Dialog target)
          java.awt.Toolkit implementation.
 java.awt.dnd.peer.DragSourceContextPeer createDragSourceContextPeer(java.awt.dnd.DragGestureEvent dge)
          java.awt.Toolkit implementation.
 java.awt.peer.FileDialogPeer createFileDialog(java.awt.FileDialog target)
          java.awt.Toolkit implementation.
 java.awt.peer.FramePeer createFrame(java.awt.Frame target)
          java.awt.Toolkit implementation.
 java.awt.Image createImage(byte[] imagedata, int imageoffset, int imagelength)
          java.awt.Toolkit implementation.
 java.awt.Image createImage(java.awt.image.ImageProducer producer)
          java.awt.Toolkit implementation.
 java.awt.Image createImage(java.lang.String filename)
          java.awt.Toolkit implementation.
 java.awt.Image createImage(java.net.URL url)
          java.awt.Toolkit implementation.
 java.awt.peer.LabelPeer createLabel(java.awt.Label target)
          java.awt.Toolkit implementation.
 java.awt.peer.ListPeer createList(java.awt.List target)
          java.awt.Toolkit implementation.
 java.awt.peer.MenuPeer createMenu(java.awt.Menu target)
          java.awt.Toolkit implementation.
 java.awt.peer.MenuBarPeer createMenuBar(java.awt.MenuBar target)
          java.awt.Toolkit implementation.
 java.awt.peer.MenuItemPeer createMenuItem(java.awt.MenuItem target)
          java.awt.Toolkit implementation.
 java.awt.peer.PanelPeer createPanel(java.awt.Panel target)
          java.awt.Toolkit implementation.
 java.awt.peer.PopupMenuPeer createPopupMenu(java.awt.PopupMenu target)
          java.awt.Toolkit implementation.
 java.awt.peer.ScrollbarPeer createScrollbar(java.awt.Scrollbar target)
          java.awt.Toolkit implementation.
 java.awt.peer.ScrollPanePeer createScrollPane(java.awt.ScrollPane target)
          java.awt.Toolkit implementation.
 java.awt.peer.TextAreaPeer createTextArea(java.awt.TextArea target)
          java.awt.Toolkit implementation.
 java.awt.peer.TextFieldPeer createTextField(java.awt.TextField target)
          java.awt.Toolkit implementation.
 java.awt.peer.WindowPeer createWindow(java.awt.Window target)
          java.awt.Toolkit implementation.
 java.awt.image.ColorModel getColorModel()
          java.awt.Toolkit implementation.
static java.lang.String getDefaultFont()
          Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.getDefaultFont ().
 java.lang.String[] getFontList()
          java.awt.Toolkit implementation.
 java.awt.FontMetrics getFontMetrics(java.awt.Font font)
          java.awt.Toolkit implementation.
 java.awt.peer.FontPeer getFontPeer(java.lang.String name, int style)
          Returns a FontPeer instance matching to font name with style.
static java.lang.String getFontsDirectory()
          Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.getFontsDirectory ().
 java.awt.Image getImage(java.lang.String filename)
          java.awt.Toolkit implementation.
 java.awt.Image getImage(java.net.URL url)
          java.awt.Toolkit implementation.
 java.awt.PrintJob getPrintJob(java.awt.Frame frame, java.lang.String jobtitle, java.util.Properties props)
          java.awt.Toolkit implementation.
 int getScreenResolution()
          java.awt.Toolkit implementation.
 java.awt.Dimension getScreenSize()
          java.awt.Toolkit implementation.
 java.awt.datatransfer.Clipboard getSystemClipboard()
          java.awt.Toolkit implementation.
 java.awt.EventQueue getSystemEventQueueImpl()
          java.awt.Toolkit implementation.
static void loadFonts()
          Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.loadFonts ().
static void loadFonts(java.lang.String dir)
          Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.loadFonts (String).
 void loadSystemColors(int[] systemColors)
          java.awt.Toolkit implementation.
static void main(java.lang.String[] args)
          Deprecated. As of PJA version 1.1, replaced by PJANativeToolkitComparison.main (args).
 java.util.Map mapInputMethodHighlight(java.awt.im.InputMethodHighlight highlight)
          java.awt.Toolkit implementation.
 boolean prepareImage(java.awt.Image image, int width, int height, java.awt.image.ImageObserver observer)
          java.awt.Toolkit implementation.
 void sync()
          java.awt.Toolkit implementation.
 
Methods inherited from class java.awt.Toolkit
addAWTEventListener, addPropertyChangeListener, createCustomCursor, createDragGestureRecognizer, createImage, getBestCursorSize, getDefaultToolkit, getDesktopProperty, getLockingKeyState, getMaximumCursorColors, getMenuShortcutKeyMask, getNativeContainer, getPrintJob, getProperty, getSystemEventQueue, initializeDesktopProperties, lazilyLoadDesktopProperty, removeAWTEventListener, removePropertyChangeListener, setDesktopProperty, setLockingKeyState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PJAToolkit

public PJAToolkit()
Method Detail

createButton

public java.awt.peer.ButtonPeer createButton(java.awt.Button target)
java.awt.Toolkit implementation.
Overrides:
createButton in class java.awt.Toolkit
See Also:
Toolkit

createTextField

public java.awt.peer.TextFieldPeer createTextField(java.awt.TextField target)
java.awt.Toolkit implementation.
Overrides:
createTextField in class java.awt.Toolkit
See Also:
Toolkit

createLabel

public java.awt.peer.LabelPeer createLabel(java.awt.Label target)
java.awt.Toolkit implementation.
Overrides:
createLabel in class java.awt.Toolkit
See Also:
Toolkit

createList

public java.awt.peer.ListPeer createList(java.awt.List target)
java.awt.Toolkit implementation.
Overrides:
createList in class java.awt.Toolkit
See Also:
Toolkit

createCheckbox

public java.awt.peer.CheckboxPeer createCheckbox(java.awt.Checkbox target)
java.awt.Toolkit implementation.
Overrides:
createCheckbox in class java.awt.Toolkit
See Also:
Toolkit

createScrollbar

public java.awt.peer.ScrollbarPeer createScrollbar(java.awt.Scrollbar target)
java.awt.Toolkit implementation.
Overrides:
createScrollbar in class java.awt.Toolkit
See Also:
Toolkit

createScrollPane

public java.awt.peer.ScrollPanePeer createScrollPane(java.awt.ScrollPane target)
java.awt.Toolkit implementation.
Overrides:
createScrollPane in class java.awt.Toolkit
See Also:
Toolkit

createTextArea

public java.awt.peer.TextAreaPeer createTextArea(java.awt.TextArea target)
java.awt.Toolkit implementation.
Overrides:
createTextArea in class java.awt.Toolkit
See Also:
Toolkit

createChoice

public java.awt.peer.ChoicePeer createChoice(java.awt.Choice target)
java.awt.Toolkit implementation.
Overrides:
createChoice in class java.awt.Toolkit
See Also:
Toolkit

createFrame

public java.awt.peer.FramePeer createFrame(java.awt.Frame target)
java.awt.Toolkit implementation.
Overrides:
createFrame in class java.awt.Toolkit
See Also:
Toolkit

createCanvas

public java.awt.peer.CanvasPeer createCanvas(java.awt.Canvas target)
java.awt.Toolkit implementation.
Overrides:
createCanvas in class java.awt.Toolkit
See Also:
Toolkit

createPanel

public java.awt.peer.PanelPeer createPanel(java.awt.Panel target)
java.awt.Toolkit implementation.
Overrides:
createPanel in class java.awt.Toolkit
See Also:
Toolkit

createWindow

public java.awt.peer.WindowPeer createWindow(java.awt.Window target)
java.awt.Toolkit implementation.
Overrides:
createWindow in class java.awt.Toolkit
See Also:
Toolkit

createDialog

public java.awt.peer.DialogPeer createDialog(java.awt.Dialog target)
java.awt.Toolkit implementation.
Overrides:
createDialog in class java.awt.Toolkit
See Also:
Toolkit

createMenuBar

public java.awt.peer.MenuBarPeer createMenuBar(java.awt.MenuBar target)
java.awt.Toolkit implementation.
Overrides:
createMenuBar in class java.awt.Toolkit
See Also:
Toolkit

createMenu

public java.awt.peer.MenuPeer createMenu(java.awt.Menu target)
java.awt.Toolkit implementation.
Overrides:
createMenu in class java.awt.Toolkit
See Also:
Toolkit

createPopupMenu

public java.awt.peer.PopupMenuPeer createPopupMenu(java.awt.PopupMenu target)
java.awt.Toolkit implementation.
Overrides:
createPopupMenu in class java.awt.Toolkit
See Also:
Toolkit

createMenuItem

public java.awt.peer.MenuItemPeer createMenuItem(java.awt.MenuItem target)
java.awt.Toolkit implementation.
Overrides:
createMenuItem in class java.awt.Toolkit
See Also:
Toolkit

createFileDialog

public java.awt.peer.FileDialogPeer createFileDialog(java.awt.FileDialog target)
java.awt.Toolkit implementation.
Overrides:
createFileDialog in class java.awt.Toolkit
See Also:
Toolkit

createCheckboxMenuItem

public java.awt.peer.CheckboxMenuItemPeer createCheckboxMenuItem(java.awt.CheckboxMenuItem target)
java.awt.Toolkit implementation.
Overrides:
createCheckboxMenuItem in class java.awt.Toolkit
See Also:
Toolkit

createComponent

public java.awt.peer.LightweightPeer createComponent(java.awt.Component target)
java.awt.Toolkit implementation.
Overrides:
createComponent in class java.awt.Toolkit
See Also:
Toolkit

getFontPeer

public java.awt.peer.FontPeer getFontPeer(java.lang.String name,
                                          int style)
Returns a FontPeer instance matching to font name with style. If font directory changed, any font available in the new directory will be loaded first. This enables to share a JVM with different users and different font directories.
Overrides:
getFontPeer in class java.awt.Toolkit
Parameters:
name - The font name.
style - The font style (Font.PLAIN, Font.ITALIC, Font.BOLD or Font.BOLD | Font.ITALIC)
Returns:
null if the font doesn't exist.
See Also:
loadFonts()

loadSystemColors

public void loadSystemColors(int[] systemColors)
java.awt.Toolkit implementation. Does nothing.
Overrides:
loadSystemColors in class java.awt.Toolkit
See Also:
Toolkit

getScreenSize

public java.awt.Dimension getScreenSize()
java.awt.Toolkit implementation.
Overrides:
getScreenSize in class java.awt.Toolkit
See Also:
Toolkit

getScreenResolution

public int getScreenResolution()
java.awt.Toolkit implementation.
Overrides:
getScreenResolution in class java.awt.Toolkit
See Also:
Toolkit

getColorModel

public java.awt.image.ColorModel getColorModel()
java.awt.Toolkit implementation.
Overrides:
getColorModel in class java.awt.Toolkit
See Also:
Toolkit

getFontsDirectory

public static java.lang.String getFontsDirectory()
Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.getFontsDirectory ().

Returns a font directory.

loadFonts

public static void loadFonts()
Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.loadFonts ().

Loads all font files (with extension .pjaf) from the directory returned by getFontsDirectory ().

loadFonts

public static void loadFonts(java.lang.String dir)
Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.loadFonts (String).

Loads all font files (with extension .pjaf) in the dir directory. May be called more than once.
Parameters:
dir - Directory where the font files are seeked.

getFontList

public java.lang.String[] getFontList()
java.awt.Toolkit implementation.
Overrides:
getFontList in class java.awt.Toolkit
See Also:
Toolkit

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font font)
java.awt.Toolkit implementation.
Overrides:
getFontMetrics in class java.awt.Toolkit
See Also:
Toolkit

getDefaultFont

public static java.lang.String getDefaultFont()
Deprecated. As of PJA version 1.1, replaced by PJAGraphicsManager.getDefaultFont ().

Returns the default font name. You may override this method to have a different font.

sync

public void sync()
java.awt.Toolkit implementation. Does nothing.
Overrides:
sync in class java.awt.Toolkit
See Also:
Toolkit

getImage

public java.awt.Image getImage(java.lang.String filename)
java.awt.Toolkit implementation.
Overrides:
getImage in class java.awt.Toolkit
See Also:
Toolkit

getImage

public java.awt.Image getImage(java.net.URL url)
java.awt.Toolkit implementation.
Overrides:
getImage in class java.awt.Toolkit
See Also:
Toolkit

createImage

public java.awt.Image createImage(java.lang.String filename)
java.awt.Toolkit implementation.
Overrides:
createImage in class java.awt.Toolkit
See Also:
Toolkit

createImage

public java.awt.Image createImage(java.net.URL url)
java.awt.Toolkit implementation.
Overrides:
createImage in class java.awt.Toolkit
See Also:
Toolkit

prepareImage

public boolean prepareImage(java.awt.Image image,
                            int width,
                            int height,
                            java.awt.image.ImageObserver observer)
java.awt.Toolkit implementation.
Overrides:
prepareImage in class java.awt.Toolkit
See Also:
Toolkit

checkImage

public int checkImage(java.awt.Image image,
                      int width,
                      int height,
                      java.awt.image.ImageObserver observer)
java.awt.Toolkit implementation.
Overrides:
checkImage in class java.awt.Toolkit
See Also:
Toolkit

createImage

public java.awt.Image createImage(java.awt.image.ImageProducer producer)
java.awt.Toolkit implementation.
Overrides:
createImage in class java.awt.Toolkit
See Also:
Toolkit

createImage

public java.awt.Image createImage(byte[] imagedata,
                                  int imageoffset,
                                  int imagelength)
java.awt.Toolkit implementation.
Overrides:
createImage in class java.awt.Toolkit
See Also:
Toolkit

beep

public void beep()
java.awt.Toolkit implementation. Does nothing.
Overrides:
beep in class java.awt.Toolkit
See Also:
Toolkit

getPrintJob

public java.awt.PrintJob getPrintJob(java.awt.Frame frame,
                                     java.lang.String jobtitle,
                                     java.util.Properties props)
java.awt.Toolkit implementation. Returns null.
Overrides:
getPrintJob in class java.awt.Toolkit
See Also:
Toolkit

getSystemClipboard

public java.awt.datatransfer.Clipboard getSystemClipboard()
java.awt.Toolkit implementation. Returns null.
Overrides:
getSystemClipboard in class java.awt.Toolkit
See Also:
Toolkit

getSystemEventQueueImpl

public java.awt.EventQueue getSystemEventQueueImpl()
java.awt.Toolkit implementation. As of PJA version 2.2, returns a dummy EventQueue.
Overrides:
getSystemEventQueueImpl in class java.awt.Toolkit
See Also:
Toolkit

createDragSourceContextPeer

public java.awt.dnd.peer.DragSourceContextPeer createDragSourceContextPeer(java.awt.dnd.DragGestureEvent dge)
java.awt.Toolkit implementation. Returns null.
Overrides:
createDragSourceContextPeer in class java.awt.Toolkit
See Also:
Toolkit

mapInputMethodHighlight

public java.util.Map mapInputMethodHighlight(java.awt.im.InputMethodHighlight highlight)
java.awt.Toolkit implementation. Returns null.
Overrides:
mapInputMethodHighlight in class java.awt.Toolkit
See Also:
Toolkit

main

public static void main(java.lang.String[] args)
Deprecated. As of PJA version 1.1, replaced by PJANativeToolkitComparison.main (args).


© 1997-2001 eTeks - All rights reserved