|
From: | John Lee |
Subject: | [Swarm-Modelling] A question about using jFreeChart in Model |
Date: | Mon, 3 Apr 2006 12:11:04 +0800 |
Hi, The other day I found the Java Swarm based ASM’s
BarChart is using jFreeChart, I want to use it in my Model. But I found I
couldn’t update the data, it always stay in initial data. How should I do to update dataset? Thank you very
much. The following is part of my code. In ObserverSwarm: … displayActions.createActionTo$message
(chart, new Selector (chart.getClass (), "_updateChart_", false)); … In BarChart’s Class: … public
Object _updateChart_ () { int x, y; int c = 0; world = new
Grid2dImpl(getZone(), WorldXSize, WorldYSize); Trade test2 = new
Trade(world); for (x = 0; x <
WorldXSize; x++) {
for (y = 0; y < WorldYSize; y++) {
Integer a = new Integer(c + 1);
positionData.setValue(0, a.toString(),
new Double(test2.getCount(x,y)));
c++;
} }
positionChart.setDataset(positionData); return this; } //getCount(x,y) means to get data in two-dimension
array. |
[Prev in Thread] | Current Thread | [Next in Thread] |