com.sun.lwuit.impl.android
Class AndroidImplementation

java.lang.Object
  extended by com.sun.lwuit.impl.LWUITImplementation
      extended by com.sun.lwuit.impl.android.AndroidImplementation
All Implemented Interfaces:
android.view.View.OnFocusChangeListener

public class AndroidImplementation
extends LWUITImplementation
implements android.view.View.OnFocusChangeListener


Field Summary
protected  int defaultFontHeight
           
static int DROID_IMPL_KEY_BACK
           
static int DROID_IMPL_KEY_BACKSPACE
           
static int DROID_IMPL_KEY_CLEAR
           
static int DROID_IMPL_KEY_DOWN
           
static int DROID_IMPL_KEY_FIRE
           
static int DROID_IMPL_KEY_LEFT
          make sure these important keys have a negative value when passed to LWUIT or they might be interpreted as characters.
static int DROID_IMPL_KEY_MENU
           
static int DROID_IMPL_KEY_RIGHT
           
static int DROID_IMPL_KEY_SYMBOL
           
static int DROID_IMPL_KEY_UP
           
 
Constructor Summary
AndroidImplementation()
           
 
Method Summary
 int charsWidth(java.lang.Object nativeFont, char[] ch, int offset, int length)
          Return the width of the given characters in the given native font instance
 int charWidth(java.lang.Object nativeFont, char ch)
          Return the width of the specific character when rendered alone
protected  void clearVirtualKeyboard()
          Deprecated.  
 void clipRect(java.lang.Object graphics, int x, int y, int width, int height)
          Changes the current clipping rectangle to subset the current clipping with the given clipping.
 void confirmControlView()
          Callback method allowing the implementation to confirm that it controls the view just before a new form is installed.
 java.lang.Object createFont(int face, int style, int size)
          Creates a new instance of a native font
 java.lang.Object createImage(byte[] bytes, int offset, int len)
          Create a nativate image from its compressed byte data
 java.lang.Object createImage(java.io.InputStream i)
          Creates a native image from a given input stream
 java.lang.Object createImage(int[] rgb, int width, int height)
          Create a platform native image object from the given RGB data
 java.lang.Object createImage(java.lang.String path)
          Creates a native image from a file in the system jar
 java.lang.Object createMutableImage(int width, int height, int fillColor)
          Creates a modifable native image that can return a graphics object
 PeerComponent createNativePeer(java.lang.Object nativeComponent)
          Creates a peer component for the given lightweight component
 java.lang.Object createSoftWeakRef(java.lang.Object o)
          Creates a soft/weak reference to an object that allows it to be collected yet caches it.
 void drawArc(java.lang.Object graphics, int x, int y, int width, int height, int startAngle, int arcAngle)
          Draws a circular or elliptical arc based on the given angles and bounding box
 void drawChar(java.lang.Object graphics, char c, int x, int y)
          the next two methods are not used yet and are part of a potential performance enhancement.
 void drawChars(java.lang.Object graphics, char[] c, int offset, int length, int x, int y)
           
 void drawImage(java.lang.Object graphics, java.lang.Object img, int x, int y)
          Draws the image so its top left coordinate corresponds to x/y
 void drawLine(java.lang.Object graphics, int x1, int y1, int x2, int y2)
          Draws a line between the 2 X/Y coordinates
 void drawPolygon(java.lang.Object graphics, int[] xPoints, int[] yPoints, int nPoints)
          Draws a closed polygon defined by arrays of x and y coordinates.
 void drawRect(java.lang.Object graphics, int x, int y, int width, int height)
          Draws a rectangle in the given coordinates
 void drawRGB(java.lang.Object graphics, int[] rgbData, int offset, int x, int y, int w, int h, boolean processAlpha)
          Draws the RGB values based on the MIDP API of a similar name.
 void drawRoundRect(java.lang.Object graphics, int x, int y, int width, int height, int arcWidth, int arcHeight)
          Draws a rounded corner rectangle in the given coordinates with the arcWidth/height matching the last two arguments respectively.
 void drawString(java.lang.Object graphics, java.lang.String str, int x, int y)
          Draw a string using the current font and color in the x,y coordinates.
protected  boolean editInProgress()
           
 void editString(Component cmp, int maxSize, int constraint, java.lang.String text)
          Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.
 java.lang.Object extractHardRef(java.lang.Object o)
          Extracts the hard reference from the soft/weak reference given
 void fillArc(java.lang.Object graphics, int x, int y, int width, int height, int startAngle, int arcAngle)
          Fills a circular or elliptical arc based on the given angles and bounding box.
 void fillPolygon(java.lang.Object graphics, int[] xPoints, int[] yPoints, int nPoints)
          Fills a closed polygon defined by arrays of x and y coordinates.
 void fillRect(java.lang.Object graphics, int x, int y, int width, int height)
          Fills the rectangle from the given position according to the width/height minus 1 pixel according to the convention in Java.
 void fillRoundRect(java.lang.Object graphics, int x, int y, int width, int height, int arcWidth, int arcHeight)
          Fills a rounded rectangle in the same way as drawRoundRect
 void flushGraphics()
          Flush the currently painted drawing onto the screen if using a double buffer
 void flushGraphics(int x, int y, int width, int height)
          Flush the currently painted drawing onto the screen if using a double buffer
 int getAlpha(java.lang.Object graphics)
          Alpha value from 0-255 can be ignored for some operations
 int getBackKeyCode()
          Returns the keycode for the back key
 int getBackspaceKeyCode()
          Returns the keycode for the backspace key
 int getClearKeyCode()
          Returns the keycode for the clear key
 int getClipHeight(java.lang.Object graphics)
          Returns the clipping coordinate
 int getClipWidth(java.lang.Object graphics)
          Returns the clipping coordinate
 int getClipX(java.lang.Object graphics)
          Returns the clipping coordinate
 int getClipY(java.lang.Object graphics)
          Returns the clipping coordinate
 int getColor(java.lang.Object graphics)
          Returns the current color
 java.lang.Object getDefaultFont()
          Return the global default font instance, if font is passed as null this font should be used
 int getDeviceDensity()
          Returns one of the density variables appropriate for this device, notice that density doesn't alwyas correspond to resolution and an implementation might decide to change the density based on DPI constraints.
 int getDisplayHeight()
          Returns the height dimention of the display controlled by this implementation
 int getDisplayWidth()
          Returns the width dimention of the display controlled by this implementation
protected  int getDragAutoActivationThreshold()
          This method allows subclasses to manipulate the drag started detection logic.
 int getGameAction(int keyCode)
          Returns the display game action for the given keyCode if applicable to match the contrct of LWUIT for the game action behavior
 int getHeight(java.lang.Object nativeFont)
          Return the total height of the font
 int getImageHeight(java.lang.Object i)
          Returns the height of a native image
 int getImageWidth(java.lang.Object i)
          Returns the width of a native image
 int getKeyboardType()
          Returns the type of the input device one of: KEYBOARD_TYPE_UNKNOWN, KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY, KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY
 int getKeyCode(int gameAction)
          Returns a keycode which can be sent to getGameAction
 java.lang.Object getNativeGraphics()
          Returns the native graphics object on which all rendering operations occur
 java.lang.Object getNativeGraphics(java.lang.Object image)
          Returns the native graphics object on the given native image occur
 java.io.InputStream getResourceAsStream(java.lang.Class cls, java.lang.String resource)
          This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.
 void getRGB(java.lang.Object nativeImage, int[] arr, int offset, int x, int y, int width, int height)
          Extracts RGB data from the given native image and places it in the given array
 int getSize(java.lang.Object nativeFont)
          Optional operation returning the font size for system fonts
 int[] getSoftkeyCode(int index)
          Returns the softkey keycode for the given softkey index
 int getSoftkeyCount()
          Returns the number of softkeys on the device
 int getStyle(java.lang.Object nativeFont)
          Optional operation returning the font style for system fonts
 boolean handleEDTException(java.lang.Throwable err)
          Invoked when an exception occurs on the EDT, allows the implementation to take control of the device to produce testing information.
 boolean hasPendingPaints()
          Returns true if the implementation still has elements to paint.
 void hideNotifyPublic()
           
 void init(java.lang.Object m)
          Invoked by the display init method allowing the implementation to "bind"
 boolean isAlphaGlobal()
          Returns true if alpha can be applied for all elements globally and efficiently otherwise alpha should be ignored.
 boolean isAlphaMutableImageSupported()
          Indicates whether mutable images respect alpha values when constructed
 boolean isAntiAliasedTextSupported()
          Indicates whether the underlying implementation allows for anti-aliased fonts
 boolean isAntiAliasingSupported()
          Indicates whether the underlying implementation allows for anti-aliasing in regular drawing operations
 boolean isLookupFontSupported()
          Indicates whether loading a font by a string is supported by the platform
 boolean isMinimized()
          Indicates whether an application is minimized
 boolean isRotationDrawingSupported()
          Indicates whether drawImageRotated is supported by the platform for FAST drawing, if not then its not worth calling the method which will be unimplemented!
 boolean isTouchDevice()
          Returns true if the device will send touch events
 boolean isVirtualKeyboardShowing()
          Deprecated.  
 boolean isVirtualKeyboardShowingSupported()
          Deprecated.  
 java.lang.Object loadNativeFont(java.lang.String lookup)
          Loads a native font based on a lookup for a font name and attributes.
 boolean minimizeApplication()
          Minimizes the current application if minimization is supported by the platform (may fail).
 void onFocusChange(android.view.View view, boolean bln)
           
protected  void pointerDragged(int x, int y)
          Subclasses should invoke this method, it delegates the event to the display and into LWUIT.
protected  void pointerPressed(int x, int y)
          Subclasses should invoke this method, it delegates the event to the display and into LWUIT.
protected  void pointerReleased(int x, int y)
          Subclasses should invoke this method, it delegates the event to the display and into LWUIT.
 void restoreMinimizedApplication()
          Restore the minimized application if minimization is supported by the platform
 void revalidate()
           
 java.lang.Object rotate(java.lang.Object image, int degrees)
          Returns an instance of this image rotated by the given number of degrees.
 java.lang.Object scale(java.lang.Object nativeImage, int width, int height)
          Scales a native image and returns the scaled version
 void setAlpha(java.lang.Object graphics, int alpha)
          Alpha value from 0-255 can be ignored for some operations
 void setAntiAliased(java.lang.Object graphics, boolean a)
          Toggles anti-aliasing mode for regular rendering operations
 void setAntiAliasedText(java.lang.Object graphics, boolean a)
          Toggles anti-aliasing mode for font rendering operations
 void setClip(java.lang.Object graphics, int x, int y, int width, int height)
          Installs a new clipping rectangle
 void setColor(java.lang.Object graphics, int RGB)
          Sets the current rgb color while ignoring any potential alpha component within said color value.
protected  void setLastSizeChangedWH(int w, int h)
           
 void setNativeCommands(java.util.Vector commands)
          Places the following commands on the native menu system
 void setNativeFont(java.lang.Object graphics, java.lang.Object font)
          Installs a native font object
 void setShowVirtualKeyboard(boolean show)
          Deprecated.  
 void showNativeScreen(java.lang.Object nativeFullScreenPeer)
          Shows a native Form/Canvas or some other heavyweight native screen
 void showNotifyPublic()
           
 int stringWidth(java.lang.Object nativeFont, java.lang.String str)
          Return the width of the given string in this font instance
 int translatePixelForDPI(int pixel)
           
 void vibrate(int duration)
          Vibrates the device for the given length of time
 
Methods inherited from class com.sun.lwuit.impl.LWUITImplementation
animateImage, cacheLinearGradients, cacheRadialGradients, cleanupAudio, clipRect, convertBidiLogicalToVisual, convertBuiltinSound, createAudio, createAudio, createNativeIndexed, createSVGImage, createVideoComponent, createVideoPeer, deinitialize, drawImageArea, drawImageRotated, edtIdle, execute, exitApplication, fillLinearGradient, fillRadialGradient, fillRectRadialGradient, fillTriangle, flashBacklight, getAudioDuration, getAudioTime, getCharLocation, getClipRect, getCurrentForm, getDisplayLock, getDragPathLength, getDragPathTime, getDragSpeed, getDragStartPercentage, getFace, getFontPlatformNames, getLWUITGraphics, getMediaTime, getProperty, getSVGDocument, getTranslateX, getTranslateY, getVideoControl, getVideoHeight, getVideoWidth, getVolume, hasDragStarted, hasDragStarted, hideNotify, installBuiltinSound, isAffineSupported, isAnimation, isAntiAliased, isAntiAliasedText, isBidiAlgorithm, isBuiltinSoundAvailable, isBuiltinSoundsEnabled, isClickTouchScreen, isMultiTouch, isNativeIndexed, isNativeInputSupported, isOpaque, isRTL, isRTLOrWhitespace, isSVGSupported, isThirdSoftButton, isTranslationSupported, isTrueTypeSupported, keyPressed, keyReleased, loadTrueTypeFont, notifyCommandBehavior, numAlphaLevels, numColors, paintDirty, paintOverlay, paintVideo, pauseAudio, playAudio, playBuiltinSound, playDialogSound, playNativeBuiltinSound, playUserSound, pointerDragged, pointerHover, pointerHover, pointerHoverPressed, pointerHoverPressed, pointerHoverReleased, pointerHoverReleased, pointerPressed, pointerReleased, repaint, resetAffine, rotate, saveTextEditingState, scale, setAudioTime, setBidiAlgorithm, setBuiltinSoundsEnabled, setClipRect, setCurrentForm, setDisplayLock, setDragStartPercentage, setLWUITGraphics, setMediaTime, setVideoFullScreen, setVideoFullScreen, setVideoLoopCount, setVideoVisible, setVolume, shear, showNotify, sizeChanged, startVideo, stopVideo, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DROID_IMPL_KEY_LEFT

public static final int DROID_IMPL_KEY_LEFT
make sure these important keys have a negative value when passed to LWUIT or they might be interpreted as characters.

See Also:
Constant Field Values

DROID_IMPL_KEY_RIGHT

public static final int DROID_IMPL_KEY_RIGHT
See Also:
Constant Field Values

DROID_IMPL_KEY_UP

public static final int DROID_IMPL_KEY_UP
See Also:
Constant Field Values

DROID_IMPL_KEY_DOWN

public static final int DROID_IMPL_KEY_DOWN
See Also:
Constant Field Values

DROID_IMPL_KEY_FIRE

public static final int DROID_IMPL_KEY_FIRE
See Also:
Constant Field Values

DROID_IMPL_KEY_MENU

public static final int DROID_IMPL_KEY_MENU
See Also:
Constant Field Values

DROID_IMPL_KEY_BACK

public static final int DROID_IMPL_KEY_BACK
See Also:
Constant Field Values

DROID_IMPL_KEY_BACKSPACE

public static final int DROID_IMPL_KEY_BACKSPACE
See Also:
Constant Field Values

DROID_IMPL_KEY_CLEAR

public static final int DROID_IMPL_KEY_CLEAR
See Also:
Constant Field Values

DROID_IMPL_KEY_SYMBOL

public static final int DROID_IMPL_KEY_SYMBOL
See Also:
Constant Field Values

defaultFontHeight

protected int defaultFontHeight
Constructor Detail

AndroidImplementation

public AndroidImplementation()
Method Detail

init

public void init(java.lang.Object m)
Description copied from class: LWUITImplementation
Invoked by the display init method allowing the implementation to "bind"

Specified by:
init in class LWUITImplementation
Parameters:
m - the object passed to the Display init method

translatePixelForDPI

public int translatePixelForDPI(int pixel)

getDeviceDensity

public int getDeviceDensity()
Description copied from class: LWUITImplementation
Returns one of the density variables appropriate for this device, notice that density doesn't alwyas correspond to resolution and an implementation might decide to change the density based on DPI constraints.

Overrides:
getDeviceDensity in class LWUITImplementation
Returns:
one of the DENSITY constants of Display

confirmControlView

public void confirmControlView()
Description copied from class: LWUITImplementation
Callback method allowing the implementation to confirm that it controls the view just before a new form is installed.

Overrides:
confirmControlView in class LWUITImplementation

editInProgress

protected boolean editInProgress()

hideNotifyPublic

public void hideNotifyPublic()

showNotifyPublic

public void showNotifyPublic()

isMinimized

public boolean isMinimized()
Description copied from class: LWUITImplementation
Indicates whether an application is minimized

Overrides:
isMinimized in class LWUITImplementation
Returns:
true if the application is minimized

minimizeApplication

public boolean minimizeApplication()
Description copied from class: LWUITImplementation
Minimizes the current application if minimization is supported by the platform (may fail). Returns false if minimization failed.

Overrides:
minimizeApplication in class LWUITImplementation
Returns:
false if minimization failed true if it succeeded or seems to be successful

restoreMinimizedApplication

public void restoreMinimizedApplication()
Description copied from class: LWUITImplementation
Restore the minimized application if minimization is supported by the platform

Overrides:
restoreMinimizedApplication in class LWUITImplementation

editString

public void editString(Component cmp,
                       int maxSize,
                       int constraint,
                       java.lang.String text)
Description copied from class: LWUITImplementation
Encapsulates the editing code which is specific to the platform, some platforms would allow "in place editing" MIDP does not.

Specified by:
editString in class LWUITImplementation
Parameters:
cmp - the TextArea component
maxSize - the maximum size from the text area
constraint - the constraints of the text area
text - the string to edit

setLastSizeChangedWH

protected void setLastSizeChangedWH(int w,
                                    int h)

handleEDTException

public boolean handleEDTException(java.lang.Throwable err)
Description copied from class: LWUITImplementation
Invoked when an exception occurs on the EDT, allows the implementation to take control of the device to produce testing information.

Overrides:
handleEDTException in class LWUITImplementation
Parameters:
err - the exception that was caught in the EDT loop
Returns:
false by default, true if the exception shouldn't be handled further by the EDT

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.Class cls,
                                               java.lang.String resource)
Description copied from class: LWUITImplementation
This method is essentially equivalent to cls.getResourceAsStream(String) however some platforms might define unique ways in which to load resources within the implementation.

Overrides:
getResourceAsStream in class LWUITImplementation
Parameters:
cls - class to load the resource from
resource - relative/absolute URL based on the Java convention
Returns:
input stream for the resource or null if not found

pointerPressed

protected void pointerPressed(int x,
                              int y)
Description copied from class: LWUITImplementation
Subclasses should invoke this method, it delegates the event to the display and into LWUIT.

Overrides:
pointerPressed in class LWUITImplementation
Parameters:
x - the position of the event
y - the position of the event

pointerReleased

protected void pointerReleased(int x,
                               int y)
Description copied from class: LWUITImplementation
Subclasses should invoke this method, it delegates the event to the display and into LWUIT.

Overrides:
pointerReleased in class LWUITImplementation
Parameters:
x - the position of the event
y - the position of the event

pointerDragged

protected void pointerDragged(int x,
                              int y)
Description copied from class: LWUITImplementation
Subclasses should invoke this method, it delegates the event to the display and into LWUIT.

Overrides:
pointerDragged in class LWUITImplementation
Parameters:
x - the position of the event
y - the position of the event

getDragAutoActivationThreshold

protected int getDragAutoActivationThreshold()
Description copied from class: LWUITImplementation
This method allows subclasses to manipulate the drag started detection logic. If more than this number of drag events were delivered it is safe to assume a drag has started This number must be bigger than 0!

Overrides:
getDragAutoActivationThreshold in class LWUITImplementation
Returns:
number representing a minimum number of motion events to start a drag operation

flushGraphics

public void flushGraphics()
Description copied from class: LWUITImplementation
Flush the currently painted drawing onto the screen if using a double buffer

Specified by:
flushGraphics in class LWUITImplementation

flushGraphics

public void flushGraphics(int x,
                          int y,
                          int width,
                          int height)
Description copied from class: LWUITImplementation
Flush the currently painted drawing onto the screen if using a double buffer

Specified by:
flushGraphics in class LWUITImplementation
Parameters:
x - position of the dirty region
y - position of the dirty region
width - width of the dirty region
height - height of the dirty region

charWidth

public int charWidth(java.lang.Object nativeFont,
                     char ch)
Description copied from class: LWUITImplementation
Return the width of the specific character when rendered alone

Specified by:
charWidth in class LWUITImplementation
Parameters:
nativeFont - the font for which the string width should be calculated
ch - the specific character
Returns:
the width of the specific character when rendered alone

charsWidth

public int charsWidth(java.lang.Object nativeFont,
                      char[] ch,
                      int offset,
                      int length)
Description copied from class: LWUITImplementation
Return the width of the given characters in the given native font instance

Specified by:
charsWidth in class LWUITImplementation
Parameters:
nativeFont - the font for which the string width should be calculated
ch - array of characters
offset - characters offsets
length - characters length
Returns:
the width of the given characters in this font instance

stringWidth

public int stringWidth(java.lang.Object nativeFont,
                       java.lang.String str)
Description copied from class: LWUITImplementation
Return the width of the given string in this font instance

Specified by:
stringWidth in class LWUITImplementation
Parameters:
nativeFont - the font for which the string width should be calculated
str - the given string *
Returns:
the width of the given string in this font instance

setNativeFont

public void setNativeFont(java.lang.Object graphics,
                          java.lang.Object font)
Description copied from class: LWUITImplementation
Installs a native font object

Specified by:
setNativeFont in class LWUITImplementation
Parameters:
graphics - the graphics context
font - the native font object

getHeight

public int getHeight(java.lang.Object nativeFont)
Description copied from class: LWUITImplementation
Return the total height of the font

Specified by:
getHeight in class LWUITImplementation
Parameters:
nativeFont - the font for which the string width should be calculated
Returns:
the total height of the font

getSize

public int getSize(java.lang.Object nativeFont)
Description copied from class: LWUITImplementation
Optional operation returning the font size for system fonts

Overrides:
getSize in class LWUITImplementation
Parameters:
nativeFont - the font for which the string width should be calculated
Returns:
Optional operation returning the font size for system fonts

getStyle

public int getStyle(java.lang.Object nativeFont)
Description copied from class: LWUITImplementation
Optional operation returning the font style for system fonts

Overrides:
getStyle in class LWUITImplementation
Parameters:
nativeFont - the font for which the string width should be calculated
Returns:
Optional operation returning the font style for system fonts

createFont

public java.lang.Object createFont(int face,
                                   int style,
                                   int size)
Description copied from class: LWUITImplementation
Creates a new instance of a native font

Specified by:
createFont in class LWUITImplementation
Parameters:
face - the face of the font, can be one of FACE_SYSTEM, FACE_PROPORTIONAL, FACE_MONOSPACE.
style - the style of the font. The value is an OR'ed combination of STYLE_BOLD, STYLE_ITALIC, and STYLE_UNDERLINED; or the value is zero (STYLE_PLAIN).
size - the size of the font, can be one of SIZE_SMALL, SIZE_MEDIUM, SIZE_LARGE
Returns:
a native font object

loadNativeFont

public java.lang.Object loadNativeFont(java.lang.String lookup)
Loads a native font based on a lookup for a font name and attributes. Font lookup values can be separated by commas and thus allow fallback if the primary font isn't supported by the platform.

Overrides:
loadNativeFont in class LWUITImplementation
Parameters:
lookup - string describing the font
Returns:
the native font object

isLookupFontSupported

public boolean isLookupFontSupported()
Indicates whether loading a font by a string is supported by the platform

Overrides:
isLookupFontSupported in class LWUITImplementation
Returns:
true if the platform supports font lookup

isAntiAliasedTextSupported

public boolean isAntiAliasedTextSupported()
Description copied from class: LWUITImplementation
Indicates whether the underlying implementation allows for anti-aliased fonts

Overrides:
isAntiAliasedTextSupported in class LWUITImplementation
Returns:
false by default

setAntiAliasedText

public void setAntiAliasedText(java.lang.Object graphics,
                               boolean a)
Description copied from class: LWUITImplementation
Toggles anti-aliasing mode for font rendering operations

Overrides:
setAntiAliasedText in class LWUITImplementation
Parameters:
graphics - the graphics context
a - true to activate Anti-aliasing, false to disable it

getDefaultFont

public java.lang.Object getDefaultFont()
Description copied from class: LWUITImplementation
Return the global default font instance, if font is passed as null this font should be used

Specified by:
getDefaultFont in class LWUITImplementation
Returns:
the global default font instance

getNativeGraphics

public java.lang.Object getNativeGraphics()
Description copied from class: LWUITImplementation
Returns the native graphics object on which all rendering operations occur

Specified by:
getNativeGraphics in class LWUITImplementation
Returns:
a native graphics context

getNativeGraphics

public java.lang.Object getNativeGraphics(java.lang.Object image)
Description copied from class: LWUITImplementation
Returns the native graphics object on the given native image occur

Specified by:
getNativeGraphics in class LWUITImplementation
Parameters:
image - the native image on which the graphics will draw
Returns:
a native graphics context

getRGB

public void getRGB(java.lang.Object nativeImage,
                   int[] arr,
                   int offset,
                   int x,
                   int y,
                   int width,
                   int height)
Description copied from class: LWUITImplementation
Extracts RGB data from the given native image and places it in the given array

Specified by:
getRGB in class LWUITImplementation
Parameters:
nativeImage - native platform image object
arr - int array to store RGB data
offset - position within the array to start
x - x position within the image
y - y position within the image
width - width to extract
height - height to extract

createImage

public java.lang.Object createImage(java.lang.String path)
                             throws java.io.IOException
Description copied from class: LWUITImplementation
Creates a native image from a file in the system jar

Specified by:
createImage in class LWUITImplementation
Parameters:
path - within the jar
Returns:
native system image
Throws:
java.io.IOException - if thrown by loading

createImage

public java.lang.Object createImage(java.io.InputStream i)
                             throws java.io.IOException
Description copied from class: LWUITImplementation
Creates a native image from a given input stream

Specified by:
createImage in class LWUITImplementation
Parameters:
i - input stream from which to load the image
Returns:
native system image
Throws:
java.io.IOException - if thrown by loading

createImage

public java.lang.Object createImage(byte[] bytes,
                                    int offset,
                                    int len)
Description copied from class: LWUITImplementation
Create a nativate image from its compressed byte data

Specified by:
createImage in class LWUITImplementation
Parameters:
bytes - the byte array representing the image data
offset - offset within the byte array
len - the length for the image within the byte array
Returns:
a native image

createImage

public java.lang.Object createImage(int[] rgb,
                                    int width,
                                    int height)
Description copied from class: LWUITImplementation
Create a platform native image object from the given RGB data

Specified by:
createImage in class LWUITImplementation
Parameters:
rgb - ARGB data from which to create a platform image
width - width for the resulting image
height - height for the resulting image
Returns:
platform image object

isAlphaMutableImageSupported

public boolean isAlphaMutableImageSupported()
Description copied from class: LWUITImplementation
Indicates whether mutable images respect alpha values when constructed

Overrides:
isAlphaMutableImageSupported in class LWUITImplementation
Returns:
true if mutable images can have an alpha value when initially created

scale

public java.lang.Object scale(java.lang.Object nativeImage,
                              int width,
                              int height)
Description copied from class: LWUITImplementation
Scales a native image and returns the scaled version

Specified by:
scale in class LWUITImplementation
Parameters:
nativeImage - image to scale
width - width of the resulting image
height - height of the resulting image
Returns:
scaled image instance

rotate

public java.lang.Object rotate(java.lang.Object image,
                               int degrees)
Description copied from class: LWUITImplementation
Returns an instance of this image rotated by the given number of degrees. By default 90 degree angle divisions are supported, anything else is implementation dependent. This method assumes a square image. Notice that it is inefficient in the current implementation to rotate to non-square angles,

E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90 and then rotate the 45 to another 90 degrees to achieve the same effect with less memory.

Overrides:
rotate in class LWUITImplementation
degrees - A degree in right angle must be larger than 0 and up to 359 degrees
Returns:
new image instance with the closest possible rotation

isRotationDrawingSupported

public boolean isRotationDrawingSupported()
Description copied from class: LWUITImplementation
Indicates whether drawImageRotated is supported by the platform for FAST drawing, if not then its not worth calling the method which will be unimplemented!

Overrides:
isRotationDrawingSupported in class LWUITImplementation
Returns:
true if drawImageRotated will draw an image

createMutableImage

public java.lang.Object createMutableImage(int width,
                                           int height,
                                           int fillColor)
Description copied from class: LWUITImplementation
Creates a modifable native image that can return a graphics object

Specified by:
createMutableImage in class LWUITImplementation
Parameters:
width - the width of the mutable image
height - the height of the mutable image
fillColor - the ARGB fill color, alpha may be ignored based on the value of isAlphaMutableImageSupported
Returns:
the native image

getImageHeight

public int getImageHeight(java.lang.Object i)
Description copied from class: LWUITImplementation
Returns the height of a native image

Specified by:
getImageHeight in class LWUITImplementation
Parameters:
i - the native image
Returns:
the height of the native image

getImageWidth

public int getImageWidth(java.lang.Object i)
Description copied from class: LWUITImplementation
Returns the width of a native image

Specified by:
getImageWidth in class LWUITImplementation
Parameters:
i - the native image
Returns:
the width of the native image

drawImage

public void drawImage(java.lang.Object graphics,
                      java.lang.Object img,
                      int x,
                      int y)
Description copied from class: LWUITImplementation
Draws the image so its top left coordinate corresponds to x/y

Specified by:
drawImage in class LWUITImplementation
Parameters:
graphics - the graphics context
img - the specified native image to be drawn
x - the x coordinate.
y - the y coordinate.

drawLine

public void drawLine(java.lang.Object graphics,
                     int x1,
                     int y1,
                     int x2,
                     int y2)
Description copied from class: LWUITImplementation
Draws a line between the 2 X/Y coordinates

Specified by:
drawLine in class LWUITImplementation
Parameters:
graphics - the graphics context
x1 - first x position
y1 - first y position
x2 - second x position
y2 - second y position

isAntiAliasingSupported

public boolean isAntiAliasingSupported()
Description copied from class: LWUITImplementation
Indicates whether the underlying implementation allows for anti-aliasing in regular drawing operations

Overrides:
isAntiAliasingSupported in class LWUITImplementation
Returns:
false by default

setAntiAliased

public void setAntiAliased(java.lang.Object graphics,
                           boolean a)
Description copied from class: LWUITImplementation
Toggles anti-aliasing mode for regular rendering operations

Overrides:
setAntiAliased in class LWUITImplementation
Parameters:
graphics - the graphics context
a - true to activate Anti-aliasing, false to disable it

drawPolygon

public void drawPolygon(java.lang.Object graphics,
                        int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Description copied from class: LWUITImplementation
Draws a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point.

Overrides:
drawPolygon in class LWUITImplementation
Parameters:
graphics - the graphics context
xPoints - - a an array of x coordinates.
yPoints - - a an array of y coordinates.
nPoints - - a the total number of points.

fillPolygon

public void fillPolygon(java.lang.Object graphics,
                        int[] xPoints,
                        int[] yPoints,
                        int nPoints)
Description copied from class: LWUITImplementation
Fills a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point.

Overrides:
fillPolygon in class LWUITImplementation
Parameters:
graphics - the graphics context
xPoints - - a an array of x coordinates.
yPoints - - a an array of y coordinates.
nPoints - - a the total number of points.

drawRGB

public void drawRGB(java.lang.Object graphics,
                    int[] rgbData,
                    int offset,
                    int x,
                    int y,
                    int w,
                    int h,
                    boolean processAlpha)
Description copied from class: LWUITImplementation
Draws the RGB values based on the MIDP API of a similar name. Renders a series of device-independent RGB+transparency values in a specified region. The values are stored in rgbData in a format with 24 bits of RGB and an eight-bit alpha value (0xAARRGGBB), with the first value stored at the specified offset. The scanlength specifies the relative offset within the array between the corresponding pixels of consecutive rows. Any value for scanlength is acceptable (even negative values) provided that all resulting references are within the bounds of the rgbData array. The ARGB data is rasterized horizontally from left to right within each row. The ARGB values are rendered in the region specified by x, y, width and height, and the operation is subject to the current clip region and translation for this Graphics object.

Specified by:
drawRGB in class LWUITImplementation
Parameters:
graphics - the graphics context
rgbData - an array of ARGB values in the format 0xAARRGGBB
offset - the array index of the first ARGB value
x - the horizontal location of the region to be rendered
y - the vertical location of the region to be rendered
w - the width of the region to be rendered
h - the height of the region to be rendered
processAlpha - true if rgbData has an alpha channel, false if all pixels are fully opaque

drawRect

public void drawRect(java.lang.Object graphics,
                     int x,
                     int y,
                     int width,
                     int height)
Description copied from class: LWUITImplementation
Draws a rectangle in the given coordinates

Specified by:
drawRect in class LWUITImplementation
Parameters:
graphics - the graphics context
x - the x coordinate of the rectangle to be drawn.
y - the y coordinate of the rectangle to be drawn.
width - the width of the rectangle to be drawn.
height - the height of the rectangle to be drawn.

drawRoundRect

public void drawRoundRect(java.lang.Object graphics,
                          int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Description copied from class: LWUITImplementation
Draws a rounded corner rectangle in the given coordinates with the arcWidth/height matching the last two arguments respectively.

Specified by:
drawRoundRect in class LWUITImplementation
Parameters:
graphics - the graphics context
x - the x coordinate of the rectangle to be drawn.
y - the y coordinate of the rectangle to be drawn.
width - the width of the rectangle to be drawn.
height - the height of the rectangle to be drawn.
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.

drawString

public void drawString(java.lang.Object graphics,
                       java.lang.String str,
                       int x,
                       int y)
Description copied from class: LWUITImplementation
Draw a string using the current font and color in the x,y coordinates. The font is drawn from the top position and not the baseline.

Specified by:
drawString in class LWUITImplementation
Parameters:
graphics - the graphics context
str - the string to be drawn.
x - the x coordinate.
y - the y coordinate.

drawChar

public void drawChar(java.lang.Object graphics,
                     char c,
                     int x,
                     int y)
the next two methods are not used yet and are part of a potential performance enhancement. see https://lwuit.dev.java.net/issues/show_bug.cgi?id=218 for details.


drawChars

public void drawChars(java.lang.Object graphics,
                      char[] c,
                      int offset,
                      int length,
                      int x,
                      int y)

drawArc

public void drawArc(java.lang.Object graphics,
                    int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Description copied from class: LWUITImplementation
Draws a circular or elliptical arc based on the given angles and bounding box

Specified by:
drawArc in class LWUITImplementation
Parameters:
graphics - the graphics context
x - the x coordinate of the upper-left corner of the arc to be drawn.
y - the y coordinate of the upper-left corner of the arc to be drawn.
width - the width of the arc to be drawn.
height - the height of the arc to be drawn.
startAngle - the beginning angle.
arcAngle - the angular extent of the arc, relative to the start angle.

fillArc

public void fillArc(java.lang.Object graphics,
                    int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Description copied from class: LWUITImplementation
Fills a circular or elliptical arc based on the given angles and bounding box. The resulting arc begins at startAngle and extends for arcAngle degrees.

Specified by:
fillArc in class LWUITImplementation
Parameters:
graphics - the graphics context
x - the x coordinate of the upper-left corner of the arc to be filled.
y - the y coordinate of the upper-left corner of the arc to be filled.
width - the width of the arc to be filled.
height - the height of the arc to be filled.
startAngle - the beginning angle.
arcAngle - the angular extent of the arc, relative to the start angle.

fillRect

public void fillRect(java.lang.Object graphics,
                     int x,
                     int y,
                     int width,
                     int height)
Description copied from class: LWUITImplementation
Fills the rectangle from the given position according to the width/height minus 1 pixel according to the convention in Java.

Specified by:
fillRect in class LWUITImplementation
Parameters:
graphics - the graphics context
x - the x coordinate of the rectangle to be filled.
y - the y coordinate of the rectangle to be filled.
width - the width of the rectangle to be filled.
height - the height of the rectangle to be filled.

fillRoundRect

public void fillRoundRect(java.lang.Object graphics,
                          int x,
                          int y,
                          int width,
                          int height,
                          int arcWidth,
                          int arcHeight)
Description copied from class: LWUITImplementation
Fills a rounded rectangle in the same way as drawRoundRect

Specified by:
fillRoundRect in class LWUITImplementation
Parameters:
graphics - the graphics context
x - the x coordinate of the rectangle to be filled.
y - the y coordinate of the rectangle to be filled.
width - the width of the rectangle to be filled.
height - the height of the rectangle to be filled.
arcWidth - the horizontal diameter of the arc at the four corners.
arcHeight - the vertical diameter of the arc at the four corners.
See Also:
LWUITImplementation.drawRoundRect(java.lang.Object, int, int, int, int, int, int)

getAlpha

public int getAlpha(java.lang.Object graphics)
Description copied from class: LWUITImplementation
Alpha value from 0-255 can be ignored for some operations

Specified by:
getAlpha in class LWUITImplementation
Parameters:
graphics - the graphics context
Returns:
the alpha channel

setAlpha

public void setAlpha(java.lang.Object graphics,
                     int alpha)
Description copied from class: LWUITImplementation
Alpha value from 0-255 can be ignored for some operations

Specified by:
setAlpha in class LWUITImplementation
Parameters:
graphics - the graphics context
alpha - the alpha channel

isAlphaGlobal

public boolean isAlphaGlobal()
Description copied from class: LWUITImplementation
Returns true if alpha can be applied for all elements globally and efficiently otherwise alpha should be ignored. Notice that fillRect MUST always support alpha regardless of the value of this variable!

Overrides:
isAlphaGlobal in class LWUITImplementation
Returns:
true if alpha support is natively implemented

setColor

public void setColor(java.lang.Object graphics,
                     int RGB)
Description copied from class: LWUITImplementation
Sets the current rgb color while ignoring any potential alpha component within said color value.

Specified by:
setColor in class LWUITImplementation
Parameters:
graphics - the graphics context
RGB - the RGB value for the color.

getBackKeyCode

public int getBackKeyCode()
Description copied from class: LWUITImplementation
Returns the keycode for the back key

Specified by:
getBackKeyCode in class LWUITImplementation
Returns:
the system key code for this device

getBackspaceKeyCode

public int getBackspaceKeyCode()
Description copied from class: LWUITImplementation
Returns the keycode for the backspace key

Specified by:
getBackspaceKeyCode in class LWUITImplementation
Returns:
the system key code for this device

getClearKeyCode

public int getClearKeyCode()
Description copied from class: LWUITImplementation
Returns the keycode for the clear key

Specified by:
getClearKeyCode in class LWUITImplementation
Returns:
the system key code for this device

getClipHeight

public int getClipHeight(java.lang.Object graphics)
Description copied from class: LWUITImplementation
Returns the clipping coordinate

Specified by:
getClipHeight in class LWUITImplementation
Parameters:
graphics - the graphics context
Returns:
the clipping coordinate

getClipWidth

public int getClipWidth(java.lang.Object graphics)
Description copied from class: LWUITImplementation
Returns the clipping coordinate

Specified by:
getClipWidth in class LWUITImplementation
Parameters:
graphics - the graphics context
Returns:
the clipping coordinate

getClipX

public int getClipX(java.lang.Object graphics)
Description copied from class: LWUITImplementation
Returns the clipping coordinate

Specified by:
getClipX in class LWUITImplementation
Parameters:
graphics - the graphics context
Returns:
the clipping coordinate

getClipY

public int getClipY(java.lang.Object graphics)
Description copied from class: LWUITImplementation
Returns the clipping coordinate

Specified by:
getClipY in class LWUITImplementation
Parameters:
graphics - the graphics context
Returns:
the clipping coordinate

setClip

public void setClip(java.lang.Object graphics,
                    int x,
                    int y,
                    int width,
                    int height)
Description copied from class: LWUITImplementation
Installs a new clipping rectangle

Specified by:
setClip in class LWUITImplementation
Parameters:
graphics - the graphics context
x - coordinate
y - coordinate
width - size
height - size

clipRect

public void clipRect(java.lang.Object graphics,
                     int x,
                     int y,
                     int width,
                     int height)
Description copied from class: LWUITImplementation
Changes the current clipping rectangle to subset the current clipping with the given clipping.

Specified by:
clipRect in class LWUITImplementation
Parameters:
graphics - the graphics context
x - coordinate
y - coordinate
width - size
height - size

getColor

public int getColor(java.lang.Object graphics)
Description copied from class: LWUITImplementation
Returns the current color

Specified by:
getColor in class LWUITImplementation
Parameters:
graphics - the graphics context
Returns:
the RGB graphics color

getDisplayHeight

public int getDisplayHeight()
Description copied from class: LWUITImplementation
Returns the height dimention of the display controlled by this implementation

Specified by:
getDisplayHeight in class LWUITImplementation
Returns:
the height

getDisplayWidth

public int getDisplayWidth()
Description copied from class: LWUITImplementation
Returns the width dimention of the display controlled by this implementation

Specified by:
getDisplayWidth in class LWUITImplementation
Returns:
the width

getGameAction

public int getGameAction(int keyCode)
Description copied from class: LWUITImplementation
Returns the display game action for the given keyCode if applicable to match the contrct of LWUIT for the game action behavior

Specified by:
getGameAction in class LWUITImplementation
Parameters:
keyCode - the device keycode
Returns:
a game action or 0

getKeyCode

public int getKeyCode(int gameAction)
Description copied from class: LWUITImplementation
Returns a keycode which can be sent to getGameAction

Specified by:
getKeyCode in class LWUITImplementation
Parameters:
gameAction - the game action
Returns:
key code matching the given game action

getSoftkeyCode

public int[] getSoftkeyCode(int index)
Description copied from class: LWUITImplementation
Returns the softkey keycode for the given softkey index

Specified by:
getSoftkeyCode in class LWUITImplementation
Parameters:
index - the index of the softkey
Returns:
the set of keycodes which can indicate the softkey, multiple keycodes might apply to the same functionality

getSoftkeyCount

public int getSoftkeyCount()
Description copied from class: LWUITImplementation
Returns the number of softkeys on the device

Specified by:
getSoftkeyCount in class LWUITImplementation
Returns:
the number of softkey buttons on the device

vibrate

public void vibrate(int duration)
Description copied from class: LWUITImplementation
Vibrates the device for the given length of time

Overrides:
vibrate in class LWUITImplementation
Parameters:
duration - length of time to vibrate

isTouchDevice

public boolean isTouchDevice()
Description copied from class: LWUITImplementation
Returns true if the device will send touch events

Specified by:
isTouchDevice in class LWUITImplementation
Returns:
true if the device will send touch events

hasPendingPaints

public boolean hasPendingPaints()
Description copied from class: LWUITImplementation
Returns true if the implementation still has elements to paint.

Overrides:
hasPendingPaints in class LWUITImplementation
Returns:
false by default

revalidate

public void revalidate()

getKeyboardType

public int getKeyboardType()
Description copied from class: LWUITImplementation
Returns the type of the input device one of: KEYBOARD_TYPE_UNKNOWN, KEYBOARD_TYPE_NUMERIC, KEYBOARD_TYPE_QWERTY, KEYBOARD_TYPE_VIRTUAL, KEYBOARD_TYPE_HALF_QWERTY

Overrides:
getKeyboardType in class LWUITImplementation
Returns:
KEYBOARD_TYPE_UNKNOWN

createSoftWeakRef

public java.lang.Object createSoftWeakRef(java.lang.Object o)
Description copied from class: LWUITImplementation
Creates a soft/weak reference to an object that allows it to be collected yet caches it. This method is in the porting layer since CLDC only includes weak references while some platforms include nothing at all and some include the superior soft references.

Overrides:
createSoftWeakRef in class LWUITImplementation
Parameters:
o - object to cache
Returns:
a caching object or null if caching isn't supported

extractHardRef

public java.lang.Object extractHardRef(java.lang.Object o)
Description copied from class: LWUITImplementation
Extracts the hard reference from the soft/weak reference given

Overrides:
extractHardRef in class LWUITImplementation
Parameters:
o - the reference returned by createSoftWeakRef
Returns:
the original object submitted or null

isVirtualKeyboardShowing

public boolean isVirtualKeyboardShowing()
Deprecated. 


isVirtualKeyboardShowingSupported

public boolean isVirtualKeyboardShowingSupported()
Deprecated. 


setShowVirtualKeyboard

public void setShowVirtualKeyboard(boolean show)
Deprecated. 


clearVirtualKeyboard

protected void clearVirtualKeyboard()
Deprecated. 


showNativeScreen

public void showNativeScreen(java.lang.Object nativeFullScreenPeer)
Description copied from class: LWUITImplementation
Shows a native Form/Canvas or some other heavyweight native screen

Overrides:
showNativeScreen in class LWUITImplementation
Parameters:
nativeFullScreenPeer - the native screen peer

setNativeCommands

public void setNativeCommands(java.util.Vector commands)
Places the following commands on the native menu system

Overrides:
setNativeCommands in class LWUITImplementation
Parameters:
commands - the LWUIT commands to use

createNativePeer

public PeerComponent createNativePeer(java.lang.Object nativeComponent)
Description copied from class: LWUITImplementation
Creates a peer component for the given lightweight component

Overrides:
createNativePeer in class LWUITImplementation
Parameters:
nativeComponent - a platform specific "native component"
Returns:
a LWUIT peer component that can be manipulated just like any other LWUIT component but would internally encapsulate the given native peer

onFocusChange

public void onFocusChange(android.view.View view,
                          boolean bln)
Specified by:
onFocusChange in interface android.view.View.OnFocusChangeListener