HolonInformationPanel.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. package holeg.ui.view.information;
  2. import holeg.model.Flexibility;
  3. import holeg.model.HolonElement;
  4. import holeg.model.HolonObject;
  5. import holeg.model.HolonObject.HolonObjectState;
  6. import holeg.preferences.ColorPreference;
  7. import holeg.preferences.ImagePreference;
  8. import holeg.ui.controller.Control;
  9. import holeg.ui.model.GuiSettings;
  10. import holeg.ui.view.image.Import;
  11. import holeg.utility.math.decimal.Format;
  12. import org.knowm.xchart.PieChart;
  13. import org.knowm.xchart.PieChartBuilder;
  14. import org.knowm.xchart.PieSeries.PieSeriesRenderStyle;
  15. import org.knowm.xchart.XChartPanel;
  16. import org.knowm.xchart.style.PieStyler;
  17. import org.knowm.xchart.style.PieStyler.LabelType;
  18. import javax.swing.*;
  19. import javax.swing.event.PopupMenuEvent;
  20. import javax.swing.event.PopupMenuListener;
  21. import java.awt.*;
  22. import java.util.List;
  23. import java.util.Map;
  24. import java.util.logging.Logger;
  25. import java.util.stream.Collectors;
  26. public class HolonInformationPanel extends JPanel {
  27. private static final Logger log = Logger.getLogger(HolonInformationPanel.class.getName());
  28. private final int defaultWidth = 50;
  29. private final int defaultHeight = 200;
  30. private static final Color[] supplyStateColors = new Color[] { ColorPreference.HolonObject.Producer,
  31. ColorPreference.HolonObject.OverSupplied, ColorPreference.HolonObject.Supplied,
  32. ColorPreference.HolonObject.PartiallySupplied, ColorPreference.HolonObject.NotSupplied,
  33. ColorPreference.HolonObject.NoEnergy, ColorPreference.InformationPanel.NoData };
  34. private static final Color[] productionColors = new Color[] { ColorPreference.Energy.Production,
  35. ColorPreference.Energy.Consumption, ColorPreference.InformationPanel.NoData };
  36. private static final Color[] activeColors = new Color[] { ColorPreference.Element.Active,
  37. ColorPreference.Element.Inactive, ColorPreference.InformationPanel.NoData };
  38. private static final Color[] flexibilityColors = new Color[] { ColorPreference.Flexibility.Offered,
  39. ColorPreference.Flexibility.InUse, ColorPreference.Flexibility.OnCooldown,
  40. ColorPreference.Flexibility.NotOffered, ColorPreference.Flexibility.Unavailable, ColorPreference.Flexibility.NoFlexibility,
  41. ColorPreference.InformationPanel.NoData };
  42. private static final Color[] priorityColors = new Color[] { ColorPreference.Element.Priority.Essential,
  43. ColorPreference.Element.Priority.High, ColorPreference.Element.Priority.Medium,
  44. ColorPreference.Element.Priority.Low, ColorPreference.InformationPanel.NoData };
  45. private final PieChart supplyChart = createSupplyStateChart();
  46. private final PieChart priorityChart = createPriorityChart();
  47. private final PieChart flexibilityChart = createFlexibilityChart();
  48. private final PieChart energyChart = createProductionChart();
  49. private final PieChart activeChart = createActiveChart();
  50. private final JPanel graphPanel = new JPanel(new GridLayout(0, 2));
  51. private final JCheckBoxMenuItem producerCheckBox = new JCheckBoxMenuItem("Producer", true);
  52. private final JCheckBoxMenuItem overSuppliedCheckBox = new JCheckBoxMenuItem("Over supplied", true);
  53. private final JCheckBoxMenuItem suppliedCheckBox = new JCheckBoxMenuItem("Supplied", true);
  54. private final JCheckBoxMenuItem partiallySuppliedCheckBox = new JCheckBoxMenuItem("Partial supplied", true);
  55. private final JCheckBoxMenuItem notSuppliedCheckBox = new JCheckBoxMenuItem("Not supplied", true);
  56. private final JCheckBoxMenuItem noEnergyCheckBox = new JCheckBoxMenuItem("No energy", true);
  57. private final JCheckBoxMenuItem essentialCheckBox = new JCheckBoxMenuItem("Essential", true);
  58. private final JCheckBoxMenuItem highCheckBox = new JCheckBoxMenuItem("High", true);
  59. private final JCheckBoxMenuItem mediumBox = new JCheckBoxMenuItem("Medium", true);
  60. private final JCheckBoxMenuItem lowCheckBox = new JCheckBoxMenuItem("Low", true);
  61. private final JCheckBoxMenuItem activeCheckBox = new JCheckBoxMenuItem("Active", true);
  62. private final JCheckBoxMenuItem inactiveCheckBox = new JCheckBoxMenuItem("Inactive", true);
  63. private final JCheckBoxMenuItem noFlexibilityCheckBox = new JCheckBoxMenuItem("No Flexibility", true);
  64. private final JCheckBoxMenuItem inUseCheckBox = new JCheckBoxMenuItem("In use", true);
  65. private final JCheckBoxMenuItem offeredCheckBox = new JCheckBoxMenuItem("Offered", true);
  66. private final JCheckBoxMenuItem notOfferedCheckBox = new JCheckBoxMenuItem("Not offered", true);
  67. private final JCheckBoxMenuItem onCooldownCheckBox = new JCheckBoxMenuItem("On cooldown", true);
  68. private final JCheckBoxMenuItem unavailableCheckBox = new JCheckBoxMenuItem("Unavailable", true);
  69. private final Control control;
  70. private final JLabel differenceEnergyLabelAmount = new JLabel("");
  71. public HolonInformationPanel(Control control) {
  72. control.OnSelectionChanged.addListener(this::updateCharts);
  73. control.OnCanvasUpdate.addListener(this::updateCharts);
  74. this.control = control;
  75. this.setLayout(new BorderLayout());
  76. initGraphPanel();
  77. this.setBackground(ColorPreference.Panel.Background);
  78. this.add(graphPanel, BorderLayout.CENTER);
  79. }
  80. public void updateCharts() {
  81. FilterableGroupNode tempGroupNode = new FilterableGroupNode();
  82. if(GuiSettings.getSelectedObjects().isEmpty()){
  83. tempGroupNode.add(control.getModel().getCanvas());
  84. }else{
  85. tempGroupNode.addAll(GuiSettings.getSelectedObjects());
  86. }
  87. List<HolonObject> filteredHolonObjectList = tempGroupNode.getAllHolonObjectsRecursive().filter(this::stateFilter).toList();
  88. Map<HolonObjectState, Long> stateMap = filteredHolonObjectList.stream().collect(Collectors.groupingBy(HolonObject::getState, Collectors.counting()));
  89. // UPDATE SUPPLY STATE
  90. int producerAmount = Math.toIntExact(stateMap.getOrDefault(HolonObjectState.PRODUCER, 0L));
  91. int overSuppliedAmount = Math.toIntExact(stateMap.getOrDefault(HolonObjectState.OVER_SUPPLIED, 0L));
  92. int suppliedAmount = Math.toIntExact(stateMap.getOrDefault(HolonObjectState.SUPPLIED, 0L));
  93. int partiallySuppliedAmount = Math.toIntExact(stateMap.getOrDefault(HolonObjectState.PARTIALLY_SUPPLIED, 0L));
  94. int notSuppliedAmount = Math.toIntExact(stateMap.getOrDefault(HolonObjectState.NOT_SUPPLIED, 0L));
  95. int noEnergyAmount = Math.toIntExact(stateMap.getOrDefault(HolonObjectState.NO_ENERGY, 0L));
  96. supplyChart.updatePieSeries("Producer", producerAmount);
  97. supplyChart.updatePieSeries("Over supplied", overSuppliedAmount);
  98. supplyChart.updatePieSeries("Supplied", suppliedAmount);
  99. supplyChart.updatePieSeries("Partial supplied", partiallySuppliedAmount);
  100. supplyChart.updatePieSeries("Not supplied", notSuppliedAmount);
  101. supplyChart.updatePieSeries("No energy", noEnergyAmount);
  102. supplyChart.updatePieSeries("No Data", filteredHolonObjectList.isEmpty() ? 1 : 0);
  103. //UPDATE PRIORITIES
  104. List<HolonElement> filteredHolonElements = filteredHolonObjectList.stream().flatMap(HolonObject::elementsStream)
  105. .filter(ele -> priorityFilter(ele) && activeFilter(ele) && flexibilityFilter(ele)).toList();
  106. Map<HolonElement.Priority, Long> priorityCounts = filteredHolonElements.stream()
  107. .collect(Collectors.groupingBy(HolonElement::getPriority, Collectors.counting()));
  108. long essential = priorityCounts.getOrDefault(HolonElement.Priority.Essential, 0L);
  109. long high = priorityCounts.getOrDefault(HolonElement.Priority.High, 0L);
  110. long medium = priorityCounts.getOrDefault(HolonElement.Priority.Medium, 0L);
  111. long low = priorityCounts.getOrDefault(HolonElement.Priority.Low, 0L);
  112. priorityChart.updatePieSeries("Essential", essential);
  113. priorityChart.updatePieSeries("High", high);
  114. priorityChart.updatePieSeries("Medium", medium);
  115. priorityChart.updatePieSeries("Low", low);
  116. boolean hasPriority = essential + high + medium + low > 0;
  117. priorityChart.updatePieSeries("No Data", hasPriority ? 0 : 1);
  118. // UPDATE PRODUCTION
  119. float consumption = filteredHolonElements.stream().filter(element -> element.getActualEnergy() < 0)
  120. .map(element -> -element.getActualEnergy()).reduce(0.0f, Float::sum);
  121. float production = filteredHolonElements.stream()
  122. .map(HolonElement::getActualEnergy).filter(energy -> energy > 0).reduce(0.0f, Float::sum);
  123. float difference = Math.abs(production - consumption);
  124. energyChart.updatePieSeries("Production", production);
  125. energyChart.updatePieSeries("Consumption", consumption);
  126. energyChart.updatePieSeries("No Data", production + consumption == 0 ? 1 : 0);
  127. differenceEnergyLabelAmount.setText(Format.doubleFixedPlaces(1, difference));
  128. // UPDATE FLEXIBILITIES
  129. int inUse = 0;
  130. int offered = 0;
  131. int onCooldown = 0;
  132. int notOffered = 0;
  133. int unavailable = 0;
  134. List<Flexibility> flexList = filteredHolonElements.stream().flatMap(ele -> ele.flexList.stream()).toList();
  135. for (Flexibility flex : flexList) {
  136. switch (flex.getState()) {
  137. case IN_USE -> inUse++;
  138. case NOT_OFFERED -> notOffered++;
  139. case OFFERED -> offered++;
  140. case ON_COOLDOWN -> onCooldown++;
  141. case UNAVAILABLE -> unavailable++;
  142. default -> {
  143. }
  144. }
  145. }
  146. int noFlexibility = (int)filteredHolonElements.stream().filter(ele -> ele.flexList.isEmpty()).count();
  147. flexibilityChart.updatePieSeries("No flexibility", noFlexibility);
  148. flexibilityChart.updatePieSeries("Offered", offered);
  149. flexibilityChart.updatePieSeries("In use", inUse);
  150. flexibilityChart.updatePieSeries("On cooldown", onCooldown);
  151. flexibilityChart.updatePieSeries("Not offered", notOffered);
  152. flexibilityChart.updatePieSeries("Unavailable", unavailable);
  153. boolean hasFlex = noFlexibility + offered + inUse + onCooldown + notOffered + unavailable > 0;
  154. flexibilityChart.updatePieSeries("No Data", hasFlex ? 0 : 1);
  155. Map<Boolean, Long> activeCounts = filteredHolonElements.stream()
  156. .collect(Collectors.groupingBy(HolonElement::isOn, Collectors.counting()));
  157. // UPDATE ActiveInActive
  158. int activeAmount = Math.toIntExact(activeCounts.getOrDefault(true, 0L));
  159. int inactiveAmounts = Math.toIntExact(activeCounts.getOrDefault(false, 0L));
  160. activeChart.updatePieSeries("Active", activeAmount);
  161. activeChart.updatePieSeries("Inactive", inactiveAmounts);
  162. activeChart.updatePieSeries("No Data", activeAmount + inactiveAmounts == 0 ? 1 : 0);
  163. this.revalidate();
  164. this.repaint();
  165. }
  166. private JPopupMenu createHolonStateSelection(){
  167. JPopupMenu menu = new JPopupMenu();
  168. producerCheckBox.addActionListener(clicked -> updateCharts());
  169. overSuppliedCheckBox.addActionListener(clicked -> updateCharts());
  170. suppliedCheckBox.addActionListener(clicked -> updateCharts());
  171. partiallySuppliedCheckBox.addActionListener(clicked -> updateCharts());
  172. notSuppliedCheckBox.addActionListener(clicked -> updateCharts());
  173. noEnergyCheckBox.addActionListener(clicked -> updateCharts());
  174. menu.add(producerCheckBox);
  175. menu.add(overSuppliedCheckBox);
  176. menu.add(suppliedCheckBox);
  177. menu.add(partiallySuppliedCheckBox);
  178. menu.add(notSuppliedCheckBox);
  179. menu.add(noEnergyCheckBox);
  180. return menu;
  181. }
  182. private JPopupMenu createPrioritySelection(){
  183. JPopupMenu menu = new JPopupMenu();
  184. essentialCheckBox.addActionListener(clicked -> updateCharts());
  185. highCheckBox.addActionListener(clicked -> updateCharts());
  186. mediumBox.addActionListener(clicked -> updateCharts());
  187. lowCheckBox.addActionListener(clicked -> updateCharts());
  188. menu.add(essentialCheckBox);
  189. menu.add(highCheckBox);
  190. menu.add(mediumBox);
  191. menu.add(lowCheckBox);
  192. return menu;
  193. }
  194. private JPopupMenu createActiveSelection(){
  195. JPopupMenu menu = new JPopupMenu();
  196. activeCheckBox.addActionListener(clicked -> updateCharts());
  197. inactiveCheckBox.addActionListener(clicked -> updateCharts());
  198. menu.add(activeCheckBox);
  199. menu.add(inactiveCheckBox);
  200. return menu;
  201. }
  202. private JPopupMenu createFlexibilitySelection(){
  203. JPopupMenu menu = new JPopupMenu();
  204. noFlexibilityCheckBox.addActionListener(clicked -> updateCharts());
  205. offeredCheckBox.addActionListener(clicked -> updateCharts());
  206. notOfferedCheckBox.addActionListener(clicked -> updateCharts());
  207. unavailableCheckBox.addActionListener(clicked -> updateCharts());
  208. inUseCheckBox.addActionListener(clicked -> updateCharts());
  209. onCooldownCheckBox.addActionListener(clicked -> updateCharts());
  210. menu.add(noFlexibilityCheckBox);
  211. menu.add(offeredCheckBox);
  212. menu.add(notOfferedCheckBox);
  213. menu.add(unavailableCheckBox);
  214. menu.add(inUseCheckBox);
  215. menu.add(onCooldownCheckBox);
  216. return menu;
  217. }
  218. private JPanel initMenuButtonPanel(JPopupMenu menu){
  219. JPanel buttonPanel = new JPanel(new BorderLayout());
  220. MenuButton button = new MenuButton(new ImageIcon(Import.loadImage(ImagePreference.HolonInformationPanel.Filter, 20, 20)), menu);
  221. buttonPanel.add(button, BorderLayout.LINE_END);
  222. buttonPanel.setOpaque(false);
  223. button.setPressedIcon(new ImageIcon(Import.loadImage(ImagePreference.HolonInformationPanel.FilterHovered, 20, 20)));
  224. button.setRolloverIcon(new ImageIcon(Import.loadImage(ImagePreference.HolonInformationPanel.FilterHovered, 20, 20)));
  225. button.setBorderPainted(false);
  226. button.setBorder(null);
  227. button.setFocusable(false);
  228. button.setMargin(new Insets(0, 0, 0, 0));
  229. button.setContentAreaFilled(false);
  230. return buttonPanel;
  231. }
  232. private boolean stateFilter(HolonObject holonObject){
  233. return switch (holonObject.getState()) {
  234. case PRODUCER -> producerCheckBox.isSelected();
  235. case OVER_SUPPLIED -> overSuppliedCheckBox.isSelected();
  236. case SUPPLIED -> suppliedCheckBox.isSelected();
  237. case PARTIALLY_SUPPLIED -> partiallySuppliedCheckBox.isSelected();
  238. case NOT_SUPPLIED -> notSuppliedCheckBox.isSelected();
  239. case NO_ENERGY -> noEnergyCheckBox.isSelected();
  240. };
  241. }
  242. private boolean priorityFilter(HolonElement ele){
  243. return switch (ele.priority) {
  244. case Essential -> essentialCheckBox.isSelected();
  245. case High -> highCheckBox.isSelected();
  246. case Medium -> mediumBox.isSelected();
  247. case Low -> lowCheckBox.isSelected();
  248. };
  249. }
  250. private boolean activeFilter(HolonElement ele){
  251. return ele.active ? activeCheckBox.isSelected(): inactiveCheckBox.isSelected();
  252. }
  253. private boolean flexibilityFilter(HolonElement ele){
  254. if(ele.flexList.isEmpty()){
  255. return noFlexibilityCheckBox.isSelected();
  256. }
  257. Map<Flexibility.FlexState,Long> flexes = ele.flexList.stream().collect(Collectors.groupingBy(Flexibility::getState, Collectors.counting()));
  258. return flexes.keySet().stream().anyMatch(flexState -> switch (flexState) {
  259. case IN_USE -> inUseCheckBox.isSelected();
  260. case UNAVAILABLE -> unavailableCheckBox.isSelected();
  261. case OFFERED -> offeredCheckBox.isSelected();
  262. case NOT_OFFERED -> notOfferedCheckBox.isSelected();
  263. case ON_COOLDOWN -> onCooldownCheckBox.isSelected();
  264. });
  265. }
  266. public static class MenuButton extends JToggleButton {
  267. JPopupMenu popup;
  268. public MenuButton(Icon icon, JPopupMenu menu) {
  269. super(icon);
  270. this.popup = menu;
  271. addActionListener(clicked -> {
  272. if (MenuButton.this.isSelected()) {
  273. popup.show(MenuButton.this, 0, MenuButton.this.getBounds().height);
  274. } else {
  275. popup.setVisible(false);
  276. }
  277. });
  278. popup.addPopupMenuListener(new PopupMenuListener() {
  279. @Override
  280. public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}
  281. @Override
  282. public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
  283. MenuButton.this.setSelected(false);
  284. }
  285. @Override
  286. public void popupMenuCanceled(PopupMenuEvent e) {}
  287. });
  288. }
  289. }
  290. private void initGraphPanel() {
  291. graphPanel.setBackground(ColorPreference.Panel.Background);
  292. XChartPanel<PieChart> panelHolonObject = new XChartPanel<>(supplyChart);
  293. panelHolonObject.setLayout(new BorderLayout());
  294. panelHolonObject.add(initMenuButtonPanel(createHolonStateSelection()), BorderLayout.PAGE_START);
  295. panelHolonObject.setBackground(ColorPreference.Panel.Background);
  296. graphPanel.add(panelHolonObject);
  297. XChartPanel<PieChart> panelPriority = new XChartPanel<>(priorityChart);
  298. panelPriority.setLayout(new BorderLayout());
  299. panelPriority.add(initMenuButtonPanel(createPrioritySelection()), BorderLayout.PAGE_START);
  300. panelPriority.setBackground(ColorPreference.Panel.Background);
  301. graphPanel.add(panelPriority);
  302. XChartPanel<PieChart> panelFlexibility = new XChartPanel<>(flexibilityChart);
  303. panelFlexibility.setLayout(new BorderLayout());
  304. panelFlexibility.add(initMenuButtonPanel(createFlexibilitySelection()), BorderLayout.PAGE_START);
  305. panelFlexibility.setBackground(ColorPreference.Panel.Background);
  306. graphPanel.add(panelFlexibility);
  307. Component panel = initEnergyChart();
  308. graphPanel.add(panel);
  309. XChartPanel<PieChart> panelActive = new XChartPanel<>(activeChart);
  310. panelActive.setLayout(new BorderLayout());
  311. panelActive.add(initMenuButtonPanel(createActiveSelection()), BorderLayout.PAGE_START);
  312. panelActive.setBackground(ColorPreference.Panel.Background);
  313. graphPanel.add(panelActive);
  314. graphPanel.setBorder(BorderFactory.createLineBorder(Color.lightGray));
  315. }
  316. private JLayeredPane initEnergyChart() {
  317. JLayeredPane panel = new JLayeredPane();
  318. JPanel panelMiddle = new JPanel(new GridBagLayout());
  319. XChartPanel<PieChart> panelEnergy = new XChartPanel<>(energyChart);
  320. panelEnergy.setBackground(ColorPreference.Panel.Background);
  321. GridBagConstraints c = new GridBagConstraints();
  322. c.gridx = 0;
  323. c.gridy = 0;
  324. c.insets = new Insets(15, 0, 0, 0); // top padding
  325. JLabel difference = new JLabel("Difference:");
  326. difference.setHorizontalAlignment(JLabel.CENTER);
  327. difference.setAlignmentX(Component.CENTER_ALIGNMENT);
  328. difference.setForeground(ColorPreference.Panel.Title);
  329. difference.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 10));
  330. panelMiddle.add(difference, c);
  331. differenceEnergyLabelAmount.setHorizontalAlignment(JLabel.CENTER);
  332. differenceEnergyLabelAmount.setForeground(Color.red);
  333. differenceEnergyLabelAmount.setAlignmentX(Component.CENTER_ALIGNMENT);
  334. differenceEnergyLabelAmount.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12));
  335. c.insets = new Insets(0, 0, 0, 0);
  336. c.gridy = 1;
  337. panelMiddle.add(differenceEnergyLabelAmount, c);
  338. panel.setLayout(new OverlayLayout(panel));
  339. panelEnergy.setOpaque(false);
  340. panelMiddle.setOpaque(false);
  341. panel.add(panelMiddle, Integer.valueOf(0));
  342. panel.add(panelEnergy, Integer.valueOf(1));
  343. return panel;
  344. }
  345. public void setDefaultPieChartSettings(PieChart chart) {
  346. PieStyler styler = chart.getStyler();
  347. styler.setChartTitleVisible(true);
  348. styler.setDefaultSeriesRenderStyle(PieSeriesRenderStyle.Donut);
  349. styler.setLabelsFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 14));
  350. styler.setLabelType(LabelType.Percentage);
  351. styler.setLabelsFontColor(Color.black);
  352. styler.setLabelsFontColorAutomaticEnabled(false);
  353. styler.setLabelsDistance(0.8);
  354. styler.setChartFontColor(ColorPreference.Panel.Title);
  355. styler.setToolTipsEnabled(true);
  356. styler.setPlotContentSize(0.9);
  357. styler.setPlotBackgroundColor(ColorPreference.Panel.Transparent);
  358. styler.setPlotBorderColor(ColorPreference.Panel.Transparent);
  359. styler.setLegendVisible(false);
  360. styler.setChartBackgroundColor(ColorPreference.Panel.Transparent);
  361. }
  362. public PieChart createSupplyStateChart() {
  363. PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("HolonObjects").build();
  364. setDefaultPieChartSettings(chart);
  365. chart.getStyler().setSeriesColors(supplyStateColors);
  366. // Series
  367. chart.addSeries("Producer", 0);
  368. chart.addSeries("Over supplied", 0);
  369. chart.addSeries("Supplied", 0);
  370. chart.addSeries("Partial supplied", 0);
  371. chart.addSeries("Not supplied", 0);
  372. chart.addSeries("No energy", 0);
  373. chart.addSeries("No Data", 0);
  374. return chart;
  375. }
  376. public PieChart createPriorityChart() {
  377. PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Priorities").build();
  378. setDefaultPieChartSettings(chart);
  379. // Customize Chart
  380. chart.getStyler().setSeriesColors(priorityColors);
  381. // Series
  382. chart.addSeries("Essential", 0);
  383. chart.addSeries("High", 0);
  384. chart.addSeries("Medium", 0);
  385. chart.addSeries("Low", 0);
  386. chart.addSeries("No Data", 0);
  387. return chart;
  388. }
  389. public PieChart createFlexibilityChart() {
  390. PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Flexibilities").build();
  391. setDefaultPieChartSettings(chart);
  392. // Customize Chart
  393. chart.getStyler().setSeriesColors(flexibilityColors);
  394. // Series
  395. chart.addSeries("Offered", 0);
  396. chart.addSeries("In use", 0);
  397. chart.addSeries("On cooldown", 0);
  398. chart.addSeries("Not offered", 0);
  399. chart.addSeries("Unavailable", 0);
  400. chart.addSeries("No flexibility", 0);
  401. chart.addSeries("No Data", 0);
  402. return chart;
  403. }
  404. public PieChart createProductionChart() {
  405. PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight)
  406. .title("Production vs. Consumption").build();
  407. setDefaultPieChartSettings(chart);
  408. // Customize Chart
  409. // Customize Chart
  410. chart.getStyler().setSeriesColors(productionColors);
  411. // Series
  412. chart.addSeries("Production", 0);
  413. chart.addSeries("Consumption", 0);
  414. chart.addSeries("No Data", 0);
  415. return chart;
  416. }
  417. public PieChart createActiveChart() {
  418. PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Active").build();
  419. setDefaultPieChartSettings(chart);
  420. // Customize Chart
  421. // Customize Chart
  422. chart.getStyler().setSeriesColors(activeColors);
  423. // Series
  424. chart.addSeries("Active", 0);
  425. chart.addSeries("Inactive", 0);
  426. chart.addSeries("No Data", 0);
  427. return chart;
  428. }
  429. }