ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  zoom-in function will get stuck if clicking multiple times
Posted by Big on Aug-03-2020 15:08
Attachments:
Hi Peter, I recently meet a bug about zoom in area. The zoom in area rectangle will not disappear when I click it multiple times. Do you have any idea about it?
zoom.png

  Re: zoom-in function will get stuck if clicking multiple times
Posted by Peter Kwan on Aug-03-2020 16:30
Hi,

In one of your previous post, you mentioned that you are using Java. Is the chart in your last email also in Java? Is it a web or desktop application? If it is a web application, is it based on JSP? If it is a desktop application, is it based on the SWING GUI framework?

Regards
Peter Kwan

  Re: zoom-in function will get stuck if clicking multiple times
Posted by Big on Aug-03-2020 16:36
Peter Kwan wrote:

Hi,

In one of your previous post, you mentioned that you are using Java. Is the chart in your last email also in Java? Is it a web or desktop application? If it is a web application, is it based on JSP? If it is a desktop application, is it based on the SWING GUI framework?

Regards
Peter Kwan


Thank you for your quick reply. it is a desktop application based on Eclipse SWT GUI framwork. And I found that the ViewPortChanged event has not been fired when get stuck.

  Re: zoom-in function will get stuck if clicking multiple times
Posted by Peter Kwan on Aug-03-2020 23:15
Hi Big,

I am thinking, it may be because the ChartDirector ChartViewer control does not receive mouse events for some reasons.

ChartDirector does not have a SWT control. It only has a Java SWING ChartViewer control. I am aware that there is a SWT/AWT bridge that can allow SWING controls to be used in SWT applications. Is this the method you use in your application? (I have never used SWT before. I learned about the SWT/AWT bridge in the following page.)

https://www.eclipse.org/articles/Article-Swing-SWT-Integration/index.html

According to the above page, the SWT and AWT runs on two different GUI threads. Like all GUI controls, an SWT control can only be used in the SWT thread, and an AWT control can only be used in the AWT thread.

For example, suppose there is SWT pushbutton so that when it is clicked, a chart will be created and assign to directly to the ChartViewer to display. The code would be unsafe as the ChartViewer (a SWING control) is accessed from a SWT thread (the pushbutton click event handler). Similarly, the ViewPortChanged event handler must not touch any SWT controls or the SWT Window itself. Any SWT/AWT interactions must use special methods to schedule the code to run in the correct thread. (See "Multiple Event Threads" in the above page.)

If the threads are not handled correctly, it can lead to deadlock. If the SWING GUI thread deadlocks, ChartViewer can no longer receive any events. This is one of the possibilities I can think of.

Regards
Peter Kwan

  Re: zoom-in function will get stuck if clicking multiple times
Posted by Big on Aug-04-2020 09:24
Yes, the bridge method is in our code.

```java

    Frame frame = SWT_AWT.new_Frame(this);
    Panel panel1 = new Panel();
    frame.add(panel1);
    panel1.setLayout(new BorderLayout(0, 0));

    rootPane = new JRootPane();
    panel1.add(rootPane);
    // Chart Viewer
    chartViewer = new ChartViewer();
    rootPane.getContentPane().add(chartViewer, BorderLayout.CENTER);
```

Good idea, I will continue to debug. but there are no message in log.