MASON-INTEREST-L Archives

November 2004

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Mon, 15 Nov 2004 17:12:31 -0500
MIME-version:
1.0 (Apple Message framework v619)
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Content-type:
text/plain; format=flowed; charset=US-ASCII
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Content-transfer-encoding:
7bit
Comments:
To: MASON Multiagent Simulation Toolkit <[log in to unmask]>
Parts/Attachments:
text/plain (30 lines)
MASON at present doesn't have built-in support for adding new objects
via the mouse, but that's just because we hadn't needed it ourselves
yet.  While you *can* compute all the coordinates yourself, it's
complex.  Each field portrayal can have its own coordinate system.

Here's how I'd do it.  In Display2D there's a method called
objectsHitBy(rect), which takes a rect (in InnerDisplay2D coordinates)
and returns LocationWrappers for all the objects in fields which
happened to fall into this region.  It does most of the math for you if
you want to cut-and-paste and modify.  The heavy lifting is done clear
to the line

             p.portrayal.hitObjects( new DrawInfo2D(region,rect),
hitObjs[x] );

...at which point you'd replace this line with some appropriate code
(and probably reduce your copy of the the objectsHitBy(...) code so it
doesn't go through all the field portrayals but just the one you need).

region defines a rectangle whose <x,y> is the origin of the field, and
whose <width,height> is the scaled width and height of the field.  So
you could interpret the DrawInfo2D as saying:  "imagine if you will
that your field has been translated and stretched so that its origin
lies on <x,y> in the cartesian plane, and has been bent to a width and
height of <width,height>.  Then the area I'm interested in is the rect
'rect' in that imaginary situation."  For a mouse click, rect will
probably have a width and height of 1,1.

Sean

ATOM RSS1 RSS2