NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
December 16, 2017, 04:16:06 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
A man paints with his brains and not with his hands. ..."Michelangelo (1475-1564, Italian sculptor, painter, architect and poet)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: How to tag onto these balls?  (Read 11279 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Yves
Newbie
*
Offline Offline

Posts: 8


«
Embed this message
on: February 09, 2008, 02:14:03 am »

Hi,

I am almost done with my project in Java. Just have a big, tiny problem. My supervisor wants to see tags on those little blue balls. How do I go about it? Any hints? This is a Brownian motion simulation.

Something like this:
http://i26.tinypic.com/2hpsux0.jpg

Cheers.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: February 09, 2008, 10:42:54 am »

It is easy with EJS, there is a text string element (you just provide text and coordinate).
However,you are writing your own code. So you need to draw a rectangle box and print a string at the same position.
You can make it as an "onmouse over" action to display those information.
Logged
Yves
Newbie
*
Offline Offline

Posts: 8


«
Embed this message
Reply #2 on: February 10, 2008, 12:52:44 am »

Thanks Professor.

I need to tag on a random ball, without the mouse coming in. Does "onmouse over" work that way?
« Last Edit: February 10, 2008, 01:22:02 am by Yves » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #3 on: February 10, 2008, 09:51:02 am »

Becuse you did not say which ball need to be tagged. So I suggested use mouseOver.
If you have decided which ball need to be tagged. Just draw a rectangle and a String near the ball (need to be tagged). And redraw each time you refresh the screen.
Logged
Yves
Newbie
*
Offline Offline

Posts: 8


«
Embed this message
Reply #4 on: February 10, 2008, 01:03:40 pm »

The tag/label needs to follow the chosen ball during the simulation. I gather from your suggestion the tag will be static until refreshed? If my understanding is right then I guess that is not what my supervisor has in mind. Any other alternative?

Thanks for your response. Really appreciate it.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #5 on: February 10, 2008, 02:42:20 pm »

The screen for java applets usually are refreshed many times per second. Usually, I use 20 frames per second.
You just need to draw the rectangle and string (near the selected particle) to follow the chosen ball at each frame in the simulation. So the tag/label will move with the particle (it is not static).
For example: if the coordinate for the chosen particle is x,y with size dx,dy.
g.fillOval(x,y,dx,dy);
Then you can draw rectangle with
g.drawRect(x+dx/2, y-2*dy, w, h);
where w, h should be larger than  width and hight for the label to be displayed.

Logged
Yves
Newbie
*
Offline Offline

Posts: 8


«
Embed this message
Reply #6 on: February 11, 2008, 02:39:51 am »

Thanks Professor. That is a suggestion I can work on.

Cheers.
Logged
Pages: [1]   Go Up
  Print  
A man paints with his brains and not with his hands. ..."Michelangelo (1475-1564, Italian sculptor, painter, architect and poet)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Racing Balls
kinematics
Fu-Kwun Hwang 28 154101 Last post April 05, 2013, 03:01:31 pm
by papagall
Astroblaster balls (The Multiple Collision Accelerator!)
Kinematics
Fu-Kwun Hwang 2 17296 Last post December 23, 2015, 06:44:38 pm
by lookang
Astroblaster balls (The Multiple Collision Accelerator!)
kinematics
ahmedelshfie 0 4567 Last post May 27, 2010, 11:54:33 pm
by ahmedelshfie
2D collision with multiple balls at the same time
Request for physics Simulations
PL_kolek 12 21927 Last post April 19, 2013, 03:27:17 pm
by tomoisgood0444
Modification of Balls in box simulation (EJS examples created by Paco)
Examples for beginner who want to learn EJS
Fu-Kwun Hwang 0 6695 Last post January 30, 2012, 11:00:14 pm
by Fu-Kwun Hwang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.06 seconds with 23 queries.since 2011/06/15