//
// Mining module for TETDM 
// Sample2.java Version 0.30
// This is one of the sample modules.
// You should read the README file.
//

package module.MiningModules.Sample2;

import source.*;
import source.TextData.*;
//import source.Utility.*;

import java.io.*;

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


public class Sample2 extends MiningModule implements ActionListener
{
	public Sample2()
	{
		setModuleID(10001);						// Set your module ID after you have got it
		setCategoryID(8);		
		pairingVisualizationID = new int[]{1};
		setToolType(2);
	}

	public void initializePanel()
	{
        button = new JButton[1];
		button[0] = new JButton();
		button[0].setBackground(Color.red);
		button[0].addActionListener(this);
		operationPanel.add(button[0]);
	}
	
	public void initializeData()
	{
		if(isMenuInJapanese())
			button[0].setText(inJapanese[0]);
		else
			button[0].setText("DISPLAY");
	}
	
	public void miningOperations(int optionNumber)
	{
		switch(optionNumber)
		{
			case 0:
                resetData();                
				setDataString("");
				break;
				
			case 1:
                resetData();
				setDataString(MyMethod());
				displayOperations(0);
				break;
		}
	}	
	
	public void actionPerformed(ActionEvent e)
	{
		writeButtonLog(e);
		
		if(e.getSource() == button[0])
			miningOperations(1);
	}
	
	String MyMethod()
	{
		StringWriter sw = new StringWriter();			//For words
		BufferedWriter bw = new BufferedWriter(sw);
		
		try{
			for(int i=0;i<text.sentenceNumber;i++)
				for(int j=0;j<text.sentence[i].wordNumber;j++)
					bw.write(text.sentence[i].word[j]+" ");
			
			bw.flush();
		}
		catch(Exception e){
			System.out.println("writing ERROR in Sample2");
		}			
		
		return sw.toString();	
	}
}
