MASON-INTEREST-L Archives

September 2015

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Content-Type:
text/plain; charset="us-ascii"
Date:
Thu, 3 Sep 2015 07:06:37 +0000
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Message-ID:
Subject:
From:
Tschanen Miriam <[log in to unmask]>
Content-Transfer-Encoding:
8bit
In-Reply-To:
MIME-Version:
1.0
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Parts/Attachments:
text/plain (56 lines)
Hi Sean,

Thanks a lot, that fixed my problems.

Cheers,
Miriam
________________________________________
Von: MASON Multiagent Simulation Toolkit [[log in to unmask]]&quot; im Auftrag von &quot;Sean Luke [[log in to unmask]]
Gesendet: Mittwoch, 2. September 2015 23:40
An: [log in to unmask]
Betreff: Re: Possible bug in ChartUtilities class

Looks like a stupid bug.  As a first cut, try replacing the PieChartSeriesAttributes.getElements() method with:

    Object[] getElements()
        {
        if (elements != null) return elements;
        else if (elements2 != null) return elements2.toArray();
        else return null;
        }

Sean

On Sep 1, 2015, at 7:56 PM, Tschanen Miriam <[log in to unmask]> wrote:

> Hi all,
>
> I'm trying to set up a custom bar chart for my model, since the level of control I have over the default inspectors isn't quite enough for my needs. I stumbled upon the sim.display.ChartUtilities class and tried to use it to attach a bar chart directly to my simulation. Unfortunately, I can't figure out how to use it correctly, or rather I am constantly getting a NullPointerException as soon as the simulation runs.
>
> As outlined in its documentation, I call the following functions in my GUIstate class to set up the bar chart:
>
> public void init(Controller c) {
>     ...
>
>     BarChartGenerator bcgenerator = ChartUtilities.buildBarChartGenerator(this, "Bar Chart");
>     barchart = ChartUtilities.addSeries(bcgenerator, "Bar Chart");  <-- this is where the exception triggers
> }
>
> public void setupPortrayals() {
>     ...
>
>     ChartUtilities.scheduleSeries(this, barchart, sim.data);
> }
>
> These are the top few lines of the trace:
> java.lang.NullPointerException
>     at sim.util.media.chart.PieChartSeriesAttributes.getElements(PieChartSeriesAttributes.java:40)
>     at sim.util.media.chart.PieChartGenerator.update(PieChartGenerator.java:136)
>     at sim.util.media.chart.PieChartGenerator.addSeries(PieChartGenerator.java:187)
>     at sim.display.ChartUtilities.addSeries(ChartUtilities.java:569)
>
> Either I'm missing something important or there is a bug in the implementation of addSeries. Is there some other way I can create a bar chart with full control over the labels and categories? As I mentioned, the default inspector isn't much help, for instance it sorts numerical categories in an awful way (placing 10 before 2 etc).
>
> Cheers,
> Miriam Tschanen

ATOM RSS1 RSS2