MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 2011-10-03 15:37:29

lois.vanhee
Member
Registered: 2011-10-03
Posts: 12

Display not refreshed

Dear all,

I extended the Viewer class to represent turtles with triangles and patches with squares in overloading the "paintTurtle" and "paintPatch" operations. The graphics are not repainted during this operation. Consequently, when my turtles move, I add the new position (what I want to) but I let the old trace on the painting device. When a repaint is called (in changing the size of the display for instance), old traces are cleared.

Do I have to call manyally a "repaint" every round ? If so, is there a method called every round, or have I to add another device by hand to check for it ?


Thank you for your help

Offline

#2 2011-10-04 10:50:11

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 172
Website

Re: Display not refreshed

Hi,

This is indeed not well documented...

Redefine paintInfo in your viewer as follows :

    @Override
    public void paintInfo(Graphics g) {
        redrawAll = true;
        super.paintInfo(g);
    }
   

This should do the trick.

Offline

#3 2011-10-04 12:43:52

lois.vanhee
Member
Registered: 2011-10-03
Posts: 12

Re: Display not refreshed

Ok, I will check this out. Why is it not the default function of the Viewer class ?

Offline

#4 2011-10-04 13:53:37

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 172
Website

Re: Display not refreshed

lois.vanhee wrote:

Why is it not the default function of the Viewer class ?

By default, the redrawing is in fact optimized when few changes are done on the grid, which is the usual case (turtles' positions and patches' color)
Anyway, it is likely that this will be refactored in version 3 as the redrawing engine will contain some changes with respect to 3D integration.

Offline

#5 2011-10-04 15:07:44

lois.vanhee
Member
Registered: 2011-10-03
Posts: 12

Re: Display not refreshed

I would like to know more about how TK manages patches. Apparently, each observer accesses the "patchGrid". Is this object shared between every view (which would be problematic with color setting, because 2 views would have the same patch color) ?

What is the best way to access patches ? Now I do it through an Observer, so I have to multiply patch operations if I want to update multiple Observers.

Offline

#6 2011-10-21 16:50:35

fmichel
Administrator
From: Montpellier
Registered: 2009-03-24
Posts: 172
Website

Re: Display not refreshed

Yes the patchGrid is a shared object but this should not be a problem as you can interpret the attributes of a pacth as will. So you can produce different visualizations. src/edu/turtlekit2/demos/diffusion shows how this could be done for having different displays corresponding to different patch variables.

Offline

Board footer