package visualization.statistics; public abstract class ModelStatistics extends LineChart{ } package visualization.statistics; public class GameOfLifeStatistics extends ModelStatistics{ public GameOfLifeStatistics() } package visualization.statistics; public class SegregationStatistics extends ModelStatistics{ public SegregationStatistics() } package visualization.statistics; public class SpreadingFireStatistics extends ModelStatistics{ public SpreadingFireStatistics() } package visualization.statistics; public class WaTorStatistics extends ModelStatistics{ public WaTorStatistics() } package visualization.model_controls; public class GameOfLifeControl extends ModelControl { public GameOfLifeControl(Simulator sim) super(sim); } public GameOfLifeControl(String shape) this(GameOfLife.generate(DEFAULT_CELL_NUM, shape)); } public void handleStructureChange(int numCell, List> neighborIndices) public void handleParamChange() } package visualization.model_controls; public class SpreadingFireControl extends ModelControl { public static final Label probCatchCaption = new Label("probCatch:"); public SpreadingFireControl(String shape) this(SpreadingFire.generate(DEFAULT_CELL_NUM, shape)); } public SpreadingFireControl(Simulator sim) public void handleStructureChange(int numCell, List> neighborIndices) public void handleParamChange() } package visualization.model_controls; public class WaTorControl extends ModelControl { public static final Label fishBreedCaption = new Label("Fish Breeding Period:"); public static final Label sharkBreedCaption = new Label("Shark Breeding Period:"); public static final Label sharkStarveCaption = new Label("Shark Starve Period:"); public WaTorControl(String shape) this(WaTor.generate(DEFAULT_CELL_NUM, shape)); } public WaTorControl(Simulator sim) public void handleStructureChange(int numCell, List> neighborIndices) public void handleParamChange() } package visualization.model_controls; public abstract class ModelControl extends VBox { public ModelControl(Simulator sim) public abstract void handleStructureChange(int numCell, List> neighborIndices); public abstract void handleParamChange(); public boolean consumeIsDirty() public SimulationPanel simPanel() return simPanel; } public Simulator simulator() return simPanel.simulator(); } } package visualization.model_controls; public class SegregationControl extends ModelControl { public static final Label thresholdCaption = new Label("Threshold:"); public SegregationControl(String shape) public SegregationControl(Simulator sim) public void handleStructureChange(int numCell, List> neighborIndices) public void handleParamChange() } package visualization; public class SimulationPanel extends VBox { public SimulationPanel(Simulator sim) public Simulator simulator() return simulator; } } package visualization.neighbor_chooser; public class NeighborChooser extends Dialog>> { public NeighborChooser(String shapeType) } package visualization.neighbor_chooser; public class NeighborChooserPane extends DialogPane { public NeighborChooserPane(String shapeType) public List> getChosenIndices() } package visualization.neighbor_chooser; public class IndexedShape { public IndexedShape(Shape shape_, Integer rowOffset_, Integer columnOffset_) public Shape shape() return shape; } public Pair offset() return new Pair<>(rowOffset, columnOffset); } public boolean selected() return selected; } public void toggleSelection() } package visualization; public class Main extends Application { public void start(Stage primaryStage) } package visualization; public class SimulationControl extends HBox { public SimulationControl(Window window_, ResourceBundle myResources, String myLanguage) public void tick(double duration, ModelStatistics modelChart) public StatusCode consumeStatusCode() public String[] models() return models; } } package visualization; public class GUI { public GUI (String language) public void runGUI (Stage primaryStage) public void step(double duration) } package simulation; public class CellGraph extends HashMap, List>> { public Set> getCells() return keySet(); } public List> getOrderedCells(SimulationModel model) public Set getViews() return getCells().stream().map(Cell::view).collect(Collectors.toSet()); } public List> getNeighbors(Cell cell) return get(cell); } public int shapeCode() } package simulation.models; public class WaTorModel implements SimulationModel { public WaTorModel(int fishBreedPeriod_, int sharkBreedPeriod_, int sharkStarvePeriod_) public int updatePriority(Fish myVal) public void localUpdate(Cell me, List> neighbors) public void globalUpdate(CellGraph graph) public Fish nextValue(Fish myVal) public Color chooseColor(Fish myVal) public String modelName() return MODEL_NAME; } public Map getStatistics(List values) public XMLWriter getXMLWriter(CellGraph graph, File outFile, String language) public void updateModelParams(Map params) public Fish getValFromCode(int code) public List getCodes() public int getDefaultCode() public int getFishBreedPeriod() return fishBreedPeriod; } public int getSharkBreedPeriod() return sharkBreedPeriod; } public int getSharkStarvePeriod() return sharkStarvePeriod; } } package simulation.models; public interface SimulationModel { } package simulation.models.wator; public class Shark extends Fish { public Shark() this(0, 0); } public Shark(int breedingCounter, int starveCounter_) public int tick(int breedPeriod, int starvePeriod) public void eat() starveCounter = 0; } public int kind() return WaTorModel.SHARK; } } package simulation.models.wator; public class Fish { public Fish() this(0); } public Fish(int breedCounter_) breedCounter = breedCounter_; starveCounter = 0; } public int tick(int breedPeriod, int starvePeriod) public void breed() breedCounter = 0; } public void eat() public int kind() return WaTorModel.FISH; } public int breedCounter() return breedCounter; } public int starveCounter() return starveCounter; } } package simulation.models; public class SegregationModel implements SimulationModel { public SegregationModel(double threshold) satisfactionThreshold = threshold; } public int updatePriority(Integer myVal) return 0; } public void localUpdate(Cell me, List> neighbors) public void globalUpdate(CellGraph graph) public Integer nextValue(Integer myVal) public Color chooseColor(Integer myVal) public String modelName() return MODEL_NAME; } public Map getStatistics(List values) public XMLWriter getXMLWriter(CellGraph graph, File outFile, String language) public void updateModelParams(Map params) public Integer getValFromCode(int code) public List getCodes() public int getDefaultCode() public double getSatisfactionThreshold() return satisfactionThreshold; } } package simulation.models; public class SpreadingFireModel implements SimulationModel { public SpreadingFireModel(double probCatch_) public int updatePriority(Integer myVal) return 0; } public void localUpdate(Cell me, List> neighbors) public void globalUpdate(CellGraph graph) public Integer nextValue(Integer myVal) public Color chooseColor(Integer myVal) public String modelName() return MODEL_NAME; } public Map getStatistics(List values) public XMLWriter getXMLWriter(CellGraph graph, File outFile, String language) public void updateModelParams(Map params) public Integer getValFromCode(int code) public List getCodes() public int getDefaultCode() public double getProbCatch() return probCatch; } } package simulation.models; public class GameOfLifeModel implements SimulationModel { public int updatePriority(Integer myVal) return 0; } public void localUpdate(Cell me, List> neighbors) public void globalUpdate(CellGraph graph) public Integer nextValue(Integer myVal) return myVal == ALIVE ? DEAD : ALIVE; } public Color chooseColor(Integer myVal) return myVal == DEAD ? Color.WHITE : Color.BLACK; } public String modelName() return MODEL_NAME; } public Map getStatistics(List values) public GameOfLifeWriter getXMLWriter(CellGraph graph, File outFile, String language) public void updateModelParams(Map params) public Integer getValFromCode(int code) public List getCodes() public int getDefaultCode() } package simulation; public class Simulator { public Simulator(CellGraph graph_, SimulationModel model_) public void tick() public Node view() public int tickCount() return tickCount; } public String modelName() return model.modelName(); } public XMLWriter getWriter(File outFile, String language) return model.getXMLWriter(graph, outFile, language); } public void updateSimulationModel(Map params) model.updateModelParams(params); } public String peekShape() public Map getStatistics() } package simulation; public class Cell { public Cell(T value_, int shapeCode_, double cx_, double cy_, double width_, double height_) public void commit() value = next; next = null; } public void updateView(SimulationModel model) view.setFill(model.chooseColor(value)); } public void handleClick(SimulationModel model) value = model.nextValue(value); updateView(model); } public T value() return value; } public T next() return next; } public int shapeCode() return shapeCode; } public double cx() return cx; } public double cy() return cy; } public double width() return width; } public double height() return height; } public Shape view() return view; } public void setNext(T next_) next = next_; } } package simulation.factory; public class GameOfLife { public static Simulator generateTri(int row, int column, public static Simulator generateRect(int row, int column, public static Simulator generate(int n, String shape, List> indices) public static Simulator generate(int n, String shape) return generate(n, shape, null); } } package simulation.factory; public class WaTor { public static Simulator generateTri( public static Simulator generateRect( public static Simulator generate(int n, String shape, List> indices) public static Simulator generate(int n, String shape) return generate(n, shape, null); } } package simulation.factory; public class NeighborUtils { public static CellGraph triangularGraph(List> cells, public static CellGraph triangularGraphWrap(List> cells, public static CellGraph rectangularGraph(List> cells, public static CellGraph rectangularGraphWrap(List> cells, public static List> indicesFor12Triangle() public static List> indicesFor8Rectangle() public static List> indicesFor4Rectangle() } package simulation.factory; public class Segregation { public static Simulator generateTri( public static Simulator generateRect( public static Simulator generate(int n, String shape, List> indices) public static Simulator generate(int n, String shape) return generate(n, shape, null); } } package simulation.factory; public class SpreadingFire { public static Simulator generateTri( public static Simulator generateRect( public static Simulator generate(int n, String shape, List> indices) public static Simulator generate(int n, String shape) return generate(n, shape, null); } } package xml.parser; public class SegregationXMLParser extends ParentXMLParser { public static final Map> VAL_TAG_TO_RANGE_MAP = Map.ofEntries( public SegregationXMLParser(String language) public Simulator getSimulator(File datafile) } package xml.parser; public class GameOfLifeXMLParser extends ParentXMLParser { public static final Map> VAL_TAG_TO_RANGE_MAP = Map.ofEntries( public GameOfLifeXMLParser(String language) public Simulator getSimulator(File datafile) } package xml.parser; public class SpreadingFireXMLParser extends ParentXMLParser { public static final Map> VAL_TAG_TO_RANGE_MAP = Map.ofEntries( public SpreadingFireXMLParser(String language) public Simulator getSimulator(File datafile) } package xml.parser; public class WaTorXMLParser extends ParentXMLParser { public static final Map> VAL_TAG_TO_RANGE_MAP = Map.ofEntries( public WaTorXMLParser(String language) public Simulator getSimulator(File datafile) } package xml.parser; public abstract class ParentXMLParser { public ParentXMLParser(String language) public abstract Simulator getSimulator(File datafile); public CellGraph getCellGraph(Element root, SimulationModel model) public ArrayList> cellValsFromList(Element root, SimulationModel model, int n) public ArrayList> cellValsFromProbs(Element root, SimulationModel model, int n) public Map getValToProbMap(Element root, SimulationModel model) public CellGraph generateRect(int row, int column, ArrayList> vals) public CellGraph generateTri(int row, int column, ArrayList> vals) public static String getTextValue(Element e, String tagName) public static int getIntValue(Element e, String tagName, int min, int max, int def) public static double getDoubleValue(Element e, String tagName, double min, double max, double def) public static Element getRootElement(File xmlFile) public static String peekModelName(File xmlFile) public static DocumentBuilder getDocumentBuilder() } package xml.writer; public class SegregationWriter extends XMLWriter { public SegregationWriter(SegregationModel model_, CellGraph graph_, File outFile_, String language) } package xml.writer; public class GameOfLifeWriter extends XMLWriter { public GameOfLifeWriter(CellGraph graph_, File outFile_, String language) } package xml.writer; public class WaTorWriter extends XMLWriter { public WaTorWriter(WaTorModel model_, CellGraph graph_, File outFile_, String language) } package xml.writer; public abstract class XMLWriter { public XMLWriter(CellGraph graph_, File outFile_, String language) public void generate() } package xml.writer; public class SpreadingFireWriter extends XMLWriter { public SpreadingFireWriter(SpreadingFireModel model_, CellGraph graph_, File outFile_, String language) } package xml; public class XMLException extends RuntimeException { public XMLException (String message, Object ... values) public XMLException (Throwable cause, String message, Object ... values) public XMLException (Throwable cause) } package utility; public class ColorUtils { public static Color mix(Color a, Color b, double pA) } package utility; public class ShapeUtils { public static void centerShape(Shape s, double cx, double cy) public static Shape makeShape(int shapeCode, double cx, double cy, double w, double h) public static List shapeCodes() public static String[] shapes() }