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

UseProxy

public class UseProxy extends StructureNodeProxy
A UseProxy proxies a Use node and computes the expanded content from the proxied use's children and its proxy expanded child.

A UseProxy has a first expanded child corresponding to the proxied Use's proxy content. Follow on expanded children come from the Use's children.

version
$Id: UseProxy.java,v 1.6 2006/06/29 10:47:36 ln156897 Exp $

Fields Summary
Constructors Summary
UseProxy(Use proxiedUse)

param
proxiedUse Use node to proxy

        super(proxiedUse);
    
Methods Summary
ElementNodeProxybuildProxiedProxy()
Implementation helper. This handles getting the proxy from the proxied Use's proxy's proxied (see comments in the code).

return
an expanded ElementNodeProxy for the proxied Use's proxy.

        // 
        // Here we are in a situation like:
        //
        // + u -> u2 -> rect
        //
        // Which we expand into
        //
        // + rect
        // + u2
        //    +~~> ElementNodeProxy(rect)
        // + u
        //    +~~> UseProxy(u2)
        //         +~~> ElementNodeProxy(rect)
        //
        // To understand the following code, we are building
        // the equivalent of UseProxy(u2)
        //
        // proxied.expandedContent[0] is a reference to 
        // u2's ElementNodeProxy(rect)
        //
        Use proxiedUse = (Use) proxied;
        ElementNodeProxy proxy
            = proxiedUse.proxy.getProxied().buildExpandedProxy();
        proxy.setParentQuiet(this);
        return proxy;
    
protected voidexpand()
Expand the content. For a use node, we create additional expanded content to account for the use proxy.

        if (expanded) {
            return;
        }
        if (proxied != null) {
            //
            // The first expanded content comes from the proxied <use>'s
            // proxy.
            // At the end of this first computation, the firstExpandedChild
            // points to a proxy for the <use>'s proxy or is null and the
            // lastExpandedChild is equal to the firstExpandedChild
            //
            Use proxiedUse = (Use) proxied;
            if (proxiedUse.proxy != null) {
                firstExpandedChild = buildProxiedProxy();
            } else {
                firstExpandedChild = null;
            }
            
            lastExpandedChild = firstExpandedChild;

            //
            // Now, do the regular expansion, in case the <use> element
            // has regular element children.
            //
            ElementNodeProxy firstRegularProxies =
                computeProxiesChain((ElementNode) proxied.getFirstChildNode());

            if (firstRegularProxies != null) {
                lastExpandedChild = firstRegularProxies.prevSibling;
                if (firstExpandedChild == null) {
                    // The proxied <use> has no proxy
                    firstExpandedChild = firstRegularProxies;
                    firstRegularProxies.prevSibling = null;
                } else {
                    // The proxied <use> had a proxy
                    firstExpandedChild.nextSibling = firstRegularProxies;
                    firstRegularProxies.prevSibling = firstExpandedChild;
                }
            }

        } 
        
        expanded = true;
    
public org.w3c.dom.svg.SVGRectgetBBox()

return
the tight bounding box in current user coordinate space.

        Transform t = null;
        Use proxiedUse = (Use) proxied;
        
        if (proxiedUse != null && (proxiedUse.x != 0 || proxiedUse.y != 0)) {
            t = new Transform(1, 0, 0, 1, proxiedUse.x, proxiedUse.y);
        }
        
        return addBBox(null, t);
    
protected voidproxiedPropertyStateChange(int propertyIndex, java.lang.Object proxiedComputedValue)
Called by the proxied node when the given property's computed value has changed.

param
propertyIndex index for the property whose value is changing.
param
proxiedComputedValue computed value for the proxied node.

        Object inheritValue = proxiedComputedValue;
        if (!((CompositeGraphicsNode) proxied).isInherited(propertyIndex)) {
            // The property is specified on the proxied node, update the 
            // state with that specified value.
            setPropertyState(propertyIndex, proxiedComputedValue);
        } else {
            // The property is unspecified on the proxied node. Inherit from
            // the proxy's parent (and not the proxied's parent).
            inheritValue = getInheritedPropertyState(propertyIndex);
            setPropertyState(propertyIndex, inheritValue);
        }

        // Propagate to children.
        ModelNode c = firstExpandedChild;
        while (c != null) {
            propagatePropertyState(propertyIndex, inheritValue);
            c = c.nextSibling;
        }
    
protected voidsetProxied(ElementNode newProxied)
Disallow proxying of anything else than Use nodes.

param
newProxied this node's new proxied node
throws
IllegalArgumentException if the input new proxy is not a Use node.
see
ElementNodeProxy#setProxied

        if (newProxied != null && !(newProxied instanceof Use)) {
            throw new IllegalArgumentException();
        }

        super.setProxied(newProxied);
    
voiduseProxySet()
Notifies this proxy that the proxied Use's proxy has just been set.

        if (!expanded) {
            expand();
        } else {
            ElementNodeProxy newFirstExpandedChild 
                = buildProxiedProxy();
            newFirstExpandedChild.nextSibling = firstExpandedChild;
            if (firstExpandedChild != null) {
                firstExpandedChild.prevSibling = newFirstExpandedChild;
            }
            firstExpandedChild = newFirstExpandedChild;
            if (lastExpandedChild == null) {
                lastExpandedChild = firstExpandedChild;
            }
        }