com.nokia.mid.ui
Class CanvasGraphicsItem

java.lang.Object
  extended bycom.nokia.mid.ui.CanvasItem
      extended bycom.nokia.mid.ui.CanvasGraphicsItem

public abstract class CanvasGraphicsItem
extends CanvasItem

A paintable item that can be used on top of Canvas or CustomItem


Field Summary
 
Fields inherited from class com.nokia.mid.ui.CanvasItem
SCALE_AVERAGE, SCALE_NEAREST, SCALE_NOT_ALLOWED
 
Constructor Summary
CanvasGraphicsItem(int width, int height)
          Creates a new CanvasGraphicsItem object with the given initial size.
 
Method Summary
 int getContentHeight()
          Gets the content's height in pixels.
 int getContentWidth()
          Gets the content's width in pixels.
protected abstract  void paint(javax.microedition.lcdui.Graphics g)
          Renders the CanvasGraphicsItem.
 void repaint()
          Requests a repaint for the entire CanvasGraphicsItem.
 void repaint(int x, int y, int w, int h)
          Requests a repaint for the specified region of the CanvasGraphicsItem.
 void setParent(java.lang.Object parent)
          Set the parent object of this CanvasItem.
 void setPosition(int x, int y)
           Sets the rendering position of this CanvasItem.
 void setSize(int width, int height)
          Sets the size of this CanvasItem in pixels.
 void setSize(int x, int y, int width, int height)
          Sets the size of the CanvasItem's container in pixels.
 void setVisible(boolean visible)
           Sets the visibility value of CanvasItem.
 void setZPosition(int z)
           Sets the Z-position, or the elevation, of the item.
 
Methods inherited from class com.nokia.mid.ui.CanvasItem
getHeight, getParent, getPositionX, getPositionY, getWidth, getZPosition, isVisible, scale, scale, setScalingMode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CanvasGraphicsItem

public CanvasGraphicsItem(int width,
                          int height)
Creates a new CanvasGraphicsItem object with the given initial size.

Parameters:
width - the width of the item in pixels
height - the height of the item in pixel
Throws:
java.lang.IllegalArgumentException - if with or height are smaller than 1
Method Detail

paint

protected abstract void paint(javax.microedition.lcdui.Graphics g)
Renders the CanvasGraphicsItem. The application implements this method to paint graphics on CanvasGraphicsItem. CanvasGraphicsItem paint works in the same way as Canvas paint method. The only difference to Canvas paint method is that application does not need to paint all the pixels of the clip region as platform ensures that the clip region needing updating is cleared and fully transparent before paint is called. Content rendered by application in previous paint method calls is not available in the clip region. Coordinates used in Graphics methods are relative to CanvasGraphicsItem itself. This means (0,0) coordinate is top left pixel of CanvasGraphicsItem as positioned in the containing parent (e.g. Canvas).

Parameters:
g - the Graphics object to be used for rendering the Canvas

repaint

public void repaint()
Requests a repaint for the entire CanvasGraphicsItem. The effect is identical to repaint(0, 0, getWidth(), getHeight());


repaint

public void repaint(int x,
                    int y,
                    int w,
                    int h)
Requests a repaint for the specified region of the CanvasGraphicsItem. Coordinates are relative to the CanvasGraphicsItem coordinates. The method works in similar manner as Canvas repaint method.

Parameters:
x - the x coordinate of the rectangle to be repainted
y - the y coordinate of the rectangle to be repainted
w - the width of the rectangle to be repainted
h - the height of the rectangle to be repainted

setParent

public void setParent(java.lang.Object parent)
Description copied from class: CanvasItem
Set the parent object of this CanvasItem. Typically in the parent object would be Canvas or CustomItem. Setting the parameter to null removes the association to the parent. If setParent(null) is called for a CanvasItem yet not having any parent the call is silently ignored.

Overrides:
setParent in class CanvasItem
Parameters:
parent - the parent object

setVisible

public void setVisible(boolean visible)
Description copied from class: CanvasItem

Sets the visibility value of CanvasItem. Initially CanvasItem is not visible so it must be explicitly set to visible in order it to appear on UI.

If the editor is already visible calling setVisible(true) does nothing. If the item is not visible calling setVisible(false) does nothing.

Overrides:
setVisible in class CanvasItem

setSize

public void setSize(int x,
                    int y,
                    int width,
                    int height)
Sets the size of the CanvasItem's container in pixels.

Overrides:
setSize in class CanvasItem
Parameters:
x - the x coordinate of the anchor point
y - the y coordinate of the anchor point
width - the new width in pixels
height - the new height in pixels
See Also:
CanvasItem.setPosition(int, int), CanvasItem.setSize(int, int)

setSize

public void setSize(int width,
                    int height)
Description copied from class: CanvasItem
Sets the size of this CanvasItem in pixels.

Overrides:
setSize in class CanvasItem
Parameters:
width - width in pixels
height - height in pixels
See Also:
for more details

setPosition

public void setPosition(int x,
                        int y)
Description copied from class: CanvasItem

Sets the rendering position of this CanvasItem. The origin is relative to the coordinate system of parent.

The CanvasItem may be placed partially or fully off of the visible area of the parent by the setPosition method; in this case the CanvasItem is just not fully visible.

Overrides:
setPosition in class CanvasItem
Parameters:
x - the x coordinate of the anchor point, in pixels.
y - the y coordinate of the anchor point, in pixels.

getContentWidth

public int getContentWidth()
Gets the content's width in pixels. When widget is not scaled this is same as calling CanvasItem.getWidth().

Returns:
width in pixels.

getContentHeight

public int getContentHeight()
Gets the content's height in pixels. When widget is not scaled this is same as calling CanvasItem.getHeight().

Returns:
width in pixels.

setZPosition

public void setZPosition(int z)
Description copied from class: CanvasItem

Sets the Z-position, or the elevation, of the item. The elevation decides the stacking order of neighboring items. An item of high Z-position will be drawn on top of an item with a lower Z-position if they share the same parent item. Other items that share the same Z-position will be drawn in an undefined order, although the order will stay the same for as long as the items live. The Z-position does not affect the item's size in any way. When items are added with setParent they will get a Z-position that is increased by 1 from the previously added item.

Overrides:
setZPosition in class CanvasItem
Parameters:
z - the z position of the item.
See Also:
CanvasItem.getZPosition()


Copyright © 2012 Nokia Corporation. All rights reserved.

Nokia is registered trademark of Nokia Corporation. Java and all Java-based marks are trademarks or registered trademarks of Oracle Corporation. Other product and company names mentioned herein may be trademarks or trade names of their respective owners. This document is confidential information of Nokia Corporation.

Disclaimer
The information in this document is provided "as is," with no warranties whatsoever, including any warranty of merchantability, fitness for any particular purpose, or any warranty otherwise arising out of any proposal, specification, or sample. Furthermore, information provided in this document is preliminary, and may be changed substantially prior to final release.

Nokia Corporation disclaims all liability, including liability for infringement of any proprietary rights, relating to this document and implementation of any information presented in this document.

Nokia Corporation retains the right to make changes to this document at any time, without notice.

License
Subject to above disclaimer, a license is hereby granted to use this documentation solely under existing Limited License Agreement and non-disclosure agreement between the companies for the agreed application development for Series 40 Nokia phones. No other licenses e.g. to any intellectual property rights are granted herein. Any use of the screen shots of this documentation, including any icons thereof, is subject to Nokia's prior written approval.