com.yospace.yae.yogi
Class NativeResources

java.lang.Object
  |
  +--com.yospace.yae.yogi.NativeResources
Direct Known Subclasses:
MIDletResources

public abstract class NativeResources
extends java.lang.Object

The controller and access point for the native resources needed by YAE and YoGI.

It may be assumed that this class and its subclasses are completely constructed before any other Toolkit or YogiRootPane subsystems are alive. Thus, it is important that no complex YoGI operations are invoked during the construction phase of this class, as they may not yet be initialized.


Constructor Summary
protected NativeResources()
          Constructor is protected so that NativeResources displays singleton characteristics.
 
Method Summary
abstract  Image createImage(byte[] imageData, int imageOffset, int imageLength)
          Creates an immutable native image which is decoded from the data stored in the specified byte array at the specified offset and length.
abstract  Image createImage(Image source)
          Creates an immutable image from a source image.
abstract  Image createImage(java.lang.String name)
          Creates an immutable image from decoded image data obtained from the named resource.
abstract  Font createNativeFont(int face, int style, int size)
          Creates a MIDP Font given a typeface, style and size.
static NativeResources get()
          Accessor method that gets the current NativeResources object.
abstract  int getCanvasHeight()
          Gets the canvas height.
abstract  int getCanvasWidth()
          Gets the canvas width.
static javax.microedition.lcdui.Display getDisplay()
          Convenience method for getting the MIDP Display of the current NativeResources object.
protected abstract  javax.microedition.lcdui.Display getDisplayImpl()
          Template method for accessing the Display.
static Graphics getGraphics()
          Convenience method for getting the Graphics of the current NativeResources object.
protected abstract  Graphics getGraphicsImpl()
          Template method for accessing the Graphics.
abstract  java.lang.String getProperty(java.lang.String propName)
          Gets the named property supplied in the Panelet URL.
abstract  java.lang.String getSystemProperty(java.lang.String name)
          Template method for accessing system properties.
 void grabResources(java.lang.Object key)
          Tells us that it is time to grab heavy resources, as YoGI is now online.
protected  void grabResourcesImpl()
          Template method for grabbing native resources.
abstract  void repaint()
          Requests a repaint of the whole canvas.
abstract  void repaint(int x, int y, int width, int height)
          Requests a repaint of a rectangular area of the canvas.
abstract  void serviceRepaints()
          Forces all pending repaints to be completed immediately.
static void set(NativeResources ynr)
          Sets the NativeResources to be ynr.
static void setKey(java.lang.Object theKey)
          Sets up the key to validate resource grabbing and trimming reation requests against.
 void trimResources(java.lang.Object key)
          Tells us that it is time to lose any heavy resources as the Panelet system is idle.
protected  void trimResourcesImpl()
          Template method for trimming native resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeResources

protected NativeResources()
Constructor is protected so that NativeResources displays singleton characteristics.
Method Detail

set

public static void set(NativeResources ynr)
Sets the NativeResources to be ynr.
Parameters:
ynr - the NativeResources to be used.

setKey

public static final void setKey(java.lang.Object theKey)
Sets up the key to validate resource grabbing and trimming reation requests against. Can only be performed once per 'run' of the VM.
Parameters:
theKey - the key to use.

get

public static NativeResources get()
Accessor method that gets the current NativeResources object.
Returns:
the current NativeResources.

getGraphics

public static Graphics getGraphics()
Convenience method for getting the Graphics of the current NativeResources object. Calls getGraphicsImpl().
Returns:
the current Graphics.

getDisplay

public static javax.microedition.lcdui.Display getDisplay()
Convenience method for getting the MIDP Display of the current NativeResources object. Calls getDisplayImpl().
Returns:
the current MIDP Display.

getGraphicsImpl

protected abstract Graphics getGraphicsImpl()
Template method for accessing the Graphics.

getDisplayImpl

protected abstract javax.microedition.lcdui.Display getDisplayImpl()
Template method for accessing the Display.

getSystemProperty

public abstract java.lang.String getSystemProperty(java.lang.String name)
Template method for accessing system properties.
Parameters:
name - the name of the requested property.
Returns:
the corresponding property value.
Throws:
NullPointerException - if there is no such property.

trimResources

public final void trimResources(java.lang.Object key)
Tells us that it is time to lose any heavy resources as the Panelet system is idle. Stop threads, remove canvases, lose weight.

Calls trimResourcesImpl() if the key is valid.

Parameters:
key - the key for the NativeResources.

trimResourcesImpl

protected void trimResourcesImpl()
Template method for trimming native resources.

grabResources

public final void grabResources(java.lang.Object key)
Tells us that it is time to grab heavy resources, as YoGI is now online. In particular, we should restart anything that we dumped if trimResources() was called.

Calls grabResourcesImpl() if the key is valid.

Parameters:
key - the key for the NativeResources.

grabResourcesImpl

protected void grabResourcesImpl()
Template method for grabbing native resources.

getCanvasWidth

public abstract int getCanvasWidth()
Gets the canvas width.
Returns:
the canvas width.

getCanvasHeight

public abstract int getCanvasHeight()
Gets the canvas height.
Returns:
the canvas height.

repaint

public abstract void repaint()
Requests a repaint of the whole canvas.

repaint

public abstract void repaint(int x,
                             int y,
                             int width,
                             int height)
Requests a repaint of a rectangular area of the canvas.
Parameters:
x - the x coordinate of the top-left corner of the rectangle.
y - the y coordinate of the top-left corner of the rectangle.
width - the width of the rectangle.
height - the height of the rectangle.

serviceRepaints

public abstract void serviceRepaints()
Forces all pending repaints to be completed immediately.

createNativeFont

public abstract Font createNativeFont(int face,
                                      int style,
                                      int size)
Creates a MIDP Font given a typeface, style and size.
Parameters:
face - the typeface of the font.
style - the style of the font.
size - the size of the font.
See Also:
Font

createImage

public abstract Image createImage(byte[] imageData,
                                  int imageOffset,
                                  int imageLength)
Creates an immutable native image which is decoded from the data stored in the specified byte array at the specified offset and length. A yogi image is then created based on this native image.
Parameters:
imageData - the array of image data in a supported image format
imageOffset - the offset of the start of the data in the array
imageLength - the length of the data in the array
Returns:
a new YoGI Image if creation of the native Image was successful

createImage

public abstract Image createImage(Image source)
Creates an immutable image from a source image.
Parameters:
source - the source image to be copied.
Returns:
the new, immutable YoGI Image.

createImage

public abstract Image createImage(java.lang.String name)
Creates an immutable image from decoded image data obtained from the named resource.
Parameters:
name - the name of the resource containing the image data in one of the supported image formats
Returns:
a new YoGI Image if creation of the native Image was successful

getProperty

public abstract java.lang.String getProperty(java.lang.String propName)
Gets the named property supplied in the Panelet URL.
Parameters:
propName - name of the required property.
Returns:
the relevant property value.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.