/*******************************************************************************************
 * setup softkeyboard(NicoTouch)
 */
package com.hiroshica.android.input.nicownn2.JAJP;

import android.inputmethodservice.Keyboard;
import com.hiroshica.android.input.nicownn2.*;
import java.util.HashMap;

public class SetupKeyboardNico implements SetupKeyboard {
	/** Toggle cycle table for full-width Nicotouch */
	public static final String[][][] JP_FULL_NICO_CYCLE_TABLE = {
		{
			{"\u3042"}, {"\u3044"}, {"\u3046"}, {"\u3048"}, {"\u304a"},      {"."},      {"-"},      {"@"},      {"_"}, {"1"},
			{"\u304b"}, {"\u304d"}, {"\u304f"}, {"\u3051"}, {"\u3053"},      {" "},      {"a"},      {"b"},      {"c"}, {"2"},
			{"\u3055"}, {"\u3057"}, {"\u3059"}, {"\u305b"}, {"\u305d"},      {"/"},      {"d"},      {"e"},      {"f"}, {"3"},
			{"\u305f"}, {"\u3061"}, {"\u3064"}, {"\u3066"}, {"\u3068"}, {"\u3063"},      {"g"},      {"h"},      {"i"}, {"4"},
			{"\u306a"}, {"\u306b"}, {"\u306c"}, {"\u306d"}, {"\u306e"},      {"("},      {"j"},      {"k"},      {"l"}, {"5"},
			{"\u306f"}, {"\u3072"}, {"\u3075"}, {"\u3078"}, {"\u307b"},      {")"},      {"m"},      {"n"},      {"o"}, {"6"},
			{"\u307e"}, {"\u307f"}, {"\u3080"}, {"\u3081"}, {"\u3082"},      {"p"},      {"q"},      {"r"},      {"s"}, {"7"},
			{"\u3084"}, {"\u3086"}, {"\u3088"}, {"\u3083"}, {"\u3085"}, {"\u3087"},      {"t"},      {"u"},      {"v"}, {"8"},
			{"\u3089"}, {"\u308a"}, {"\u308b"}, {"\u308c"}, {"\u308d"},      {"w"},      {"x"},      {"y"},      {"z"}, {"9"},
			{"\u308f"}, {"\u3092"}, {"\u3093"}, {"\u3001"}, {"\u3002"}, {"\u30fc"}, {"\u30fb"}, {"\uff01"}, {"\uff1f"}, {"0"},
		},
		{
			{"\u3042"}, {"\u3044"}, {"\u3046"}, {"\u3048"}, {"\u304a"},      {"."},      {"-"},      {"@"},      {"_"}, {"1"},
			{"\u304b"}, {"\u304d"}, {"\u304f"}, {"\u3051"}, {"\u3053"},      {" "},      {"A"},      {"B"},      {"C"}, {"2"},
			{"\u3055"}, {"\u3057"}, {"\u3059"}, {"\u305b"}, {"\u305d"},      {"/"},      {"D"},      {"E"},      {"F"}, {"3"},
			{"\u305f"}, {"\u3061"}, {"\u3064"}, {"\u3066"}, {"\u3068"}, {"\u3063"},      {"G"},      {"H"},      {"I"}, {"4"},
			{"\u306a"}, {"\u306b"}, {"\u306c"}, {"\u306d"}, {"\u306e"},      {"("},      {"J"},      {"K"},      {"L"}, {"5"},
			{"\u306f"}, {"\u3072"}, {"\u3075"}, {"\u3078"}, {"\u307b"},      {")"},      {"M"},      {"N"},      {"O"}, {"6"},
			{"\u307e"}, {"\u307f"}, {"\u3080"}, {"\u3081"}, {"\u3082"},      {"P"},      {"Q"},      {"R"},      {"S"}, {"7"},
			{"\u3084"}, {"\u3086"}, {"\u3088"}, {"\u3083"}, {"\u3085"}, {"\u3087"},      {"T"},      {"U"},      {"V"}, {"8"},
			{"\u3089"}, {"\u308a"}, {"\u308b"}, {"\u308c"}, {"\u308d"},      {"W"},      {"X"},      {"Y"},      {"Z"}, {"9"},
			{"\u308f"}, {"\u3092"}, {"\u3093"}, {"\u3001"}, {"\u3002"}, {"\u30fc"}, {"\u30fb"}, {"\uff01"}, {"\uff1f"}, {"0"},
		}
	};

	/** Replace table for full-width Nicotouch */
	public static final HashMap<String, String> JP_FULL_NICO_REPLACE_TABLE = new HashMap<String, String>() {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

	{
			put("\u3042", "\u3041"); put("\u3044", "\u3043"); put("\u3046", "\u3045"); put("\u3048", "\u3047"); put("\u304a", "\u3049"); // A
			put("\u3041", "\u3042"); put("\u3043", "\u3044"); put("\u3045", "\u30f4"); put("\u3047", "\u3048"); put("\u3049", "\u304a"); // a
			put("\u304b", "\u304c"); put("\u304d", "\u304e"); put("\u304f", "\u3050"); put("\u3051", "\u3052"); put("\u3053", "\u3054"); // K
			put("\u304c", "\u304b"); put("\u304e", "\u304d"); put("\u3050", "\u304f"); put("\u3052", "\u3051"); put("\u3054", "\u3053"); // k
			put("\u3055", "\u3056"); put("\u3057", "\u3058"); put("\u3059", "\u305a"); put("\u305b", "\u305c"); put("\u305d", "\u305e"); // S
			put("\u3056", "\u3055"); put("\u3058", "\u3057"); put("\u305a", "\u3059"); put("\u305c", "\u305b"); put("\u305e", "\u305d"); // s
			put("\u305f", "\u3060"); put("\u3061", "\u3062"); put("\u3064", "\u3065"); put("\u3066", "\u3067"); put("\u3068", "\u3069"); // T
			put("\u3060", "\u305f"); put("\u3062", "\u3061"); put("\u3065", "\u3063"); put("\u3067", "\u3066"); put("\u3069", "\u3068"); // t
			put("\u3063", "\u3064"); put("\u30f4", "\u3046");
			put("\u306f", "\u3070"); put("\u3072", "\u3073"); put("\u3075", "\u3076"); put("\u3078", "\u3079"); put("\u307b", "\u307c"); // H
			put("\u3070", "\u3071"); put("\u3073", "\u3074"); put("\u3076", "\u3077"); put("\u3079", "\u307a"); put("\u307c", "\u307d"); // h
			put("\u3071", "\u306f"); put("\u3074", "\u3072"); put("\u3077", "\u3075"); put("\u307a", "\u3078"); put("\u307d", "\u307b"); // h.
			put("\u3084", "\u3083"); put("\u3086", "\u3085"); put("\u3088", "\u3087"); // Y
			put("\u3083", "\u3084"); put("\u3085", "\u3086"); put("\u3087", "\u3088"); // y
			put("\u308f", "\u308e");
			put("\u308e", "\u308f");
			put("\u309b", "\u309c");
			put("\u309c", "\u309b");

			put("a", "A"); put("b", "B"); put("c", "C"); put("d", "D"); put("e", "E"); put("f", "F"); put("g", "G"); put("h", "H"); put("i", "I"); put("j", "J");
			put("k", "K"); put("l", "L"); put("m", "M"); put("n", "N"); put("o", "O"); put("p", "P"); put("q", "Q"); put("r", "R"); put("s", "S"); put("t", "T");
			put("u", "U"); put("v", "V"); put("w", "W"); put("x", "X"); put("y", "Y"); put("z", "Z");
			put("A", "a"); put("B", "b"); put("C", "c"); put("D", "d"); put("E", "e"); put("F", "f"); put("G", "g"); put("H", "h"); put("I", "i"); put("J", "j");
			put("K", "k"); put("L", "l"); put("M", "m"); put("N", "n"); put("O", "o"); put("P", "p"); put("Q", "q"); put("R", "r"); put("S", "s"); put("T", "t");
			put("U", "u"); put("V", "v"); put("W", "w"); put("X", "x"); put("Y", "y"); put("Z", "z");

			put("1", "\uff11"); put("2", "\uff12"); put("3", "\uff13"); put("4", "\uff14"); put("5", "\uff15");
			put("6", "\uff16"); put("7", "\uff17"); put("8", "\uff18"); put("9", "\uff19"); put("0", "\uff10");
			put("\uff11", "1"); put("\uff12", "2"); put("\uff13", "3"); put("\uff14", "4"); put("\uff15", "5");
			put("\uff16", "6"); put("\uff17", "7"); put("\uff18", "8"); put("\uff19", "9"); put("\uff10", "0");

			put(".", "\uff0e"); put("-", "\u2015"); put("@", "\uff20"); put("_", "\uff3f");
			put("\uff0e", "."); put("\u2015", "-"); put("\uff20", "@"); put("\uff3f", "_");

			put("\uff01", "!"); put("\uff1f", "?");
			put("!", "\uff01"); put("?", "\uff1f");

			put("\u3000", " "); put(" ", "\u3000");

			put("(", "["); put("[", "\u300c"); put("\u300c", "\u300e"); put("\u300e", "\u3010"); put("\u3010", "(");
			put(")", "]"); put("]", "\u300d"); put("\u300d", "\u300f"); put("\u300f", "\u3011"); put("\u3011", ")");
		}};

	/**
	 * change map
	 */
	public static final int flickChangeMap[][] = {
		{  0,  4,  1,  2,  3 }, // A
		{  0,  4,  1,  2,  3 }, // Ka
		{  0,  4,  1,  2,  3 }, // Sa
		{  0,  4,  1,  2,  3 }, // Ta
		{  0,  4,  1,  2,  3 }, // Na
		{  0,  4,  1,  2,  3 }, // Ha
		{  0,  4,  1,  2,  3 }, // Ma
		{  0,  2, -1,  1, -1 }, // Ya
		{  0,  4,  1,  2,  3 }, // Ra
		{  0, -1,  1,  2,  5 }, // Wa
	};

	private static int selectKeyTable[][] = {
		/* small */
		{
			R.xml.key_nico_top,
			R.xml.key_nico_a, R.xml.key_nico_k, R.xml.key_nico_s, R.xml.key_nico_t, R.xml.key_nico_n,
			R.xml.key_nico_h, R.xml.key_nico_m, R.xml.key_nico_y, R.xml.key_nico_r, R.xml.key_nico_w,
			R.xml.key_nico_input_top,
			R.xml.key_nico_input_a, R.xml.key_nico_input_k, R.xml.key_nico_input_s, R.xml.key_nico_input_t, R.xml.key_nico_input_n,
			R.xml.key_nico_input_h, R.xml.key_nico_input_m, R.xml.key_nico_input_y, R.xml.key_nico_input_r, R.xml.key_nico_input_w,
		},
		/* middle */
		{
			R.xml.mid_key_nico_top,
			R.xml.mid_key_nico_a, R.xml.mid_key_nico_k, R.xml.mid_key_nico_s, R.xml.mid_key_nico_t, R.xml.mid_key_nico_n,
			R.xml.mid_key_nico_h, R.xml.mid_key_nico_m, R.xml.mid_key_nico_y, R.xml.mid_key_nico_r, R.xml.mid_key_nico_w,
			R.xml.mid_key_nico_input_top,
			R.xml.mid_key_nico_input_a, R.xml.mid_key_nico_input_k, R.xml.mid_key_nico_input_s, R.xml.mid_key_nico_input_t, R.xml.mid_key_nico_input_n,
			R.xml.mid_key_nico_input_h, R.xml.mid_key_nico_input_m, R.xml.mid_key_nico_input_y, R.xml.mid_key_nico_input_r, R.xml.mid_key_nico_input_w,
		},
		/* large */
		{
			R.xml.large_key_nico_top,
			R.xml.large_key_nico_a, R.xml.large_key_nico_k, R.xml.large_key_nico_s, R.xml.large_key_nico_t, R.xml.large_key_nico_n,
			R.xml.large_key_nico_h, R.xml.large_key_nico_m, R.xml.large_key_nico_y, R.xml.large_key_nico_r, R.xml.large_key_nico_w,
			R.xml.large_key_nico_input_top,
			R.xml.large_key_nico_input_a, R.xml.large_key_nico_input_k, R.xml.large_key_nico_input_s, R.xml.large_key_nico_input_t, R.xml.large_key_nico_input_n,
			R.xml.large_key_nico_input_h, R.xml.large_key_nico_input_m, R.xml.large_key_nico_input_y, R.xml.large_key_nico_input_r, R.xml.large_key_nico_input_w,
		},
	};
	private static int selectLandKeyTable[][] = {
		/* small */
		{
			R.xml.key_nico_top_land,
			R.xml.key_nico_a_land, R.xml.key_nico_k_land, R.xml.key_nico_s_land, R.xml.key_nico_t_land, R.xml.key_nico_n_land,
			R.xml.key_nico_h_land, R.xml.key_nico_m_land, R.xml.key_nico_y_land, R.xml.key_nico_r_land, R.xml.key_nico_w_land,
			R.xml.key_nico_input_top_land,
			R.xml.key_nico_input_a_land, R.xml.key_nico_input_k_land, R.xml.key_nico_input_s_land, R.xml.key_nico_input_t_land, R.xml.key_nico_input_n_land,
			R.xml.key_nico_input_h_land, R.xml.key_nico_input_m_land, R.xml.key_nico_input_y_land, R.xml.key_nico_input_r_land, R.xml.key_nico_input_w_land,
		},
		/* middle */
		{
			R.xml.mid_key_nico_top_land,
			R.xml.mid_key_nico_a_land, R.xml.mid_key_nico_k_land, R.xml.mid_key_nico_s_land, R.xml.mid_key_nico_t_land, R.xml.mid_key_nico_n_land,
			R.xml.mid_key_nico_h_land, R.xml.mid_key_nico_m_land, R.xml.mid_key_nico_y_land, R.xml.mid_key_nico_r_land, R.xml.mid_key_nico_w_land,
			R.xml.mid_key_nico_input_top_land,
			R.xml.mid_key_nico_input_a_land, R.xml.mid_key_nico_input_k_land, R.xml.mid_key_nico_input_s_land, R.xml.mid_key_nico_input_t_land, R.xml.mid_key_nico_input_n_land,
			R.xml.mid_key_nico_input_h_land, R.xml.mid_key_nico_input_m_land, R.xml.mid_key_nico_input_y_land, R.xml.mid_key_nico_input_r_land, R.xml.mid_key_nico_input_w_land,
		},
		/* large */
		{
			R.xml.large_key_nico_top_land,
			R.xml.large_key_nico_a_land, R.xml.large_key_nico_k_land, R.xml.large_key_nico_s_land, R.xml.large_key_nico_t_land, R.xml.large_key_nico_n_land,
			R.xml.large_key_nico_h_land, R.xml.large_key_nico_m_land, R.xml.large_key_nico_y_land, R.xml.large_key_nico_r_land, R.xml.large_key_nico_w_land,
			R.xml.large_key_nico_input_top_land,
			R.xml.large_key_nico_input_a_land, R.xml.large_key_nico_input_k_land, R.xml.large_key_nico_input_s_land, R.xml.large_key_nico_input_t_land, R.xml.large_key_nico_input_n_land,
			R.xml.large_key_nico_input_h_land, R.xml.large_key_nico_input_m_land, R.xml.large_key_nico_input_y_land, R.xml.large_key_nico_input_r_land, R.xml.large_key_nico_input_w_land,
		},
	};
	/******************************************************************************************/
	/*********************************
	 *
	 */
	public Keyboard[][] SetupSoftKeyboard(NicoWnn parent, int displaymode, int keysize) {
		Keyboard[][] nicokeyboard = new Keyboard[11][2];
		if (DefaultSoftKeyboard.PORTRAIT == displaymode) {
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_TOP][0]   = new Keyboard(parent, selectKeyTable[keysize][0]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_A][0]     = new Keyboard(parent, selectKeyTable[keysize][1]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_K][0]     = new Keyboard(parent, selectKeyTable[keysize][2]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_S][0]     = new Keyboard(parent, selectKeyTable[keysize][3]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_T][0]     = new Keyboard(parent, selectKeyTable[keysize][4]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_N][0]     = new Keyboard(parent, selectKeyTable[keysize][5]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_H][0]     = new Keyboard(parent, selectKeyTable[keysize][6]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_M][0]     = new Keyboard(parent, selectKeyTable[keysize][7]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_Y][0]     = new Keyboard(parent, selectKeyTable[keysize][8]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_R][0]     = new Keyboard(parent, selectKeyTable[keysize][9]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_W][0]     = new Keyboard(parent, selectKeyTable[keysize][10]);

			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_TOP][1]   = new Keyboard(parent, selectKeyTable[keysize][11]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_A][1]     = new Keyboard(parent, selectKeyTable[keysize][12]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_K][1]     = new Keyboard(parent, selectKeyTable[keysize][13]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_S][1]     = new Keyboard(parent, selectKeyTable[keysize][14]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_T][1]     = new Keyboard(parent, selectKeyTable[keysize][15]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_N][1]     = new Keyboard(parent, selectKeyTable[keysize][16]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_H][1]     = new Keyboard(parent, selectKeyTable[keysize][17]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_M][1]     = new Keyboard(parent, selectKeyTable[keysize][18]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_Y][1]     = new Keyboard(parent, selectKeyTable[keysize][19]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_R][1]     = new Keyboard(parent, selectKeyTable[keysize][20]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_W][1]     = new Keyboard(parent, selectKeyTable[keysize][21]);
		}
		else{
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_TOP][0]   = new Keyboard(parent, selectLandKeyTable[keysize][0]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_A][0]     = new Keyboard(parent, selectLandKeyTable[keysize][1]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_K][0]     = new Keyboard(parent, selectLandKeyTable[keysize][2]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_S][0]     = new Keyboard(parent, selectLandKeyTable[keysize][3]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_T][0]     = new Keyboard(parent, selectLandKeyTable[keysize][4]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_N][0]     = new Keyboard(parent, selectLandKeyTable[keysize][5]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_H][0]     = new Keyboard(parent, selectLandKeyTable[keysize][6]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_M][0]     = new Keyboard(parent, selectLandKeyTable[keysize][7]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_Y][0]     = new Keyboard(parent, selectLandKeyTable[keysize][8]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_R][0]     = new Keyboard(parent, selectLandKeyTable[keysize][9]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_W][0]     = new Keyboard(parent, selectLandKeyTable[keysize][10]);

			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_TOP][1]   = new Keyboard(parent, selectLandKeyTable[keysize][11]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_A][1]     = new Keyboard(parent, selectLandKeyTable[keysize][12]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_K][1]     = new Keyboard(parent, selectLandKeyTable[keysize][13]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_S][1]     = new Keyboard(parent, selectLandKeyTable[keysize][14]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_T][1]     = new Keyboard(parent, selectLandKeyTable[keysize][15]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_N][1]     = new Keyboard(parent, selectLandKeyTable[keysize][16]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_H][1]     = new Keyboard(parent, selectLandKeyTable[keysize][17]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_M][1]     = new Keyboard(parent, selectLandKeyTable[keysize][18]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_Y][1]     = new Keyboard(parent, selectLandKeyTable[keysize][19]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_R][1]     = new Keyboard(parent, selectLandKeyTable[keysize][20]);
			nicokeyboard[DefaultSoftKeyboard.NICO_SLIDE_MODE_W][1]     = new Keyboard(parent, selectLandKeyTable[keysize][21]);
		}
		return nicokeyboard;
	}
	/*********************************
	 *
	 */
	public String[][][] SetupCycleTable() {
		return JP_FULL_NICO_CYCLE_TABLE;
	}
	/*********************************
	 *
	 */
	public HashMap<String, String> SetupReplaceTable() {
		return JP_FULL_NICO_REPLACE_TABLE;
	}
	/*********************************
	 *
	 */
	public int SetupIcon() {
		return R.drawable.immodeic_niko;
	}
	/*********************************
	 *
	 */
	public int GetFlickKeyCode(int line, int row) {
		return flickChangeMap[line][row];
	}
}
/******************** end of file ********************/
