123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993 |
- package ui.model;
- import java.awt.Color;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Hashtable;
- import java.util.LinkedList;
- import java.util.List;
- import javax.swing.JTable;
- import com.google.gson.Gson;
- import com.google.gson.GsonBuilder;
- import com.google.gson.JsonObject;
- import com.google.gson.JsonParser;
- import TypeAdapter.AbstractCpsObjectAdapter;
- import TypeAdapter.ColorAdapter;
- import TypeAdapter.PositionAdapter;
- import classes.AbstractCpsObject;
- import classes.Category;
- import classes.CpsEdge;
- import classes.CpsUpperNode;
- import classes.HolonElement;
- import classes.HolonSwitch;
- import classes.Position;
- import interfaces.CategoryListener;
- import interfaces.GraphListener;
- import interfaces.ObjectListener;
- import ui.view.Console;
- import ui.view.DefaulTable;
- import ui.view.PropertyTable;
- import ui.view.StatisticGraphPanel;
- import ui.view.StatisticPanel;
- /**
- * 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 {
- // 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;
- // Global Variables
- private static int sCALE = 50; // Picture Scale
- private static int sCALEdIV2 = sCALE / 2;
- private static int holonBodysCALE = 100; // Picture Scale
- private static final int ITERATIONS = 100;
- 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<AbstractCpsObject>();
- private ArrayList<AbstractCpsObject> clipboardObjects = new ArrayList<AbstractCpsObject>();
- 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<GraphListener>();
- // 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;
- // if the simulation is running and has not been reseted
- private boolean isSimRunning = false;
- // if the console log of the program should be displayed
- private boolean showConsoleLog = true;
- /*
- * 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;
- public String[] colNames = { "Field", "Information" };
- /*
- * Object that runs the Algorithm
- */
- private Object algorithm = null;
- private int selectedHolonBody;
- // Statistic Graph Data
- private Hashtable<String, StatisticGraphPanel> statisticGraphTable = new Hashtable<String, StatisticGraphPanel>();
- 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<Category>());
- setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
- setEdgesOnCanvas(new ArrayList<CpsEdge>());
- setCategoryListeners(new LinkedList<CategoryListener>());
- setObjectListeners(new LinkedList<ObjectListener>());
- setCgIdx(new HashMap<String, Integer>());
- setCvsObjIdx(new HashMap<Integer, Integer>());
- setClipboradObjects(new ArrayList<AbstractCpsObject>());
- setTrackingObj(new ArrayList<AbstractCpsObject>());
- setEleToDelete(new HashMap<Integer, ArrayList<HolonElement>>());
- 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 == "") {
- 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;
- }
- /**
- * 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);
- }
- /**
- * Sets the edges on the Canvas.
- *
- * @param arrayList
- * the edgesOnCanvas to set
- */
- public void setEdgesOnCanvas(ArrayList<CpsEdge> arrayList) {
- this.edgesOnCanvas = arrayList;
- }
- /**
- * 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;
- }
- /**
- * 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 ID of the selected Object 0 = no Object is selected.
- *
- * @return ID
- */
- public int getSelectedObjectID() {
- return selectedID;
- }
- /**
- * 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;
- }
- /**
- * Returns sCALEdIV2 (The Scale divided by 2).
- *
- * @return sCALEdIV2
- */
- public int getScaleDiv2() {
- return sCALEdIV2;
- }
- /**
- * Sets the Image Scale.
- *
- * @param scale
- * for the image
- */
- public void setScale(int scale) {
- sCALE = scale;
- sCALEdIV2 = sCALE / 2;
- }
- /**
- * Returns ITERATIONS.
- *
- * @return ITERATIONS
- */
- public int getIterations() {
- return ITERATIONS;
- }
- /**
- * sets the current Iteration.
- *
- * @param curIT
- * the current Iteration
- */
- public void setCurIteration(int curIT) {
- this.curIteration = curIT;
- notifyGraphListeners();
- }
- private void notifyGraphListeners() {
- for (GraphListener gl : graphListeners) {
- gl.repaintTree();
- }
- }
- /**
- * Returns cURiTERATION.
- *
- * @return cURiTERATION
- */
- public int getCurIteration() {
- return curIteration;
- }
- /**
- * Set the selected Edge.
- *
- * @param edge
- * that is selected
- *
- */
- public void setSelectedEdge(CpsEdge edge) {
- this.selectedEdge = edge;
- }
- /**
- * Returns the selected Edge.
- *
- * @return selectedEdge
- */
- public CpsEdge getSelectedEdge() {
- return selectedEdge;
- }
- /**
- * 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;
- }
- /**
- * Sets the auto save Number.
- *
- * @param autoSaveNr
- * the auto save number
- */
- public void setAutoSaveNr(int autoSaveNr) {
- this.autoSaveNr = autoSaveNr;
- }
- /**
- * Returns the auto save Number.
- *
- * @return the auto save Number
- */
- public int getAutoSaveNr() {
- return 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;
- }
- /**
- * Sets the ClipboardObjects.
- *
- * @param c
- * Array of Objects
- */
- public void setClipboradObjects(ArrayList<AbstractCpsObject> c) {
- this.clipboardObjects = c;
- }
- /**
- * Returns all Objects in the Clipboard.
- *
- * @return Objects in the Clipboard
- */
- public ArrayList<AbstractCpsObject> getClipboradObjects() {
- return clipboardObjects;
- }
- /**
- * Sets the console.
- *
- * @param console
- * the console
- */
- public void setConsole(Console console) {
- this.console = console;
- }
- /**
- * Returns the Console.
- *
- * @return console the console
- */
- public Console getConsole() {
- return console;
- }
- /**
- * @return the maxCapacity
- */
- public float getMaxCapacity() {
- return maxCapacity;
- }
- /**
- * @param maxCapacity
- * the maxCapacity to set
- */
- public void setMaxCapacity(float maxCapacity) {
- this.maxCapacity = maxCapacity;
- }
- /**
- * Sets the Interval in ms between each Iteration.
- *
- * @param t
- * speed for the Iterations
- */
- public void setTimerSpeed(int t) {
- this.timerSpeed = t;
- }
- /**
- * get the Interval in ms between each Iteration.
- *
- * @return timerSpeed speed for the Iterations
- */
- public int getTimerSpeed() {
- return this.timerSpeed;
- }
- /**
- * 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 void setTrackingObj(ArrayList<AbstractCpsObject> toTrack) {
- trackedObjects = toTrack;
- }
- public ArrayList<AbstractCpsObject> getTrackingObj() {
- return trackedObjects;
- }
- public void addGraphListener(GraphListener gl) {
- graphListeners.add(gl);
- }
- public void setEleToDelete(HashMap<Integer, ArrayList<HolonElement>> theHash) {
- this.eleToDelete = theHash;
- }
- public HashMap<Integer, ArrayList<HolonElement>> getEleToDelete() {
- return this.eleToDelete;
- }
- public void setSingleTable(PropertyTable pt) {
- this.tableModelHolonElementSingle = pt;
- }
- public PropertyTable getSingleTable() {
- return this.tableModelHolonElementSingle;
- }
- 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;
- }
- /**
- * Sets the HolonBody Scale.
- *
- * @param scale
- * for the HolonBody
- */
- public void setHolonBodyScale(int scale) {
- holonBodysCALE = scale;
- }
- /**
- * Returns the sCale (Scale for the Images).
- *
- * @return sCALE
- */
- public int getHolonBodyScale() {
- return holonBodysCALE;
- }
- /**
- * Sets the ID of the selected HolonBody
- *
- * @param i
- * int
- */
- public void setSelectedHolonBody(int i) {
- selectedHolonBody = i;
- }
- /**
- * Returns the ID of the selected HolonBody
- *
- * @return selectedHolonBody
- */
- public int getSelectedHolonBody() {
- return selectedHolonBody;
- }
- /**
- * 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;
- }
- /**
- * Returns the mode for the background Image of the Canvas.
- *
- * 0 take size of the Image 1 stretch the Image 2 Custom Image size
- *
- * @return backgroundMode the mode
- */
- public int getCanvasImageMode() {
- return backgroundMode;
- }
- /**
- * Returns the Custom width of the background Image of the Canvas.
- *
- * @return backgroundWidth the Width
- */
- public int getCanvasImageWidth() {
- return backgroundWidth;
- }
- /**
- * Returns the Custom height of the background Image of the Canvas.
- *
- * @return backgroundHeight the height
- */
- public int getCanvasImageHeight() {
- return backgroundHeight;
- }
- /**
- * Set the Path for the background Image of the Canvas.
- *
- * @param paththe
- * Path
- */
- public void setCanvasImagePath(String path) {
- imgPath = path;
- }
- /**
- * Set the mode for the background Image of the Canvas.
- *
- * 0 take size of the Image, 1 stretch the Image, 2 Custom Image size
- *
- * @param backgroundMode
- * the mode
- */
- public void setCanvasImageMode(int mode) {
- backgroundMode = mode;
- }
- /**
- * Set the Custom width of the background Image of the Canvas.
- *
- * @param width
- * the Width
- */
- public void setCanvasImageWidth(int width) {
- backgroundWidth = width;
- }
- /**
- * Set the Custom height of the background Image of the Canvas.
- *
- * @param height
- * the height
- */
- public void setCanvasImageHeight(int height) {
- backgroundHeight = height;
- }
- /**
- * Set the graphtable for Statistic Graphs
- */
- public void setGraphTable(Hashtable<String, StatisticGraphPanel> gT) {
- statisticGraphTable = gT;
- }
- /**
- * Returns the graphtable for Statistic Graphs.
- */
- public Hashtable<String, StatisticGraphPanel> getGraphTable() {
- return statisticGraphTable;
- }
- /**
- * 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;
- }
-
- /**
- * Initialize the Gson with wanted parameters
- */
- private void initGson() {
- // TODO Auto-generated method stub
- 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());
- // 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 void setStatPanel(StatisticPanel sP){
- statPanel = sP;
- }
-
- public StatisticPanel getStatPanel(){
- return statPanel;
- }
- }
|