de.enough.polish.ui
Class SnapshotScreen

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by de.enough.polish.ui.Screen
              extended by de.enough.polish.ui.SnapshotScreen
All Implemented Interfaces:
AccessibleCanvas, java.lang.Runnable

public class SnapshotScreen
extends Screen
implements java.lang.Runnable

A convenience screen for taking snapshots. This screen requires support of the MMAPI by the current target device!

 //#if polish.api.mmapi
    import de.enough.polish.ui.SnapshotScreen;
 //#endif
 ...
 //#if polish.api.mmapi
    //#style snapshotScreen
    SnapshotScreen screen = new SnapshotScreen("Snapshot");
 //#endif
 

Copyright Enough Software 2006 - 2008

 history
        Sep 8, 2006 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.Screen
background, border, container, contentHeight, contentWidth, contentX, contentY, cssSelector, fullScreenHeight, ignoreRepaintRequests, infoHeight, isInitRequested, isRepaintRequested, isScrollBackground, isSetFullScreenCalled, itemStateListener, keyPressedProcessed, keyReleasedProcessed, lastInteractionTime, lastTriggeredCommand, menuBarHeight, originalScreenHeight, paintScrollBarOnRightSide, screenHeight, screenOrientationDegrees, screenStateListener, screenWidth, scrollBar, scrollBarVisible, style, subTitleHeight, title, titleHeight, triggerReleasedKeyCode, triggerReleasedTime
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
SnapshotScreen(java.lang.String title)
          Creates a new screen for taking screenshots.
SnapshotScreen(java.lang.String title, Style style)
          Creates a new screen for taking screenshots.
 
Method Summary
protected  java.lang.String createCssSelector()
          Retrieves the CSS selector for this screen.
 byte[] getSnapshot()
          Takes a snapshot in the default encoding
 byte[] getSnapshot(java.lang.String encoding)
          Takes a snapshot in the desired encoding/settings
static java.lang.String[] getSnapshotEncodings()
          Retrieves the supported snapshot encodings available on the current device.
 javax.microedition.lcdui.Image getSnapshotImage()
          Takes a snapshot in the default encoding
 javax.microedition.lcdui.Image getSnapshotImage(java.lang.String encoding)
          Takes a snapshot in the desired encoding/settings
 void hideNotify()
          Unregisters this screen and notifies all items that they will not be shown anymore.
protected  void paintScreen(javax.microedition.lcdui.Graphics g)
          Paints the screen.
 void run()
           
 void showNotify()
          Initialises this screen and informs all items about being painted soon.
 
Methods inherited from class de.enough.polish.ui.Screen
addCommand, addCommand, addSubCommand, addSubCommand, animate, animate, calculateContentArea, callCommandListener, checkForRequestInit, closeMenu, commandAction, focus, focus, focus, focus, focus, getAvailableHeight, getCommandItem, getCommandListener, getCurrentIndex, getCurrentItem, getGameAction, getItemAt, getMenuBar, getPolishTicker, getRootItems, getScreenContentHeight, getScreenContentWidth, getScreenData, getScreenFullHeight, getScreenFullWidth, getScreenHeight, getScreenStyle, getScrollBarWidth, getScrollYOffset, getTitle, handleCommand, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handlePointerPressed, handlePointerReleased, isGameActionFire, isKeyboardAccessible, isMenuOpened, isShown, isSoftKey, isSoftKey, isSoftKeyLeft, isSoftKeyMiddle, isSoftKeyRight, keyPressed, keyReleased, keyRepeated, notifyScreenStateChanged, notifyStateListener, paint, pointerDragged, pointerPressed, pointerReleased, releaseResources, removeAllCommands, removeCommand, removeItemCommands, requestInit, requestRepaint, requestRepaint, scrollRelative, setCommandListener, setFullScreenMode, setInfo, setItemCommands, setItemStateListener, setItemStateListener, setMenuBarStyle, setMenuItemStyle, setPolishTicker, setPolishTicker, setScreenData, setScreenOrientation, setScreenStateListener, setScrollYOffset, setStyle, setSubTitle, setTitle, setTitle, setTitle, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Canvas
getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, repaint, repaint, serviceRepaints
 
Methods inherited from class javax.microedition.lcdui.Displayable
getHeight, getTicker, getWidth, setTicker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnapshotScreen

public SnapshotScreen(java.lang.String title)
Creates a new screen for taking screenshots.

Parameters:
title - the title of the screen

SnapshotScreen

public SnapshotScreen(java.lang.String title,
                      Style style)
Creates a new screen for taking screenshots.

Parameters:
title - the title of the screen
style - the style
Method Detail

hideNotify

public void hideNotify()
Description copied from class: Screen
Unregisters this screen and notifies all items that they will not be shown anymore.

Specified by:
hideNotify in interface AccessibleCanvas
Overrides:
hideNotify in class Screen

showNotify

public void showNotify()
Description copied from class: Screen
Initialises this screen and informs all items about being painted soon.

Specified by:
showNotify in interface AccessibleCanvas
Overrides:
showNotify in class Screen

run

public void run()
Specified by:
run in interface java.lang.Runnable

getSnapshotEncodings

public static java.lang.String[] getSnapshotEncodings()
Retrieves the supported snapshot encodings available on the current device.

Returns:
an array of encodings. When the "video.snapshot.encodings" system property is null, an empty array is returned.

getSnapshotImage

public javax.microedition.lcdui.Image getSnapshotImage()
                                                throws javax.microedition.media.MediaException
Takes a snapshot in the default encoding

Returns:
the image taken
Throws:
javax.microedition.media.MediaException - when taking the snapshot fails

getSnapshotImage

public javax.microedition.lcdui.Image getSnapshotImage(java.lang.String encoding)
                                                throws javax.microedition.media.MediaException
Takes a snapshot in the desired encoding/settings

Parameters:
encoding - the encoding and optionally size
Returns:
the image taken
Throws:
javax.microedition.media.MediaException - when taking the snapshot fails

getSnapshot

public byte[] getSnapshot()
                   throws javax.microedition.media.MediaException
Takes a snapshot in the default encoding

Returns:
the image taken
Throws:
javax.microedition.media.MediaException - when taking the snapshot fails

getSnapshot

public byte[] getSnapshot(java.lang.String encoding)
                   throws javax.microedition.media.MediaException
Takes a snapshot in the desired encoding/settings

Parameters:
encoding - the encoding and optionally size
Returns:
the image taken
Throws:
javax.microedition.media.MediaException - when taking the snapshot fails

paintScreen

protected void paintScreen(javax.microedition.lcdui.Graphics g)
Description copied from class: Screen
Paints the screen. This method also needs to set the protected variables paintScrollIndicator, paintScrollIndicatorUp and paintScrollIndicatorDown.

Overrides:
paintScreen in class Screen
Parameters:
g - the graphics on which the screen should be painted
See Also:
Screen.contentX, Screen.contentY, Screen.contentWidth, Screen.contentHeight, Screen.paintScrollIndicator, Screen.paintScrollIndicatorUp, Screen.paintScrollIndicatorDown

createCssSelector

protected java.lang.String createCssSelector()
Description copied from class: Screen
Retrieves the CSS selector for this screen. The CSS selector is used for the dynamic assignment of styles - that is the styles are assigned by the usage of the screen and not by a predefined style-name. With the #style preprocessing command styles are set in a static way, this method yields in a faster GUI and is recommended. When in a style-sheet dynamic styles are used, e.g. "form>p", than the selector of the screen is needed. This abstract method needs only be implemented, when dynamic styles are used: #ifdef polish.useDynamicStyles

Specified by:
createCssSelector in class Screen
Returns:
the name of the appropriate CSS Selector for this screen.