Print

Print


Hello List,

my agents have a method that color them according to a boolean variable:

@Override
    public final void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
        if (answer) {
            graphics.setColor(rightAnswer);
        } else {
            graphics.setColor(badAnswer);
        }
        // this code was stolen from OvalPortrayal2D
        int xx = (int) (info.draw.x - info.draw.width / 2.0);
        int yy = (int) (info.draw.y - info.draw.height / 2.0);
        int width = (int) (info.draw.width);
        int height = (int) (info.draw.height);
        graphics.fillOval(xx, yy, width, height);
    }

I adapted this method from antsforage, but I'd like to add a LabelledPortrayal2D to display the id number of my agents. However, I have no clue on how to accomplish this task, what is the easier way to modify my draw()?

Best regards,
Simone