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

📄 exportsmildialog.java

📁 编辑视频文件
💻 JAVA
字号:
/* * File:     ExportSmilDialog.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.export;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.Selection;import mpi.eudico.client.annotator.util.FileExtension;import mpi.eudico.client.util.CheckBoxTableCellRenderer;import mpi.eudico.client.util.EAF2SMIL;import mpi.eudico.server.corpora.clom.Transcription;import mpi.eudico.server.corpora.clomimpl.abstr.MediaDescriptor;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import java.awt.Frame;import java.awt.GridBagConstraints;import java.io.File;import java.io.IOException;import java.util.ArrayList;import java.util.List;import java.util.Vector;import javax.swing.DefaultCellEditor;import javax.swing.JCheckBox;import javax.swing.JOptionPane;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import javax.xml.transform.TransformerException;/** * DOCUMENT ME! * $Id: jalopy_gnu_src_dist.xml,v 1.3 2007/02/06 13:30:33 hasloe Exp $ * @author $Author: hasloe $ * @version $Revision: 1.3 $ */public class ExportSmilDialog extends AbstractTierExportDialog    implements ListSelectionListener {    /**    *    * @param parent    * @param modal    * @param transcription    * @param selection    */    public ExportSmilDialog(Frame parent, boolean modal,        Transcription transcription, Selection selection) {        super(parent, modal, transcription, selection);        this.makeLayout();        extractTiers();        postInit();    }    /**     * Initializes UI elements.     */    protected void makeLayout() {        super.makeLayout();        model.setColumnIdentifiers(new String[] { EXPORT_COLUMN, TIER_NAME_COLUMN });        tierTable.getColumn(EXPORT_COLUMN).setCellEditor(new DefaultCellEditor(                new JCheckBox()));        tierTable.getColumn(EXPORT_COLUMN).setCellRenderer(new CheckBoxTableCellRenderer());        tierTable.getColumn(EXPORT_COLUMN).setMaxWidth(30);        tierTable.setShowVerticalLines(false);        tierTable.setTableHeader(null);        tierTable.getSelectionModel().addListSelectionListener(this);        // options        GridBagConstraints gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 0;        //gridBagConstraints.gridwidth = 3;        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.anchor = GridBagConstraints.WEST;        gridBagConstraints.insets = insets;        optionsPanel.add(restrictCheckBox, gridBagConstraints);        updateLocale();    }    /**     * Extract candidate tiers for export.     */    protected void extractTiers() {        if (model != null) {            for (int i = model.getRowCount() - 1; i >= 0; i--) {                model.removeRow(i);            }            if (transcription != null) {                Vector v = transcription.getTiers();                TierImpl t;                for (int i = 0; i < v.size(); i++) {                    t = (TierImpl) v.get(i);                    // add all                    if (i == 0) {                        model.addRow(new Object[] { Boolean.TRUE, t.getName() });                    } else {                        model.addRow(new Object[] { Boolean.FALSE, t.getName() });                    }                }            }        }    }    /**     * @see mpi.eudico.client.annotator.export.AbstractTierExportDialog#updateLocale()     */    protected void updateLocale() {        super.updateLocale();        setTitle(ElanLocale.getString("ExportSmilDialog.Title"));        titleLabel.setText(ElanLocale.getString("ExportSmilDialog.TitleLabel"));    }    /**     * @see mpi.eudico.client.annotator.export.AbstractTierExportDialog#startExport()     */    protected boolean startExport() throws IOException {        List selectedTiers = getSelectedTiers();        if (selectedTiers.size() == 0) {            JOptionPane.showMessageDialog(this,                ElanLocale.getString("ExportTradTranscript.Message.NoTiers"),                ElanLocale.getString("Message.Warning"),                JOptionPane.WARNING_MESSAGE);            return false;        }        // prompt for file name and location        File exportFile = promptForFile(ElanLocale.getString(                    "Export.TigerDialog.title"), FileExtension.SMIL_EXT);        if (exportFile == null) {            return false;        }        // export....        String[] tierNames = (String[]) selectedTiers.toArray(new String[] {  });        String mediaURL = "";        if (((TranscriptionImpl) transcription).getMediaDescriptors().size() > 0) {            mediaURL = ((MediaDescriptor) ((TranscriptionImpl) transcription).getMediaDescriptors()                                           .get(0)).mediaURL;        }        try {            if ((selection != null) && restrictCheckBox.isSelected()) {                EAF2SMIL.export2SMIL(new File(                        ((TranscriptionImpl) transcription).getPathName()),                    exportFile, tierNames, mediaURL, selection.getBeginTime(),                    selection.getEndTime());            } else {                EAF2SMIL.export2SMIL(new File(                        ((TranscriptionImpl) transcription).getPathName()),                    exportFile, tierNames, mediaURL);            }        } catch (TransformerException te) {            // this is ugly            throw new IOException("TransformerException: " + te.getMessage());        }        return true;    }    /**     * Updates the checked state of the export checkboxes.     *     * @param lse the list selection event     */    public void valueChanged(ListSelectionEvent lse) {        if ((model != null) && lse.getValueIsAdjusting()) {            int b = lse.getFirstIndex();            int e = lse.getLastIndex();            int col = model.findColumn(EXPORT_COLUMN);            for (int i = b; i <= e; i++) {                if (tierTable.isRowSelected(i)) {                    model.setValueAt(Boolean.TRUE, i, col);                }            }        }    }}

⌨️ 快捷键说明

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