Class CanvasGraphicsItem

  extended by
      extended by

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
Constructor Summary
CanvasGraphicsItem(int width, int height)
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 width, int height)
          Requests a repaint for the specified region of the CanvasGraphicsItem.
 void setParent(java.lang.Object theParent)
          Set the parent object of this CanvasItem.
Methods inherited from class
getHeight, getParent, getPositionX, getPositionY, getWidth, getZPosition, isValidImageAnchor, isVisible, scale, scale, setPosition, setScalingMode, setSize, setSize, setVisible, setZPosition
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public CanvasGraphicsItem(int width,
                          int height)
                   throws java.lang.IllegalArgumentException
Method Detail


public void setParent(java.lang.Object theParent)
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.

setParent in class CanvasItem
theParent - the parent object
java.lang.IllegalArgumentException - if parent is not a valid object with which a TextEditor can be associated, or if CanvasItem is already set to another another parent


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).

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


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


public void repaint(int x,
                    int y,
                    int width,
                    int height)
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.

x - the x coordinate of the rectangle to be repainted
y - the y coordinate of the rectangle to be repainted
width - the width of the rectangle to be repainted
height - the height of the rectangle to be repainted


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

width in pixels.


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

width in pixels.

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.

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.

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.