Print

Print


field.remove(foo) will definitely remove foo from the field, and the Field Portrayal will definitely stop calling draw() on its corresponding SimplePortrayal.  So if you're having a problem at this point either there's a bug in your code or a bug in ours.  To determine this, I will need you to send me (directly) a tarball containing an ideally simple example of the bug happening, including source code, so we can poke around.

The only other thing I can think of is that you are using the same SimplePortrayal for multiple objects in the field -- that's typical -- but are storing some kind of state or information in the SimplePortrayal which is somehow carrying over -- that's unlikely.  Or you have the object being added to the field somehow or it's part of some other field which is being drawn.

Sean

On Aug 7, 2012, at 9:21 PM, Luís de Sousa wrote:

> Hi again Sean,
> 
> So I must be missing something. I'm simply invoking the remove method, like:
> 
> field.remove(this)
> 
> Is there a way to find which fields an object is be attached to?
> 
> Thank you,
> 
> Luís
> 
> On 7 August 2012 00:01, Sean Luke <[log in to unmask]> wrote:
>> It's not possible that the objects have been removed from the field.  Here's how draw() works.
>> 
>> 1. The window tells the Display to draw.
>> 2. The Display tells each Field Portrayal to draw.
>> 3. The Field Portrayal for your Sparse Grid looks up all the objects in the grid.  For each object:
>>    3a. The Field Portrayal determines if the object is presently in the viewable area.
>>    3b. If it is, the Field Portrayal looks up the Simple Portrayal for the underlying object and calls draw() on it.
>> 
>> And that's about it.  Your object has to be in the grid in order to receive a draw request, so far as I can think of.
>> 
>> Sean
>> 
>> On Aug 6, 2012, at 11:30 PM, Luís de Sousa wrote:
>> 
>>> Hi Sean, thanks for answering.
>>> 
>>> I'm sorry for not being more explicit, this is happening with objects
>>> that have been stopped and removed from the field, a SparseGrid in
>>> this case. So I believe they are not in the physical world any more.
>>> 
>>> Luís
>>> 
>>> On 1 January 2001 07:44, Sean Luke <[log in to unmask]> wrote:
>>>> 
>>>> In fact, even after the simulation has *ended*, as long as you have objects present in the physical world, whenever the window is resized or certain other GUI events occur, the draw() method may *still* be called to redraw them.
>>>> 
>>>> You should *always* redraw your objects.  If you don't want them drawn, remove them from your field.  If you'd like them to draw themselves with some default color indicating that they're "stopped", you could do that.
>>>> 
>>>> Sean
>>