how to recreate EJSS models from EJS.
this tutorial is made to help anyone figure out how to recreate EJSS models from EJS.
files required https://gitlab.com/ejsS/JavaEditor/release older EJS
- Download the suitable candidate for re-creation the easy way as i have figure out recently.
- as part of reviewing lesson for the ICT information and communication technology Master-plan in Education http://ictconnection.moe.edu.sg/lesson-examples&func=view&rid=2931, this lesson uses an paid iPad app.
- select a folder place to save the EJS ejs or xml file and agree to all request if any.
- here, there are 2 things needed, the old EJS and a re-create EJSS file of the same thing waiting for more edits.
- select Yes, to view the old EJS file, keep it open for reference
- select No, to generate the EJSS file from the EJS for more edits
- there should be 2 EJS copies opened, Left EJS old (view is VIEW), and Right EJSS new (view is HTML)
- First step is to save it as ejss.
- Discard the old EJS view by selecting No
- the EJS output will show something like this Skipping Java view from this JS file...File saved successfully users/sgeducation/lookang/ThinLenModel02.ejss
- Debugging and making it able to be compile in the EJSS version.
- When trying to Run Simulation, error message says no HTML view, just go ahead to give it one
- Click to create a HTML page
- now, EJS output show a lot of errors, fix them one by one in no particular order, the principle is reduce the complexity of the old EJS and make it runnable first before adding views to it
- scroll to initialization, remove codes that seems to give errors
- replace {} as [] in the variables declarations.
- change mode to be array dimension [1] string
- change codes for drop-down menu to from if(mode.equals("0.1 mm version 1")) to if(mode[0]==="0.02 mm version 1")
- replace (int) to parseInt, as advised by http://www.w3schools.com/jsref/jsref_parseint.asp
- replace int to var, Javascript local variable declaration
- drawing such as polygon need to be reassign in the following manner create a dummy new variable say xytail = [[xmax,0],[xmax,size/2],[xmax-size*2,size/2],[xmax-size*2,size],[-size*16,size],[-size*16,0]] dimensions [6][2] from the old xt = [xmax,xmax,xmax-size*2,xmax-size*2,-size*16,-size*16] and yt = [0,size/2,size/2,size,size,0]
- sometimes need to draw dotted lines , add in Attributes { "stroke-dasharray":"8 8 8 8" }
- remove unnecessary codes in custom like chinese detection, decimal place display, play/pause label change etc in the custom usually.
- replace new java.awt.Color to function Custom rgb function rgb(r, g, b){
return "rgb("+r+","+g+","+b+")";
} as advised by http://www.compadre.org/osp/bulletinboard/TDetails.cfm?ViewType=2&TID=3380&CID=84198&#PID84199 - change the type of color from Object to String
- add values to variable declared
- now test it by running the simulation, the browser should show a runnable view of the EJSS now.
- now that the ejss runs, it is time to transfer as much drawables in HTML equivalent over. first the Drawing Panel
- test to see what is the effect of the changes in ejss
- adding object one per one, for example lens group
- Open up another ejss file to transfer the layout design
- run it to see what you have done
-