沌珍館企画 開発部 部品倉庫 BF i-Javaフロア






栃ナビ! - 栃木のお店、スポット情報
宮カフェ 宇都宮を考えるホームページ



このサイトはSitehinaで作成されています。

スーパーフルーツトマト

糖度9度+ 極甘スーパーフルーツトマト

フルソース

干支から年令を計算『なに年くん』

import com.nttdocomo.ui.*;
import java.util.*;
/*
 * タイトル:  干支から年令を計算『なに年くん』
 * 説明:   干支を選択して年令を計算し列挙
 * 著作権: Copyright (c) 2006
 * 会社名: 沌珍館企画
 * @author 開発部ケータイアプリ課iアプリTeam
 * @version 1.1i
 */

public class nanidoshi extends IApplication {
	public void start() {
		panel1 p1 = new panel1(this);
		Display.setCurrent(p1);
	}
}

class panel1 extends Panel implements SoftKeyListener {
	//  タイトル
	String title0 = "干支から年令を計算『なに年くん』V1.1i";
	String title1 = "干支から年令を計算『なに年くん』V1.1i\n"+
			"2006/10,(c)沌珍館企画\n"+
			"info@tonchinkan.office.ne.jp";
	ListBox listbox1;
	TextBox textbox1;
	public int y;

	panel1 (IApplication app) {
	//	コンポーネントリスナー
		ListenerClass lclass = new ListenerClass();
		this.setComponentListener(lclass);
	//  タイトル行
		setTitle(title0);
	//  リストボックス
		listbox1 = new ListBox(ListBox.CHOICE);
		listbox1.setSize(getWidth()-4,listbox1.getHeight()+2);
		this.add(listbox1);
		listbox1.append("子・ね(ねずみ)");
		listbox1.append("丑・うし");
		listbox1.append("寅・とら");
		listbox1.append("卯・う(うさぎ)");
		listbox1.append("辰・たつ");
		listbox1.append("巳・み(へび)");
		listbox1.append("午・うま");
		listbox1.append("未・ひつじ");
		listbox1.append("申・さる");
		listbox1.append("酉・とり");
		listbox1.append("戌・いぬ");
		listbox1.append("亥・い(いのしし)");
	//	テキストボックス
		textbox1 = new TextBox("",getWidth()-4,2,TextBox.DISPLAY_ANY);
		this.add(textbox1);

	//	年を取得するカレンダー系
		Calendar cal = Calendar.getInstance(TimeZone.getDefault());
		cal.setTime(new Date());
		y = cal.get(Calendar.YEAR);
		listbox1.select(( y + 8 ) % 12 );

	//  ソフトキー定義
		setSoftLabel(Frame.SOFT_KEY_1, "終了");
		setSoftLabel(Frame.SOFT_KEY_2, "消去");
		setSoftKeyListener(this);
	}

	//	想定年令を計算
	public StringBuffer ages (int param) {
		int i;	//	カウンタ
		int yy;	//	想定年令
		yy = (( y + 8 ) % 12 ) - param;
		if ( yy < 0 ) { yy = yy + 12;};
		StringBuffer s = new StringBuffer("");
		for (i=0; i<7; i++) {
			s.append(yy).append(",");
			yy = yy + 12;
		}
		s.append(yy);
		return s;
	}

	//	コンポーネントリスナー
	class ListenerClass implements ComponentListener {
		public void componentAction(Component c, int type, int param) {
			if (c == textbox1) {return;}   //  テキストボックスが反応しても無視
			//	それ以外はリストボックスの反応
			textbox1.setText("この年に生まれた人は、今年"+ages(param)+"才です。");
		}
	}

	//	ソフトキー動作
	public void softKeyPressed(int no) {
		if (Frame.SOFT_KEY_1 == no) {
			Dialog dialog1 = new Dialog (Dialog.DIALOG_YESNO, "終了しますか?");
			dialog1.setText(title1);
			if (dialog1.show() == Dialog.BUTTON_YES) {
				IApplication.getCurrentApp().terminate();
			}
		} else if (Frame.SOFT_KEY_2 == no) {
			textbox1.setText("");
		}
	}
	public void softKeyReleased(int no) {
	}

}

列車速度表示『ガタゴト君』

import com.nttdocomo.ui.*;
/**
 * タイトル:  『ガタゴト君』絵文字版
 * 説明:   レール音クリックで乗っている列車の速度を表示
 * 著作権: Copyright (c) 2003-2005
 * 会社名: 沌珍館企画
 * @author 開発部ケータイアプリ課iアプリTeam
 * @version 1.2i
 */

public class gatagoto extends IApplication {
	public void start() {
		panel1 p1 = new panel1(this);
		Display.setCurrent(p1);
	}
}

class panel1 extends Panel implements SoftKeyListener {
	//  タイトル
	String title0 = "列車速度表示『ガタゴト君』V1.2i";
	String title1 = "列車速度表示『ガタゴト君』V1.2i\n"+
			"2005/05,(c)沌珍館企画\n"+
			"info@tonchinkan.office.ne.jp";
	public long t0 = 0;
	public long t1 = 0;
	public long t2 = 0;
	public long d1 = 0;
	public long d2 = 0;
	Label label0;
	Label label1;
	Label label2;
	Label label3;
	// 絵文字 [0][1][2][3][4][5][6][7][8][9]
	String [] suuji =  { "\uE6EB","\uE6E2","\uE6E3","\uE6E4","\uE6E5",
			"\uE6E6","\uE6E7","\uE6E8","\uE6E9","\uE6EA" };
	// 絵文字 [0][0][0]
	String stop0 = "\uE6EB"+"\uE6EB"+"\uE6EB"+"Km/h";
	// 絵文字 電車+ケータイ+@+アプリ
	String emoji0 = "\uE65B"+"\uE688"+"\uE6D1"+"\uE70C";
	long s0;
	int  s1;
	int  s2;
	int  s3;

	panel1 (IApplication app) {
	//  タイトル行
		setTitle(title0);
	//  フォントサイズ
		Font font1 = Font.getFont(Font.SIZE_LARGE);
	//  上余白行
		label0 = new Label("",Label.CENTER);
		label0.setSize(getWidth(),label0.getHeight());
		this.add(label0);
	//  表示行
		label1 = new Label(emoji0,Label.CENTER);
		label1.setFont(font1);
		label1.setSize(getWidth(),label1.getHeight());
		this.add(label1);
	//  下余白行
		label2 = new Label("",Label.CENTER);
		label2.setSize(getWidth(),label2.getHeight());
		this.add(label2);
	//  速度表示域
		label3 = new Label("",Label.CENTER);
		label3.setFont(font1);
		label3.setSize(getWidth(),label3.getHeight());
		this.add(label3);
	//  ソフトキー
		setSoftLabel(Frame.SOFT_KEY_1, "終了");
		setSoftLabel(Frame.SOFT_KEY_2, "停止");
		setSoftKeyListener(this);
	//  一般キー
		KeyListenerClass keylclass = new KeyListenerClass();
		this.setKeyListener (keylclass);
	}

	public void softKeyPressed(int no) {
		if (Frame.SOFT_KEY_1 == no) {
			Dialog dlg1 = new Dialog (Dialog.DIALOG_YESNO, "終了しますか?");
			dlg1.setText(title1);
			if (dlg1.show() == Dialog.BUTTON_YES) {
				IApplication.getCurrentApp().terminate();
			}
		} else if (Frame.SOFT_KEY_2 == no) {
			label3.setText(stop0);
			setTitle(title0);
		}
	}
	public void softKeyReleased(int no) {
	}

	class KeyListenerClass implements KeyListener {
		public void keyReleased(Panel panel, int no) {
		}

		public void keyPressed(Panel panel, int key) {
			t2 = System.currentTimeMillis();
			d1 = t2 - t1;
			d2 = t2 - t0;
			if ((d1 < 1500) && (t0 != 0)) {
				s0 = 180000 / d2;
			} else {
				s0 =  90000 / d1;
			}
			s3 = (int)   s0 / 100;
			s2 = (int) ( s0 % 100 ) / 10;
			s1 = (int)   s0 % 10;
			label3.setText(suuji[s3] + suuji[s2] + suuji[s1] + "Km/h");
			t0 = t1;
			t1 = t2;
		}
	}
}

券ちゃん 回数券?定期券?

import com.nttdocomo.ui.*;
/*
 * タイトル:  『券ちゃん 回数券?定期券?』V1.3i
 * 説明:   回数券と定期券の金額を比較
 * 著作権: Copyright (c) 2003-2005
 * 会社名: 沌珍館企画
 * @author 開発部ケータイアプリ課iアプリTeam
 * @version 1.3i
 */

public class kenchan extends IApplication {
	public	static	Panel1 p1;

	public void start() {
		p1 = new Panel1(this);
		Display.setCurrent(new Panel1(this));
	}
}

class Panel1 extends Panel implements SoftKeyListener {
	//  タイトル
	String title0 =   "券ちゃん回数券?定期券? V1.3i";
	String title1 = "『券ちゃん回数券?定期券?』V1.3i\n"+
			"2005/05,(c)沌珍館企画\n"+
			"info@tonchinkan.office.ne.jp";
	//  メールコピー用
	public static String mailtext;
	//  0.切符
	TextBox textbox01;	//  区間金額
	int     KippuKingaku;
	ListBox listbox01;	//  片道|往復
	int     KaisuuKubun;	// 片道|往復
	TextBox textbox02;	//  回数
	int     KippuKaisuu;
	int     KippuMaisuu;
	int     KippuGoukei;	//  総支払額
	Label   KippuEn;
	//  1.回数券
	TextBox textbox11;	//  一冊金額
	int     IssatsuKingaku;
	ListBox listbox11;	//  枚数型|金額型
	TextBox textbox12;	//  一冊枚数
	int     IssatsuMaisuu;
	int     Satsusuu;
	int     SatsuMaisuu;
	int     SatsuKingaku;
	int     NokoriMaisuu;
	int     NokoriKingaku;
	int     KaisuuGoukei;
	Label   KaisuuEn;
	AnchorButton textbox13;	// 回数券換算
	int     sa1;
	//  2.定期券
	TextBox textbox21;	//  定期金額
	int     TeikiKingaku;
	int     KatamichiKansan;
	int     OufukuKansan;
	int     sa2;
	AnchorButton textbox22;	//  定期切符換算
	//  3.結論
	int     Hantei;
	AnchorButton textbox31;	//  がより_円お得

	Panel1(IApplication app) {
		setTitle(title0);
		ListenerClass lclass = new ListenerClass();
		this.setComponentListener(lclass);
	Label Dummy = new Label("0");
	int Ch; //  Char Height 文字高さ(ドット)
		Ch = Dummy.getHeight();
	int Dw; //  Display width 画面幅(ドット)
		Dw = Display.getWidth();
	int Du; //  Display width usable 表示可能幅(ドット)
	//  切符
		Du = Dw -2;
		textbox01 = new TextBox("",6,1,TextBox.DISPLAY_ANY);
		textbox01.setInputMode(textbox01.NUMBER);
		this.add(textbox01);
		Du = Du - textbox01.getWidth() -2;
	Label EnKukanwo;
		EnKukanwo = new Label("円区間を");
		this.add(EnKukanwo);
		Du = Du - EnKukanwo.getWidth() -2;
		listbox01 = new ListBox(ListBox.CHOICE);
		listbox01.setSize(Dummy.getWidth()*10,listbox01.getHeight());
		this.add(listbox01);
		Du = Du - listbox01.getWidth() -2;
		listbox01.append("往復");
		listbox01.append("片道");
		textbox02 = new TextBox("10",3,1,TextBox.DISPLAY_ANY);
		textbox02.setInputMode(textbox02.NUMBER);
		this.add(textbox02);
		Du = Du - textbox02.getWidth() -2;
	Label Kai;
		Kai = new Label("回");
		this.add(Kai);
		Du = Du - Kai.getWidth() -2;
	Label Kayouto;
		Kayouto = new Label("通うと",0);
		Kayouto.setSize(Du,Ch);
		this.add(Kayouto);
		KippuEn = new Label("円。",2);
		KippuEn.setSize(Dw,Ch);
		this.add(KippuEn);
	//  回数券
	Label KaisuukenWa;
		KaisuukenWa = new Label("回数券は",0);
		KaisuukenWa.setSize(Dw,Ch);
		this.add(KaisuukenWa);
		textbox11 = new TextBox("10",6,1,TextBox.DISPLAY_ANY);
		textbox11.setInputMode(textbox11.NUMBER);
		this.add(textbox11);
		listbox11 = new ListBox(ListBox.CHOICE);
		listbox11.setSize(Dummy.getWidth()*10,listbox11.getHeight());
		this.add(listbox11);
		listbox11.append("枚分で");
		listbox11.append("円で");
		textbox12 = new TextBox("11",3,1,TextBox.DISPLAY_ANY);
		textbox12.setInputMode(textbox12.NUMBER);
		this.add(textbox12);
	Label MaiKaerunode;
		MaiKaerunode = new Label("枚買えるので");
		this.add(MaiKaerunode);
		textbox13 = new AnchorButton("");
		this.add(textbox13);
		textbox13.setEnabled(false);
	//  定期券
		Du = Dw -2;
	Label TeikikenWa;
		TeikikenWa = new Label("定期券は",0);
		this.add(TeikikenWa);
		Du = Du - TeikikenWa.getWidth() -2;
		textbox21 = new TextBox("",8,1,TextBox.DISPLAY_ANY);
		textbox21.setInputMode(textbox21.NUMBER);
		this.add(textbox21);
		Du = Du - textbox21.getWidth() -2;
	Label Yenwa;
		Yenwa = new Label("円なので",0);
		Yenwa.setSize(Du,Ch);
		this.add(Yenwa);
		textbox22 = new AnchorButton();	// 回分の 円
		this.add(textbox22);
		textbox22.setEnabled(false);
		textbox31 = new AnchorButton();	// のほうが より 円お得です
		this.add(textbox31);
		textbox31.setEnabled(false);

	//  ソフトキー定義
		setSoftLabel(Frame.SOFT_KEY_1, "終了");
		setSoftLabel(Frame.SOFT_KEY_2, "戻る");
		setSoftKeyListener(this);
	}

//---------------------------------------------------------------------
//	【感謝】 http://members.aol.com/Weball2man/comma.htm
//	▼ここから
//---------------------------------------------------------------------
	public final int commaPlace = 3;

	public String getCommadata(String money) {
		return this.change(money);
	}

	public String change(String workMoney) {
		String data;
		int endCounter;
		int rate = 0;
		boolean markFlag = false;
		String workString;

		if (workMoney.substring(0, 1).equals("-")) {
			workString = workMoney.substring(1);
			markFlag = true;
		} else {
			workString = workMoney;
			markFlag = false;
		}

		int commaCharPlace = workString.indexOf(".");
		String afterComma = "";

		if (commaCharPlace != -1) {
			afterComma = workString.substring(commaCharPlace);
			workString = workString.substring(0, commaCharPlace);
		}

		int stringLength = workString.length();
		if (stringLength >= 4) {
			StringBuffer stringEditer = new StringBuffer(workString);
			int remainder = stringLength;
			for (rate = 0; remainder >= commaPlace; rate++) {
				remainder = remainder - commaPlace;
			}
			for (int i = 0; i <= rate; i++) {
				endCounter = remainder + commaPlace * i;
				if (i != rate) {
					stringEditer = stringEditer.insert(endCounter + i, ",");
				}
			}
			if (remainder == 0) {
				stringEditer = stringEditer.delete(0, 1);
			}
			if (markFlag == true) {
				stringEditer.insert(0, "-").toString();
			} else {
				stringEditer.toString();
			}
			if (commaCharPlace != -1) {
				stringEditer.append(afterComma);
			}
			return stringEditer.toString();
		} else {
			StringBuffer shortStringEditer = new StringBuffer(workString);
			if (markFlag == true) {
				shortStringEditer.insert(0, "-").toString();
			}
			if (commaCharPlace != -1) {
				shortStringEditer.append(afterComma);
			}
			return shortStringEditer.toString();
		}
	}
//---------------------------------------------------------------------
//	▲ここまで
//---------------------------------------------------------------------

	public void softKeyPressed(int KeyPressed) {
		if (KeyPressed == Frame.SOFT_KEY_1) {
			Dialog dlg = new Dialog (Dialog.DIALOG_YESNO, "終了しますか?");
			dlg.setText(title1);
			if (dlg.show() == Dialog.BUTTON_YES) {
				IApplication.getCurrentApp().terminate();
			}
		} else if (KeyPressed == Frame.SOFT_KEY_2) {
			textbox01.setText("");
			textbox21.setText("");
			textbox31.setEnabled(false);
			textbox01.requestFocus();
		}
	}

	public void softKeyReleased(int no) {
	}

	public void Calc0() {
		try {
			// 切符だけの総支払額
			KippuKingaku = Integer.parseInt(textbox01.getText().trim());
			KippuKaisuu = Integer.parseInt(textbox02.getText().trim());
		} catch (NumberFormatException e) {
			// 数値に変換できない場合
			KippuKingaku = 0;
			KippuKaisuu = 0;
		}
		if ((KippuKingaku == 0)||(KippuKaisuu == 0)) {
			KippuEn.setText("円。");
			textbox13.setText("");
			textbox21.setText("");
			textbox22.setText("");
			textbox31.setText("");
			return;
			}
		mailtext = " "+change(KippuKingaku+"")+"円区間を";
		if (listbox01.getSelectedIndex() == 1) {
			KaisuuKubun = 1; // 片道
			mailtext = mailtext + "片道";
		} else {
			KaisuuKubun = 2; // 往復
			mailtext = mailtext + "往復";
		}
		KippuMaisuu = KaisuuKubun * KippuKaisuu;
		mailtext = mailtext + KippuKaisuu+"回通うと ";
		KippuGoukei = KippuKingaku * KippuMaisuu;
		KippuEn.setText(change(KippuGoukei + "")+"円。");
		mailtext = mailtext + change(KippuGoukei + "")+"円。\n";
	}

	public void Calc1() {
		try {
			// 回数券の構成
			IssatsuKingaku = Integer.parseInt(textbox11.getText().trim());
			IssatsuMaisuu = Integer.parseInt(textbox12.getText().trim());
		} catch (NumberFormatException e) {
			// 数値に変換できない場合
			IssatsuKingaku = 0;
			IssatsuMaisuu = 0;
		}
		if ((IssatsuKingaku == 0)||(IssatsuMaisuu == 0)) {
			textbox13.setText("");
			textbox22.setText("");
			textbox31.setText("");
			return;
			}
		mailtext = mailtext + "回数券は"+change(IssatsuKingaku+"");
		Satsusuu = KippuMaisuu / IssatsuMaisuu;
		SatsuMaisuu = Satsusuu * IssatsuMaisuu;
		if (listbox11.getSelectedIndex() == 1) {
			SatsuKingaku = Satsusuu * IssatsuKingaku;    //  金額型
			mailtext = mailtext + "円で";
		} else {
			SatsuKingaku = Satsusuu * IssatsuKingaku * KippuKingaku;    //  枚数型
			mailtext = mailtext + "枚分で";
		}
		mailtext = mailtext + IssatsuMaisuu + "枚買えるので、";
		NokoriMaisuu = KippuMaisuu - SatsuMaisuu;
		NokoriKingaku = NokoriMaisuu * KippuKingaku;
		KaisuuGoukei = SatsuKingaku + NokoriKingaku;
		sa1 = KippuGoukei - KaisuuGoukei;

		String s13 = "" + KippuMaisuu+"枚分は、回数券"+Satsusuu+"冊("+
		SatsuMaisuu+"枚)で "+change(SatsuKingaku+"")+"円、\n"+
		"残り"+NokoriMaisuu+"枚で "+change(NokoriKingaku+"")+"円、"+
		"合計 "+change(KaisuuGoukei+"")+
		"円。\n回数券で節約になるのは "+change(sa1+"")+"円。";
		textbox13.setText(s13);
		mailtext = mailtext + s13 + "\n";
	}

	public void Calc2() {
		try {
			// 定期券
			TeikiKingaku = Integer.parseInt(textbox21.getText().trim());
		} catch (NumberFormatException e) {
			// 数値に変換できない場合
			TeikiKingaku = 0;
		}
		if (TeikiKingaku == 0) {
			textbox22.setText("");
			textbox31.setText("");
			return;
			}
		mailtext = mailtext + "定期券は、";
		KatamichiKansan = TeikiKingaku / KippuKingaku;
		OufukuKansan = KatamichiKansan / 2;
		sa2 = KippuGoukei - TeikiKingaku;
		String s22 = "往復"+OufukuKansan+"回分、"+
			"片道"+KatamichiKansan+"回分の、"+
			change(TeikiKingaku+"")+"円。\n"+
			"定期券で節約になるのは "+change(sa2+"")+"円。";
		textbox22.setText(s22);
		mailtext = mailtext + s22 + "\n";

		//  総合判定
		String s31;
		Hantei = KaisuuGoukei - TeikiKingaku;
		if (Hantei < 0) {
			Hantei = - Hantei;
			s31 = "回数券のほうが、定期券より "+change(Hantei+"")+"円お得です。";
		} else if (Hantei > 0) {
			s31 = "定期券のほうが、回数券より "+change(Hantei+"")+"円お得です。";
		} else {
			s31 = "回数券も定期券も、同じ金額です。";
		}
		textbox31.setText(s31);
		textbox31.setEnabled(true);
		mailtext = mailtext + s31 + "\n";
		mailtext = mailtext + "by " + title0 + "\n";
	}

	class ListenerClass implements ComponentListener {
		public void componentAction(Component c, int type, int param) {
			if (c == textbox13) {return;}   //  回数券結果が反応しても無視
			if ((c == textbox21)&(textbox21.getText().trim() == "")) {
					textbox22.setText("");
					textbox31.setText("");
					return;
				}   //  定期金額がクリアされたら結果をクリア
			if (c == textbox22) {return;}   //  定期券結果が反応しても無視
			if ((c == textbox31)&(type == TEXT_CHANGED)) {return;}   //  総合判定が反応しても無視
			Calc0();    //  切符ベースで計算
			if ((KippuKingaku == 0)||(KippuKaisuu == 0)) {return;}
			Calc1();    //  回数券を計算
			if ((IssatsuKingaku == 0)||(IssatsuMaisuu == 0)) {return;}
			Calc2();    //  定期券を計算
			if ((c == textbox31)&&(type == BUTTON_PRESSED)) {
				//  総合判定を押されたらメール文を持ってキャンバスのエディタ画面へ
				Display.setCurrent(new Canvas1());
				return;
			}
		}
	}

	public static String getmailtext() {
		return(mailtext);
	}

}

class Canvas1 extends Canvas {

	public Canvas1() {
	}

	public void paint(Graphics g) {
		imeOn(Panel1.getmailtext(),TextBox.DISPLAY_ANY,TextBox.KANA);
	}

	public void processEvent(int type, int param) {
		super.processEvent(type, param);
	}

	public void processIMEEvent(int type, String text) {
		Display.setCurrent(kenchan.p1); //パネルへ戻る
	}

}

IT文芸ツール『回文ちゃん』

import com.nttdocomo.ui.*;
/**
 * タイトル:  『回文ちゃん』
 * 説明:   素材から回文を生成
 * 著作権: Copyright (c) 2003-2005
 * 会社名: 沌珍館企画
 * @author 開発部ケータイアプリ課iアプリTeam
 * @version 1.5i
 */

public class kaibun extends IApplication {
	public	static	Panel1 p1;

	public void start() {
		p1 = new Panel1(this);
		Display.setCurrent(p1);
	}
}

class Panel1 extends Panel implements SoftKeyListener {
	//  タイトル
	String title0 = "『回文ちゃん』V1.5i";
	String title1 = "『回文ちゃん』V1.5i\n"+
			"2005/05(c)沌珍館企画\n"+
			"info@tonchinkan.office.ne.jp";
	TextBox textbox1;
	ListBox listbox1, listbox2;
	//  メールへのコピー用
	public static String mailtext;
	//  空白変換用
	String b0 = " ";
	String b1 = "_";
	//  小大文字変換用
	String t0 = "あいうえおつやゆよわアイウエオツヤユヨワ";
	String t1 = "ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ";
	//  カナかな変換用
	String k0 = "あいうえおかきくけこさしすせそたちつてとなにぬねの"
		+ "はひふへほまみむめもやゆよらりるれろわをん"
		+ "がぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽ";
	String k1 = "アイウエオカキクケコサシスセソタチツテトナニヌネノ"
		+ "ハヒフヘホマミムメモヤユヨラリルレロワヲン"
		+ "ガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポ";
	//  初期清音列作成用
	String d0 = "かきくけこさしすせそたちってとはひふへほはひふへほおっゃゅょ";
	String d1 = "がぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽをつやゆよ";
	//  濁音半濁音変換用
	String c0 = "あいうえおかきくけこさしすせそたちつてとなにぬねの"
		+ "はひふへほまみむめもやゆよゃゅょらりるれろわをん"
		+ "がぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽっ";
	String c1 = "あいうえをがぎぐげござじずぜぞだぢづでどなにぬねの"
		+ "ばびぶべぼまみむめもゃゅょやゆよらりるれろわおん"
		+ "かきくけこさしすせそたちってとぱぴぷぺぽはひふへほつ";

	StringBuffer    str1 = new StringBuffer("");   //  listbox1展開用の4文
	String          str2;   //  listbox2展開用の初期清音
	String          ss;     //  StingBuffer sのString

	Panel1(IApplication app) {
		ListenerClass lclass = new ListenerClass();
		this.setComponentListener(lclass);
		Font font1 = Font.getFont(Font.SIZE_LARGE);
		//  タイトル行
		setTitle(title0);
		//  入力行
		textbox1 = new TextBox("",getWidth(),1,TextBox.DISPLAY_ANY);
		this.add(textbox1);
		//  生成行
		listbox1 = new ListBox(ListBox.SINGLE_SELECT);
		this.add(listbox1);
		listbox1.setVisible(false);
		//  展開行
		listbox2 = new ListBox(ListBox.SINGLE_SELECT);
		this.add(listbox2);
		listbox2.setVisible(false);
		//  ソフトキー
		setSoftLabel(Frame.SOFT_KEY_1, "終了");
		setSoftLabel(Frame.SOFT_KEY_2, "戻る");
		setSoftKeyListener(this);
	}

	public void softKeyPressed(int no) {
		if (Frame.SOFT_KEY_1 == no) {
			Dialog dlg2 = new Dialog (Dialog.DIALOG_YESNO, "COPYRIGHT");
			dlg2.setText(title1);
			if (dlg2.show() == Dialog.BUTTON_YES) {
				IApplication.getCurrentApp().terminate();
			}
		} else if (Frame.SOFT_KEY_2 == no) {
			setTitle(title0);
			textbox1.requestFocus();
			listbox1.removeAll();
			listbox1.setVisible(false);
			listbox2.removeAll();
			listbox2.setVisible(false);
		}
	}
	public void softKeyReleased(int no) {
	}

	boolean ValidCheck(StringBuffer s) {
		String s0 = "をんっゃゅょー";
		String v0 = "ゃゅょ";
		String v1 = "きしちにひみりぎじぢびぴ";
		ss = s.toString();  //  sを実体化
		//  先頭検査
		if (s0.indexOf(s.charAt(0)) != -1) {return false;};
		//  句内検査
		if (ss.indexOf("をを") != -1) {return false;};
		if (ss.indexOf("をん") != -1) {return false;};
		if (ss.indexOf("んん") != -1) {return false;};
		if (ss.indexOf("っっ") != -1) {return false;};
		if (ss.indexOf("ーー") != -1) {return false;};
		//  拗音検査 ("ゃゅょ"を見付けたら直前が相応しいか検査)
		int i,l;
		l = s.length();
		for (i = 1 ; i < l ; i++) {
			if (v0.indexOf(s.charAt(i)) > -1) {
				if (v1.indexOf(s.charAt(i-1)) < 0) {return false;}
			}
		}
		//  合格なら
		return true;
	}

	public void MakeOriginal() {
		StringBuffer strR = new StringBuffer(textbox1.getText().trim());
			//  入力行を左半分に入れる
		int i;  //  処理中の文字の位置
		int n;  //  左半分の長さ
		int p;  //  発見した文字の位置
		n = strR.length();
		//  空白を可視化
		for (i = 0; i < n; i++) {
			if (strR.charAt(i) == b0.charAt(0)) {
				strR.setCharAt(i,b1.charAt(0));
				}
			}
		String strL = strR.toString();  //  左半分を固定化
		//  まず反転
		strR.reverse(); //  右半分を反転
		//  右半分の小文字→大文字
		for (i = 0; i < n; i++) {
			p = t1.indexOf(strR.charAt(i));
			if (p != -1) {
				strR.setCharAt(i,t0.charAt(p));
			}
			//  右半分のカタカナ→ひらがな
			p = k1.indexOf(strR.charAt(i));
			if (p != -1) {
				strR.setCharAt(i,k0.charAt(p));
			}
		}
		//  奇数句(あいうえういあ)
		str1.delete(0,str1.length()).append(strL).append(strR).deleteCharAt(strL.length());
		if (ValidCheck(str1)) {listbox1.append(str1.toString());};
		// 反転奇数句(えういあいうえ)
		str1.delete(0,str1.length()).append(strR).append(strL).deleteCharAt(strL.length()-1);
		if (ValidCheck(str1)) {
			if (listbox1.getItem(0).trim()!=str1.toString().trim()) {
				listbox1.append(str1.toString());
			}
		};
		//  偶数句(あいうええういあ)
		str1.delete(0,str1.length()).append(strL).append(strR);
		if (ValidCheck(str1)) {listbox1.append(str1.toString());};
		//  反転偶数句(えういああいうえ)
		str1.delete(0,str1.length()).append(strR).append(strL);
		if (ValidCheck(str1)) {
				listbox1.append(str1.toString());
		};
	}

	private void SetInit() {
		//  初期清音を作る
		int i;  //  処理中の文字の位置
		int l;  //  文字列の長さ
		int p;  //  発見した文字の位置
		StringBuffer s = new StringBuffer(str2);
		l = s.length();
		for (i=0; i<l; i++) {
			p = d1.indexOf(s.charAt(i));
			if (p != -1) {
				s.setCharAt(i,d0.charAt(p));
			}
		}
		if (ValidCheck(s)) {
			listbox2.append(s.toString());
		};
		str2 = s.toString();
	}

	private void MakeVariation() {
		String s1 = str2;
		StringBuffer s2 = new StringBuffer(s1);
		int p,k;
		do {
			 k = s2.length();  //  右端から始める
			do {
				p = c0.indexOf(s2.charAt(k-1));
				// ともかくc0からc1にする
				if (p != -1) {
					s2.setCharAt(k-1,c1.charAt(p));
				}
				if (s2.toString().compareTo(s1) <= 0) {
					k--;    // 変わらずか繰り上がりなら視点を上げる
				};
			} while (s2.toString().compareTo(s1) <= 0 && k > 0);
			// 次が出来るか左端まで行ったかまで
			if ( s2.toString().compareTo(s1) != 0 ) {
				if (ValidCheck(s2) && (s2.toString().compareTo(str2) != 0)) {
					listbox2.append(s2.toString());
				};
				s1 = s2.toString();
			}
		} while (s2.toString().compareTo(str2) != 0); //  初期清音に戻れば終了
		setTitle(listbox2.getItemCount()+"パターン");
	}

	class ListenerClass implements ComponentListener {
		public void componentAction(Component c, int type, int param) {
		if (c == textbox1) {
			if (textbox1.getText().trim().compareTo("") == 0) {
				setTitle(title0);
				textbox1.requestFocus();
				listbox1.removeAll();
				listbox2.removeAll();
				listbox1.setVisible(false);
				listbox2.setVisible(false);
			}
			else {
				setTitle(title0);
				listbox1.removeAll();
				listbox2.removeAll();
				listbox1.setVisible(true);
				listbox2.setVisible(false);
				MakeOriginal();
				listbox1.requestFocus();
			}
		}
		else if (c == listbox1) {
			listbox2.removeAll();
			listbox1.setVisible(true);
			listbox2.setVisible(true);
			str2 = listbox1.getItem(param);
			SetInit();
			MakeVariation();
			listbox2.requestFocus();
			}
		else if (c == listbox2) {
			mailtext = listbox2.getItem(param).toString();
			Display.setCurrent(new Canvas1());
			listbox2.requestFocus();
			}
		}
	}

	// パネル側のテキストをキャンバス側のエディタに渡す
	public static String getmailtext() {
		return(mailtext);
	}

}

class Canvas1 extends Canvas {

	public Canvas1() {
	}

	public void paint(Graphics g) {
		// エディタ画面にする
		imeOn(Panel1.getmailtext(),TextBox.DISPLAY_ANY,TextBox.KANA);
	}

	public void processEvent(int type, int param) {
		super.processEvent(type, param);
	}

	public void processIMEEvent(int type, String text) {
		Display.setCurrent(kaibun.p1); // パネルへ戻る
	}

}

戻る

Copyright(C) 2004-2015 沌珍館企画