/* * luna.java * * DATE : 2010/06/22 09:24 */ /* * LoveCute.java * * Created on 2003/03/31, 22:40 * * forte --> eclispe * Porting on 16 jan 04 * */ import com.nttdocomo.ui.*; import com.nttdocomo.io.*; import java.io.*; import javax.microedition.io.Connector; /** * luna * * @author NAME */ public class luna extends IApplication { public void start() { /* * The program of IApplication is written here. */ Display.setCurrent(new MainPanel()); } } /** * MainPanel * */ class MainPanel extends Canvas { // int cellwidth[] = new int[32]; String celltext[][] = new String[32][4096]; int xmax = 32; int ymax = 4096; int xtop = 0; int ytop = 0; int xpos = 1; int ypos = 1; int xend = 1; int yend = 1; int xhoz = xmax - 1; int yhoz = ymax - 1; String bunshomei = ""; // Point tposi = new Point(); int tposix = 0; int tposiy = 0; int mojiwidth = 8; int keystop = 0; int tfini = 0; int xmov = 0; int ymov = 0; String subtitle = ""; // public MainPanel() { // 8 apr 03 for (int j=0; j Display.getHeight()){ yend = k; break; } }// k m = m + cellwidth[j] + 4; if (m > Display.getWidth()){ xend = j; break; } }// j } // 15 apr 03 public void processEvent(int type,int param) { if(type==Display.KEY_PRESSED_EVENT) { int ylin = yend - ytop + 1; if(param==Display.KEY_LEFT) { hako(0); xpos = xpos - 1; if (xpos < 0){xpos = 0;} if (xpos < xtop){ xtop = xpos; repaint(); } hako(1); } if(param==Display.KEY_RIGHT) { hako(0); xpos = xpos + 1; if (xpos > xmax - 1){xpos = xmax - 1;} if (xpos > xend){ xtop = xtop + 1; if (xtop > xmax - 1){xtop = xmax - 1;} repaint(); xpos = xend;// 9 jan 05 } hako(1); xmov = 1; ymov = 0; } if(param==Display.KEY_UP) { hako(0); ypos = ypos - 1; if (ypos < 0){ypos = 0;} if (ypos < ytop){ ytop = ypos; repaint(); } hako(1); } if(param==Display.KEY_DOWN) { hako(0); ypos = ypos + 1; if (ypos > ymax - 1){ypos = ymax - 1;} if (ypos > yend){ ytop = ytop + 1; if (ytop > ymax - ylin){ytop = ymax - ylin;} repaint(); } hako(1); xmov = 0; ymov = 1; } if(param==Display.KEY_SOFT1) { ytop = ytop - ylin; if (ytop < 0){ytop = 0;} ypos = ypos - ylin; if (ypos < 0){ypos = 0;} repaint(); } if(param==Display.KEY_SOFT2) { ytop = ytop + ylin; if (ytop > ymax - ylin){ytop = ymax - ylin;} ypos = ypos + ylin; if (ypos > ymax - 1){ypos = ymax - 1;} repaint(); } } } // 12 apr 03 public int hikaku(int r, int s){ if (r == 0 || s == 0 || celltext[r][s].length() == 0){ return 0; }// 21 apr 03 String h = celltext[r][s].substring(0, 1); // 17 jan 04 if (h.equals("1")){ return 1; } else if (h.equals("2")){ return 1; } else if (h.equals("3")){ return 1; } else if (h.equals("4")){ return 1; } else if (h.equals("5")){ return 1; } else if (h.equals("6")){ return 1; } else if (h.equals("7")){ return 1; } else if (h.equals("8")){ return 1; } else if (h.equals("9")){ return 1; } else if (h.equals("0")){ return 1; } else if (h.equals("-")){ return 1; } else { return 0; } } // 17 apr 03 public void hako(int u) { // 9 apr 03 Graphics grap = getGraphics(); // 6 apr 03 int m = 0; int n = 0; int o = 0; int p = 14; int q = 0; for (int j=xtop; j Display.getWidth()){ xend = j; break; } } o = cellwidth[xpos]; for (int k=ytop; k Display.getHeight()){ yend = k; break; } } // 8 apr 03 if (u == 1){ grap.setColor(Graphics.getColorOfName(Graphics.LIME)); } else if (xpos == 0 || ypos == 0){ grap.setColor(Graphics.getColorOfName(Graphics.AQUA)); } else { grap.setColor(Graphics.getColorOfName(Graphics.YELLOW)); } grap.fillRect(m, n, o, p); grap.setColor(Graphics.getColorOfName(Graphics.GRAY)); grap.fillRect(m, n+p, o, 4); grap.fillRect(m+o, n, 4, p+4); // 24 apr 03 tposix = m; tposiy = n; // 9 apr 03 q = celltext[xpos][ypos].length() * mojiwidth; if (xpos == 0 || hikaku(xpos, ypos) == 1){ q = m + cellwidth[xpos] - q; } else if (ypos == 0){ q = m + (cellwidth[xpos] - q) / 2; } else { q = m; } // 7 apr 03 grap.setColor(Graphics.getColorOfName(Graphics.BLACK)); grap.drawString(celltext[xpos][ypos], q, n+p-2); } // 31 may 03 public void filread(String filname){ int f = 0; BufferedReader buff = null; try{ InputStream instream = Connector.openInputStream("resource:///"+filname); InputStreamReader inreader = new InputStreamReader(instream); buff = new BufferedReader(inreader); String data = buff.readLine(); int n = data.indexOf(","); int o = data.length(); String g = data.substring(0,n); String h = data.substring(n+1,o); int p = Integer.parseInt(g); int q = Integer.parseInt(h); xhoz = p+1; yhoz = q+1; if (xhoz>=xmax){ xhoz=xmax-1; } if (yhoz>=ymax){ yhoz=ymax-1; } int j = 1; int k = 1; int l = 0; cellwidth[j] = 30;// 8 jan 05 while ((data = buff.readLine()) != null){ // 1 jun 03 if (jq+1){ k = 1; j++; if (j>p+1){ break; } cellwidth[j] = 30;// 8 jan 05 } if (cellwidth[j] < data.length()*10){ cellwidth[j] = data.length()*10; } } if ((data = buff.readLine()) != null){ l = data.length();// 12 jun 03 subtitle = data.substring(1,l-1); } inreader.close(); } catch(IOException e){ System.out.println("Error"+e); } bunshomei = filname; // 1 jun 03 if (f == 1){ celltext[0][0]="ERR"; } } }