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 18 package com.android.mms.dom.smil; 19 20 import java.util.ArrayList; 21 22 import org.w3c.dom.DOMException; 23 import org.w3c.dom.NodeList; 24 import org.w3c.dom.events.DocumentEvent; 25 import org.w3c.dom.events.Event; 26 import org.w3c.dom.smil.ElementParallelTimeContainer; 27 import org.w3c.dom.smil.ElementTime; 28 import org.w3c.dom.smil.SMILParElement; 29 import org.w3c.dom.smil.Time; 30 import org.w3c.dom.smil.TimeList; 31 32 public class SmilParElementImpl extends SmilElementImpl implements SMILParElement { 33 public final static String SMIL_SLIDE_START_EVENT = "SmilSlideStart"; 34 public final static String SMIL_SLIDE_END_EVENT = "SmilSlideEnd"; 35 36 ElementParallelTimeContainer mParTimeContainer = 37 new ElementParallelTimeContainerImpl(this) { 38 @Override 39 public TimeList getBegin() { 40 /* 41 * For children of a sequence, the only legal value for begin is 42 * a (single) non-negative offset value. 43 */ 44 TimeList beginTimeList = super.getBegin(); 45 if (beginTimeList.getLength() > 1) { 46 ArrayList<Time> singleTimeContainer = new ArrayList<Time>(); 47 singleTimeContainer.add(beginTimeList.item(0)); 48 beginTimeList = new TimeListImpl(singleTimeContainer); 49 } 50 return beginTimeList; 51 } 52 53 public NodeList getTimeChildren() { 54 return getChildNodes(); 55 } 56 57 public boolean beginElement() { 58 DocumentEvent doc = (DocumentEvent) SmilParElementImpl.this.getOwnerDocument(); 59 Event startEvent = doc.createEvent("Event"); 60 startEvent.initEvent(SMIL_SLIDE_START_EVENT, false, false); 61 dispatchEvent(startEvent); 62 return true; 63 } 64 65 public boolean endElement() { 66 DocumentEvent doc = (DocumentEvent) SmilParElementImpl.this.getOwnerDocument(); 67 Event endEvent = doc.createEvent("Event"); 68 endEvent.initEvent(SMIL_SLIDE_END_EVENT, false, false); 69 dispatchEvent(endEvent); 70 return true; 71 } 72 73 public void pauseElement() { 74 // TODO Auto-generated method stub 75 76 } 77 78 public void resumeElement() { 79 // TODO Auto-generated method stub 80 81 } 82 83 public void seekElement(float seekTo) { 84 // TODO Auto-generated method stub 85 86 } 87 88 ElementTime getParentElementTime() { 89 return ((SmilDocumentImpl) mSmilElement.getOwnerDocument()).mSeqTimeContainer; 90 } 91 }; 92 93 /* 94 * Internal Interface 95 */ 96 97 SmilParElementImpl(SmilDocumentImpl owner, String tagName) 98 { 99 super(owner, tagName.toUpperCase()); 100 } 101 102 int getBeginConstraints() { 103 /* 104 * For children of a sequence, the only legal value for begin is 105 * a (single) non-negative offset value. 106 */ 107 return (TimeImpl.ALLOW_OFFSET_VALUE); // Do not set ALLOW_NEGATIVE_VALUE 108 } 109 110 /* 111 * ElementParallelTimeContainer 112 */ 113 114 public String getEndSync() { 115 return mParTimeContainer.getEndSync(); 116 } 117 118 public float getImplicitDuration() { 119 return mParTimeContainer.getImplicitDuration(); 120 } 121 122 public void setEndSync(String endSync) throws DOMException { 123 mParTimeContainer.setEndSync(endSync); 124 } 125 126 public NodeList getActiveChildrenAt(float instant) { 127 return mParTimeContainer.getActiveChildrenAt(instant); 128 } 129 130 public NodeList getTimeChildren() { 131 return mParTimeContainer.getTimeChildren(); 132 } 133 134 public boolean beginElement() { 135 return mParTimeContainer.beginElement(); 136 } 137 138 public boolean endElement() { 139 return mParTimeContainer.endElement(); 140 } 141 142 public TimeList getBegin() { 143 return mParTimeContainer.getBegin(); 144 } 145 146 public float getDur() { 147 return mParTimeContainer.getDur(); 148 } 149 150 public TimeList getEnd() { 151 return mParTimeContainer.getEnd(); 152 } 153 154 public short getFill() { 155 return mParTimeContainer.getFill(); 156 } 157 158 public short getFillDefault() { 159 return mParTimeContainer.getFillDefault(); 160 } 161 162 public float getRepeatCount() { 163 return mParTimeContainer.getRepeatCount(); 164 } 165 166 public float getRepeatDur() { 167 return mParTimeContainer.getRepeatDur(); 168 } 169 170 public short getRestart() { 171 return mParTimeContainer.getRestart(); 172 } 173 174 public void pauseElement() { 175 mParTimeContainer.pauseElement(); 176 } 177 178 public void resumeElement() { 179 mParTimeContainer.resumeElement(); 180 } 181 182 public void seekElement(float seekTo) { 183 mParTimeContainer.seekElement(seekTo); 184 } 185 186 public void setBegin(TimeList begin) throws DOMException { 187 mParTimeContainer.setBegin(begin); 188 } 189 190 public void setDur(float dur) throws DOMException { 191 mParTimeContainer.setDur(dur); 192 } 193 194 public void setEnd(TimeList end) throws DOMException { 195 mParTimeContainer.setEnd(end); 196 } 197 198 public void setFill(short fill) throws DOMException { 199 mParTimeContainer.setFill(fill); 200 } 201 202 public void setFillDefault(short fillDefault) throws DOMException { 203 mParTimeContainer.setFillDefault(fillDefault); 204 } 205 206 public void setRepeatCount(float repeatCount) throws DOMException { 207 mParTimeContainer.setRepeatCount(repeatCount); 208 } 209 210 public void setRepeatDur(float repeatDur) throws DOMException { 211 mParTimeContainer.setRepeatDur(repeatDur); 212 } 213 214 public void setRestart(short restart) throws DOMException { 215 mParTimeContainer.setRestart(restart); 216 } 217 } 218