Education Prize Logo
Science SPORE Prize
November 2011

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

dotted and dashed lines post and replies

Return to the dotted and dashed lines thread
Login to post to this thread

How to make dotted or dashed 2D lines - Feb 5, 2013 at 5:08PM
Paul DeYoung
86 Posts

It seems like this should be straight forward but my searching has turned up little of use.  
Is there an easy way within EJS (in particular within the EJS GUI) to make a line dotted or dashed?  Sorry if I missed something obvious.

Thanks
Paul DeYoung


Paul A. DeYoung

Replies to How to make dotted or dashed 2D lines

Re: How to make dotted or dashed 2D lines - Feb 05 2013 5:45PM
Francisco Esquembre
136 Posts

Hi Paul,

No. It is not obvious.

There are two possibilities of doing this.

- The first one is using a deprecated version of the 2D drawables that accept any kind of java.awt.Strokes. There is nothing wrong with this. They are old, and I recommend the later versions, but they still work.

- The second one is that you use the new (still experimental) EJS that I have just compiled and in which I have added this feature to any 2D drawable.

See attached an example which uses both possibilities. But, again, you need an EJS older than 130205 to run it (otherwise, the code that illustrates the second possibility will cause a compile error).
Run the simulation to see the stroke working. (In this example, the stroke is computed in the initialization.)

You can find the new EJS at http://fem.um.es/EjsWiki/uploads/Download/EJS_4.3.7_130205.zip

Any future release of EJS will have this feature.

You can learn about Strokes here , for instance: http://docstore.mik.ua/orelly/java-ent/jfc/ch04_05.htm

Paco

Attached File: ejs_StrokeExample.zip



Re: Re: How to make dotted or dashed 2D lines - Mar 08 2013 8:47AM
lookang Avatar
lookang
111 Posts

dear prof paco, i follow the instructions and it works.

but i notice a lag in the "new" simulation i added the new features of dotted lines. the lag is noticable when i check or uncheck the checkboxes that control g1 g2 or phi1 phi2. in addition, the view mass1 and mass2 also becomes hard to drag around.

please take a look and see if i found a bug in the stroke implementation?

thank you :)

 

download: https://dl.dropbox.com/u/44365627/lookangEJSworkspace/export/ejs_GField_and_Potential_1D_v7weelag.jar

the no lag version

https://dl.dropbox.com/u/44365627/lookangEJSworkspace/export/ejs_GField_and_Potential_1D_v7wee.jar

Attached File: lag2013-03-08_2146.png


http://weelookang.blogspot.sg


The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics