Print

Print


Hello everyone,

I have the following problem. I'm painting a Continuous2D world (this is
the field that I paint) and I have a region in this world that I want to
draw in another color, as well as use it as a *special *zone for my agents.

I have the information of this region stored in a class that I defined,
called "Rectangle" (as the shape is a rectangle, so original name :-) ).
With the position and the size. Then, what I'm trying to do is to paint the
zone as follows:

In the start() method of my SimState I've done:

world.setObjectLocation(AREA, new Double2D(AREA.getX(), AREA.getY()));

While in setupPortrayals() in the GUIState class I've done:

entityPortrayal.setPortrayalForClass(Rectangle.class, new
RectanglePortrayal2D() {
            @Override
            public void draw(Object object, Graphics2D graphics, DrawInfo2D
info) {
                paint = new Color(0f, 0f, 0f, 0.3f);
                super.draw(object, graphics, info);
            }
        });

With this line I'm drawing a semi-transparent black rectangle, which center
is located in the position that I gave. However, it is drawn as a square
(and a big one by the way).
The point is that I don't know how to specify the shape and size of this
rectangle so it is drawn properly. I've been trying to look into the MASON
examples but I don't get it...

I'm also wondering how the "getNeighbors" would work if I want to know if
my agent is in the zone (actually I don't need to access to this
information this way as the rectangle is fixed to the same position and I
can do the calculus about the zone manually).

Thanks in advance for the help!

Regards,
Javier