FileDocCategorySizeDatePackage
Group.javaAPI DocphoneME MR2 API (J2ME)15780Wed May 02 18:00:36 BST 2007com.sun.perseus.model

Group

public class Group extends StructureNode implements Transformable
A Group corresponds to an SVT Tiny <g> element.
version
$Id: Group.java,v 1.10 2006/06/29 10:47:32 ln156897 Exp $

Fields Summary
protected com.sun.perseus.j2d.Transform
transform
The Transform applied to this node.
protected com.sun.perseus.j2d.Transform
motion
The motion transform applied to this node. This is typically used for animateMotion, but it can be used as a regular trait as well.
protected com.sun.perseus.j2d.Transform
inverseTransform
The parent space to child space transform
Constructors Summary
public Group(DocumentNode ownerDocument)
Constructor.

param
ownerDocument this element's owner DocumentNode

        super(ownerDocument);
    
Methods Summary
protected com.sun.perseus.j2d.TransformappendTransform(com.sun.perseus.j2d.Transform tx, com.sun.perseus.j2d.Transform workTx)
Appends this node's transform, if it is not null.

param
tx the Transform to apply additional node transforms to. This may be null.
param
workTx a Transform which can be re-used if a new Transform needs to be created and workTx is not the same instance as tx.
return
a transform with this node's transform added.

        if (transform == null && motion == null) {
            return tx;
        } 

        tx = recycleTransform(tx, workTx);
        
        if (motion != null) {
            tx.mMultiply(motion);
        }

        if (transform != null) {
            tx.mMultiply(transform);
        }

        return tx;    
    
TraitAnimcreateTraitAnimImpl(java.lang.String traitName)

param
traitName the trait name.

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE == traitName) {
            return new TransformTraitAnim(this, traitName);
        } else if (SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE == traitName) {
            return new MotionTraitAnim(this, traitName);
        } else {
            return super.createTraitAnimImpl(traitName);
        }
    
public java.lang.StringgetLocalName()

return
the SVGConstants.SVG_GROUP_TAG value

        return SVGConstants.SVG_G_TAG;
    
org.w3c.dom.svg.SVGMatrixgetMatrixTraitImpl(java.lang.String name)
AbstractShapeNode handles the transform attribute. Other attributes are handled by the super class.

param
name matrix trait name.
return
the trait value corresponding to name as SVGMatrix.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE.equals(name)) {
            return toSVGMatrixTrait(transform);
        } else if (SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE.equals(name)) {
            return toSVGMatrixTrait(motion);
        } else {
            return super.getMatrixTraitImpl(name);
        }
    
public com.sun.perseus.j2d.TransformgetMotion()

return
this node's motion transform

        return motion;
    
public java.lang.StringgetTraitImpl(java.lang.String name)
AbstractShapeNode handles the transform attribute. Other attributes are handled by the super class.

param
name the requested trait name.
return
the requested trait value.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to a String (SVG Tiny only).

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE == name) {
            return toStringTrait(transform);
        } else if (SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE == name) {
            return toStringTrait(motion);
        } else {
            return super.getTraitImpl(name);
        }
    
public com.sun.perseus.j2d.TransformgetTransform()

return
this node's transform

        return transform;
    
public ElementNodenewInstance(DocumentNode doc)
Used by DocumentNode to create a new instance from a prototype Group.

param
doc the DocumentNode for which a new node is should be created.
return
a new Group for the requested document.

        return new Group(doc);
    
voidsetFloatArrayTrait(java.lang.String name, float[][] value)
Set the trait value as float array.

param
name the trait's name.
param
value the trait's value.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element.
throws
DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a float
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait.

        // We use .equals for the transform attribute as the string may not
        // have been interned. We use == for the motion pseudo attribute because
        // it is only used internally and from the SVGConstants strings.
        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE.equals(name)) {
            if (transform == null) {
                modifyingNode();
                transform = new Transform(value[0][0],
                                          value[1][0],
                                          value[2][0],
                                          value[3][0],
                                          value[4][0],
                                          value[5][0]);
            } else {
                if (!transform.equals(value)) {
                    modifyingNode();
                    transform.setTransform(value[0][0],
                                           value[1][0],
                                           value[2][0],
                                           value[3][0],
                                           value[4][0],
                                           value[5][0]);
                } else {
                    return;
                }
            }
            recomputeTransformState();
            recomputeProxyTransformState();
            modifiedNode();
        } else if (SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE == name) {
            if (motion == null) {
                modifyingNode();
                motion = new Transform(value[0][0],
                                       value[1][0],
                                       value[2][0],
                                       value[3][0],
                                       value[4][0],
                                       value[5][0]);
            } else {
                if (!motion.equals(value)) {
                    modifyingNode();
                    motion.setTransform(value[0][0],
                                        value[1][0],
                                        value[2][0],
                                        value[3][0],
                                        value[4][0],
                                        value[5][0]);
                } else {
                    return;
                }
            }
            recomputeTransformState();
            recomputeProxyTransformState();
            modifiedNode();
        } else {
            super.setFloatArrayTrait(name, value);
        }    
    
voidsetMatrixTraitImpl(java.lang.String name, com.sun.perseus.j2d.Transform matrix)
AbstractShapeNode handles the transform attribute. Other attributes are handled by the super class.

param
name name of trait to set
param
matrix Transform value of trait
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as an {@link org.w3c.dom.svg.SVGMatrix SVGMatrix}
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
throws
DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if attempt is made to change readonly trait.

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE.equals(name)) {
            setTransform(matrix);
        } else if (SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE.equals(name)) {
            setMotion(matrix);
        } else {
            super.setMatrixTraitImpl(name, matrix);
        }
    
public voidsetMotion(com.sun.perseus.j2d.Transform newMotion)

param
newMotion The new motion transform.

        if (equal(newMotion, motion)) {
            return;
        }

        modifyingNode();
        this.motion = newMotion;
        recomputeTransformState();
        recomputeProxyTransformState();
        modifiedNode();
    
public voidsetTraitImpl(java.lang.String name, java.lang.String value)
AbstractShapeNode handles the transform attribute. Other attributes are handled by the super class.

param
name the trait's name.
param
value the new trait value, as a string.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a String
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
throws
DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if attempt is made to change readonly trait.

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE == name) {
            setTransform(parseTransformTrait(name, value));
        } else if (SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE == name) {
            setMotion(parseTransformTrait(name, value));
        } else {
            super.setTraitImpl(name, value);
        }
    
public voidsetTransform(com.sun.perseus.j2d.Transform newTransform)

param
newTransform this node's new transform. Note that the input value is used by reference.

        if (equal(newTransform, transform)) {
            return;
        }

        modifyingNode();
        this.transform = newTransform;
        recomputeTransformState();
        recomputeProxyTransformState();
        modifiedNode();
    
booleansupportsTrait(java.lang.String traitName)
Supported traits: transform.

param
traitName the name of the trait which the element may support.
return
true if this element supports the given trait in one of the trait accessor methods.

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE == traitName) {
            return true;
        } else {
            return super.supportsTrait(traitName);
        }
    
java.lang.StringtoStringTrait(java.lang.String name, float[][] value)

param
name the name of the trait to convert.
param
value the float trait value to convert.

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE == name) {
            Transform transform = new Transform(value[0][0],
                                                value[1][0],
                                                value[2][0],
                                                value[3][0],
                                                value[4][0],
                                                value[5][0]);
            return toStringTrait(transform);
        } else {
            return super.toStringTrait(name, value);
        }
    
public float[][]validateFloatArrayTrait(java.lang.String traitName, java.lang.String value, java.lang.String reqNamespaceURI, java.lang.String reqLocalName, java.lang.String reqTraitNamespace, java.lang.String reqTraitName)
Validates the input trait value.

param
traitName the name of the trait to be validated.
param
value the value to be validated
param
reqNamespaceURI the namespace of the element requesting validation.
param
reqLocalName the local name of the element requesting validation.
param
reqTraitNamespace the namespace of the trait which has the values value on the requesting element.
param
reqTraitName the name of the trait which has the values value on the requesting element.
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is incompatible with the given trait.

        if (SVGConstants.SVG_TRANSFORM_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_MOTION_PSEUDO_ATTRIBUTE == traitName) {
            Transform txf = parseTransformTrait(traitName, value);
            return new float[][] {{(float) txf.getComponent(0)},
                                  {(float) txf.getComponent(1)},
                                  {(float) txf.getComponent(2)},
                                  {(float) txf.getComponent(3)},
                                  {(float) txf.getComponent(4)},
                                  {(float) txf.getComponent(5)}};
        } else {
            return super.validateFloatArrayTrait(traitName,
                                                 value,
                                                 reqNamespaceURI,
                                                 reqLocalName,
                                                 reqTraitNamespace,
                                                 reqTraitName);
        }