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

StructureNodeProxy

public class StructureNodeProxy extends CompositeGraphicsNodeProxy implements com.sun.perseus.j2d.TextRenderingProperties
A TextProxy proxies a Text node and computes its expanded content from the proxied text's data content.
version
$Id: StructureNodeProxy.java,v 1.4 2006/06/29 10:47:35 ln156897 Exp $

Fields Summary
protected String[]
fontFamily
Controls this node's fontFamily
protected float
fontSize
Controls this node's fontSize
Constructors Summary
protected StructureNodeProxy(StructureNode proxiedNode)

param
proxiedNode StructureNode to proxy


              
        
        super(proxiedNode);

        // We copy the computed value for all properties upon initialization. 
        // When the node is hooked in the tree, inherited properties will be
        // recomputed. Note that the fontStyle, fontWeight and textAnchor
        // properties are in the pack value that is already copied in the 
        // parent constructor.
        fontFamily = proxiedNode.fontFamily;
        fontSize = proxiedNode.fontSize;
    
Methods Summary
com.sun.perseus.j2d.BoxaddBBox(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 to apply from the node's coordinate space to the target coordinate space. May be null for the identity transform.
return
the node's bounding box in the target coordinate space.

        ModelNode c = getFirstExpandedChild();
        while (c != null) {
            if (c.canRenderState == 0) {
                bbox = c.addBBox(bbox, c.appendTransform(t, null));
            }
            c = c.nextSibling;
        }

        return bbox;
    
public org.w3c.dom.svg.SVGRectgetBBox()

return
the tight bounding box in current user coordinate space.

        return addBBox(null, null);
    
protected floatgetFloatPropertyState(int propertyIndex)
Returns the value for the given float property.

return
the value for the given property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_SIZE:
            return fontSize;
        default:
            return super.getFloatPropertyState(propertyIndex);
        }
    
public java.lang.String[]getFontFamily()

return
this node's computed font-family

        return fontFamily;
    
public floatgetFontSize()

return
this node's computed fontSize

        return fontSize;
    
public intgetFontStyle()

return
this node's computed fontStyle

        switch (pack & StructureNode.FONT_STYLE_MASK) {
        case StructureNode.FONT_STYLE_NORMAL_IMPL:
            return FONT_STYLE_NORMAL;
        case StructureNode.FONT_STYLE_ITALIC_IMPL:
            return FONT_STYLE_ITALIC;
        default:
            return FONT_STYLE_OBLIQUE;
        }
    
public intgetFontWeight()

return
this node's computed fontWeight

        switch (pack & StructureNode.FONT_WEIGHT_MASK) {
        case StructureNode.FONT_WEIGHT_100_IMPL:
            return FONT_WEIGHT_100;
        case StructureNode.FONT_WEIGHT_200_IMPL:
            return FONT_WEIGHT_200;
        case StructureNode.FONT_WEIGHT_300_IMPL:
            return FONT_WEIGHT_300;
        case StructureNode.FONT_WEIGHT_400_IMPL:
            return FONT_WEIGHT_400;
        case StructureNode.FONT_WEIGHT_500_IMPL:
            return FONT_WEIGHT_500;
        case StructureNode.FONT_WEIGHT_600_IMPL:
            return FONT_WEIGHT_600;
        case StructureNode.FONT_WEIGHT_700_IMPL:
            return FONT_WEIGHT_700;
        case StructureNode.FONT_WEIGHT_800_IMPL:
            return FONT_WEIGHT_800;
        case StructureNode.FONT_WEIGHT_900_IMPL:
            return FONT_WEIGHT_900;
        case StructureNode.FONT_WEIGHT_LIGHTER_IMPL:
            return TextNode.FONT_WEIGHT_LIGHTER;
        default:
            return TextNode.FONT_WEIGHT_BOLDER;
        }
    
protected intgetPackedPropertyState(int propertyIndex)
Returns the value for the given packed property.

return
the value for the given property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_STYLE:
            return pack & StructureNode.FONT_STYLE_MASK;
        case TextNode.PROPERTY_FONT_WEIGHT:
            return pack & StructureNode.FONT_WEIGHT_MASK;
        case TextNode.PROPERTY_TEXT_ANCHOR:
            return pack & StructureNode.TEXT_ANCHOR_MASK;
        default:
            return super.getPackedPropertyState(propertyIndex);
        }
    
protected java.lang.ObjectgetPropertyState(int propertyIndex)
Returns the value for the given property.

return
the value for the given property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_FAMILY:
            return fontFamily;
        default:
            return super.getPropertyState(propertyIndex);
        }
    
public intgetTextAnchor()

return
this node's computed textAnchor

        switch (pack & StructureNode.TEXT_ANCHOR_MASK) {
        case StructureNode.TEXT_ANCHOR_START_IMPL:
            return TEXT_ANCHOR_START;
        case StructureNode.TEXT_ANCHOR_MIDDLE_IMPL:
            return TEXT_ANCHOR_MIDDLE;
        default:
            return TEXT_ANCHOR_END;
        }
    
protected booleanisFloatPropertyState(int propertyIndex, float propertyValue)
Checks the state of the float property value.

param
propertyIndex the property index
param
propertyValue the computed value for the property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_SIZE:
            return fontSize == propertyValue;
        default:
            return super.isFloatPropertyState(propertyIndex, propertyValue);
        }
    
protected booleanisPackedPropertyState(int propertyIndex, int propertyValue)
Checks the state of the property value.

param
propertyIndex the property index
param
propertyValue the computed value for the property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_STYLE:
            return (propertyValue 
                    ==
                    (pack & StructureNode.FONT_STYLE_MASK));
        case TextNode.PROPERTY_FONT_WEIGHT:
            return (propertyValue
                    ==
                    (pack & StructureNode.FONT_WEIGHT_MASK));
        case TextNode.PROPERTY_TEXT_ANCHOR:
            return (propertyValue
                    ==
                    (pack & StructureNode.TEXT_ANCHOR_MASK));
        default:
            return super.isPackedPropertyState(propertyIndex, propertyValue);
        }
    
protected booleanisPropertyState(int propertyIndex, java.lang.Object propertyValue)
Checks the state of the property value.

param
propertyIndex the property index
param
propertyValue the computed value for the property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_FAMILY:
            return fontFamily == propertyValue;
        default:
            return super.isPropertyState(propertyIndex, propertyValue);
        }
    
public voidpaint(com.sun.perseus.j2d.RenderGraphics rg)
By default, an ElementNodeProxy does not paint anything.

param
rg the RenderGraphics where the node should paint itself

        if (canRenderState != 0) {
            return;
        }

        paint(getFirstExpandedChild(), rg);
    
voidrecomputeInheritedProperties()
Recomputes all inherited properties.

        super.recomputeInheritedProperties();
        ModelNode p = ownerDocument;
        if (parent != null) {
            p = parent;
        }
        
        recomputePropertyState(
                TextNode.PROPERTY_FONT_FAMILY, 
                p.getPropertyState(TextNode.PROPERTY_FONT_FAMILY));
        recomputeFloatPropertyState(
                TextNode.PROPERTY_FONT_SIZE, 
                p.getFloatPropertyState(TextNode.PROPERTY_FONT_SIZE));
        recomputePackedPropertyState(
                TextNode.PROPERTY_FONT_STYLE, 
                p.getPackedPropertyState(TextNode.PROPERTY_FONT_STYLE));
        recomputePackedPropertyState(
                TextNode.PROPERTY_FONT_WEIGHT,
                p.getPackedPropertyState(TextNode.PROPERTY_FONT_WEIGHT));
        recomputePackedPropertyState(
                TextNode.PROPERTY_TEXT_ANCHOR,
                p.getPackedPropertyState(TextNode.PROPERTY_TEXT_ANCHOR));
    
protected voidrecomputePackedPropertyState(int propertyIndex, int parentPropertyValue)
Recomputes the given packed property's state given the new parent property.

param
propertyIndex index for the property whose value is changing.
param
parentPropertyValue the value that children of this node should now inherit.

        if (propertyIndex != StructureNode.PROPERTY_FONT_WEIGHT) {
            super.recomputePackedPropertyState(propertyIndex, 
                                               parentPropertyValue);
        } else {
            // We do not need to recompute the fontWeight value if:
            // - the fontWeight is _not_ inherited & not relative (i.e. lighter
            //   or bolder)
            // or
            // - the property is inherited but the new parent property computed
            //   value is the same as the current value & the bolder and lighter
            //   markes are in the same state
            if ((!((StructureNode) proxied).isInherited(propertyIndex) 
                 && 
                 !((StructureNode) proxied).isMarkerSet(
                        StructureNode.FONT_WEIGHT_BOLDER_MARKER)
                 &&
                 !((StructureNode) proxied).isMarkerSet(
                        StructureNode.FONT_WEIGHT_LIGHTER_MARKER))
                 ||
                 isPackedPropertyState(propertyIndex, parentPropertyValue)) {
                return;
            }
            
            setPackedPropertyState(propertyIndex, parentPropertyValue);
            propagatePackedPropertyState(propertyIndex, parentPropertyValue);
        }
    
protected voidsetFloatPropertyState(int propertyIndex, float propertyValue)
Sets the computed value for the given float property.

param
propertyIndex the property index
param
propertyValue the computed value for the property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_SIZE:
            setFontSize(propertyValue);
            break;
        default:
            super.setFloatPropertyState(propertyIndex, propertyValue);
        }
    
public voidsetFontFamily(java.lang.String[] newFontFamily)

param
newFontFamily the new computed font-family property value.

        this.fontFamily = newFontFamily;
    
public voidsetFontSize(float newFontSize)

param
newFontSize the new computed font-size property value.

        this.fontSize = newFontSize;
    
public voidsetFontStyle(int newFontStyle)

param
newFontStyle the new computed font-style property.

        pack &= ~StructureNode.FONT_STYLE_MASK;
        switch (newFontStyle) {
        case FONT_STYLE_NORMAL:
            pack |= StructureNode.FONT_STYLE_NORMAL_IMPL;
            break;
        case FONT_STYLE_ITALIC:
            pack |= StructureNode.FONT_STYLE_ITALIC_IMPL;
            break;
        default:
            pack |= StructureNode.FONT_STYLE_OBLIQUE_IMPL;
            break;
        }
    
public voidsetFontWeight(int newFontWeight)

param
newFontWeight new computed value for the font-weight property.

        pack &= ~StructureNode.FONT_WEIGHT_MASK;

        switch (newFontWeight) {
        case FONT_WEIGHT_100:
            pack |= StructureNode.FONT_WEIGHT_100_IMPL;
            break;
        case FONT_WEIGHT_200:
            pack |= StructureNode.FONT_WEIGHT_200_IMPL;
            break;
        case FONT_WEIGHT_300:
            pack |= StructureNode.FONT_WEIGHT_300_IMPL;
            break;
        case FONT_WEIGHT_400:
            pack |= StructureNode.FONT_WEIGHT_400_IMPL;
            break;
        case FONT_WEIGHT_500:
            pack |= StructureNode.FONT_WEIGHT_500_IMPL;
            break;
        case FONT_WEIGHT_600:
            pack |= StructureNode.FONT_WEIGHT_600_IMPL;
            break;
        case FONT_WEIGHT_700:
            pack |= StructureNode.FONT_WEIGHT_700_IMPL;
            break;
        case FONT_WEIGHT_800:
            pack |= StructureNode.FONT_WEIGHT_800_IMPL;
            break;
        case FONT_WEIGHT_900:
            pack |= StructureNode.FONT_WEIGHT_900_IMPL;
            break;
        case StructureNode.FONT_WEIGHT_LIGHTER:
            pack |= StructureNode.FONT_WEIGHT_LIGHTER_IMPL;
            break;
        default:
            pack |= StructureNode.FONT_WEIGHT_BOLDER_IMPL;
            break;
        }
    
protected voidsetPackedPropertyState(int propertyIndex, int propertyValue)
Sets the computed value for the given packed property.

param
propertyIndex the property index
param
propertyValue the computed value for the property.

        switch (propertyIndex) {
        case StructureNode.PROPERTY_FONT_STYLE:
            switch (propertyValue) {
                case StructureNode.FONT_STYLE_NORMAL_IMPL:
                    setFontStyle(FONT_STYLE_NORMAL);
                    break;
                case StructureNode.FONT_STYLE_ITALIC_IMPL:
                    setFontStyle(FONT_STYLE_ITALIC);
                    break;
                case StructureNode.FONT_STYLE_OBLIQUE_IMPL:
                default:
                    setFontStyle(FONT_STYLE_OBLIQUE);
                    break;
            }
            break;
        case StructureNode.PROPERTY_FONT_WEIGHT:
            switch (propertyValue) {
                case StructureNode.FONT_WEIGHT_100_IMPL:
                    setFontWeight(FONT_WEIGHT_100);
                    break;
                case StructureNode.FONT_WEIGHT_200_IMPL:
                    setFontWeight(FONT_WEIGHT_200);
                    break;
                case StructureNode.FONT_WEIGHT_300_IMPL:
                    setFontWeight(FONT_WEIGHT_300);
                    break;
                case StructureNode.FONT_WEIGHT_400_IMPL:
                    setFontWeight(FONT_WEIGHT_400);
                    break;
                case StructureNode.FONT_WEIGHT_500_IMPL:
                    setFontWeight(FONT_WEIGHT_500);
                    break;
                case StructureNode.FONT_WEIGHT_600_IMPL:
                    setFontWeight(FONT_WEIGHT_600);
                    break;
                case StructureNode.FONT_WEIGHT_700_IMPL:
                    setFontWeight(FONT_WEIGHT_700);
                    break;
                case StructureNode.FONT_WEIGHT_800_IMPL:
                    setFontWeight(FONT_WEIGHT_800);
                    break;
                case StructureNode.FONT_WEIGHT_900_IMPL:
                    setFontWeight(FONT_WEIGHT_900);
                    break;
            }
            break;
        case StructureNode.PROPERTY_TEXT_ANCHOR:
            switch (propertyValue) {
                case StructureNode.TEXT_ANCHOR_START_IMPL:
                    setTextAnchor(TEXT_ANCHOR_START);
                    break;
                case StructureNode.TEXT_ANCHOR_MIDDLE_IMPL:
                    setTextAnchor(TEXT_ANCHOR_MIDDLE);
                    break;
                case StructureNode.TEXT_ANCHOR_END_IMPL:
                default:
                    setTextAnchor(TEXT_ANCHOR_END);
                    break;
            }
            break;
        default:
            super.setPackedPropertyState(propertyIndex, propertyValue);
        }
    
protected voidsetPropertyState(int propertyIndex, java.lang.Object propertyValue)
Sets the computed value for the given property.

param
propertyIndex the property index
param
propertyValue the computed value for the property.

        switch (propertyIndex) {
        case TextNode.PROPERTY_FONT_FAMILY:
            setFontFamily((String[]) propertyValue);
            break;
        default:
            super.setPropertyState(propertyIndex, propertyValue);
        }
    
public voidsetTextAnchor(int newTextAnchor)
Sets the value of the computed text anchor property.

param
newTextAnchor the new value for the computed text anchor property.

        pack &= ~StructureNode.TEXT_ANCHOR_MASK;
        switch (newTextAnchor) {
        case TEXT_ANCHOR_START:
            pack |= StructureNode.TEXT_ANCHOR_START_IMPL;
            break;
        case TEXT_ANCHOR_MIDDLE:
            pack |= StructureNode.TEXT_ANCHOR_MIDDLE_IMPL;
            break;
        default:
            pack |= StructureNode.TEXT_ANCHOR_END_IMPL;
            break;
        }