com.nokia.mid.ui
Class CanvasGraphicsItem

java.lang.Object
  extended by com.nokia.mid.ui.CanvasItem
      extended by com.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)
           
 
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 com.nokia.mid.ui.CanvasItem
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

CanvasGraphicsItem

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

setParent

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.

Overrides:
setParent in class CanvasItem
Parameters:
theParent - the parent object
Throws:
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

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

Parameters:
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

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.


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.