📄 dialogs.java
字号:
/* jahmm package - v0.3.1 *//* * Copyright (c) 2004, Jean-Marc Francois. * * This file is part of Jahmm. * Jahmm 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. * * Jahmm 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 Jahmm; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package be.ac.ulg.montefiore.run.jahmm.apps;import java.util.*;import java.io.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;/* * Creates various dialogs. */ public class Dialogs { protected JFrame mainFrame; protected JFileChooser fileChooser; protected ObservationDescriptionDialog observationDescription; protected LearningParametersDialog learningParameters; public Dialogs(JFrame mainFrame) { this.mainFrame = mainFrame; fileChooser = new JFileChooser(); observationDescription = new ObservationDescriptionDialog(); learningParameters = new LearningParametersDialog(); } // Returns null if canceled public File chooseFileToOpen() { fileChooser.rescanCurrentDirectory(); int returnValue = fileChooser.showOpenDialog(mainFrame); if (returnValue == JFileChooser.APPROVE_OPTION) return fileChooser.getSelectedFile(); else return null; } /* * Chooses a file to save. * Returns null if canceled. */ public File chooseFileToSave() { fileChooser.rescanCurrentDirectory(); fileChooser.setSelectedFile(new File("")); // Unselect last file int returnValue = fileChooser.showSaveDialog(mainFrame); if (returnValue == JFileChooser.APPROVE_OPTION) return fileChooser.getSelectedFile(); else return null; } /* * Returns one chosen open HMM. * Returns null if canceled. */ public Hmm chooseOpenHmm() { java.util.List<Hmm> hmms = OperationsManager.instance().hmms(); if (hmms.size() == 0) { showMessage("No HMM available."); return null; } Object choice = JOptionPane.showInputDialog(mainFrame, "Select a Hidden Markov Model", "Select a HMM", JOptionPane.QUESTION_MESSAGE, (Icon) null, hmms.toArray(), hmms.toArray()[0]); if (choice == null) return null; else return hmms.get(hmms.indexOf(choice)); } /* * Returns one chosen open set of sequences. * Returns null if canceled. */ public ObservationSequences chooseOpenSequences() { java.util.List<ObservationSequences> sequences = OperationsManager.instance().sequences(); if (sequences.size() == 0) { showMessage("No sequence available."); return null; } Object choice = JOptionPane.showInputDialog(mainFrame, "Select a set of observation sequences", "Select a set of sequences", JOptionPane.QUESTION_MESSAGE, (Icon) null, sequences.toArray(), sequences.toArray()[0]); if (choice == null) return null; else return sequences.get(sequences.indexOf(choice)); } /* * Describe an observation type (integer or vector) and dimension. * Returns null if canceled. */ public ObservationDescriptionDialog.ObservationDescription observationDescription() { observationDescription.pack(); observationDescription.setVisible(true); if (observationDescription.type() < 0) return null; else return observationDescription.describe(); } /* * Returns the learning parameters chosen by the user. * Returns null if canceled. */ public LearningParametersDialog.LearningParameters chooseLearningParameters(int observationType, int observationDimension) { learningParameters.setupObservationType(observationType, observationDimension); learningParameters.pack(); learningParameters.setVisible(true); if (learningParameters.isValidated()) return learningParameters.parameters(); else return null; } /* * Shows an informational, non-modal dialog with a costum message. */ public void showMessage(String message) { JOptionPane.showMessageDialog(mainFrame, message); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -