/* * (c) 1998-2000 The Brookings Institution, All Rights Reserved * * Permission to use this software and its documentation for non-commercial * purposes and without fee is hereby granted, provided this copyright statement * is included. Please contact us for permission for redistribution and other uses. *  * BROOKINGS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,  * OR NON-INFRINGEMENT. BROOKINGS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING THIS SOFTWARE OR ITS DERIVATIVES. * * _Sugarscape_ * See _Growing Artificial Societies: Social Science from the Ground Up_ * Brookings Institution Press, The MIT Press * Joshua Epstein * jepstein@brook.edu * Robert Axtell * raxtell@brook.edu * * Miles Parker * mparker@brook.edu * http://www.brook.edu/es/dynamics/models/ascape * The Brookings Institution * Washington, D.C. */package edu.brook.sugarscape;import java.lang.*;import java.awt.*;import java.applet.*;import edu.brook.ascape.model.*;import edu.brook.ascape.util.*;import edu.brook.ascape.view.*;public class GAS_II_4 extends GAS_III_2 {    public void createViews() {        super.createViews();                final StatCollectorCSAMM wealth = new StatCollectorCSAMM() {        	public double getValue(Object o) {        		return ((SugarAgent) o).getSugar().getStock();        	}            public String getName() {                return "Wealth";            }        };        agents.addStatCollector(wealth);                class DecileCollector extends StatCollectorCond {			int decile;			public DecileCollector(int decile) {				this.decile = decile;			}            public boolean meetsCondition(Object o) {                return ((((SugarAgent) o).getSugar().getStock() > ((decile - 1) * 0.1 * wealth.getMax())) && (((SugarAgent) o).getSugar().getStock() < (decile * 0.1 * wealth.getMax())));            }            public final boolean isPhase2() {            	return true;            }            public String getName() {                return "Decile " +Integer.toString(decile);            }        }                StatCollectorCond[] decileStats = new StatCollectorCond[10];        for (int n = 1; n <= 10; n++) {	        decileStats[n - 1] = new DecileCollector(n);        }        agents.addStatCollectors(decileStats);                //Create pie chart		ChartView chart = new ChartView();    	chart.setChartType(ChartView.HISTOGRAM);		agents.addView(chart);		for (int i = 1; i <= 10; i++) {        	chart.addSeries("Count Decile " + i, Color.red);        }    }}
