This is the web version of EJS interface
EJS version 4.2.7
  1. Author=Fu-Kwun Hwang - Dept. of Physics, National Taiwan Normal Univ.
  2. Abstract=hwang@phy.ntnu.edu.tw
  3. CaptureTools=true
  4. DataTools=true
  5. LanguageTools=true
  6. EmersionSupport=false
  7. UseInterpreter=true
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Init Page

    if(dial){ x0=x2; }else x0=x2+zero; dx=(x4-x2-zero-size)/(nm-1); for(int i=0;i<nm;i++){ xcm[i]=x0+i*dx; if(i%10==0){ ycm[i]=size*2.; xcms[i/10]=xcm[i]; }else if(i%5==0)ycm[i]=size*1.5; else ycm[i]=size*1.; } din=dx*25.4/40; if(inch && dial){ yinm=y4; ysc=1; }else{ yinm=y3; ysc=-1; }

    FixRel Page

    x=xd-x2; xt[4]=xt[5]=-x; id=0; if(dial && inch)sinch=0; else sinch=1.; for(int i=0;i<ni;i++){ xin[i]=x0+i*din; if(i%40==0){ yin[i]=ysc*size*2.; xins[id]=xin[i]; yins[id]=yinm+yin[i]*1.3; sins[id]=(i/40%10)+""; id++; }else if(i%4==0){ yin[i]=ysc*size*1.2; xins[id]=xin[i]; yins[id]=yinm+yin[i]*1.5; sins[id]=(i/4%10)+""; id++; }else yin[i]=ysc*size*sinch; } vin=(int)(x/din/40.*1000.+0.5)/1000.; if(dial){ dc=2*pi/ndial; xc=x2+x+R; for(int i=0;i<ndial;i++){ c=i*dc; dialx[i]=xc+R*Math.sin(c); dialy[i]=R*Math.cos(c); if(i%10==0){ r=-0.3; dials[i/10]=i+""; dialxs[i/10]=xc+0.6*R*Math.sin(c); dialys[i/10]=0.6*R*Math.cos(c); }else if(i%5==0)r=-0.2; else r=-0.1; dialdx[i]=r*R*Math.sin(c); dialdy[i]=r*R*Math.cos(c); } if(inch){ v=vin; dialmsg=".001''"; c=((int)(v*1000.+0.5)%1000)*dc; }else{ v=(int)(x/dx*100.+0.5)/100.; dialmsg=".01mm"; c=((int)(v*100.+0.5)%1000)*dc;//2* pi/ndial; } dialxc=0.85*R*Math.sin(c); dialyc=0.85*R*Math.cos(c); if(inch){ vmsg="d= "+v; if((int)(v*1000)%100==0)vmsg+="00"; else if((int)(v*1000)%10==0)vmsg+="0"; vmsg+=" inch"; }else{ vmsg="d= "+v; if((int)(v*100)%10==0)vmsg+="0"; vmsg+=" mm"; } // dial }else{ vin2=(int)(vin*1000.) %1000; vin3=vin2 %25; vin4=vin2%100- vin3; v=((int)(x/dx*20.+0.5))/20.; v2=(int)(v*20.+0.5)%20; if(show){ vmsg="d= "+ v; if(v==0)vmsg+="00"; else if(v*10-(int)(v*10)==0)vmsg+="0"; vmsg+=" mm = "+vin2/1000.; if(vin2%100==0)vmsg+="00"; else if(vin2%10==0)vmsg+="0"; vmsg +=" inch = ("+((vin2-vin3)/1000.); if((vin2-vin3) %100==0)vmsg+="00"; else if((vin2-vin3)%10==0)vmsg+="0"; if(vin3<10)vmsg+=" + 0.00"+vin3+") inch"; else vmsg+=" + 0.0"+vin3 +") inch"; }else { vmsg="d = ??? "; } dx2=dx*0.95; delta=xcm[(int)v+v2]-(x+x0+v2*dx2); for(int i=0;i<nm2;i++){ xcm2[i]=x+x0+i*dx2+delta; if(i%2==0){ ycm2[i]=-size*1.5; xcms2[i/2]=xcm2[i]; }else ycm2[i]=-size; } din2=din*24/25; delta=xin[(int)vin2/25 +vin3]-(x+x0+vin3*din2); for(int i=0;i<ni2;i++){ xin2[i]=x+x0+i*din2+delta; if(i%5==0){ xins2[i/5]=xin2[i]; yin2[i]=size*1.5; }else yin2[i]=size; } } tdmin=x-(xtail-x4); if(tdmin<size)tdmin=size; arrowdx[0]=arrowdx[2]=-x/2; arrowdx[1]=arrowdx[3]=x/2; if(yo+h/2>y5){ if(xd>xo+w/2)enableleft=true; else enableleft=false; }else{ if(x>0)enableleft=true; else enableleft=false; } enableright=true; if(diameter && x>=w2)enableright=false; else if(tail && x>=xtail-x4+td)enableright=false;
    double dv; public double dvalue (double v) { if(v>0)dv=0.5; else if(v<0)dv=-0.5; else dv=0; return (int)(v*100+dv)/100.; }
    public void dragx () { if(xd<x2)xd=x2; xc=xd+R; if(tail && xd-x2>xtail-x4+td){ //if(xd-x2+x4-td<xmax-size)xtail=xd-x2+x4-td; xd=x2+td+xtail-x4; } if(yo>y5 &&xd<xo+w/2)xd=xo+w/2; if(diameter){ if(xd-x2>w2)xd=x2+w2; if(xd-x2<size*1.5)xd=x2+size*1.5; } if(xd>x4-14*size)xd=x4-14*size; }
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double,double,double,double
    title="Frame"
    layout=border
    visible=true
    location="71,-35"
    size="935,558"
    position=center
    autoscaleX=false
    autoscaleY=false
    minimumX=xmin
    maximumX=xmax
    minimumY=ymin
    maximumY=ymax
    square=true
    background=BLACK
    xData=xt
    yData=yt
    x=x4+x
    y=y4/4
    lineColor=128,192,0
    fillColor=128,192,0
    xData=xu
    yData=yu
    x=xd
    y=0+0
    enabledPosition=true
    dragAction=dragx ()
    lineColor=128,192,0
    fillColor=192,128,64
    lineWidth=stroke
    xData=xb
    yData=yb
    sensitivity=0
    lineColor=128,0,128
    fillColor=128,64,0
    lineWidth=stroke
    numberOfElements=ni
    x=xin
    y=yinm
    sizeX=0
    sizeY=yin
    visible=!dial || inch
    lineColor=128,255,255
    numberOfElements=nm
    x=xcm
    y=y4
    sizeX=0
    sizeY=ycm
    visible=!(dial && inch)
    lineColor=128,255,255
    xData=xm
    yData=ym
    x=xd
    y=y4+size2/2
    enabledPosition=true
    dragAction=dragx ()
    lineColor=128,192,0
    fillColor=192,128,64
    numberOfElements=nm2
    x=xcm2
    y=y4+size2/2
    sizeX=0
    sizeY=ycm2
    visible=!dial
    lineColor=128,255,255
    numberOfElements=ni2
    x=xin2
    y=y3
    sizeX=0
    sizeY=yin2
    visible=!dial
    lineColor=128,255,255
    x=xo
    y=yo
    sizeX=w
    sizeY=h
    enabledPosition=true
    sensitivity=0
    dragAction=if(x<w){ if(yo+h/2>y5)yo=y5-h/2; } if(yo+h/2>y4)yo=y4-h/2; if(yo+h/2>y5){ if(xo<x2+w/2)xo=x2+w/2; else if(xo+w/2>xd)xo=xd-w/2; }
    style=ROUND_RECTANGLE
    elementposition=CENTERED
    lineColor=null
    fillColor=GRAY
    xData=xu2
    yData=yu2
    x=xm2
    y=ym2
    visible=diameter
    fillColor=128,128,0
    numberOfElements=id%25
    x=xins
    y=yins
    pixelSize=true
    visible=!dial || inch
    text=%sins%
    font=Monospaced,PLAIN,15
    lineColor=192,255,0
    fillColor=192,255,0
    numberOfElements=7
    x=xcms
    y=y4+size*2.2
    pixelSize=true
    visible=!(dial && inch)
    text=%cms%
    font=Monospaced,BOLD,16
    elementposition=SOUTH
    lineColor=192,255,0
    fillColor=192,255,0
    numberOfElements=6
    x=xins2
    y=y3+2*size
    pixelSize=true
    visible=!dial
    text=%ins%
    lineColor=192,255,0
    fillColor=192,255,0
    numberOfElements=11
    x=xcms2
    y=y4-size*1.7
    pixelSize=true
    visible=!dial
    text=%cms%
    font=Monospaced,BOLD,12
    elementposition=NORTH
    lineColor=192,255,0
    fillColor=192,255,0
    x=xc
    y=0+0
    sizeX=2*R
    sizeY=2*R
    visible=dial
    enabledPosition=true
    dragAction=xd=xc-R; dragx();
    lineColor=DARKGRAY
    fillColor=GRAY
    x=xc
    y=0+0
    sizeX=dialxc
    sizeY=dialyc
    visible=dial
    lineColor=255,192,0
    fillColor=255,128,0
    numberOfElements=10
    x=dialxs
    y=dialys
    pixelSize=true
    visible=dial
    text=%dials%
    font=Monospaced,BOLD,16
    lineColor=64,64,0
    fillColor=64,64,0
    numberOfElements=ndial
    x=dialx
    y=dialy
    sizeX=dialdx
    sizeY=dialdy
    visible=dial
    lineColor=128,0,128
    x=xc
    y=-2*size
    pixelSize=true
    visible=dial
    text=%dialmsg%
    lineColor=64,255,64
    fillColor=64,255,64
    x=xc-din/2
    y=-size2
    sizeX=0
    sizeY=-size
    visible=dial
    lineColor=192,0,64
    x=xc+din/2
    y=-size2
    sizeX=0
    sizeY=-size
    visible=dial
    lineColor=192,0,64
    x=x2+x/4
    y=y5-size2
    pixelSize=true
    text=%vmsg%
    font=Monospaced,BOLD,16
    elementposition=WEST
    lineColor=LIGHTGRAY
    fillColor=LIGHTGRAY
    x=xcm2[v2]
    y=y4-3*size
    sizeX=0
    sizeY=2*size
    visible=!dial
    lineColor=192,0,128
    fillColor=192,0,128
    numberOfElements=4
    x=x2+x/2
    y=arrowy
    sizeX=arrowdx
    sizeY=0
    lineColor=64,128,0
    fillColor=64,128,0
    x=xin2[vin3]
    y=y3+3*size
    sizeX=0
    sizeY=-2*size
    visible=!dial
    lineColor=192,0,128
    fillColor=192,0,128
    x=xcms2[10]+size2
    y=y4-size*1.7
    pixelSize=true
    visible=!dial
    text=".05mm"
    font=Monospaced,BOLD,12
    elementposition=NORTH_WEST
    lineColor=128,0,128
    fillColor=128,0,128
    xData=ox
    yData=oy
    x=xtail
    y=y4/6
    visible=tail
    enabledPosition=true
    dragAction=if(xtail-x4+td<x)xtail=x+x4-td; if(xtail<x4)xtail=x4;
    fillColor=128,128,0
    numberOfElements=2
    x=x4+x/2
    y=y4/4-size2/2
    sizeX=arrowdx
    sizeY=0
    lineColor=255,0,128
    fillColor=255,0,128
    x=xins2[5]+2*size2
    y=y3+2*size
    pixelSize=true
    visible=!dial
    text=".001''"
    font=Monospaced,BOLD,12
    elementposition=WEST
    lineColor=128,0,128
    fillColor=128,0,128
    position=south
    layout=HBOX
    borderType=LOWERED_ETCHED
    background=GRAY
    text="Reset"
    image=/org/opensourcephysics/resources/controls/images/reset.gif
    action=_reset()
    background=BLACK
    foreground=64,255,0
    variable=show
    text="show"
    foreground=255,255,0
    variable=diameter
    text="inner diameter"
    action=dragx ()
    foreground=255,255,0
    variable=tail
    text="depth"
    foreground=255,255,0
    variable=dial
    selected=true
    text="dial"
    action=_initialize()
    foreground=255,255,0
    variable=inch
    selected=true
    text="inch"
    enabled=dial
    action=_initialize()
    foreground=255,255,0
    image="/org/opensourcephysics/resources/controls/images/stepback.gif"
    enabled=enableleft
    action=if(dial){ if(inch)xd-=din/25.; else xd-=dx/100.; }else{ if(inch)xd-=din/25.; else xd-=dx/20.; } dragx();
    background=128,64,0
    image="/org/opensourcephysics/resources/controls/images/stepforward.gif"
    enabled=enableright
    action=if(dial){ if(inch)xd+=din/25.; else xd+=dx/100.; }else{ if(inch)xd+=din/25.; else xd+=dx/20.; } dragx();
    background=128,64,0
    layout=HBOX
    background=128,64,0
    variable=x
    minimum=0.0
    maximum=w2
    dragaction=xd=x2+x; dragx();
    background=64,64,0
    variable=w
    minimum=0.0
    maximum=x2+x-xs
    pressaction=xs=xo-w/2;
    dragaction=xo=xs+w/2;
    background=255,128,0
    variable=w2
    minimum=xd-x2
    maximum=xmax*1.5
    enabled=diameter
    dragaction=xu2[2]=xu2[3]=w2+4*size; xu2[4]=xu2[5]=w2+2*size;
    background=128,192,0
    variable=td
    minimum=tdmin
    maximum=td2
    enabled=tail
    dragaction=ox[2]=ox[3]=td;
    background=64,64,0