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

📄 exportresulttableaseaf.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        if ((transcription == null) || (nextTrans == null) ||                (topTiers == null)) {            return;        }        TierImpl tier;        ArrayList tiersToCopy = new ArrayList();        for (int i = 0; i < topTiers.size(); i++) {            tier = (TierImpl) topTiers.get(i);            tiersToCopy.add(tier);            tiersToCopy.addAll(tier.getDependentTiers());        }        ArrayList typesToCopy = new ArrayList();        ArrayList cvsToCopy = new ArrayList();        ControlledVocabulary cv;        String cvName;        for (int i = 0; i < tiersToCopy.size(); i++) {            tier = (TierImpl) tiersToCopy.get(i);            if (!typesToCopy.contains(tier.getLinguisticType())) {                typesToCopy.add(tier.getLinguisticType());                if (tier.getLinguisticType().isUsingControlledVocabulary()) {                    cvName = tier.getLinguisticType()                                 .getControlledVocabylaryName();                    cv = transcription.getControlledVocabulary(cvName);                    if ((cv != null) && !cvsToCopy.contains(cv)) {                        cvsToCopy.add(cv);                    }                }            }        }        // copy cv's        Vector cvc = new Vector(cvsToCopy.size());        ControlledVocabulary cv1;        ControlledVocabulary cv2;        CVEntry[] entries;        CVEntry ent1;        CVEntry ent2;        for (int i = 0; i < cvsToCopy.size(); i++) {            cv1 = (ControlledVocabulary) cvsToCopy.get(i);            cv2 = new ControlledVocabulary(cv1.getName(), cv1.getDescription());            entries = cv1.getEntries();            for (int j = 0; j < entries.length; j++) {                ent1 = entries[j];                ent2 = new CVEntry(ent1.getValue(), ent1.getDescription());                cv2.addEntry(ent2);            }            cvc.add(cv2);        }        nextTrans.setControlledVocabularies(cvc);        // copy ling types        Vector typc = new Vector(typesToCopy.size());        LinguisticType lt1;        LinguisticType lt2;        Constraint con1;        Constraint con2 = null;        for (int i = 0; i < typesToCopy.size(); i++) {            lt1 = (LinguisticType) typesToCopy.get(i);            lt2 = new LinguisticType(lt1.getLinguisticTypeName());            lt2.setTimeAlignable(lt1.isTimeAlignable());            lt2.setGraphicReferences(lt1.hasGraphicReferences());            lt2.setControlledVocabularyName(lt1.getControlledVocabylaryName());            con1 = lt1.getConstraints();            if (con1 != null) {                switch (con1.getStereoType()) {                case Constraint.TIME_SUBDIVISION:                    con2 = new TimeSubdivision();                    break;                case Constraint.SYMBOLIC_SUBDIVISION:                    con2 = new SymbolicSubdivision();                    break;                case Constraint.SYMBOLIC_ASSOCIATION:                    con2 = new SymbolicAssociation();                    break;                case Constraint.INCLUDED_IN:                    con2 = new IncludedIn();                }                lt2.addConstraint(con2);            }            typc.add(lt2);        }        nextTrans.setLinguisticTypes(typc);        // copy tiers        TierTree tree = new TierTree(transcription);        DefaultMutableTreeNode root = tree.getTree();        DefaultMutableTreeNode node;        TierImpl t1;        TierImpl t2;        TierImpl copyTier;        String name;        String parentName;        Enumeration en = root.breadthFirstEnumeration();        en.nextElement();        while (en.hasMoreElements()) {            copyTier = null; // reset            node = (DefaultMutableTreeNode) en.nextElement();            name = (String) node.getUserObject();            t1 = (TierImpl) transcription.getTierWithId(name);            if (!tiersToCopy.contains(t1)) {                continue;            }            if (t1 != null) {                lt1 = t1.getLinguisticType();                lt2 = nextTrans.getLinguisticTypeByName(lt1.getLinguisticTypeName());                if (lt2 != null) {                    if (t1.hasParentTier()) {                        parentName = t1.getParentTier().getName();                        t2 = (TierImpl) nextTrans.getTierWithId(parentName);                        if (t2 != null) {                            copyTier = new TierImpl(t2, name,                                    t1.getParticipant(), nextTrans, lt2);                            copyTier.setDefaultLocale(t1.getDefaultLocale());                            copyTier.setAnnotator(t1.getAnnotator());                        } else {                            LOG.warning("The parent tier: " + parentName +                                " for tier: " + name +                                " was not found in the destination transcription");                        }                    } else {                        copyTier = new TierImpl(name, t1.getParticipant(),                                nextTrans, lt2);                        copyTier.setDefaultLocale(t1.getDefaultLocale());                        copyTier.setAnnotator(t1.getAnnotator());                    }                } else {                    LOG.warning("Could not add tier: " + name +                        " because the Linguistic Type was not found in the destination transcription.");                }            }            if (copyTier != null) {                nextTrans.addTier(copyTier);            }        }        progressUpdate(null, 30);    }    /**     * Copies (toplevel) annotations and all depending annotations.     * @param transcription source transcription     * @param nextTrans destination transcription     * @param topAnnos the toplevel annotations     */    private void copyAnnotations(TranscriptionImpl transcription,        TranscriptionImpl nextTrans, ArrayList topAnnos) {        if ((transcription == null) || (nextTrans == null) ||                (topAnnos == null)) {            return;        }        // copy the annotations        AlignableAnnotation aa;        AlignableAnnotation copyAnn;        DefaultMutableTreeNode record;        int tp = 90 - 30;        float incr = (float) tp / Math.max(topAnnos.size(), 1); //prevent division by 0        for (int i = 0; i < topAnnos.size(); i++) {            aa = (AlignableAnnotation) topAnnos.get(i);            record = AnnotationRecreator.createTreeForAnnotation(aa);            copyAnn = (AlignableAnnotation) AnnotationRecreator.createAnnotationFromTree(nextTrans,                    record);            if (copyAnn == null) {                LOG.warning("Could not copy annotation: " + aa.getValue() +                    " (" + aa.getBeginTimeBoundary() + " - " +                    aa.getEndTimeBoundary() + ")");            }            progressUpdate(null, (30 + (int) (i * incr)));            if (isCancelled()) {                return;            }        }    }    /**     * Finds the root or toplevel annotation for the specified annotation.     * @param ann the annotation to find the root for     * @return the toplevel annotation     */    private AlignableAnnotation rootAnnotationOf(Annotation ann) {        if (ann == null) {            return null;        }        TierImpl tier = (TierImpl) ann.getTier();        if (tier.hasParentTier()) {            tier = tier.getRootTier();            return (AlignableAnnotation) tier.getAnnotationAtTime((ann.getBeginTimeBoundary() +                ann.getEndTimeBoundary()) / 2);        } else {            return (AlignableAnnotation) ann;        }    }    /**     * Prompt for a filename and location.     *     * @return a path as a string     */    private String promptForFileName() {        String exportDir = (String) Preferences.get("LastUsedEAFDir", null);        if (exportDir == null) {            exportDir = System.getProperty("user.dir");        }        JFileChooser chooser = new JFileChooser();        chooser.setCurrentDirectory(new File(exportDir));        chooser.setDialogTitle(ElanLocale.getString("SaveDialog.Title"));        File exportFile = null;        FileFilter filter = ElanFileFilter.createFileFilter(ElanFileFilter.EAF_TYPE);        chooser.setFileFilter(filter);        if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {            File curDir = chooser.getCurrentDirectory();            if (curDir != null) {                Preferences.set("LastUsedEAFDir", curDir.getAbsolutePath(), null);            }            exportFile = chooser.getSelectedFile();            if (exportFile != null) {                String name = exportFile.getAbsolutePath();                String lowerPathName = name.toLowerCase();                String[] exts = FileExtension.EAF_EXT;                boolean validExt = false;                for (int i = 0; i < exts.length; i++) {                    if (lowerPathName.endsWith("." + exts[i])) {                        validExt = true;                        break;                    }                }                if (!validExt) {                    name += ("." + exts[0]);                    exportFile = new File(name);                }                if (exportFile.exists()) {                    int answer = JOptionPane.showConfirmDialog(null,                            ElanLocale.getString("Message.Overwrite"),                            ElanLocale.getString("SaveDialog.Message.Title"),                            JOptionPane.YES_NO_OPTION);                    if (answer == JOptionPane.NO_OPTION) {                        return promptForFileName();                    } else {                        return name;                    }                } else {                    return name;                }            } else {                return null;            }        } else {            // save dialog canceled            return null;        }    }    /**     * Updates the progress bar and the message of the monitor.     * @param note the progress message     * @param progress the progress value     */    private void progressUpdate(String note, int progress) {        if (monitor != null) {            if (note != null) {                monitor.setNote(note);            }            monitor.setProgress(progress);        }    }    /**     * Checks whether the operation has been canceled via the progress monitor.     *     * @return true if the cancel button of the monitor has been clicked, false otherwise     */    private boolean isCancelled() {        if (monitor != null) {            return monitor.isCanceled();        }        return false;    }}

⌨️ 快捷键说明

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