2 * Copyright (C) 2007 Esmertec AG.
3 * Copyright (C) 2007 The Android Open Source Project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package com.android.mms.dom.smil;
20 import org.w3c.dom.DOMException;
21 import org.w3c.dom.smil.SMILRootLayoutElement;
23 public class SmilRootLayoutElementImpl extends SmilElementImpl implements
24 SMILRootLayoutElement {
26 private static final String WIDTH_ATTRIBUTE_NAME = "width";
27 private static final String HEIGHT_ATTRIBUTE_NAME = "height";
28 private static final String BACKGROUND_COLOR_ATTRIBUTE_NAME = "backgroundColor";
29 private static final String TITLE_ATTRIBUTE_NAME = "title";
31 SmilRootLayoutElementImpl(SmilDocumentImpl owner, String tagName) {
32 super(owner, tagName);
35 public String getBackgroundColor() {
36 return this.getAttribute(BACKGROUND_COLOR_ATTRIBUTE_NAME);
39 public int getHeight() {
40 String heightString = this.getAttribute(HEIGHT_ATTRIBUTE_NAME);
41 return parseAbsoluteLength(heightString);
44 public String getTitle() {
45 return this.getAttribute(TITLE_ATTRIBUTE_NAME);
48 public int getWidth() {
49 String widthString = this.getAttribute(WIDTH_ATTRIBUTE_NAME);
50 return parseAbsoluteLength(widthString);
53 public void setBackgroundColor(String backgroundColor) throws DOMException {
54 this.setAttribute(BACKGROUND_COLOR_ATTRIBUTE_NAME, backgroundColor);
57 public void setHeight(int height) throws DOMException {
58 this.setAttribute(HEIGHT_ATTRIBUTE_NAME, String.valueOf(height) + "px");
62 public void setTitle(String title) throws DOMException {
63 this.setAttribute(TITLE_ATTRIBUTE_NAME, title);
66 public void setWidth(int width) throws DOMException {
67 this.setAttribute(WIDTH_ATTRIBUTE_NAME, String.valueOf(width) + "px");
74 private int parseAbsoluteLength(String length) {
75 if (length.endsWith("px")) {
76 length = length.substring(0, length.indexOf("px"));
79 return Integer.parseInt(length);
80 } catch (NumberFormatException e) {