Menu

#103 TracePainterDisc - last painted disc left

next_bugfix_release
open-works-for-me
UI (33)
5
2012-04-25
2012-01-25
Liliya
No

I have a trace with points and it has a TraceDiscPainter as a tracePainter. At some moment I remove all points from the trace (removeAllPoints() method). And still there is one disc left on the chart, although the trace is empty. I looked through the source code and it seems to me that the TraceDiscPainter keeps painting the previous values of X and Y (m_previousX and m_previousY).
This can be reproduced by running standard example from demos - info.monitorenter.gui.chart.demos.StaticChartDiscs.java after adding the following piece of code to the very end of the main method (after frame.setVisible(true)):
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}

trace.removeAllPoints();

chart.updateUI(); - does not help

I attach screenshots before and after thread sleep.

Discussion

  • Liliya

    Liliya - 2012-01-25

    Before thread aleep

     
  • Liliya

    Liliya - 2012-01-25

    After thread sleep

     
  • Achim Westermann

    Hi,
    thx for the report. I fixed it in GIT master. This was indeed a bug.

    kind regards,
    Achim

     
  • Achim Westermann

    • status: open --> closed-fixed
     
  • Achim Westermann

    • status: closed-fixed --> open-fixed
     
  • Achim Westermann

    Comment received in https://sourceforge.net/projects/jchart2d/forums/forum/166411/topic/4967046

    "Hi,
    I've just downloaded the latest version from git, although the TracePainterDisc bug is fixed, there is a similar situation with TracePainterVerticalBar. Before bugfixing with TracePainterDisc there was the same picture - one bar was left after removing all points from trace. Now it is different - the whole chart becomes a colored rectangle. To reproduce this use the same sample info.monitorenter.gui.chart.demos.StaticChartDiscs, but instead of trace.setTracePainter(new TracePainterDisc()) use trace.setTracePainter(new TracePainterVerticalBar(2, chart));
    Thank you in advance!"

     
  • Achim Westermann

    Hi Liliya,

    I changed StaticChartDisc as you described:

    [code]
    /*
    *
    * StaticChartDiscs.java, rendering demo of jchart2d.
    * Copyright (C) 2007 - 2011 Achim Westermann, created on 10.12.2004, 13:48:55
    *
    * This library is free software; you can redistribute it and/or
    * modify it under the terms of the GNU Lesser General Public
    * License as published by the Free Software Foundation; either
    * version 2.1 of the License, or (at your option) any later version.
    *
    * This library is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    * Lesser General Public License for more details.
    *
    * You should have received a copy of the GNU Lesser General Public
    * License along with this library; if not, write to the Free Software
    * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    *
    * If you modify or optimize the code in a useful way please let me know.
    * Achim.Westermann@gmx.de
    *
    */
    package info.monitorenter.gui.chart.demos;

    import info.monitorenter.gui.chart.Chart2D;
    import info.monitorenter.gui.chart.ITrace2D;
    import info.monitorenter.gui.chart.traces.Trace2DSimple;
    import info.monitorenter.gui.chart.traces.painters.TracePainterVerticalBar;
    import info.monitorenter.gui.chart.views.ChartPanel;

    import java.awt.Color;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;

    import javax.swing.JFrame;

    /**
    * A demo chart that uses a
    * {@link info.monitorenter.gui.chart.traces.painters.TracePainterDisc}.
    * <p>
    *
    * @author <a href="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
    *
    * @version $Revision: 1.6 $
    *
    */
    public final class StaticChartDiscs {

    /**
    * Main entry.
    * <p>
    *
    * @param args
    * ignored.
    */
    public static void main(final String[] args) {
    // Create a chart:
    Chart2D chart = new Chart2D();

    // Create an ITrace:
    ITrace2D trace = new Trace2DSimple();
    // Add the trace to the chart:
    chart.addTrace(trace);
    trace.setTracePainter(new TracePainterVerticalBar(2, chart));
    trace.setColor(Color.DARK_GRAY);
    // Add all points, as it is static:
    double count = 0;
    double value;
    double place = 0;
    for (int i = 120; i >= 0; i--) {
    count += 1.0;
    place += 1.0;
    value = Math.random() * count * 10;
    trace.addPoint(place, value);
    }

    // Make it visible:
    // Create a frame.
    JFrame frame = new JFrame("StaticChartDiscs");
    // add the chart to the frame:
    frame.getContentPane().add(new ChartPanel(chart));
    frame.setSize(400, 300);
    // Enable the termination button [cross on the upper right edge]:
    frame.addWindowListener(new WindowAdapter() {
    /**
    * @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
    */
    @Override
    public void windowClosing(final WindowEvent e) {
    System.exit(0);
    }
    });
    frame.setVisible(true);

    try {
    Thread.sleep(3000);
    } catch (InterruptedException e1) {
    e1.printStackTrace();
    }

    trace.removeAllPoints();

    //chart.updateUI();
    }

    /**
    * Defcon.
    * <p>
    */
    private StaticChartDiscs() {
    // nop
    }
    }

    [/code]

    I don't see "the whole chart becomes a colored rectangle".

    I attach a screenshot.

    How does your picture look like?

    kind regards,
    Achim

     
  • Achim Westermann

     
  • Achim Westermann

    • status: open-fixed --> open-works-for-me
     
  • Liliya

    Liliya - 2012-04-26

    "colored rectangle"

     
  • Liliya

    Liliya - 2012-04-26

    Hi Achim,
    Thank you for quick response. I uploaded the picture I am getting after executing the same code you posted. I am getting this picture after trace.removeAllPoints(); is executed. I am using java version jdk1.6.0_21 on wndows,if this may somehow be a difference.

     
  • Liliya

    Liliya - 2012-04-26

    And this is the output of the program that is shown on console:
    info.monitorenter.gui.chart.Chart2D rendered 121 points of a trace with 121 points. It took 2 ms.
    info.monitorenter.gui.chart.Chart2D rendered 121 points of a trace with 121 points. It took 1 ms.
    info.monitorenter.gui.chart.Chart2D rendered 121 points of a trace with 121 points. It took 2 ms.
    info.monitorenter.gui.chart.Chart2D rendered 0 points of a trace with 0 points. It took 0 ms.

     
  • Achim Westermann

    Hi Liliya,
    sorry for the late response. This sounds like a race - condition, like: While the points are removed another paint is invoked that locks rescaling. I have to test this on a windows VM next week.

     
  • Liliya

    Liliya - 2012-05-14

    Will be waiting for your response)

     
  • Liliya

    Liliya - 2012-06-04

    Hey Achim,
    Any update on this?

     
  • Achim Westermann

    Hi Liliya,

    sorry for the long delay. I don't have access to a windows machine. Only @ work and there I don'T have much time for private stuff. Could someone else confirm this. For me on ubuntu/debian this is not reproducable.

    BTW: It's not optimal to add another bug report as a comment of another bug for several reasons. I had to read 5 minutes to remember that the bug description has nothing to do with the open issue. Also others won't read all comments and get the point that this is now a different bug. Perhaps a new bug for this should be openend so that others see it and can help verifying.

    cheers,
    Achim

     
  • Liliya

    Liliya - 2012-06-04

    Oh, OK. I opened a new bug and a new thread in forum.

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB