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

📄 transcriptionimpl.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            Iterator tierIter = tiers.iterator();            while (tierIter.hasNext()) {                TierImpl t = (TierImpl) tierIter.next();                //if (t.getParentTier() == theAnnot.getTier()) {                if (t.hasAncestor(theAnnot.getTier())) {                    descTiers.add(t);                }            }            // on these descendant tiers, check all annots if they have theAnnot as parent            Iterator descTierIter = descTiers.iterator();            while (descTierIter.hasNext()) {                TierImpl descT = (TierImpl) descTierIter.next();                Iterator annIter = descT.getAnnotations().iterator();                while (annIter.hasNext()) {                    Annotation a = (Annotation) annIter.next();                    if (a instanceof RefAnnotation) {                        // HS 29 jul 04: added test on the size of the Vector to prevent                         // NoSuchElementException                        if ((((RefAnnotation) a).getReferences().size() > 0) &&                                (((RefAnnotation) a).getReferences()                                      .firstElement() == theAnnot)) {                            children.add(a);                        }                    } else if (a instanceof AlignableAnnotation) {                        if (connAnnotVector.contains(a)) {                            children.add(a);                        } else if (descT.getLinguisticType().getConstraints()                                            .getStereoType() == Constraint.INCLUDED_IN) {                            // feb 2006: special case for Included_In tier, child annotations are not                             // found in the graph tree, test overlap, or more precise inclusion                            /*                            if (a.getBeginTimeBoundary() >= theAnnot.getBeginTimeBoundary() &&                                    a.getEndTimeBoundary() <= theAnnot.getEndTimeBoundary()) {                                children.add(a);                            }                            */                            // return overlapping instead of included annotations                            if ((a.getBeginTimeBoundary() < theAnnot.getEndTimeBoundary()) &&                                    (a.getEndTimeBoundary() > theAnnot.getBeginTimeBoundary())) {                                children.add(a);                            }                            if (a.getBeginTimeBoundary() > theAnnot.getEndTimeBoundary()) {                                break;                            }                        }                    }                }            }        }        return children;    }    /**     * Annotation based variant of the graph based getConnectedAnnots(TreeSet, TreeSet, TimeSlot).     * Annotations on "Included_In" tiers are not discovered in the graph based way.     *     * @param connectedAnnots storage for annotations found     * @param connectedTimeSlots storage for slots found     * @param fromAnn the parent annotation     */    public void getConnectedAnnots(TreeSet connectedAnnots,        TreeSet connectedTimeSlots, AlignableAnnotation fromAnn) {        // first get the annotations and slots, graph based        getConnectedAnnots(connectedAnnots, connectedTimeSlots,            fromAnn.getBegin());        // then find Included_In dependent tiers        TierImpl t = (TierImpl) fromAnn.getTier();        Vector depTiers = t.getDependentTiers();        Iterator dtIt = depTiers.iterator();        TierImpl tt;        Vector anns;        while (dtIt.hasNext()) {            tt = (TierImpl) dtIt.next();            if (tt.getLinguisticType().getConstraints().getStereoType() == Constraint.INCLUDED_IN) {                //anns = tt.getOverlappingAnnotations(fromAnn.getBeginTimeBoundary(), fromAnn.getEndTimeBoundary());                anns = tt.getAnnotations();                AlignableAnnotation aa;                ;                Iterator anIt = anns.iterator(); // iterations over all annotations on the tier...                while (anIt.hasNext()) {                    aa = (AlignableAnnotation) anIt.next();                    if (fromAnn.isAncestorOf(aa)) {                        getConnectedAnnots(connectedAnnots, connectedTimeSlots,                            aa);                    }                    //getConnectedAnnots(connectedAnnots, connectedTimeSlots,                     //        ((AlignableAnnotation) anIt.next()).getBegin());                }            }        }    }    /**     * DOCUMENT ME!     *     * @param connectedAnnots DOCUMENT ME!     * @param connectedTimeSlots DOCUMENT ME!     * @param startingFromTimeSlot DOCUMENT ME!     */    public void getConnectedAnnots(TreeSet connectedAnnots,        TreeSet connectedTimeSlots, TimeSlot startingFromTimeSlot) {        Vector annots = null;        connectedTimeSlots.add(startingFromTimeSlot);        // annots = getAnnotsBeginningAtTimeSlot(startingFromTimeSlot);        annots = getAnnotationsUsingTimeSlot(startingFromTimeSlot);        if (annots != null) {            //connectedAnnots.addAll(annots);            Iterator aIter = annots.iterator();            while (aIter.hasNext()) {                AlignableAnnotation aa = (AlignableAnnotation) aIter.next();                boolean added = connectedAnnots.add(aa);                if (!added) {                    continue;                }                if (!connectedTimeSlots.contains(aa.getBegin())) {                    getConnectedAnnots(connectedAnnots, connectedTimeSlots,                        aa.getBegin());                }                if (!connectedTimeSlots.contains(aa.getEnd())) {                    getConnectedAnnots(connectedAnnots, connectedTimeSlots,                        aa.getEnd());                }            }        }    }    /**     * Find all annotations part of the (sub) graph, time slot based.     * HS mar 06: the top level tier for the search can be specified to prevent     * iterations over unrelated tiers.     *     * @param connectedAnnots TreeSet to add found annotations to (in/out)     * @param startingFromTimeSlot begin time slot of the subtree     * @param stopTimeSlot end time slot of the sub tree     * @param topTier the top level tier for the subtree search (can be a dependent tier though)     * @return true when the end time slot has been reached, false otherwise     */    public boolean getConnectedSubtree(TreeSet connectedAnnots,        TimeSlot startingFromTimeSlot, TimeSlot stopTimeSlot, Tier topTier) {        Vector annots = null;        boolean endFound = false;        if (topTier == null) {            annots = getAnnotsBeginningAtTimeSlot(startingFromTimeSlot);        } else {            annots = getAnnotsBeginningAtTimeSlot(startingFromTimeSlot,                    topTier, true);        }        if (annots != null) {            Iterator aIter = annots.iterator();            while (aIter.hasNext()) {                AlignableAnnotation aa = (AlignableAnnotation) aIter.next();                if (aa.getEnd() != stopTimeSlot) {                    //endFound = getConnectedSubtree(connectedAnnots, aa.getEnd(), stopTimeSlot, topTier);                    endFound = getConnectedSubtree(connectedAnnots,                            aa.getEnd(), stopTimeSlot, aa.getTier());                    if (endFound) {                        connectedAnnots.add(aa);                    }                } else {                    endFound = true;                    connectedAnnots.add(aa);                }            }        }        return endFound;    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean eachRootHasSubdiv() {        boolean eachRootHasSubdiv = true;        Vector topTiers = getTopTiers();        Iterator tierIter = topTiers.iterator();        while (tierIter.hasNext()) {            TierImpl t = (TierImpl) tierIter.next();            Vector annots = t.getAnnotations();            Iterator aIter = annots.iterator();            while (aIter.hasNext()) {                AbstractAnnotation a = (AbstractAnnotation) aIter.next();                ArrayList children = a.getParentListeners();                if ((children == null) || (children.size() == 0)) {                    return false;                } else {                    boolean subdivFound = false;                    Iterator childIter = children.iterator();                    while (childIter.hasNext()) {                        AbstractAnnotation ch = (AbstractAnnotation) childIter.next();                        Constraint constraint = ((TierImpl) ch.getTier()).getLinguisticType()                                                 .getConstraints();                        if ((constraint.getStereoType() == Constraint.SYMBOLIC_SUBDIVISION) ||                                (constraint.getStereoType() == Constraint.TIME_SUBDIVISION)) {                            subdivFound = true;                            break;                        }                    }                    if (!subdivFound) {                        return false;                    }                }            }        }        return eachRootHasSubdiv;    }    /**     * Returns whether any modifications are made since the last reset (when saving)     */    public boolean isChanged() {        return changed;    }    /**     * Resets 'changed' status to unchanged     */    public void setUnchanged() {        changed = false;    }    /**     * Sets 'changed' status to changed     */    public void setChanged() {        changed = true;    }    /**     * Returns time Change Propagation Mode (normal, bulldozer or shift)     *     * @author hennie     */    public int getTimeChangePropagationMode() {        return timeChangePropagationMode;    }    /**     * Set Time Change Propagation Mode (normal, bulldozer or shift)     * @author hennie     */    public void setTimeChangePropagationMode(int theMode) {        timeChangePropagationMode = theMode;    }    /**     * Propagate time changes by shifting all next annotations to later times,     * maintaining gaps. Algorithm: shift all time slots after end of fixedAnnotation     * over distance newEnd minus oldEnd.     *     * @param fixedAnnotation the source annotation     * @param fixedSlots slots connected to the source annotation that should not be shifted     * @param oldBegin the old begin time of the annotation     * @param oldEnd the old end time of the annotation     */    public void correctOverlapsByShifting(AlignableAnnotation fixedAnnotation,        Vector fixedSlots, long oldBegin, long oldEnd) {        long newEnd = fixedAnnotation.getEnd().getTime();        // right shift        if (newEnd > oldEnd) { // implies that end is time aligned            long shift = newEnd - oldEnd;            getTimeOrder().shift(oldEnd, shift, fixedAnnotation.getEnd(),                fixedSlots);        }    }    /**     * Propagate time changes by shifting time slots.<br>     * <b>Note: </b> this method is intended only to be used to     * reverse the effects of an earlier call to <code>correctOverlapsByShifting     * </code>, as in an undo operation!     *     * @see #correctOverlapsByShifting(AlignableAnnotation, long, long)     * @param from starting point for shifting     * @param amount the distance to shift the timeslots     */    public void shiftBackward(long from, long amount) {        if (amount < 0) {            getTimeOrder().shift(from, amount, null, null);            // let listeners know the whole transcription             // could be changed            modified(ACMEditEvent.CHANGE_ANNOTATIONS, null);        }    }    /**     * Shifts all aligned timeslots with the specified amount of ms.<br>     * When an attempt is made to shift slots such that one or more slots     * would have a negative time value an exception is thrown.     * Slots (and annotations) will never implicitely be deleted.     * The shift operation is delegated to th TimeOrder object.     *     * @param shiftValue the number of ms to add to the time value of aligned timeslots,     *    can be less than zero     * @throws IllegalArgumentException when the shift value is such that any aligned     *    slot would get a negative time value     */    public void shiftAllAnnotations(long shiftValue)        throws IllegalArgumentException {        timeOrder.shiftAll(shiftValue);        // notify        modified(ACMEditEvent.CHANGE_ANNOTATIONS, null);    }    /**         * Markus Note: THE ARGUEMENT IS IGNORED         * HS aug 2005: MediaObject not used at all in TranscriptionImpl,         * but still in some extending classes.         *         * @param mediaFileName DOCUMENT ME!         *         * @return DOCUMENT ME!         */    /*    public MediaObject createMediaObject(String mediaFileName) {        // Markus note: the easiest way to ignore the argument:        // HS feb 2005 old MediaObject stuff should be removed...        //mediaFileName = this.mediafileName;        // System.out.println(" createDobesMediaObject: "+     mediaFileName);        MediaObject mediaObject = null;        if (mediaFileName != null) {            File f = new File(mediaFileName);            if (f.exists()) {                mediaObject = new MediaObjectImpl(mediaFileName, 0, null,                        "file:" + mediaFileName);            } else {                mediaObject = null;            }        }        return mediaObject;    }    */    /**         * Returns all Tiers from this Transcription.         *         * @return DOCUMENT ME!         */    public Vector getTiers() {        if (!isLoaded()) {            //			(new MinimalTranscriptionStore()).loadTranscription(this, identity);            (new ACM24TranscriptionStore()).loadTranscription(this, null);        }        return tiers;    }    /**         * This ToolAdministrator must be able to answer quetions regarding its         * condition.         *         * @param condition the Condition that must be checked.         *         * @return DOCUMENT ME!         */    public boolean checkToolCondition(ToolCondition condition) {        // HIER MOET EEN GOEDE TEST KOMEN VOOR AANWEZIGHEID VAN MEDIA DATA        // WAARSCHIJNLIJK IS HET HET BESTE ALS ER EEN TOOL KOMT DIE ALTIJD        // GESTART KAN WORDEN MAAR PAS VRAAGT OM MEDIA DATA ALS DIE NODIG IS.        return true;    }    /**         * Check if an Object is equal to this Transcription. For DOBES equality is         * true if the names of two Transcriptions are the same.         *         * @param obj DOCUMENT ME!         *         * @return DOCUMENT ME!         */    public boolean equals(Object obj) {        if (obj instanceof TranscriptionImpl &&                (((TranscriptionImpl) obj).getName() == name)) {            return true;        }        return false;    }    /**         * DOCUMENT ME!         *         * @param identity DOCUMENT ME!         */    public void loadTags() {        loadAnnotations();    }

⌨️ 快捷键说明

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