T <[EMAIL PROTECTED]> writes:
>  Hi,
>     I'm having a problem with a circular plot in that when I run my code
> a line is left behind instead of being erased.  You can see what I mean
> if you compile my code.  (plotapplet.jar will need to be in the working
> directory to use appletviewer).  Any help would be appreciated.
> 
> Thanks,
> Trevor

and then

> Sorry about this but I posted the incorrect version of the code.
> testapplet.java is ok though.

--start--    
    import ptolemy.plot.*;
    import java.awt.*;
    import java.applet.Applet;
    
    public class test extends PlotLive {
    
    
                public test() {
    
                                setTitle("Test");
                                setYRange(-1, 1);
                                setXRange(-1,1);
                                setPointsPersistence(2);
                                setMarksStyle("none");
                                setReuseDatasets(true);
                                setConnected(true,0);
                }
    
    
                public synchronized void addPoints() {
                                addPoint(0, Math.cos(omega), Math.sin(omega),
                                false); 
                                addPoint(0, 0,0,true);
    
                                first = false;
                                count += 1.0;
                                omega += Math.PI/64;
    
                                try {
                                                Thread.sleep(5);
                                                clear(0);
                                }
                                catch (InterruptedException e) {}
                }
    
    
                private boolean first = true;
    
                private double count = 0.0;
    
                private double omega = 0.0;
    }
--end--

BTW - Here is testapplet.java: 
--start--
import ptolemy.plot.*;
import ptolemy.plot.PlotLive;
import java.applet.Applet;
import java.awt.*;

/*
    <APPLET
            CODE = testapplet.class
            WIDTH = 500
            HEIGHT = 500
                archive = ./plotapplet.jar>
                </APPLET>
                                    */

public class testapplet extends PlotLiveApplet {

                public PlotBox newPlot() {
                                return new test();
                }
}
--end--
PlotLive has a problem with leaving trash behind on the screen.
There are lots of really really neat issues around this, one
of which has to do with threading, another of which has to
with XOR bugs in the JDK.  We have a likely candidate for a fix, 
to give you an idea of what we are up against, some of the comments
look like: 


        if (_showing && graphics != null) {

            if ((_pointsPersistence > 0 || _xPersistence > 0.0)
                    && isDoubleBuffered()) {
                // NOTE: Double buffering has a bug in Java (in at least
                // version 1.3) where there is a one pixel alignment problem
                // that prevents XOR drawing from working correctly.
                // XOR drawing is used for live plots, and if double buffering
                // is turned on, then cruft is left on the screen whenever the
                // fill or zoom functions are used.
                // Here, if it hasn't been done already, we turn off double
                // buffering on this panel and all its parents for which this
                // is possible.  Note that we could do this globally using
                //
                // RepaintManager repaintManager
                //        = RepaintManager.currentManager(this);
                // repaintManager.setDoubleBufferingEnabled(false);
                //
                // However, that turns off double buffering in all windows
                // of the application, which means that other windows that only
                // work properly with double buffering (such as vergil windows)
                // will not work.
                //
                // NOTE: This fix creates another problem...
                // If there are other widgets besides the plotter in the
                // same top-level window, and they implement double
                // buffering (which they will by default), then they
                // need to be opaque or drawing artifacts will appear
                // upon exposure events.  The workaround is simple:
                // Make these other objects opaque, and set their
                // background color appropriately.
                //
                // See:
                // <pre>
                // http://developer.java.sun.com/developer/bugParade/bugs/
                //     4188795.html
                //     4204551.html
                //     4295712.htm
                // </pre>
                //
                // Since we are assured of being in the event dispatch thread,
                // we can simply execute this.
                setDoubleBuffered(false);
                Component parent = getParent();
                while (parent != null) {
                    if (parent instanceof JComponent) {
                        ((JComponent)parent).setDoubleBuffered(false);
                    }
                    parent = parent.getParent();
                }
            }

We are planning to do a Ptplot0.4.1 release, but Installshield Java
version has a bug that prevents Ptplot from uninstalling, so
I'm waiting for a fix from them before proceeding with the release
process.  If you are still interested in working around this,
send me email and I'll point you at Ptplot0.4.1 tree.

I tried out your example, and after I commented out:


                                try {
                                                Thread.sleep(5);
                                                clear(0);
                                }
                                catch (InterruptedException e) {}

then your example ran without kruft.

-Christopher

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to