Search in sources :

Example 1 with NodeListImpl

use of com.android.mms.dom.NodeListImpl in project qksms by moezbhatti.

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(com.android.mms.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 2 with NodeListImpl

use of com.android.mms.dom.NodeListImpl in project qksms by moezbhatti.

the class ElementSequentialTimeContainerImpl method getActiveChildrenAt.

/*
     * ElementSequentialTimeContainer Interface
     */
public NodeList getActiveChildrenAt(float instant) {
    NodeList allChildren = this.getTimeChildren();
    ArrayList<Node> nodes = new ArrayList<Node>();
    for (int i = 0; i < allChildren.getLength(); i++) {
        instant -= ((ElementTime) allChildren.item(i)).getDur();
        if (instant < 0) {
            nodes.add(allChildren.item(i));
            return new NodeListImpl(nodes);
        }
    }
    return new NodeListImpl(nodes);
}
Also used : NodeListImpl(com.android.mms.dom.NodeListImpl) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList)

Aggregations

NodeListImpl (com.android.mms.dom.NodeListImpl)2 ArrayList (java.util.ArrayList)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 ElementTime (org.w3c.dom.smil.ElementTime)1 Time (org.w3c.dom.smil.Time)1 TimeList (org.w3c.dom.smil.TimeList)1