Sender: |
|
Date: |
Wed, 11 Feb 2015 17:35:26 +0100 |
Reply-To: |
|
Subject: |
|
MIME-Version: |
1.0 |
Message-ID: |
|
In-Reply-To: |
|
Content-Type: |
multipart/alternative; boundary=089e012947ac6a7702050ed298d9 |
From: |
|
Parts/Attachments: |
|
|
Hi Sean,
thanks for the help,
First off, I'd not copy stuff from OvalPortrayal2D unless you have to.
> Just subclass your agents from OvalPortrayal2D. Then you can say:
>
> public final void draw(Object object, Graphics2D graphics, DrawInfo2D
> info) {
> if (answer)
> graphics.setColor(rightAnswer);
> else
> graphics.setColor(badAnswer);
> super.draw(object, graphics, info);
> }
>
Actually I was copying your code from antsforage, but if I do as you
suggest here, my agents don't get colored, they remains grey as default.
About the labeling, I have added these lines as suggested:
/*
* in MyModelWithUI.java
*/
public void setupPortrayals() {
ArgumentativeAgents af = (ArgumentativeAgents)state;
bugPortrayal.setField(af.buggrid);
// NEW CODE
LabelledPortrayal2D foo = new LabelledPortrayal2D(null, "pipo");
bugPortrayal.setPortrayalForClass(ArgumentativeAgent.class, foo);
// END
// reschedule the displayer
display.reset();
// redraw the display
display.repaint();
}
/*
* In ArgumentativeAgent.java
*/
@Override
public String toString(){
return String.valueOf(id);
}
But nothing's happening... where am I wrong?
Best,
Simone
|
|
|