Search in sources :

Example 6 with ElementTime

use of org.w3c.dom.smil.ElementTime in project Signal-Android by WhisperSystems.

the class ElementParallelTimeContainerImpl method getImplicitDuration.

public float getImplicitDuration() {
    float dur = -1.0F;
    if (ENDSYNC_LAST.equals(getEndSync())) {
        NodeList children = getTimeChildren();
        for (int i = 0; i < children.getLength(); ++i) {
            ElementTime child = (ElementTime) children.item(i);
            TimeList endTimeList = child.getEnd();
            for (int j = 0; j < endTimeList.getLength(); ++j) {
                Time endTime = endTimeList.item(j);
                if (endTime.getTimeType() == Time.SMIL_TIME_INDEFINITE) {
                    // Return "indefinite" here.
                    return -1.0F;
                }
                if (endTime.getResolved()) {
                    float end = (float) endTime.getResolvedOffset();
                    dur = (end > dur) ? end : dur;
                }
            }
        }
    }
    return dur;
}
Also used : NodeList(org.w3c.dom.NodeList) ElementTime(org.w3c.dom.smil.ElementTime) Time(org.w3c.dom.smil.Time) ElementTime(org.w3c.dom.smil.ElementTime) TimeList(org.w3c.dom.smil.TimeList)

Example 7 with ElementTime

use of org.w3c.dom.smil.ElementTime in project Signal-Android by WhisperSystems.

the class ElementParallelTimeContainerImpl method getActiveChildrenAt.

public NodeList getActiveChildrenAt(float instant) {
    /*
         * Find the closest Time of ElementTime before instant.
         * Add ElementTime to list of active elements if the Time belongs to the begin-list,
         * do not add it otherwise.
         */
    ArrayList<Node> activeChildren = new ArrayList<Node>();
    NodeList children = getTimeChildren();
    int childrenLen = children.getLength();
    for (int i = 0; i < childrenLen; ++i) {
        double maxOffset = 0.0;
        boolean active = false;
        ElementTime child = (ElementTime) children.item(i);
        TimeList beginList = child.getBegin();
        int len = beginList.getLength();
        for (int j = 0; j < len; ++j) {
            Time begin = beginList.item(j);
            if (begin.getResolved()) {
                double resolvedOffset = begin.getResolvedOffset() * 1000.0;
                if ((resolvedOffset <= instant) && (resolvedOffset >= maxOffset)) {
                    maxOffset = resolvedOffset;
                    active = true;
                }
            }
        }
        TimeList endList = child.getEnd();
        len = endList.getLength();
        for (int j = 0; j < len; ++j) {
            Time end = endList.item(j);
            if (end.getResolved()) {
                double resolvedOffset = end.getResolvedOffset() * 1000.0;
                if ((resolvedOffset <= instant) && (resolvedOffset >= maxOffset)) {
                    maxOffset = resolvedOffset;
                    active = false;
                }
            }
        }
        if (active) {
            activeChildren.add((Node) child);
        }
    }
    return new NodeListImpl(activeChildren);
}
Also used : NodeListImpl(org.thoughtcrime.securesms.dom.NodeListImpl) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) ElementTime(org.w3c.dom.smil.ElementTime) Time(org.w3c.dom.smil.Time) ElementTime(org.w3c.dom.smil.ElementTime) TimeList(org.w3c.dom.smil.TimeList)

Example 8 with ElementTime

use of org.w3c.dom.smil.ElementTime in project Signal-Android by WhisperSystems.

the class ElementSequentialTimeContainerImpl method getDur.

public float getDur() {
    float dur = super.getDur();
    if (dur == 0) {
        NodeList children = getTimeChildren();
        for (int i = 0; i < children.getLength(); ++i) {
            ElementTime child = (ElementTime) children.item(i);
            if (child.getDur() < 0) {
                // Return "indefinite" since containing a child whose duration is indefinite.
                return -1.0F;
            }
            dur += child.getDur();
        }
    }
    return dur;
}
Also used : NodeList(org.w3c.dom.NodeList) ElementTime(org.w3c.dom.smil.ElementTime)

Example 9 with ElementTime

use of org.w3c.dom.smil.ElementTime in project Signal-Android by WhisperSystems.

the class SmilDocumentImpl method getBody.

public SMILElement getBody() {
    Node rootElement = getDocumentElement();
    Node headElement = getHead();
    Node bodyElement = headElement.getNextSibling();
    if (bodyElement == null || !(bodyElement instanceof SMILElement)) {
        // The body doesn't exist. Create a new one.
        bodyElement = createElement("body");
        rootElement.appendChild(bodyElement);
    }
    // Initialize the real sequential time container, which is body.
    mSeqTimeContainer = new ElementSequentialTimeContainerImpl((SMILElement) bodyElement) {

        public NodeList getTimeChildren() {
            return getBody().getElementsByTagName("par");
        }

        public boolean beginElement() {
            Event startEvent = createEvent("Event");
            startEvent.initEvent(SMIL_DOCUMENT_START_EVENT, false, false);
            dispatchEvent(startEvent);
            return true;
        }

        public boolean endElement() {
            Event endEvent = createEvent("Event");
            endEvent.initEvent(SMIL_DOCUMENT_END_EVENT, false, false);
            dispatchEvent(endEvent);
            return true;
        }

        public void pauseElement() {
        // TODO Auto-generated method stub
        }

        public void resumeElement() {
        // TODO Auto-generated method stub
        }

        public void seekElement(float seekTo) {
        // TODO Auto-generated method stub
        }

        ElementTime getParentElementTime() {
            return null;
        }
    };
    return (SMILElement) bodyElement;
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) DocumentEvent(org.w3c.dom.events.DocumentEvent) Event(org.w3c.dom.events.Event) SMILElement(org.w3c.dom.smil.SMILElement) ElementTime(org.w3c.dom.smil.ElementTime)

Example 10 with ElementTime

use of org.w3c.dom.smil.ElementTime in project qksms by moezbhatti.

the class ElementParallelTimeContainerImpl method getImplicitDuration.

public float getImplicitDuration() {
    float dur = -1.0F;
    if (ENDSYNC_LAST.equals(getEndSync())) {
        NodeList children = getTimeChildren();
        for (int i = 0; i < children.getLength(); ++i) {
            ElementTime child = (ElementTime) children.item(i);
            TimeList endTimeList = child.getEnd();
            for (int j = 0; j < endTimeList.getLength(); ++j) {
                Time endTime = endTimeList.item(j);
                if (endTime.getTimeType() == Time.SMIL_TIME_INDEFINITE) {
                    // Return "indefinite" here.
                    return -1.0F;
                }
                if (endTime.getResolved()) {
                    float end = (float) endTime.getResolvedOffset();
                    dur = (end > dur) ? end : dur;
                }
            }
        }
    }
    return dur;
}
Also used : NodeList(org.w3c.dom.NodeList) ElementTime(org.w3c.dom.smil.ElementTime) Time(org.w3c.dom.smil.Time) ElementTime(org.w3c.dom.smil.ElementTime) TimeList(org.w3c.dom.smil.TimeList)

Aggregations

ElementTime (org.w3c.dom.smil.ElementTime)14 NodeList (org.w3c.dom.NodeList)10 Time (org.w3c.dom.smil.Time)6 TimeList (org.w3c.dom.smil.TimeList)6 ArrayList (java.util.ArrayList)4 Node (org.w3c.dom.Node)4 DocumentEvent (org.w3c.dom.events.DocumentEvent)2 Event (org.w3c.dom.events.Event)2 SMILElement (org.w3c.dom.smil.SMILElement)2 NodeListImpl (com.android.mms.dom.NodeListImpl)1 NodeListImpl (org.thoughtcrime.securesms.dom.NodeListImpl)1