Java DTV API 1.3
18-Nov-2009

com.sun.dtv.ui
Class AnimatedMatte

java.lang.Object
  extended by com.sun.dtv.ui.AnimatedMatte
All Implemented Interfaces:
Animation, Animated, Matte

public class AnimatedMatte
extends Object
implements Matte, Animation, Animated

This class represents an animated matte with a dynamic image mask, where the pixel values determine the matte transparency for every pixel for a certain point of time.

See Also:
Matte

Field Summary
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
Constructor Summary
AnimatedMatte()
           
 
Method Summary
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
 int getAnimationMode()
          Obtains the animation mode for the matte's animation.
 int getDelay()
          Obtains the delay after every image for the matte's animation when running.
 Image[] getImageOpacity()
          Gets the opacity value images for this matte, if an image animation has been previously assigned to this matte, null otherwise.
 Dimension getOffset(int index)
          Obtains the offset the image matte has relatively to the top left corner of the component's area for a certain position within the animation.
 float[] getOpacity()
          Gets the opacity values for the animation of this matte, if a row of unitary opacity values is assigned to this matte at the moment, otherwise null.
 int[] getOpacityAsInts()
          Gets the opacity values for the animation of this matte, if a row of unitary opacity values is assigned to this matte at the moment, otherwise null.
 int getPosition()
          Obtains the current position the matte's animation is at the point of time of the method call.
 int getRepetitionMode()
          Returns the repetition mode of the matte's animation in form of a number.
 boolean hasImageAnimation()
          Obtains whether the currently assigned animation to this matte is based on a row of images or not.
 boolean isRunning()
          Obtains the running mode of the matte's animation.
 void jumpTo(int index)
          Forces the matte's animation to jump to the position indicated by the parameter.
 void paint(Graphics g)
          Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.
 void setAnimationMode(int mode)
          Sets the animation mode for the matte's animation.
 void setDelay(int delay)
          Determines the delay after every image when running the matte's animation.
 void setOffset(int index, Dimension dimension)
          Determines the offset for the opacity image to be assigned with this matte for a certain position in the animation.
 void setOpacity(float[] opacities)
          Sets opacity values for this matte, causing an animation of changing opacity, while the opacity at a certain point of time is unitary for all pixels.
 void setOpacity(Image[] images)
          Sets the opacity of the matte to a row of images causing an animation of changing opacity images.
 void setOpacity(int[] opacities)
          Sets opacity values for this matte, causing an animation of changing opacity, while the opacity at a certain point of time is unitary for all pixels.
 void setRepetitionMode(int repetitions)
          Determines how often the matte's animation is repeated once it has been started.
 void start()
          Starts the matte's animation.
 void stop()
          Stops the matte's animation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimatedMatte

public AnimatedMatte()
Method Detail

setOpacity

public void setOpacity(int[] opacities)
Sets opacity values for this matte, causing an animation of changing opacity, while the opacity at a certain point of time is unitary for all pixels. A call to this method overwrites a previously set animation of images or unitary opacity values. This method has exactly the same aim as setOpacity(float[]), where an integer value i in the array passed to this method has the same effect as a float value (float)(i/255) at the same position in the array passed to setOpacity(float[]).

Parameters:
opacities - the values for the changing opacity during the animation of this matte. The array elements should be integer values between 0 and 255, where 0 stands for full transparency, and 255 for full opacity. Values below 0 will be interpreted as 0 (fully transparent), values greater 255 as 255 (fully opaque). If the parameter is null, previously opacity values are removed.
Throws:
IllegalArgumentException - if the length of the opacity array is 0.
See Also:
getOpacityAsInts()

setOpacity

public void setOpacity(float[] opacities)
Sets opacity values for this matte, causing an animation of changing opacity, while the opacity at a certain point of time is unitary for all pixels. A call to this method overwrites a previously set animation of images or unitary opacity values. This method has exactly the same aim as setOpacity(int[]), where a floating point value f in the array passed to this method has the same effect as an integer value (int)(f * 255) at the same position in the array passed to setOpacity(int[]).

Parameters:
opacities - the values for the changing opacity during the animation of this matte. The array elements should be a floating point values between 0.0f and 1.0f, where 0.0f stands for full transparency, and 1.0f for full opacity. Values below 0.0f will be interpreted as 0.0f (fully transparent), values greater 1.0f as 1.0f (fully opaque). If the parameter is null, previously opacity values are removed.
Throws:
IllegalArgumentException - if the length of the opacity array is 0.
See Also:
getOpacity()

setOpacity

public void setOpacity(Image[] images)
Sets the opacity of the matte to a row of images causing an animation of changing opacity images. The provided images may be smaller than the affected component, in this case the remaining area is shown as it would be covered by a StaticMatte with opacity 1.0. By default the images matte is aligned with the top left corner of the components area. This can be changed (for any image separately) using the setOffset() method. A call to this method overwrites a previously set animation of images or unitary opacity values.

Parameters:
images - the values for the opacity, which have to be an array of images, containing pixel values between 0.0 and 1.0. 0.0 stands for full transparency, and 1.0 for full opacity. Values below 0.0 will be interpreted as 0.0 (fully transparent), values greater 1.0 as 1.0 (fully opaque). Note that if an image is not available while the animation is running (because the array element is null or the image is still loading) this image will be skipped.
See Also:
getOpacity()

getOpacity

public float[] getOpacity()
Gets the opacity values for the animation of this matte, if a row of unitary opacity values is assigned to this matte at the moment, otherwise null.

Returns:
the opacity values for the animation of this matte. The array elements are always floating point values in the range between 0.0 and 1.0, where 0.0 stands for full transparency, and 1.0 for full opacity. If null is returned, no unitary opacity values are assigned to this matte at the moment, but rather a row of opacity images.
See Also:
setOpacity(float[])

getOpacityAsInts

public int[] getOpacityAsInts()
Gets the opacity values for the animation of this matte, if a row of unitary opacity values is assigned to this matte at the moment, otherwise null.

Returns:
the opacity values for the animation of this matte. The array elements are always integer values in the range between 0 and 255, where 0 stands for full transparency, and 255 for full opacity. If null is returned, no unitary opacity values are assigned to this matte at the moment, but rather a row of opacity images.
See Also:
setOpacity(int[])

getImageOpacity

public Image[] getImageOpacity()
Gets the opacity value images for this matte, if an image animation has been previously assigned to this matte, null otherwise.

Returns:
the opacity values for this matte in form of an image array, where each image contains pixel values between 0.0 and 1.0. 0.0 stands for full transparency, and 1.0 for full opacity. If null is returned, there is no opacity image animation assigned to this matte at the moment.
See Also:
setOpacity(com.sun.dtv.lwuit.Image[])

setOffset

public void setOffset(int index,
                      Dimension dimension)
Determines the offset for the opacity image to be assigned with this matte for a certain position in the animation. While per default the images matte is aligned with the top left corner of the components area, this can be changed using this method - separately for any position of the animation. If currently an animation based on unitary opacity values is assigned to this matte, a call to this method has no effect.

Parameters:
index - index of the content image array for which the offset should be set
dimension - a Dimension object determining the offset toward the top left corner of the component's area. if the parameter is null, no offset will be determined, and a previously assigned offset will be removed.
See Also:
getOffset(int)

getOffset

public Dimension getOffset(int index)
Obtains the offset the image matte has relatively to the top left corner of the component's area for a certain position within the animation. If currently an animation based ion unitary opacity values is assigned to this matte, null is returned.

Parameters:
index - index of the animation position the offset value should be obtained for
Returns:
the offset for this animation position in form of a Dimension object or null (in this case there is no offset for this animation position, or the currently valid animation is based on unitary opacity values)
See Also:
setOffset(int, com.sun.dtv.lwuit.geom.Dimension)

start

public void start()
Starts the matte's animation. Please consider that an animation is in the stopped mode per default, so it has to be started explicitly once it has been created. In case the animation is already running, a call to start() causes a restart of the animation.

Specified by:
start in interface Animated

stop

public void stop()
Stops the matte's animation. In case the animation is already stopped, the call to stop() has no effect.

Specified by:
stop in interface Animated

isRunning

public boolean isRunning()
Obtains the running mode of the matte's animation. Returns true if the animation is running, false otherwise.

Specified by:
isRunning in interface Animated
Returns:
true if the animation is running, false otherwise

jumpTo

public void jumpTo(int index)
Forces the matte's animation to jump to the position indicated by the parameter. An animation can be considered as a row of images, the parameter of this method provides the index within this row. If the animation is stopped, a call to this method causes the animation to show the image at the indicated position, but not to start. If the animation is running, a call to this method causes the animation to jump to the image at the indicated position and continue running immediately.

Specified by:
jumpTo in interface Animated
Parameters:
index - the index in the row of images building the animation to which the animation is forced to jump

getPosition

public int getPosition()
Obtains the current position the matte's animation is at the point of time of the method call. An animation can be considered as a row of images, this method provides the index within this row.

Specified by:
getPosition in interface Animated
Returns:
the current position of the image within the row of images building this animation

setRepetitionMode

public void setRepetitionMode(int repetitions)
Determines how often the matte's animation is repeated once it has been started.

Specified by:
setRepetitionMode in interface Animated
Parameters:
repetitions - number of repetitions to be determined. This can be any number larger than zero or LOOP alternatively. LOOP means that the animation runs in an endless loop until the stop() method has been called.
See Also:
getRepetitionMode()

getRepetitionMode

public int getRepetitionMode()
Returns the repetition mode of the matte's animation in form of a number. The number reads how many repetitions have been determined for this animation.

Specified by:
getRepetitionMode in interface Animated
Returns:
number of repetitions determined for this animation or LOOP which means the animation runs in an endless loop until the stop() method has been called.
See Also:
setRepetitionMode(int)

setDelay

public void setDelay(int delay)
Determines the delay after every image when running the matte's animation.

Specified by:
setDelay in interface Animated
Parameters:
delay - delay in milliseconds
See Also:
getDelay()

getDelay

public int getDelay()
Obtains the delay after every image for the matte's animation when running.

Specified by:
getDelay in interface Animated
Returns:
the delay in milliseconds
See Also:
setDelay(int)

setAnimationMode

public void setAnimationMode(int mode)
Sets the animation mode for the matte's animation. The animation mode determines how the animation is running: always forwards, or forwards and backwards alternating.

Specified by:
setAnimationMode in interface Animated
Parameters:
mode - the animation mode. Possible values are: REPEATING and ALTERNATING.
See Also:
getAnimationMode()

getAnimationMode

public int getAnimationMode()
Obtains the animation mode for the matte's animation. The animation mode determines how the animation is running: always forwards, or forwards and backwards alternating.

Specified by:
getAnimationMode in interface Animated
Returns:
the animation mode. Possible values are: REPEATING and ALTERNATING.
See Also:
setAnimationMode(int)

hasImageAnimation

public boolean hasImageAnimation()
Obtains whether the currently assigned animation to this matte is based on a row of images or not.

Returns:
true is current animation is based on a row of opacity images, false if it is based on a row of unitary opacity values

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame.

Specified by:
animate in interface Animation
Returns:
true if a repaint is desired or false if no repaint is necessary

paint

public void paint(Graphics g)
Draws the animation, within a component the standard paint method would be invoked since it bares the exact same signature.

Specified by:
paint in interface Animation

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.