CompassPlot Range Question

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

CompassPlot Range Question

Post by Tom Bunio » Thu Mar 13, 2003 8:14 pm

Hi,

I am having an issue that I don't quite understand. I am trying to write a weather station application for a weather station that outputs serial data.

I am trying to use the CompassPlot class to show the current wind direction. The issue is that the weather station uses a range of 0 to 255 to indicate wind direction (instead of the more common 0 to 360).

I am trying to set the range of the Compass to 0-255 and then set the current value of the compass to a value in that range. However, it seems as if the direction is still being mapped to a 0 to 360 range. For example, using my range of 0-255, I would expect that a value of 127.5 would give me a south pointing direction. Instead, it is pointing in a more southeast direction. After trying 180 for a value, it seems clear that this does in fact point south, but does so incorrectly for the range I have set.

Here is my code:

compassData = new DefaultMeterDataset ();
compassData.setRange(new Double(0), new Double(255.0));
compassPlot = new CompassPlot(compassData);

compassData.setValue(127); // should now point south, not southeast

Is the assumption that changing the range should correctly affect the scaling of the pointing direction? Thanks in advance.

Tom

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Mar 14, 2003 6:43 pm

I think that only the getValue() method from the MeterDataset is used...everything else is ignored. And the range is assumed to be 360 degrees.

I plan to add a ValueDataset interface to JFreeChart in a future release, and the compass plot will probably be modified to use it.

Regards,

Dave Gilbert

Locked