Pārlūkot izejas kodu

Adds GroupNode aggregation

TomTroppmann 3 gadi atpakaļ
vecāks
revīzija
d7b38fd473

+ 0 - 0
jars/xchart-3.8.0/CONTRIBUTORS → jars/xchart-3.8.1/CONTRIBUTORS


+ 0 - 0
jars/xchart-3.8.0/LICENSE → jars/xchart-3.8.1/LICENSE


+ 0 - 0
jars/xchart-3.8.0/NOTICE → jars/xchart-3.8.1/NOTICE


+ 0 - 0
jars/xchart-3.8.0/README.md → jars/xchart-3.8.1/README.md


BIN
jars/xchart-3.8.0/xchart-3.8.1.jar → jars/xchart-3.8.1/xchart-3.8.1-custom.jar


+ 0 - 1
src/TypeAdapter/AbstractCpsObjectAdapter.java

@@ -39,7 +39,6 @@ public class AbstractCpsObjectAdapter
 		} catch (ClassNotFoundException cnfe) {
 			throw new JsonParseException("Unknown element type: " + type, cnfe);
 		}
-
 	}
 
 }

+ 1 - 1
src/classes/HolonElement.java

@@ -51,7 +51,7 @@ public class HolonElement implements LocalMode, GraphEditable{
     
     
     @Expose
-    private Priority priority;
+    private Priority priority = Priority.Low;
 
 	public static enum Priority {
     	Essential, High, Medium , Low

+ 16 - 10
src/preferences/ColorPreference.java

@@ -3,17 +3,23 @@ package preferences;
 import java.awt.Color;
 
 /**
- * A Class to save all colors in Holeg;
+ * A Class to save all colors in Holeg.
  * @author Tom
  *
  */
 public class ColorPreference {
 	
-	public static class Priority{
-		public static final Color Essential = new Color(181, 24, 54);
-		public static final Color High = new Color(248, 72, 6);
-		public static final Color Medium = new Color(250, 196, 37);
-		public static final Color Low = new Color(255, 255, 175);
+	
+	public static class Element{
+		public static class Priority{
+			public static final Color Essential = new Color(201, 44, 74);
+			public static final Color High = new Color(255, 92, 26);
+			public static final Color Medium = new Color(255, 216, 57);
+			public static final Color Low = new Color(255, 255, 175);
+			public static final Color NoData = new Color(21, 8, 17);
+		}
+		public static final Color Active = new Color(255, 203, 35);
+		public static final Color Inactive = new Color(128, 154, 163);
 	}
 	public static class HolonObject{
 		public static final Color Producer = Color.lightGray;
@@ -24,13 +30,13 @@ public class ColorPreference {
 		public static final Color NoEnergy = Color.white;
 	}
 	public static class Energy{
-		public static final Color Production = new Color(21, 93, 203);
-		public static final Color Consumption = new Color(239, 27, 20);
+		public static final Color Production = new Color(61, 133, 243);
+		public static final Color Consumption = new Color(255, 67, 60);
 	}
 	public static class Flexibility{
-		public static final Color InUse = new Color(96, 180, 85);
+		public static final Color InUse = new Color(182, 238, 166);
 		public static final Color OnCooldown = new Color(239, 215, 128);
-		public static final Color Offered = new Color(55, 150, 52);
+		public static final Color Offered = new Color(75, 170, 72);
 		public static final Color NotOffered = new Color(237, 106, 90);
 		public static final Color Unavailable = new Color(193, 193, 193);
 	}

+ 2 - 0
src/ui/controller/LoadController.java

@@ -1,6 +1,7 @@
 package ui.controller;
 
 import classes.*;
+import classes.HolonElement.Priority;
 
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -500,6 +501,7 @@ public class LoadController {
     void initElements(HolonElement ele) {
         ele.flexList = new ArrayList<Flexibility>();
         ele.setGraphPoints(new LinkedList<>());
+        if(ele.getPriority() == null) ele.setPriority(Priority.Low);
         ele.reset();
     }
 

+ 120 - 44
src/ui/model/DecoratedGroupNode.java

@@ -1,12 +1,18 @@
 package ui.model;
 
 import java.util.ArrayList;
+import java.util.stream.Stream;
 
 import classes.Node;
+import jdk.jfr.Unsigned;
 import classes.GroupNode;
+import classes.HolonElement;
+import classes.Flexibility;
 import ui.model.DecoratedHolonObject.HolonObjectState;
+
 /**
  * For the @VisualRepresentationalState only.
+ * 
  * @author Tom
  *
  */
@@ -17,19 +23,18 @@ public class DecoratedGroupNode {
 	private ArrayList<Consumer> consumerList;
 	private ArrayList<Node> nodeList;
 	/**
-	 * Cables that only exist on that group node. From a object in that group node to a object in that group Node.
-	 * Not exit the group node (a layer down).
+	 * Cables that only exist on that group node. From a object in that group node
+	 * to a object in that group Node. Not exit the group node (a layer down).
 	 */
 	private ArrayList<DecoratedCable> internCableList;
 	/**
-	 * Cables that exit this group node (a Layer Up). From a object in this group node to a object in a upper layer.
+	 * Cables that exit this group node (a Layer Up). From a object in this group
+	 * node to a object in a upper layer.
 	 */
-	private ArrayList<ExitCable> exitCableList;	
+	private ArrayList<ExitCable> exitCableList;
 	private ArrayList<DecoratedSwitch> switchList;
 	private ArrayList<DecoratedGroupNode> groupNodeList;
 
-
-
 	public DecoratedGroupNode(GroupNode model) {
 		this.model = model;
 		this.supplierList = new ArrayList<Supplier>();
@@ -41,93 +46,164 @@ public class DecoratedGroupNode {
 		this.switchList = new ArrayList<DecoratedSwitch>();
 		this.groupNodeList = new ArrayList<DecoratedGroupNode>();
 	}
+
 	public GroupNode getModel() {
 		return model;
 	}
+
 	public ArrayList<Supplier> getSupplierList() {
 		return supplierList;
 	}
+
 	public ArrayList<Passiv> getPassivList() {
 		return passivList;
 	}
+
 	public ArrayList<Consumer> getConsumerList() {
 		return consumerList;
 	}
+
 	public ArrayList<Node> getNodeList() {
 		return nodeList;
 	}
+
 	public ArrayList<DecoratedCable> getInternCableList() {
 		return internCableList;
 	}
+
 	public ArrayList<ExitCable> getExitCableList() {
 		return exitCableList;
 	}
+
 	public ArrayList<DecoratedSwitch> getSwitchList() {
 		return switchList;
 	}
+
 	public ArrayList<DecoratedGroupNode> getGroupNodeList() {
 		return groupNodeList;
 	}
-	
-	
-	//Returns the amount of holons and count himself 
+
+	// Returns the amount of holons and count himself
 	public int getAmountOfGroupNodes() {
 		return 1 + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfGroupNodes()).reduce(0, Integer::sum);
 	}
-	
-	
-	//Gather Informations:
+
+	public Stream<Flexibility> getFlexibilitiesStream() {
+
+		Stream<Flexibility> flexInChildGorupNode = this.groupNodeList.stream()
+				.flatMap(groupNode -> groupNode.getFlexibilitiesStream());
+
+		Stream<Flexibility> flexInThisGorupNode = objectStream()
+				.flatMap(object -> object.getModel().getElements().stream().flatMap(ele -> ele.flexList.stream()));
+
+		return Stream.concat(flexInChildGorupNode, flexInThisGorupNode);
+	}
+
+	public Stream<DecoratedHolonObject> objectStream() {
+		return Stream.concat(Stream.concat(this.consumerList.stream(), this.supplierList.stream()),
+				this.passivList.stream());
+	}
+
+	// Gather Informations:
 	public int getAmountOfSupplier() {
-		return supplierList.size() + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfSupplier()).reduce(0, Integer::sum);
+		return supplierList.size()
+				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfSupplier()).reduce(0, Integer::sum);
 	}
+
 	public int getAmountOfConsumer() {
-		return consumerList.size() + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfConsumer()).reduce(0,Integer::sum);
+		return consumerList.size()
+				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfConsumer()).reduce(0, Integer::sum);
 	}
+
 	public int getAmountOfPassiv() {
-		return passivList.size() + groupNodeList.stream().map(groupNode -> groupNode.getAmountOfPassiv()).reduce(0, Integer::sum);
+		return passivList.size()
+				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfPassiv()).reduce(0, Integer::sum);
 	}
-	
+
 	public int getAmountOfConsumerWithState(HolonObjectState state) {
-		return ((int) consumerList.stream().map(con -> con.getState()).filter(rightState -> (rightState == state)).count()) +  groupNodeList.stream().map(groupNode -> groupNode.getAmountOfConsumerWithState(state)).reduce(0, Integer::sum);
+		return ((int) consumerList.stream().map(con -> con.getState()).filter(rightState -> (rightState == state))
+				.count())
+				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfConsumerWithState(state)).reduce(0,
+						Integer::sum);
 	}
-	
+
 	public int getAmountOfElemntsFromHolonObjects() {
-		return passivList.stream().map(object -> object.getModel().getElements().size()).reduce(0, Integer::sum)+
-				supplierList.stream().map(object -> object.getModel().getElements().size()).reduce(0, Integer::sum)+
-				consumerList.stream().map(object -> object.getModel().getElements().size()).reduce(0, Integer::sum)+
-				groupNodeList.stream().map(groupNode -> groupNode.getAmountOfElemntsFromHolonObjects()).reduce(0, Integer::sum);
+		return objectStream().map(object -> object.getModel().getElements().size()).reduce(0, Integer::sum)
+				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfElemntsFromHolonObjects()).reduce(0,
+						Integer::sum);
+	}
+
+	public PriorityCounts getPriorityCounts() {
+		PriorityCounts priority = new PriorityCounts();
+		objectStream().forEach(object -> object.getModel().getElements().stream().forEach(ele -> priority.Count(ele)));
+		groupNodeList.stream().forEach(groupNode -> priority.Add(groupNode.getPriorityCounts()));
+		return priority;
+	}
+
+	public class PriorityCounts {
+		@Unsigned
+		public int low, medium, high, essential;
+
+		public void Add(PriorityCounts other) {
+			low += other.low;
+			medium += other.medium;
+			high += other.high;
+			essential += other.essential;
+		}
+
+		public void Count(HolonElement element) {
+			switch (element.getPriority()) {
+			case Essential:
+				essential++;
+				break;
+			case High:
+				high++;
+				break;
+			case Medium:
+				medium++;
+				break;
+			case Low:
+				low++;
+				break;
+			default:
+				break;
+
+			}
+		}
 	}
 
 	public int getAmountOfAktiveElemntsFromHolonObjects() {
-		return passivList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
-				supplierList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
-				consumerList.stream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0, Integer::sum)+
-				groupNodeList.stream().map(groupNode -> groupNode.getAmountOfAktiveElemntsFromHolonObjects()).reduce(0, Integer::sum);
+		return objectStream().map(object -> object.getModel().getNumberOfActiveElements()).reduce(0,
+						Integer::sum)
+				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfAktiveElemntsFromHolonObjects())
+						.reduce(0, Integer::sum);
 	}
-	public float getConsumptionFromConsumer() {		
-		return consumerList.stream().map(con -> con.getEnergyNeededFromNetwork()).reduce(0.f, Float::sum)+
-				groupNodeList.stream().map(groupNode -> groupNode.getConsumptionFromConsumer()).reduce(0.f, Float::sum);
+
+	public float getConsumptionFromConsumer() {
+		return consumerList.stream().map(con -> con.getEnergyNeededFromNetwork()).reduce(0.f, Float::sum)
+				+ groupNodeList.stream().map(groupNode -> groupNode.getConsumptionFromConsumer()).reduce(0.f,
+						Float::sum);
 	}
-	public float getProductionFromSupplier() {		
-		return supplierList.stream().map(sup -> sup.getEnergyToSupplyNetwork()).reduce(0.f, Float::sum)+
-				groupNodeList.stream().map(groupNode -> groupNode.getProductionFromSupplier()).reduce(0.f, Float::sum);
+
+	public float getProductionFromSupplier() {
+		return supplierList.stream().map(sup -> sup.getEnergyToSupplyNetwork()).reduce(0.f, Float::sum) + groupNodeList
+				.stream().map(groupNode -> groupNode.getProductionFromSupplier()).reduce(0.f, Float::sum);
 	}
-	
+
 	public float getAverageConsumption() {
-		return getConsumptionFromConsumer() / (float)getAmountOfGroupNodes();
+		return getConsumptionFromConsumer() / (float) getAmountOfGroupNodes();
 	}
+
 	public float getAverageProduction() {
-		return getProductionFromSupplier() / (float)getAmountOfGroupNodes();
+		return getProductionFromSupplier() / (float) getAmountOfGroupNodes();
 	}
-	
-	
+
 	public String toString() {
-		return 
-				"GroupNode" + model.getId() + " with [Supplier:" + getAmountOfSupplier() 
-				+ ", NotSupplied:" + getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED) 
-				+ ", PartiallySupplied:" + getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED) 
-				+ ", Supplied:" + getAmountOfConsumerWithState(HolonObjectState.SUPPLIED) 
-				+ ", OverSupplied:" + getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED) 
-				+ ", Passiv:"+ getAmountOfPassiv() + "]";
+		return "GroupNode" + model.getId() + " with [Supplier:" + getAmountOfSupplier() + ", NotSupplied:"
+				+ getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED) + ", PartiallySupplied:"
+				+ getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED) + ", Supplied:"
+				+ getAmountOfConsumerWithState(HolonObjectState.SUPPLIED) + ", OverSupplied:"
+				+ getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED) + ", Passiv:" + getAmountOfPassiv()
+				+ "]";
 	}
 }

+ 186 - 70
src/ui/view/HolonInformationPanel.java

@@ -2,20 +2,28 @@ package ui.view;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
 import java.awt.GridLayout;
+import java.awt.Insets;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
+import javax.swing.OverlayLayout;
 import javax.swing.SwingUtilities;
 import javax.swing.border.EmptyBorder;
 
@@ -30,35 +38,44 @@ import org.knowm.xchart.style.PieStyler;
 import org.knowm.xchart.style.PieStyler.LabelType;
 
 import classes.AbstractCanvasObject;
+import classes.Flexibility;
 import classes.GroupNode;
+import classes.HolonElement;
 import classes.HolonObject;
 import preferences.ColorPreference;
 import ui.controller.Control;
+import ui.controller.FlexManager;
+import ui.controller.FlexManager.FlexWrapper;
 import ui.model.DecoratedGroupNode;
+import ui.model.DecoratedGroupNode.PriorityCounts;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.Model;
+import util.StringFormat;
 
 public class HolonInformationPanel extends JPanel {
 
 	private final int defaultWidth = 50;
-	private final int defaultHeight = 150;
+	private final int defaultHeight = 200;
 
 	private PieChart supplyChart = createSupplyStateChart();
 	private PieChart priorityChart = createPriorityChart();
 	private PieChart flexibilityChart = createFlexibilityChart();
-	private CategoryChart energyChart = createProductionChart();
+	private PieChart energyChart = createProductionChart();
+	private PieChart activeChart = createActiveChart();
 
 	private XChartPanel<PieChart> panelHolonObject;
 	private XChartPanel<PieChart> panelPriority;
 	private XChartPanel<PieChart> panelFlexibility;
-	private XChartPanel<CategoryChart> panelEnergy;
-	
-	
-	
+	private XChartPanel<PieChart> panelEnergy;
+	private XChartPanel<PieChart> panelActive;
+
+	// TODO is this needed to be fields
 	private JPanel graphPanel = new JPanel(new GridLayout(0, 2));
 	private JPanel titlePanel = new JPanel(new BorderLayout(0, 0));
 
 	private Control control;
+	private JTextField titleTextField;
+	private JLabel differenceEnergyLabelAmount;
 
 	public static void main(String[] args) {
 		HolonInformationPanel exampleChart = new HolonInformationPanel(new Control(new Model()));
@@ -76,21 +93,24 @@ public class HolonInformationPanel extends JPanel {
 		List<GroupNode> list = control.getModel().getSelectedCpsObjects().stream()
 				.filter(object -> object instanceof GroupNode).map(object -> (GroupNode) object)
 				.collect(Collectors.toList());
-		System.out.println("UPDATE CHART" + list.size());
-		if(list.size() != 1) {
+		if (list.size() != 1) {
 			return;
 		}
 		GroupNode groupNode = list.get(0);
-		DecoratedGroupNode decoratedGroupNode = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().get(groupNode);
-		
-		//UPDATE SUPPLY STATE
+		DecoratedGroupNode decoratedGroupNode = control.getSimManager().getActualVisualRepresentationalState()
+				.getCreatedGroupNodes().get(groupNode);
+		// UPDATE NAME
+		titleTextField.setText(groupNode.getName());
+
+		// UPDATE SUPPLY STATE
 		int producerAmount = decoratedGroupNode.getAmountOfSupplier();
 		int overSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED);
 		int suppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.SUPPLIED);
-		int partiallySuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED);
+		int partiallySuppliedAmount = decoratedGroupNode
+				.getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED);
 		int notSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED);
 		int noEnergyAmount = decoratedGroupNode.getAmountOfPassiv();
-		
+
 		supplyChart.updatePieSeries("Producer", producerAmount);
 		supplyChart.updatePieSeries("Over supplied", overSuppliedAmount);
 		supplyChart.updatePieSeries("Supplied", suppliedAmount);
@@ -98,10 +118,74 @@ public class HolonInformationPanel extends JPanel {
 		supplyChart.updatePieSeries("Not supplied", notSuppliedAmount);
 		supplyChart.updatePieSeries("No energy", noEnergyAmount);
 		panelHolonObject.updateToolTips();
+
+		// UPDATE PRIORITYS
+		PriorityCounts priorityCounts = decoratedGroupNode.getPriorityCounts();
 		
-		//UPDATE PRIORITYS
-		//decoratedGroupNode.
+		priorityChart.updatePieSeries("Essential", priorityCounts.essential);
+		priorityChart.updatePieSeries("High", priorityCounts.high);
+		priorityChart.updatePieSeries("Medium", priorityCounts.medium);
+		priorityChart.updatePieSeries("Low", priorityCounts.low);
+		boolean hasPriority = priorityCounts.essential + priorityCounts.high + priorityCounts.medium + priorityCounts.low > 0;
+		priorityChart.updatePieSeries("No Data", hasPriority?0:1);
+		panelPriority.updateToolTips();
+
+		// UPDATE PRODUCTION
+		float production = decoratedGroupNode.getProductionFromSupplier();
+		float consumption = decoratedGroupNode.getConsumptionFromConsumer();
+		float difference = Math.abs(production - consumption);
+		energyChart.updatePieSeries("Production", production);
+		energyChart.updatePieSeries("Consumption", consumption);
+		differenceEnergyLabelAmount.setText(StringFormat.doubleFixedPlaces(1, difference));
+		panelEnergy.updateToolTips();
 		
+		// UPDATE FLEXIBILITIES
+		int inUse = 0;
+		int offered = 0;
+		int onCooldown = 0;
+		int notOffered = 0;
+		int unavailable = 0;
+		FlexManager manager = control.getSimManager().getActualFlexManager();
+		Stream<FlexWrapper> flexWrapperStream = decoratedGroupNode.getFlexibilitiesStream().map(flex -> manager.getFlexWrapperFromFlexibility(flex));
+		List<FlexWrapper> wrapperList = flexWrapperStream.collect(Collectors.toList());
+		for(FlexWrapper wrapper : wrapperList) {
+			switch(wrapper.getState()) {
+			case IN_USE:
+				inUse++;
+				break;
+			case NOT_OFFERED:
+				notOffered++;
+				break;
+			case OFFERED:
+				offered++;
+				break;
+			case ON_COOLDOWN:
+				onCooldown++;
+				break;
+			case UNAVAILABLE:
+				unavailable++;
+				break;
+			default:
+				break;
+			
+			}
+		}
+		flexibilityChart.updatePieSeries("Offered", offered);
+		flexibilityChart.updatePieSeries("In use", inUse);
+		flexibilityChart.updatePieSeries("On cooldown", onCooldown);
+		flexibilityChart.updatePieSeries("Not offered", notOffered);
+		flexibilityChart.updatePieSeries("Unavailable", unavailable);
+		boolean hasFlex = offered + inUse + onCooldown + notOffered + unavailable > 0;
+		flexibilityChart.updatePieSeries("No Data", hasFlex?0:1);
+		panelFlexibility.updateToolTips();
+		
+		
+		// UPDATE ActiveInActive
+		int activeAmount = decoratedGroupNode.getAmountOfAktiveElemntsFromHolonObjects();
+		int inactiveAmounts = decoratedGroupNode.getAmountOfElemntsFromHolonObjects() - activeAmount;
+		activeChart.updatePieSeries("Active", activeAmount);
+		activeChart.updatePieSeries("Inactive", inactiveAmounts);
+		panelActive.updateToolTips();
 		
 		this.revalidate();
 		this.repaint();
@@ -129,22 +213,56 @@ public class HolonInformationPanel extends JPanel {
 		panelFlexibility = new XChartPanel<PieChart>(flexibilityChart);
 		panelFlexibility.setBackground(ColorPreference.Panel.Background);
 		graphPanel.add(panelFlexibility);
-		panelEnergy = new XChartPanel<CategoryChart>(energyChart);
-		panelEnergy.setBackground(ColorPreference.Panel.Background);
-		graphPanel.add(panelEnergy);
+		Component panel = initEnergyChart();
+		graphPanel.add(panel);
+		panelActive = new XChartPanel<PieChart>(activeChart);
+		panelActive.setBackground(ColorPreference.Panel.Background);
+		panelActive.setLayout(new GridBagLayout());
+		graphPanel.add(panelActive);
 		graphPanel.setBorder(BorderFactory.createLineBorder(Color.lightGray));
 	}
 
+	private JLayeredPane initEnergyChart() {
+		JLayeredPane panel = new JLayeredPane();
+		JPanel panelMiddle = new JPanel(new GridBagLayout());
+		panelEnergy = new XChartPanel<PieChart>(energyChart);
+		panelEnergy.setBackground(ColorPreference.Panel.Background);
+		GridBagConstraints c = new GridBagConstraints();
+		c.gridx = 0;
+		c.gridy = 0;
+		c.insets = new Insets(15, 0, 0, 0); // top padding
+		JLabel difference = new JLabel("Difference:");
+		difference.setHorizontalAlignment(JLabel.CENTER);
+		difference.setAlignmentX(Component.CENTER_ALIGNMENT);
+		difference.setForeground(ColorPreference.Panel.Title);
+		difference.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 10));
+		panelMiddle.add(difference, c);
+		differenceEnergyLabelAmount = new JLabel("");
+		differenceEnergyLabelAmount.setHorizontalAlignment(JLabel.CENTER);
+		differenceEnergyLabelAmount.setForeground(Color.red);
+		differenceEnergyLabelAmount.setAlignmentX(Component.CENTER_ALIGNMENT);
+		differenceEnergyLabelAmount.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12));
+		c.insets = new Insets(0, 0, 0, 0);
+		c.gridy = 1;
+		panelMiddle.add(differenceEnergyLabelAmount, c);
+		panel.setLayout(new OverlayLayout(panel));
+		panelEnergy.setOpaque(false);
+		panelMiddle.setOpaque(false);
+		panel.add(panelMiddle, Integer.valueOf(0));
+		panel.add(panelEnergy, Integer.valueOf(1));
+		return panel;
+	}
+
 	public void initTitlePanel() {
-		JTextField textField = new JTextField("WindPanel");
-		textField.setFont(new Font("Arial", Font.BOLD, 24));
-		textField.setForeground(ColorPreference.Panel.Title);
-		textField.setBackground(ColorPreference.Panel.Background);
-		textField.setBackground(null);
-		textField.setBorder(null);
+		titleTextField = new JTextField("");
+		titleTextField.setFont(new Font("Arial", Font.BOLD, 24));
+		titleTextField.setForeground(ColorPreference.Panel.Title);
+		titleTextField.setBackground(ColorPreference.Panel.Background);
+		titleTextField.setBackground(null);
+		titleTextField.setBorder(null);
 		titlePanel.setBackground(ColorPreference.Panel.Background);
 		titlePanel.setBorder(new EmptyBorder(5, 5, 2, 0));
-		titlePanel.add(textField, BorderLayout.CENTER);
+		titlePanel.add(titleTextField, BorderLayout.CENTER);
 	}
 
 	public void setDefaultPieChartSettings(PieChart chart) {
@@ -159,10 +277,10 @@ public class HolonInformationPanel extends JPanel {
 		styler.setChartFontColor(ColorPreference.Panel.Title);
 		styler.setToolTipsEnabled(true);
 		styler.setPlotContentSize(0.9);
-		styler.setPlotBackgroundColor(ColorPreference.Panel.Background);
-		styler.setPlotBorderColor(ColorPreference.Panel.Background);
+		styler.setPlotBackgroundColor(ColorPreference.Panel.Transparent);
+		styler.setPlotBorderColor(ColorPreference.Panel.Transparent);
 		styler.setLegendVisible(false);
-		styler.setChartBackgroundColor(ColorPreference.Panel.Background);
+		styler.setChartBackgroundColor(ColorPreference.Panel.Transparent);
 	}
 
 	public PieChart createSupplyStateChart() {
@@ -174,16 +292,13 @@ public class HolonInformationPanel extends JPanel {
 				ColorPreference.HolonObject.NoEnergy };
 		chart.getStyler().setSeriesColors(sliceColors);
 
-		// TODO: get data
 		// Series
-		chart.addSeries("Producer", 40);
-		chart.addSeries("Over supplied", 21);
-		chart.addSeries("Supplied", 24);
-		chart.addSeries("Partial supplied", 39);
-		chart.addSeries("Not supplied", 17);
+		chart.addSeries("Producer", 0);
+		chart.addSeries("Over supplied", 0);
+		chart.addSeries("Supplied", 0);
+		chart.addSeries("Partial supplied", 0);
+		chart.addSeries("Not supplied", 0);
 		chart.addSeries("No energy", 0);
-		chart.updatePieSeries("Producer", 100);
-		
 		return chart;
 	}
 
@@ -192,15 +307,16 @@ public class HolonInformationPanel extends JPanel {
 		PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Priotities").build();
 		setDefaultPieChartSettings(chart);
 		// Customize Chart
-		Color[] sliceColors = new Color[] { ColorPreference.Priority.Essential, ColorPreference.Priority.High,
-				ColorPreference.Priority.Medium, ColorPreference.Priority.Low, };
+		Color[] sliceColors = new Color[] { ColorPreference.Element.Priority.Essential,
+				ColorPreference.Element.Priority.High, ColorPreference.Element.Priority.Medium,
+				ColorPreference.Element.Priority.Low, ColorPreference.Element.Priority.NoData };
 		chart.getStyler().setSeriesColors(sliceColors);
-		// TODO: get data
 		// Series
-		chart.addSeries("Essential", 20);
-		chart.addSeries("High", 28);
-		chart.addSeries("Medium", 29);
-		chart.addSeries("Low", 70);
+		chart.addSeries("Essential", 0);
+		chart.addSeries("High", 0);
+		chart.addSeries("Medium", 0);
+		chart.addSeries("Low", 0);
+		chart.addSeries("No Data", 0);
 		return chart;
 	}
 
@@ -212,45 +328,45 @@ public class HolonInformationPanel extends JPanel {
 		// Customize Chart
 		Color[] sliceColors = new Color[] { ColorPreference.Flexibility.Offered, ColorPreference.Flexibility.InUse,
 				ColorPreference.Flexibility.OnCooldown, ColorPreference.Flexibility.NotOffered,
-				ColorPreference.Flexibility.Unavailable, };
+				ColorPreference.Flexibility.Unavailable, ColorPreference.Element.Priority.NoData };
 		chart.getStyler().setSeriesColors(sliceColors);
-		// TODO: get data
 		// Series
-		chart.addSeries("Offered", 124);
-		chart.addSeries("In use", 45);
-		chart.addSeries("On cooldown", 30);
-		chart.addSeries("Not offered", 15);
-		chart.addSeries("Unavailable", 2);
+		chart.addSeries("Offered", 0);
+		chart.addSeries("In use", 0);
+		chart.addSeries("On cooldown", 0);
+		chart.addSeries("Not offered", 0);
+		chart.addSeries("Unavailable", 0);
+		chart.addSeries("No Data", 0);
 		return chart;
 	}
 
-	public CategoryChart createProductionChart() {
+	public PieChart createProductionChart() {
 		// Create Chart
-		CategoryChart chart = new CategoryChartBuilder().width(defaultWidth).height(defaultHeight)
-				.title("Production vs. Consumption").yAxisTitle("Energy Units").build();
+		PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight)
+				.title("Production vs. Consumption").build();
+		setDefaultPieChartSettings(chart);
 
 		// Customize Chart
-		CategoryStyler styler = chart.getStyler();
+		// Customize Chart
 		Color[] barColors = new Color[] { ColorPreference.Energy.Production, ColorPreference.Energy.Consumption };
 		chart.getStyler().setSeriesColors(barColors);
-
-		styler.setLegendVisible(false);
-		styler.setXAxisTitleVisible(false);
-		styler.setLabelsVisible(false);
-		styler.setXAxisTicksVisible(false);
-		styler.setChartFontColor(ColorPreference.Panel.Title);
-		styler.setChartBackgroundColor(ColorPreference.Panel.Background);
-		styler.setPlotBackgroundColor(ColorPreference.Panel.Background);
-		styler.setPlotBorderColor(ColorPreference.Panel.Background);
-		styler.setToolTipsEnabled(true);
-		// TODO: get data
 		// Series
-		chart.addSeries("Production", new ArrayList<String>(Arrays.asList(new String[] { "Production" })),
-				new ArrayList<Number>(Arrays.asList(new Number[] { 50.0 })));
-
-		chart.addSeries("Consumption", new ArrayList<String>(Arrays.asList(new String[] { "Consumption" })),
-				new ArrayList<Number>(Arrays.asList(new Number[] { 55.0 })));
+		chart.addSeries("Production", 0);
+		chart.addSeries("Consumption", 0);
+		return chart;
+	}
 
+	public PieChart createActiveChart() {
+		// Create Chart
+		PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Active").build();
+		setDefaultPieChartSettings(chart);
+		// Customize Chart
+		// Customize Chart
+		Color[] barColors = new Color[] { ColorPreference.Element.Active, ColorPreference.Element.Inactive };
+		chart.getStyler().setSeriesColors(barColors);
+		// Series
+		chart.addSeries("Active", 0);
+		chart.addSeries("Inactive", 0);
 		return chart;
 	}
 }