Search in sources :

Example 1 with TimeList

use of org.w3c.dom.smil.TimeList 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 TimeList

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

the class ElementTimeImpl method getEnd.

public TimeList getEnd() {
    ArrayList<Time> endTimeList = new ArrayList<>();
    String[] endTimeStringList = mSmilElement.getAttribute("end").split(";");
    int len = endTimeStringList.length;
    if (!((len == 1) && (endTimeStringList[0].length() == 0))) {
        // Initialize Time instances and add them to Vector
        for (String anEndTimeStringList : endTimeStringList) {
            try {
                endTimeList.add(new TimeImpl(anEndTimeStringList, getEndConstraints()));
            } catch (IllegalArgumentException e) {
                // Ignore badly formatted times
                Log.e(TAG, "Malformed time value.", e);
            }
        }
    }
    // "end" time is not specified
    if (endTimeList.isEmpty()) {
        // Get duration
        float duration = getDur();
        if (duration < 0) {
            endTimeList.add(new TimeImpl("indefinite", getEndConstraints()));
        } else {
            // Get begin
            TimeList begin = getBegin();
            for (int i = 0; i < begin.getLength(); i++) {
                endTimeList.add(new TimeImpl(// end = begin + dur
                begin.item(i).getResolvedOffset() + duration + "s", getEndConstraints()));
            }
        }
    }
    return new TimeListImpl(endTimeList);
}
Also used : ArrayList(java.util.ArrayList) ElementTime(org.w3c.dom.smil.ElementTime) Time(org.w3c.dom.smil.Time) TimeList(org.w3c.dom.smil.TimeList)

Example 3 with TimeList

use of org.w3c.dom.smil.TimeList 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 4 with TimeList

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

the class ElementTimeImpl method getEnd.

public TimeList getEnd() {
    ArrayList<Time> endTimeList = new ArrayList<Time>();
    String[] endTimeStringList = mSmilElement.getAttribute("end").split(";");
    int len = endTimeStringList.length;
    if (!((len == 1) && (endTimeStringList[0].length() == 0))) {
        // Initialize Time instances and add them to Vector
        for (int i = 0; i < len; i++) {
            try {
                endTimeList.add(new TimeImpl(endTimeStringList[i], getEndConstraints()));
            } catch (IllegalArgumentException e) {
                // Ignore badly formatted times
                Log.e(TAG, "Malformed time value.", e);
            }
        }
    }
    // "end" time is not specified
    if (endTimeList.size() == 0) {
        // Get duration
        float duration = getDur();
        if (duration < 0) {
            endTimeList.add(new TimeImpl("indefinite", getEndConstraints()));
        } else {
            // Get begin
            TimeList begin = getBegin();
            for (int i = 0; i < begin.getLength(); i++) {
                endTimeList.add(new TimeImpl(// end = begin + dur
                begin.item(i).getResolvedOffset() + duration + "s", getEndConstraints()));
            }
        }
    }
    return new TimeListImpl(endTimeList);
}
Also used : ArrayList(java.util.ArrayList) ElementTime(org.w3c.dom.smil.ElementTime) Time(org.w3c.dom.smil.Time) TimeList(org.w3c.dom.smil.TimeList)

Example 5 with TimeList

use of org.w3c.dom.smil.TimeList 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)

Aggregations

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