Browse Source

fixed IntelliJ inspection warnings

I. Dix 7 years ago
parent
commit
d601300e4b
1 changed files with 28 additions and 35 deletions
  1. 28 35
      src/ui/view/GUI.java

+ 28 - 35
src/ui/view/GUI.java

@@ -3,10 +3,6 @@ package ui.view;
 import java.awt.*;
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.awt.event.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyVetoException;
-import java.beans.VetoableChangeListener;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -98,7 +94,7 @@ public class GUI<E> implements CategoryListener {
     private final JMenu mnNewMenuOptions = new JMenu("Options");
     private final JMenu mnNewMenuView = new JMenu("View");
     private final JMenu mnHelp = new JMenu("Help");
-    private JCheckBox consoleLogCheckBox = new JCheckBox("Show program console log");
+    private final JCheckBox consoleLogCheckBox = new JCheckBox("Show program console log");
     private final JMenuItem mntmOpen = new JMenuItem("Open");
     private final JMenuItem mntmNew = new JMenuItem("New");
     private final JMenuItem mntmSave = new JMenuItem("Save");
@@ -118,12 +114,12 @@ public class GUI<E> implements CategoryListener {
     private JSplitPane tempSplit;
     private boolean initSplit = true;
 
-    private JPopupMenu popmenuEdit = new JPopupMenu();
-    private JMenuItem editItem = new JMenuItem("Edit Object");
+    private final JPopupMenu popmenuEdit = new JPopupMenu();
+    private final JMenuItem editItem = new JMenuItem("Edit Object");
     private String catOfObjToBeEdited;
     private FlexiblePane flexPane;
-    private StatisticPanel statSplitPane;
-    private JScrollPane statScrollPane;
+    private final StatisticPanel statSplitPane;
+    private final JScrollPane statScrollPane;
     private UpperNodeCanvas unc;
     private JPanel contentPane;
 
@@ -149,13 +145,13 @@ public class GUI<E> implements CategoryListener {
 
     // Model for single or multi selection
     private final JPanel scrollElements = new JPanel();
-    private JScrollPane tableHolonElementScrollPane = new JScrollPane();
+    private final JScrollPane tableHolonElementScrollPane = new JScrollPane();
 
     // In this section are all the properties that correspond to the clicked
     // HolonObject, such as connections, name, Type, etc.
     // Table for Properties --> Cell with (0,1) is editable by CpsObjt and
     // Cell(3,1) is editable by Edges
-    private JTable tableProperties = new JTable() {
+    private final JTable tableProperties = new JTable() {
 
         private static final long serialVersionUID = 1L;
 
@@ -177,16 +173,16 @@ public class GUI<E> implements CategoryListener {
             }
         }
     };
-    private JPanel graphLabel = new JPanel();
+    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
     // HolonObject
-    private JTable tableGraph = new JTable();
-    private DefaultTableModel tableModelGraph = new DefaultTableModel();
+    private final JTable tableGraph = new JTable();
+    private final DefaultTableModel tableModelGraph = new DefaultTableModel();
     private final JScrollPane scrollGraph = new JScrollPane();
 
-    private Model model;
+    private final Model model;
     private final Control controller;
 
     // Pop up Windows
@@ -224,10 +220,10 @@ public class GUI<E> implements CategoryListener {
     private AbstractCpsObject tempCps = null;
     private int yValueElements = 0;
 
-    private Console console = new Console();
-    private MyCanvas canvas;
-    private HolonCanvas holonCanvas;
-    private UnitGraph unitGraph;
+    private final Console console = new Console();
+    private final MyCanvas canvas;
+    private final HolonCanvas holonCanvas;
+    private final UnitGraph unitGraph;
     private final JSplitPane splitPane3 = new JSplitPane();
     private final JSlider sizeSlider = new JSlider();
     private final JLabel lblImageSize = new JLabel(Languages.getLanguage()[94]);
@@ -253,18 +249,18 @@ public class GUI<E> implements CategoryListener {
     private final JMenuItem mntmResetCategory = new JMenuItem("Reset Categories");
     private final JMenu mnLanguage = new JMenu("Language");
 
-    private String[] columnNamesMulti = {"Object", "Nr.", "Device", "Energy", "Flexibility", "Quantity", "Activated",
+    private final String[] columnNamesMulti = {"Object", "Nr.", "Device", "Energy", "Flexibility", "Quantity", "Activated",
             "Flex. activated"};
-    private String[] columnNamesSingle = {"Nr.", "Device", "Energy", "Flexibility", "Quantity", "Activated",
+    private final String[] columnNamesSingle = {"Nr.", "Device", "Energy", "Flexibility", "Quantity", "Activated",
             "Flex. activated"};
-    private ArrayList<PropertyTable> tables = new ArrayList<>();
-    private String[] comboBoxCat = {"Category", "Object", "Switch"};
+    private final ArrayList<PropertyTable> tables = new ArrayList<>();
+    private final String[] comboBoxCat = {"Category", "Object", "Switch"};
     private String warningText = "Warning";
     private String saveBeforeNew = "Do you want to save your current data?";
     private String eraseCategory = "Do you really want to delete the Category ";
     private String selectObjBeforeErase = "Please select a Category or an Object in order to delete something.";
 
-    private UpdateController updCon;
+    private final UpdateController updCon;
     private final JSplitPane splitPane_1 = new JSplitPane();
     private final JSlider holonBodySizeSlider = new JSlider();
     private final JLabel lblHolonBodySize = new JLabel("HolonBody SIze");
@@ -303,7 +299,7 @@ public class GUI<E> implements CategoryListener {
     private void initialize() {
         frmCyberPhysical = new JFrame();
         frmCyberPhysical.setTitle("Cyber Physical Systems Model");
-        frmCyberPhysical.setBounds(100, -1080, 1000, 800);
+        frmCyberPhysical.setBounds(100, 100, 1000, 800);
         frmCyberPhysical.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
         frmCyberPhysical.setExtendedState(JFrame.MAXIMIZED_BOTH);
         frmCyberPhysical.addWindowListener(new java.awt.event.WindowAdapter() {
@@ -1000,7 +996,7 @@ public class GUI<E> implements CategoryListener {
                         }
                         updCon.getActualHolonElement(null, yValueElements, 2, tables);
                     }
-                    // if no control-button pressed but a HolonElement choosen
+                    // if no control-button pressed but a HolonElement chosen
                     else {
                         selectedElements.clear();
                         selectedElements.add(ele);
@@ -1924,6 +1920,7 @@ public class GUI<E> implements CategoryListener {
 
     private void hideScrollGraph() {
         scrollGraph.setVisible(false);
+        unitGraph.empty();
         splitGraphHolonEl.remove(scrollGraph);
         splitGraphHolonEl.setDividerLocation(0);
     }
@@ -1933,7 +1930,7 @@ public class GUI<E> implements CategoryListener {
      *
      * @param dest path to save-folder
      */
-    public void setUpAutoSave(File dest) {
+    private void setUpAutoSave(File dest) {
         dest.mkdirs();
         try {
             controller.autoSave();
@@ -1949,7 +1946,7 @@ public class GUI<E> implements CategoryListener {
      * @param objType      type of the Object
      * @param selectedNode The selected Node
      */
-    public void addObjectAction(String objType, DefaultMutableTreeNode selectedNode) {
+    private void addObjectAction(String objType, DefaultMutableTreeNode selectedNode) {
         if (selectedNode == null) {
             JOptionPane.showMessageDialog(new JFrame(),
                     "Please select a Category first before adding " + objType + ".");
@@ -1985,7 +1982,7 @@ public class GUI<E> implements CategoryListener {
      *
      * @param categories the current categories
      */
-    public void updateCategories(final ArrayList<Category> categories) {
+    private void updateCategories(final ArrayList<Category> categories) {
         tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Categories") {
 
             private static final long serialVersionUID = 1L;
@@ -2076,13 +2073,9 @@ public class GUI<E> implements CategoryListener {
         canvas.updateLanguages();
 
         // Tables
-        for (int i = 0; i < columnNamesMulti.length; i++) {
-            columnNamesMulti[i] = tempArray[i + 17];
-        }
+        System.arraycopy(tempArray, 17, columnNamesMulti, 0, columnNamesMulti.length);
         model.getMultiTable().setColumnIdentifiers(columnNamesMulti);
-        for (int i = 0; i < columnNamesSingle.length; i++) {
-            columnNamesSingle[i] = tempArray[i + 18];
-        }
+        System.arraycopy(tempArray, 18, columnNamesSingle, 0, columnNamesSingle.length);
         model.getSingleTable().setColumnIdentifiers(columnNamesSingle);
         model.colNames[0] = tempArray[23];
         model.colNames[1] = tempArray[24];