MASON has facilities for inspecting objects automatically by double-
clicking on them. But it has no built-in facilities for user
selection and moving. However, it DOES have easy hooks for them, at
least in the 2D environment.
A useful method to examine is Display2D.createInspectors(...). This
method is called when the user double-clicks on the Display2D (by a
mouse listener that passed in a 1x1 rectangle at the mouse-click
point). createInspectors calls a method called Display2D.objectsHitBy
(rect), which returns an array of Bags, one Bag per FieldPortrayal
attached to the Display2D. Each Bag contains LocationWrappers
pointing to all the objects in the fields which intersected with this
point. Display3D has similar methods.
You are free to add a mouse listener, or modify Display2D's, and call
objectsHitBy to get the objects yourself and do whatever you like
with them. At present we do not have any method for *changing* the
"location" of an object, to move it per se -- mostly because we
hadn't bothered to write such a monster yet -- but it's definitely
doable. We do have a hook for Portrayals (setSelected(...), unused
at the moment) which allows you to tell Portrayals that certain
underlying objects have been "selected" by the user -- perhaps he
clicked on them one time or something. But we've not hooked that up
yet. Wouldn't be hard to wire it I guess.
On Feb 14, 2006, at 8:03 PM, Ben Axelrod wrote:
> I recently started using MASON a few weeks ago. I am modifying
> 5 for a quick and dirty distributed network simulator. I would
> like to
> allow the user to select a node or group of nodes with the mouse.
> nodes are now motionless in my simulation). this selection only needs
> to set a boolean member variable. what is the easiest way to do this?
> PS. I am pretty good with C++, but still new to Java...