root/graph/JavaPopWeb/src/jp/ac/nime/computer/grpsimulator/DlgMeasureSharpness.java

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. DlgMeasureSharpness
  2. initComponents
  3. jButton3_ActionPerformed
  4. jButton2_ActionPerformed
  5. jButton1_ActionPerformed
  6. resetState
  7. addActionListener
  8. removeActionListener
  9. getParameterType
  10. getParameters
  11. getStepCount
  12. requireSrc
  13. setStepDone
  14. setStepResult

package jp.ac.nime.computer.grpsimulator;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;

/** 画像計測 細線化用 パラメタ設定ダイアログ
 *
 * @author  igarashi
 */
public class DlgMeasureSharpness extends JPanel
        implements OperationDialog, SteppingParameter
{
        
        private ActionListener actionListener_;

        private JButton jButton1_;
        private JButton jButton2_;
        private JButton jButton3_;
        private JTextField jTextField_;

        private int nStepCount_;        // 状態を示す
        
        /** Creates new form DlgMeasureSharpness */
        public DlgMeasureSharpness() {
                initComponents();
        }

        /** This method is called from within the constructor to
         * initialize the form.
         */
        private void initComponents() {
                setLayout(new GridBagLayout());
                setBorder(new TitledBorder(GrpSim.res_.getString("DlgMeasureSharpnessCaption")));
                setPreferredSize(new Dimension(240, 240));
                
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
                
                jButton1_ = new JButton();
                jButton1_.setText(GrpSim.res_.getString("DlgMeasureSharpnessButtonBinary"));
                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);
                
                JLabel jLabel = new JLabel();
                jLabel.setText(GrpSim.res_.getString("DlgMeasureSharpnessLabelLimit"));
                gridBagConstraints.gridy = 1;
                gridBagConstraints.gridwidth = 1;
                gridBagConstraints.insets = new Insets(10, 10, 0, 10);
                add(jLabel, gridBagConstraints);
                
                jTextField_ = new JTextField("10",3);
                jTextField_.setHorizontalAlignment(JTextField.RIGHT);
                gridBagConstraints.gridy = 2;
                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                gridBagConstraints.insets = new Insets(0, 10, 110, 10);
                add(jTextField_, gridBagConstraints);
                
                jButton2_ = new JButton();
                jButton2_.setText(GrpSim.res_.getString("DlgMeasureSharpnessButtonExec"));
                jButton2_.setEnabled(false);
                jButton2_.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                                jButton2_ActionPerformed(evt);
                        }
                });
                gridBagConstraints.gridx = 1;
                gridBagConstraints.gridy = 1;
                gridBagConstraints.insets = new Insets(10, 10, 5, 10);
                add(jButton2_, gridBagConstraints);
                
                jButton3_ = new JButton();
                jButton3_.setText(GrpSim.res_.getString("DlgMeasureSharpnessButtonFinal"));
                jButton3_.setEnabled(false);
                jButton3_.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                                jButton3_ActionPerformed(evt);
                        }
                });
                gridBagConstraints.gridy = 2;
                gridBagConstraints.insets = new Insets(5, 10, 110, 10);
                add(jButton3_, gridBagConstraints);
        }

        private void jButton3_ActionPerformed(ActionEvent evt) {
                // 最後まで細線化
                nStepCount_ = -1;
                jButton2_.setEnabled(false);
                jButton3_.setEnabled(false);
                actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"ParameterChanged"));
        }

        private void jButton2_ActionPerformed(ActionEvent evt) {
                // 一回細線化
                nStepCount_ ++;
                actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"ParameterChanged"));
        }

        private void jButton1_ActionPerformed(ActionEvent evt) {
                // 2値化処理
                nStepCount_ = 1;
                jButton2_.setEnabled(true);
                jButton3_.setEnabled(true);
                jTextField_.setEnabled(true);
                actionListener_.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"ParameterChanged"));
        }

        /** ダイアログの状態をリセットする */
        public void resetState() {
                nStepCount_ = 0;
                jButton2_.setEnabled(false);
                jButton3_.setEnabled(false);
                jTextField_.setEnabled(true);
        }       

        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_SHARP;
        }
        
        /** 変換のパラメータを取得します
         * @return パラメータを表す配列。内容については変換の種類に依存します。エラーはnullを返す。
         */
        public int[] getParameters() {
                int[] ret = new int[1];
                // テキストフィールドから数値を取り出す
                ret[0] = Integer.valueOf(jTextField_.getText()).intValue();;
                return ret;
        }
        
        /** 現在のステップ数を返す
         * @return 現在のステップ数。-1はステップが完了している事を表す。
         */
        public int getStepCount() {
                return nStepCount_;
        }
        
        /** 変換元画像を必要とするかどうかを返す
         * @return 変換元画像を必要とするならtrueを返す
         */
        public boolean requireSrc() {
                return true;
        }
        
        /** ステップがすべて完了した
         */
        public void setStepDone() {
        }
        
        /** ステップごとの処理結果
         */
        public void setStepResult(Object obj) {
        }
        
}

/* [<][>][^][v][top][bottom][index][help] */