|
@@ -1,4 +1,4 @@
|
|
|
-package ui.view;
|
|
|
+package ui.view.main;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
import java.awt.Color;
|
|
@@ -29,8 +29,6 @@ import java.net.URI;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.ListIterator;
|
|
|
-import java.util.Timer;
|
|
|
-import java.util.TimerTask;
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
import javax.swing.ActionMap;
|
|
@@ -74,18 +72,30 @@ import classes.AbstractCanvasObject;
|
|
|
import classes.Category;
|
|
|
import classes.Edge;
|
|
|
import classes.GroupNode;
|
|
|
-import classes.HolonElement;
|
|
|
import classes.HolonObject;
|
|
|
import classes.HolonSwitch;
|
|
|
import classes.IdCounter;
|
|
|
import classes.IdCounter.CounterType;
|
|
|
import interfaces.GraphEditable;
|
|
|
import ui.controller.Control;
|
|
|
-import ui.controller.UpdateController;
|
|
|
import ui.model.DecoratedState;
|
|
|
import ui.model.Model;
|
|
|
import ui.model.Model.FairnessModel;
|
|
|
-import ui.view.CreateNewDialog.Option;
|
|
|
+import ui.view.canvas.AbstractCanvas;
|
|
|
+import ui.view.canvas.Canvas;
|
|
|
+import ui.view.canvas.GroupNodeCanvas;
|
|
|
+import ui.view.component.ButtonTabComponent;
|
|
|
+import ui.view.dialog.AboutUsPopUp;
|
|
|
+import ui.view.dialog.AddObjectPopUp;
|
|
|
+import ui.view.dialog.BackgroundPopUp;
|
|
|
+import ui.view.dialog.CanvasResizePopUp;
|
|
|
+import ui.view.dialog.CreateNewDialog;
|
|
|
+import ui.view.dialog.CreateNewDialog.Option;
|
|
|
+import ui.view.dialog.EditEdgesPopUp;
|
|
|
+import ui.view.dialog.SearchPopUp;
|
|
|
+import ui.view.window.AddOnWindow;
|
|
|
+import ui.view.window.FlexWindow;
|
|
|
+import ui.view.window.Outliner;
|
|
|
import utility.ImageImport;
|
|
|
|
|
|
/**
|
|
@@ -158,11 +168,8 @@ public class GUI {
|
|
|
private final JTabbedPane tabbedPaneOriginal = new JTabbedPane(JTabbedPane.TOP);
|
|
|
private final JPopupMenu popmenuEdit = new JPopupMenu();
|
|
|
private final JMenuItem editItem = new JMenuItem("Edit Object");
|
|
|
- private final JLabel maxGraph = new JLabel("100%");
|
|
|
- private final JLabel medGraph = new JLabel("50%");
|
|
|
- private final JLabel minGraph = new JLabel("0%");
|
|
|
+
|
|
|
private final JLabel elementGraph = new JLabel("None ");
|
|
|
- private final ArrayList<HolonElement> selectedElements = new ArrayList<>();
|
|
|
private final JTree categoryTree = new JTree();
|
|
|
/******************************************
|
|
|
************* Right Container*************
|
|
@@ -176,16 +183,10 @@ public class GUI {
|
|
|
private final int distanceBetweenElementsAndGraph = 350;
|
|
|
|
|
|
// Prechoosed local Periods
|
|
|
- private String[] comboContext = { "", "5", "10", "20", "100", "1000" };
|
|
|
- private JComboBox<String> localPeriodInput = new JComboBox<String>(comboContext);
|
|
|
- JButton resetButton = new JButton("", new ImageIcon(ImageImport.loadImage("/Images/resetIcon3.png")));
|
|
|
- ImageIcon localPeriodButtonImage = new ImageIcon(
|
|
|
- GrayFilter.createDisabledImage(ImageImport.loadImage("/Images/Graph.png")));
|
|
|
- private JButton localPeriodButton = new JButton("", localPeriodButtonImage);
|
|
|
- private final JPanel graphLabel = new JPanel();
|
|
|
+
|
|
|
private final JScrollPane scrollProperties = new JScrollPane();
|
|
|
// In this section is the graph for the selected HolonElement of the clicked
|
|
|
- private final JScrollPane scrollGraph = new JScrollPane();
|
|
|
+
|
|
|
private final Model model;
|
|
|
private final Control controller;
|
|
|
|
|
@@ -202,12 +203,10 @@ public class GUI {
|
|
|
private final JMenuItem mItemObject = new JMenuItem("Object");
|
|
|
private final JMenuItem mItemSwitch = new JMenuItem("Switch");
|
|
|
private final JButton btnDel = new JButton();
|
|
|
- private final JButton btnAddHolEL = new JButton();
|
|
|
- private final JButton btnDelHolEL = new JButton();
|
|
|
|
|
|
private final JToolBar toolBar = new JToolBar();
|
|
|
private final JToolBar toolBarHolonEl = new JToolBar();
|
|
|
- private final JToolBar toolBarGraph = new JToolBar();
|
|
|
+
|
|
|
// Languages
|
|
|
private final Canvas canvas;
|
|
|
private final UnitGraph unitGraph;
|
|
@@ -219,28 +218,17 @@ public class GUI {
|
|
|
private final JMenuItem mntmFindReplace = new JMenuItem("Find/ Replace");
|
|
|
private final JMenuItem mntmAlignAll = new JMenuItem("Align All");
|
|
|
private final JMenuItem mntmResetCategory = new JMenuItem("Reset Categories");
|
|
|
- private final String[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Flexibility active", "Quantity",
|
|
|
- "Activated" };
|
|
|
- private final String[] columnNamesSingle = { "Nr.", "Device", "Energy", "Flexibility active", "Quantity",
|
|
|
- "Activated" };
|
|
|
- private final ArrayList<PropertyTable> tables = new ArrayList<>();
|
|
|
- private final UpdateController updCon;
|
|
|
- // for doubleclick
|
|
|
- private boolean click = false;
|
|
|
// TODO make GUI a JFRAME and remove holegJFrame
|
|
|
private JFrame holegJFrame;
|
|
|
|
|
|
// tabbedPaneOriginal or tabbedPaneSplit
|
|
|
private JTabbedPane tabTemp;
|
|
|
- private boolean initSplit = true;
|
|
|
private String catOfObjToBeEdited;
|
|
|
private GroupNodeCanvas unc;
|
|
|
private JPanel contentPane;
|
|
|
- private String holonEleNamesDisplayed = "None ";
|
|
|
// Pop up Windows
|
|
|
private AddObjectPopUp addObjectPopUP;
|
|
|
private AboutUsPopUp aboutUsPopUp;
|
|
|
- private AddElementPopUp addElementPopUp;
|
|
|
// variables
|
|
|
private boolean dragging = false;
|
|
|
private String actualObjectClicked;
|
|
@@ -275,11 +263,10 @@ public class GUI {
|
|
|
inspector = new Inspector(control);
|
|
|
control.setGui(this);
|
|
|
control.calculateStateAndVisualForCurrentTimeStep();
|
|
|
- this.unitGraph = new UnitGraph(model, control);
|
|
|
+ this.unitGraph = new UnitGraph(control);
|
|
|
this.canvas = new Canvas(model, control, unitGraph);
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
|
- updCon = new UpdateController(model, controller);
|
|
|
control.OnCategoryChanged.addListener(() -> this.updateCategoryUI(model.getCategories()));
|
|
|
}
|
|
|
|
|
@@ -464,7 +451,6 @@ public class GUI {
|
|
|
}
|
|
|
|
|
|
model.getSelectedObjects().clear();
|
|
|
- hideScrollGraph();
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -750,131 +736,14 @@ public class GUI {
|
|
|
**********************/
|
|
|
|
|
|
panelHolonEl.setLayout(new BoxLayout(panelHolonEl, BoxLayout.X_AXIS));
|
|
|
- toolBarHolonEl.add(btnAddHolEL);
|
|
|
- toolBarHolonEl.add(btnDelHolEL);
|
|
|
toolBarHolonEl.setFloatable(false);
|
|
|
panelHolonEl.add(toolBarHolonEl);
|
|
|
|
|
|
- // Set up of the Properties section
|
|
|
-
|
|
|
- scrollGraph.setViewportView(unitGraph);
|
|
|
- graphLabel.setLayout(new BorderLayout(0, 10));
|
|
|
- graphLabel.add(maxGraph, BorderLayout.NORTH);
|
|
|
- graphLabel.add(medGraph, BorderLayout.CENTER);
|
|
|
- graphLabel.add(minGraph, BorderLayout.SOUTH);
|
|
|
-
|
|
|
- toolBarGraph.setFloatable(false);
|
|
|
- toolBarGraph.setAlignmentY(Component.RIGHT_ALIGNMENT);
|
|
|
-
|
|
|
- localPeriodButton.setToolTipText("Toggle Local/Global Mode");
|
|
|
- toolBarGraph.add(localPeriodButton);
|
|
|
- // ComboBox
|
|
|
- localPeriodInput.setEditable(true);
|
|
|
- localPeriodInput.setVisible(false);
|
|
|
- localPeriodInput.setMaximumSize(new Dimension(20, 23));
|
|
|
- localPeriodInput.addItemListener(aListener -> {
|
|
|
- if (aListener.getStateChange() == ItemEvent.DESELECTED) {
|
|
|
- validateInput(localPeriodInput.getEditor().getItem().toString(), true);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- toolBarGraph.add(localPeriodInput);
|
|
|
-
|
|
|
- // localPeriodButtonFunction
|
|
|
- localPeriodButton.addActionListener(actionEvent -> {
|
|
|
- boolean newState = !localPeriodInput.isVisible();
|
|
|
- changeLocalPeriodButtonAppeareance(newState);
|
|
|
- unitGraph.setUseLocalPeriod(newState);
|
|
|
- });
|
|
|
-
|
|
|
- toolBarGraph.add(Box.createHorizontalGlue());
|
|
|
- resetButton.setToolTipText("Reset");
|
|
|
- resetButton.addActionListener(actionEvent -> unitGraph.reset());
|
|
|
- toolBarGraph.add(resetButton);
|
|
|
-
|
|
|
- scrollGraph.setRowHeaderView(graphLabel);
|
|
|
- scrollGraph.setColumnHeaderView(toolBarGraph);
|
|
|
+
|
|
|
|
|
|
- tables.add(model.getSingleTable());
|
|
|
- tables.add(model.getMultiTable());
|
|
|
- /***********************
|
|
|
- * HolonElement Table Actions
|
|
|
- **********************/
|
|
|
- /*
|
|
|
- * Add HolonElement to given HolonObject
|
|
|
- */
|
|
|
- btnAddHolEL.addActionListener(actionEvent -> {
|
|
|
- if (model.getSelectedObjects().size() == 1) {
|
|
|
- AbstractCanvasObject tempCpsObject = updCon.getActualCps();
|
|
|
- if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
|
|
|
- && tempCpsObject.getId() != 0) {
|
|
|
- addElementPopUp = new AddElementPopUp(holegJFrame);
|
|
|
- addElementPopUp.setActualHolonObject((HolonObject) updCon.getActualCps());
|
|
|
- addElementPopUp.setVisible(true);
|
|
|
- HolonElement ele = addElementPopUp.getElement();
|
|
|
- if (ele != null) {
|
|
|
- controller.addElementCanvasObject(tempCpsObject.getId(), ele.getEleName(), ele.getEnergy(),
|
|
|
- ele.getId());
|
|
|
- }
|
|
|
- controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
|
|
|
- triggerUpdateController(null);
|
|
|
- contentPane.updateUI();
|
|
|
- }
|
|
|
- } else {
|
|
|
- JOptionPane.showMessageDialog(contentPane, "No object selected.\nPlease select a object first.",
|
|
|
- "Message", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- }
|
|
|
- });
|
|
|
- btnAddHolEL.setIcon(new ImageIcon(ImageImport.loadImage("Images/plus.png", 16, 16)));
|
|
|
- btnAddHolEL.setToolTipText("<html><b>Add Element</b><br>Add a new HolonElement to the HolonObject.</html>");
|
|
|
|
|
|
- /*
|
|
|
- * Delete the chosen HolonElement of the selected HolonObject, Multi-Selection
|
|
|
- * for CpsObjects as well as for HolonElements possible
|
|
|
- */
|
|
|
- btnDelHolEL.addActionListener(actionEvent -> {
|
|
|
- // For Single Selection of CpsObject
|
|
|
- if (model.getSelectedObjects().size() == 1) {
|
|
|
- if (updCon.getActualCps().getClass() == HolonObject.class) {
|
|
|
- HolonObject obj = (HolonObject) updCon.getActualCps();
|
|
|
- if (selectedElements.isEmpty()) {
|
|
|
- JOptionPane.showMessageDialog(contentPane,
|
|
|
- "No element selectet.\nPlease select a element in the list first.", "Message",
|
|
|
- JOptionPane.INFORMATION_MESSAGE);
|
|
|
- }
|
|
|
- for (HolonElement e : selectedElements) {
|
|
|
- controller.deleteElementCanvas(obj.getId(), e.getId());
|
|
|
- controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
- triggerUpdateController(null);
|
|
|
- contentPane.updateUI();
|
|
|
- // Names displayed in graph are not updated
|
|
|
- }
|
|
|
- model.getEleToDelete().clear();
|
|
|
- selectedElements.clear();
|
|
|
- }
|
|
|
- // For MultiSelection of CpsObject
|
|
|
- } else if (model.getSelectedObjects().size() > 1) {
|
|
|
- for (Integer i : model.getEleToDelete().keySet()) {
|
|
|
- for (HolonElement e : model.getEleToDelete().get(i)) {
|
|
|
- controller.deleteElementCanvas(i, e.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- triggerUpdateController(null);
|
|
|
- model.getEleToDelete().clear();
|
|
|
- selectedElements.clear();
|
|
|
- } else {
|
|
|
- JOptionPane.showMessageDialog(contentPane, "No object selectet.\nPlease select a object first.",
|
|
|
- "No object selectet", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- }
|
|
|
- triggerUpdateController(null);
|
|
|
- elementGraph.setText("None");
|
|
|
- holonEleNamesDisplayed = "None";
|
|
|
- });
|
|
|
- btnDelHolEL.setIcon(new ImageIcon(ImageImport.loadImage("Images/minus.png", 16, 16)));
|
|
|
- btnDelHolEL.setToolTipText(
|
|
|
- "<html><b>Remove Element</b><br>Removes the selected HolonElement from the HolonObject.</html>");
|
|
|
|
|
|
+
|
|
|
/***********************
|
|
|
* HolonElement Graph Actions
|
|
|
**********************/
|
|
@@ -1124,8 +993,6 @@ public class GUI {
|
|
|
.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
|
|
|
if (selectedNode.getLevel() == 2) {
|
|
|
controller.searchCategoryObject(selectedNode.getParent().toString(), selectedNode.toString());
|
|
|
- updCon.deleteRows(model.getSingleTable());
|
|
|
- updCon.deleteRows(model.getMultiTable());
|
|
|
// if (selected instanceof HolonObject && selected !=
|
|
|
// null) {
|
|
|
// selected = (HolonObject) selected;
|
|
@@ -1328,7 +1195,6 @@ public class GUI {
|
|
|
controller.setSelectedObjectID(0);
|
|
|
controller.setSelecteEdge(null);
|
|
|
controller.setCurIteration(0);
|
|
|
- hideScrollGraph();
|
|
|
elementGraph.setText("None");
|
|
|
canvas.tempCps = null;
|
|
|
canvas.repaint();
|
|
@@ -1426,7 +1292,6 @@ public class GUI {
|
|
|
|
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
canvas.repaint();
|
|
|
- hideScrollGraph();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -1447,7 +1312,6 @@ public class GUI {
|
|
|
|
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
|
canvas.repaint();
|
|
|
- hideScrollGraph();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -1486,19 +1350,16 @@ public class GUI {
|
|
|
|
|
|
splitGraphHolonEl.setTopComponent(inspector);
|
|
|
splitGraphHolonEl.setDividerLocation(distanceBetweenElementsAndGraph);
|
|
|
- splitGraphHolonEl.setBottomComponent(scrollGraph);
|
|
|
canvasSP.setViewportView(canvas);
|
|
|
|
|
|
tabbedPaneOriginal.setBorder(null);
|
|
|
scrollProperties.setBorder(null);
|
|
|
- scrollGraph.setBorder(null);
|
|
|
splitPane.setBorder(null);
|
|
|
splitPane1.setBorder(null);
|
|
|
splitHolonElPro.setBorder(null);
|
|
|
splitGraphHolonEl.setBorder(null);
|
|
|
panelHolonEl.setBorder(null);
|
|
|
canvasSP.setBorder(null);
|
|
|
- hideScrollGraph();
|
|
|
|
|
|
holegJFrame.getContentPane().add(timePanel, BorderLayout.SOUTH);
|
|
|
|
|
@@ -1598,19 +1459,6 @@ public class GUI {
|
|
|
out.update();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void showScrollGraph() {
|
|
|
- scrollGraph.setVisible(true);
|
|
|
- splitGraphHolonEl.setBottomComponent(scrollGraph);
|
|
|
- splitGraphHolonEl.setDividerLocation(distanceBetweenElementsAndGraph);
|
|
|
- }
|
|
|
-
|
|
|
- private void hideScrollGraph() {
|
|
|
- scrollGraph.setVisible(false);
|
|
|
- splitGraphHolonEl.remove(scrollGraph);
|
|
|
- splitGraphHolonEl.setDividerLocation(0);
|
|
|
- }
|
|
|
-
|
|
|
private boolean isUpperPanelInsideBounds() {
|
|
|
int x = holegJFrame.getX();
|
|
|
int y = holegJFrame.getY();
|
|
@@ -1688,28 +1536,6 @@ public class GUI {
|
|
|
holegJFrame.setVisible(value);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Checks if a double click was made.
|
|
|
- *
|
|
|
- * @return true if doublecklick, false if not
|
|
|
- */
|
|
|
- private boolean doubleClick() {
|
|
|
- if (click) {
|
|
|
- click = false;
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- click = true;
|
|
|
- Timer t = new Timer("doubleclickTimer", false);
|
|
|
- t.schedule(new TimerTask() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- click = false;
|
|
|
- }
|
|
|
- }, 350);
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
/*
|
|
|
* Open a new Tab with an UpperNodeCanvas
|
|
|
*/
|
|
@@ -1831,67 +1657,8 @@ public class GUI {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void triggerUpdateController(AbstractCanvasObject temp) {
|
|
|
- if (model != null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (temp != null) {
|
|
|
- updCon.paintProperties(temp);
|
|
|
- }
|
|
|
- updCon.refreshTableProperties(model.getPropertyTable());
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
- /**
|
|
|
- * This Method updates the UnitGraph, saves the old LocalModeState and load the
|
|
|
- * new LocalModeState.
|
|
|
- *
|
|
|
- * @param element The new Element to load the UnitGraph
|
|
|
- */
|
|
|
- private void updateUnitGraph(GraphEditable element) {
|
|
|
- // SaveOld LocalMode State.
|
|
|
- if (localPeriodInput.isVisible()) {
|
|
|
- // Save Old State
|
|
|
- validateInput(localPeriodInput.getEditor().getItem().toString(), false);
|
|
|
- }
|
|
|
- // Update UnitGraph
|
|
|
- unitGraph.initNewElement(element);
|
|
|
- // Load LocalMode State.
|
|
|
- changeLocalPeriodButtonAppeareance(unitGraph.isUsingLocalPeriod());
|
|
|
- localPeriodInput.getEditor().setItem(unitGraph.getLocalPeriod());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Displayed the actual LocalModeState.
|
|
|
- *
|
|
|
- * @param enabled
|
|
|
- */
|
|
|
- private void changeLocalPeriodButtonAppeareance(boolean enabled) {
|
|
|
- localPeriodInput.setVisible(enabled);
|
|
|
- if (enabled) {
|
|
|
- localPeriodButtonImage.setImage(ImageImport.loadImage("/Images/Graph.png"));
|
|
|
- } else {
|
|
|
- localPeriodButtonImage.setImage(GrayFilter.createDisabledImage(ImageImport.loadImage("/Images/Graph.png")));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Validate the LocalMode Input and when its valid save on the Element.
|
|
|
- *
|
|
|
- * @param text the inputText to validate.
|
|
|
- * @param bShowMessage when true, open a MessageDialog when text invalid.
|
|
|
- */
|
|
|
- private void validateInput(String text, boolean bShowMessage) {
|
|
|
- int localPeriodInputValue;
|
|
|
- try {
|
|
|
- localPeriodInputValue = Integer.parseInt(text);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- if (bShowMessage)
|
|
|
- JOptionPane.showMessageDialog(contentPane,
|
|
|
- '"' + text + '"' + " is not a valid Input. \n Use whole numbers.");
|
|
|
- return;
|
|
|
- }
|
|
|
- unitGraph.setLocalPeriod(localPeriodInputValue);
|
|
|
- }
|
|
|
|
|
|
private void openWebpage(String URL) {
|
|
|
try {
|