1/*
2 * Copyright (C) 2007 Esmertec AG.
3 * Copyright (C) 2007 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.mms.dom.smil;
19
20import org.w3c.dom.NodeList;
21import org.w3c.dom.smil.SMILLayoutElement;
22import org.w3c.dom.smil.SMILRootLayoutElement;
23
24import com.android.mms.layout.LayoutManager;
25
26public class SmilLayoutElementImpl extends SmilElementImpl implements
27        SMILLayoutElement {
28    SmilLayoutElementImpl(SmilDocumentImpl owner, String tagName) {
29        super(owner, tagName);
30    }
31
32    public boolean getResolved() {
33        // TODO Auto-generated method stub
34        return false;
35    }
36
37    public String getType() {
38        return this.getAttribute("type");
39    }
40
41    public NodeList getRegions() {
42        return this.getElementsByTagName("region");
43    }
44
45    public SMILRootLayoutElement getRootLayout() {
46        NodeList childNodes = this.getChildNodes();
47        SMILRootLayoutElement rootLayoutNode = null;
48        int childrenCount = childNodes.getLength();
49        for (int i = 0; i < childrenCount; i++) {
50            if (childNodes.item(i).getNodeName().equals("root-layout")) {
51                rootLayoutNode = (SMILRootLayoutElement)childNodes.item(i);
52            }
53        }
54        if (null == rootLayoutNode) {
55            // root-layout node is not set. Create a default one.
56            rootLayoutNode = (SMILRootLayoutElement) getOwnerDocument().createElement("root-layout");
57            rootLayoutNode.setWidth(LayoutManager.getInstance().getLayoutParameters().getWidth());
58            rootLayoutNode.setHeight(LayoutManager.getInstance().getLayoutParameters().getHeight());
59            appendChild(rootLayoutNode);
60        }
61        return rootLayoutNode;
62    }
63
64}
65