import java.applet.Applet; import java.awt.event.*; import java.awt.*; import java.awt.geom.*; public class SelectRing { double x,y,w,h; String S; int on; Font FONT; boolean CORRECT; int[] PREVECTOR=new int[3]; ListenSquare MAIN,SEND; /*rectangle*/ public SelectRing(String S) { this.S=S; } public SelectRing(double x,double y,double w,double h,String S) { this.x=x; this.y=y; this.w=w; this.h=h; this.FONT=new Font("Helvetica",Font.PLAIN,12); this.S=S; MAIN=new ListenSquare(x,y,w,h); CORRECT=true; } /* drawing methods */ public void render(Graphics g,Color C1,Color C2,Color C3,Color C4) { int n1=S.length(); g.setColor(C1); if(CORRECT==false) g.setColor(C2); g.fillRect((int)(x),(int)(y),(int)(w),(int)(h)); if(on==1) g.setColor(C3); g.drawRect((int)(x),(int)(y),(int)(w),(int)(h)); g.setColor(C4); g.setFont(FONT); g.drawString(S,(int)(x+3),(int)(y+h-2)); } /**evaluating the text*/ public boolean setValues() { try{ int[] X=evaluate(); PREVECTOR[0]=X[0]; PREVECTOR[1]=X[1]; PREVECTOR[2]=X[2]; } catch(Exception e) {} return(true); } /**processing the text*/ public int countPM() { return(countPM(S)); } public int countPM(String T) { int count1=0; int n=T.length(); for(int i=0;i=0)&&(val<=9)) { return(true); } return(false); } public void accept(int x,int y) { Integer X=new Integer(x); Integer Y=new Integer(y); if(y==0) S=X.toString(); if(y>0) S=X.toString()+"+"+Y.toString()+"s"; if(y<0) S=X.toString()+" "+Y.toString()+"s"; setValues(); } public boolean activate(Point X) { if(MAIN.inside(X)==1) on=1; if(MAIN.inside(X)==0) on=0; return(false); } public boolean modify(KeyEvent e) { if(on==0) return(false); int n=S.length(); char ch=e.getKeyChar(); if(isDigit(ch)==true) S=S+ch; int val=0; val=(int)(ch-'s'); if(val==0) S=S+"s"; val=(int)(ch-'t'); if(val==0) S=S+"t"; val=(int)(ch-'+'); if(val==0) S=S+"+"; val=(int)(ch-'-'); if(val==0) S=S+"-"; val=(int)(ch-' '); if(val==0) S=S+" "; if (ch==KeyEvent.VK_BACK_SPACE) { if(n>0) S=S.substring(0,n-1); } if (ch==KeyEvent.VK_DELETE) { S="22"; } if(S.length()>50) S=S.substring(0,n-1); setValues(); return(true); } }