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

📄 changetierattributescommand.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * File:     ChangeTierAttributesCommand.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.client.annotator.commands;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.gui.IndeterminateProgressMonitor;import mpi.eudico.client.annotator.util.AnnotationRecreator;import mpi.eudico.server.corpora.clom.Tier;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.type.LinguisticType;import java.awt.Cursor;import java.util.ArrayList;import java.util.Iterator;import java.util.Locale;import java.util.Vector;/** * A Command to change tier attributes. * * @author HB, HS * @version 1.0 */public class ChangeTierAttributesCommand implements UndoableCommand {    private String commandName;    // old state    private String oldTierName;    private String oldParticipant;    private String oldAnnotator;    private Locale oldLocale;    private LinguisticType oldLingType;    private Tier oldParentTier;    // new state    private String tierName;    private Tier parentTier;    private String lingTypeName;    private LinguisticType lingType;    private String participant;    private String annotator;    private Locale locale;    // receiver    private TierImpl tier;    private TranscriptionImpl transcription;    //private ArrayList annotationsNodes;    // an ArrayList of SVGAnnotationDataRecord objects    /** Holds value of property DOCUMENT ME! */    ArrayList storedGraphicsData;    /**     * Creates a new ChangeTierAttributesCommand instance     *     * @param theName the name of the command     */    public ChangeTierAttributesCommand(String theName) {        commandName = theName;    }    /**     * <b>Note: </b>it is assumed the types and order of the arguments are     * correct.     *     * @param receiver the Tier     * @param arguments the arguments:  <ul><li>arg[0] = the tier name     *        (String)</li> <li>arg[1] = the parent tier (Tier)</li>     *        <li>arg[2] = the linguistic type (String)</li> <li>arg[3] = the     *        participant (String)</li> <li>arg[4] =  the annotator     *        (String)</li> <li>arg[5] =  the default language     *        (Locale)</li> </ul>     */    public void execute(Object receiver, Object[] arguments) {        // receiver is Tier        tier = (TierImpl) receiver;        transcription = (TranscriptionImpl) tier.getParent();        // arguments, store for redo        tierName = (String) arguments[0];        parentTier = (Tier) arguments[1];        lingTypeName = (String) arguments[2];        participant = (String) arguments[3];        annotator = (String) arguments[4];        locale = (Locale) arguments[5];        if (tier != null) {            setWaitCursor(true);            try {                oldTierName = tier.getName();                oldParticipant = tier.getParticipant();                oldLocale = tier.getDefaultLocale();                oldLingType = tier.getLinguisticType();                oldParentTier = (TierImpl) tier.getParentTier();                oldAnnotator = tier.getAnnotator();                // first back up the annotations if necessary                // HS sep-04                 // as long as there is no proper mechanism of updating                  // existing annotations, changes that can effect data integrity                 // are prevented in the change tier dialog                /*                   if ((parentTier != oldParentTier) ||                           !oldLingType.getLinguisticTypeName().equals(lingTypeName)) {                       annotationsNodes = new ArrayList();                       Vector annos = tier.getAnnotations(null);                       Iterator anIter = annos.iterator();                       AbstractAnnotation ann;                       while (anIter.hasNext()) {                           ann = (AbstractAnnotation) anIter.next();                           annotationsNodes.add(AnnotationRecreator.createTreeForAnnotation(                                   ann));                       }                   }                 */                if (!tierName.equals(oldTierName)) {                    // assumes there has been a check on the uniqueness of the name                     tier.setName(tierName);                }                if (parentTier != oldParentTier) {                    tier.setParentTier(parentTier);                }                if (!participant.equals(oldParticipant)) {                    tier.setParticipant(participant);                }                if (!annotator.equals(oldAnnotator)) {                    tier.setAnnotator(annotator);                }                if (locale != oldLocale) {                    tier.setDefaultLocale(locale);                }                if ((oldLingType == null) ||                        (lingTypeName != oldLingType.getLinguisticTypeName())) {                    Vector types = ((Transcription) (tier.getParent())).getLinguisticTypes();                    LinguisticType t = null;                    Iterator typeIter = types.iterator();                    while (typeIter.hasNext()) {                        t = (LinguisticType) typeIter.next();                        if (t.getLinguisticTypeName().equals(lingTypeName)) {                            break;                        }                    }                    if (t != null) {                        lingType = t;                        tier.setLinguisticType(lingType);                        if (oldLingType.hasGraphicReferences() != lingType.hasGraphicReferences()) {                            // convert AlignableAnnotations to SVGAlignableAnnotations or vice versa                            if (oldLingType.hasGraphicReferences()) {                                new ConversionThread(transcription, tier).start(true);                            } else {                                new ConversionThread(transcription, tier).start();                            }                        }                    }                }            } catch (Exception ex) {                ex.printStackTrace();                setWaitCursor(false);            }            setWaitCursor(false);        }    }    /**     * The undo action.     */    public void undo() {        if (tier != null) {            try {                if ((tierName != null) && (!tierName.equals(oldTierName))) {                    tier.setName(oldTierName);                }                if (parentTier != oldParentTier) {                    tier.setParentTier(oldParentTier);                }                tier.setLinguisticType(oldLingType);                if ((participant != null) &&                        (!participant.equals(oldParticipant))) {                    tier.setParticipant(oldParticipant);

⌨️ 快捷键说明

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