FileDocCategorySizeDatePackage
SmilRegionElementImpl.javaAPI DocAndroid 1.5 API9835Wed May 06 22:42:46 BST 2009com.android.mms.dom.smil

SmilRegionElementImpl

public class SmilRegionElementImpl extends SmilElementImpl implements org.w3c.dom.smil.SMILRegionElement

Fields Summary
private static final String
HIDDEN_ATTRIBUTE
private static final String
SLICE_ATTRIBUTE
private static final String
SCROLL_ATTRIBUTE
private static final String
MEET_ATTRIBUTE
private static final String
FILL_ATTRIBUTE
private static final String
ID_ATTRIBUTE_NAME
private static final String
WIDTH_ATTRIBUTE_NAME
private static final String
TITLE_ATTRIBUTE_NAME
private static final String
HEIGHT_ATTRIBUTE_NAME
private static final String
BACKGROUND_COLOR_ATTRIBUTE_NAME
private static final String
Z_INDEX_ATTRIBUTE_NAME
private static final String
TOP_ATTRIBUTE_NAME
private static final String
LEFT_ATTRIBUTE_NAME
private static final String
RIGHT_ATTRIBUTE_NAME
private static final String
BOTTOM_ATTRIBUTE_NAME
private static final String
FIT_ATTRIBUTE_NAME
private static final String
TAG
private static final boolean
DEBUG
private static final boolean
LOCAL_LOGV
Constructors Summary
SmilRegionElementImpl(SmilDocumentImpl owner, String tagName)


        
        super(owner, tagName);
    
Methods Summary
public java.lang.StringgetBackgroundColor()

        return this.getAttribute(BACKGROUND_COLOR_ATTRIBUTE_NAME);
    
public java.lang.StringgetFit()

        String fit = getAttribute(FIT_ATTRIBUTE_NAME);
        if (FILL_ATTRIBUTE.equalsIgnoreCase(fit)) {
            return FILL_ATTRIBUTE;
        } else if (MEET_ATTRIBUTE.equalsIgnoreCase(fit)) {
            return MEET_ATTRIBUTE;
        } else if (SCROLL_ATTRIBUTE.equalsIgnoreCase(fit)) {
            return SCROLL_ATTRIBUTE;
        } else if (SLICE_ATTRIBUTE.equalsIgnoreCase(fit)) {
            return SLICE_ATTRIBUTE;
        } else {
            return HIDDEN_ATTRIBUTE;
        }
    
public intgetHeight()

        try {
            return parseRegionLength(getAttribute(HEIGHT_ATTRIBUTE_NAME), false);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Height attribute is not set or incorrect.");
            }
        }
        int bbh = ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getHeight();
        try {
            bbh -= parseRegionLength(getAttribute(TOP_ATTRIBUTE_NAME), false);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Top attribute is not set or incorrect.");
            }
        }
        try {
            bbh -= parseRegionLength(getAttribute(BOTTOM_ATTRIBUTE_NAME), false);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Bottom attribute is not set or incorrect.");
            }
        }
        return bbh;
    
public java.lang.StringgetId()

        return this.getAttribute(ID_ATTRIBUTE_NAME);
    
public intgetLeft()

        try {
            return parseRegionLength(getAttribute(LEFT_ATTRIBUTE_NAME), true);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Left attribute is not set or incorrect.");
            }
        }
        try {
            int bbw = ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getWidth();
            int right = parseRegionLength(getAttribute(RIGHT_ATTRIBUTE_NAME), true);
            int width = parseRegionLength(getAttribute(WIDTH_ATTRIBUTE_NAME), true);
            return bbw - right - width;
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Right or width attribute is not set or incorrect.");
            }
        }
        return 0;
    
public java.lang.StringgetTitle()

        return this.getAttribute(TITLE_ATTRIBUTE_NAME);
    
public intgetTop()

        try {
            return parseRegionLength(getAttribute(TOP_ATTRIBUTE_NAME), false);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Top attribute is not set or incorrect.");
            }
        }
        try {
            int bbh = ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getHeight();
            int bottom = parseRegionLength(getAttribute(BOTTOM_ATTRIBUTE_NAME), false);
            int height = parseRegionLength(getAttribute(HEIGHT_ATTRIBUTE_NAME), false);
            return bbh - bottom - height;
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Bottom or height attribute is not set or incorrect.");
            }
        }
        return 0;
    
public intgetWidth()

        try {
            return parseRegionLength(getAttribute(WIDTH_ATTRIBUTE_NAME), true);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Width attribute is not set or incorrect.");
            }
        }
        int bbw = ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getWidth();
        try {
            bbw -= parseRegionLength(getAttribute(LEFT_ATTRIBUTE_NAME), true);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Left attribute is not set or incorrect.");
            }
        }
        try {
            bbw -= parseRegionLength(getAttribute(RIGHT_ATTRIBUTE_NAME), true);
        } catch (NumberFormatException _) {
            if (LOCAL_LOGV) {
                Log.v(TAG, "Right attribute is not set or incorrect.");
            }
        }
        return bbw;
    
public intgetZIndex()

        try {
            return Integer.parseInt(this.getAttribute(Z_INDEX_ATTRIBUTE_NAME));
        } catch (NumberFormatException _) {
            return 0;
        }
    
private intparseRegionLength(java.lang.String length, boolean horizontal)

        if (length.endsWith("px")) {
            length = length.substring(0, length.indexOf("px"));
            return Integer.parseInt(length);
        } else if (length.endsWith("%")) {
            double value = 0.01*Integer.parseInt(length.substring(0, length.length() - 1));
            if (horizontal) {
                value *= ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getWidth();
            } else {
                value *= ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getHeight();
            }
            return (int) Math.round(value);
        } else {
            return Integer.parseInt(length);
        }
    
public voidsetBackgroundColor(java.lang.String backgroundColor)

        this.setAttribute(BACKGROUND_COLOR_ATTRIBUTE_NAME, backgroundColor);
    
public voidsetFit(java.lang.String fit)

        if (fit.equalsIgnoreCase(FILL_ATTRIBUTE)
                || fit.equalsIgnoreCase(MEET_ATTRIBUTE)
                || fit.equalsIgnoreCase(SCROLL_ATTRIBUTE)
                || fit.equalsIgnoreCase(SLICE_ATTRIBUTE)) {
            this.setAttribute(FIT_ATTRIBUTE_NAME, fit.toLowerCase());
        } else {
            this.setAttribute(FIT_ATTRIBUTE_NAME, HIDDEN_ATTRIBUTE);
        }
    
public voidsetHeight(int height)

        this.setAttribute(HEIGHT_ATTRIBUTE_NAME, String.valueOf(height) + "px");
    
public voidsetId(java.lang.String id)

        this.setAttribute(ID_ATTRIBUTE_NAME, id);
    
public voidsetLeft(int left)

        this.setAttribute(LEFT_ATTRIBUTE_NAME, String.valueOf(left));
    
public voidsetTitle(java.lang.String title)

        this.setAttribute(TITLE_ATTRIBUTE_NAME, title);
    
public voidsetTop(int top)

        this.setAttribute(TOP_ATTRIBUTE_NAME, String.valueOf(top));
    
public voidsetWidth(int width)

        this.setAttribute(WIDTH_ATTRIBUTE_NAME, String.valueOf(width) + "px");
    
public voidsetZIndex(int zIndex)

        if (zIndex > 0) {
            this.setAttribute(Z_INDEX_ATTRIBUTE_NAME, Integer.toString(zIndex));
        } else {
            this.setAttribute(Z_INDEX_ATTRIBUTE_NAME, Integer.toString(0));
        }
    
public java.lang.StringtoString()

        return super.toString()
                + ": id=" + getId()
                + ", width=" + getWidth()
                + ", height=" + getHeight()
                + ", left=" + getLeft()
                + ", top=" + getTop();