/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- DlgMeasureScale
- initComponents
- jButton5_ActionPerformed
- jButton4_ActionPerformed
- jButton3_ActionPerformed
- jButton2_ActionPerformed
- jButton1_ActionPerformed
- resetState
- addActionListener
- removeActionListener
- getParameterType
- getParameters
- getStepCount
- requireSrc
- setStepDone
- setStepResult
package jp.ac.nime.computer.grpsimulator;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
/** 画像計測 拡大縮小(膨張収斂)
* @version 1.0.0
* @author igarashi
*/
public class DlgMeasureScale extends JPanel
implements OperationDialog, SteppingParameter
{
private JButton jButton1_;
private JButton jButton2_;
private JButton jButton3_;
private JButton jButton4_;
private JButton jButton5_;
private ActionListener actionListener_;
private int nAction_;
/** Creates new form DlgMeasureScale */
public DlgMeasureScale() {
initComponents();
nAction_ = 0; // 初期状態
}
/** This method is called from within the constructor to
* initialize the form.
*/
private void initComponents() {
setLayout(new GridBagLayout());
setBorder(new TitledBorder(GrpSim.res_.getString("DlgMeasureScaleCaption")));
setPreferredSize(new Dimension(280, 240));
GridBagConstraints gridBagConstraints = new GridBagConstraints();
jButton1_ = new JButton();
jButton1_.setText(GrpSim.res_.getString("DlgMeasureScaleButtonBinary"));
jButton1_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1_ActionPerformed(evt);
}
});
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.insets = new Insets(10, 10, 10, 10);
add(jButton1_, gridBagConstraints);
jButton2_ = new JButton();
jButton2_.setText(GrpSim.res_.getString("DlgMeasureScaleButtonEnlarge4"));
jButton2_.setEnabled(false);
jButton2_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton2_ActionPerformed(evt);
}
});
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 1;
add(jButton2_, gridBagConstraints);
jButton3_ = new JButton();
jButton3_.setText(GrpSim.res_.getString("DlgMeasureScaleButtonReduce4"));
jButton3_.setEnabled(false);
jButton3_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton3_ActionPerformed(evt);
}
});
gridBagConstraints.gridx = 1;
add(jButton3_, gridBagConstraints);
jButton4_ = new JButton();
jButton4_.setText(GrpSim.res_.getString("DlgMeasureScaleButtonEnlarge8"));
jButton4_.setEnabled(false);
jButton4_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton4_ActionPerformed(evt);
}
});
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new Insets(10, 10, 100, 10);
add(jButton4_, gridBagConstraints);
jButton5_ = new JButton();
jButton5_.setText(GrpSim.res_.getString("DlgMeasureScaleButtonReduce8"));
jButton5_.setEnabled(false);
jButton5_.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton5_ActionPerformed(evt);
}
});
gridBagConstraints.gridx = 1;
add(jButton5_, gridBagConstraints);
}
private void jButton5_ActionPerformed(ActionEvent evt) {
// 8連結で縮小
nAction_ = 4;
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED, "ParameterChanged"));
}
private void jButton4_ActionPerformed(ActionEvent evt) {
// 8連結で拡大
nAction_ = 3;
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED, "ParameterChanged"));
}
private void jButton3_ActionPerformed(ActionEvent evt) {
// 4連結で縮小
nAction_ = 2;
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED, "ParameterChanged"));
}
private void jButton2_ActionPerformed(ActionEvent evt) {
// 4連結で拡大
nAction_ = 1;
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED, "ParameterChanged"));
}
private void jButton1_ActionPerformed(ActionEvent evt) {
// ボタン有効
jButton2_.setEnabled(true);
jButton3_.setEnabled(true);
jButton4_.setEnabled(true);
jButton5_.setEnabled(true);
// 2値化処理
nAction_ = 0;
actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED, "ParameterChanged"));
}
/** ダイアログの状態をリセットする */
public void resetState() {
jButton2_.setEnabled(false);
jButton3_.setEnabled(false);
jButton4_.setEnabled(false);
jButton5_.setEnabled(false);
}
public void addActionListener(ActionListener listener) {
actionListener_ = AWTEventMulticaster.add(actionListener_, listener);
}
public void removeActionListener(ActionListener listener) {
actionListener_ = AWTEventMulticaster.remove(actionListener_, listener);
}
/** 変換の種類を取得します
* @return 変換の種類を表す値
*/
public int getParameterType() {
return ParameterSetting.PARAM_TYPE_MEASURE_SCALE;
}
/** 変換のパラメータを取得します
* @return パラメータを表す配列。最初の要素が有効値。 0:二値化 1:4連結拡大 2:4連結縮小 3:8連結拡大 4:8連結縮小。
* エラーはnullを返す。
*/
public int[] getParameters() {
int nRet[] = new int [1];
nRet[0] = nAction_; // nAction 0:二値化 1:4連結拡大 2:4連結縮小 3:8連結拡大 4:8連結縮小
return nRet;
}
/** 現在のステップ数を返す
* @return 現在のステップ数。-1はステップが完了している事を表す。
*/
public int getStepCount() {
return nAction_;
}
/** 変換元画像を必要とするかどうかを返す
* @return 変換元画像を必要とするならtrueを返す
*/
public boolean requireSrc() {
return true;
}
/** ステップがすべて完了した
*/
public void setStepDone() {
}
/** ステップごとの処理結果
*/
public void setStepResult(Object obj) {
}
}