Skip to main content

Enhancement request: JSlider to handle long instead of int values

12 replies [Last post]
olafchrist
Offline
Joined: 2006-05-02
Points: 0

Hi,
i have got only one problem with JSlider when using it with JMF.

Since a JMF positioning control is not accurate enough and, when using audio only, does not even exist, I am using a JSlider instead and getMediaTime()/setMediaTime() to build my own positioning control.
Now, the problem is, that because JMF uses long values for media time (long getNanoSeconds()) I cant use JSlider.

Using another model that uses long values is a problem, because JSlider depends on a BoundedRangeModel (DefaultBoundedRangeModel) which uses int values.

I am sure the problem already has ocurred to others, therefore a JSlider that can handle long values would be nice.

OlafChrist (christ_o@gmx.de)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
prunge
Offline
Joined: 2004-05-06
Points: 0

> Sure, I can scale the long into int values.
> For large long values I would lose a lot of
> precision.

If the JSlider is controlling the position of a media file, would it be that big a deal if there was only a precision of, say, milliseconds instead of nanos? And given that the JSlider would likely only ever be displayed on a couple of thousand pixels at the most (unless it's in a scroll pane or something) the user's precision would be limited anyway.

olafchrist
Offline
Joined: 2006-05-02
Points: 0

> If the JSlider is controlling the position of a media
> file, would it be that big a deal if there was only a
> precision of, say, milliseconds instead of nanos?
> And given that the JSlider would likely only ever be
> e displayed on a couple of thousand pixels at the
> most (unless it's in a scroll pane or something) the
> user's precision would be limited anyway.

For this particular problem, you are right and milliseconds will work.
However, a JSlider that is using long values would be much more generic.

OlafChrist

spdenne
Offline
Joined: 2006-02-15
Points: 0

A nice example of extending a JSlider is org.mc4j.console.swing.LogarithmicJSlider
by Greg Hinkle
http://jroller.com/page/ghinkle?entry=where_have_all_the_swing

olafchrist
Offline
Joined: 2006-05-02
Points: 0

Very nice!

Thanks

OlafChrist

Message was edited by: olafchrist

olafchrist
Offline
Joined: 2006-05-02
Points: 0

I think that's it.

Message was edited by: olafchrist

olafchrist
Offline
Joined: 2006-05-02
Points: 0

.

trembovetski
Offline
Joined: 2003-12-31
Points: 0

Can't you scale your long values into an interval which is handled by int?

Dmitri

olafchrist
Offline
Joined: 2006-05-02
Points: 0

Sure, I can scale the long into int values.
For large long values I would lose a lot of precision.
Also, I still need longs instead of integers. Which means I have to convert the int back into the original long value.

OlafChrist

leouser
Offline
Joined: 2005-12-12
Points: 0

hmmm, I wonder how much work it would take to create a genericised JSlider, with a corresponding generic model? On the surface from perusing the JSlider source it doesn't look too terrible, but then you'd have to go into the UI's probably and get things to function against the generic numbers.

leouser

olafchrist
Offline
Joined: 2006-05-02
Points: 0

To quickly try things out, I copied the original sources and basically changed "every" int to long.
That could be done very quickly in about a few minutes.
However, when trying to actually use this hacked slider exceptions occur regarding the UI and look and feel.

Thus, in my media editor where the problem occured, I am not using the slider right now. Instead, I am using some ugly buttons for accurate positioning together with the not very accurate JMF control panel.

Still, a JSlider using long values would be much more elegant and intuitive.

OlafChrist

leouser
Offline
Joined: 2005-12-12
Points: 0

Im going to guess you should just make a LongJSlider from the source and a look and feel based off of the relevant source as well. A quick search and replace won't be adequate for the change your trying to do.

leouser

olafchrist
Offline
Joined: 2006-05-02
Points: 0

Yes, a quick search and replace didnt work. I guess I will have to put some work into the UI/look and feel.

OlafChrist