import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Font; import javax.microedition.lcdui.Image; public class functions { int w,h; int fh; int mcr; list menu; Font f; String[] smenu=new String[]{"Сохранить","Вставить микросхему","Изменить размер","Редактировать описание","В конец X","В конец Y","Перейти на позицию","Ускоренный режим"}; String d="MENU"; String snum=""; int num_i=0; Graphics gmc; Image new_mc; int wimg,himg; int[] rot,num; int ii,pmc; int[] copy_rot,copy_num; int mcw,mch, rot_mc=0, rot_now; int[] argb; Image numbers; Image[] number=new Image[10]; int n_i,n_n_i; boolean isBlack; String go_x="",go_y=""; int go_i=0; public functions(int w, int h, Font f) { mcr=0; this.w=w; this.h=h; this.f=f; fh=f.getHeight(); menu=new list(w-w/3, Math.min(smenu.length*(fh+2), h-h/3), Font.getFont(0,1,8)); for(int i=0; i0) snum=snum.substring(0,snum.length()-1); if((k==-6 || k==-5) && !"".equals(snum)) { num_i=Integer.parseInt(snum); newMicroCxema(num_i); } if(k==-11) d="MENU"; if(k==-7) d="MENU"; if(k>=48 && k<=57 && snum.length()<2) snum+=(char)k; } else { switch(k) { case -5: case -6: case 53: if((Math.abs(edit.e.x)+new_mc.getWidth()/wimg)<=edit.e.width && (Math.abs(edit.e.y)+new_mc.getHeight()/himg)<=edit.e.height) { edit.e.mcd.addElement(""+Math.abs(edit.e.x)); edit.e.mcd.addElement(""+Math.abs(edit.e.y)); edit.e.mcd.addElement(""+new_mc.getWidth()/wimg); edit.e.mcd.addElement(""+new_mc.getHeight()/himg); edit.e.mcd.addElement(""+mcr); edit.e.mcd.addElement(""+num_i); ii=0; for(int ih=0; ih0-edit.e.height+1) edit.e.y--; break; case -3: case 52: if(edit.e.x<0) edit.e.x++; break; case -4: case 54: if(edit.e.x>0-edit.e.width+1) edit.e.x--; break; case 51: mcr++; mc_rotate(); break; } } } else if(d.equals("GOTO")){ switch(k){ case -1: go_i=0; break; case -2: go_i=1; break; case -8: case 35: if(go_i==0) go_x=(go_x.length()>0) ? go_x.substring(0, go_x.length()-1) : ""; else if(go_i==1) go_y=(go_y.length()>0) ? go_y.substring(0, go_y.length()-1) : ""; break; case -11: d="MENU"; break; case -5: case -6: edit.e.x=0-Math.min(Integer.parseInt(go_x), edit.e.width-1); edit.e.y=0-Math.min(Integer.parseInt(go_y), edit.e.height-1); d="MENU"; edit.e.d="EDIT"; break; case -7: d="MENU"; break; default: if(k>47 && k<58){ if(go_i==0 && go_x.length()<9) go_x+=(char)k; else if(go_i==1 && go_y.length()<9) go_y+=(char)k; } break; } } else if(d.equals("FAST")){ switch(k){ case -1: case 50: edit.e.y+=20; edit.e.y=Math.min(edit.e.y, 0); break; case -2: case 56: edit.e.y-=20; edit.e.y=Math.max(edit.e.y, 0-edit.e.height+1); break; case -3: case 52: edit.e.x+=20; edit.e.x=Math.min(edit.e.x, 0); break; case -4: case 54: edit.e.x-=20; edit.e.x=Math.max(edit.e.x, 0-edit.e.width+1); break; case -11: case -7: d="MENU"; break; case -5: case -6: case 53: d="MENU"; edit.e.d="EDIT"; break; } } } public void mc_rotate(){ new_mc=Image.createImage(new_mc, 0, 0, new_mc.getWidth(), new_mc.getHeight(), edit.e.rot_f[rot_mc]); rot_mc=edit.e.rot_f[rot_mc]; mcw=new_mc.getWidth()/wimg; mch=new_mc.getHeight()/himg; for(int iw=0; iw