FileDocCategorySizeDatePackage
ImageNode.javaAPI DocphoneME MR2 API (J2ME)34617Wed May 02 18:00:34 BST 2007com.sun.perseus.model

ImageNode

public class ImageNode extends AbstractRenderingNode implements RasterImageConsumer
This class models the SVG Tiny <image>. A value of 0 on the width and height attributes disables the rendering of the Image object. Negative width or height values on the ImageNode are illegal. If the referenced Image is null, this node will draw a gray box using the current fill value
version
$Id: ImageNode.java,v 1.17 2006/06/29 10:47:32 ln156897 Exp $

Fields Summary
static final String[]
REQUIRED_TRAITS
width and height are required on
static final String[]
REQUIRED_TRAITS_NS
xlink:href is required on
protected float
x
The viewport defined by the image element
protected float
y
protected float
width
protected float
height
protected com.sun.perseus.j2d.RasterImage
image
The painted Image. The image is built from the href attribute.
protected boolean
imageLoaded
Controls whether the image has been loaded or not.
protected String
href
The reference to the image data. This can be using base64 PNG or JPEG encoding or an absolute or relative URI.
protected String
absoluteURI
The absolute URI is computed from the href and the node's base URI.
protected int
align
Controls whether the image is aligned in the viewport or if it is just scaled to the viewport.
protected static final String
BROKEN_URI
Constant used to identify broken URI values
Constructors Summary
public ImageNode(DocumentNode ownerDocument)
Constructor.

param
ownerDocument this element's owner DocumentNode


    // =========================================================================
    // Image specific
    // =========================================================================

                
        
        super(ownerDocument);
        image = ownerDocument.getImageLoader().getLoadingImage();
        
        // Initially, the image's width and height are zero, so we
        // set the corresponding bits accordingly.
        canRenderState |= CAN_RENDER_ZERO_WIDTH_BIT;
        canRenderState |= CAN_RENDER_ZERO_HEIGHT_BIT;
    
Methods Summary
com.sun.perseus.j2d.BoxaddNodeBBox(com.sun.perseus.j2d.Box bbox, com.sun.perseus.j2d.Transform t)

param
bbox the bounding box to which this node's bounding box should be appended. That bounding box is in the target coordinate space. It may be null, in which case this node should create a new one.
param
t the transform from the node coordinate system to the coordinate system into which the bounds should be computed.
return
the bounding box of this node, in the target coordinate space,

        return addTransformedBBox(bbox, x, y, width, height, t);
    
protected voidcomputeRenderingTile(com.sun.perseus.j2d.Tile tile, com.sun.perseus.j2d.Transform t, com.sun.perseus.j2d.GraphicsProperties gp)
Computes the rendering tile for the given set of GraphicsProperties.

param
tile the Tile instance whose bounds should be set.
param
t the Transform to the requested tile space, from this node's user space.
param
gp the GraphicsProperties for which the tile should be computed.
return
the screen bounding box when this node is rendered with the given render context.

        tile.snapBox(addNodeBBox(null, t));
    
TraitAnimcreateTraitAnimImpl(java.lang.String traitName)

param
traitName the trait name.

        if (SVGConstants.SVG_X_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_Y_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_WIDTH_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_HEIGHT_ATTRIBUTE == traitName) {
            return new FloatTraitAnim(this, traitName, TRAIT_TYPE_FLOAT);
        } else if (SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE 
                == traitName) {
            return new StringTraitAnim(this, NULL_NS, traitName);
        } else {
            return super.createTraitAnimImpl(traitName);
        }
    
TraitAnimcreateTraitAnimNSImpl(java.lang.String traitNamespace, java.lang.String traitName)

param
traitName the trait name.
param
traitNamespace the trait's namespace. Should not be null.

        if (traitNamespace == SVGConstants.XLINK_NAMESPACE_URI
            &&
            traitName == SVGConstants.SVG_HREF_ATTRIBUTE) {
            return new StringTraitAnim(this, traitNamespace, traitName);
        }

        return super.createTraitAnimNSImpl(traitNamespace, traitName);
    
public intgetAlign()

return
the image's align property
see
StructureNode#ALIGN_NONE
see
StructureNode#ALIGN_XMIDYMID

        return align;
    
floatgetFloatTraitImpl(java.lang.String name)
ImageNode handles x, y, width and height traits. Other attributes are handled by the super class.

param
name the requested trait name.
param
the requested trait's floating point 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 float
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        if (SVGConstants.SVG_X_ATTRIBUTE == name) {
            return getX();
        } else if (SVGConstants.SVG_Y_ATTRIBUTE == name) {
            return getY();
        } else if (SVGConstants.SVG_WIDTH_ATTRIBUTE == name) {
            return getWidth();
        } else if (SVGConstants.SVG_HEIGHT_ATTRIBUTE == name) {
            return getHeight();
        } else {
            return super.getFloatTraitImpl(name);
        }
    
public floatgetHeight()

return
this image's height

        return height;
    
public java.lang.StringgetHref()

return
this node's image reference. This should be a URI

        return href;
    
public com.sun.perseus.j2d.RasterImagegetImage()

return
this node's Image resource. May be null in case no uri has been set or if loading the image data failed.

        return image;
    
public java.lang.StringgetLocalName()

return
the SVGConstants.SVG_IMAGE_TAG value

        return SVGConstants.SVG_IMAGE_TAG;
    
public java.lang.String[]getRequiredTraits()

return
an array of traits that are required by this element.

        return REQUIRED_TRAITS;
    
public java.lang.String[][]getRequiredTraitsNS()

return
an array of namespaceURI, localName trait pairs required by this element.

        return REQUIRED_TRAITS_NS;
    
public com.sun.perseus.util.RunnableQueue.RunnableHandlergetRunnableHandler()

return
the associated RunnableHandler, in case the associated RunnableQueue is not null.

        return ownerDocument.getRunnableHandler();
    
public java.lang.StringgetTraitImpl(java.lang.String name)
ImageNode handles x, y, width and height traits. Other traits are handled by the super class.

param
name the requested trait's 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_X_ATTRIBUTE == name) {
            return Float.toString(getX());
        } else if (SVGConstants.SVG_Y_ATTRIBUTE == name) {
            return Float.toString(getY());
        } else if (SVGConstants.SVG_WIDTH_ATTRIBUTE == name) {
            return Float.toString(getWidth());
        } else if (SVGConstants.SVG_HEIGHT_ATTRIBUTE == name) {
            return Float.toString(getHeight());
        } else if (SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE == name) {
            return alignToStringTrait(align);
        } else {
            return super.getTraitImpl(name);
        }
    
java.lang.StringgetTraitNSImpl(java.lang.String namespaceURI, java.lang.String name)
ImageNode handles the xlink href attribute

param
namespaceURI the requested trait's namespace URI.
param
name the requested trait's local name (i.e., un-prefixed, as "href")
return
the requested trait's string 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).
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        if (SVGConstants.XLINK_NAMESPACE_URI == namespaceURI
            &&
            SVGConstants.SVG_HREF_ATTRIBUTE == name) {
            if (href == null) {
                return "";
            } 
            return href;
        } else {
            return super.getTraitNSImpl(namespaceURI, name);
        }
    
public com.sun.perseus.util.RunnableQueuegetUpdateQueue()

return
the associated RunnableQueue. If not null, setImage should be called from within the runnable queue.

        return ownerDocument.getUpdateQueue();
    
public floatgetWidth()

return
this node's width

        return width;
    
public floatgetX()

return
this image's upper left corner position on the x-axis

        return x;
    
public floatgetY()

return
this image's upper left corner position on the y-axis

        return y;
    
public booleanhasNodeRendering()
An ImageNode has something to render

return
true

        return true;
    
protected booleanisHitVP(float[] pt)
Returns true if this node is hit by the input point. The input point is in viewport space.

param
pt the x/y coordinate. Should never be null and be of size two. If not, the behavior is unspecified. The x/y coordinate is in viewport space.
return
true if the node is hit by the input point.
see
#nodeHitAt

        if (!getVisibility()) {
                return false;
        }
        getInverseTransformState().transformPoint(pt, ownerDocument.upt);
        pt = ownerDocument.upt;
        return (pt[0] > x && pt[0] < (x + width)
                && pt[1] > y && pt[1] < (y + height));
    
protected booleanisProxyHitVP(float[] pt, AbstractRenderingNodeProxy proxy)
Returns true if the proxy node is hit by the input point. The input point is in viewport space.

param
pt the x/y coordinate. Should never be null and be of size two. If not, the behavior is unspecified. The x/y coordinate is in viewport space.
param
proxy the tested ElementNodeProxy.
return
true if the node is hit by the input point.
see
#nodeHitAt

        proxy.getInverseTransformState().transformPoint(pt, ownerDocument.upt);
        pt = ownerDocument.upt;
        return (pt[0] > x && pt[0] < (x + width)
                && pt[1] > y && pt[1] < (y + height));
    
public voidloadImage()
Implementation. Loads the image through the ownerDocument's ImageLoader. If this image's paintNeedsLoad is true, this will block until the image data has been retrieved. Otherwise, a request to asynchronously load the image is placed.

        // Note that if absoluteURI is null, it is because either href is null
        // or this node is not hooked into the tree. In these cases, we stick
        // to the loadingImage
        if (absoluteURI != null) {
            if (paintNeedsLoad) {
                image = ownerDocument.getImageLoader()
                    .getImageAndWait(absoluteURI);
                if (image == ownerDocument.getImageLoader().getBrokenImage()) {
                    throw new IllegalStateException();
                }
            } else {
                ownerDocument.getImageLoader().getImageLater(absoluteURI, this);
            }
        }
        imageLoaded = true;
    
public ElementNodenewInstance(DocumentNode doc)
Used by DocumentNode to create a new instance from a prototype ImageNode.

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

        return new ImageNode(doc);
    
voidpaintRendered(com.sun.perseus.j2d.RenderGraphics rg, com.sun.perseus.j2d.GraphicsProperties gp, com.sun.perseus.j2d.PaintTarget pt, com.sun.perseus.j2d.Transform tx)
Paints this node into the input RenderGraphics.

param
rg this node is painted into this RenderGraphics
param
gp the GraphicsProperties controlling the operation's rendering
param
pt the PaintTarget for the paint operation.
param
txf the Transform from user space to device space for the paint operation.

        if (!gp.getVisibility()) {
            return;
        }

        rg.setTransform(tx);
	rg.setOpacity(getOpacity());

        if (!imageLoaded) {
            loadImage();
        }

        //
        // Scale the image so that it fits into width/height
        // and is centered
        //
        int iw = image.getWidth();
        int ih = image.getHeight();

        if (align == StructureNode.ALIGN_NONE) {
            rg.drawImage(image, x, y, width, height);
        } else {
            float ws = width / iw;
            float hs = height / ih;
            float is = ws;
            if (hs < ws) {
                is = hs;
            }

            float oh = ih * is;
            float ow = iw * is;
            float dx = (width - ow) / 2;
            float dy = (height - oh) / 2;

            rg.drawImage(image, (x + dx), (y + dy), ow, oh);
        }
    
public voidsetAlign(int newAlign)

param
newAlign one of StructureNode.ALIGN_NONE or StructureNode.ALIGN_XMIDYMID

        if (newAlign == align) {
            return;
        }
        modifyingNode();
        this.align = newAlign;
        modifiedNode();
    
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_X_ATTRIBUTE == name) {
            setX(value[0][0]);
        } else if (SVGConstants.SVG_Y_ATTRIBUTE == name) {
            setY(value[0][0]);
        } else if (SVGConstants.SVG_WIDTH_ATTRIBUTE == name) {
            checkPositive(name, value[0][0]);
            setWidth(value[0][0]);
        } else if (SVGConstants.SVG_HEIGHT_ATTRIBUTE == name) {
            checkPositive(name, value[0][0]);
            setHeight(value[0][0]);
        } else {
            super.setFloatArrayTrait(name, value);
        }
    
public voidsetFloatTraitImpl(java.lang.String name, float value)
ImageNode handles x, y, rx, ry, width and height traits. Other traits are handled by the super class.

param
name the trait's name.
param
value the new trait's floating point 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.
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        try {
            if (SVGConstants.SVG_X_ATTRIBUTE == name) {
                setX(value);
            } else if (SVGConstants.SVG_Y_ATTRIBUTE == name) {
                setY(value);
            } else if (SVGConstants.SVG_WIDTH_ATTRIBUTE == name) {
                setWidth(value);
            } else if (SVGConstants.SVG_HEIGHT_ATTRIBUTE == name) {
                setHeight(value);
            } else {
                super.setFloatTraitImpl(name, value);
            }
        } catch (IllegalArgumentException iae) {
            throw illegalTraitValue(name, Float.toString(value));
        }
    
public voidsetHeight(float newHeight)

param
newHeight the new height for this image's node Should be strictly positive.

        if (newHeight < 0) {
            throw new IllegalArgumentException();
        }

        if (newHeight == height) {
            return;
        }

        modifyingNode();
        renderingDirty();
        this.height = newHeight;
        computeCanRenderHeightBit(height);
        modifiedNode();
    
public voidsetHref(java.lang.String newHref)

param
newHref the new reference for this node's image.
throws
IllegalArgumentException if the href cannot be resolved into an absoluteURI and paintNeedsLoad is set to true.

        if (newHref == null) {
            throw new IllegalArgumentException();
        }

        if (equal(newHref, href)) {
            return;
        }

        modifyingNode();
        renderingDirty();
        this.href = newHref;
        this.image = ownerDocument.getImageLoader().getLoadingImage();
        ownerDocument.getImageLoader().removeRasterImageConsumer(absoluteURI, 
                                                                 this);
        this.absoluteURI = null;
        this.imageLoaded = false;

        // Only declare the new URI to load if this node is
        // part of the document tree and if its href is set 
        // to a non-null value.
        if (isInDocumentTree() && href != null) {
            willNeedImage();
        }
        modifiedNode();
    
public voidsetImage(com.sun.perseus.j2d.RasterImage image, java.lang.String uri)
Sets the node's image if the computed absolute URI is equal to the input uri.

param
image the new node image. Should not be null.
param
uri the uri image corresponds to. This is passed in case the node's uri changed between a call to the ImageLoader's needsURI and a call to setImage.

        // This is done to handle situations where the href/parent
        // or other change occur while the image is loading.
        if (absoluteURI != null && absoluteURI.equals(uri)) {
            if (this.image != image) {
                modifyingNode();
                this.image = image;
                modifiedNode();
            }
        }
    
protected voidsetParentQuiet(ModelNode newParent)
Sets this node's parent but does not generate change events.

param
newParent the node's new parent node.

        super.setParentQuiet(newParent);

        // Reset the image if this node has a different parent that
        // impacts the computation of the absoluteURI
        if (href != null && !href.equals(absoluteURI)) {
            willNeedImage();
        }
    
public voidsetTraitImpl(java.lang.String name, java.lang.String value)
ImageNode handles x, y, rx, ry, width and height traits. Other traits are handled by the super class.

param
name the trait's name.
param
value the new trait string 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 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_X_ATTRIBUTE == name) {
            setX(parseFloatTrait(name, value));
        } else if (SVGConstants.SVG_Y_ATTRIBUTE == name) {
            setY(parseFloatTrait(name, value));
        } else if (SVGConstants.SVG_WIDTH_ATTRIBUTE == name) {
            setWidth(parsePositiveFloatTrait(name, value));
        } else if (SVGConstants.SVG_HEIGHT_ATTRIBUTE == name) {
            setHeight(parsePositiveFloatTrait(name, value));
        } else if (SVGConstants
                   .SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE.equals(name)) {
            if (SVGConstants
                .SVG_SVG_PRESERVE_ASPECT_RATIO_DEFAULT_VALUE.equals(value)) {
                setAlign(StructureNode.ALIGN_XMIDYMID);
            } else if (SVGConstants.SVG_NONE_VALUE.equals(value)) {
                setAlign(StructureNode.ALIGN_NONE);
            } else {
                throw illegalTraitValue(name, value);
            }
        } else {
            super.setTraitImpl(name, value);
        }
    
public voidsetTraitNSImpl(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
ImageNode supports the xlink:href trait.

param
namespaceURI the trait's namespace.
param
name the trait's local name (un-prefixed, e.g., "href");
param
value the new trait value (e.g., "http://www.sun.com/mypng.png")
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.
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        try {
            if (SVGConstants.XLINK_NAMESPACE_URI == namespaceURI
                &&
                SVGConstants.SVG_HREF_ATTRIBUTE == name) {
                setHref(value);
            } else {
                super.setTraitNSImpl(namespaceURI, name, value);
            }
        } catch (IllegalArgumentException iae) {
            throw illegalTraitValue(name, value);
        }
    
public voidsetWidth(float newWidth)

param
newWidth this node's new width. Should be strictly positive

        if (newWidth < 0) {
            throw new IllegalArgumentException();
        }

        if (newWidth == width) {
            return;
        }

        modifyingNode();
        renderingDirty();
        this.width = newWidth;
        computeCanRenderWidthBit(width);
        modifiedNode();
    
public voidsetX(float newX)

param
newX the new position of this image's upper left corner on the x-axis

        if (newX == x) {
            return;
        }
        modifyingNode();
        renderingDirty();
        this.x = newX;
        modifiedNode();
    
public voidsetY(float newY)

param
newY the new postion of this image's upper left corner on the y-axis

        if (newY == y) {
            return;
        }
        modifyingNode();
        renderingDirty();
        this.y = newY;
        modifiedNode();
    
booleansupportsTrait(java.lang.String traitName)
Supported traits: x, y, width, height

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_X_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_Y_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_WIDTH_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_HEIGHT_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE == traitName) {
            return true;
        } else {
            return super.supportsTrait(traitName);
        }
    
booleansupportsTraitNS(java.lang.String namespaceURI, java.lang.String traitName)
Supported traits: xlink:href

param
namespaceURI the trait's namespace.
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.XLINK_NAMESPACE_URI == namespaceURI
            &&
            SVGConstants.SVG_HREF_ATTRIBUTE == traitName) {
            return true;
        } else {
            return super.supportsTraitNS(namespaceURI, 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_X_ATTRIBUTE == name
            ||
            SVGConstants.SVG_Y_ATTRIBUTE == name
            ||
            SVGConstants.SVG_WIDTH_ATTRIBUTE == name
            ||
            SVGConstants.SVG_HEIGHT_ATTRIBUTE == name) {
            return Float.toString(value[0][0]);
        } 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_X_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_Y_ATTRIBUTE == traitName) {
            return new float[][]{{parseFloatTrait(traitName, value)}};
        } else if (SVGConstants.SVG_WIDTH_ATTRIBUTE == traitName
                   ||
                   SVGConstants.SVG_HEIGHT_ATTRIBUTE == traitName) {
            return new float[][] {{parsePositiveFloatTrait(traitName, value)}};
        } else {
            return super.validateFloatArrayTrait(traitName,
                                                 value,
                                                 reqNamespaceURI,
                                                 reqLocalName,
                                                 reqTraitNamespace,
                                                 reqTraitName);
        }
    
java.lang.StringvalidateTraitNS(java.lang.String namespaceURI, 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
namespaceURI the trait's namespace URI.
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 (namespaceURI != null) {
            return super.validateTraitNS(namespaceURI,
                                         traitName,
                                         value,
                                         reqNamespaceURI,
                                         reqLocalName,
                                         reqTraitNamespace,
                                         reqTraitName);
        }

        if (SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE
                .equals(traitName)) {
            if (!SVGConstants
                .SVG_SVG_PRESERVE_ASPECT_RATIO_DEFAULT_VALUE.equals(value)
                &&
                !SVGConstants.SVG_NONE_VALUE.equals(value)) {
                throw illegalTraitValue(traitName, value);
            }
            return value;
        } else {
            return super.validateTraitNS(namespaceURI,
                                         traitName,
                                         value,
                                         reqNamespaceURI,
                                         reqLocalName,
                                         reqTraitNamespace,
                                         reqTraitName);
        }
    
voidwillNeedImage()
Implementation. Declares to the ImageLoader that an image will be needed.

        imageLoaded = false;
        image = ownerDocument.getImageLoader().getLoadingImage();

        absoluteURI
            = ownerDocument.getImageLoader().resolveURI(href, getURIBase());
        
        if (absoluteURI == null) {
            if (paintNeedsLoad) {
                throw new IllegalArgumentException();
            } else {
                absoluteURI = BROKEN_URI;
                imageLoaded = true;
                image = ownerDocument.getImageLoader().getBrokenImage();
                return;
            }
        } else {
            ownerDocument.getImageLoader().addRasterImageConsumer(absoluteURI, 
                                                                  this);
            ownerDocument.getImageLoader().needsURI(absoluteURI);
        }