|
@@ -2,20 +2,28 @@ package ui.view;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
import java.awt.Color;
|
|
|
|
+import java.awt.Component;
|
|
import java.awt.Font;
|
|
import java.awt.Font;
|
|
|
|
+import java.awt.GridBagConstraints;
|
|
|
|
+import java.awt.GridBagLayout;
|
|
import java.awt.GridLayout;
|
|
import java.awt.GridLayout;
|
|
|
|
+import java.awt.Insets;
|
|
import java.awt.event.MouseAdapter;
|
|
import java.awt.event.MouseAdapter;
|
|
import java.awt.event.MouseEvent;
|
|
import java.awt.event.MouseEvent;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
import javax.swing.BorderFactory;
|
|
|
|
+import javax.swing.BoxLayout;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JLabel;
|
|
|
|
+import javax.swing.JLayeredPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
import javax.swing.JTextField;
|
|
|
|
+import javax.swing.OverlayLayout;
|
|
import javax.swing.SwingUtilities;
|
|
import javax.swing.SwingUtilities;
|
|
import javax.swing.border.EmptyBorder;
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
|
|
@@ -30,35 +38,44 @@ import org.knowm.xchart.style.PieStyler;
|
|
import org.knowm.xchart.style.PieStyler.LabelType;
|
|
import org.knowm.xchart.style.PieStyler.LabelType;
|
|
|
|
|
|
import classes.AbstractCanvasObject;
|
|
import classes.AbstractCanvasObject;
|
|
|
|
+import classes.Flexibility;
|
|
import classes.GroupNode;
|
|
import classes.GroupNode;
|
|
|
|
+import classes.HolonElement;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
import preferences.ColorPreference;
|
|
import preferences.ColorPreference;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
|
|
+import ui.controller.FlexManager;
|
|
|
|
+import ui.controller.FlexManager.FlexWrapper;
|
|
import ui.model.DecoratedGroupNode;
|
|
import ui.model.DecoratedGroupNode;
|
|
|
|
+import ui.model.DecoratedGroupNode.PriorityCounts;
|
|
import ui.model.DecoratedHolonObject.HolonObjectState;
|
|
import ui.model.DecoratedHolonObject.HolonObjectState;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
|
|
+import util.StringFormat;
|
|
|
|
|
|
public class HolonInformationPanel extends JPanel {
|
|
public class HolonInformationPanel extends JPanel {
|
|
|
|
|
|
private final int defaultWidth = 50;
|
|
private final int defaultWidth = 50;
|
|
- private final int defaultHeight = 150;
|
|
|
|
|
|
+ private final int defaultHeight = 200;
|
|
|
|
|
|
private PieChart supplyChart = createSupplyStateChart();
|
|
private PieChart supplyChart = createSupplyStateChart();
|
|
private PieChart priorityChart = createPriorityChart();
|
|
private PieChart priorityChart = createPriorityChart();
|
|
private PieChart flexibilityChart = createFlexibilityChart();
|
|
private PieChart flexibilityChart = createFlexibilityChart();
|
|
- private CategoryChart energyChart = createProductionChart();
|
|
|
|
|
|
+ private PieChart energyChart = createProductionChart();
|
|
|
|
+ private PieChart activeChart = createActiveChart();
|
|
|
|
|
|
private XChartPanel<PieChart> panelHolonObject;
|
|
private XChartPanel<PieChart> panelHolonObject;
|
|
private XChartPanel<PieChart> panelPriority;
|
|
private XChartPanel<PieChart> panelPriority;
|
|
private XChartPanel<PieChart> panelFlexibility;
|
|
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 graphPanel = new JPanel(new GridLayout(0, 2));
|
|
private JPanel titlePanel = new JPanel(new BorderLayout(0, 0));
|
|
private JPanel titlePanel = new JPanel(new BorderLayout(0, 0));
|
|
|
|
|
|
private Control control;
|
|
private Control control;
|
|
|
|
+ private JTextField titleTextField;
|
|
|
|
+ private JLabel differenceEnergyLabelAmount;
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
HolonInformationPanel exampleChart = new HolonInformationPanel(new Control(new Model()));
|
|
HolonInformationPanel exampleChart = new HolonInformationPanel(new Control(new Model()));
|
|
@@ -76,21 +93,24 @@ public class HolonInformationPanel extends JPanel {
|
|
List<GroupNode> list = control.getModel().getSelectedCpsObjects().stream()
|
|
List<GroupNode> list = control.getModel().getSelectedCpsObjects().stream()
|
|
.filter(object -> object instanceof GroupNode).map(object -> (GroupNode) object)
|
|
.filter(object -> object instanceof GroupNode).map(object -> (GroupNode) object)
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
- System.out.println("UPDATE CHART" + list.size());
|
|
|
|
- if(list.size() != 1) {
|
|
|
|
|
|
+ if (list.size() != 1) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
GroupNode groupNode = list.get(0);
|
|
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 producerAmount = decoratedGroupNode.getAmountOfSupplier();
|
|
int overSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED);
|
|
int overSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED);
|
|
int suppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.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 notSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(HolonObjectState.NOT_SUPPLIED);
|
|
int noEnergyAmount = decoratedGroupNode.getAmountOfPassiv();
|
|
int noEnergyAmount = decoratedGroupNode.getAmountOfPassiv();
|
|
-
|
|
|
|
|
|
+
|
|
supplyChart.updatePieSeries("Producer", producerAmount);
|
|
supplyChart.updatePieSeries("Producer", producerAmount);
|
|
supplyChart.updatePieSeries("Over supplied", overSuppliedAmount);
|
|
supplyChart.updatePieSeries("Over supplied", overSuppliedAmount);
|
|
supplyChart.updatePieSeries("Supplied", suppliedAmount);
|
|
supplyChart.updatePieSeries("Supplied", suppliedAmount);
|
|
@@ -98,10 +118,74 @@ public class HolonInformationPanel extends JPanel {
|
|
supplyChart.updatePieSeries("Not supplied", notSuppliedAmount);
|
|
supplyChart.updatePieSeries("Not supplied", notSuppliedAmount);
|
|
supplyChart.updatePieSeries("No energy", noEnergyAmount);
|
|
supplyChart.updatePieSeries("No energy", noEnergyAmount);
|
|
panelHolonObject.updateToolTips();
|
|
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.revalidate();
|
|
this.repaint();
|
|
this.repaint();
|
|
@@ -129,22 +213,56 @@ public class HolonInformationPanel extends JPanel {
|
|
panelFlexibility = new XChartPanel<PieChart>(flexibilityChart);
|
|
panelFlexibility = new XChartPanel<PieChart>(flexibilityChart);
|
|
panelFlexibility.setBackground(ColorPreference.Panel.Background);
|
|
panelFlexibility.setBackground(ColorPreference.Panel.Background);
|
|
graphPanel.add(panelFlexibility);
|
|
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));
|
|
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() {
|
|
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.setBackground(ColorPreference.Panel.Background);
|
|
titlePanel.setBorder(new EmptyBorder(5, 5, 2, 0));
|
|
titlePanel.setBorder(new EmptyBorder(5, 5, 2, 0));
|
|
- titlePanel.add(textField, BorderLayout.CENTER);
|
|
|
|
|
|
+ titlePanel.add(titleTextField, BorderLayout.CENTER);
|
|
}
|
|
}
|
|
|
|
|
|
public void setDefaultPieChartSettings(PieChart chart) {
|
|
public void setDefaultPieChartSettings(PieChart chart) {
|
|
@@ -159,10 +277,10 @@ public class HolonInformationPanel extends JPanel {
|
|
styler.setChartFontColor(ColorPreference.Panel.Title);
|
|
styler.setChartFontColor(ColorPreference.Panel.Title);
|
|
styler.setToolTipsEnabled(true);
|
|
styler.setToolTipsEnabled(true);
|
|
styler.setPlotContentSize(0.9);
|
|
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.setLegendVisible(false);
|
|
- styler.setChartBackgroundColor(ColorPreference.Panel.Background);
|
|
|
|
|
|
+ styler.setChartBackgroundColor(ColorPreference.Panel.Transparent);
|
|
}
|
|
}
|
|
|
|
|
|
public PieChart createSupplyStateChart() {
|
|
public PieChart createSupplyStateChart() {
|
|
@@ -174,16 +292,13 @@ public class HolonInformationPanel extends JPanel {
|
|
ColorPreference.HolonObject.NoEnergy };
|
|
ColorPreference.HolonObject.NoEnergy };
|
|
chart.getStyler().setSeriesColors(sliceColors);
|
|
chart.getStyler().setSeriesColors(sliceColors);
|
|
|
|
|
|
- // TODO: get data
|
|
|
|
// Series
|
|
// 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.addSeries("No energy", 0);
|
|
- chart.updatePieSeries("Producer", 100);
|
|
|
|
-
|
|
|
|
return chart;
|
|
return chart;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -192,15 +307,16 @@ public class HolonInformationPanel extends JPanel {
|
|
PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Priotities").build();
|
|
PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Priotities").build();
|
|
setDefaultPieChartSettings(chart);
|
|
setDefaultPieChartSettings(chart);
|
|
// Customize 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);
|
|
chart.getStyler().setSeriesColors(sliceColors);
|
|
- // TODO: get data
|
|
|
|
// Series
|
|
// 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;
|
|
return chart;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -212,45 +328,45 @@ public class HolonInformationPanel extends JPanel {
|
|
// Customize Chart
|
|
// Customize Chart
|
|
Color[] sliceColors = new Color[] { ColorPreference.Flexibility.Offered, ColorPreference.Flexibility.InUse,
|
|
Color[] sliceColors = new Color[] { ColorPreference.Flexibility.Offered, ColorPreference.Flexibility.InUse,
|
|
ColorPreference.Flexibility.OnCooldown, ColorPreference.Flexibility.NotOffered,
|
|
ColorPreference.Flexibility.OnCooldown, ColorPreference.Flexibility.NotOffered,
|
|
- ColorPreference.Flexibility.Unavailable, };
|
|
|
|
|
|
+ ColorPreference.Flexibility.Unavailable, ColorPreference.Element.Priority.NoData };
|
|
chart.getStyler().setSeriesColors(sliceColors);
|
|
chart.getStyler().setSeriesColors(sliceColors);
|
|
- // TODO: get data
|
|
|
|
// Series
|
|
// 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;
|
|
return chart;
|
|
}
|
|
}
|
|
|
|
|
|
- public CategoryChart createProductionChart() {
|
|
|
|
|
|
+ public PieChart createProductionChart() {
|
|
// Create Chart
|
|
// 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
|
|
// Customize Chart
|
|
- CategoryStyler styler = chart.getStyler();
|
|
|
|
|
|
+ // Customize Chart
|
|
Color[] barColors = new Color[] { ColorPreference.Energy.Production, ColorPreference.Energy.Consumption };
|
|
Color[] barColors = new Color[] { ColorPreference.Energy.Production, ColorPreference.Energy.Consumption };
|
|
chart.getStyler().setSeriesColors(barColors);
|
|
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
|
|
// 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;
|
|
return chart;
|
|
}
|
|
}
|
|
}
|
|
}
|