RFR: 8334900: IOOBE when adding data to a Series of a BarChart that already contains data [v3]
Markus Mack
mmack at openjdk.org
Sat Aug 10 16:24:36 UTC 2024
On Mon, 15 Jul 2024 16:42:33 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
> I am going to ask this question - unrelated to this PR, but in the context of this PR.
>
> Consider the case of a context menu, where the application needs to know the data point from the screen/local coordinates.
>
> Currently, we can get the Node from the Data instance (XYChart.Data.node property), but not the other way around - that is, given the chart, and given the PickResult of a MouseEvent, it is impossible to get the data point corresponding to a Node. In other words, we have the model->view path but not the view->model one.
>
> In theory, the app developer could monitor the `node` property of Data and use `Node.getProperties()` map to set the Data instance on the node, or they could iterate through all the visible data points, matching the node with the data point, so it is not a big issue.
>
> I am interested in your opinion. What do you think?
Good question, I'd say it is easy enough to loop through the chart's data items to find the correct node in that case, so I don't see a need to add this on the jfx side.
Also, currently Data.getNode() just returns an opaque Node, so I don't see a good place where to expose that without either changing that API. Adding an Node.getProperties() entry should probably be done only by application developers.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1488#issuecomment-2282199843
More information about the openjfx-dev
mailing list