hageldave / JPlotter

OpenGL based 2D Plotting Library for Java using AWT and LWJGL
https://github.com/hageldave/JPlotter/wiki
MIT License
45 stars 6 forks source link

Ready-to-use scatter plot class #22

Closed hageldave closed 1 year ago

hageldave commented 3 years ago

When creating a scatter plot in JPlotter, the usual setup works something like this:

  1. create Points objects and fill with coordinates from data
  2. put Points in new PointsRenderer
  3. set or add PointsRenderer as content of new CoordSysRenderer
  4. set CoordSysRenderer as renderer of your JPlotterCanvas instance
  5. optional: setup interaction capabilities, e.g. CoordSysScrollZoom, CoordSysAreaSelector, CoordSysPanning
  6. optional: setup custom interaction schemes through mouse/key listeners (e.g. highlighting points on mouse over)

This is a lot of setup for a standard chart.

To allow developers to quickly create a scatterplot of their data, an extensible convenience class for a scatter plot needs to be developed. The class should also allow for an easy setup of interaction schemes, e.g. mouseover, point selection, area selection.

reichmla commented 3 years ago

Should the interaction possibilities (e.g. "select area and zoom into it") be predefined by the ScatterPlot class or should the user also be able to define his own interactions? For example the CoordSysViewSelector class is abstract and therefore an object can't be returned to the user, before its methods are implemented. If i'm not missing anything, this implicates that the interaction possibilities have to be predefined by the ScatterPlot class? This question might also apply to other interaction schemes, like the mouse/key listeners.

hageldave commented 3 years ago

I'd say the developers should be able to define their own interactions in addition to "standard" interactions which are panning, scroll zooming, and area zooming. The way the developers can add their custom interaction schemes needs a bit more thought I guess. I'll think of something

hageldave commented 3 years ago

As already discussed internally The scatter plot class should provide a listener interface to be notified when a point of the scatter plot is hovered over by the mouse cursor. Something like mouseOverPoint(Point mouseLocation, Point2D pointLocation, double[] data, int dataIndex). The triggering has has to be realized through picking, meaning that on every mouseMoved event the current picking color under the cursor has to be fetched to check whether mouse over is occurring.

A similar functionality for clicking on a scatter plot point should also be supported, e.g. pointClicked(int mouseButton, Point mouseLocation, Point2D pointLocation, double[] data, int dataIndex).

Not discussed internally A rectangular selection of scatter plot points should also be supported in some way. I'm also thinking of a listener interface, e.g. pointsSelected(Rectangle2D bounds, List<double[]> data, List<Integer> dataIndices) that is notified when a rectangular selection was made (not on area zooming though).

This should at least allow for a convenient implementation of most conventional scatter plot interactions.

(Please excuse my ignorance of the current point set/dataset structure of the scatterplot class in my suggested method signatures)

hageldave commented 1 year ago

TODO for me: check class for open issues. If ok, it can be merged.

hageldave commented 1 year ago

A lasso selection was introduced in branch rope-selection https://github.com/hageldave/JPlotter/tree/rope-selection scatter plot was merged into the lasso branch, so these two features are coupled

hageldave commented 1 year ago

@lvcarx you mentioned that the branch https://github.com/hageldave/JPlotter/tree/temp-scatterplot-and-barchart had fixes which should be adopted. I don't want this temporary branch to be merged with anything (rather delete it at some point). So could you please copy the fixes? I think they are in these two commits:

hageldave commented 1 year ago

now in master as of 5758ffc7c4f0468342d3746d2a818c39df823d95