Bug 451269 - Zoom on right Click results in flickering
Summary: Zoom on right Click results in flickering
Status: ASSIGNED
Alias: None
Product: Graphiti
Classification: Modeling
Component: Core (show other bugs)
Version: 0.10.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2014-11-13 03:15 EST by rahul kumar CLA
Modified: 2014-11-14 10:18 EST (History)
2 users (show)

See Also:


Attachments
Stack Trace for Zoom Flickering (306.15 KB, image/png)
2014-11-13 03:19 EST, rahul kumar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description rahul kumar CLA 2014-11-13 03:15:53 EST
I have a tree view corresponding to my Graphiti View. When I select a node from the tree, using selectionchanged event, I am zooming my Graphiti View so that the entire relationship tree of the selected node will be fit in the graphiti view.

Issue is that when I do a right click on the tree view, zoom happens in steps, but is interrupted when context menu is shown. If I do multiple consecutive right clicks, It keeps on saving the zoom steps. Finally when I do a left click selection, it executes all the remaining zoom steps that results in flickering.

This is my observation:

Problem is: Zoom happens in an animated way in 5 steps. And for each step it checks if some other interrupt is produced by the user. In case of interrupt it pauses zooming and handles the interrupt first. Rest of the  Zooming steps are performed when the interrupt is handled. Now the scenario is:
 
1. User presses right click on the Dependency tree

2. An item is selected, so we perform the color change and Zooming. 

3. Suppose one step of zooming is performed and suddenly an interrupt comes for context menu and so zooming is paused. 

4. Next 5 times also user presses right click, So step 2 and 3 will be executed. and after 6th right click, total number of zooming steps is 24.

5. After that user presses left click. This time there is no interrupt and so remaining 24 zoom steps are performed at one plus 5 more for current selection. So the flickering.
 
The interrupt handling during zoom is done in following manner:
 
/**
     * Calculates the zoom-steps using a square root algorithm.
     */
    private void zoomSqrt(double currentZoom, double targetZoom, int totalSteps) {
        double currentZoom2 = Math.sqrt(currentZoom);
        double targetZoom2 = Math.sqrt(targetZoom);
        double delta = (targetZoom2 - currentZoom2) / totalSteps;
        for (int i = 0; i < totalSteps; i++) {
            currentZoom2 += delta;
            super.primSetZoom(currentZoom2 * currentZoom2);
            stepPerformed();
        }
    }
    /**
     * Is called after each performed step.
     * <p>
     * By default it dispatches all pending events of the current Display. This
     * is important, because typically the steps do something which shall be
     * visible to the user. By dispatching the events all updates to the UI will
     * be performed.
     */
    public void stepPerformed() {
        while (true) {
            if (!Display.getCurrent().readAndDispatch())
                break;
        }
    }
 
Flickering will not happen, if user presses right click for longer times, as the context menu is popped up on mouse release.
 
Number of steps and the zooming method is private to Graphiti's org.eclipse.graphiti.ui.internal.util.gef.ZoomManagerWithAnimation class. So we cannot change it.
Comment 1 rahul kumar CLA 2014-11-13 03:17:20 EST
I am using Graphiti 0.10.2.v20140217-1225
Comment 2 rahul kumar CLA 2014-11-13 03:19:58 EST
Created attachment 248625 [details]
Stack Trace for Zoom Flickering