This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hi everyone  RSS feed

 
Ram Sateesh Talari
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We might have seen this many places...

whenever we see a plotted graph offered by some graphics tool.. if we take the mouse pointer to a specific plotted point then it shows a tool tip showing the point co-ordinates.

I wanted to do a similar thing, but couldn't figure out ways for doing the same...

I thought of implementing a mousemoved event. I am using Jpanel and graphics object to plot these points. and I am drawing an oval to plot a point with radius one. Now when I have a cluster of points then my tooltip might suggest wrong coordinates. But, before all that I need to show the co-ordinates on the tool tip... so this didn't workout.. coz I couldn't even print them on the to console...

please help... this is urgent..

Thank you
Ram
 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ram,

Originally posted by Ram Sateesh Talari:

But, before all that I need to show the co-ordinates on the tool tip... so this didn't workout.. coz I couldn't even print them on the to console...

please help... this is urgent..

Thank you
Ram


Unless you post the code here, how would you expect any one to help you out. Any ways, how are you tracking the tool tip information? Some how I didn't get you.

- Sai
 
Ram Sateesh Talari
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sai,

Well I can't post the code as it is distirbuted among many files... well let me give u a gist of the entire code...

I have a class RnaMain which extends JFrame

I have another class RnaGraph which extends JPanel

both of these classes belong to rna package

in RnaGraph I have used paint(Graphics g) function to paint the axes and the co-ordinates.

The co-ordinate information is stored in a vector in RnaGraph object

so paint function essesntially consists of two function calls

1. drawAxes
2. drawCoordinates

In drawAxes I am drawing the boundary of the graph the and the two axes lines and along the boundary I wrote text labeling each unit of the graph using the graphics object.

Everything is wroking properly, all the co-ordinates are visible on the Graph as I expected.

Now I found that the points are very close to eachother and it's hard to find the actual co-ordiantes of each point that is there on the graph.

So I thought, if I place labels of sizeBounds(i,j,2,2) where i and j are the coordinates of the point that I have to plot then I can write a tool tip for that Label but this didn't work.

Now can u suggest me a better idea as how to solve this problem..

I was thinking if I write a point class by extending it from javax.swing.JComponent will it work??

Regards
Ram
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe your problem can be solved using a JTooltip. For some explanation on using them look at The sun tooltip tutorial
 
Ram Sateesh Talari
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks sai, I tried using JToolTip but didn't workout the way I wanted..

so proceeded with someother idea.


Thanks anyways

cheers
Ram
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!