Fix data selection following zooming with mouse #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
Data selection works fine when the chart is unzoomed, with an app's
selectionChanged()
callback being invoked following data point selection. When the chart is zoomed, however, theselectionChanged()
callback is not invoked.Playing with zooming shows that data selection always fails following zooming using the mouse (i.e., mouse button down + drag). When zooming using the mouse wheel, data selection works for the first few zoom-in mouse wheel works. Once the chart has been enlarged a few times, selection fails.
Reproducing the Problem
The problem can be reproduced easily with a minimally modified SelectionDemo1.java file.
The Technical Explanation
Examining the FSE code shows that the reason for
SelectionChanged()
not being called following zooming is because the hash value of theDatasetSelectionExtension<XYCursor>
object registered in functioncreateDemoPanel()
is modified because of zooming. This causes the statement "registeredExtensions.get(dataset)" inDatasetExtensionManager.getExtension()
to return null:Drilling down further shows that the
Calendar
member variableworkingCalendar
has some of its member variables changed due to zooming.The hash returned by the
Calendar
class takes these into account, causing theHashMap get()
to fail and return null, preventingselectionChanged()
from being invoked.For an explanation complete with screen captures, see the following PDF file.
The Proposed Fix
I believe
workCalendar
is unsafe to include in the hash of aTimesSeriesCollection
object and should be removed. I would like to propose removing it fromTimeSeriesCollection.hashCode()
. When I made the fix locally and rebuilt FSE, data selection works perfectly on both zoomed and non-zoomed charts.