|
@@ -1,10 +1,8 @@
|
|
|
package api;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
-import java.awt.Component;
|
|
|
import java.awt.Dimension;
|
|
|
import java.awt.FlowLayout;
|
|
|
-import java.awt.image.BufferedImage;
|
|
|
import java.io.BufferedWriter;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
@@ -16,7 +14,6 @@ import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
-import java.util.LinkedHashSet;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
@@ -29,13 +26,11 @@ import java.util.stream.Collectors;
|
|
|
import javax.swing.BorderFactory;
|
|
|
import javax.swing.Box;
|
|
|
import javax.swing.BoxLayout;
|
|
|
-import javax.swing.ImageIcon;
|
|
|
import javax.swing.JButton;
|
|
|
import javax.swing.JCheckBox;
|
|
|
import javax.swing.JFileChooser;
|
|
|
import javax.swing.JFormattedTextField;
|
|
|
import javax.swing.JLabel;
|
|
|
-import javax.swing.JOptionPane;
|
|
|
import javax.swing.JPanel;
|
|
|
import javax.swing.JProgressBar;
|
|
|
import javax.swing.JScrollPane;
|
|
@@ -46,7 +41,6 @@ import classes.Category;
|
|
|
import classes.Edge;
|
|
|
import classes.GroupNode;
|
|
|
import classes.Flexibility;
|
|
|
-import classes.HolonElement;
|
|
|
import classes.HolonObject;
|
|
|
import classes.HolonSwitch;
|
|
|
import classes.IdCounterElem;
|
|
@@ -54,12 +48,9 @@ import classes.Node;
|
|
|
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.DecoratedState;
|
|
|
-import ui.model.IntermediateCableWithState;
|
|
|
import ui.model.Model;
|
|
|
-import ui.model.DecoratedCable.CableState;
|
|
|
import ui.model.DecoratedHolonObject.HolonObjectState;
|
|
|
import ui.model.DecoratedSwitch.SwitchState;
|
|
|
import ui.model.DecoratedNetwork;
|
|
@@ -126,6 +117,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
LinkedList<ParameterStepping> parameterSteppingList= new LinkedList<ParameterStepping>();
|
|
|
protected boolean useStepping = false;
|
|
|
+ //SwitchButton
|
|
|
|
|
|
|
|
|
|
|
@@ -179,6 +171,13 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
|
|
|
private JPanel createButtonPanel() {
|
|
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
|
|
|
|
|
+ JButton toggleSwitchesButton = new JButton("Toggle Switches");
|
|
|
+ toggleSwitchesButton.setToolTipText("Set all switches active or inactive.");
|
|
|
+ toggleSwitchesButton.addActionListener(actionEvent -> toggleSwitches());
|
|
|
+ buttonPanel.add(toggleSwitchesButton);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
JButton resetButton = new JButton("Reset");
|
|
|
resetButton.setToolTipText("Resets the State to before the Algorithm has runed.");
|
|
|
resetButton.addActionListener(actionEvent -> reset());
|
|
@@ -216,6 +215,22 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
|
|
|
|
|
|
//ParameterImports
|
|
|
|
|
|
+ private void toggleSwitches() {
|
|
|
+ List<HolonSwitch> allSwitchList = control.getModel().getAllSwitches();
|
|
|
+ if(allSwitchList.isEmpty()) return;
|
|
|
+ boolean set = allSwitchList.get(0).getState(control.getModel().getCurIteration());
|
|
|
+ allSwitchList.forEach(hSwitch -> {
|
|
|
+ hSwitch.setManualMode(true);
|
|
|
+ hSwitch.setManualState(!set);
|
|
|
+ });
|
|
|
+ updateVisual();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//int
|
|
|
protected void addIntParameter(String parameterName, int parameterValue, Consumer<Integer> setter, Supplier<Integer> getter) {
|
|
|
this.addIntParameter(parameterName, parameterValue, setter, getter, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
|
@@ -825,7 +840,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
|
|
|
}
|
|
|
IndexCable cable = new IndexCable(index0, index1);
|
|
|
//if cable is in existing cables
|
|
|
- if(cableSet.contains(cable) || addedIndexCable.values().contains(cable)) {
|
|
|
+ if(cableSet.contains(cable) || addedIndexCable.keySet().contains(cable)) {
|
|
|
return;
|
|
|
}
|
|
|
generateEdgeFromIndexCable(cable, switchBetween);
|