APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Converting to EJSS from xml files post and replies

Return to the Converting to EJSS from xml files thread
Login to post to this thread

I have xml and jar files, is there a path to EJSS format
Paul DeYoung
100 Posts

I'm sorry if this is obvious but I am very confused.  It is time to move my 100 simulations to EJSS 6 and I was excited that I found the tutorial by lookang (aug 3, 2019) about converting .ejs to .ejss  Looked reasonbly straight forward.  

However...
All my simulations are xml files that get made into jar files and used by students.  I do not have a single .ejs file that I can find.  I feel that I am missing something silly about how to save in .ejs before converting.  Alternately, I searched for how to read .xml into EJSS and came up empty.

Thanks to anybody that can get me pointed at what I am missing.  How did I get into what appears to be a dead end and how do I get turned around.

I love Easy Simulations but I need to be able to move to version 6 and continue to maintain the existing work.

Please, Please, Please and Thankyou.

An example of what I am trying to convert is attached

Attached File: blink_test6_slider.zip


Paul A. DeYoung

Replies to I have xml and jar files, is there a path to EJSS format

Re: I have xml and jar files, is there a path to EJSS format -
Francisco Esquembre
237 Posts

Hi Paul,

EJS files had originally the .xml extension. Later on, I moved to the .ejs extension to make it more obvious that they were EJS-related files. But I made it in a backwards compatible way. Hence, the JAVA version of EJS can read them perfectly well.

Note, however, that the last EJS version that can read BOTH java and javascript files, and can therefore be used to do the conversion Loo Kang shows, is EJS 5.3.

So, you have two choices:

1) Install (also) EJS 5.3 and use Loo Kang's conversion tutorial.

2) Run two copies of EJS 6.x side by side. One should be the JAVA version of EJS and read your .xml file in it. It should work just fine. The other should be a the JavaScript version and will start blanck. Then, reproduce (copying and pasting will help you) your simulation model. When it comes to the HTMLView, you will have to try to mimic what you had in the Java View, using the HTML models for JavaScript. HTML View elements are similar but some (mostly the panels and layouts) are somewhat different.

Hope this helps.

Best,

Paco (EJS author)



Re: I have xml and jar files, is there a path to EJSS format -
Paul DeYoung
100 Posts

Thank you so much.  I have reached the point of putting drawables into the html view (fixed the model errors etc).  I started simple; just draw a box (and followed the mass and spring ejss example).  When I run the simulation a window pops open in my chrome browser with the title and author info but now window with a box.  I feel so close and feel I just missed something simple.  Any ideas or pointer into Loo Kang's document.   My ejss file is attached.

Thanks again.  Once I get over this, I feel like it is just a matter of time on task.

Attached File: blink_test6_noslider.zip


Paul A. DeYoung


Re: I have xml and jar files, is there a path to EJSS format -
lookang Avatar
lookang
245 Posts

I corrected Java to JavaScript syntax in the Evolution Page.
summary:
JavaScript color are strings like "blue" "red" etc
JavaScript parseInt() does same thing as (int)
alert(e) instead to pop up a dialog box
catch(e) instead



if (boxstatus == 0) systimestart = System.currentTimeMillis();
             t += dt;
iteration += 1;
  
  if (boxstatus == 0) {
//   System.out.println(" starting the red part ");
//   System.out.println(System.currentTimeMillis());
       // sleeptimered = (int)(fixedint*2*slider);
       sleeptimered = parseInt(fixedint*2*slider)

  
            try {
            // thread to sleep for 1000 milliseconds
          //  Thread.sleep(sleeptimered);
         } catch (e) {
              //System.out.println(e);
              alert(e);
           }
          
        //shapecolor=java.awt.Color.BLUE;
        shapecolor= "BLUE";
          systime = (System.currentTimeMillis() - systimestart)/1000.;
//              System.out.println(" awake in the red part ");
          boxstatus = 1;
         // sleeptimeblue = 3000 + (int)Math.round(5000*Math.random());
sleeptimeblue = 3000 + parseInt(Math.round(5000*Math.random()));
          }
          else {    
//             System.out.println(" starting the blue part ");
//                System.out.println(System.currentTimeMillis());
                           try {
            // thread to sleep for 1000 milliseconds
           // Thread.sleep(sleeptimeblue);
         } catch (e) {
             // System.out.println(e);
              alert(e);
           }
//              System.out.println(" awake in the blue part ");
           boxstatus = 0;
           systime = 0;
           //shapecolor=java.awt.Color.RED;
           shapecolor="RED";
//

           }

Attached File: ejss_src_blink_test6_nosliderlookang.zip


OSP@SG blog
OSP@SG Digital Library


OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book