/* * (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.view.*;import edu.brook.ascape.util.*;import jclass.chart.*;public class GAS_III_3 extends GAS_SexBase {    public void createViews() {        super.createViews();        		StatCollector[] stats = new StatCollector[4];        stats[0] = new StatCollectorCond() {            public boolean meetsCondition(Object object) {                return (((SugarAgent) object).getSugarMetabolism() == 1);            }            public String getName() {                return "Sugar Metabolism = 1";            }        };        stats[1] = new StatCollectorCond() {            public boolean meetsCondition(Object object) {                return (((SugarAgent) object).getSugarMetabolism() == 2);            }            public String getName() {                return "Sugar Metabolism = 2";            }        };        stats[2] = new StatCollectorCond() {            public boolean meetsCondition(Object object) {                return (((SugarAgent) object).getSugarMetabolism() == 3);            }            public String getName() {                return "Sugar Metabolism = 3";            }        };        stats[3] = new StatCollectorCond() {            public boolean meetsCondition(Object object) {                return (((SugarAgent) object).getSugarMetabolism() == 4);            }            public String getName() {                return "Sugar Metabolism = 4";            }        };		agents.addStatCollectors(stats);                //Create some colors to use throughout the views        //White is just a placeholder, since there is no metabolism 0        final Color[] colorForMetabolism = {Color.white, new Color(0.0f, 0.0f, 1.0f), new Color(0.6f, 0.0f, 1.0f),                                                         new Color(1.0f, 0.0f, 0.6f), new Color(1.0f, 0.0f, 0.0f)};                //Set the method that the view will use to determine agent color        sugarView.setAgentColorFeature(new ColorFeatureConcrete("Sugar Metabolism") {            public Color getColor(Object object) {                return colorForMetabolism[((SugarAgent) object).getSugarMetabolism()];            }        });                //Create pie chart		ChartView chart = new ChartView();    	chart.setChartType(ChartView.PIE);		agents.addView(chart);		for (int i = 1; i <=4; i++) {        	chart.addSeries("Count Sugar Metabolism = " + i, colorForMetabolism[i]);        }                //And time series		ChartView ts = new ChartView();    	ts.setChartType(ChartView.TIME_SERIES);		agents.addView(ts);		for (int i = 1; i <=4; i++) {        	ts.addSeries("Count Sugar Metabolism = " + i, colorForMetabolism[i]);        }    	ts.getLegend().setIsShowing(false);    }}
