import Graph; import GenerationsContainerGraph; import java.awt.Color; import java.util.Vector; import java.util.Observable; import java.util.Observer; public class GenerationsContainerGraph extends Graph implements Observer { public static int AVERAGE=1; public static int MINIMUM=2; public static int MAXIMUM=3; protected int graphStat; protected boolean useDefColor; protected GenerationsContainer genCon; public GenerationsContainerGraph() { this(null); } public GenerationsContainerGraph(GenerationsContainer gc) { super("Average"); setGenerationsContainer(gc); useDefColor=true; setGraphStatistic(AVERAGE); } public void setGraphStatistic(int stat) { if (stat==AVERAGE||stat==MINIMUM||stat==MAXIMUM) { graphStat=stat; setName(); if (useDefColor) setToDefColor(); } } protected void setName() { if (graphStat==AVERAGE) setName("Average"); if (graphStat==MINIMUM) setName("Minimum"); if (graphStat==MAXIMUM) setName("Maximum"); } protected void setToDefColor() { System.out.println("Ran GenerationsContainerGraph.setToDefColor()"); if (graphStat==AVERAGE) super.setColor(Color.blue); if (graphStat==MINIMUM) super.setColor(Color.red); if (graphStat==MAXIMUM) super.setColor(new Color(0,128,0)); } public void setColor(Color c) { useDefColor=false; super.setColor(c); } public void setGenerationsContainer(GenerationsContainer gc) { if (genCon!=null) genCon.deleteObserver(this); genCon=gc; genCon.addObserver(this); } public GenerationsContainer getGenerationsContainer() { return genCon; } public Vector getPointsBetween(float minX, float maxX) { int len=genCon.getLastGenerationNumber(); int min=genCon.getLowestGenerationNumber(); int stPoint=min>=minX ? min : (int)minX; Vector p=new Vector(0,1); int fitnesses[]; float x, y=0; //assign to shut up compiler Generation gen=new Generation(0); //assign to shut up compiler for (int i=stPoint;i