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

Symbol

public class Symbol extends Group
Represents an SVG Tiny <a> element. An symbol is a simple Group extension which simply has a href and a target attribute.
version
$Id: Symbol.java,v 1.6 2006/06/29 10:47:35 ln156897 Exp $

Fields Summary
protected float[]
viewBox
This SVG node's viewBox. If null, then there is no viewBox.
Constructors Summary
public Symbol(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)
Apply this node's viewBox x/y translation if it is not (0,0).

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 (viewBox == null
            ||
            (viewBox[0][0] == 0 && viewBox[0][1] == 0)) {
            return tx;
        }

        tx = recycleTransform(tx, workTx);
        
        if (viewBox != null) {
            tx.mTranslate(-viewBox[0][0], -viewBox[0][1]);
        }
        
        return tx;
    
TraitAnimcreateTraitAnimImpl(java.lang.String traitName)

param
traitName the trait name.

        if (SVGConstants.SVG_VIEW_BOX_ATTRIBUTE == traitName) {
            return new FloatTraitAnim(this, traitName, TRAIT_TYPE_SVG_RECT);
        } else {
            return super.createTraitAnimImpl(traitName);
        }
    
public org.w3c.dom.svg.SVGRectgetBBox()

        if (viewBox != null) {
            Transform t = new Transform(1, 0, 0, 1, -viewBox[0][0], 
                                        -viewBox[0][1]);
            return addBBox(null, t);
        }
        
        return addBBox(null, null);
    
public java.lang.StringgetLocalName()

return
the SVGConstants.SVG_A_TAG value

        return SVGConstants.SVG_SYMBOL_TAG;
    
org.w3c.dom.svg.SVGRectgetRectTraitImpl(java.lang.String name)
Symbol handles the viewBox Rect trait.

param
name the requested trait name (e.g., "viewBox")
return
the requested trait SVGRect 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 {@link org.w3c.dom.svg.SVGRect SVGRect}
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        if (SVGConstants.SVG_VIEW_BOX_ATTRIBUTE.equals(name)) {
            return toSVGRect(viewBox);
        } else {
            return super.getRectTraitImpl(name);
        }
    
public org.w3c.dom.svg.SVGMatrixgetScreenCTM()

        SVGMatrix m = super.getScreenCTM();
        if (m != null) {
            if (viewBox != null) {
                m = m.mTranslate(viewBox[0][0], viewBox[0][1]);
            }
        } 

        return m;
    
public java.lang.StringgetTraitImpl(java.lang.String name)
Symbol handles the viewBox trait.

param
name the requested trait name
return
the requested trait's 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_VIEW_BOX_ATTRIBUTE == name) {
            if (viewBox == null) {
                return "";
            } else {
                return "" + viewBox[0][0] + SVGConstants.COMMA 
                    + viewBox[0][1] + SVGConstants.COMMA 
                    + viewBox[1][0] + SVGConstants.COMMA 
                    + viewBox[2][0];
            }
        } else {
            return super.getTraitImpl(name);
        }
    
public float[][]getViewBox()

return
this Symbol's viewBox

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

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

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

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.

        if (SVGConstants.SVG_VIEW_BOX_ATTRIBUTE == name) {
            setViewBox(value);
        } else {
            super.setFloatArrayTrait(name, value);
        }
    
public voidsetRectTraitImpl(java.lang.String name, org.w3c.dom.svg.SVGRect rect)
Symbol handles the viewBox Rect trait.

param
name the trait name (e.g., "viewBox"
param
rect the 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 the requested trait's value cannot be specified as an {@link org.w3c.dom.svg.SVGRect SVGRect}
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null. SVGRect is invalid if the width or height values are set to negative.
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        // Note that here, we use equals because the string 
        // has not been interned.
        if (SVGConstants.SVG_VIEW_BOX_ATTRIBUTE.equals(name)) {
            if (rect == null) {
                throw illegalTraitValue(name, null);
            }
            
            if (rect.getWidth() < 0 || rect.getHeight() < 0) {
                throw illegalTraitValue(name, toStringTrait(new float[]
                    {rect.getX(), 
                     rect.getY(), 
                     rect.getWidth(), 
                     rect.getHeight()}));
            }
                
            setViewBox(new float[][] {
                new float[] {rect.getX(), rect.getY()}, 
                new float[] {rect.getWidth()}, 
                new float[] {rect.getHeight()}
            });
            
        } else {
            super.setRectTraitImpl(name, rect);
        }
    
public voidsetTraitImpl(java.lang.String name, java.lang.String value)
Symbol handles the viewBox trait.

param
name the name of the trait to set.
param
value the value of the trait to set.
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_VIEW_BOX_ATTRIBUTE == name) {
            setViewBox(toViewBox(name, value));
        } else {
            super.setTraitImpl(name, value);
        }
    
public voidsetViewBox(float[][] newViewBox)
Sets a new value for the viewBox. If there viewBox is not null, it should be of size 4

param
newViewBox the new viewBox for this SVG
throws
IllegalArgumentException if the input viewBox is not null and of size other than 4.


        if (newViewBox != null) {
            if (newViewBox.length != 3 
                ||
                newViewBox[0] == null
                ||
                newViewBox[1] == null
                ||
                newViewBox[2] == null
                ||
                newViewBox[0].length != 2
                ||
                newViewBox[1][0] < 0 
                || 
                newViewBox[2][0] < 0) {
                throw new IllegalArgumentException();
            }
        }

        modifyingNode();

        if (viewBox == null) {
            viewBox = new float[3][];
            viewBox[0] = new float[2];
            viewBox[1] = new float[1];
            viewBox[2] = new float[1];
        }

        viewBox[0][0] = newViewBox[0][0];    
        viewBox[0][1] = newViewBox[0][1];    
        viewBox[1][0] = newViewBox[1][0];    
        viewBox[2][0] = newViewBox[2][0];    

        recomputeTransformState();
        recomputeProxyTransformState();
        computeCanRenderEmptyViewBoxBit(viewBox);
        modifiedNode();
    
booleansupportsTrait(java.lang.String traitName)
Symbol handles the target trait.

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_VIEW_BOX_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_VIEW_BOX_ATTRIBUTE == name) {
            float[] vb = {value[0][0], value[0][1], value[1][0], value[2][0]};
            return toStringTrait(vb);
        } 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_VIEW_BOX_ATTRIBUTE == traitName) {
            return ownerDocument.viewBoxParser.parseViewBox(value);
        } else {
            return super.validateFloatArrayTrait(traitName,
                                                 value,
                                                 reqNamespaceURI,
                                                 reqLocalName,
                                                 reqTraitNamespace,
                                                 reqTraitName);
        }