123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- package classes;
- import java.awt.Point;
- import java.util.LinkedList;
- 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;
-
- String sav;
-
- String obj;
- /*
- * Energy at each point of the graph with 50 predefined points. At the
- * beginning, it starts with all values at energy
- */
- float[] energyAt = new float[100];
- //Points on the UnitGraph
- LinkedList<Point> graphPoints = new LinkedList<>();
- public HolonElement(String eleName, float energy, int amount) {
- setEleName(eleName);
- setAmount(amount);
- setEnergy(energy);
- setActive(true);
- setSign(energy);
- setEnergyAt(energy);
- }
- public HolonElement(HolonElement element) {
- setEleName(element.getEleName());
- setAmount(element.getAmount());
- setEnergy(element.getEnergy());
- setActive(element.getActive());
- setSign(element.getEnergy());
- setEnergyAt(element.getEnergy());
- setSav("Canvas");
- setObj(element.getObj());
- }
- public float[] getEnergyAt() {
- return energyAt;
- }
- public void setEnergyAt(float energy) {
- for (int i = 0; i < 49; 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;
- }
- /**
- * @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<Point> getGraphPoints() {
- return graphPoints;
- }
- /**
- * @param points, the Graph points
- */
- public void setGraphPoints(LinkedList<Point> points) {
- this.graphPoints = points;
- }
- }
|