import com.gzdxid.chemicalelements.SV_main; public class ScreenClick { public float x,y; public int I=-1,J=-1; public int priviousI=0,previousJ=0; public float xSpan,ySpan,xOffset,yOffset; public ScreenClick(float xSpan,float ySpan) { // TODO Auto-generated constructor stub this.xSpan=xSpan; this.ySpan=ySpan; this.xOffset=xSpan; this.yOffset=ySpan-10; } public void setCoor1(float x,float y){ this.x=x; this.y=y; judge1(); } public void setCoor2(float x,float y){ this.x=x; this.y=y; judge2(); } public void judge1(){ label1 :for(int i=0;i<10;i++){ for(int j=0;j<13;j++){ if(i%2==0){ if(isInRect_ou(i,j)){ SV_main.x1=i;SV_main.y1=j; if(priviousI==i&&previousJ==j){ SV_main.count=1; }else { SV_main.count=0; if(SV_main.colorEdgeFlag1){ SV_main.x1=priviousI;SV_main.y1=previousJ; SV_main.saveIndex[1]=getPreviousElementIndex(); } } I=i;J=j; priviousI=i;previousJ=j; break label1; } }else { if(isInRect_ji(i,j)){ SV_main.x1=i;SV_main.y1=j; if(priviousI==i&&previousJ==j){ SV_main.count=1; }else { SV_main.count=0; if(SV_main.colorEdgeFlag1){ SV_main.x1=priviousI;SV_main.y1=previousJ; SV_main.saveIndex[1]=getPreviousElementIndex(); } } I=i;J=j; priviousI=i;previousJ=j; break label1; } } } } } public void judge2(){ label1 :for(int i=0;i<10;i++){ for(int j=0;j<13;j++){ if(i%2==0){ if(isInRect_ou(i,j)){ SV_main.x2=i;SV_main.y2=j; I=i;J=j; break label1; } }else { if(isInRect_ji(i,j)){ SV_main.x2=i;SV_main.y2=j; I=i;J=j; break label1; } } } } } private boolean isInRect_ou(int i,int j) { // TODO Auto-generated method stub if(xSpan*j+xOffset+50<x&&x<xSpan*(j+1)+50+xOffset&&ySpan*i+yOffset<y&&y<ySpan*(i+1)+yOffset){ return true; } return false; } private boolean isInRect_ji(int i,int j) { // TODO Auto-generated method stub if(xSpan*j+xOffset*0.5f+50<x&&x<xSpan*(j+1)+xOffset*0.5f+50&&ySpan*i+yOffset<y&&y<ySpan*(i+1)+yOffset){ return true; } return false; } public float getX(){ return x; } public float getY(){ return y; } public int getI(){ return I; } public int getJ(){ return J; } public int getElementIndex(){ //点击按钮输出对应的坐标,system。out if(I==3&&J==10){ return 0;//na } if(I==2&&J==1){ return 1;//cl } if(I==7&&J==5){ return 2;//h } if(I==6&&J==5){ return 3;//o } return 0; } public int getPreviousElementIndex(){ //点击按钮输出对应的坐标,system。out if(priviousI==3&&previousJ==10){ return 0;//na } if(priviousI==2&&previousJ==1){ return 1;//cl } if(priviousI==7&&previousJ==5){ return 2;//h } if(priviousI==6&&previousJ==5){ return 3;//o } return 0; } }