com.nokia.mid.ui
Class CanvasItem

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

public abstract class CanvasItem
extends java.lang.Object


Field Summary
static int SCALE_AVERAGE
          Constant used to indicate the SCALE_AVERAGE mode of a CanvasItem.
static int SCALE_NEAREST
          Constant used to indicate the SCALE_NEAREST mode of a CanvasItem.
static int SCALE_NOT_ALLOWED
          Constant used to indicate the SCALE_NOT_ALLOWED mode of a CanvasItem.
 
Method Summary
 int getHeight()
          Gets the height of this CanvasItem in pixels.
 java.lang.Object getParent()
          Gets the current parent of this CanvasItem
 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.
protected static boolean isValidImageAnchor(int anchor)
          Tests whether anchor has valid values
 boolean isVisible()
          Returns the current visibility of this CanvasItem
 void scale(int width, int height)
          Scales CanvasItem to the specified size as per current scaling mode.
 void scale(int x, int y, int width, int height)
          Scales CanvasItem to the specified size as per current scaling mode and resets the current anchor position.
 void setParent(java.lang.Object theParent)
          Set the parent object of this CanvasItem.
 void setPosition(int x, int y)
           Sets the rendering position of this CanvasItem.
 void setScalingMode(int scaleMode, boolean aspectRatioPreserved, int anchor)
          This method is called to define how size change / scaling should be performed.
 void setSize(int width, int height)
          Sets the size of this Window in pixels.
 void setSize(int x, int y, int width, int height)
          Sets the size of this CanvasItem in pixels and resets the current anchor position.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCALE_NOT_ALLOWED

public static final int SCALE_NOT_ALLOWED

Constant used to indicate the SCALE_NOT_ALLOWED mode of a CanvasItem.

This might be passed as a parameter to #setScalingMode(int, boolean) if window is intended not to allow scaling.

Constant value 0x0 is set to SCALE_NOT_ALLOWED.

See Also:
Constant Field Values

SCALE_NEAREST

public static final int SCALE_NEAREST

Constant used to indicate the SCALE_NEAREST mode of a CanvasItem.

This might be passed as a parameter to #setScalingMode(int, boolean) if window is intended be in a nearest neighbor scaling mode.

Constant value 0x1 is set to SCALE_NEAREST.

See Also:
Constant Field Values

SCALE_AVERAGE

public static final int SCALE_AVERAGE

Constant used to indicate the SCALE_AVERAGE mode of a CanvasItem.

This might be passed as a parameter to #setScalingMode(int, boolean) if window is intended to be in a "interpolate using average" scaling mode .

Constant value 0x2 is set to SCALE_AVERAGE.

See Also:
Constant Field Values
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.

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

setSize

public void setSize(int width,
                    int height)
             throws java.lang.IllegalArgumentException
Sets the size of this Window 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
See Also:
for more details

setSize

public void setSize(int x,
                    int y,
                    int width,
                    int height)
Sets the size of this CanvasItem in pixels and resets the current anchor position.

This call has the same effect as calling consecutively the following two methods setSize(int, int) and setPosition(int, int).

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
Throws:
java.lang.IllegalArgumentException - if the width or height is less than one pixel
See Also:
setPosition(int, int), setSize(int, int)

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

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

setZPosition

public void setZPosition(int z)
                  throws java.lang.IllegalArgumentException

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.

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

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

getZPosition

public int getZPosition()

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

See Also:
#getZPosition(int)

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

Throws:
java.lang.IllegalStateException - If its visibility is locked by the platform.

isVisible

public boolean isVisible()
Returns the current visibility of this CanvasItem

Returns:
true if currently visible, false otherwise

scale

public void scale(int width,
                  int height)
Scales CanvasItem to the specified size as per current scaling mode.

Parameters:
width - the new width in pixels
height - the new height in pixels
See Also:
scalling mode settings

scale

public void scale(int x,
                  int y,
                  int width,
                  int height)
Scales CanvasItem to the specified size as per current scaling mode and resets the current anchor position.

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:
scaling mode settings, setPosition(int, int), scale(int, int)

setScalingMode

public void setScalingMode(int scaleMode,
                           boolean aspectRatioPreserved,
                           int anchor)
This method is called to define how size change / scaling should be performed.

Parameters:
scaleMode - scaling mode: SCALE_NEAREST or SCALE_AVERAGE or SCALE_NOT_ALLOWED
aspectRatioPreserved - set to true to preserve aspect ration when scaling
anchor - the anchor point for positioning the window
Throws:
java.lang.IllegalArgumentException - if scaleMode or/and anchor are not a legal values.
See Also:
for more details

getParent

public java.lang.Object getParent()
Gets the current parent of this CanvasItem

Returns:
the current parent

isValidImageAnchor

protected static boolean isValidImageAnchor(int anchor)
Tests whether anchor has valid values

Parameters:
anchor - anchor value to be tested
Returns:
true if anchor is valid, otherwise false


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.