1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- package ui.model;
- import TypeAdapter.AbstractCpsObjectAdapter;
- import TypeAdapter.ColorAdapter;
- import TypeAdapter.PairAdapter;
- import TypeAdapter.PositionAdapter;
- import classes.*;
- import com.google.gson.Gson;
- import com.google.gson.GsonBuilder;
- import com.google.gson.JsonObject;
- import interfaces.CategoryListener;
- import interfaces.GraphListener;
- import interfaces.ObjectListener;
- import ui.view.*;
- import javax.swing.*;
- import java.awt.*;
- import java.util.*;
- import java.util.List;
- /**
- * The Class Model is the class where everything is saved. All changes made to
- * the Data is managed via a controller.
- *
- * @author Gruppe14
- */
- public class Model {
-
- private static final int GRAPH_ITERATIONS = 100;
- // Global Variables
- private static int sCALE = 50; // Picture Scale
- private static int sCALEdIV2 = sCALE / 2;
- private static int holonBodysCALE = 100; // Picture Scale
- public String[] colNames = {"Field", "Information"};
- // Canvas Attributes
- private String imgPath = "";
- private int backgroundMode = 0;
- private int backgroundWidth = 0;
- private int backgroundHeight = 0;
- private int canvasX = 1000;
- private int canvasY = 1000;
- private int curIteration = 0;
- private LinkedList<Color> subNetColors = new LinkedList<>();
- // ID of the Selected Object
- private AbstractCpsObject selectedCpsObject = null;
- private HolonElement selectedHolonElement;
- private CpsEdge selectedEdge;
- private ArrayList<AbstractCpsObject> selectedObjects = new ArrayList<>();
- private ArrayList<AbstractCpsObject> clipboardObjects = new ArrayList<>();
- private Console console;
- private HashMap<Integer, ArrayList<HolonElement>> eleToDelete;
- // Capacity for Edge
- private float maxCapacity;
- // Table for HolonElements --> all cells are editable
- private JTable tableHolonElement;
- private ArrayList<GraphListener> graphListeners = new ArrayList();
- // Iteration Speed
- private int timerSpeed = 1000;
- private int selectedID = 0;
- // number of the current autosave
- private int autoSaveNr = -1;
- // number of max simultaneous autosaves
- private int numberOfSaves = 35;
- // whether the simulation is running and has not been reseted
- private boolean isSimRunning = false;
- // whether the console log of the program should be displayed
- private boolean showConsoleLog = true;
- // whether the console log of the program should be displayed
- private boolean useFlexibleDevices = true;
- /** whether the supplyBars should be shown or not */
- private boolean showSupplyBars = true;
- //TODO:
- private int iterations=100;
-
- /** the Fairness model in use */
- private short fairnessModel = 0;
- /*
- * Array of all categories in the model. It is set by default with the
- * categories ENERGY, BUILDINGS and COMPONENTS
- */
- private ArrayList<Category> categories;
- /*
- * Array of all HolonObj and HolonSwitches, that should be tracked through
- * out the statistics tab
- */
- private ArrayList<AbstractCpsObject> trackedObjects;
- /*
- * Array of all CpsObjects in our canvas. It is set by default as an empty
- * list.
- */
- private ArrayList<AbstractCpsObject> objectsOnCanvas;
- private HashMap<String, Integer> cgIdx;
- private HashMap<Integer, Integer> cvsObjIdx;
- /*
- * Array of all CpsObjects in our canvas. It is set by default as an empty
- * list.
- */
- private ArrayList<CpsEdge> edgesOnCanvas;
- /*
- * Array for all Listeners
- */
- private List<CategoryListener> categoryListeners;
- private List<ObjectListener> objectListeners;
- private PropertyTable tableModelHolonElementMulti;
- private PropertyTable tableModelHolonElementSingle;
- private DefaulTable tableModelProperties;
- /*
- * Object that runs the Algorithm
- */
- private Object algorithm = null;
- private int selectedHolonBody;
- // Statistic Graph Data
- private Hashtable<String, StatisticGraphPanel> statisticGraphTable = new Hashtable<>();
- private HashMap<Integer, CpsUpperNode> hashcodeMap = new HashMap<>();
- private ArrayList<JsonObject> statisticData = new ArrayList<>();
- private Gson gson;
- private StatisticPanel statPanel;
- /**
- * Constructor for the model. It initializes the categories and
- * objectsOnCanvas by default values. Listeners are also initialized by
- * default values.
- */
- public Model() {
- setCategories(new ArrayList<>());
- setObjectsOnCanvas(new ArrayList<>());
- setEdgesOnCanvas(new ArrayList<>());
- setCategoryListeners(new LinkedList<>());
- setObjectListeners(new LinkedList<>());
- setCgIdx(new HashMap<>());
- setCvsObjIdx(new HashMap<>());
- setClipboradObjects(new ArrayList<>());
- setTrackingObj(new ArrayList<>());
- setEleToDelete(new HashMap<>());
- setSingleTable(new PropertyTable());
- setMultiTable(new PropertyTable());
- setPropertyTable(new DefaulTable(1000, colNames.length));
- getPropertyTable().setColumnIdentifiers(colNames);
- setTableHolonElement(new JTable());
- initGson();
- }
- /**
- * Returns all Categories.
- *
- * @return the categories
- */
- public ArrayList<Category> getCategories() {
- return categories;
- }
- /**
- * Sets all Categories.
- *
- * @param categories the categories to set
- */
- public void setCategories(ArrayList<Category> categories) {
- this.categories = categories;
- }
- /**
- * Transform the Arraylist of categories into a string of all objectName
- * with a separation (',') between each name.
- *
- * @return String of all names separeted by ','
- */
- public String toStringCat() {
- String text = "";
- for (int i = 0; i < categories.size(); i++) {
- if (text.equals("")) {
- text = categories.get(i).getName();
- } else {
- text = text + ", " + categories.get(i).getName();
- }
- }
- return text;
- }
- /**
- * Returns all Objects on the Canvas.
- *
- * @return the objectsOnCanvas
- */
- public ArrayList<AbstractCpsObject> getObjectsOnCanvas() {
- return objectsOnCanvas;
- }
- /**
- * Sets all Objects on the Canvas.
- *
- * @param objectsOnCanvas the objectsOnCanvas to set
- */
- public void setObjectsOnCanvas(ArrayList<AbstractCpsObject> objectsOnCanvas) {
- this.objectsOnCanvas = objectsOnCanvas;
- }
- /**
- * Get all Edges on the Canvas.
- *
- * @return the objectsOnCanvas
- */
- public ArrayList<CpsEdge> getEdgesOnCanvas() {
- return edgesOnCanvas;
- }
- /**
- * Sets the edges on the Canvas.
- *
- * @param arrayList the edgesOnCanvas to set
- */
- public void setEdgesOnCanvas(ArrayList<CpsEdge> arrayList) {
- this.edgesOnCanvas = arrayList;
- }
- /**
- * Adds an Edge to The Canvas.
- *
- * @param edge the edgesOnCanvas to add
- */
- public void addEdgeOnCanvas(CpsEdge edge) {
- this.edgesOnCanvas.add(edge);
- }
- /**
- * Remove an edge from the Canvas.
- *
- * @param edge the edge to remove
- */
- public void removeEdgesOnCanvas(CpsEdge edge) {
- this.edgesOnCanvas.remove(edge);
- }
- /**
- * Returns the ObjectListener.
- *
- * @return the objectListeners
- */
- public List<ObjectListener> getObjectListeners() {
- return objectListeners;
- }
- /**
- * Sets the ObjectListener.
- *
- * @param linkedList the objectListeners to set
- */
- public void setObjectListeners(LinkedList<ObjectListener> linkedList) {
- this.objectListeners = linkedList;
- }
- /**
- * Returns the CategorieListener.
- *
- * @return the categoryListeners
- */
- public List<CategoryListener> getCategoryListeners() {
- return categoryListeners;
- }
- /**
- * Sets the CategorieListener.
- *
- * @param linkedList the categoryListeners to set
- */
- public void setCategoryListeners(LinkedList<CategoryListener> linkedList) {
- this.categoryListeners = linkedList;
- }
- /**
- * Returns the ID of the selected Object 0 = no Object is selected.
- *
- * @return ID
- */
- public int getSelectedObjectID() {
- return selectedID;
- }
- /**
- * Set the ID of the selected Object 0 = no Object is selected.
- *
- * @param id the ID
- */
- public void setSelectedObjectID(int id) {
- this.selectedID = id;
- }
- /**
- * Returns the Selected Cps Object.
- *
- * @return selected Cps Object
- */
- public AbstractCpsObject getSelectedCpsObject() {
- return selectedCpsObject;
- }
- /**
- * Set the Selected Objecs.
- *
- * @param selectedCpsObject Objects that are selected
- */
- public void setSelectedCpsObject(AbstractCpsObject selectedCpsObject) {
- this.selectedCpsObject = selectedCpsObject;
- }
- /**
- * Returns all selected Objects on the Canvas.
- *
- * @return The selected Objects
- */
- public ArrayList<AbstractCpsObject> getSelectedCpsObjects() {
- return selectedObjects;
- }
- /**
- * Returns all selected Objects on the Canvas.
- *
- * @return The selected Objects
- */
- public void setSelectedCpsObjects(ArrayList<AbstractCpsObject> arr) {
- this.selectedObjects = arr;
- }
- /**
- * Returns the Selected Holon Element.
- *
- * @return selected Holon Element
- */
- public HolonElement getSelectedHolonElement() {
- return selectedHolonElement;
- }
- /**
- * Sets the Selecte HolonElement.
- *
- * @param selectedHolonElement that is Selected
- */
- public void setSelectedHolonElement(HolonElement selectedHolonElement) {
- this.selectedHolonElement = selectedHolonElement;
- }
- /**
- * Returns the sCale (Scale for the Images).
- *
- * @return sCALE
- */
- public int getScale() {
- return sCALE;
- }
- /**
- * Sets the Image Scale.
- *
- * @param scale for the image
- */
- public void setScale(int scale) {
- sCALE = scale;
- if ((sCALE & 1) == 0)
- sCALEdIV2 = sCALE / 2;
- else
- sCALEdIV2 = (sCALE + 1) / 2;
- }
- /**
- * Returns sCALEdIV2 (The Scale divided by 2).
- *
- * @return sCALEdIV2
- */
- public int getScaleDiv2() {
- return sCALEdIV2;
- }
- /**
- * Returns ITERATIONS.
- *
- * @return ITERATIONS
- */
- public int getIterations() {
- return iterations;
- }
- private void notifyGraphListeners() {
- for (GraphListener gl : graphListeners) {
- gl.repaintTree();
- }
- }
- /**
- * Returns cURiTERATION.
- *
- * @return cURiTERATION
- */
- public int getCurIteration() {
- return curIteration;
- }
- /**
- * sets the current Iteration.
- *
- * @param curIT the current Iteration
- */
- public void setCurIteration(int curIT) {
- this.curIteration = curIT;
- notifyGraphListeners();
- }
- /**
- * Returns the selected Edge.
- *
- * @return selectedEdge
- */
- public CpsEdge getSelectedEdge() {
- return selectedEdge;
- }
- /**
- * Set the selected Edge.
- *
- * @param edge that is selected
- */
- public void setSelectedEdge(CpsEdge edge) {
- this.selectedEdge = edge;
- }
- /**
- * Returns the Categorie Index.
- *
- * @return the cgIdx
- */
- public HashMap<String, Integer> getCgIdx() {
- return cgIdx;
- }
- /**
- * Sets the Categorie Index.
- *
- * @param cgIdx the cgIdx to set
- */
- public void setCgIdx(HashMap<String, Integer> cgIdx) {
- this.cgIdx = cgIdx;
- }
- /**
- * Returns the CanvasObject Index.
- *
- * @return the cvsObjIdx
- */
- public HashMap<Integer, Integer> getCvsObjIdx() {
- return cvsObjIdx;
- }
- /**
- * Sets the CanvasObject Index.
- *
- * @param cvsObjIdx the cvsObjIdx to set
- */
- public void setCvsObjIdx(HashMap<Integer, Integer> cvsObjIdx) {
- this.cvsObjIdx = cvsObjIdx;
- }
- /**
- * Returns the auto save Number.
- *
- * @return the auto save Number
- */
- public int getAutoSaveNr() {
- return autoSaveNr;
- }
- /**
- * Sets the auto save Number.
- *
- * @param autoSaveNr the auto save number
- */
- public void setAutoSaveNr(int autoSaveNr) {
- this.autoSaveNr = autoSaveNr;
- }
- /**
- * Returns the Number of Saves.
- *
- * @return the numberOfSaves
- */
- public int getNumberOfSaves() {
- return numberOfSaves;
- }
- /**
- * Set the Number of Saves.
- *
- * @param numberOfSaves the numberOfSaves to set
- */
- public void setNumberOfSaves(int numberOfSaves) {
- this.numberOfSaves = numberOfSaves;
- }
- /**
- * Returns all Objects in the Clipboard.
- *
- * @return Objects in the Clipboard
- */
- public ArrayList<AbstractCpsObject> getClipboradObjects() {
- return clipboardObjects;
- }
- /**
- * Sets the ClipboardObjects.
- *
- * @param c Array of Objects
- */
- public void setClipboradObjects(ArrayList<AbstractCpsObject> c) {
- this.clipboardObjects = c;
- }
- /**
- * Returns the Console.
- *
- * @return console the console
- */
- public Console getConsole() {
- return console;
- }
- /**
- * Sets the console.
- *
- * @param console the console
- */
- public void setConsole(Console console) {
- this.console = console;
- }
- /**
- * @return the maxCapacity
- */
- public float getMaxCapacity() {
- return maxCapacity;
- }
- /**
- * @param maxCapacity the maxCapacity to set
- */
- public void setMaxCapacity(float maxCapacity) {
- this.maxCapacity = maxCapacity;
- }
- /**
- * get the Interval in ms between each Iteration.
- *
- * @return timerSpeed speed for the Iterations
- */
- public int getTimerSpeed() {
- return this.timerSpeed;
- }
- /**
- * Sets the Interval in ms between each Iteration.
- *
- * @param t speed for the Iterations
- */
- public void setTimerSpeed(int t) {
- this.timerSpeed = t;
- }
- /**
- * Get Canvas X Size.
- *
- * @return the cANVAS_X
- */
- public int getCanvasX() {
- return canvasX;
- }
- /**
- * Set Canvas X Size.
- *
- * @param canvasX the cANVAS_X to set
- */
- public void setCanvasX(int canvasX) {
- this.canvasX = canvasX;
- }
- /**
- * get Canvas Y size.
- *
- * @return the cANVAS_Y
- */
- public int getCanvasY() {
- return canvasY;
- }
- /**
- * Set Canvas Y size.
- *
- * @param canvasY the cANVAS_Y to set
- */
- public void setCanvasY(int canvasY) {
- this.canvasY = canvasY;
- }
- /**
- * get the Algorithm.
- *
- * @return the Algorithm
- */
- public Object getAlgorithm() {
- return algorithm;
- }
- /**
- * Set the Algorithm.
- *
- * @param obj the Algorithm
- */
- public void setAlgorithm(Object obj) {
- this.algorithm = null;
- this.algorithm = obj;
- }
- /**
- * Add a SubNetColor.
- *
- * @param c the Color
- */
- public void addSubNetColor(Color c) {
- this.subNetColors.add(c);
- }
- /**
- * Get the SubNetColors.
- *
- * @return SubNetColors
- */
- public LinkedList<Color> getSubNetColors() {
- return this.subNetColors;
- }
- public ArrayList<AbstractCpsObject> getTrackingObj() {
- return trackedObjects;
- }
- public void setTrackingObj(ArrayList<AbstractCpsObject> toTrack) {
- trackedObjects = toTrack;
- }
- public void addGraphListener(GraphListener gl) {
- graphListeners.add(gl);
- }
- public HashMap<Integer, ArrayList<HolonElement>> getEleToDelete() {
- return this.eleToDelete;
- }
- public void setEleToDelete(HashMap<Integer, ArrayList<HolonElement>> theHash) {
- this.eleToDelete = theHash;
- }
- public PropertyTable getSingleTable() {
- return this.tableModelHolonElementSingle;
- }
- public void setSingleTable(PropertyTable pt) {
- this.tableModelHolonElementSingle = pt;
- }
- public PropertyTable getMultiTable() {
- return this.tableModelHolonElementMulti;
- }
- public void setMultiTable(PropertyTable pt) {
- this.tableModelHolonElementMulti = pt;
- }
- public void addObjectsToGraphListeners() {
- for (GraphListener gl : graphListeners) {
- gl.addTrackedObject(trackedObjects);
- gl.repaintTree();
- }
- }
- public DefaulTable getPropertyTable() {
- return this.tableModelProperties;
- }
- public void setPropertyTable(DefaulTable pt) {
- this.tableModelProperties = pt;
- }
- public JTable getTableHolonElement() {
- return tableHolonElement;
- }
- public void setTableHolonElement(JTable tableHolonElement) {
- this.tableHolonElement = tableHolonElement;
- }
- /**
- * Returns the sCale (Scale for the Images).
- *
- * @return sCALE
- */
- public int getHolonBodyScale() {
- return holonBodysCALE;
- }
- /**
- * Sets the HolonBody Scale.
- *
- * @param scale for the HolonBody
- */
- public void setHolonBodyScale(int scale) {
- holonBodysCALE = scale;
- }
- /**
- * Returns the ID of the selected HolonBody
- *
- * @return selectedHolonBody
- */
- public int getSelectedHolonBody() {
- return selectedHolonBody;
- }
- /**
- * Sets the ID of the selected HolonBody
- *
- * @param i int
- */
- public void setSelectedHolonBody(int i) {
- selectedHolonBody = i;
- }
- /**
- * get all Switches
- */
- public ArrayList<HolonSwitch> getSwitches() {
- ArrayList<HolonSwitch> switches = new ArrayList<>();
- for (AbstractCpsObject obj : getObjectsOnCanvas()) {
- if (obj instanceof HolonSwitch) {
- switches.add((HolonSwitch) obj);
- } else if (obj instanceof CpsUpperNode) {
- getSwitchesRec(((CpsUpperNode) obj).getNodes(), switches);
- }
- }
- return switches;
- }
- /**
- * get the Amount of Switches help function
- *
- * @param objects objects
- * @param switches List of switches
- */
- private ArrayList<HolonSwitch> getSwitchesRec(ArrayList<AbstractCpsObject> objects,
- ArrayList<HolonSwitch> switches) {
- for (AbstractCpsObject obj : objects) {
- if (obj instanceof HolonSwitch) {
- switches.add((HolonSwitch) obj);
- } else if (obj instanceof CpsUpperNode) {
- getSwitchesRec(((CpsUpperNode) obj).getNodes(), switches);
- }
- }
- return switches;
- }
- /**
- * Returns the Path for the background Image of the Canvas.
- *
- * @return imgPath the Path
- */
- public String getCanvasImagePath() {
- return imgPath;
- }
- /**
- * Set the Path for the background Image of the Canvas.
- *
- * @param path the Path
- */
- public void setCanvasImagePath(String path) {
- imgPath = path;
- }
- /**
- * Returns the mode for the background Image of the Canvas.
- * <p>
- * 0 take size of the Image 1 stretch the Image 2 Custom Image size
- *
- * @return backgroundMode the mode
- */
- public int getCanvasImageMode() {
- return backgroundMode;
- }
- /**
- * Set the mode for the background Image of the Canvas.
- * <p>
- * 0 take size of the Image, 1 stretch the Image, 2 Custom Image size
- *
- * @param mode the backgroundMode
- */
- public void setCanvasImageMode(int mode) {
- backgroundMode = mode;
- }
- /**
- * Returns the Custom width of the background Image of the Canvas.
- *
- * @return backgroundWidth the Width
- */
- public int getCanvasImageWidth() {
- return backgroundWidth;
- }
- /**
- * Set the Custom width of the background Image of the Canvas.
- *
- * @param width the Width
- */
- public void setCanvasImageWidth(int width) {
- backgroundWidth = width;
- }
- /**
- * Returns the Custom height of the background Image of the Canvas.
- *
- * @return backgroundHeight the height
- */
- public int getCanvasImageHeight() {
- return backgroundHeight;
- }
- /**
- * Set the Custom height of the background Image of the Canvas.
- *
- * @param height the height
- */
- public void setCanvasImageHeight(int height) {
- backgroundHeight = height;
- }
- /**
- * Returns the graphtable for Statistic Graphs.
- */
- public Hashtable<String, StatisticGraphPanel> getGraphTable() {
- return statisticGraphTable;
- }
- /**
- * Set the graphtable for Statistic Graphs
- */
- public void setGraphTable(Hashtable<String, StatisticGraphPanel> gT) {
- statisticGraphTable = gT;
- }
- /**
- * Returns if the Simulation is running.
- */
- public boolean getIsSimRunning() {
- return isSimRunning;
- }
- /**
- * Sets isSimRunning.
- *
- * @param isRunning
- */
- public void setIsSimRunning(boolean isRunning) {
- isSimRunning = isRunning;
- }
- /**
- * @return the statisticData
- */
- public ArrayList<JsonObject> getStatisticData() {
- return statisticData;
- }
- /**
- * @param statisticData the statisticData to set
- */
- public void setStatisticData(ArrayList<JsonObject> statisticData) {
- this.statisticData = statisticData;
- }
- /**
- * Returns showConsoleLog.
- */
- public boolean getShowConsoleLog() {
- return this.showConsoleLog;
- }
- /**
- * Sets showConsoleLog.
- *
- * @param showConsoleLog
- */
- public void setShowConsoleLog(boolean showConsoleLog) {
- this.showConsoleLog = showConsoleLog;
- }
- public boolean useFlexibleDevices() {
- return this.useFlexibleDevices;
- }
- public void setUseFlexibleDevices(boolean useFlexibleDevices) {
- this.useFlexibleDevices = useFlexibleDevices;
- }
- /**
- * @return true if SupplyBars should be shown
- */
- public boolean getShowSupplyBars() {
- return showSupplyBars;
- }
- /**
- * @param showSupplyBars true if the SupplyBars should be shown
- */
- public void setShowSupplyBars(boolean showSupplyBars) {
- this.showSupplyBars = showSupplyBars;
- }
-
- /**
- * @param iterations the number of steps for this simulation
- */
- public void setIterations(int iterations){
- this.iterations=iterations;
- }
-
- /**
- * @return the fairnessModel
- */
- public short getFairnessModel() {
- return fairnessModel;
- }
-
- /**
- * @param fairnessModel the fairnessModel to set
- */
- public void setFairnessModel(short fairnessModel) {
- this.fairnessModel = fairnessModel;
- }
-
- public int getGraphIterations(){
- return GRAPH_ITERATIONS;
- }
- /**
- * Initialize the Gson with wanted parameters
- */
- private void initGson() {
- GsonBuilder builder = new GsonBuilder();
- builder.serializeNulls();
- builder.excludeFieldsWithoutExposeAnnotation();
- builder.setPrettyPrinting();
- builder.registerTypeAdapter(AbstractCpsObject.class, new AbstractCpsObjectAdapter());
- builder.registerTypeAdapter(Position.class, new PositionAdapter());
- builder.registerTypeAdapter(Color.class, new ColorAdapter());
- builder.registerTypeAdapter(Pair.class, new PairAdapter());
- // use the builder and make a instance of the Gson
- this.setGson(builder.create());
- }
- /**
- * @return the gson
- */
- public Gson getGson() {
- return gson;
- }
- /**
- * @param gson the gson to set
- */
- public void setGson(Gson gson) {
- this.gson = gson;
- }
- public StatisticPanel getStatPanel() {
- return statPanel;
- }
- public void setStatPanel(StatisticPanel sP) {
- statPanel = sP;
- }
- /**
- * @return the hashcodeMap
- */
- public HashMap<Integer, CpsUpperNode> getHashcodeMap() {
- return hashcodeMap;
- }
- /**
- * @param hashcodeMap the hashcodeMap to set
- */
- public void setHashcodeMap(HashMap<Integer, CpsUpperNode> hashcodeMap) {
- this.hashcodeMap = hashcodeMap;
- }
- }
|