Hi
Here's a piece of code from setupPortrayals for making a plot to show 3
statistics (averages of wealth, preference and utility) for my
population of agents.
if(agentAvgPlotGenerator!=null)
((JFrame)agentAvgPlotGenerator.getRootPane().getParent()).dispose();
//throw away the old chart (if its not the first time you pressed "Start")
Properties ap = new SimpleProperties(new AgentProperties());
//AgentProperties is a innerclass inside MySimWithUI
//where I make public a bunch of getters (and setters)
//for my agents.
ChartingPropertyInspector iPref = new TimeSeriesChartingPropertyInspector(ap,5,this, null);
agentAvgPlotGenerator =iPref.getGenerator();
//I make a new inspector and I take its chart generator
//so I can reuse it to show the rest of the stats in the same chart
ChartingPropertyInspector iWealth = new TimeSeriesChartingPropertyInspector(ap,6,this, agentAvgPlotGenerator);
ChartingPropertyInspector iUtil = new TimeSeriesChartingPropertyInspector(ap,10,this, agentAvgPlotGenerator);
//5, 6 and 10 are the indices of the right getters in SimpleProperties(AgentProperties).
//This is one of the reasons for using the proxy AgentProperties, instead
//of using the methods from MySim: as you continue to add methods to MySim, the indices might change.
//So you just make the proxy class that's only used by the charting code.
////(I myself also use these proxies inside a tabbed inspector for the
//// model (agent stats, firm stats, sim stats, etc), but for
//// now you should do as I say not as I do).
iWealth.setStopper(iWealth.reviseStopper(scheduleImmediateRepeat(true, iWealth.getUpdateSteppable())));
controller.registerInspector(iWealth, iWealth.getStopper());
//now get the stopper for each inspector and register it with the console
iPref.setStopper(iPref.reviseStopper(scheduleImmediateRepeat(true, iPref.getUpdateSteppable())));
controller.registerInspector(iPref, iPref.getStopper());
iUtil.setStopper(iUtil.reviseStopper(scheduleImmediateRepeat(true, iUtil.getUpdateSteppable())));
controller.registerInspector(iUtil, iUtil.getStopper());
enjoy
Gabriel
On Tue, 6 May 2008, MASON-INTEREST-L automatic digest system wrote:
> There are 2 messages totalling 162 lines in this issue.
>
> Topics of the day:
>
> 1. TimeSeriesChartingPropertyInspector (2)
>
> ----------------------------------------------------------------------
>
> Date: Mon, 5 May 2008 17:11:06 +0200
> From: =?ISO-8859-1?Q?Bj=F6rn_Raupach?= <[log in to unmask]>
> Subject: TimeSeriesChartingPropertyInspector
>
> Dear,
>
> hope this software is still alive ;-)
>
> Everything worked right out of the box, except some naming conflict -
> Java 6 introduces also some kind of console.
> Simulation runs fine, no problem.
> But I am having trouble with adding a
> TimeSeriesChartingPropertyInspector. I would like to display some
> property of my agents
> in a timeseries chart. There is a TimeSeriesChartingPropertyInspector in
> the source, but it is never referenced. Searching the mailing list
> didn't help much either. Could you help me out? How to display variables
> of agents in a proper way?
>
> Thanks in advance!
>
> with kind regards,
> bjoern
>
>
|