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

📄 transcriptionimpl.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * File:     TranscriptionImpl.java * Project:  MPI Linguistic Application * Date:     02 May 2007 * * Copyright (C) 2001-2007  Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package mpi.eudico.server.corpora.clomimpl.abstr;import mpi.eudico.server.corpora.clom.Annotation;import mpi.eudico.server.corpora.clom.DecoderInfo;import mpi.eudico.server.corpora.clom.MediaObject;import mpi.eudico.server.corpora.clom.MetaTime;import mpi.eudico.server.corpora.clom.Property;import mpi.eudico.server.corpora.clom.Tier;import mpi.eudico.server.corpora.clom.TimeOrder;import mpi.eudico.server.corpora.clom.TimeSlot;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clomimpl.dobes.ACM24TranscriptionStore;import mpi.eudico.server.corpora.clomimpl.type.Constraint;import mpi.eudico.server.corpora.clomimpl.type.LinguisticType;import mpi.eudico.server.corpora.location.LocatorManager;import mpi.eudico.server.corpora.util.ACMEditEvent;import mpi.eudico.server.corpora.util.ACMEditListener;import mpi.eudico.server.corpora.util.ACMEditableObject;import mpi.eudico.server.corpora.util.DataTreeNode;import mpi.eudico.tool.ToolCondition;import mpi.util.ControlledVocabulary;import java.io.File;import java.io.InputStream;import java.net.URL;import java.util.ArrayList;import java.util.Arrays;import java.util.Enumeration;import java.util.HashSet;import java.util.Iterator;import java.util.TreeSet;import java.util.Vector;/** * TranscriptionImpl implements Transcription. * * @author Hennie Brugman * @author Albert Russel * @version 22-Jun-1999 * * */// modified Daan Broeder 23-10-2000// added url atribute + getFullPath() method// added url parameter to constructor//public class TranscriptionImpl implements Transcription {    /** Holds value of property DOCUMENT ME! */    public static final String UNDEFINED_FILE_NAME = "aishug294879ryshfda9763afo8947a5gf";    private ArrayList listeners;    /**     * The list of Tiers in this Transcription.     */    protected Vector tiers;    /**     * The media file or stream associated with this Transcription     * - deprecated since ELAN 2.0     */    protected MediaObject mediaObject;    /**     * Descriptors for the media files or streams associated with this Transcription     */    protected Vector mediaDescriptors;    /**     * Descriptors for secondary associated files. I.e. non-audio/video files, or files     * representing sources that are not a primary subject of transcription.     */    protected Vector linkedFileDescriptors;    /**     * The url of the transcription (if applicable)     */    protected String url;    /**     * The content type of the transcription (if applicable)     * default impl. is "text/plain"     */    protected String content_type = "text/plain";    /**     * Transcription name     */    protected String name;    /** Holds value of property DOCUMENT ME! */    protected String owner;    private DataTreeNode parent; // back reference, used for deletion of Transcriptions    /** Holds value of property DOCUMENT ME! */    protected LocatorManager locatorManager;    /** Holds value of property DOCUMENT ME! */    protected MetaTime metaTime;    /** Holds value of property DOCUMENT ME! */    protected TimeOrder timeOrder;    /** Holds value of property DOCUMENT ME! */    protected Vector linguisticTypes; // contains id strings for all types    /** Holds value of property DOCUMENT ME! */    protected String author;    /** Holds value of property DOCUMENT ME! */    protected boolean isLoaded;    private boolean changed = false;    private int timeChangePropagationMode = Transcription.NORMAL;    private TimeProposer timeProposer;    /**     * Holds associated ControlledVocabulary objects.     * @since jun 04     */    protected Vector controlledVocabularies;    private ArrayList docProperties;    /**     * A flag to temporarily turn of unnecessary notification of ACMEditListeners,     * e.g. when a number of modifications is performed in a batch.     * @since oct 04     */    protected boolean isNotifying;    /** Holds value of property DOCUMENT ME! */    protected String fileName;    /** Holds value of property DOCUMENT ME! */    protected String mediafileName;    /** Holds value of property DOCUMENT ME! */    protected String svgFile;    /**     * New constructor for unknown file name     */    public TranscriptionImpl() {        this(UNDEFINED_FILE_NAME);    }    /**     * New constructor with only the full file path     *     * @param eafFilePath DOCUMENT ME!     */    public TranscriptionImpl(String eafFilePath) {        this(eafFilePath.substring(eafFilePath.lastIndexOf(System.getProperty(                        "file.separator")) + 1), null, null,            "file:" + eafFilePath);        initialize(eafFilePath.substring(eafFilePath.lastIndexOf(                    System.getProperty("file.separator")) + 1), eafFilePath,            null);    }    /**     * Constructor with the full source file path and an additional info object for the decoder/parser.     *     * @param sourceFilePath the full path to the source file     * @param decoderInfo the info object for the parser     */    public TranscriptionImpl(String sourceFilePath, DecoderInfo decoderInfo) {        this(sourceFilePath.substring(sourceFilePath.lastIndexOf(                    System.getProperty("file.separator")) + 1), null, null,            "file:" + sourceFilePath);        initialize(sourceFilePath.substring(sourceFilePath.lastIndexOf(                    System.getProperty("file.separator")) + 1), sourceFilePath,            decoderInfo);    }    /**     * MK:02/06/19     * @param myURL unclear, hack from Dobes or Chat, often set null.     */    public TranscriptionImpl(String theName, DataTreeNode theParent,        LocatorManager theLocatorManager, String myURL) {        name = theName;        parent = theParent;        url = myURL;        locatorManager = theLocatorManager;        tiers = new Vector();        metaTime = new FastMetaTime();        listeners = new ArrayList();        timeOrder = new TimeOrderImpl(this);        linguisticTypes = new Vector();        mediaDescriptors = new Vector();        linkedFileDescriptors = new Vector();        controlledVocabularies = new Vector();        docProperties = new ArrayList(5);        isLoaded = false;        isNotifying = true;        timeProposer = new TimeProposer();    }    /**     * DOCUMENT ME!     *     * @param l DOCUMENT ME!     */    public void addACMEditListener(ACMEditListener l) {        if (!listeners.contains(l)) {            listeners.add(l);        }    }    /**     * DOCUMENT ME!     *     * @param l DOCUMENT ME!     */    public void removeACMEditListener(ACMEditListener l) {        listeners.remove(l);    }    /**     * DOCUMENT ME!     *     * @param source DOCUMENT ME!     * @param operation DOCUMENT ME!     * @param modification DOCUMENT ME!     */    public void notifyListeners(ACMEditableObject source, int operation,        Object modification) {        Iterator i = listeners.iterator();        ACMEditEvent event = new ACMEditEvent(source, operation, modification);        while (i.hasNext()) {            ((ACMEditListener) i.next()).ACMEdited(event);        }    }    /**     * DOCUMENT ME!     *     * @param operation DOCUMENT ME!     * @param modification DOCUMENT ME!     */    public void modified(int operation, Object modification) {        handleModification(this, operation, modification);    }    /**     * DOCUMENT ME!     *     * @param source DOCUMENT ME!     * @param operation DOCUMENT ME!     * @param modification DOCUMENT ME!     */    public void handleModification(ACMEditableObject source, int operation,        Object modification) {        if (changed == false) {            changed = true;        }        timeProposer.correctProposedTimes(this, source, operation, modification);        if (isNotifying) {            notifyListeners(source, operation, modification);        }    }    /**     * Sets the notification flag.     * When set to false ACMEditListeners are no longer notified of modification.     * When set to true listeners are notified of an CHANGE_ANNOTATIONS     * ACMEditEvent. Every modification will then be followed by a notification.     *     * @param notify the new notification flag     */    public void setNotifying(boolean notify) {        isNotifying = notify;        if (isNotifying) {            modified(ACMEditEvent.CHANGE_ANNOTATIONS, null);        }    }    /**     * Returns the notifying flag.     * @return true when ACMEditListeners are notified of every modification,     *     false otherwise     */    public boolean isNotifying() {        return isNotifying;    }    /**     * @param name HAS TO BE THE SAME AS THE XML NAME PREFIX     * @param fileName the absolute path of the XML transcription file.     * @param decoderInfo decoder info object for certain file types(Toolbox, Transcriber etc)     */    private void initialize(String name, String fileName,        DecoderInfo decoderInfo) {        if (fileName.startsWith("file:")) {            fileName = fileName.substring(5);        }        author = ""; // make sure that it is initialized to empty string        File fff = new File(fileName);        if (!fff.exists()) {            isLoaded = true; // prevent loading        } else {            isLoaded = false;        }        this.fileName = fileName;        // we don't know if it's wav or mpg or mov. We have to try.        String mimeType = "";        this.mediafileName = null;        // try mpg first!        // replace *.??? by *.mpg        if (this.mediafileName == null) {            String test = this.fileName.substring(0, this.fileName.length() -                    3) + "mpg";            if (test.startsWith("file:")) {                test = test.substring(5);            }            if ((new File(test)).exists()) {                this.mediafileName = test;                mimeType = MediaDescriptor.MPG_MIME_TYPE;            }        }        // replace *.??? by *.wav        if (this.mediafileName == null) {            String test = this.fileName.substring(0, this.fileName.length() -                    3) + "wav";            if (test.startsWith("file:")) {                test = test.substring(5);            }            if ((new File(test)).exists()) {                this.mediafileName = test;                mimeType = MediaDescriptor.WAV_MIME_TYPE;            }        }        // HS 21-11-2001 mov added        // replace *.??? by *.mov        if (this.mediafileName == null) {            String test = this.fileName.substring(0, this.fileName.length() -                    3) + "mov";            if (test.startsWith("file:")) {                test = test.substring(5);            }            if ((new File(test)).exists()) {                this.mediafileName = test;            }        }        // media object is not used anymore        //this.mediaObject = createMediaObject(this.mediafileName);        // HB, 3 dec 03. After this, media descriptors are instantiated, if in the EAF file        if (!isLoaded()) {            (new ACM24TranscriptionStore()).loadTranscription(this, decoderInfo);            // jul 2005: make sure the proposed times are precalculated            timeProposer.correctProposedTimes(this, null,                ACMEditEvent.CHANGE_ANNOTATIONS, null);        }        // if no media descriptors, and mediafileName is not null, create media descriptors        if ((mediaDescriptors.size() == 0) && (mediafileName != null) &&                (mediafileName.length() > 0)) {            String mediaURL = pathToURLString(mediafileName);            //		String mediaURL = "file:///" + mediafileName;            //		mediaURL = mediaURL.replace('\\', '/');            MediaDescriptor masterMD = new MediaDescriptor(mediaURL, mimeType);            mediaDescriptors.add(masterMD);            String checkFile = this.fileName.substring(0,                    this.fileName.length() - 3) + "wav";            if (checkFile.startsWith("file:")) {                checkFile = checkFile.substring(5);            }            if ((new File(checkFile)).exists()) {                String signalURL = pathToURLString(checkFile);                //			String signalURL = "file:///" + checkFile;                //			signalURL = signalURL.replace('\\', '/');                mimeType = MediaDescriptor.WAV_MIME_TYPE;                MediaDescriptor signalMD = new MediaDescriptor(signalURL,                        mimeType);                signalMD.extractedFrom = mediaURL;                mediaDescriptors.add(signalMD);            }        }        // in ELAN versions < 2.7 the .svg file was not referred to in the eaf

⌨️ 快捷键说明

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