com.nokia.mid.ui
Class CanvasItem

java.lang.Object
  extended by com.nokia.mid.ui.CanvasItem
Direct Known Subclasses:
CanvasGraphicsItem, TextEditor

public abstract class CanvasItem
extends java.lang.Object

Parent object just for components on Canvas. Currently there are two components: CanvasGraphicsItem and TextEditor. Methods of CanvasItem are implemented in subclasses CanvasGraphicsItem and TextEditor.

Since:
1.4

Constructor Summary
CanvasItem()
           
 
Method Summary
 int getHeight()
          Gets the height of this CanvasItem in pixels.
 java.lang.Object getParent()
          Get the parent object of this CanvasItem or null, if no parent set.
 int getPositionX()
           Gets the rendering position of this CanvasItem.
 int getPositionY()
           Sets the rendering position of this CanvasItem.
 int getWidth()
          Gets the width of this CanvasItem in pixels.
 int getZPosition()
           Returns the Z-position, or the elevation, of the item.
 boolean isVisible()
           Returns the visibility value of CanvasItem.
 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 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CanvasItem

public CanvasItem()
Method Detail

setParent

public void setParent(java.lang.Object parent)
Set the parent object of this CanvasItem.

Typically the parent object would be Canvas. Setting the parameter to null removes the association to the parent. If setParent(null) is called for a CanvasItem yet not having any parent or setParent(parent) is called with the same parent, the call is silently ignored.

Parameters:
parent - the parent object
Throws:
java.lang.IllegalArgumentException - if parent is not a valid object with which a CanvasItem can be associated, or if CanvasItem is already set to another another parent

getParent

public java.lang.Object getParent()
Get the parent object of this CanvasItem or null, if no parent set.

Returns:
Object parent object or null
See Also:
setParent(java.lang.Object parent )

setSize

public void setSize(int width,
                    int height)
Sets the size of this CanvasItem in pixels.

Parameters:
width - width in pixels
height - height in pixels
Throws:
java.lang.IllegalArgumentException - if the width or height is less than one pixel

getHeight

public int getHeight()
Gets the height of this CanvasItem in pixels.

Returns:
height in pixels

getWidth

public int getWidth()
Gets the width of this CanvasItem in pixels.

Returns:
width in pixels

setPosition

public void setPosition(int x,
                        int y)

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

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

Parameters:
x - the x coordinate of the anchor point, in pixels.
y - the y coordinate of the anchor point, in pixels.

getPositionX

public int getPositionX()

Gets the rendering position of this CanvasItem.

The origin is relative to the coordinate system of parent.

Returns:
X location of the CanvasItem

getPositionY

public int getPositionY()

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.

Returns:
Y location of the CanvasItem

setVisible

public void setVisible(boolean visible)

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 item is already visible calling setVisible(true) does nothing. If the item is not visible calling setVisible(false) does nothing.

Parameters:
visible - visibility of the CanvasItem
Throws:
java.lang.IllegalStateException - If the item is not added to any parent

isVisible

public boolean isVisible()

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

Returns:
true if currently visible, false otherwise
See Also:
setVisible(boolean visible )

setZPosition

public void setZPosition(int z)

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.

The z-position is unique for each item meaning that changing a Z-position of an item may change the Z-position of the items that share the same parent item. The Z-position does not affect the item's size in any way.

When items are added with setParent(java.lang.Object) they will get a Z-position that is increased by 1 from the item that is the top most item at that time.

Parameters:
z - the z position of the item.
Throws:
java.lang.IllegalArgumentException - if z < 0
See Also:
getZPosition()

getZPosition

public int getZPosition()

Returns the Z-position, or the elevation, of the item. The Z-position decides the stacking order of neighboring items.

Returns:
The Z-position, or the elevation, of the item.
See Also:
setZPosition(int)

forum.nokia.com/java

Copyright (c) 2002-2010 Nokia Corporation. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc.