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

📄 copytierstep3.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * File:     CopyTierStep3.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.tier;import mpi.eudico.client.annotator.ElanLocale;import mpi.eudico.client.annotator.commands.Command;import mpi.eudico.client.annotator.commands.CopyTierCommand;import mpi.eudico.client.annotator.commands.ELANCommandFactory;import mpi.eudico.client.annotator.gui.EditTypeDialog;import mpi.eudico.client.annotator.gui.multistep.MultiStepPane;import mpi.eudico.client.annotator.gui.multistep.StepPane;import mpi.eudico.client.annotator.type.LinguisticTypeTableModel;import mpi.eudico.client.annotator.util.ProgressListener;import mpi.eudico.client.util.CheckBoxTableCellRenderer;import mpi.eudico.server.corpora.clomimpl.abstr.TierImpl;import mpi.eudico.server.corpora.clomimpl.abstr.TranscriptionImpl;import mpi.eudico.server.corpora.clomimpl.type.Constraint;import mpi.eudico.server.corpora.clomimpl.type.LinguisticType;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Vector;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JProgressBar;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.ListSelectionModel;import javax.swing.SwingConstants;import javax.swing.border.EmptyBorder;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;/** * The third step in the reparent process:  allow or, in some cases, force to * choose another linguistic type. * * @author Han Sloetjes * @version 1.0 */public class CopyTierStep3 extends StepPane implements ListSelectionListener,    ActionListener, ProgressListener {    private TranscriptionImpl transcription;    private JLabel tierOverview;    private JTable typeTable;    private JScrollPane scrollPane;    private String tierName;    private String newParentName;    private TierImpl selTier;    private TierImpl newParent;    private LinguisticType curType;    private String selTypeName;    private LinguisticTypeTableModel model;    private String[] columns;    private Vector types;    private JButton typButton;    private GridBagLayout layout;    private JProgressBar progressBar;    private JLabel progressLabel;    private CopyTierCommand com;    private boolean copyMode = false;    /**     * Creates a new CopyTierStep3 instance.     *     * @param multiPane the enclosing container for the steps     * @param transcription the transcription     */    public CopyTierStep3(MultiStepPane multiPane,        TranscriptionImpl transcription) {        super(multiPane);        this.transcription = transcription;        types = this.transcription.getLinguisticTypes();        if (multiPane.getStepProperty("CopyMode") != null) {            copyMode = true;        }        initComponents();    }    /**     * Initialise components.     */    public void initComponents() {        // setPreferredSize        layout = new GridBagLayout();        setLayout(layout);        setBorder(new EmptyBorder(12, 12, 12, 12));        tierOverview = new JLabel();        ImageIcon tickIcon = new ImageIcon(this.getClass().getResource("/mpi/eudico/client/annotator/resources/Tick16.gif"));        ImageIcon untickIcon = new ImageIcon(this.getClass().getResource("/mpi/eudico/client/annotator/resources/Untick16.gif"));        CheckBoxTableCellRenderer cbRenderer = new CheckBoxTableCellRenderer();        cbRenderer.setIcon(untickIcon);        cbRenderer.setSelectedIcon(tickIcon);        cbRenderer.setHorizontalAlignment(SwingConstants.CENTER);        // create a tablemodel for linguistic types        if (types != null) {            columns = new String[] {                    LinguisticTypeTableModel.NAME,                    LinguisticTypeTableModel.STEREOTYPE,                    LinguisticTypeTableModel.CV_NAME,                    LinguisticTypeTableModel.TIME_ALIGNABLE,                    LinguisticTypeTableModel.GRAPHICS                };            model = new LinguisticTypeTableModel(types, columns);        } else {            model = new LinguisticTypeTableModel();        }        typeTable = new JTable(model);        typeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        typeTable.getSelectionModel().addListSelectionListener(this);        for (int i = 0; i < typeTable.getColumnCount(); i++) {            if (typeTable.getModel().getColumnClass(i) != String.class) {                typeTable.getColumn(typeTable.getModel().getColumnName(i))                         .setPreferredWidth(35);            }            if (typeTable.getModel().getColumnClass(i) == Boolean.class) {                typeTable.getColumn(typeTable.getModel().getColumnName(i))                         .setCellRenderer(cbRenderer);            }        }        scrollPane = new JScrollPane();        scrollPane.setViewportView(typeTable);        Insets insets = new Insets(4, 6, 4, 6);        GridBagConstraints gbc = new GridBagConstraints();        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.insets = insets;        gbc.weightx = 1.0;        add(tierOverview, gbc);        gbc = new GridBagConstraints();        gbc.gridy = 1;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.BOTH;        gbc.insets = insets;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        add(scrollPane, gbc);        typButton = new JButton(ElanLocale.getString("Menu.Type.AddNewType"));        typButton.addActionListener(this);        gbc = new GridBagConstraints();        gbc.gridy = 2;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.NONE;        gbc.insets = insets;        gbc.weightx = 0.0;        add(typButton, gbc);    }    /**     * Remove the table and linguistictype button and add a progressbar  and a     * message label.     */    private void adjustComponents() {        JPanel progressPanel = new JPanel(new GridBagLayout());        JPanel filler = new JPanel();        Insets insets = new Insets(4, 6, 4, 6);        GridBagConstraints gbc = new GridBagConstraints();        gbc.gridx = 0;        gbc.gridy = 0;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.BOTH;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        progressPanel.add(filler, gbc);        progressLabel = new JLabel("...");        gbc.gridx = 0;        gbc.gridy = 1;        gbc.anchor = GridBagConstraints.NORTHWEST;        progressPanel.add(progressLabel, gbc);        progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);        progressBar.setValue(0);        gbc = new GridBagConstraints();        gbc.gridy = 2;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.weightx = 1.0;        progressPanel.add(progressBar, gbc);        remove(scrollPane);        remove(typButton);        gbc = new GridBagConstraints();        gbc.gridx = 0;        gbc.gridy = 1;        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.fill = GridBagConstraints.BOTH;        gbc.insets = insets;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        add(progressPanel, gbc);        revalidate();    }    /**     * @see mpi.eudico.client.tool.viewer.enhanced.multistep.Step#getStepTitle()     */    public String getStepTitle() {        return ElanLocale.getString("MultiStep.Reparent.SelectType");    }    /**     * Get the selected tier and new parent and fill the linguistic type table.     *     * @see mpi.eudico.client.tool.viewer.enhanced.multistep.Step#enterStepForward()     */    public void enterStepForward() {        tierName = (String) multiPane.getStepProperty("SelTier");        selTier = (TierImpl) transcription.getTierWithId(tierName);        if (selTier != null) {            curType = selTier.getLinguisticType();        }        Object par = multiPane.getStepProperty("SelNewParent");        if (par != null) {            newParentName = (String) par;            newParent = (TierImpl) transcription.getTierWithId(newParentName);        } else {            newParentName = "-";        }        tierOverview.setText("<html><table><tr><td>" +            ElanLocale.getString("MultiStep.Reparent.SelectedTier") + " " +            "</td><td>" + tierName + "</td></tr>" + "<tr><td>" +            ElanLocale.getString("MultiStep.Reparent.SelectedParent") + " " +            "</td><td>" + newParentName + "</td></tr>");        Constraint con = null;        if (newParent != null) {            con = newParent.getLinguisticType().getConstraints();        }        if (newParent == null) {            model.showOnlyStereoTypes(new int[] { -1 }); // -1 == no constraints        } else if ((con == null) ||                (con.getStereoType() == Constraint.TIME_SUBDIVISION) ||                (con.getStereoType() == Constraint.INCLUDED_IN)) {            // parent is root or time subdivision

⌨️ 快捷键说明

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