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

    Stopwatch

    double StopwatchTempAngle = 2 * Math.PI / 300 ; //Angle between two ticks. This angle will be used to find position. int StopwatchIndex ; //Iteration index //Draw Ticks for Second hand for(StopwatchIndex = 0 ; StopwatchIndex < 300; StopwatchIndex++) { StopwatchTickSecondX[StopwatchIndex] = StopwatchPositionX + StopwatchSize * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //X position of Second hand in circle StopwatchTickSecondY[StopwatchIndex] = StopwatchPositionY + StopwatchSize * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Y position of Second hand in circle if(StopwatchIndex % 25 == 0) { StopwatchTickSecondSizeX[StopwatchIndex] = - (StopwatchSize/8) * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //Second hand tick size X StopwatchTickSecondSizeY[StopwatchIndex] = - (StopwatchSize/8) * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Second hand tick size Y StopwatchTextSecondX[StopwatchIndex/25] = StopwatchTickSecondX[StopwatchIndex] + 1.2 * StopwatchTickSecondSizeX[StopwatchIndex] ; //Second text X StopwatchTextSecondY[StopwatchIndex/25] = StopwatchTickSecondY[StopwatchIndex] + 1.2 * StopwatchTickSecondSizeY[StopwatchIndex] ; //Second text Y if(StopwatchIndex > 0) StopwatchText[StopwatchIndex/25] = StopwatchIndex/5 + ""; //Text in each 25th position else StopwatchText[0] = "0"; //Text in 0th position StopwatchTextAngle[StopwatchIndex/25] = - StopwatchIndex * StopwatchTempAngle; //Text transformation angle } else if(StopwatchIndex % 5 == 0) { StopwatchTickSecondSizeX[StopwatchIndex] = - (StopwatchSize/10) * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //Second hand tick size X StopwatchTickSecondSizeY[StopwatchIndex] = - (StopwatchSize/10) * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Second hand tick size Y } else { StopwatchTickSecondSizeX[StopwatchIndex] = - (StopwatchSize/14) * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //Second hand tick size X StopwatchTickSecondSizeY[StopwatchIndex] = - (StopwatchSize/14) * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Second hand tick size Y } } //Draw Ticks for Minute hand StopwatchTempAngle = 2 * Math.PI / 60 ; //Angle between two ticks. This angle will be used to find position. for(StopwatchIndex = 0 ; StopwatchIndex < 60; StopwatchIndex++) { StopwatchTickMinuteX[StopwatchIndex] = StopwatchPositionX + (StopwatchSize/2) * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //X position of Minute hand in circle StopwatchTickMinuteY[StopwatchIndex] = (StopwatchPositionY+(StopwatchSize/4)) + (StopwatchSize/2) * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Y position of Minute hand in circle if(StopwatchIndex % 5 == 0) { StopwatchTickMinuteSizeX[StopwatchIndex] = - (StopwatchSize/12) * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //Minute hand tick size X StopwatchTickMinuteSizeY[StopwatchIndex] = - (StopwatchSize/12) * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Minute hand tick size Y StopwatchTextMinuteX[StopwatchIndex/5] = StopwatchTickMinuteX[StopwatchIndex] + 1.2 * StopwatchTickMinuteSizeX[StopwatchIndex] ; //Minute text X StopwatchTextMinuteY[StopwatchIndex/5] = StopwatchTickMinuteY[StopwatchIndex] + 1.2 * StopwatchTickMinuteSizeY[StopwatchIndex] ; //Minute text Y if(StopwatchIndex > 0) StopwatchText[StopwatchIndex/5] = StopwatchIndex + ""; //Text in each 5th position else StopwatchText[0] = "0"; //Text in 0th position StopwatchTextAngle[StopwatchIndex/5] = - StopwatchIndex * StopwatchTempAngle; //Text transformation angle } else { StopwatchTickMinuteSizeX[StopwatchIndex] = - (StopwatchSize/25) * Math.sin(StopwatchIndex * StopwatchTempAngle) ; //Minute hand tick size X StopwatchTickMinuteSizeY[StopwatchIndex] = - (StopwatchSize/25) * Math.cos(StopwatchIndex * StopwatchTempAngle) ; //Minute hand tick size Y } } //initialize second hand degree to 0 StopwatchDegreeSecond = 0 ;

    Stopwatch

    Stopwatch

    //Compute Second hand angle StopwatchRadianSecond = StopwatchDegreeSecond * Math.PI / 180 ; //Compute Secon hand position StopwatchSecondHandX = StopwatchSize * Math.sin(StopwatchRadianSecond) ; StopwatchSecondHandY = StopwatchSize * Math.cos(StopwatchRadianSecond) ; //Compute Minute Hand position StopwatchMinuteHandX = (StopwatchSize/2) * (Math.sin(StopwatchRadianSecond/60)) ; StopwatchMinuteHandY = (StopwatchSize/2) * (Math.cos(StopwatchRadianSecond/60)) ;
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double
    title="Frame"
    layout=border
    visible=true
    location="25,27"
    size="466,382"
    position=center
    autoscaleX=false
    autoscaleY=false
    minimumX=-10
    maximumX=10
    minimumY=-10
    maximumY=10
    square=true
    x=StopwatchPositionX
    y=StopwatchPositionY
    sizeX=2.1 * StopwatchSize
    sizeY=2.1 * StopwatchSize
    style=ELLIPSE
    fillColor=CYAN
    x=StopwatchPositionX
    y=StopwatchPositionY
    sizeX=2 * StopwatchSize
    sizeY=2 * StopwatchSize
    style=ELLIPSE
    fillColor=PINK
    x=StopwatchPositionX + StopwatchSize * Math.cos(1.570)
    y=(StopwatchPositionY + StopwatchSize * Math.sin(1.570))+ (StopwatchSize/7)
    sizeX=StopwatchSize/6
    sizeY=StopwatchSize/4
    visible=true
    enabledPosition=true
    pressAction=if(_isPlaying())_pause(); else _play();
    style=RECTANGLE
    fillColor=BLUE
    x=StopwatchPositionX + StopwatchSize * Math.cos(2.09)
    y=(StopwatchPositionY + StopwatchSize * Math.sin(2.09))+ (StopwatchSize/6)
    sizeX=StopwatchSize/6
    sizeY=StopwatchSize/4
    transformation=30
    visible=true
    enabledPosition=true
    pressAction=_reset()
    style=RECTANGLE
    fillColor=BLUE
    numberOfElements=300
    x=StopwatchTickSecondX
    y=StopwatchTickSecondY
    sizeX=StopwatchTickSecondSizeX
    sizeY=StopwatchTickSecondSizeY
    numberOfElements=60
    x=StopwatchTickMinuteX
    y=StopwatchTickMinuteY
    sizeX=StopwatchTickMinuteSizeX
    sizeY=StopwatchTickMinuteSizeY
    numberOfElements=60
    x=StopwatchTextSecondX
    y=StopwatchTextSecondY
    sizeX=StopwatchSize/15
    sizeY=StopwatchSize/15
    transformation=StopwatchTextAngle
    text=%StopwatchText%
    numberOfElements=60
    x=StopwatchTextMinuteX
    y=StopwatchTextMinuteY
    sizeX=StopwatchSize/20
    sizeY=StopwatchSize/20
    transformation=StopwatchTextAngle
    text=%StopwatchText%
    x=StopwatchPositionX
    y=StopwatchPositionY
    sizeX=StopwatchSecondHandX
    sizeY=StopwatchSecondHandY
    x=StopwatchPositionX
    y=(StopwatchPositionY+(StopwatchSize/4))
    sizeX=StopwatchMinuteHandX
    sizeY=StopwatchMinuteHandY
    fillColor=RED
    x=x
    y=y
    sizeX=w
    sizeY=w
    visible=show
    enabledPosition=ENABLED_ANY
    sensitivity=0
    lineColor=YELLOW
    fillColor=null
    position=south
    layout=border
    visible=StopwatchDegreeSecond>0
    position=center
    variable=factor
    minimum=1.0
    maximum=10.0
    enabled=show
    dragaction=ratio=w/factor;
    position=east
    variable=show
    text="magnifier"
    enabled=StopwatchDegreeSecond>0
    background=YELLOW
    layout=border
    visible=show
    location="25,459"
    size="462,345"
    position=center
    autoscaleX=false
    autoscaleY=false
    minimumX=x-ratio
    maximumX=x+ratio
    minimumY=y-ratio
    maximumY=y+ratio
    square=true
    x=StopwatchPositionX
    y=StopwatchPositionY
    sizeX=2.1 * StopwatchSize
    sizeY=2.1 * StopwatchSize
    style=ELLIPSE
    fillColor=CYAN
    x=StopwatchPositionX
    y=StopwatchPositionY
    sizeX=2 * StopwatchSize
    sizeY=2 * StopwatchSize
    style=ELLIPSE
    fillColor=PINK
    x=StopwatchPositionX + StopwatchSize * Math.cos(1.570)
    y=(StopwatchPositionY + StopwatchSize * Math.sin(1.570))+ (StopwatchSize/7)
    sizeX=StopwatchSize/6
    sizeY=StopwatchSize/4
    visible=true
    enabledPosition=true
    pressAction=if(_isPlaying())_pause(); else _play();
    style=RECTANGLE
    fillColor=BLUE
    x=StopwatchPositionX + StopwatchSize * Math.cos(2.09)
    y=(StopwatchPositionY + StopwatchSize * Math.sin(2.09))+ (StopwatchSize/6)
    sizeX=StopwatchSize/6
    sizeY=StopwatchSize/4
    transformation=30
    visible=true
    enabledPosition=true
    pressAction=_reset()
    style=RECTANGLE
    fillColor=BLUE
    numberOfElements=300
    x=StopwatchTickSecondX
    y=StopwatchTickSecondY
    sizeX=StopwatchTickSecondSizeX
    sizeY=StopwatchTickSecondSizeY
    numberOfElements=60
    x=StopwatchTickMinuteX
    y=StopwatchTickMinuteY
    sizeX=StopwatchTickMinuteSizeX
    sizeY=StopwatchTickMinuteSizeY
    numberOfElements=60
    x=StopwatchTextSecondX
    y=StopwatchTextSecondY
    sizeX=StopwatchSize/15
    sizeY=StopwatchSize/15
    transformation=StopwatchTextAngle
    text=%StopwatchText%
    numberOfElements=60
    x=StopwatchTextMinuteX
    y=StopwatchTextMinuteY
    sizeX=StopwatchSize/20
    sizeY=StopwatchSize/20
    transformation=StopwatchTextAngle
    text=%StopwatchText%
    x=StopwatchPositionX
    y=StopwatchPositionY
    sizeX=StopwatchSecondHandX
    sizeY=StopwatchSecondHandY
    x=StopwatchPositionX
    y=(StopwatchPositionY+(StopwatchSize/4))
    sizeX=StopwatchMinuteHandX
    sizeY=StopwatchMinuteHandY
    fillColor=RED