Media Authoring
with Java API

tv.amwa.maj.embeddable
Class RGBAComponent

java.lang.Object
  extended by tv.amwa.maj.embeddable.RGBAComponent
All Implemented Interfaces:
Serializable, Cloneable, MAJCommon, XMLSerializable, RGBAComponent

public final class RGBAComponent
extends Object
implements RGBAComponent, Serializable, XMLSerializable, Cloneable, MAJCommon

Implements an element of an array representing the order and size of the component values within a pixel value as part of an RGBA Layout. The RGB layout type type is a fixed-size 8 element array, where each element consists of an RGBA component value. Each RGBA component has with the following fields:

Author:
Richard Cartwright
See Also:
TypeDefinitionRecord.RGBAComponent, RGBADescriptor, RGBAComponentKind, RGBALayout, Serialized Form

Nested Class Summary
static class RGBAComponent.XMLHandler
          XML parser event handler for converting RGBA component elements into RGBA component values.
 
Field Summary
static String RGBACOMPONENT_TAG
           
 
Constructor Summary
RGBAComponent()
          Create a new RGBA component with a RGBAComponentKind.Null code and a size of 0.
RGBAComponent(RGBAComponentKind code, byte size)
          Create an element of an RGBAComponent array.
 
Method Summary
 void appendXMLChildren(Node parent)
          Append child elements to the given parent node to serialize the value of an object to an XML fragment.
static RGBAComponent castFromInterface(RGBAComponent component)
          Cast a tv.amwa.maj.record.RGBAComponent value from the generic interface to this implementation of the interface.
 RGBAComponent clone()
          Creates a cloned deep copy of this embeddable value.
 boolean equals(Object o)
          Tests to see if the given object is equal to this embeddable value.
 RGBAComponentKind getCode()
          Returns the type of an RGBA component.
 byte getSize()
          Returns the size, measured in bits, of the RGBA component.
 int hashCode()
          Returns a hash code value for this embeddable object.
 void setCode(RGBAComponentKind code)
          Sets the type of an RGBA component.
 void setPropertiesFromInterface(RGBAComponent castFrom)
          Set the properties of this value from those available in the given value, which is specified by the RGBA component interface.
 void setSize(byte size)
          Sets the size, measured in bits, of the RGBA component.
 String toString()
          Creates a pseudo-XML string representation of this RGBA component value.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RGBACOMPONENT_TAG

public static final String RGBACOMPONENT_TAG
See Also:
Constant Field Values
Constructor Detail

RGBAComponent

public RGBAComponent()

Create a new RGBA component with a RGBAComponentKind.Null code and a size of 0.

This constructor is public to allow the TypeDefinitionRecord.getObject(tv.amwa.maj.iface.PropertyValue, Class) method to create new instances of objects from record property values.


RGBAComponent

public RGBAComponent(RGBAComponentKind code,
                     @UInt8
                     byte size)
              throws NullPointerException,
                     IllegalArgumentException

Create an element of an RGBAComponent array.

Parameters:
code - Code for the component.
size - Size of the component in bits.
Throws:
NullPointerException - The code argument is null.
IllegalArgumentException - The size argument is negative.
Method Detail

castFromInterface

public static final RGBAComponent castFromInterface(RGBAComponent component)
                                             throws NullPointerException

Cast a tv.amwa.maj.record.RGBAComponent value from the generic interface to this implementation of the interface. If the given value is not this MAJ API implementation, a copy will be instantiated of this type and with an equivalent value.

Parameters:
component - A potentially alien implementation of an instance of the RGBA component interface.
Returns:
Instance of this class that is equal to the given value.
Throws:
NullPointerException - The given alien rational value is null.
See Also:
setPropertiesFromInterface(tv.amwa.maj.record.RGBAComponent)

setPropertiesFromInterface

public final void setPropertiesFromInterface(RGBAComponent castFrom)

Set the properties of this value from those available in the given value, which is specified by the RGBA component interface.

Parameters:
castFrom - Value to extract properties from.
Throws:
NullPointerException - The given value to use to set this value is null.
See Also:
castFromInterface(tv.amwa.maj.record.RGBAComponent)

getCode

public final RGBAComponentKind getCode()
Description copied from interface: RGBAComponent

Returns the type of an RGBA component.

Specified by:
getCode in interface RGBAComponent
Returns:
Type of an RGBA component.

setCode

public final void setCode(RGBAComponentKind code)
                   throws NullPointerException
Description copied from interface: RGBAComponent

Sets the type of an RGBA component.

Specified by:
setCode in interface RGBAComponent
Parameters:
code - Type of an RGBA component.
Throws:
NullPointerException - The given component kind is null.

getSize

@UInt8
public final byte getSize()
Description copied from interface: RGBAComponent

Returns the size, measured in bits, of the RGBA component.

Specified by:
getSize in interface RGBAComponent
Returns:
Size of the RGBA component.

setSize

public final void setSize(@UInt8
                          byte size)
                   throws IllegalArgumentException
Description copied from interface: RGBAComponent

Sets the size, measured in bits, of the RGBA component.

Specified by:
setSize in interface RGBAComponent
Parameters:
size - Size of the RGBA component.
Throws:
IllegalArgumentException - The size value is negative.

equals

public final boolean equals(Object o)
Description copied from interface: MAJCommon

Tests to see if the given object is equal to this embeddable value. To be equal, the given value must be not null, share the same interface to its value and each of the properties of the value must each be equal.

Specified by:
equals in interface MAJCommon
Overrides:
equals in class Object
Parameters:
o - Object to test for equality with.
Returns:
Is the given object equals to this value?
See Also:
Object.equals(Object)

toString

public final String toString()

Creates a pseudo-XML string representation of this RGBA component value. The representation consists of a RGBAComponent element with Code and Size sub-elements. For example, an 8-bit red component is represented as follows:

   <RGBAComponent>
     <Code>CompRed</Code>
     <Size>8</Size>
   </RGBAComponent>
 

Specified by:
toString in interface MAJCommon
Overrides:
toString in class Object
Returns:
Pseudo-XML representation of this RGBA component value.
See Also:
RGBAComponent.XMLHandler

clone

public final RGBAComponent clone()
Description copied from interface: MAJCommon

Creates a cloned deep copy of this embeddable value. The clone will be initialized to have the same value as this value but exists independently from then on. Changes to this value will not effect the clone and changes to the clone will not effect this. MAJ API clones are true deep clones with no shared references to areas of memory within the original.

This method does not throw a CloneNotSupportedException as all embeddable values must implement the Cloneable interface.

Specified by:
clone in interface MAJCommon
Overrides:
clone in class Object
Returns:
Independent clone of this value, which is a deep copy.
See Also:
Object.clone()

hashCode

public int hashCode()
Description copied from interface: MAJCommon

Returns a hash code value for this embeddable object.

Specified by:
hashCode in interface MAJCommon
Overrides:
hashCode in class Object
Returns:
Hash code value for this embeddable object.
See Also:
Object.hashCode()

appendXMLChildren

public void appendXMLChildren(Node parent)
Description copied from interface: XMLSerializable

Append child elements to the given parent node to serialize the value of an object to an XML fragment. Methods of the XMLBuilder class are provided to help with this process.

Specified by:
appendXMLChildren in interface XMLSerializable
Parameters:
parent - XML parent element to append child nodes to.

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.