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

📄 segmentationdialog.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * File:     SegmentationDialog.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.gui;import mpi.eudico.client.annotator.Constants;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.Preferences;import mpi.eudico.client.annotator.commands.Command;import mpi.eudico.client.annotator.commands.ELANCommandFactory;import mpi.eudico.client.annotator.player.*;import mpi.eudico.client.annotator.viewer.SegmentationViewer;import mpi.eudico.client.mediacontrol.ControllerEvent;import mpi.eudico.client.mediacontrol.ControllerListener;import mpi.eudico.client.mediacontrol.StartEvent;import mpi.eudico.client.mediacontrol.StopEvent;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.util.TimeInterval;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Insets;import java.awt.Rectangle;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.KeyEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.util.ArrayList;import java.util.Iterator;import java.util.Vector;import javax.swing.AbstractAction;import javax.swing.Action;import javax.swing.ActionMap;import javax.swing.ButtonGroup;import javax.swing.ComponentInputMap;import javax.swing.InputMap;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JComponent;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.KeyStroke;import javax.swing.WindowConstants;import javax.swing.border.LineBorder;import javax.swing.border.TitledBorder;/** * A dialog for convenient batch-like creation of annotations/segmentation. * * @author Han Sloetjes * @version Aug 2005 Identity removed */public class SegmentationDialog extends ClosableDialog implements ActionListener,    ItemListener, ControllerListener {    private JComboBox tierComboBox;    private JLabel keyLabel;    private JLabel titleLabel;    private JPanel titlePanel;    private JLabel tierLabel;    private JRadioButton oneClickRB;    private JRadioButton twoClicksRB;    private ButtonGroup optionButtonGroup;    private JPanel tierSelectionPanel;    private JPanel tierPreviewPanel;    private JPanel controlPanel;    private JButton applyButton;    private JButton closeButton;    private JPanel buttonPanel;    private TranscriptionImpl transcription;    private ElanMediaPlayer player;    /** no selection */    private final String EMPTY = "-";    /**     * every time the enter key is typed either a begin or an end time is added     */    private final int TWO_TIMES_SEGMENTATION = 0;    /** every time the enter key is typed an end and a begin are added */    private final int ONE_TIME_SEGMENTTATION = 1;    // administration    private ArrayList timeSegments;    private String curTier;    // default mode is the two-times-segmentation mode    private int mode = TWO_TIMES_SEGMENTATION;    private long lastSegmentTime = -1;    private int timeCount = 0;    private SegmentationViewer previewer;    /**     * Creates a new SegmentationDialog instance     *     * @param transcription the transcription     */    public SegmentationDialog(Transcription transcription) {        super(ELANCommandFactory.getRootFrame(transcription), true);        this.transcription = (TranscriptionImpl) transcription;        player = ELANCommandFactory.getViewerManager(transcription)                                   .getMasterMediaPlayer();        previewer = ELANCommandFactory.getViewerManager(transcription)                                      .createSegmentationViewer();        timeSegments = new ArrayList();        initComponents();        extractRootTiers();        postInit();    }    /**     * Extract the root tiers as candidates for auto segmentation.     */    private void extractRootTiers() {        if (transcription != null) {            Vector tiers = transcription.getTiers();            Iterator tierIt = tiers.iterator();            TierImpl tier = null;            while (tierIt.hasNext()) {                tier = (TierImpl) tierIt.next();                if (tier.getLinguisticType().getConstraints() == null) {                    tierComboBox.addItem(tier.getName());                }            }            // if there are no tiers yet            if (tierComboBox.getModel().getSize() == 0) {                tierComboBox.addItem(EMPTY);            }        } else {            tierComboBox.addItem(EMPTY);        }        curTier = (String) tierComboBox.getSelectedItem();        if (!curTier.equals(EMPTY)) {            previewer.setTier(transcription.getTierWithId(curTier));        }    }    /**     * Initializes UI elements.     */    private void initComponents() {        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);        addWindowListener(new WindowAdapter() {                public void windowClosing(WindowEvent evt) {                    closeDialog(evt);                }            });        tierComboBox = new JComboBox();        keyLabel = new JLabel();        titleLabel = new JLabel();        titlePanel = new JPanel();        tierLabel = new JLabel();        oneClickRB = new JRadioButton();        twoClicksRB = new JRadioButton();        optionButtonGroup = new ButtonGroup();        tierSelectionPanel = new JPanel();        tierPreviewPanel = new JPanel();        controlPanel = new JPanel();        applyButton = new JButton();        closeButton = new JButton();        buttonPanel = new JPanel();        updateLocale();        GridBagConstraints gridBagConstraints;        getContentPane().setLayout(new GridBagLayout());        Insets insets = new Insets(2, 6, 2, 6);        titleLabel.setFont(titleLabel.getFont().deriveFont((float) 16));        titlePanel.add(titleLabel);        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 0;        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = GridBagConstraints.NORTH;        gridBagConstraints.insets = insets;        gridBagConstraints.weightx = 1.0;        getContentPane().add(titlePanel, gridBagConstraints);        tierSelectionPanel.setLayout(new GridBagLayout());        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 0;        gridBagConstraints.anchor = GridBagConstraints.WEST;        gridBagConstraints.insets = insets;        tierSelectionPanel.add(tierLabel, gridBagConstraints);        tierComboBox.addItemListener(this);        tierComboBox.setMaximumRowCount(Constants.COMBOBOX_VISIBLE_ROWS);        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 0;        gridBagConstraints.fill = GridBagConstraints.NONE;        gridBagConstraints.anchor = GridBagConstraints.WEST;        gridBagConstraints.insets = insets;        tierSelectionPanel.add(tierComboBox, gridBagConstraints);        twoClicksRB.setSelected(true);        optionButtonGroup.add(twoClicksRB);        twoClicksRB.addActionListener(this);        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 1;        gridBagConstraints.gridwidth = 2;        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = GridBagConstraints.WEST;        gridBagConstraints.insets = insets;        gridBagConstraints.weightx = 1.0;        tierSelectionPanel.add(twoClicksRB, gridBagConstraints);        optionButtonGroup.add(oneClickRB);        oneClickRB.addActionListener(this);        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 2;        gridBagConstraints.gridwidth = 2;        gridBagConstraints.anchor = GridBagConstraints.WEST;        gridBagConstraints.insets = insets;        tierSelectionPanel.add(oneClickRB, gridBagConstraints);        keyLabel.setFont(Constants.DEFAULTFONT);        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 3;        gridBagConstraints.gridwidth = 2;        gridBagConstraints.anchor = GridBagConstraints.WEST;        gridBagConstraints.insets = insets;        tierSelectionPanel.add(keyLabel, gridBagConstraints);        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 1;        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = GridBagConstraints.NORTH;        gridBagConstraints.insets = insets;        gridBagConstraints.weightx = 1.0;        getContentPane().add(tierSelectionPanel, gridBagConstraints);        Dimension tpd = new Dimension(400, 60);        tierPreviewPanel.setMinimumSize(tpd);        tierPreviewPanel.setPreferredSize(tpd);        tierPreviewPanel.setLayout(new GridBagLayout());        //JPanel timeLinePanel = new JPanel(); // timeline light        //timeLinePanel.setBackground(java.awt.Color.white);        //previewer.setMinimumSize(tpd);        //previewer.setPreferredSize(tpd);        previewer.setBorder(new LineBorder(Constants.SHAREDCOLOR3, 1));        gridBagConstraints = new GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 0;        gridBagConstraints.fill = GridBagConstraints.BOTH;        gridBagConstraints.anchor = GridBagConstraints.NORTH;        gridBagConstraints.insets = insets;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.weighty = 1.0;        tierPreviewPanel.add(previewer, gridBagConstraints);        controlPanel.setLayout(new GridLayout(1, 3, 6, 0));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.GO_TO_BEGIN)));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.PREVIOUS_SCROLLVIEW)));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.SECOND_LEFT)));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.PLAY_PAUSE)));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.SECOND_RIGHT)));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.NEXT_SCROLLVIEW)));        controlPanel.add(new JButton(ELANCommandFactory.getCommandAction(                    transcription, ELANCommandFactory.GO_TO_END)));

⌨️ 快捷键说明

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