|
@@ -16,6 +16,7 @@ import javax.swing.JButton;
|
|
|
import javax.swing.JFrame;
|
|
|
import javax.swing.JLabel;
|
|
|
import javax.swing.JPanel;
|
|
|
+import javax.swing.JScrollPane;
|
|
|
import javax.swing.JSeparator;
|
|
|
import javax.swing.JTextField;
|
|
|
import javax.swing.SpringLayout;
|
|
@@ -26,38 +27,49 @@ import classes.HolonElement.Priority;
|
|
|
import ui.controller.Control;
|
|
|
import ui.controller.FlexManager.FlexState;
|
|
|
import ui.controller.FlexManager.FlexWrapper;
|
|
|
+import ui.model.DecoratedGroupNode;
|
|
|
import ui.model.DecoratedHolonObject.HolonObjectState;
|
|
|
import ui.model.DecoratedState;
|
|
|
+import ui.model.VisualRepresentationalState;
|
|
|
|
|
|
public class InformationPanel implements AddOn {
|
|
|
Control control;
|
|
|
|
|
|
private JPanel content = new JPanel();
|
|
|
-
|
|
|
+ private JScrollPane scrollPane;
|
|
|
|
|
|
|
|
|
|
|
|
- private int amountHolonObjects;
|
|
|
private int amountSwitch;
|
|
|
- private int amountConsumer;
|
|
|
- private int amountUnderSupplied;
|
|
|
- private int amountPatiallySupplied;
|
|
|
- private int amountFullySupplied;
|
|
|
- private int amountOversupllied;
|
|
|
+ private int amountHolonObjects;
|
|
|
+ private int amountConsumer;
|
|
|
+ private int amountUnderSupplied;
|
|
|
+ private int amountPatiallySupplied;
|
|
|
+ private int amountFullySupplied;
|
|
|
+ private int amountOversupllied;
|
|
|
private int amountSupplier;
|
|
|
|
|
|
private int amountHolonElements;
|
|
|
private int amountActiveHolonElements;
|
|
|
private int amountInactiveHolonElements;
|
|
|
private int amountFlexibilities;
|
|
|
+ private int amountActiveFlexibilities;
|
|
|
private int amountEssential;
|
|
|
+ private int amountActiveEssential;
|
|
|
private int amountHigh;
|
|
|
+ private int amountActiveHigh;
|
|
|
private int amountMedium;
|
|
|
+ private int amountActiveMedium;
|
|
|
private int amountLow;
|
|
|
+ private int amountActiveLow;
|
|
|
|
|
|
private int amountConsumingFlexibilities;
|
|
|
private int amountProducingFlexibilities;
|
|
|
private int amountPassiv;
|
|
|
+
|
|
|
+ private int amountHolons;
|
|
|
+ private float averageConsumption;
|
|
|
+ private float averageProduction;
|
|
|
|
|
|
List<Entry> entryList = new ArrayList<Entry>();
|
|
|
|
|
@@ -66,11 +78,19 @@ public class InformationPanel implements AddOn {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
public InformationPanel(){
|
|
|
content.setLayout(new BorderLayout());
|
|
|
- content.add(createMiddlePanel(), BorderLayout.CENTER);
|
|
|
+ scrollPane = new JScrollPane(createMiddlePanel(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
|
|
|
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
|
|
+ int size = 75;
|
|
|
+ scrollPane.setPreferredSize(new Dimension(16*size, 9*size));
|
|
|
+ content.add(scrollPane, BorderLayout.CENTER);
|
|
|
JButton button = new JButton("calculate");
|
|
|
button.addActionListener(action -> updateEntrys());
|
|
|
content.add(button, BorderLayout.SOUTH);
|
|
@@ -91,8 +111,7 @@ public class InformationPanel implements AddOn {
|
|
|
JPanel middle = new JPanel();
|
|
|
middle.setLayout(new GridBagLayout());
|
|
|
|
|
|
- int size = 60;
|
|
|
- middle.setPreferredSize(new Dimension(16*size, 9*size));
|
|
|
+
|
|
|
|
|
|
|
|
|
entryList.add(new Entry(() -> Integer.toString(amountHolonObjects), "amountHolonObjects", middle));
|
|
@@ -120,8 +139,17 @@ public class InformationPanel implements AddOn {
|
|
|
entryList.add(new Entry(() -> Integer.toString(amountMedium) + addPercentage(amountMedium, amountFlexibilities), "\tamountMedium", middle));
|
|
|
entryList.add(new Entry(() -> Integer.toString(amountHigh) + addPercentage(amountHigh, amountFlexibilities), "\tamountHigh", middle));
|
|
|
entryList.add(new Entry(() -> Integer.toString(amountEssential) + addPercentage(amountEssential, amountFlexibilities), "\tamountEssential", middle));
|
|
|
-
|
|
|
-
|
|
|
+ addSeperator(middle);
|
|
|
+ entryList.add(new Entry(() -> Integer.toString(amountActiveFlexibilities), "amountActiveFlexibilities", middle));
|
|
|
+ entryList.add(new Entry(() -> Integer.toString(amountActiveLow) + addPercentage(amountActiveLow, amountActiveFlexibilities), "\tamountActiveLow", middle));
|
|
|
+ entryList.add(new Entry(() -> Integer.toString(amountActiveMedium) + addPercentage(amountActiveMedium, amountActiveFlexibilities), "\tamountActiveMedium", middle));
|
|
|
+ entryList.add(new Entry(() -> Integer.toString(amountActiveHigh) + addPercentage(amountActiveHigh, amountActiveFlexibilities), "\tamountActiveHigh", middle));
|
|
|
+ entryList.add(new Entry(() -> Integer.toString(amountActiveEssential) + addPercentage(amountActiveEssential, amountActiveFlexibilities), "\tamountActiveEssential", middle));
|
|
|
+ addSeperator(middle);
|
|
|
+ entryList.add(new Entry(() -> Integer.toString(amountHolons), "amountHolons", middle));
|
|
|
+ addSeperator(middle);
|
|
|
+ entryList.add(new Entry(() -> String.format (Locale.US, "%.2f", averageConsumption), "averageConsumption", middle));
|
|
|
+ entryList.add(new Entry(() -> String.format (Locale.US, "%.2f", averageProduction), "averageProduction", middle));
|
|
|
|
|
|
return middle;
|
|
|
}
|
|
@@ -197,6 +225,18 @@ public class InformationPanel implements AddOn {
|
|
|
amountMedium = (int)flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
|
|
|
amountLow = (int)flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).count();
|
|
|
this.amountFlexibilities = amountEssential + amountHigh + amountMedium + amountLow;
|
|
|
+
|
|
|
+
|
|
|
+ List<Flexibility> flexActiveList = control.getSimManager().getActualFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE).stream().map(flex -> flex.getFlex()).collect(Collectors.toList());
|
|
|
+ amountActiveEssential = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential).count();
|
|
|
+ amountActiveHigh = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.High).count();
|
|
|
+ amountActiveMedium = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
|
|
|
+ amountActiveLow = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).count();
|
|
|
+ this.amountActiveFlexibilities = amountActiveEssential + amountActiveHigh + amountActiveMedium + amountActiveLow;
|
|
|
+ VisualRepresentationalState visualState =control.getSimManager().getActualVisualRepresentationalState();
|
|
|
+ amountHolons = visualState.getAmountOfHolons();
|
|
|
+ averageConsumption = visualState.getAverageConsumption();
|
|
|
+ averageProduction = visualState.getAverageProduction();
|
|
|
int cost = 0;
|
|
|
int consumingFlex = 0;
|
|
|
float consumingFlexEnergy = 0.0f;
|
|
@@ -220,6 +260,8 @@ public class InformationPanel implements AddOn {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public JPanel getPanel() {
|
|
|
return content;
|