//
// Visuzalization module for TETDM 
// TextDisplay.java Version 0.31
// Copyright(C) 2011 WATARU SUNAYAMA ALL RIGHTS RESERVED.
//
// This program is provided under the license.
// You should read the README file.
//

package module.VisualizationModules.TextDisplayHtml;

import source.*;
import source.TextData.*;

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


public class TextDisplay extends VisualizationModule
{
	//Text pane
	JTextPane text1;
	JScrollPane scroll1;

	//for DISPLAY
	String displayText;	//display text

    String nothing;
    String outputInJapanese;

	int fontsize;

	public TextDisplay()
	{
		setModuleID(1);	
	}

	public void initializePanel()
	{
		text1 = new JTextPane();
		text1.setContentType("text/plain");		
		scroll1 = new JScrollPane(text1);
		add(scroll1);

		outputInJapanese = fileRead();
	}
	
	public void initializeData()
	{
		fontsize = 14;

		if(isMenuInJapanese())
		    displayText = outputInJapanese;
		else
		    displayText = "Nothing";		    
	}
	
	public void displayOperations(int optionNumber)
	{
		switch(optionNumber)
		{
			case 0:
				text1.setFont(new Font("Dialog", Font.BOLD, fontsize));
				text1.setText(displayText);
				text1.setCaretPosition(0);
				break;
				
			case 1:
				text.fileSave(text1.getText());
				break;
				
			case 9:
				fontsize--;
				displayOperations(0);
				break;
				
			case 10:
				fontsize++;
				displayOperations(0);
				break;
				
			case 100:
				displayText = text.originalText;
				displayOperations(0);				
				break;				
		}		
	}	
	
	public void setData(int dataID, String t)
	{
		switch(dataID)
		{
			default:
				displayText = t;
				break;
		}
	}
	
	public void setFont()
	{
		fontsize = text.fontSize;
	}
}
