import com.nttdocomo.ui.*; import java.io.*; public class Station extends IApplication { public void start() { StationPanel ap = new StationPanel(this); Display.setCurrent(ap); } } class StationPanel extends Panel implements SoftKeyListener { private IApplication iApp; private ListBox lst1; private TextBox txt1; private int i,j,cnt,sct; private int honsuu1 = 79; private int honsuu2 = 75; private long now; private String rst,sh,sm,pic1,pic2; private byte[] b={(byte)0xF8,(byte)0xBC}; //上りデータ private int jikoku1[] = { 347,3,4,3,3, 363,0,0,0,23, 366,3,4,4,4, 388,4,5,4,5, 396,3,4,3,6, 400,4,4,3,7, 410,0,0,0,21, 413,3,4,3,8, 430,0,0,0,22, 432,3,4,3,8, 443,3,4,4,9, 459,3,4,3,8, 462,4,3,4,7, 478,0,0,0,23, 480,4,3,4,10, 487,3,3,4,9, 490,4,4,5,11, 519,3,4,3,8, 528,0,0,0,24, 541,0,0,0,22, 555,0,0,0,21, 580,3,3,4,8, 592,0,0,0,22, 594,0,0,0,21, 617,4,4,3,7, 642,0,0,0,22, 644,4,4,3,3, 670,0,0,0,22, 702,0,0,0,21, 705,3,4,5,8, 719,0,0,0,21, 734,3,4,3,7, 750,4,4,3,12, 760,0,0,0,22, 763,3,4,4,13, 772,0,0,0,21, 788,4,4,4,14, 805,3,5,3,15, 816,0,0,0,22, 834,0,0,0,21, 854,3,4,3,7, 868,3,3,4,3, 876,0,0,0,25, 882,0,0,0,21, 905,4,4,3,9, 914,0,0,0,21, 923,4,3,4,7, 932,0,0,0,21, 936,0,0,0,22, 939,3,4,3,13, 966,0,0,0,21, 982,3,4,4,7, 989,0,6,0,11, 996,0,0,0,22, 998,4,3,4,16, 1016,0,0,0,21, 1020,4,3,4,4, 1036,0,0,0,24, 1042,4,4,3,8, 1055,0,0,0,22, 1062,3,4,4,9, 1091,3,4,3,17, 1097,3,4,3,7, 1111,0,0,0,21, 1113,3,4,3,8, 1121,0,0,0,22, 1130,0,0,0,21, 1141,3,4,3,9, 1170,3,4,4,8, 1182,3,4,5,18, 1200,0,0,0,21, 1210,3,4,4,15, 1222,0,0,0,22, 1255,3,4,3,13, 1269,3,4,4,7, 1290,4,4,3,5, 1320,3,3,4,8, 1374,3,4,3,9, 1509,0,0,0,25 }; //下りデータ private int jikoku2[] = { 367,4,3,4,1, 401,4,4,4,2, 434,3,3,4,1, 450,4,4,4,1, 463,4,4,5,1, 469,4,3,4,2, 473,4,3,4,1, 482,4,3,4,1, 491,4,3,4,2, 496,4,3,4,1, 500,4,4,3,19, 515,4,3,4,1, 523,4,3,6,1, 534,4,3,4,1, 541,0,0,0,2, 558,4,3,4,2, 569,0,0,0,1, 572,5,3,4,1, 590,0,0,0,2, 599,4,3,4,1, 603,4,3,4,1, 614,0,0,0,1, 628,0,0,0,26, 641,4,3,4,1, 651,0,0,0,2, 678,4,4,4,2, 707,0,0,0,1, 710,0,0,0,2, 733,4,3,4,1, 754,5,3,5,2, 770,0,0,0,2, 794,0,0,0,1, 809,4,3,4,1, 816,0,0,0,1, 830,0,0,0,2, 833,4,3,4,1, 848,4,3,4,2, 872,0,0,0,27, 886,0,0,0,2, 900,4,4,4,2, 934,4,3,4,2, 940,0,0,0,1, 950,0,0,0,2, 986,4,4,4,1, 1000,4,4,4,1, 1010,0,0,0,2, 1038,4,3,4,1, 1046,4,3,4,1, 1057,0,0,0,1, 1070,0,0,0,2, 1091,4,3,4,1, 1097,4,4,4,2, 1113,4,4,4,1, 1121,0,0,0,1, 1130,0,0,0,2, 1133,4,3,4,20, 1171,0,0,0,1, 1190,0,0,0,2, 1193,4,3,4,1, 1205,3,4,3,1, 1212,4,3,4,2, 1247,0,0,0,1, 1257,0,0,0,2, 1260,4,4,4,1, 1276,0,0,0,1, 1279,4,4,4,1, 1287,0,0,0,1, 1290,4,4,4,2, 1325,4,3,4,1, 1349,0,0,0,1, 1378,4,3,4,1, 1390,4,3,4,1, 1426,0,0,0,1, 1682,0,0,0,2, 1700,0,0,0,27 }; //駅名データ private String eki[] = { "松本  ","長野  ","高尾  ","辰野  ","岡谷  ","立川  ","中津川 ","甲府  ", "上諏訪 ","塩尻  ","飯田  ","天竜峡 ","小淵沢 ","木曽福島","茅野  ","大月  ", "富士見 ","上松  ","有明  ","明科  ","新宿  ","名古屋 ","東京  ","千葉  ", "大阪  ","南小谷 ","白馬  " }; // コンストラクタメソッド StationPanel(IApplication ap) { super(); iApp = ap; now = System.currentTimeMillis() / 60000; now = (now + 540) % 1440; sh = String.valueOf(now / 60); if (sh.length() == 1) sh = "0" + sh; sm = String.valueOf(now % 60); if (sm.length() == 1) sm = "0" + sm; // 絵文字の取得 try{ pic1 = new String(b,"SJIS"); b[1] += 2; pic2 = new String(b,"SJIS"); } catch (UnsupportedEncodingException e){} setTitle("My時刻表 " + sh + ":" + sm); //時刻データ展開 for (i = 0;i < honsuu1;i++) { cnt = 0; for (j = 0;j < 3;j++) { if (jikoku1[i*5+j+1] > 0) { cnt += jikoku1[i*5+j+1]; jikoku1[i*5+j+1] = jikoku1[i*5] + cnt; } } } for (i = 0;i < honsuu2;i++) { cnt = 0; for (j = 0;j < 3;j++) { if (jikoku2[i*5+j+1] > 0) { cnt += jikoku2[i*5+j+1]; jikoku2[i*5+j+1] = jikoku2[i*5] + cnt; } } } //リストボックス lst1 = new ListBox(ListBox.CHOICE); lst1.append("松本(中央上り)"); lst1.append("南松本(中央上り)"); lst1.append("村井(中央上り)"); lst1.append("広丘(中央上り)"); lst1.append("塩尻(中央下り)"); lst1.append("広丘(中央下り)"); lst1.append("村井(中央下り)"); lst1.append("南松本(中央下り)"); lst1.select(0); add(lst1); txt1 = new TextBox("",18,6,TextBox.DISPLAY_ANY); add(txt1); txt1.setEditable(false); // ソフトキー1の表示を変更 setSoftLabel(Frame.SOFT_KEY_1, "検索"); // ソフトキー2の表示を変更 setSoftLabel(Frame.SOFT_KEY_2, "EXIT"); // SoftKeyListenerを設定 setSoftKeyListener(this); } // キーを離した時のイベント処理 public void softKeyReleased(int key) { switch(key){ // ソフトキー1の処理 case Frame.SOFT_KEY_1: rst = ""; cnt = 0; sct = lst1.getSelectedIndex(); //上りの場合 if (sct < 4) { for (i = 0 ;i < honsuu1;i++) { if (jikoku1[i*5+sct] >= now && jikoku1[i*5+sct] > 0) { sh = String.valueOf((jikoku1[i*5+sct] % 1440) / 60); if (sh.length() == 1) sh = "0" + sh; sm = String.valueOf(jikoku1[i*5+sct] % 60); if (sm.length() == 1) sm = "0" + sm; rst = rst + sh + ":" + sm + " " + eki[jikoku1[i*5+4]-1]; if (jikoku1[i*5+2] > 0) { rst = rst + pic1 + "\n"; } else { rst = rst + pic2 + "\n"; } cnt++; if (cnt >= 6) { i = honsuu1; break; } } } //下りの場合 } else { for (i = 0 ;i < honsuu2;i++) { if (jikoku2[i*5+sct-4] >= now && jikoku2[i*5+sct-4] > 0) { sh = String.valueOf((jikoku2[i*5+sct-4] % 1440) / 60); if (sh.length() == 1) sh = "0" + sh; sm = String.valueOf(jikoku2[i*5+sct-4] % 60); if (sm.length() == 1) sm = "0" + sm; rst = rst + sh + ":" + sm + " " + eki[jikoku2[i*5+4]-1]; if (jikoku2[i*5+2] > 0) { rst = rst + pic1 + "\n"; } else { rst = rst + pic2 + "\n"; } cnt++; if (cnt >= 6) { i = honsuu2; break; } } } } txt1.setText(rst); break; // ソフトキー2の処理 case Frame.SOFT_KEY_2: iApp.terminate(); } } // 他のキーを押した時のイベント処理(使わない) public void softKeyPressed (int key) {} }