package classes; import java.awt.Point; import java.util.LinkedList; import ui.model.idCounterElem; public class HolonElement { /* Name of the gadget */ String eleName; /* Quantity */ int amount; /* Energy per gadget */ float energy; /* If the gadget is working xor not (true xor false) */ boolean active; /* Total Energy */ float totalEnergy; /* Path of the image for the Obj. */ String image; /* +: for Consumers and -: Producers */ char sign; /* Place where the Object is Stored */ String sav; /* Object where the Element is Stored */ String obj; int id; /* * Energy at each point of the graph with 100 predefined points. At the * beginning, it starts with all values at energy */ float[] energyAt = new float[100]; // Points on the UnitGraph LinkedList graphPoints = new LinkedList<>(); public HolonElement(String eleName, int amount, float energy) { setEleName(eleName); setAmount(amount); setEnergy(energy); setActive(true); setSign(energy); setEnergyAt(energy); setId(idCounterElem.nextId()); } public HolonElement(HolonElement element) { setEleName(element.getEleName()); setAmount(element.getAmount()); setEnergy(element.getEnergy()); setActive(element.getActive()); setSign(element.getEnergy()); setEnergyAt(element.getEnergy()); setSav("CVS"); setObj(element.getObj()); setId(idCounterElem.nextId()); } /** * get the EnergyAt Array */ public float[] getEnergyAt() { return energyAt; } /** * @param energy, * the value */ public void setEnergyAt(float energy) { for (int i = 0; i < energyAt.length; i++) { this.energyAt[i] = energy; } } public void setEnergyAt(int pos, float energy) { this.energyAt[pos] = energy; } /** * @return the name */ public String getEleName() { return eleName; } /** * @param name * the name to set */ public void setEleName(String name) { this.eleName = name; } /** * @return the amount */ public int getAmount() { return amount; } /** * @param amount * the amount to set */ public void setAmount(int amount) { this.amount = amount; } /** * @return the energy */ public float getEnergy() { return energy; } /** * @param energy * the energy to set */ public void setEnergy(float energy) { this.energy = energy; } /** * @return the active */ public boolean getActive() { return active; } /** * @param active * the active to set */ public void setActive(boolean active) { this.active = active; } /** * @return the image */ public String getImage() { return image; } /** * @param image * the image to set */ public void setImage(String image) { this.image = image; } /** * Multiply the amount of gadgets, given by the user, and the * consumption/production. If the switch isWorking is turned off for on * gadget, the energy of this gadget have to be subtracted * * @return totalEnergy (actual) */ public float getTotalEnergy() { totalEnergy = ((float) amount) * energy; return totalEnergy; } public float getTotalEnergyAtTimeStep(int x) { float result = ((float) amount) * energyAt[x]; return result; } /** * @return the sign */ public char getSign() { return sign; } /** * @param energy * the sign to set */ public void setSign(float energy) { if (energy < 0) this.sign = '-'; else this.sign = '+'; } /** * @return the stored */ public String getSav() { return sav; } /** * @param stored * the stored to set */ public void setSav(String sav) { this.sav = sav; } /** * @return the obj */ public String getObj() { return obj; } /** * @param obj * the obj to set */ public void setObj(String obj) { this.obj = obj; } /** * @return the Graph Points */ public LinkedList getGraphPoints() { return graphPoints; } /** * @param points, * the Graph points */ public void setGraphPoints(LinkedList points) { this.graphPoints = points; } private void setId(int id) { this.id = id; } public int getId() { return id; } }