Dragging mouse is extremely slow

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
cowwoc
Posts: 6
Joined: Wed May 07, 2008 7:33 pm

Dragging mouse is extremely slow

Post by cowwoc » Fri May 30, 2008 2:09 am

Hi,

JFreeChart seems to be fast for the most part but if I click and drag the mouse to outline the area I want to zoom into it updates the rectangle *very* slowly. This looks very bad for a desktop application.

I create the chart as follows:

Code: Select all

    XYSeriesCollection data = new XYSeriesCollection();
    XYSeries series = new XYSeries("Series 1");
    for (int i = 0; i < 10; ++i)
      series.add(Math.random() * 100, Math.random() * 100);
    data.addSeries(series);
    JFreeChart chart = ChartFactory.createXYLineChart("title", "x-axis",
      "y-axis", data, PlotOrientation.HORIZONTAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    DeviationRenderer renderer = new DeviationRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, true);
    plot.setRenderer(renderer);
    return new ChartPanel(chart, true);
Is this a known bug? Is there a way to improve the performance? My computer is only 3 months old and I tried enabling buffering in JFreeChart so something else must be at fault. Any ideas?

Gili

RoyW
Posts: 93
Joined: Wed Apr 23, 2008 7:42 pm
Contact:

Post by RoyW » Fri May 30, 2008 3:02 pm

Does your application do anything else? (it could be your app is hogging the EDT).
Have you tried running one of the demos that just contains a chart?
In my experience I haven't seen the problem you describe
The answer does not come from thinking outside the box, rather the answer comes from realizing the truth; There is no Box. my js site

cowwoc
Posts: 6
Joined: Wed May 07, 2008 7:33 pm

Post by cowwoc » Fri May 30, 2008 4:02 pm

RoyW wrote:Does your application do anything else? (it could be your app is hogging the EDT).
Have you tried running one of the demos that just contains a chart?
In my experience I haven't seen the problem you describe
I can reproduce this problem by running the ScatterPlotDemo1. When I move the mouse the cross repaints very slowly/choppy.

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Fri May 30, 2008 5:50 pm

I do not have this problem, and I have run JFreeChart-based applications on a variety of low-end and high-end machines. JFreeChart occasionally slows down when you start dealing with hundreds of thousands to millions of data points, but certainly not for a plot of only 10 points. Have you tried altering various parameters of the plot to see if and how they change the response time?

For additional background:
* what version of JFreeChart are you using?
* which JRE are you running?
* what OS are you running?

Offline assignment: check either the Windows Task Manager (on a Windows machine) or 'top' (on a Linux or Mac OSX machine) to see what else is running in the background that could be hogging resources.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

mmehan
Posts: 4
Joined: Wed Nov 26, 2008 9:54 pm

Post by mmehan » Wed Nov 26, 2008 10:01 pm

I am having the same problem. I recently reinstalled windows on my machine and now when I compile my own charts the zoom rectangle is extremely slow, to the point where it is unusable. The same is true on the demos. The charts render fine, but the zoom box get's repainted many times very slowly before finally arriving at a new location. Strangely though the speedometer example moves very smoothly. I am running Windows XP SP2 and I have just installed the latest version of Java (6u10). I have also installed my latest video card drivers. I am stumped and hope you can help. Thanks!

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Wed Nov 26, 2008 10:41 pm

Does the problem go away if you add

Code: Select all

-Dsun.java2d.noddraw=true
to the command line when starting your application?

mmehan
Posts: 4
Joined: Wed Nov 26, 2008 9:54 pm

Post by mmehan » Wed Nov 26, 2008 10:55 pm

Unfortunately not. Any idea what might be causing it?
I should also mention that the cross hairs refresh very slowly as well. I'm using JFreeChart v. 1.0.11.

mmehan
Posts: 4
Joined: Wed Nov 26, 2008 9:54 pm

Post by mmehan » Wed Nov 26, 2008 11:03 pm

I don't know if this will help but here is more detail. In an application that I wrote, I have turned on the zoom rectangle feature such that I always have a pair of cross-hairs on the plot. The rectangle that defines a zoom rectangle is filled gray.
When I go to select a zoom rectangle, the cross hairs jump around the plot area very slowly behind my mouse. When I select a zoom box, it slowly gets to the size defined by the mouse (sometimes partially drawing smaller rectangles on the way) and when it begins to draw the rectangle it draws it slowly in successive left to right lines, a pixel at a time. It probably adds about 1000 pixels a second but hard to judge. A box the size of chart area takes over a minute.
The zoom boxes in the demo behave similar to the cross hairs in my application since they are unfilled zoom boxes.

kandidat
Posts: 7
Joined: Thu Dec 04, 2008 11:39 pm

Post by kandidat » Thu Dec 04, 2008 11:47 pm

Same to me with slow mouse dragging on a XYDiagram.

But I made an interesting detection: Only in Windows XP Sun JDK 1.6.0_10!

On my Mac (Apple JDK 1.6.0_07) dragging a zoom-box is very smooth.

Oliver

mmehan
Posts: 4
Joined: Wed Nov 26, 2008 9:54 pm

Post by mmehan » Fri Dec 05, 2008 12:01 am

It's funny that you mention this today. No more than an hour ago I realized the same thing. I recently installed the new JDK on my windows machine at work and noticed the same problem where it had worked fine before the upgrade. Also, my laptop running a previous version doesn't have the problem at all. Looks like I'll have to revert to a previous version for now. Thanks!!

kandidat
Posts: 7
Joined: Thu Dec 04, 2008 11:39 pm

Post by kandidat » Fri Dec 05, 2008 12:12 am

just checked unter windows with sun jdk 1.5.0_11 (i have both installed)

Zooming is smooth!

Seems to be a problem only with sun jdk 1.6.0_10

Doragorn
Posts: 4
Joined: Thu Dec 11, 2008 6:00 pm

Post by Doragorn » Thu Dec 11, 2008 6:11 pm

I have the same problem since update 10.

I have also tested with update 11 and it's always the same problem.

But adding "-Dsun.java2d.noddraw=true" to the launch command solves the problem.

I heard that the new versions of Java try to use the graphic card for rendering, there could be a problem with that.

bensond
Posts: 7
Joined: Wed Jan 19, 2005 4:12 pm
Location: England
Contact:

Post by bensond » Mon Dec 22, 2008 6:11 pm

We have the same problem in JGraph. Sun have broken XOR drawing in Windows, in short. See http://www.jgraph.com/forum/viewtopic.php?t=4066 for more information. In a library there little that can be done apart from vote for the bug in your droves...

David

tomkieffer
Posts: 24
Joined: Wed May 16, 2007 8:20 am

Post by tomkieffer » Tue Dec 30, 2008 12:10 am

Setting

System.setProperty("sun.java2d.d3d", "false");

does the deal. This problem is happening with a lot of code under windows. It is also in the Sun bug database (XOR rendering).

bensond
Posts: 7
Joined: Wed Jan 19, 2005 4:12 pm
Location: England
Contact:

Post by bensond » Wed Jan 07, 2009 4:45 pm

But this is not a runtime JVM setting, you can't make that call after the application has started.

David

Locked