NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Easy Java Simulations (2001- ) => Questions related to EJS => Topic started by: akunkeji on March 06, 2011, 02:51:25 pm



Title: Can draw points directly on the "drawing panel" component?
Post by: akunkeji on March 06, 2011, 02:51:25 pm
Can draw points directly on the  "drawing panel" component?(or on the other component)
Do not use "Points" component.

thanks



Title: Re: How to draw points while drag mouse inside the "EJS drawing panel"
Post by: Fu-Kwun Hwang on March 06, 2011, 08:51:24 pm
Define two double variables: e.g. mx,my
And assigned "Pos X" property(of drawingPanel) to mx, and "Pos Y" properties to my.
Then the mouse position will be assigned to mx,my when you click into the drawingPanel.

If you want to show trace of mouse movement, you can add Trace element and assign "Input X,Input Y" to "mx,my".


Title: Re: Can draw points directly on the "drawing panel" component?
Post by: akunkeji on March 06, 2011, 10:32:14 pm
Can not draw a point from the specified position?
Like this(java Syntax):
java.awt.graphics g=new java.awt.graphics();
g.drawLine(0,0,x,y);//Draw a line or point.


Title: Re: How to draw a segment in EJS
Post by: Fu-Kwun Hwang on March 07, 2011, 08:52:37 am
If you just want to draw a segment, use GUI element "segment":
assign PosX,PosY to 0,0 and Size x, Size y to x,y will do it. (it should be x-xi,y-yi if the starting point is (xi,yi) instead of origin)

You can use Arrow to draw an arrow. (If you change style property of arrow, it can be turned into a segment).

There are many examples in this forum. I suggest find one you like, run it locally and open it with EJS(Right click "open EJS model")  to view how it was done.


Title: Re: Can draw points directly on the "drawing panel" component?
Post by: akunkeji on March 07, 2011, 10:00:34 am
thank you!