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.

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
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.

Paul DeYoung

Paul A. DeYoung

Replies to How to make dotted or dashed 2D lines

Re: How to make dotted or dashed 2D lines -
Francisco Esquembre
228 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


Attached File: ejs_StrokeExample.zip

Re: Re: How to make dotted or dashed 2D lines -
lookang Avatar
222 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


Attached File: lag2013-03-08_2146.png

OSP@SG blog
OSP@SG Digital Library

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