⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notimegapwithinparent.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                ets = new TimeSlotImpl(end, timeOrder);                timeOrder.insertTimeSlot(ets, bts, currAnn.getEnd());                //currAnn.setBegin(ets); later...                //  propagate changes to depending tiers, the begin                TierImpl nextT;                for (int i = 0; i < childTiers.size(); i++) {                    nextT = (TierImpl) childTiers.get(i);                    if (nextT.isTimeAlignable()) {                        // hier... testen op stereotype en Included In apart behandelen, of hier alleen Time Sub                         // en Included In overlaten aan TierImpl correctOverlaps etc.                        setAlignableBeginSlot(nextT, currAnn, ets, end);                    }                }                currAnn.setBegin(ets);            } else {                // multiple overlapping annotations, end is in the boundaries of one of the following anno's                if (!insertAtParentEnd) {                    TimeSlot oldBeginTS;                    TierImpl nextT;                    ets = new TimeSlotImpl(end, timeOrder);                    oldBeginTS = currEndAnn.getBegin();                    if (!oldBeginTS.isTimeAligned()) {                        AlignableAnnotation naa = getFirstAlignedAnnotation((TierImpl) forTier,                                currEndAnn);                        if (naa != null) {                            currEndAnn = naa;                            oldBeginTS = currEndAnn.getBegin();                        }                    }                    timeOrder.insertTimeSlot(ets, currEndAnn.getBegin(),                        currEndAnn.getEnd());                    // propagate changes to depending tiers, the end                    for (int i = 0; i < childTiers.size(); i++) {                        nextT = (TierImpl) childTiers.get(i);                        if (nextT.isTimeAlignable()) {                            setAlignableBeginSlot(nextT, currEndAnn, ets, end);                        }                    }                    currEndAnn.setBegin(ets);                } else {                    // end is the same as the end of one of the following annotations                    ets = parentAnn.getEnd();                }            }        } else {            // case 3 and 4: begin is not the same as an exisitng annotation,create a new timeSlot            AlignableAnnotation nextAA;            TimeSlot oldEndTS;            TierImpl nextT;            bts = new TimeSlotImpl(begin, timeOrder);            oldEndTS = currAnn.getEnd();            timeOrder.insertTimeSlot(bts, currAnn.getBegin(), ets);            //currAnn.setEnd(bts);            // reconnect next annotation            if (multiOverlappingAnns) {                Vector nx = ((TierImpl) forTier).getAnnotsBeginningAtTimeSlot(oldEndTS);                for (int j = 0; j < nx.size(); j++) {                    nextAA = (AlignableAnnotation) nx.get(j);                    if (parentAnn.getParentListeners().contains(nextAA)) {                        for (int i = 0; i < childTiers.size(); i++) {                            nextT = (TierImpl) childTiers.get(i);                            if (nextT.isTimeAlignable()) {                                //setAlignableBeginSlot(nextT, nextAA, bts, end);//hier begin?? of alle annots met oldEndTS als begin                                //setAlignableBeginSlot(nextT, nextAA, bts, begin);//hier begin?? timealignable?                                // nieuwe methode setBeginSlot(nextT, nextAA, bts, oldEndTS)??                            }                        }                        nextAA.setBegin(bts);                    }                }            }            // propagate changes to depending tiers            for (int i = 0; i < childTiers.size(); i++) {                nextT = (TierImpl) childTiers.get(i);                if (nextT.isTimeAlignable()) {                    setAlignableEndSlot(nextT, currAnn, bts, ets, begin, end);                }            }            currAnn.setEnd(bts);            // if !multiOverlappingAnns end has been set to be the same as currAnn's end time            if (multiOverlappingAnns) {                // end is in the boundaries of a following annotation                if (coincidingEnd) {                    // case 3: coinciding begin time of currEndAnn or end time of currEndAnn in case it is the parents end                    if (insertAtParentEnd) {                        ets = parentAnn.getEnd();                    } else {                        ets = currEndAnn.getBegin();                    }                } else {                    //case 4:  create a new end time slot too                    TimeSlot oldBeginTS;                    ets = new TimeSlotImpl(end, timeOrder);                    oldBeginTS = currEndAnn.getBegin();                    if (!oldBeginTS.isTimeAligned()) {                        AlignableAnnotation naa = getFirstAlignedAnnotation((TierImpl) forTier,                                currEndAnn);                        if (naa != null) {                            currEndAnn = naa;                            oldBeginTS = currEndAnn.getBegin();                        }                    }                    timeOrder.insertTimeSlot(ets, currEndAnn.getBegin(),                        currEndAnn.getEnd());                    //currEndAnn.setBegin(ets); later...                    // propagate changes to depending tiers, the end                    for (int i = 0; i < childTiers.size(); i++) {                        nextT = (TierImpl) childTiers.get(i);                        if (nextT.isTimeAlignable()) {                            setAlignableBeginSlot(nextT, currEndAnn, ets, end);                        }                    }                    currEndAnn.setBegin(ets);                }            }        }        slots.add(bts);        slots.add(ets);        return slots;    }    /**     * DOCUMENT ME!     *     * @param theTier DOCUMENT ME!     */    public void enforceOnWholeTier(Tier theTier) {        // close all gaps within parents by reconnecting time slots        // iterate over parent's annotations.        // for each parent, find enclosed annotations        // iterate over enclosed annotations        // for each, connect begin timeslot to either parent's begin or previous annots end        // connect end of last to parent's end        Tier parentTier = ((TierImpl) theTier).getParentTier();        if (parentTier != null) {            Vector parentAnnots = null;            parentAnnots = ((TierImpl) parentTier).getAnnotations();            Iterator parentIter = parentAnnots.iterator();            while (parentIter.hasNext()) {                AlignableAnnotation parent = (AlignableAnnotation) parentIter.next();                //Vector enclosedAnnots = ((TierImpl) theTier).getOverlappingAnnotations(                //	parent.getBegin().getTime(), parent.getEnd().getTime(), true);                Vector enclosedAnnots = ((TierImpl) theTier).getOverlappingAnnotations(parent.getBegin(),                        parent.getEnd());                Iterator annIter = enclosedAnnots.iterator();                AlignableAnnotation previousAnn = null;                while (annIter.hasNext()) {                    AlignableAnnotation a = (AlignableAnnotation) annIter.next();                    if (previousAnn == null) { // connect to parent's begin                        a.setBegin(parent.getBegin());                    } else { // connect end of previous to ann begin                        previousAnn.setEnd(a.getBegin());                    }                    previousAnn = a;                }                // connect last ann to end of parent                if (previousAnn != null) {                    previousAnn.setEnd(parent.getEnd());                }            }            TimeOrder timeOrder = ((TranscriptionImpl) (theTier.getParent())).getTimeOrder();            timeOrder.pruneTimeSlots();        }    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean supportsInsertion() {        return true;    }    /**     * DOCUMENT ME!     *     * @param beforeAnn DOCUMENT ME!     * @param theTier DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public Annotation insertBefore(Annotation beforeAnn, Tier theTier) {        AlignableAnnotation a = null;        AlignableAnnotation beforeA = (AlignableAnnotation) beforeAnn;        TimeOrder timeOrder = ((TranscriptionImpl) (theTier.getParent())).getTimeOrder();        TimeSlot newTs = new TimeSlotImpl(timeOrder);        timeOrder.insertTimeSlot(newTs, beforeA.getBegin(), beforeA.getEnd());        // check whether or not the tier supports graphical references        if (((TierImpl) theTier).getLinguisticType().hasGraphicReferences()) {            a = new SVGAlignableAnnotation(beforeA.getBegin(), newTs, theTier,                    null);        } else {            a = new AlignableAnnotation(beforeA.getBegin(), newTs, theTier);        }        //    beforeA.setBegin(newTs);        Annotation parentAnn = beforeAnn.getParentAnnotation();        Vector beginningAtTs = ((TranscriptionImpl) (theTier.getParent())).getAnnotsBeginningAtTimeSlot(beforeA.getBegin(),                theTier, true);        if (beginningAtTs.contains(parentAnn)) {            beginningAtTs.remove(parentAnn);        }        // HS jan 2005 only update annotations on the same tier or on depending tiers        Vector depTiers = ((TierImpl) theTier).getDependentTiers();        for (int i = 0; i < beginningAtTs.size(); i++) {            AlignableAnnotation other = (AlignableAnnotation) beginningAtTs.elementAt(i);            if ((other.getTier() == theTier) ||                    depTiers.contains(other.getTier())) {                other.setBegin(newTs);            }        }        ((TierImpl) theTier).addAnnotation(a);        return a;    }    /**     * DOCUMENT ME!     *     * @param afterAnn DOCUMENT ME!     * @param theTier DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public Annotation insertAfter(Annotation afterAnn, Tier theTier) {        AlignableAnnotation a = null;        AlignableAnnotation afterA = (AlignableAnnotation) afterAnn;        TimeOrder timeOrder = ((TranscriptionImpl) (theTier.getParent())).getTimeOrder();        TimeSlot newTs = new TimeSlotImpl(timeOrder);        // timeOrder.insertTimeSlot(newTs, afterA.getBegin(), afterA.getEnd());        // HS July 2006: insert after the highest aligned time slot on any of the dependent chikdren        TimeSlot highestATS = null;        Annotation loopA;        TimeSlot ts;        ArrayList pls = afterA.getParentListeners();        for (int i = 0; i < pls.size(); i++) {            loopA = (Annotation) pls.get(i);            if (loopA instanceof AlignableAnnotation) {                ts = ((AlignableAnnotation) loopA).getBegin();                if (ts.isTimeAligned()) {                    if ((highestATS == null) ||                            (ts.getTime() > highestATS.getTime())) {                        highestATS = ts;                    }                }            }        }        if (highestATS == null) {            timeOrder.insertTimeSlot(newTs, afterA.getBegin(), afterA.getEnd());        } else {            timeOrder.insertTimeSlot(newTs, highestATS, afterA.getEnd());        }        // check whether or not the tier supports graphical references        if (((TierImpl) theTier).getLinguisticType().hasGraphicReferences()) {            a = new SVGAlignableAnnotation(newTs, afterA.getEnd(), theTier, null);        } else {            a = new AlignableAnnotation(newTs, afterA.getEnd(), theTier);        }        //      afterA.setEnd(newTs);        Annotation parentAnn = afterAnn.getParentAnnotation();        Vector endingAtTs = ((TranscriptionImpl) (theTier.getParent())).getAnnotsEndingAtTimeSlot(afterA.getEnd(),                theTier, true);        if (endingAtTs.contains(parentAnn)) {            endingAtTs.remove(parentAnn);        }        // HS jan 2005 only update annotations on the same tier or on depending tiers        Vector depTiers = ((TierImpl) theTier).getDependentTiers();        for (int i = 0; i < endingAtTs.size(); i++) {            AlignableAnnotation other = (AlignableAnnotation) endingAtTs.elementAt(i);            if ((other.getTier() == theTier) ||                    depTiers.contains(other.getTier())) {                other.setEnd(newTs);            }        }        ((TierImpl) theTier).addAnnotation(a);        a.registerWithParent(); //HB, 18-5-04, only works after addAnnotation, newTS not used on any tier during construction        return a;    }    /**     * Detach annotation theAnn from tier theTier by reconnecting remaining     * Annotations on the tier. Assumes that all references and     * ParentAnnotationListener registrations are already cleaned up.     *     * @param theAnn DOCUMENT ME!     * @param theTier DOCUMENT ME!     */    public void detachAnnotation(Annotation theAnn, Tier theTier) {        // find all dependents on this tier for theAnn's parent.        // within this set, find theAnn's previous and next annotion, if they exist.        // finally, reconnect        AlignableAnnotation a = (AlignableAnnotation) theAnn; // cast is safe for case of NoTimeGapWithinParent        Annotation parent = a.getParentAnnotation();        //System.out.println("\ndetach: " + a.getValue());        Vector enclosedAnnots = new Vector();        Vector childAnnots = new Vector();        if (parent != null) {            //	enclosedAnnots = parent.getChildrenOnTier(theTier);            childAnnots = ((TranscriptionImpl) (theTier.getParent())).getChildAnnotationsOf(parent);        }        Iterator childIter = childAnnots.iterator();        while (childIter.hasNext()) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -