Clickable tick-labels? (A new approach to vertical zoom)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Irv Thomae

Clickable tick-labels? (A new approach to vertical zoom)

Post by Irv Thomae » Tue Jan 21, 2003 9:07 pm

David (and anyone else who has worked with Java 2D),
Can you think of any way to make the vertical-axis TickLabels "mouse-sensitive", i.e., individually clickable?

We are using my "XYImplulseRenderer" class to plot statistical data that is always >= 0, and may fluctuate wildly. Sometimes, because of one isolated reading that was many times larger than the mean, autoscaling sets a vertical scale that leaves almost all of the data too small to see on the plot.

For example, a single datapoint of 4879 might cause the the top vertical ticklabel to be 5000, even though 99% of the data is less than 500. To see what elseis going on, we need a convenient way to change the vertical magnification, allowing the largest data to disapper off-scale. If there was a way to make each ticklabel a "hot spot", a user who wanted the new full-scale value to be 500 instead of 5000 could just click on that ticklabel.

If the ticklabels were JLabels (Swing components), this would be very easy to implement , for example

class clickableTickLabel extends JLabel implements MouseListener

From a quick scan through the source code, however, it's not at all clear whether TickLabel objects have well-defined boundaries as JLabel objects do. Could the mechanism used for crosshairs and tooltips somehow be extended? Or does 95% of this cpability already exist, though I haven' discovered it yet?

Thanks,
Irv Thomae

David Gilbert

Re: Clickable tick-labels? (A new approach to vertical zoom)

Post by David Gilbert » Wed Jan 22, 2003 4:38 pm

Hi Irv,

I think it should be possible to extend the chart entity mechanism to include items on the axes...hopefully there won't be some 'gotcha' that gets in the way. If it does work, it will make it possible to identify mouse clicks on different parts of the axis, and also to display tooltips if necessary.

I plan to work on this at some point, after 0.9.5 is out...

Regards,

Dave Gilbert

Irv Thomae

Re: Clickable tick-labels? (A new approach to vertical zoom)

Post by Irv Thomae » Thu Jan 23, 2003 7:32 pm

David,
Being able to recognize clicks on different TickLabels will permit some pretty neat user-interface embellishments..
Meanwhile, if I'm willing to use menus until it can be done more smoothly, how can I do the following to a VerticalNumberAxis:

(a) Read the current maximum scale-value being used (I'd settle for
getting the top TickLabel's text, whioch could then be parsed)
(b) _Set_ the maximum scale-value, and cause the axis (and plot) to
recalculate and display the result?


Thanks,
Irv Thomae

Irv Thomae

Re: Clickable tick-labels? (A new approach to vertical zoom)

Post by Irv Thomae » Thu Jan 23, 2003 7:50 pm

Never mind, I see that it's quite easy:
To get the current top-of-scale:
NumberAxis.calculateHighestVisibleTickValue()
To set the scale:
<axis>.setRange(double low, double high)
except that, if a margin is desired, the recommended "high" value is 105% of the new maximum tick-value.

Locked