//
// Core Program for TETDM 
// VisualizationModule.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.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

import java.awt.image.*;
import javax.imageio.ImageIO;

public abstract class VisualizationModule extends JPanel implements MouseListener, MouseMotionListener, AdjustmentListener, MouseWheelListener
{
	private int moduleID = -1;
	private int categoryID = -1;
	private int useMode = 3;	
	private int panelID = -1;
	
	public int toolType = 4;//1:simple 2:primitive 3:semi-primitive 4:special
	
	public TextData text;
	
	public String myModulePath;
	public String myModuleName;
	
	boolean makePanel = true;
	boolean firstTime = true;
    
    public boolean cancelOperationPanel = false;

	public int oldSizeX, oldSizeY;
	public int sizeX=0, sizeY=0;
	public double changeX, changeY;

	public int pairingMiningIndex[];
	
//	public boolean panelCreated = false;
	
    //  FOR FOCUS
    public boolean focusSegments[];
    public boolean focusSentences[];
    public boolean focusKeywords[];
    
    //  FOR ATTENTION
    public boolean attentionSegments[];
    public boolean attentionSentences[];
    public boolean attentionKeywords[];
    
	//	FOR PROCESSING
	
	PopUpForProcessing processingPanel;
    
    //  FOR JAPANESE
    
    public String inJapanese[];
	
//	public boolean focusTouchDisplay = false;
//	public boolean focusClickDisplay = false;
	
	//-->public boolean focusDisplay = true;	
	
	public VisualizationModule(){}

	public final void setModuleID(int moduleID)
	{
		this.moduleID = moduleID;
	}	
	public final int getModuleID()
	{
		return moduleID;
	}
	public final void setCategoryID(int categoryID)
	{
		this.categoryID = categoryID;
	}	
	public final int getCategoryID()
	{
		return categoryID;
	}	
	public final void setUseMode(int useMode)
	{
		this.useMode = useMode;
	}	
	public final int getUseMode()
	{
		return useMode;
	}		
	public final void setPanelID(int panelID)
	{
		this.panelID = panelID;
	}
	public final int getPanelID()
	{
		return panelID;
	}	
	public final void setToolType(int type)
	{
		this.toolType = type;
	}
	public final int getToolType()
	{
		return toolType;
	}
    public final int getFontSize()
    {
        return text.control.sp1.toolFontSize;
    }
    
    public final void setInJapanese()
    {
        inJapanese = fileReadArray();
    }
    
	public final void initPanel()
	{
		setLayout(new BorderLayout());
		setBackground(Color.white);
 
        
		
		myModulePath = text.absolutePath + this.getClass().getPackage().getName().replaceAll("\\.","/") + File.separator;
		myModuleName = this.getClass().getPackage().getName().replaceAll("module\\.VisualizationModules\\.","");
        
        setInJapanese();        // JAPANESE
		
//		System.out.println("myModuleName= "+myModuleName);


		initializePanel();			// Step.3
		
		System.out.println(" + Visualization: "+this.getClass().getName());
        
        addMouseListener(this);
        addMouseMotionListener(this);
	}
	
	public final void selected(TextData tex)
	{
		text = tex;
		if(makePanel)
		{
			initPanel();			//(to Step.3)		
			makePanel = false;
		}
		initializeData();			// Step.4
	}
	
	//FOCUS
	public final void focusSelected(TextData tex)
	{
		text = tex;
		initializeData();			// Step.4
	}	

	public abstract void initializePanel();		// #Step.3
	public abstract void initializeData();				// #Step.4
	public abstract void displayOperations(int optionNumber);		// #Step.6

	public final void setData(){}		// for check only

    int booleanNumber = 0;
    int integerNumber = 0;
    int doubleNumber = 0;
    int StringNumber = 0;
    int booleanArrayNumber = 0;
    int integerArrayNumber = 0;
    int doubleArrayNumber = 0;
    int StringArrayNumber = 0;
    int booleanArray2Number = 0;
    int integerArray2Number = 0;
    int doubleArray2Number = 0;
    
    public int dataNumbers[] = {0,0,0,0,0,0,0,0,0,0,0};
    
    public boolean checkDataNumbers()
    {
        if(booleanNumber < dataNumbers[0]) return false;
        if(integerNumber < dataNumbers[1]) return false;
        if(doubleNumber < dataNumbers[2]) return false;
        if(StringNumber < dataNumbers[3]) return false;
        if(booleanArrayNumber < dataNumbers[4]) return false;
        if(integerArrayNumber < dataNumbers[5]) return false;
        if(doubleArrayNumber < dataNumbers[6]) return false;
        if(StringArrayNumber < dataNumbers[7]) return false;
        if(booleanArray2Number < dataNumbers[8]) return false;
        if(integerArray2Number < dataNumbers[9]) return false;
        if(doubleArray2Number < dataNumbers[10]) return false;

		if(dataConstraint() == false)
			return false;
		
        return true;
    }
	
	public boolean dataConstraint(){return true;}
    
    public void resetData()
    {
        booleanNumber = 0;
        integerNumber = 0;
        doubleNumber = 0;
        StringNumber = 0;
        booleanArrayNumber = 0;
        integerArrayNumber = 0;
        doubleArrayNumber = 0;
        StringArrayNumber = 0;
        booleanArray2Number = 0;
        integerArray2Number = 0;
        doubleArray2Number = 0;
    }

	public boolean setData(int dataID, boolean data){return false;}
	public boolean setData(int dataID, int data){return false;}
	public boolean setData(int dataID, double data){return false;}
	public boolean setData(int dataID, String data){return false;}
	public boolean setData(int dataID, boolean data[]){return false;}
	public boolean setData(int dataID, int data[]){return false;}
	public boolean setData(int dataID, double data[]){return false;}
	public boolean setData(int dataID, String data[]){return false;}	
	public boolean setData(int dataID, boolean data[][]){return false;}
	public boolean setData(int dataID, int data[][]){return false;}
	public boolean setData(int dataID, double data[][]){return false;}	

	final public boolean setData(boolean data){return false;}
	final public boolean setData(int data){return false;}
	final public boolean setData(double data){return false;}
	final public boolean setData(String data){return false;}
	final public boolean setData(boolean data[]){return false;}
	final public boolean setData(int data[]){return false;}
	final public boolean setData(double data[]){return false;}
	final public boolean setData(String data[]){return false;}
	final public boolean setData(boolean data[][]){return false;}
	final public boolean setData(int data[][]){return false;}
	final public boolean setData(double data[][]){return false;}
	
	//display for visualization
	public void setFont(){}
	
	public boolean getPanelSize()
	{
		boolean change = false;
		
		oldSizeX = sizeX;
		oldSizeY = sizeY;
		
		sizeX = getWidth();
		sizeY = getHeight();
		
		if(sizeX != oldSizeX || sizeY != oldSizeY)
			change = true;

		changeX = changeY = 1.0;
		if(oldSizeX != 0)
			changeX = sizeX / (double)oldSizeX;
		if(oldSizeY != 0)
			changeY = sizeY / (double)oldSizeY;
		
		return change;
	}
	
	public void imageCapture()
	{
		JFileChooser chooser = new JFileChooser(text.absolutePath);		
		BufferedImage image = null;
		
		try{
            text.control.mainf.toFront();
            
			Robot robo = new Robot();
			image = robo.createScreenCapture(new Rectangle(getLocationOnScreen(),getSize()));
		}
		catch(Exception e){}
		
		int result = chooser.showSaveDialog(this);
		File selectedFile = chooser.getSelectedFile();
		
		if(result == JFileChooser.APPROVE_OPTION)
			try{
				String filename = selectedFile.getName();
				if(filename.endsWith(".png") == false)
					filename += ".png";
				
				ImageIO.write(image,"png", new File(selectedFile.getParent(), filename));
			} 
			catch(Exception e){}	
	}
	
	public void imageCapture(String filename)
	{	
		BufferedImage image = null;
		
		try{
            text.control.mainf.toFront();
            
			Robot robo = new Robot();
			image = robo.createScreenCapture(new Rectangle(getLocationOnScreen(),getSize()));
		}
		catch(Exception e){}

		try{
				ImageIO.write(image,"png", new File(filename));
		} 
		catch(Exception e){}	
	}	
	
	public String fileRead()
	{	
		return FILEIO.TextFileAllReadCode(new File(myModulePath+"Japanese.txt"));
	}	
	
	public String fileRead(String filename)
	{	
		return FILEIO.TextFileAllReadCode(new File(filename));
	}
	
	public String[] fileReadArray()
	{
        System.out.println("-------"+myModulePath+"-----");
        
		return FILEIO.TextFileAllReadCodeArray(new File(myModulePath+"Japanese.txt"));
        
        
	}	
	
	public String[] fileReadArray(String filename)
	{	
		return FILEIO.TextFileAllReadCodeArray(new File(filename));
	}
	
	public void fileWrite(String filename, String writeText)
	{	
		FILEIO.TextFileWrite2(new File(filename), writeText);
	}
	
	public void fileWriteArray(String filename, String writeText[], int lineNumber)
	{	
		FILEIO.TextFileWrite(new File(filename), writeText, lineNumber);
	}
	
	//get setting information
	public final String getSegmentTag()
	{
		return text.control.sp1.segment_tag;
	}
	
	public final String getSentenceTag()
	{
		return text.control.sp1.kind_touns[0];
	}	
	
	//CREATE DICTIONARY
	public void createDictionary()// windows,  commandPath, dictionaryPath
	{
		EXECUTE.createDictionaryByIgo(text.control.sp1.isWindows, text.control.sp1.chasenPath, text.control.sp1.absolutePath);		
	}	

    
    //SET ATTENTION
    
    public void initializeAttentionSegments()
    {
        attentionSegments = new boolean[text.segmentNumber];
        for(int i=0;i<text.segmentNumber;i++)
            attentionSegments[i] = false;// LOCAL focus
    }
    
    public void initializeAttentionSentences()
    {
        attentionSentences = new boolean[text.sentenceNumber];
        for(int i=0;i<text.sentenceNumber;i++)
            attentionSentences[i] = false;// LOCAL focus
    }
    
    public void initializeAttentionKeywords()
    {
        attentionKeywords = new boolean[text.keywordNumber];
        for(int i=0;i<text.keywordNumber;i++)
            attentionKeywords[i] = false;// LOCAL focus
    }
    
    public void setAttentionKeywords()
    {
        text.attention.setAttentionKeywords(attentionKeywords);
    }
    
    public void setAttentionSegments()
    {
        text.attention.setAttentionSegments(attentionSegments);
    }
    
    public void setAttentionSentences()
    {
        text.attention.setAttentionSentences(attentionSentences);
    }
    
    
    //NEW FOCUS
    public final void setDisplayByFocus()
    {
        displayOperations(4500);
    }
    /*
	//FOCUS
	public final void setDisplayByTouchFocus()
	{
		displayOperations(4501);
	}
	//FOCUS		
	public final void setDisplayByClickFocus()
	{
		displayOperations(4502);
	}
	//FOCUS
	public final void setDisplayByTimingFocus()
	{
		displayOperations(4503);
	}		*/
	
	
    //NEW FOCUS
    protected final void repaintOthersByFocus()
    {
        if(panelID != 10000)
            text.control.setDisplayOthersByFocus(panelID);
    }
    //NEW FOCUS
    protected final void executeOthersByFocus()
    {
        if(panelID != 10000)
            text.control.resetSelectPanelDataByFocus(panelID);
    }
    //NEW FOCUS    ALL
    protected final void executeAllByFocus()
    {
        if(panelID != 10000)
            text.control.resetSelectPanelDataByFocusAll(panelID);
    }
    /*
	//FOCUS		
	protected final void repaintOthersByTouch()
	{
		text.control.setDisplayOthersByTouchFocus(panelID);
	}
	//FOCUS		
	protected final void repaintOthersByClick()
	{
		text.control.setDisplayOthersByClickFocus(panelID);		
	}
	//FOCUS		
	protected final void repaintOthersByTiming()
	{
		text.control.setDisplayOthersByTimingFocus(panelID);		
	}
     *//*
	//FOCUS
    protected final void executeOthersByTouch()
    {
		text.control.resetSelectPanelDataByTouchFocus(panelID);
    }
    //FOCUS
    protected final void executeOthersByClick()
    {
		text.control.resetSelectPanelDataByClickFocus(panelID);		
    }
    //FOCUS
    protected final void executeOthersByTiming()
    {
		text.control.resetSelectPanelDataByTimingFocus(panelID);		
    }	*//*
	//FOCUS	ALL		
	protected final void executeAllByTouch()
	{
		text.control.resetSelectPanelDataByTouchFocusAll(panelID);
	}
	//FOCUS	ALL		
	protected final void executeAllByClick()
	{
		text.control.resetSelectPanelDataByClickFocusAll(panelID);
	}
	//FOCUS	ALL		
	protected final void executeAllByTiming()
	{
		text.control.resetSelectPanelDataByTimingFocusAll(panelID);
	}	
	*/
	/*
    //FOCUS PARTIAL SEGMENTS
    public void createSegmentPartialData()
    {
        text.control.resetBySegmentPartialData(0);
    }
    //FOCUS PARTIAL SENTENCES
    public void createSentencePartialData()
    {
        text.control.resetBySentencePartialData(0);
    }
	*/
	
    //FOCUS PARTIAL SEGMENTS
    public void createSegmentPartialData(int number)
    {
        if(panelID != 10000)
            text.control.resetBySegmentPartialData(number);
    }
    //FOCUS PARTIAL SENTENCES
    public void createSentencePartialData(int number)
    {
        if(panelID != 10000)
            text.control.resetBySentencePartialData(number);
    }
    
    //SET FOCUS
    
    public void initializeFocusSegments()
    {
        focusSegments = new boolean[text.segmentNumber];
        for(int i=0;i<text.segmentNumber;i++)
            focusSegments[i] = false;// LOCAL focus
    }
    
    public void initializeFocusSentences()
    {
        focusSentences = new boolean[text.sentenceNumber];
        for(int i=0;i<text.sentenceNumber;i++)
            focusSentences[i] = false;// LOCAL focus
    }
    
    public void initializeFocusKeywords()
    {
        focusKeywords = new boolean[text.keywordNumber];
        for(int i=0;i<text.keywordNumber;i++)
            focusKeywords[i] = false;// LOCAL focus
    }
    
    
    public void setFocusSegments()
    {
        setFocusSegments(focusSegments);        // LOCAL focus
    }
    
    public void setFocusSentences()
    {
        setFocusSentences(focusSentences);// LOCAL focus
    }
    
    public void setFocusKeywords()
    {
        setFocusKeywords(focusKeywords);// LOCAL focus
    }
    
    public void setFocusSegments(boolean value[])
    {
        if(panelID != 10000)
            text.focus.setFocusSegments(2, moduleID, value, "","", true);
        else
            text.focus.setFocusSegments(2, moduleID, value, "","", false);
    }
    public void setFocusSentences(boolean value[])
    {
        if(panelID != 10000)
            text.focus.setFocusSentences(2, moduleID, value, "","", true);
        else
            text.focus.setFocusSentences(2, moduleID, value, "","", false);
    }
    public void setFocusKeywords(boolean value[])
    {
        if(panelID != 10000)
            text.focus.setFocusKeywords(2, moduleID, value, "","", true);
        else
            text.focus.setFocusKeywords(2, moduleID, value, "","", false);
    }
    /*
    private void setOriginalFocusSegments(boolean value[])
    {
        text.control.text.focus.setFocusSegments(2, moduleID, value, "","",false);
    }
    private void setOriginalFocusSentences(boolean value[])
    {
        text.control.text.focus.setFocusSentences(2, moduleID, value, "","",false);
    }
    private void setOriginalFocusKeywords(boolean value[])
    {
        text.control.text.focus.setFocusKeywords(2, moduleID, value, "","",false);
    }*/
    /*
    public void setMainFocusKeyword(int value)
    {
        if(panelID != 10000)
            text.focus.setMainFocusKeyword(value);
    }
    public void setSubFocusKeyword(int value)
    {
        if(panelID != 10000)
            text.focus.setSubFocusKeyword(value);
    }
    public void setMainFocusSegment(int value)
    {
        if(panelID != 10000)
            text.focus.setMainFocusSegment(value);
    }
    public void setSubFocusSegment(int value)
    {
        if(panelID != 10000)
            text.focus.setSubFocusSegment(value);
    }
    public void setMainFocusSentence(int value)
    {
        if(panelID != 10000)
            text.focus.setMainFocusSentence(value);
    }
    public void setSubFocusSentence(int value)
    {
        if(panelID != 10000)
            text.focus.setSubFocusSentence(value);
    }
    */
    
    public void resetAllFocus()
    {
        text.control.text.focus.clearAllFocus();
    }
    
    public void resetMainSub()
    {
        text.control.text.focus.clearMainSub();
    }
    
    public void setMainFocusKeyword(int value, boolean only)
    {
        if(panelID != 10000)
        {
            if(text.textID != 0)
                text.control.text.focus.setMainFocusKeyword(2, moduleID, value, "","", only, false);
            
            text.focus.setMainFocusKeyword(2, moduleID, value, "","", only, true);
        }
    }
    public void setSubFocusKeyword(int value, boolean only)
    {
        if(panelID != 10000)
        {
            if(text.textID != 0)
                text.control.text.focus.setSubFocusKeyword(2, moduleID, value, "","", only, false);
            
            text.focus.setSubFocusKeyword(2, moduleID, value, "","", only, true);
        }
    }
    public void setMainFocusSegment(int value, boolean only)
    {
        if(panelID != 10000)
        {
            if(text.textID != 0)
                text.control.text.focus.setMainFocusSegment(2, moduleID, text.originalSegmentNumbers[value], "","", only, false);
            
            text.focus.setMainFocusSegment(2, moduleID, value, "","", only, true);
        }
    }
    public void setSubFocusSegment(int value, boolean only)
    {
        if(panelID != 10000)
        {
            if(text.textID != 0)
                text.control.text.focus.setSubFocusSegment(2, moduleID, text.originalSegmentNumbers[value], "","", only, false);
            
            text.focus.setSubFocusSegment(2, moduleID, value, "","", only, true);
        }
    }
    public void setMainFocusSentence(int value, boolean only)
    {
        if(panelID != 10000)
        {
            if(text.textID != 0)
                text.control.text.focus.setMainFocusSentence(2, moduleID, text.originalSentenceNumbers[value], "","", only, false);
            
            text.focus.setMainFocusSentence(2, moduleID, value, "","", only, true);
        }
    }
    public void setSubFocusSentence(int value, boolean only)
    {
        if(panelID != 10000)
        {
            if(text.textID != 0)
                text.control.text.focus.setSubFocusSentence(2, moduleID, text.originalSentenceNumbers[value], "","", only, false);
            
            text.focus.setSubFocusSentence(2, moduleID, value, "","", only, true);
        }
    }
    
    
    
    public boolean[] getFocusKeywords()
    {
        return text.focus.getFocusKeywords();
    }
    public boolean[] getFocusSegments()
    {
        return text.focus.getFocusSegments();
    }
    public boolean[] getFocusSentences()
    {
        return text.focus.getFocusSentences();
    }
    
    public int getMainFocusKeyword()
    {
        return text.focus.getMainFocusKeyword();
    }
    public int getSubFocusKeyword()
    {
        return text.focus.getSubFocusKeyword();
    }
    public int getMainFocusSegment()
    {
        return text.focus.getMainFocusSegment();
    }
    public int getSubFocusSegment()
    {
        return text.focus.getSubFocusSegment();
    }
    public int getMainFocusSentence()
    {
        return text.focus.getMainFocusSentence();
    }
    public int getSubFocusSentence()
    {
        return text.focus.getSubFocusSentence();
    }
    
    
    public int getFocusStatus(int dataNumber)
    {
        return text.focus.getFocusStatus(dataNumber);
    }
    
    //FOCUS SHRINK CONTROL
    
    public void shrinkReset()
    {
        text.control.btd2.doClick();
    }
    
    public void shrinkExecute()  //MUST BE USED WITH shrinkReset
    {
        text.control.btd1.doClick();
    }
    
    
    
    // FOCUS CONTROL
    
    public void setMainFocusBoolean(boolean value)
    {
        if(panelID != 10000)
            text.control.focus.mainFocusBoolean = value;
    }
    public void setSubFocusBoolean(boolean value)
    {
        if(panelID != 10000)
            text.control.focus.subFocusBoolean = value;
    }
    public void setMainFocusInteger(int value)
    {
        if(panelID != 10000)
            text.control.focus.mainFocusInteger = value;
    }
    public void setSubFocusInteger(int value)
    {
        if(panelID != 10000)
            text.control.focus.subFocusInteger = value;
    }
    public void setMainFocusDouble(double value)
    {
        if(panelID != 10000)
            text.control.focus.mainFocusDouble = value;
    }
    public void setSubFocusDouble(double value)
    {
        if(panelID != 10000)
            text.control.focus.subFocusDouble = value;
    }
    public void setMainFocusString(String value)
    {
        if(panelID != 10000)
            text.control.focus.mainFocusString = value;
    }
    public void setSubFocusString(String value)
    {
        if(panelID != 10000)
            text.control.focus.subFocusString = value;
    }
    
    public void setFocusBooleanArray(boolean values[])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusBooleanArray = new boolean[values.length];
        for(int i=0;i<values.length;i++)
            text.control.focus.focusBooleanArray[i] = values[i];
    }
    public void setFocusIntegerArray(int values[])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusIntegerArray = new int[values.length];
        for(int i=0;i<values.length;i++)
            text.control.focus.focusIntegerArray[i] = values[i];
    }
    public void setFocusDoubleArray(double values[])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusDoubleArray = new double[values.length];
        for(int i=0;i<values.length;i++)
            text.control.focus.focusDoubleArray[i] = values[i];
    }
    public void setFocusStringArray(String values[])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusStringArray = new String[values.length];
        for(int i=0;i<values.length;i++)
            text.control.focus.focusStringArray[i] = values[i];
    }
    
    public void setFocusBooleanArray2(boolean values[][])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusBooleanArray2 = new boolean[values.length][];
        for(int i=0;i<values.length;i++)
        {
            text.control.focus.focusBooleanArray2[i] = new boolean[values[i].length];
            for(int j=0;j<values[i].length;j++)
                text.control.focus.focusBooleanArray2[i][j] = values[i][j];
        }
    }
    public void setFocusIntegerArray2(int values[][])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusIntegerArray2 = new int[values.length][];
        for(int i=0;i<values.length;i++)
        {
            text.control.focus.focusIntegerArray2[i] = new int[values[i].length];
            for(int j=0;j<values[i].length;j++)
                text.control.focus.focusIntegerArray2[i][j] = values[i][j];
        }
    }
    public void setFocusDoubleArray2(double values[][])
    {
        if(panelID == 10000)
            return;
        
        text.control.focus.focusDoubleArray2 = new double[values.length][];
        for(int i=0;i<values.length;i++)
        {
            text.control.focus.focusDoubleArray2[i] = new double[values[i].length];
            for(int j=0;j<values[i].length;j++)
                text.control.focus.focusDoubleArray2[i][j] = values[i][j];
        }
    }
    
    
    
    public boolean getMainFocusBoolean()
    {
        return text.control.focus.mainFocusBoolean;
    }
    public boolean getSubFocusBoolean()
    {
        return text.control.focus.subFocusBoolean;
    }
    public int getMainFocusInteger()
    {
        return text.control.focus.mainFocusInteger;
    }
    public int getSubFocusInteger()
    {
        return text.control.focus.subFocusInteger;
    }
    public double getMainFocusDouble()
    {
        return text.control.focus.mainFocusDouble;
    }
    public double getSubFocusDouble()
    {
        return text.control.focus.subFocusDouble;
    }
    public String getMainFocusString()
    {
        return text.control.focus.mainFocusString;
    }
    public String getSubFocusString()
    {
        return text.control.focus.subFocusString;
    }
    
    public boolean[] getFocusBooleanArray()
    {
        return text.control.focus.focusBooleanArray;
    }
    public int[] getFocusIntegerArray()
    {
        return text.control.focus.focusIntegerArray;
    }
    public double[] getFocusDoubleArray()
    {
        return text.control.focus.focusDoubleArray;
    }
    public String[] getFocusStringArray()
    {
        return text.control.focus.focusStringArray;
    }
    
    public boolean[][] getFocusBooleanArray2()
    {
        return text.control.focus.focusBooleanArray2;
    }
    public int[][] getFocusIntegerArray2()
    {
        return text.control.focus.focusIntegerArray2;
    }
    public double[][] getFocusDoubleArray2()
    {
        return text.control.focus.focusDoubleArray2;
    }
    
    
    
	//EXECUTION
	public final void executeOtherModuleFirst(int executeModuleID, int optionNumber)
	{
		text.connection.executeModuleWithOptionFirst(panelID, executeModuleID, optionNumber);
	}	
	
	public final void executeOtherModule(int executeModuleID, int optionNumber)
	{
		text.connection.executeModuleWithOption(panelID, executeModuleID, optionNumber);
	}
	
	//DISPLAY
	public final void displayOtherModuleFirst(int displayModuleID, int optionNumber)
	{
		text.connection.displayModuleWithOptionFirst(panelID, displayModuleID, optionNumber);
	}	
	
	public final void displayOtherModule(int displayModuleID, int optionNumber)
	{
		text.connection.displayModuleWithOption(panelID, displayModuleID, optionNumber);
	}	
	
	public boolean isMenuInJapanese()
	{
		return text.control.text.settingData.inJapanese;
	}	
	
	//DISPLAY PROCESS
	public void createProcessingPop()
	{
		String windowTitle = "Visualization Processing";
		if(text.control.sp1.inJapanese)
			windowTitle = text.control.windowNameInJapanese[14];		
		
        if(processingPanel == null)		
			processingPanel = new PopUpForProcessing(text.control.sp1.windowSizeX/2 - 250, 500,500,300, myModuleName+" in PANEL "+(panelID+1), Color.green,
												 text.control.absolutePath, text.getFontName(), windowTitle);		
	}
	
	public void setProcessingPercent(int percent)
	{
        if(processingPanel != null)		
			processingPanel.setPercent(percent);
	}		
	
	public void disposeProcessingPop()
	{
        if(processingPanel != null)
        {
            processingPanel.dispose();
            processingPanel = null;
        }
	}
	
    
    //MouseMotionListener
    public void mouseDragged(MouseEvent me){writeDragLog();}
    public void mouseMoved(MouseEvent me){writeMoveLog();}
    
    //Mouse Event
    public void mouseClicked(MouseEvent e){writeClickLog();}
    public void mouseEntered(MouseEvent e){writeEnterLog();}
    public void mouseExited(MouseEvent e){writeExitLog();}
    public void mousePressed(MouseEvent e){writePressLog();}
    public void mouseReleased(MouseEvent e){writeReleaseLog();}
    
    //AdjustmentListener
    public void adjustmentValueChanged(AdjustmentEvent e){writeBarDragLog();}
    
    //MouseWheelListener
    public void mouseWheelMoved(MouseWheelEvent mwe)
    {
        double rotation = mwe.getWheelRotation();
        writeWheelLog(rotation);
    }
    
    
	/*
	public String getButtonName(ActionEvent e)
	{
		return text.control.getButtonName(e);
	}
	*/

	
    public void writeButtonLog(String buttonName, Component component)
    {
        ACTIONLOG.writeButtonLogFromModule("PANEL-"+panelID+"-VISUAL",buttonName,getMiningID(),moduleID,component);
    }
    
    public void writeButtonLogWithExp(String buttonName, Component component)
    {
        ACTIONLOG.writeButtonLogFromModule("PANEL-"+panelID+"-VISUAL",buttonName,getMiningID(),moduleID,component);
        
        text.control.ex1.addExpByOperatedVisualizationModule(moduleID);
        if(text.control.expPanel != null)
            text.control.expPanel.repaint();
    }
    
    public void writeMouseLog(String operation)
    {
        ACTIONLOG.writeMouseLogFromModule("PANEL-"+panelID+"-VISUAL",operation,getMiningID(),moduleID);
    }
    
    public void writeMouseWheelLog(double rotation)
    {
        ACTIONLOG.writeMouseWheelLogFromModule("PANEL-"+panelID+"-VISUAL",rotation,getMiningID(),moduleID);
    }
    /*
	public void writeMouseLogWithExp(String operation)
	{
		ACTIONLOG.writeMouseLogFromModule("PANEL-"+panelID+"-VISUAL",operation,getMiningID(),moduleID);
		
        text.control.ex1.addExpByOperatedVisualizationModule(moduleID);
		if(text.control.expPanel != null)
			text.control.expPanel.repaint();		
	}
    */
    public void writeTextLog(String text)
    {
        ACTIONLOG.writeTextInputLogFromModule("PANEL-"+panelID+"-VISUAL",text,getMiningID(),moduleID);
    }
    
    public int getMiningID()
    {
        return text.control.panel[panelID].miningIDs[text.control.panel[panelID].selected_module];
    }
	
	//mouse motion listener
	public void writeMoveLog()
	{
		writeMouseLog("MOVE");
	}
	
	public void writeDragLog()
	{
//		writeLogWithExp("DRAG");
		writeMouseLog("DRAG");
	}
	
	public void writeBarDragLog()
	{
		writeMouseLog("DRAG(BAR-ADJUSTED)");
	}
	
	//mouse listener
	public void writeClickLog()
	{
		writeMouseLog("CLICK");
	}
	
	public void writePressLog()
	{
		writeMouseLog("PRESS");
	}
	
	public void writeReleaseLog()
	{
		writeMouseLog("RELEASE");
	}	
	
	public void writeEnterLog()
	{
		writeMouseLog("ENTER");
	}
	
	public void writeExitLog()
	{
		writeMouseLog("EXIT");
	}	
	
	//mouse wheel "WHEEL"
	public void writeWheelLog(double rotation)
	{
		writeMouseWheelLog(rotation);
	}	
	
	//button
	public void writeButtonLog(ActionEvent e)
	{
		writeButtonLogWithExp(getButtonName(e), (Component)e.getSource());
	}
	
	public String getButtonName(ActionEvent e)
	{
		return text.control.getButtonName(e);
	}	
	
	//SAVE ACTION LOG
//    String logFilename;
    public void writeActionLog(String data)
    {
//        String dataText = String.format("%.2f",text.control.getDiffTime())+" Visualization PanelID="+panelID+" "+"ModuleID="+moduleID+" "+"TextID="+text.textID+" "+data+System.getProperty("line.separator");
        ACTIONLOG.writeActionLog("PANEL-"+panelID+"-VISUAL*"+data);
      
    }
}

