//
// Core Program for TETDM 
// SettingData.java Version 1.00
// Copyright(C) 2011-2018 TETDM CORE MEMBER ALL RIGHTS RESERVED.
// This program is provided under the license.
//

package source;

import source.TextData.*;

import java.io.*;
import java.util.*;

import javax.swing.UIManager;
import java.awt.Font;
import java.awt.*;

public class SettingData
{
	public String guideComments[];
	
	public String kind_nouns[];	//Part of speech without conjugation
	public String kind_verbs[];	//Part of speech with conjugation
	public String kind_touns[];	//Period/Cut points of sentences
	public String kind_nonNoises[];	//Non Stop words
	public String kind_noises[];	//Noise/Stop words
	public String unknown;			//Unknown words
	public String segment_tag;		//Tag for cutting segments
	public String kind_objects[];	//Subject words/Nominative
	public String kind_objects_speech[];	//Part of speech for subject	
	public String kind_speech[];	//All Part of speech
    
    public String tempNoises[];     //Temporary Noise/Stop words
    public int tempNoiseNumber = 0;
    
    public int minimumFrequency = 1;    //NEW KEYWORD SETTING
    
    public boolean leftTags = false;
	
	public String settingLines[];

	int comments=14;
	
	public int nouns=0;
	public int verbs=0;
	public int touns=0;
	public int nonNoises=0;
	public int noises=0;
	public int objects=0;
	
	int speeches = 9;//kind number of part of speech
	int settings = 8;
	
	
	public String miningLines[];
	public String visualizationLines[];	
	
	int miningLineNumber = 0;
	int visualizationLineNumber = 0;	
	
    //for setting panels
	public String panelCombinationLines[];
	public int panels = 0;
	final int MAX_PANELS = 10;
	public int miningID[];
	public int visualizationID[];
    public int textID[];
	public int balancedPanelSizeX[];

	
	//for backup
    public int lastMiningID[];
    public int lastVisualizationID[];
	public int lastTextID[];
	public int lastBalancedPanelSizeX[];
    
	public boolean isWindows;
	public boolean isEnglish = false;
	public boolean isCsv = false;
//	public String defaultCode = "EUC-JP";		//Japanese code for ChaSen, MAC:EUC-JP, WIN:SJIS
	public String fontName = "Dialog";
    public int fontSize = 0;
    public int toolFontSize = 14;
	String chasenPath;
    public String dictionaryPath;
//	boolean chasenexe = true;
//    public String morpheme;// = "Igo";
    
 //   String defaultChasenPath = "/opt/local/bin";
	
	public boolean excludeHiragana = true;
	public boolean excludeKatakana = true;
	public boolean excludeOne = true;
	public boolean excludeHankaku = false;
	
	public boolean inJapanese = true;


	public ModuleData readModuleData;
	
	String settingFileName;
	String activationFileName;
	
	String absolutePath;
	
	//Mode
    public boolean firstTime = true;
    
	public int mode = 0;	//0:SuperLight, 1:Light, 2:Normal, 3:Advanced
	
	public boolean gameMode = false;
    
    public boolean navigation = false;
	
	public boolean controlButtons[];
	public boolean selectButtons[];
	public boolean miningButtons[];
	
	public final int buttonNumbers = 28;    //control button number
    
    public int windowSizeX = 1024, windowSizeY = 768;
    public int popSizeY = 65;
	
	public SettingData(String settingFile, ModuleData readModuleD)
	{
		settingFileName = settingFile;
		readModuleData = readModuleD;
		absolutePath = readModuleData.absolutePath;
		
		miningID = new int[MAX_PANELS];
		visualizationID = new int[MAX_PANELS];
        textID = new int[MAX_PANELS];
		balancedPanelSizeX = new int[MAX_PANELS];
		
		//Mode Setting
		controlButtons = new boolean[buttonNumbers];
		selectButtons = new boolean[4];
		miningButtons = new boolean[8];
		
		readSettingFile(new File(settingFileName));
		activationFileName = absolutePath+"activation.conf";
		readActivationFile(new File(activationFileName));		
		
		setMode();
		
		String osname = System.getProperty("os.name");
		if(osname.indexOf("Windows")>=0)
		{
			isWindows = true;
			//fontName = "MS Gothic";
			fontName = "Meiryo UI";
			try{
				UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
			}catch(Exception ex){
				System.out.println("Error L&F Setting");
			}			
		}
		else
		{
			isWindows = false;
			fontName = "Dialog";	
		}
		
		setDefaultFont();
		
//		if(isWindows)
//			defaultCode = "SJIS";
        
  //      System.out.println("DefaultCode= "+defaultCode);
	}
	
	public void setMode()
	{
		switch(mode)
		{
				//super light
			case 0:		boolean superLightModeControl[] = {false,false,false,false,false,
														false,true,false,false,false,
														false,true,true,false,false,
														false,false,false,true,true,
														false,true,false,true,true,
                                                        true,true,false};
						boolean superLightModeSelect[] = {false,false,true,false};
						boolean superLightModeMining[] = {false,false,false,true,true,false,false,false};
				
						for(int i=0;i<buttonNumbers;i++)
							controlButtons[i] = superLightModeControl[i];							
						for(int i=0;i<4;i++)
							selectButtons[i] = superLightModeSelect[i];		
						for(int i=0;i<8;i++)
							miningButtons[i] = superLightModeMining[i];
						break;
				
				//light
			case 1:		boolean lightModeControl[] = {false,false,false,false,false,
														false,true,false,false,true,
														true,true,true,false,false,
														false,false,true,true,true,
														true,true,false,true,true,
                                                        true,true,true};
						boolean lightModeSelect[] = {false,false,true,false};
						boolean lightModeMining[] = {true,true,true,true,true,true,false,false};

						for(int i=0;i<buttonNumbers;i++)
							controlButtons[i] = lightModeControl[i];							
						for(int i=0;i<4;i++)
							selectButtons[i] = lightModeSelect[i];		
						for(int i=0;i<8;i++)
							miningButtons[i] = lightModeMining[i];
						break;
				
				//public
			case 2:		boolean publicModeControl[] = {true,false,true,false,false,
														false,true,true,false,true,
														true,true,true,false,false,
														true,true,true,true,true,
														true,true,true,true,true,
                                                        true,true,true};
						boolean publicModeSelect[] = {false,false,true,false};
						boolean publicModeMining[] = {true,true,true,true,true,true,false,false};
				
						for(int i=0;i<buttonNumbers;i++)
							controlButtons[i] = publicModeControl[i];							
						for(int i=0;i<4;i++)
							selectButtons[i] = publicModeSelect[i];		
						for(int i=0;i<8;i++)
							miningButtons[i] = publicModeMining[i];
						break;				
				
				//all
			case 3:		for(int i=0;i<buttonNumbers;i++)
							controlButtons[i] = true;
						controlButtons[4] = false; /////
                        controlButtons[8] = false; ///// image
                        controlButtons[13] = false; /////
                        controlButtons[14] = false; /////
						for(int i=0;i<4;i++)
							selectButtons[i] = true;
                        selectButtons[3] = false; /////
						for(int i=0;i<8;i++)
							miningButtons[i] = true;
                
                        miningButtons[6] = false; ///// partial
						miningButtons[7] = false; ///// diff

				
						break;
		}
	}
	
	public void setDefaultFont()
	{
		GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
		DisplayMode displayMode = env.getDefaultScreenDevice().getDisplayMode();		
		
		int displaySize = displayMode.getWidth();		
		
		Font font;
		
        if(fontSize == 0)
        {
            if(displaySize <= 1024)
                fontSize = 8;
            else if(displaySize <= 1280)
                fontSize = 10;
            else if(displaySize <= 1600)
                fontSize = 12;
            else
                fontSize = 14;
        }
        
        font = new Font(fontName, Font.PLAIN, fontSize);
		
		Enumeration<Object> enumeration = UIManager.getDefaults().keys();
		
		while(enumeration.hasMoreElements())
		{
			Object key = enumeration.nextElement();
			Object value = UIManager.get(key);
		
			if (value instanceof java.awt.Font)
			{
				UIManager.put(key.toString(), font);
			}
		}
		
		/*
		UIManager.put("ToggleButton.font",new Font(fontName,Font.PLAIN,12));		
		UIManager.put("Button.font",new Font(fontName,Font.PLAIN,12));
		UIManager.put("TextPane.font",new Font(fontName,Font.PLAIN,12));	
		*/
		
	}	
	
	public void readSettingFile(File settingFile)
	{
		String speechtext = FILEIO.TextFileAllReadCode(settingFile);
		
		count_numbers(speechtext);
		init_arrays();
		read_texts(speechtext);
		
		setModuleSettings();
		
		String words[];
	/*	 = settingLines[2].split(" ");
//        if(words.length == 1)
//            chasenexe = false;
 //       else
   //     {
    //        chasenexe = true;
      //      morpheme = words[1];
      //  }
        
        //chasenPath
		words = settingLines[3].split(" ");
        if(words.length == 1)
        {
   //         if(morpheme.equals("ChaSen"))
     //           chasenPath = defaultChasenPath;
       //     else
                chasenPath = absolutePath;
        }
        else
            chasenPath = words[1];
        
        //dictionaryPath        
		words = settingLines[4].split(" ");
        if(words.length == 1)
            dictionaryPath = absolutePath;
        else
            dictionaryPath = words[1];
        */
		
		chasenPath = absolutePath;
		dictionaryPath = absolutePath;
		
		words = settingLines[2].split(" ");
		excludeHiragana = words[1].equals("true");
		words = settingLines[3].split(" ");
		excludeKatakana = words[1].equals("true");		
		words = settingLines[4].split(" ");
		excludeOne = words[1].equals("true");
		words = settingLines[5].split(" ");
		excludeHankaku = words[1].equals("true");		
		words = settingLines[6].split(" ");
		inJapanese = words[1].equals("true");
		words = settingLines[7].split(" ");
		leftTags = words[1].equals("true");	
	}
	
	public void readActivationFile(File activationFile)
	{

		String speechtext = FILEIO.TextFileAllReadCode(activationFile);
		String ss;
		
		try
		{
			BufferedReader br1 = new BufferedReader(new StringReader(speechtext));
//			
            //activation
            ss = br1.readLine();
            String lineData[] = br1.readLine().split(" ");
            firstTime = lineData[1].equals("true");
            
            
            ss = br1.readLine();
            lineData = br1.readLine().split(" ");
			panels = Integer.parseInt(lineData[1]);
			
			panelCombinationLines = new String[panels];

			
			for(int i=0;i<panels;i++)
			{
				panelCombinationLines[i] = br1.readLine();
				lineData = panelCombinationLines[i].split(" ");
				miningID[i] = Integer.parseInt(lineData[0]);
				visualizationID[i] = Integer.parseInt(lineData[1]);
			}
		
			ss = br1.readLine();			
			lineData = br1.readLine().split(" ");
			if(lineData.length < panels || lineData[0].charAt(0) == '#')
				for(int i=0;i<panels;i++)
					balancedPanelSizeX[i] = 1;
			else 
				for(int i=0;i<panels;i++)
					balancedPanelSizeX[i] = Integer.parseInt(lineData[i]);
			
			ss = br1.readLine();
			lineData = br1.readLine().split(" ");
			mode = Integer.parseInt(lineData[1]);
			
			ss = br1.readLine();
			lineData = br1.readLine().split(" ");
			gameMode = lineData[1].equals("true");
            
            ss = br1.readLine();
            lineData = br1.readLine().split(" ");
            navigation = lineData[1].equals("true");
            
            ss = br1.readLine();
            lineData = br1.readLine().split(" ");
            {
                int X = Integer.parseInt(lineData[0]);
                int Y = Integer.parseInt(lineData[1]);
                if(X >= 0 && Y >= 0)
                {
                    windowSizeX = X;
                    windowSizeY = Y;
                }
            }
            
            ss = br1.readLine();
            lineData = br1.readLine().split(" ");
            {
                int f = Integer.parseInt(lineData[1]);
                if(f >= 0)
                    fontSize = f;
            }
		}
		catch(Exception e){
			System.out.println("Text Reading ERROR activation.conf");
		}
	}	

    
	public void readOriginalSettingFile()
	{
		readSettingFile(new File(settingFileName+".original"));
		readActivationFile(new File(activationFileName+".original"));		
	}

	public void count_numbers(String speechtext)
	{
		String ss;
		int count=0, n=0;
		
		int comm = 0;
		guideComments = new String[comments];		

		try
		{
			BufferedReader br1 = new BufferedReader(new StringReader(speechtext));

			while((ss = br1.readLine()) != null && comm < 14)
				if(ss.charAt(0) == '#')
				{
					guideComments[comm++] = ss;					
					switch(count)
					{
						case 1:nouns = n;
							break;
						case 2:verbs = n;
							break;
						case 3:touns = n;
							break;
						case 4:nonNoises = n;
							break;							
						case 5:noises = n;
							break;
						case 8:objects = n;
							break;
						case 11:miningLineNumber = n;
							break;
						case 12:visualizationLineNumber = n;
							break;
//						case 13:panels = n;
//							break;							
					}
					count++;
					n=0;
				}
				else
					n++;
		}
		catch(Exception e){
			System.out.println("Text Reading ERROR speechtext1");
		}
	}

	public void init_arrays()
	{
		kind_nouns = new String[nouns];
		kind_verbs = new String[verbs];
		kind_touns = new String[touns];
		kind_nonNoises = new String[nonNoises];
		kind_noises = new String[noises];
		kind_objects = new String[objects];
		kind_objects_speech = new String[objects];
		
		kind_speech = new String[speeches];
		
		settingLines = new String[settings];
		
		miningLines = new String[miningLineNumber];
		visualizationLines = new String[visualizationLineNumber];
		
//		panels--;
//		panelCombinationLines = new String[panels];
	}

	public void read_texts(String speechtext)
	{
		String ss;

		try
		{
			BufferedReader br1 = new BufferedReader(new StringReader(speechtext));

			ss = br1.readLine();
			for(int i=0;i<nouns;i++)
				kind_nouns[i] = br1.readLine();

			ss = br1.readLine();
			for(int i=0;i<verbs;i++)
				kind_verbs[i] = br1.readLine();

			ss = br1.readLine();
			for(int i=0;i<touns;i++)
				kind_touns[i] = br1.readLine();

			ss = br1.readLine();
			for(int i=0;i<nonNoises;i++)
				kind_nonNoises[i] = br1.readLine();			
			
			ss = br1.readLine();
			for(int i=0;i<noises;i++)
				kind_noises[i] = br1.readLine();

			ss = br1.readLine();
			unknown = br1.readLine();

			ss = br1.readLine();
			segment_tag = br1.readLine();

			ss = br1.readLine();
			for(int i=0;i<objects;i++)
			{
				String shugo[] = (br1.readLine()).split(" ");
				kind_objects[i] = shugo[0];
				kind_objects_speech[i] = shugo[1];
			}
			
			ss = br1.readLine();
			for(int i=0;i<speeches;i++)
				kind_speech[i] = br1.readLine();
			
			ss = br1.readLine();					
			for(int i=0;i<settings;i++)
				settingLines[i] = br1.readLine();
			
			ss = br1.readLine();
			for(int i=0;i<miningLineNumber;i++)
				miningLines[i] = br1.readLine();
			
			ss = br1.readLine();
			for(int i=0;i<visualizationLineNumber;i++)
				visualizationLines[i] = br1.readLine();
/*			
			ss = br1.readLine();
			ss = br1.readLine();
			for(int i=0;i<panels;i++)
			{
				panelCombinationLines[i] = br1.readLine();
				String lineData[] = panelCombinationLines[i].split(" ");
				miningID[i] = Integer.parseInt(lineData[0]);
				visualizationID[i] = Integer.parseInt(lineData[1]);
			}
			
			ss = br1.readLine();			
			String lineData[] = br1.readLine().split(" ");
			if(lineData.length < panels || lineData[0].charAt(0) == '#')
				for(int i=0;i<panels;i++)
					balancedPanelSizeX[i] = 1;
			else 
				for(int i=0;i<panels;i++)
					balancedPanelSizeX[i] = Integer.parseInt(lineData[i]);
			
			ss = br1.readLine();
			String lineData[] = br1.readLine().split(" ");
			mode = Integer.parseInt(lineData[1]);
			
			ss = br1.readLine();
			lineData = br1.readLine().split(" ");
			gameMode = lineData[1].equals("true");
 
*/ 
		}
		catch(Exception e){
			System.out.println("Text Reading ERROR speechtext2");
		}
	}
	/*
	public void modifyModuleSettings(int miningIndex, int visualizationID)
	{
		for(int i=0;i<moduleData.mining[miningIndex].pairingVisualizationID.length;i++)
			if(moduleData.mining[miningIndex].pairingVisualizationID[i] == visualizationID)
				return;
		
		int pairingIDs[] = new int[moduleData.mining[miningIndex].pairingVisualizationID.length + 1];
		
		for(int i=0;i<moduleData.mining[miningIndex].pairingVisualizationID.length;i++)
			pairingIDs[i] = moduleData.mining[miningIndex].pairingVisualizationID[i];
		pairingIDs[moduleData.mining[miningIndex].pairingVisualizationID.length] = visualizationID;
		
		moduleData.mining[miningIndex].pairingVisualizationID = new int[pairingIDs.length];
		for(int i=0;i<pairingIDs.length;i++)
			moduleData.mining[miningIndex].pairingVisualizationID[i] = pairingIDs[i];
	}
	*/
	
    public void resetTempNoise()
    {
        tempNoiseNumber = 0;
    }
    
    public void createTempNoiseByFrequency(KeywordData keyword[], int keywordNumber, int threashold)
    {
        int noiseIndex[] = new int[keywordNumber];
        tempNoiseNumber = 0;
        for(int i=0;i<keywordNumber;i++)
            if(keyword[i].frequency < threashold)
                noiseIndex[tempNoiseNumber++] = i;
        
        tempNoises = new String[tempNoiseNumber];
        for(int i=0;i<tempNoiseNumber;i++)
            tempNoises[i] = keyword[noiseIndex[i]].word;
    }
    
    
	public void setModuleSettings()
	{
		for(int i=0;i<miningLineNumber;i++)
		{
			String miningLineData[] = miningLines[i].split(" ");
			int id = Integer.parseInt(miningLineData[0]);
			int pairingIDs[] = new int[miningLineData.length - 4];
			for(int j=0;j<pairingIDs.length;j++)
				pairingIDs[j] = Integer.parseInt(miningLineData[j+2]);
			boolean selected = miningLineData[miningLineData.length - 2].equals("true");
			

			for(int j=0;j<readModuleData.module_names.length;j++)
				if(id == readModuleData.moduleIDs[j])
				{
					readModuleData.mining[j].pairingVisualizationID = new int[pairingIDs.length];
					for(int k=0;k<pairingIDs.length;k++)
						readModuleData.mining[j].pairingVisualizationID[k] = pairingIDs[k];
					readModuleData.setModuleIndex(j, readModuleData.mining[j].pairingVisualizationID);					
					
					if(pairingIDs.length == 0)
						selected = false;
					readModuleData.miningModuleSelection[j] = selected;
				}
			
//			String modeNumber[] = miningLines[i].split(" ");
		}
		
		for(int i=0;i<readModuleData.visu_module_names.length;i++)		
			readModuleData.createPairingMiningID(i);	
	}



	
	 

    public void createBackupID()
    {
        lastMiningID = new int[panels];
        lastVisualizationID = new int[panels];
		lastTextID = new int[panels];		
		lastBalancedPanelSizeX = new int[panels];
		
		System.out.println("*****CREATE BACKUP ID*****");
		
        for(int i=0;i<panels;i++)
            lastMiningID[i] = miningID[i];
        
        for(int i=0;i<panels;i++)
            lastVisualizationID[i] = visualizationID[i];
		
//        for(int i=0;i<panels;i++)
  //          lastTextID[i] = 0;
		
        for(int i=0;i<panels;i++)
            lastTextID[i] = textID[i];
		
        for(int i=0;i<panels;i++)
            lastBalancedPanelSizeX[i] = balancedPanelSizeX[i];		
    }
    
    public void createBackupTextID(int tID)
    {
        System.out.println("*****CREATE BACKUP Text ID*****");
        
        for(int i=0;i<lastTextID.length;i++)
            lastTextID[i] = tID;
    }

	/*   
    public void traceBackupID()
    {
        miningID = new int[lastMiningID.length];
        visualizationID = new int[lastVisualizationID.length];
        
        for(int i=0;i<lastMiningID.length;i++)
            miningID[i] = lastMiningID[i];
        
        for(int i=0;i<lastVisualizationID.length;i++)
            visualizationID[i] = lastVisualizationID[i];
    }
*/	
	public void writeToWriter(BufferedWriter bw1, String words)
	{
		try
		{	
//			System.out.println(""+words);
			bw1.write(words);
			bw1.newLine();
		}
		catch(Exception e){
			System.out.println("Text Writing ERROR saveSettingTexts for "+words);
		}		
	}
	
	public void saveActivationFile()
	{
		String saveSettingTexts = "";
		
		try
		{
			StringWriter sw1 = new StringWriter();
			BufferedWriter bw1 = new BufferedWriter(sw1);
			
            writeToWriter(bw1, "#firstActivation");
            writeToWriter(bw1, "firstTime= "+firstTime);
            
			writeToWriter(bw1, "#activation");
			writeToWriter(bw1, "panelNumber= "+panels);
			for(int i=0;i<panels;i++)
			{
				bw1.write(miningID[i]+" "+visualizationID[i]+" 0");
				bw1.newLine();
			}
			
			writeToWriter(bw1, "#Panel Balance");		
			for(int i=0;i<panels;i++)
				bw1.write(balancedPanelSizeX[i]+" ");
			bw1.newLine();	
			
			writeToWriter(bw1, "#Mode Number");
			writeToWriter(bw1, "Mode= "+mode);
			
			writeToWriter(bw1, "#Game Mode");
			writeToWriter(bw1, "GameMode= "+gameMode);
            
            writeToWriter(bw1, "#Navigation");
            writeToWriter(bw1, "Navigation= "+navigation);
			
            writeToWriter(bw1, "#Window Size");
            writeToWriter(bw1, windowSizeX+" "+windowSizeY);
            
            writeToWriter(bw1, "#Button Font Size");
            writeToWriter(bw1, "FontSize= "+fontSize);
            
			bw1.flush();
			sw1.flush();
			saveSettingTexts = sw1.toString();
			bw1.close();
			sw1.close();
		}
		catch(Exception e){
			System.out.println("Text Writing ERROR saveActivationFile");
		}
		FILEIO.TextFileWriteCode(new File(activationFileName), saveSettingTexts, "SJIS");
	}	
	
	public void saveSettingFile()
	{
		String saveSettingTexts = "";
		
		try
		{
			StringWriter sw1 = new StringWriter();
			BufferedWriter bw1 = new BufferedWriter(sw1);

			writeToWriter(bw1, guideComments[0]);
			for(int i=0;i<nouns;i++)
				writeToWriter(bw1, kind_nouns[i]);				

			writeToWriter(bw1, guideComments[1]);
			for(int i=0;i<verbs;i++)
				writeToWriter(bw1, kind_verbs[i]);				

			writeToWriter(bw1, guideComments[2]);			
			for(int i=0;i<touns;i++)
				writeToWriter(bw1, kind_touns[i]);				

			writeToWriter(bw1, guideComments[3]);
			for(int i=0;i<nonNoises;i++)
				writeToWriter(bw1, kind_nonNoises[i]);			
			
			writeToWriter(bw1, guideComments[4]);
			for(int i=0;i<noises;i++)
				writeToWriter(bw1, kind_noises[i]);				
			
			writeToWriter(bw1, guideComments[5]);
			writeToWriter(bw1, unknown);			

			writeToWriter(bw1, guideComments[6]);
			writeToWriter(bw1, segment_tag);	

			writeToWriter(bw1, guideComments[7]);
			for(int i=0;i<objects;i++)
				writeToWriter(bw1, kind_objects[i] +" "+kind_objects_speech[i]);
			
			writeToWriter(bw1, guideComments[8]);			
			for(int i=0;i<speeches;i++)
				writeToWriter(bw1, kind_speech[i]);

			writeToWriter(bw1, guideComments[9]);
			writeToWriter(bw1, "Windows= "+isWindows);
			writeToWriter(bw1, "English= "+isEnglish);
//			writeToWriter(bw1, "MorphemeAnalysisExecution= "+morpheme);
/*			writeToWriter(bw1, "MorphemeAnalysisExecution= ");			

            if(chasenPath.equals(absolutePath))
                writeToWriter(bw1, "MorphemeAnalysisPath= ");
            else
                writeToWriter(bw1, "MorphemeAnalysisPath= "+chasenPath);
            if(dictionaryPath.equals(absolutePath))
                writeToWriter(bw1, "MorphemeAnalysisDictionaryPath= ");
            else
                writeToWriter(bw1, "MorphemeAnalysisDictionaryPath= "+dictionaryPath);*/
//			writeToWriter(bw1, "ChaSenCode= "+defaultCode);
			writeToWriter(bw1, "ExcludeHiragana= "+excludeHiragana);
			writeToWriter(bw1, "ExcludeKatakana= "+excludeKatakana);
			writeToWriter(bw1, "ExcludeOne= "+excludeOne);
			writeToWriter(bw1, "ExcludeHankaku= "+excludeHankaku);			
			writeToWriter(bw1, "JapaneseMenu= "+inJapanese);
			writeToWriter(bw1, "LeftTags= "+leftTags);
					
			writeToWriter(bw1, guideComments[10]);
			for(int i=0;i<readModuleData.module_names.length;i++)
			{
				bw1.write(readModuleData.moduleIDs[i]+" "+readModuleData.module_names[i]+" ");
				for(int j=0;j<readModuleData.mining[i].pairingVisualizationID.length;j++)
					bw1.write(readModuleData.mining[i].pairingVisualizationID[j]+" ");
				bw1.write(readModuleData.miningModuleSelection[i]+" ]");				
				bw1.newLine();
			}

			writeToWriter(bw1, guideComments[11]);
			for(int i=0;i<readModuleData.visu_module_names.length;i++)
			{
				bw1.write(readModuleData.visuModuleIDs[i]+" "+readModuleData.visu_module_names[i]+" ");
				bw1.write(readModuleData.visualizationModuleSelection[i]+" ]");
				bw1.newLine();
			}
/*
			writeToWriter(bw1, guideComments[12]);
			writeToWriter(bw1, "panelNumber= "+panels);
			for(int i=0;i<panels;i++)
			{
				bw1.write(miningID[i]+" "+visualizationID[i]);
				bw1.newLine();
			}
			
			writeToWriter(bw1, "#Panel Balance");		
			for(int i=0;i<panels;i++)
				bw1.write(balancedPanelSizeX[i]+" ");
			bw1.newLine();
			
			writeToWriter(bw1, "#Mode Number");
			writeToWriter(bw1, "Mode= "+mode);
			
			writeToWriter(bw1, "#Game Mode");
			writeToWriter(bw1, "GameMode= "+gameMode);			
*/
			bw1.flush();
			sw1.flush();
			saveSettingTexts = sw1.toString();
			bw1.close();
			sw1.close();
		}
		catch(Exception e){
			System.out.println("Text Writing ERROR saveSettingTexts2");
		}
		FILEIO.TextFileWriteCode(new File(settingFileName), saveSettingTexts, "SJIS");
	}
}
