[パット見でのコイン認識問題] の実験を行うための、コンピューター・プログラム (ソースプログラム・リストあり)

Cognition of Number, Index, 数に関する認知, インデックス へ
-----

2024.4.13 presented in internet World Wide Web
2024.7.5 rewritten
2024.7.5 presented in [note] ( //note.com/runningWater/]

-----
----------

  1. はじめに

下記のコンテンツにおいて、私は、

 机の上に、様々な種類のコインが、置かれていたとき、パット見で、種類ごとの個数を認識することが、できるだろうか?
 
という、問題提起を行った。

Coin recognition problem at a glance? パット見でのコイン認識問題

そこで、私は、これに関する実験を行うために、ある、(コンピューター)プログラムを、作った。そのプログラムのソースリストの全てを、ここに、記述した。

----------
2. このプログラムが動作する様

これ以降に記述されている内容は、このようなコンピューター・プログラムを制作した、それを動かしたら、このような結果になった、というような事を、ただ、述べているに過ぎない。

以下の記述を読んだ人が、それを単に参考にする、というのであれば、問題は無いと、思われる。

しかし、記述されている内容に沿って、その人が、そこに記されているのと同様の制作や作業を行った際に、その制作、作業、コンピューターの作動の結果、使用されたコンピューター等、様々な方面において、何らかの問題が発生しない、という保証は、全くない。

その制作、作業、コンピューターの作動の結果、その人や、その人が所属している組織、その人が使用した様々な機器、インフラストラクチャー等の、身の上にどのような事が起ころうとも、私は一切、責任を負わない。

このプログラムは、Java言語を使って、記述されている。

(1) フェーズ 1

[Start class] が起動されると、下の図(Fig 2.1) のような画面が表示される。

Fig 2.1

(2) フェーズ 2

次に、[enter key]が押されると、画面の表示内容は、下図 (Fig. 2.2)のようになる。

Fig 2.2

各図形の個数や表示位置は、乱数によって決定されているので、下図 (Fig. 2.3)のような表示になることもある。

Fig 2.3

(3) フェーズ 3

次に、[enter key]が押されると、画面の表示内容は、下図 (Fig. 2.4)のようになる。

Fig 2.4

更に、[enter key]が押されると、制御が、[フェーズ 2]に、戻される。

このような、

[フェーズ 2] --> [フェーズ 3] --> [フェーズ 2]

の過程が、20回、繰り返される。各過程ごとに、まちまちの個数の図形が表示される。3種類の図形が表示される。

各過程ごとに、[フェーズ 2]から[フェーズ 3]への移行に要した時間が、コンピューターによって測定され、記録されていく。この時間を見れば、各課題が、パット見でもって行われているか、そうではないのか、ということが、分かるだろう。

(4) フェーズ 4

20回の過程が完了すると、画面の表示内容は、下図 (Fig. 2.5)のようになる。

Fig 2.5

そして、各過程ごとに記録された数値が、下記のように、[System.out.println]によって(画面上にではなく)、表示される。

1列目に表示されるのは、各過程の番号
2列目に表示されるのは、各過程において、要した時間(秒)
3列目、4列目、5列目に表示されるのは、各過程において、画面上に表示された図形の種類別の個数
6列目に表示されるのは、各過程において、画面上に表示された図形の総数

と、なる。

=============================
Class : Process , Methode : do_showing_results_process
The results of the trial are as follows
=============================
current_trial_number , time_second_for_response , number of figure type_1 , number of figure type_2 , number of figure type_3 , total number of figures
-----------------------------------------------
1 , 1.523 , 3 , 0 , 1 , 4
2 , 2.322 , 3 , 3 , 1 , 7
・・・・・・・・・・

----------
3. このプログラムのソースコード

表示される図形は、事前に画像データ( imagedata_1.jpg , imagedata_2.jpg , imagedata_3.jpg )として作成し、下記フォルダーに格納しておくようにした。このようにしておけば、図形を別のものに変える事が、容易にできるようになるから。

D
 Test1
  ImageData
    imagedata_1.jpg
    imagedata_2.jpg
    imagedata_3.jpg

Fig 3.1  格納しておく図形の画像


各段階で表示されるメッセージは、事前に、テキストデータ ( textdata_1.txt , textdata_2.txt , textdata_3.txt , textdata_4.txt ) として作成し、下記フォルダーに格納しておくようにした。このようにしておけば、メッセージ内容を別のものに変える事が、容易にできるようになるから。

D
 Test1
  TextData
   textdata_1.txt
   textdata_2.yxy
   textdata_3.txt
   textdata_4.txt

================
textdata_1.txt

Trial 20 rounds, will be done
Are you ready?
Push [enter] key
================

このプログラムは、Java言語を使って、記述されている。以下のようなものである。

----------

import  java.util.Calendar ;
import  java.util.ArrayList ;
    //***************************
import java.awt.Graphics;
import  java.awt.Color ;
import java.awt.Font ;
import java.awt.image.BufferedImage ;
    //***************************
import java.io. *;
import javax.imageio.ImageIO ;
    //***************************
import javax.swing.JFrame;
import javax.swing.JPanel;

//====================================
public class Start {
	
	 static String cv_this_class_name = "Start" ; 

    //-----------------------------------------------------------------	
     public static void main ( String args[] ) {
			  
          Process.do_prepare_process ( ) ;
          Process.do_measurement_process ( ) ;
          Process.do_showing_results_process ( ) ;
        }
    } 
//==============================================
class ContainParameters {

  public static final int cv_max_phase_number  = 4 ;  
//*************************************************  
   public static final int cv_max_trial_number = 20 ;
   public static final int cv_max_value_of_desired_range = 7 ;
   public static final int cv_number_of_figure = 3 ;
//*************************************************   
   public static final int cv_width_of_DisplayImage = 800 ;	  
   public static final int cv_height_of_DisplayImage = 900 ;	
   public static final int  cv_margin_of_DisplayImage_Frame = 40 ;
	      
	public static final int  cv_width_of_mark_display_area = 740 ;
	public  static final  int cv_width_of_mark = 70 ;
    public  static final  int cv_height_of_mark = 70 ; 
    public  static final  int cv_interval_Y_of_mark = 90 ;
    	      
	 public static final int cv_Color_background_R = 10 ;
     public static final int cv_Color_background_G = 30 ;  
     public static final int cv_Color_background_B = 70 ; 
	      
	  public static final int  cv_Color_display_text_R = 220 ;
      public static final int  cv_Color_display_text_G = 200 ;
      public static final int  cv_Color_display_text_B = 20 ;
	      
  public static final int cv_height_of_message_one_line = 40 ;
  public static final int  cv_begin_Y_of_display_message = 700 ;
//***********************************************	      
  public static final String cv_using_drive  = "D:\\" ;
  public static final String cv_using_parent_folder  = "Test1\\" ;
  public static final String cv_using_folder_for_imagedata  = "ImageData\\" ;    
  public static final String cv_using_folder_for_textdata  = "TextData\\" ;    
  public static final String cv_filename_of_imagedata_part_1  = "imagedata_" ;
  public static final String cv_filename_of_imagedata_part_2  = ".jpg" ;
  
  public static final String cv_filename_of_textdata_part_1  = "textdata_" ;
  public static final String cv_filename_of_textdata_part_2  = ".txt" ;

//*************************************************           
        }
//==============================================
class  Process {
      
  static String cv_this_class_name = "Process" ;
            
  static float  [ ] cv_array_time_second_for_response ;
  static  DisplayImage  cv_ins_DisplayImage ; 
//----------------------------------------------------------
public  static void  do_prepare_process ( ) {
     
  String  this_methode_name = "do_prepare_process" ;
     
  System.out.println ( "=============================" ) ;	   
  System.out.println ( "Start , Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
  System.out.println ( "=============================" ) ;
  
   String  absolute_path_of_file ;
     	     
     	     //---------- get imegedata file -------------------
   AreaForTransferOfIinformation
             .cv_array_HandleImageData = new HandleImageData
                          [ ContainParameters.cv_number_of_figure ] ;
     	     
  for ( int order_number_of_imagedata = 1 
                ; order_number_of_imagedata
                        <= ContainParameters.cv_number_of_figure
     	       ;  order_number_of_imagedata  += 1 ) {
     	       
     absolute_path_of_file
     	        = ContainParameters.cv_using_drive
                    + ContainParameters.cv_using_parent_folder
                    + ContainParameters.cv_using_folder_for_imagedata
                    + ContainParameters.cv_filename_of_imagedata_part_1
                    + order_number_of_imagedata
                    + ContainParameters.cv_filename_of_imagedata_part_2 ;
     AreaForTransferOfIinformation
          .cv_array_HandleImageData [ order_number_of_imagedata - 1 ]
              = new  HandleImageData ( absolute_path_of_file ) ;
  }
     	     //------------- get text file ------------------------
  AreaForTransferOfIinformation
       .cv_array_HandleTextData = new HandleTextData
                                    [ ContainParameters.cv_max_phase_number  ] ;
     	     
  for ( int order_number_of_textdata = 1 
                ; order_number_of_textdata
                        <= ContainParameters.cv_max_phase_number 
     	       ;  order_number_of_textdata  += 1 ) {
     	       
     absolute_path_of_file
     	        = ContainParameters.cv_using_drive
                    + ContainParameters.cv_using_parent_folder
                    + ContainParameters.cv_using_folder_for_textdata
                    + ContainParameters.cv_filename_of_textdata_part_1
                    + order_number_of_textdata
                    + ContainParameters.cv_filename_of_textdata_part_2 ;
     AreaForTransferOfIinformation
          .cv_array_HandleTextData [ order_number_of_textdata - 1 ]
                   = new  HandleTextData ( absolute_path_of_file ) ;
  }     	       
//-----------------------------       
   AreaForTransferOfIinformation
               .cv_array_number_of_all_figure_for_each_trial
                           = new int [ ContainParameters.cv_max_trial_number ] ;
   AreaForTransferOfIinformation                       
               .cv_array_type_of_figure
                           = new int [ ContainParameters.cv_max_trial_number ]
                                               [ ContainParameters.cv_max_value_of_desired_range ] ;                             
  AreaForTransferOfIinformation
               .cv_array_number_of_figure_for_each_type
                            = new int [ ContainParameters.cv_max_trial_number ]
                                                [ ContainParameters.cv_number_of_figure ] ;      
  AreaForTransferOfIinformation
               .cv_array_figure_set_location_X
                           = new int [ ContainParameters.cv_max_trial_number ]
                                               [ ContainParameters.cv_max_value_of_desired_range ] ;
  AreaForTransferOfIinformation
               .cv_array_figure_set_location_Y
                           = new int [ ContainParameters.cv_max_trial_number ]
                                               [ ContainParameters.cv_max_value_of_desired_range ] ;
                    
  cv_array_time_second_for_response = new float  [ ContainParameters.cv_max_trial_number ] ;
                          //-------------------------------------------------- 
  for ( int i = 1 ; i <= ContainParameters.cv_max_trial_number ; i += 1 ) {
      set_values_1_using_random_number ( i ) ;
      cv_array_time_second_for_response [ i - 1 ] = 0 ;
     }
                                //-------- display  first message ---------------
  AreaForTransferOfIinformation.cv_phase_number = 1 ;                                      
  cv_ins_DisplayImage = new DisplayImage ( ) ;
  cv_ins_DisplayImage.do_repaint ( ) ;
  wait_for_push_enter_key ( )   ;
      //--------------------------------------------------          
  System.out.println ( "=============================" ) ;	   
  System.out.println ( "End , Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
  System.out.println ( "=============================" ) ;	
 }   
//-------------------------------------------------------------------      
private static void  set_values_1_using_random_number (
                                                         int  arg_order_number_of_trial ) {

  AreaForTransferOfIinformation
         .cv_array_number_of_all_figure_for_each_trial 
                             [ arg_order_number_of_trial - 1 ]
          = get_int_random_value (
                            1  //arg_from_value 
                         ,  ContainParameters.cv_max_value_of_desired_range  //arg_to_value
                                                         ) ;
  for ( int i = 1 ; i <= ContainParameters.cv_number_of_figure ; i ++ ) {                                                       
     AreaForTransferOfIinformation
               .cv_array_number_of_figure_for_each_type
                       [ arg_order_number_of_trial - 1 ] [ i - 1 ] = 0 ;
  }
                 //---------------------------------------
  for ( int  order_number_of_setting_mark = 1 
               ; order_number_of_setting_mark <= AreaForTransferOfIinformation
                             .cv_array_number_of_all_figure_for_each_trial 
                                              [ arg_order_number_of_trial - 1 ] 
               ; order_number_of_setting_mark += 1 ) {
       set_values_2_using_random_number (
                           arg_order_number_of_trial
                       ,   order_number_of_setting_mark  )  ;
  }                                                                                  
}
//---------------------------------------------------------                                             
private static void  set_values_2_using_random_number (
                                                int arg_order_number_of_trial
                                            ,   int arg_order_number_of_setting_mark  )  {
                                            
  int   type_of_figure 
              = get_int_random_value (
                            1  //arg_from_value 
                         ,  ContainParameters.cv_number_of_figure  //arg_to_value
                                                         ) ;            
  AreaForTransferOfIinformation
          .cv_array_type_of_figure
               [ arg_order_number_of_trial - 1 ]
               [ arg_order_number_of_setting_mark - 1 ] =  type_of_figure ;
   AreaForTransferOfIinformation
               .cv_array_number_of_figure_for_each_type
                [ arg_order_number_of_trial - 1 ]   [ type_of_figure - 1 ] 
                           += 1 ;
        //---------------------------------------------       
  AreaForTransferOfIinformation
               .cv_array_figure_set_location_X
                    [ arg_order_number_of_trial - 1 ]
                    [ arg_order_number_of_setting_mark - 1 ]
         = get_int_random_value (
                             ContainParameters.cv_width_of_mark  //arg_from_value 
                         ,  ( ContainParameters.cv_width_of_mark_display_area
                                    - ContainParameters.cv_width_of_mark )
                                                         ) ;
  AreaForTransferOfIinformation
               .cv_array_figure_set_location_Y
                    [ arg_order_number_of_trial - 1 ]
                    [ arg_order_number_of_setting_mark - 1 ] 
            =  ContainParameters.cv_interval_Y_of_mark
                        *  arg_order_number_of_setting_mark ;      
 }
//-------------------------------------------------------------------      
private static int  get_int_random_value (
                                           int  arg_from_value  ,  int  arg_to_value ) {
                                           
    double  random_number_from_0_to_1 = Math.random ( ) ;
    double  add_value = ( arg_to_value - arg_from_value + 1 )
                                                     * random_number_from_0_to_1 ;                                       
    int  w1 = ( int ) ( arg_from_value +add_value ) ;
    int return_value = w1 ;
    if ( w1 < arg_from_value ) {
      return_value = arg_from_value ;
    }
    if ( w1 > arg_to_value ) {
      return_value = arg_to_value ;
    }
    
    return  return_value ;
}
//------------------------------------     
public  static void  do_measurement_process ( ) {
        
   for (  AreaForTransferOfIinformation
                                        .cv_current_trial_number = 1 
                   ; AreaForTransferOfIinformation
                                   .cv_current_trial_number 
                                         <= ContainParameters.cv_max_trial_number
                   ; AreaForTransferOfIinformation
                                   .cv_current_trial_number  += 1 ) {
 
     AreaForTransferOfIinformation.cv_phase_number = 2 ;
     cv_ins_DisplayImage.do_repaint ( ) ;
     wait_for_push_enter_key_for_tarminate_displaying_image (
                                                 AreaForTransferOfIinformation
                                                                   .cv_current_trial_number ) ;
        //--------------------------------         
     AreaForTransferOfIinformation.cv_phase_number = 3 ;
     cv_ins_DisplayImage.do_repaint ( ) ;
             //wait for [push enter key] for starting next trial
     wait_for_push_enter_key ( )   ;
   }
 }          
//-------------------------------------------------------
private static void  wait_for_push_enter_key_for_tarminate_displaying_image
                                                            ( int  arg_current_trial_number ) {
        
  String this_methode_name = "wait_for_push_enter_key_for_tarminate_displaying_image" ;

  System.out.println ( "=============================" ) ;	   
  System.out.println ( "Start , Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
  System.out.println ( "arg_current_trial_number = "
 	                                                     + arg_current_trial_number ) ;
  System.out.println ( "=============================" ) ;
     	     
  Calendar  ins_calendar_1 = Calendar.getInstance ( ) ;

  wait_for_push_enter_key ( )   ;
                 
  Calendar  ins_calendar_2 = Calendar.getInstance ( ) ;
                                                                      
  cv_array_time_second_for_response [ arg_current_trial_number - 1 ] 
                            =  culculate_time_second_between_given_2_times (  
                                                  ins_calendar_1.get ( Calendar.HOUR) 
                                                , ins_calendar_1.get ( Calendar.MINUTE ) 
                                                , ins_calendar_1.get ( Calendar.SECOND ) 
                                                , ins_calendar_1.get ( Calendar.MILLISECOND )  
                                                    ,  ins_calendar_2.get ( Calendar.HOUR) 
                                                    , ins_calendar_2.get ( Calendar.MINUTE ) 
                                                    , ins_calendar_2.get ( Calendar.SECOND ) 
                                                    , ins_calendar_2.get ( Calendar.MILLISECOND ) 
                                                ) ;
                                                
System.out.println ( "**********************************" ) ;	   
System.out.println ( "Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
 System.out.println ( "**********************************" ) ;	  
 System.out.println ( "cv_array_time_second_for_response [ arg_current_trial_number - 1 ]  = "
 	                                                     + cv_array_time_second_for_response [ arg_current_trial_number - 1 ]  ) ;
  System.out.println ( "=============================" ) ;                    
 }
//-------------------------------------------------------------
public   static  void  do_showing_results_process ( ) {
     
  String this_methode_name = "do_showing_results_process" ;
            
  AreaForTransferOfIinformation.cv_phase_number = 4 ;
  cv_ins_DisplayImage.do_repaint ( ) ;
                  //---------------------------------------------------
  System.out.println ( "=============================" ) ;	   
  System.out.println ( "Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
  System.out.println ( "The results of the trial are as follows"   ) ;
  System.out.println ( "=============================" ) ;
  System.out.println ( "current_trial_number"
                                                         + " , " +  "time_second_for_response"
                                                         + " , "  +  "number of figure type_1"
                                                         + " , "  +  "number of figure type_2"
                                                         + " , "  +  "number of figure type_3"
                                                          + " , " +  "total number of figures"
                                                             ) ;
  System.out.println ( "-----------------------------------------------" ) ;
                                                                  
  for ( int  current_trial_number = 1 
                                  ; current_trial_number  <= ContainParameters.cv_max_trial_number
                                  ; current_trial_number  += 1 ) {
                                  
     System.out.print ( current_trial_number ) ;
      System.out.print ( " , " 
                 + cv_array_time_second_for_response
                                    [ current_trial_number - 1 ] ) ;

      for ( int i = 1 ; i <= ContainParameters.cv_number_of_figure  
                           ;  i += 1 ) {
        System.out.print ( " , " 
                 +AreaForTransferOfIinformation                
                          .cv_array_number_of_figure_for_each_type 
                                  [ current_trial_number - 1 ]
                                  [ i - 1 ] ) ;
        }
        //------------------------------------                                                                                    
     System.out.println ( " , " 
                 + AreaForTransferOfIinformation                
                          .cv_array_number_of_all_figure_for_each_trial
                                   [ current_trial_number - 1 ] ) ;
        //------------------------------------                                                                                    
                               
    }
 }
//-------------------------------------------------------
public  static float   culculate_time_second_between_given_2_times (  
                                                    int arg_1_hour  ,  int  arg_1_minute   , int  arg_1_second 
                                                                                      , int  arg_1_milli_second 
                                                 ,  int arg_2_hour ,  int  arg_2_minute   , int  arg_2_second 
                                                                                      , int  arg_2_milli_second 
                                                                                          ) {
                                                                                          
  String    this_methode_name = "culculate_time_second_between_given_2_times" ;                                                                       
                                                                                          
  long time_1_minute =  arg_1_hour * 60 +  arg_1_minute ;
  long time_1_second =   time_1_minute * 60 + arg_1_second ;
  long time_1_milli_second =  time_1_second * 1000 +  arg_1_milli_second  ;                                                                                                                                          
  long time_2_minute =  arg_2_hour * 60 +  arg_2_minute ;
  long time_2_second =   time_2_minute * 60 + arg_2_second ;
  long time_2_milli_second =  time_2_second * 1000 +  arg_2_milli_second  ;
                
  if ( time_2_milli_second  <=  time_1_milli_second ) {
     System.out.println ( "===== Error !!!!!!!! ========================" ) ;	   
	 System.out.println ( " Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
	System.out.println ( "time_2_milli_second <= time_1_milli_second"   ) ;
		             
	System.out.println ( "time_1_milli_second = " + time_1_milli_second ) ;		     
	System.out.println ( "arg_1  hour, minute, second, milli_second = "
		                 + arg_1_hour + " , " + arg_1_minute + " , " + arg_1_second
		                             + " , " +  arg_1_milli_second ) ;
		                             	
	System.out.println ( "time_2_milli_second = " + time_2_milli_second ) ;		     
	System.out.println ( "arg_2  hour, minute, second, milli_second = "
		                 + arg_2_hour + " , " + arg_2_minute + " , " + arg_2_second
		                             + " , " +  arg_2_milli_second ) ; 	  		     
     System.out.println ( "=============================" ) ;
     	     
     wait_for_push_enter_key ( )   ; 
    }                                                                                       
                //---------------------------------------------                                                                          ;         
  long time_1_2_difference_milli_second =  time_2_milli_second
                                                                                                - time_1_milli_second ;
  float  return_value_second = time_1_2_difference_milli_second / 1000.0f ; 
  return  return_value_second ;
 }
 //-------------------------------------------------------------
 public   static void  wait_for_push_enter_key ( ) {

  String this_methode_name = "wait_for_push_enter_key" ;

  System.out.println ( "=============================" ) ;	   
  System.out.println ( " Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
  System.out.println ( "************* push [ enter ] key ************"   ) ;
  System.out.println ( "=============================" ) ;	
  
  char process_continue = 'Y' ;
  int get_code = 0 ;   	     
  try {
	                         //wait EntKey Push
       while ( process_continue =='Y' ) {
	        get_code = System.in.read ( ) ;
	        if ( get_code == 10 ) {
	           process_continue = 'N' ;
	         }
         }
	  }
   catch ( java.io.IOException  arg_ins_ex ) {
	   System.err.println ( "Class = " +  cv_this_class_name
	                         + " , Methode = " + this_methode_name
	                         + " : IOEception"  ) ;
	 }
  }
}
//==============================================
class  AreaForTransferOfIinformation  {
  
  public  static int cv_phase_number ; 
  public static int   cv_current_trial_number ;
	  
  public  static int [ ]  cv_array_number_of_all_figure_for_each_trial ;
  public  static int [ ] [ ]  cv_array_type_of_figure ;
  public  static int [ ] [ ]  cv_array_number_of_figure_for_each_type ;
  
  public   static int [ ] [ ] cv_array_figure_set_location_X ;
  public    static int [ ] [ ] cv_array_figure_set_location_Y ;
	  
  public static  HandleImageData [ ]  cv_array_HandleImageData ;
  public static  HandleTextData [ ]  cv_array_HandleTextData ;      
 }
 //====================================
 class  HandleImageData {
     
  private  String cv_this_class_name = "HandleImageData" ;
  
  private  BufferedImage  cv_ins_BufferedImage_of_contained_image_data ;
//---------------------------------------------------
              // constructer
public HandleImageData (
	                      String  arg_absolute_path_of_file_contains_image_data
	                                            ) {
	                                            
  String    this_methode_name = "constructer" ;
  
  File  ins_File  = new File
                                ( arg_absolute_path_of_file_contains_image_data ) ;
  cv_ins_BufferedImage_of_contained_image_data = null ;
	                                                                                              
  try {
      cv_ins_BufferedImage_of_contained_image_data  = ImageIO.read ( ins_File ) ; 
      
      System.out.println ( "****************************************" ) ;	   
      System.out.println ( "Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
	  System.out.println ( "image data have been gotten" ) ;
	  System.out.println ( "arg_absolute_path_of_file_contains_image_data = "
	                                      + arg_absolute_path_of_file_contains_image_data  ) ;
      System.out.println ( "width , height of image data = "
                             + cv_ins_BufferedImage_of_contained_image_data.getWidth ( )
                 +  " , " + cv_ins_BufferedImage_of_contained_image_data.getHeight ( )                                    
                                                                ) ;
      //Process.wait_for_push_enter_key ( )   ;
     }
 catch ( IOException  arg_ins_IOException ) {
     System.out.println ( "===== Error !!!!!!!! ========================" ) ;	   
	 System.out.println ( " Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
	  System.out.println ( "arg_absolute_path_of_file_contains_image_data = "
	                                      + arg_absolute_path_of_file_contains_image_data  ) ;
      Process.wait_for_push_enter_key ( )   ;
	  }
 }
//----------------------------------------------
public  BufferedImage  get_BufferedImage_of_contained_image_data  ( ) {

	return   cv_ins_BufferedImage_of_contained_image_data ;
 }
//======================================================	
}
//======================================================
class HandleTextData {

  private  String cv_this_class_name = "HandleTextData" ;

  private ArrayList <TextOneLineContained>  cv_ArrayList_TextOneLineContained ;
  private  int  cv_number_of_contained_TextOneLine ;
  private  String  cv_ins_String_one_line_readed  ;
  private  BufferedReader  cv_ins_BufferedReader ;
  private  String  cv_absolute_path_of_file_contains_text_data ;
//-----------------------------------------------------	
	              // constructer
public HandleTextData (
	                      String  arg_absolute_path_of_file_contains_text_data
	                                            ) {
	                                            
  String    this_methode_name = "constructer" ;
  
  cv_absolute_path_of_file_contains_text_data
            = arg_absolute_path_of_file_contains_text_data ;
  
  cv_ArrayList_TextOneLineContained = new ArrayList <TextOneLineContained> () ;

  try {  
    FileReader  ins_FileReader  = new FileReader
                                ( cv_absolute_path_of_file_contains_text_data ) ;
    cv_ins_BufferedReader  = new  BufferedReader  ( ins_FileReader ) ;
  }
 catch ( IOException  arg_ins_IOException ) {
     System.out.println ( "===== Error !!!!!!!! ========================" ) ;	   
	 System.out.println ( " Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
	  System.out.println ( "cv_absolute_path_of_file_contains_text_data = "
	                                      + cv_absolute_path_of_file_contains_text_data  ) ;
      Process.wait_for_push_enter_key ( )   ;
	  }  

  cv_number_of_contained_TextOneLine = 0 ;
  
  char  result_of_reading = 'Y' ;

  char  process_continue = 'Y' ;
  while  ( 	process_continue == 'Y' ) {
      result_of_reading = read_one_line_from_file ( ) ;

      if ( result_of_reading != 'Y' ) {
          process_continue = 'N' ;
          break ;
       }
    }
    
  System.out.println ( "****************************************" ) ;	   
  System.out.println ( "Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
  System.out.println ( "cv_absolute_path_of_file_contains_text_data = "
	                                      + cv_absolute_path_of_file_contains_text_data  ) ;
  System.out.println ( cv_number_of_contained_TextOneLine
	                                       + " text lines have been gotten" ) ;

      //Process.wait_for_push_enter_key ( )   ;
}
//-------------------------------------------
private  char  read_one_line_from_file ( ) {

  String  this_methode_name = "read_one_line_from_file " ;

  char  return_value = 'N' ;
  TextOneLineContained  ins_TextOneLineContained ;
  
  try {
     cv_ins_String_one_line_readed
                = cv_ins_BufferedReader
                                .readLine ( ) ;
     if (   cv_ins_String_one_line_readed == null ) {
       return_value = 'E' ;      //reached to data end
      }
     else {
        ins_TextOneLineContained 
             = new TextOneLineContained ( cv_ins_String_one_line_readed ) ;
      	cv_ArrayList_TextOneLineContained
                 .add ( ins_TextOneLineContained  ) ;
       return_value = 'Y' ;      //one line text data readed       
     }                              
   }
 catch ( IOException  arg_ins_IOException ) {
     System.out.println ( "===== Error !!!!!!!! ========================" ) ;	   
	 System.out.println ( " Class : "   + cv_this_class_name
		                                   +   " , Methode : " + this_methode_name ) ;
	  System.out.println ( "cv_absolute_path_of_file_contains_text_data = "
	                                      + cv_absolute_path_of_file_contains_text_data  ) ;
      Process.wait_for_push_enter_key ( )   ;
	 }

  return return_value ;	  
 }
//-----------------------------------------------
  public  int  get_number_of_contained_TextOneLine ( ) { 
 
     return  cv_ArrayList_TextOneLineContained
                                     .size () ;
  }
//------------------------------------------ 
public  String  get_one_text_line_readed ( int arg_order_number_of_line ) {

  TextOneLineContained  ins_TextOneLineContained 
                 =  cv_ArrayList_TextOneLineContained
                                  .get ( arg_order_number_of_line - 1 ) ;
  return  ins_TextOneLineContained.cv_ins_String_one_line_text ;
}
//======================================================	
}
//======================================================
class  TextOneLineContained {

  public  String  cv_ins_String_one_line_text ;
  
  	              // constructer
public  TextOneLineContained ( String  arg_ins_String  ) {
	                                            
  cv_ins_String_one_line_text = arg_ins_String ;
}
//======================================================	
}
//======================================================


//==============================================
class  DisplayImage {

    private  JFrame   cv_ins_JFrame ;
     private  JPanelForDisplay   cv_ins_JPanelForDisplay  ;
    
    //-------------------------------------------------
     // constructer
    //-------------------------------------------------
public DisplayImage ( ) {
	
            cv_ins_JFrame = new JFrame ( "Display" ) ;
            cv_ins_JFrame
                        .setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ;

            cv_ins_JPanelForDisplay  = new JPanelForDisplay  ( ) ; 
            cv_ins_JFrame.add ( cv_ins_JPanelForDisplay ) ;
            cv_ins_JFrame.pack ( );
            cv_ins_JFrame.setSize (
                                            ( ContainParameters.cv_width_of_DisplayImage + 50 )	  
	                                      , ( ContainParameters.cv_height_of_DisplayImage + 100 ) 
                                                       ) ;
            cv_ins_JFrame.setVisible ( true ) ;
	       }
	     //-------------------------------------------------
	     public void do_repaint ( ) {  

	       	    cv_ins_JPanelForDisplay
	       	           .repaint ( ) ;
	     }
	     //---------------------------------------------
      }
//=============================== 
class  JPanelForDisplay  extends JPanel {

//-----------------------------------
public  void paintComponent ( Graphics  arg_ins_Graphics ) {
      
  super.paintComponent ( arg_ins_Graphics ) ;
  
  draw_backgound_area ( arg_ins_Graphics ) ;
  draw_message_area ( arg_ins_Graphics ) ;
  if ( AreaForTransferOfIinformation.cv_phase_number == 2 ) {
     draw_mark_area ( arg_ins_Graphics ) ;
  }
}
//--------------------------------------------------
private void  draw_backgound_area  ( Graphics  arg_ins_Graphics ) {          

  Color  ins_Color_background = new Color (
                           ContainParameters.cv_Color_background_R
                         , ContainParameters.cv_Color_background_G
                         , ContainParameters.cv_Color_background_B ) ;
  arg_ins_Graphics.setColor  ( ins_Color_background ) ;
               
  arg_ins_Graphics
                          .fillRect (  ContainParameters.cv_margin_of_DisplayImage_Frame
                                           , ContainParameters.cv_margin_of_DisplayImage_Frame
                                           , ContainParameters.cv_width_of_mark_display_area
                                           , ContainParameters.cv_height_of_DisplayImage
                                          ) ;
}
//--------------------------------------------------
private void  draw_message_area  ( Graphics  arg_ins_Graphics ) {
 
  Color  ins_Color_display_text = new Color (
                           ContainParameters.cv_Color_display_text_R
                         , ContainParameters.cv_Color_display_text_G
                         , ContainParameters.cv_Color_display_text_B ) ;
  arg_ins_Graphics.setColor  ( ins_Color_display_text ) ;
               
  int font_size = ContainParameters.cv_height_of_message_one_line - 4 ;
  Font  ins_Font = new Font ( "Arial" ,  Font.PLAIN , font_size ) ;
  arg_ins_Graphics.setFont (  ins_Font ) ;
              
  int  location_x = ContainParameters.cv_margin_of_DisplayImage_Frame ;
  int  location_y = 0 ;
  
  HandleTextData  ins_HandleTextData
         = AreaForTransferOfIinformation.cv_array_HandleTextData
                 [ AreaForTransferOfIinformation.cv_phase_number - 1 ] ;
  int number_of_contained_TextOneLine
               = ins_HandleTextData.get_number_of_contained_TextOneLine ( ) ;
   String  ins_String_TextOneLine ;            
  for ( int row_of_display_message = 1
                             ; row_of_display_message <= number_of_contained_TextOneLine
                              ; row_of_display_message += 1 ) {
      ins_String_TextOneLine
             =  ins_HandleTextData        
                           .get_one_text_line_readed ( row_of_display_message ) ;
      location_y = ( ContainParameters.cv_begin_Y_of_display_message 
                                                    +
                                                     ( ContainParameters.cv_height_of_message_one_line
                                                       * row_of_display_message )
                                                       ) ; 
	arg_ins_Graphics.drawString (
		                        ins_String_TextOneLine
		                     ,  location_x  ,  location_y ) ;
   }
  }
//--------------------------------------------------
private void  draw_mark_area  ( Graphics  arg_ins_Graphics ) { 
 
    BufferedImage  ins_BufferedImage ;
    int  figure_type  ;
    HandleImageData  ins_HandleImageData ;
    int  figure_set_location_X ;
    int  figure_set_location_Y ;
    
    int number_of_marks_for_display
                    = AreaForTransferOfIinformation                     
                                .cv_array_number_of_all_figure_for_each_trial
                            [ AreaForTransferOfIinformation.cv_current_trial_number - 1 ] ;
    for ( int order_number_of_mark = 1
                         ;  order_number_of_mark <= number_of_marks_for_display
                         ;   order_number_of_mark += 1 ) {
        figure_type =  AreaForTransferOfIinformation
                                               .cv_array_type_of_figure
                                          [ AreaForTransferOfIinformation.cv_current_trial_number - 1 ]
                                          [ order_number_of_mark - 1 ] ;
        ins_HandleImageData = AreaForTransferOfIinformation
                                                              .cv_array_HandleImageData
                                            [ figure_type - 1 ] ;
	   ins_BufferedImage = ins_HandleImageData
	                        .get_BufferedImage_of_contained_image_data  ( ) ;
	   figure_set_location_X = AreaForTransferOfIinformation
	                                                      .cv_array_figure_set_location_X
                                          [ AreaForTransferOfIinformation.cv_current_trial_number - 1 ]
                                          [ order_number_of_mark - 1 ] ;
       figure_set_location_Y = AreaForTransferOfIinformation
                                                          .cv_array_figure_set_location_Y
                                          [ AreaForTransferOfIinformation.cv_current_trial_number - 1 ]
                                          [ order_number_of_mark - 1 ] ;
                   //----------------------------------------------                       
      arg_ins_Graphics
                  .drawImage ( ins_BufferedImage
                                              , figure_set_location_X
                                              , figure_set_location_Y
                                              , ContainParameters.cv_width_of_mark
                                              , ContainParameters.cv_height_of_mark
                                              , this ) ;
      }
    }
//==============================================
}
//===========================================

Cognition of Number, Index, 数に関する認知, インデックス へ

いいなと思ったら応援しよう!