com.sun.perseus.demo.picturedecorator
Class PhotoFrame

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by com.sun.perseus.demo.picturedecorator.PhotoFrame

public class PhotoFrame
extends javax.microedition.lcdui.Canvas

The photo frame represents a single photo with SVG overlays.


Field Summary
(package private)  javax.microedition.lcdui.Image currentImage
          The current background image.
(package private)  int cursorX
          The crosshair cursor's horizontal position.
(package private)  int cursorY
          The crosshair cursor's vertical position.
(package private)  org.w3c.dom.Document doc
          The SVG document.
(package private)  ItemPicker itemPicker
          The ItemPicker canvas.
(package private)  int photoNumber
          The current photo number.
(package private)  org.w3c.dom.svg.SVGLocatableElement prop
          The current prop.
protected  javax.microedition.m2g.ScalableGraphics sg
          The scalable graphics instance used for rendering.
(package private)  javax.microedition.lcdui.Command showItemPicker
          The ItemPicker command.
(package private)  org.w3c.dom.svg.SVGSVGElement svg
          The element.
 java.lang.String SVG_NAMESPACE_URI
          The namespace for the svg document.
(package private)  javax.microedition.m2g.SVGImage svgImage
          The current SVG image.
(package private)  java.util.Vector visibleProps
          The list of props that have been placed and can be picked up.
static java.lang.String XLINK_NAMESPACE_URI
          The namespace for xlink:href
 
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
PhotoFrame(PictureDecorator main)
          Constructs a new photo frame.
 
Method Summary
 void addProp(java.lang.String id)
          Adds the prop referenced by id in the library.
 void addProp(org.w3c.dom.svg.SVGLocatableElement newProp)
          Adds the prop to the SVG document.
 void keyPressed(int keyCode)
          Handle a keypress.
 void keyRepeated(int keyCode)
          Repeat a keypress.
(package private) static void locateProps(org.w3c.dom.svg.SVGElement parent, int level, int defs, java.util.Vector hiddens, java.util.Vector visibles)
          Walk the current parent node downward to find all "hiddens" (The SVG elements within a section that have IDs) and all "visibles" (The SVG elements outside the sections).
 void mirrorProp(org.w3c.dom.svg.SVGLocatableElement prop, boolean flipHorizontal)
          Mirrors the prop about the horizontal or vertical axis.
 void paint(javax.microedition.lcdui.Graphics g)
          Paint the photo in the back, then layer all SVG images on top.
 void removeProp()
          Removes the current prop if it is displayed.
 void rotateProp(org.w3c.dom.svg.SVGLocatableElement prop, float angle)
          Rotates the prop by the given angle.
 void scaleProp(org.w3c.dom.svg.SVGLocatableElement prop, float scale)
          Scales the prop by the given scale.
 void setPhoto(int number)
          Establishes the current background photo.
 void setPropsLibrary(javax.microedition.m2g.SVGImage image)
          Establishes the current prop library, which holds definitions of props in its section(s).
 void translateProp(org.w3c.dom.svg.SVGLocatableElement prop, float dx, float dy)
          Translate the prop by the given horizontal and vertical distances.
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyReleased, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, showNotify, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XLINK_NAMESPACE_URI

public static final java.lang.String XLINK_NAMESPACE_URI
The namespace for xlink:href

See Also:
Constant Field Values

SVG_NAMESPACE_URI

public final java.lang.String SVG_NAMESPACE_URI
The namespace for the svg document.

See Also:
Constant Field Values

sg

protected javax.microedition.m2g.ScalableGraphics sg
The scalable graphics instance used for rendering.


photoNumber

int photoNumber
The current photo number.


currentImage

javax.microedition.lcdui.Image currentImage
The current background image.


svgImage

javax.microedition.m2g.SVGImage svgImage
The current SVG image.


doc

org.w3c.dom.Document doc
The SVG document.


svg

org.w3c.dom.svg.SVGSVGElement svg
The element.


prop

org.w3c.dom.svg.SVGLocatableElement prop
The current prop.


visibleProps

java.util.Vector visibleProps
The list of props that have been placed and can be picked up.


cursorX

int cursorX
The crosshair cursor's horizontal position.


cursorY

int cursorY
The crosshair cursor's vertical position.


itemPicker

ItemPicker itemPicker
The ItemPicker canvas.


showItemPicker

javax.microedition.lcdui.Command showItemPicker
The ItemPicker command.

Constructor Detail

PhotoFrame

public PhotoFrame(PictureDecorator main)
Constructs a new photo frame.

Method Detail

setPhoto

public void setPhoto(int number)
Establishes the current background photo.

Parameters:
number - The number of the photo in the JAD file.

setPropsLibrary

public void setPropsLibrary(javax.microedition.m2g.SVGImage image)
Establishes the current prop library, which holds definitions of props in its section(s). Each prop is located by its ID.

When a prop is used on the display, a <use> element is inserted into the library, effectively making the prop available for display.

Parameters:
image - The SVG image containing the prop definitions. The image may also contain elements that are statically positioned.

locateProps

static void locateProps(org.w3c.dom.svg.SVGElement parent,
                        int level,
                        int defs,
                        java.util.Vector hiddens,
                        java.util.Vector visibles)
Walk the current parent node downward to find all "hiddens" (The SVG elements within a section that have IDs) and all "visibles" (The SVG elements outside the sections).

Parameters:
parent - The relative parent node.
level - The nesting level (0..n).
defs - The nesting level.
hiddens - The list of elements with IDs within a section.
visibles - The list of elements outside a section.

addProp

public void addProp(java.lang.String id)
Adds the prop referenced by id in the library.

Parameters:
id - The identifier of the prop within a <defs> section of the library.

addProp

public void addProp(org.w3c.dom.svg.SVGLocatableElement newProp)
Adds the prop to the SVG document.

Parameters:
newProp - The prop to be added.

removeProp

public void removeProp()
Removes the current prop if it is displayed.


translateProp

public void translateProp(org.w3c.dom.svg.SVGLocatableElement prop,
                          float dx,
                          float dy)
Translate the prop by the given horizontal and vertical distances.

Parameters:
dx - The horizontal distance to move the prop.
dy - The vertical distance to move the prop.

scaleProp

public void scaleProp(org.w3c.dom.svg.SVGLocatableElement prop,
                      float scale)
Scales the prop by the given scale.

Parameters:
scale - The scaling factor to be applied to the prop.

rotateProp

public void rotateProp(org.w3c.dom.svg.SVGLocatableElement prop,
                       float angle)
Rotates the prop by the given angle.

Parameters:
angle - The angle by which the prop will be rotated.

mirrorProp

public void mirrorProp(org.w3c.dom.svg.SVGLocatableElement prop,
                       boolean flipHorizontal)
Mirrors the prop about the horizontal or vertical axis.

Parameters:
prop - The angle by which the image will be rotated.
flipHorizontal - true if mirroring will be about the vertical axis; false if mirroring will be about the horizontal axis.

keyPressed

public void keyPressed(int keyCode)
Handle a keypress.

Overrides:
keyPressed in class javax.microedition.lcdui.Canvas
Parameters:
keyCode - The code for the key that was pressed.

keyRepeated

public void keyRepeated(int keyCode)
Repeat a keypress.

Overrides:
keyRepeated in class javax.microedition.lcdui.Canvas
Parameters:
keyCode - The code for the key that was pressed.

paint

public void paint(javax.microedition.lcdui.Graphics g)
Paint the photo in the back, then layer all SVG images on top.

Specified by:
paint in class javax.microedition.lcdui.Canvas
Parameters:
g - The graphics context for this canvas.