eclipse / swtchart

Eclipse Public License 2.0
46 stars 41 forks source link

[discussion] PlotArea Paint event while tool tip is shown #420

Closed buchen closed 2 hours ago

buchen commented 2 hours ago

Portfolio Performance attempts to move from org.swtchart to org.eclipse.swtchart (discussed in https://github.com/portfolio-performance/portfolio/pull/4302)

The problem at the moment is that the tooltip is visibly janky (see the screen recording below).

The issues appears to be a paint event to the PlotArea while the tooltip is moved around. Due to the high number of data points, drawing takes a moment. And that becomes visible when moving the tooltip.

I tested in the debugger

HELP WANTED Does anybody have an idea what the difference could be? It is unclear to me what is producing the paint event.

Screen Recording **Left:** org.swtchart **Right:** org.eclipse.swtchart https://github.com/user-attachments/assets/e02a0849-5e34-4990-aa61-eef216c33c20
buchen commented 2 hours ago

I think I got it. The constructor now adds a mouse move listener that calls a redraw.

    public Chart(Composite parent, int style) {

        this(parent, style, null);
        new PlotArea(this, SWT.NONE);
        /*
         * Mouse Move Position Marker
         */
        plotArea.addMouseMoveListener(new MouseMoveListener() {

            @Override
            public void mouseMove(MouseEvent e) {

                for(IAxis axis : axisSet.getAxes()) {
                    axis.updatePositionMarker(e);
                }
                redraw();
            }
        });
    }
buchen commented 2 hours ago

I can "fix" this by calling the alternative constructor.

    public TimelineChart(Composite parent)
    {
        super(parent, SWT.NONE, null);
        new PlotArea(this, SWT.NONE);

The PlotArea is restricted API (even though it is mentioned in the JavaDocs of the API).