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.SMILDocument;
22import org.w3c.dom.smil.SMILRegionElement;
23import org.w3c.dom.smil.SMILRegionMediaElement;
24
25public class SmilRegionMediaElementImpl extends SmilMediaElementImpl implements
26        SMILRegionMediaElement {
27    private SMILRegionElement mRegion;
28
29    SmilRegionMediaElementImpl(SmilDocumentImpl owner, String tagName) {
30        super(owner, tagName);
31    }
32
33    public SMILRegionElement getRegion() {
34        if (mRegion == null) {
35            SMILDocument doc = (SMILDocument)this.getOwnerDocument();
36            NodeList regions = doc.getLayout().getElementsByTagName("region");
37            SMILRegionElement region = null;
38            for (int i = 0; i < regions.getLength(); i++) {
39                region = (SMILRegionElement)regions.item(i);
40                if (region.getId().equals(this.getAttribute("region"))) {
41                    mRegion = region;
42                }
43            }
44        }
45        return mRegion;
46    }
47
48    public void setRegion(SMILRegionElement region) {
49        this.setAttribute("region", region.getId());
50        mRegion = region;
51    }
52
53}
54