/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- DlgDescriptPoint
- resetState
- getParameterType
- getParameters
- jButton1_ActionPerformed
- stateChanged
- addActionListener
- removeActionListener
- getVectorData
- requireSrc
package jp.ac.nime.computer.grpsimulator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.TitledBorder;
import java.io.*;
import java.util.*;
import jp.ac.nime.computer.grpsimulator.VecPr.*;
/** 画像データ表現 点 パラメタ設定ダイアログ
*
* @version 1.0.0
* @author kikuchi
*/
public class DlgDescriptPoint extends JPanel
implements ChangeListener, ParameterSetting, OperationDialog, VectorDataDialog
{
private JSlider jSlider_;
private JButton jButton1_;
private String srcPath_;
private ActionListener actionListener_;
private GrpSimVectorData gsvd_;
/** Creates new form DlgContrast */
public DlgDescriptPoint() {
setLayout(new BorderLayout());
setBorder(new TitledBorder(GrpSim.res_.getString("DlgDescriptPointLabel")));
setMaximumSize(new Dimension(320, 240));
setMinimumSize(new Dimension(320, 240));
setPreferredSize(new Dimension(320, 240));
JPanel jPanel1 = new JPanel();
jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));
jButton1_ = new JButton();
jButton1_.setText(GrpSim.res_.getString("DlgDescriptPointFileLoad"));
jButton1_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
jPanel1.add(jButton1_);
JLabel jLabel1 = new JLabel();
jLabel1.setText(GrpSim.res_.getString("DlgDescriptPointSliderLabel"));
jPanel1.add(jLabel1);
jSlider_ = new JSlider(0, 400);
jSlider_.setMajorTickSpacing(50);
jSlider_.setMinorTickSpacing(10);
jSlider_.setPaintLabels(true);
jSlider_.setPaintTicks(true);
jSlider_.setValue(100);
jSlider_.addChangeListener(this);
jPanel1.add(jSlider_);
add(jPanel1, BorderLayout.CENTER);
// データ
gsvd_ = new GrpSimVectorData();
}
/** ダイアログの状態をリセットする */
public void resetState() {
jSlider_.setEnabled(false);
jButton1_.setEnabled(true);
}
public int getParameterType() {
return ParameterSetting.PARAM_TYPE_DESCRIPT_POINT;
}
public int[] getParameters() {
int ret[] = new int[1];
ret[0] = jSlider_.getValue();
if (ret[0] < 1) ret[0] = 1;
return ret;
}
private void jButton1_ActionPerformed(ActionEvent evt) {
// ファイルロード
JFileChooser fc = new JFileChooser(srcPath_);
FileFilterNime dsddFilter = new FileFilterNime(".gsvd", "GrpSimDraw-File");
fc.addChoosableFileFilter( dsddFilter );
fc.setFileFilter( dsddFilter );
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(this)) {
srcPath_ = fc.getCurrentDirectory().getAbsolutePath();
File f = fc.getSelectedFile();
if (f != null) {
setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) );
try{
// クリア
gsvd_.clr();
// 入力 全ての行を読む
FileInputStream fi = new FileInputStream(fc.getSelectedFile());
BufferedReader br = new BufferedReader(new InputStreamReader(fi));
while (br.ready()) {
String str = br.readLine();
gsvd_.add(str);
}
br.close();
fi.close();
}
catch(Exception ee) {}
setCursor( Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR) );
}
}
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"ParameterChanged"));
// スクロールバー有効
jSlider_.setEnabled(true);
}
public void stateChanged(ChangeEvent evt) {
JSlider source = (JSlider) evt.getSource();
if ( !source.getValueIsAdjusting() )
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"ParameterChanged"));
}
public void addActionListener(ActionListener listener) {
actionListener_ = AWTEventMulticaster.add(actionListener_, listener);
}
public void removeActionListener(ActionListener listener) {
actionListener_ = AWTEventMulticaster.remove(actionListener_, listener);
}
/** GrpSimVectorData データを受け渡す
*/
public GrpSimVectorData getVectorData() {
return gsvd_;
}
/** 変換元画像を必要とするかどうかを返す
* @return 変換元画像を必要とするならtrueを返す
*/
public boolean requireSrc() {
return true;
}
}