Procházet zdrojové kódy

Fixed a bug with switches.

I did not notice the bug earlier, because it was caused by the fix for
multiselecting HolonElements.
Ludwig Tietze před 6 roky
rodič
revize
49704f36fa
2 změnil soubory, kde provedl 8 přidání a 5 odebrání
  1. 2 2
      src/ui/view/GUI.java
  2. 6 3
      src/ui/view/UnitGraph.java

+ 2 - 2
src/ui/view/GUI.java

@@ -1724,8 +1724,8 @@ public class GUI implements CategoryListener {
 					 */
 					if(e.getKeyCode() == KeyEvent.VK_ENTER)
 						unitGraph.setLocalPeriod(localLength);						
-				}catch(Exception ex){
-					unitGraphLocalPeriod.setBackground(Color.RED);
+				}catch(NumberFormatException ex){
+					unitGraphLocalPeriod.setBackground(PALE_RED);
 				}
 				
 			}

+ 6 - 3
src/ui/view/UnitGraph.java

@@ -627,8 +627,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param s which should be visualized
      */
     public void repaintWithNewSwitch(HolonSwitch s) {
-    	current=s;
+    	
         //arrayOfBooleans = s.getValueArray();
+    	current=s;
         pointList = s.getGraphPoints();
         isSwitch = true;
         isElement = false;
@@ -849,7 +850,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param localPeriod
      */
     public void setLocalPeriod(int localPeriod){
-    	for(IGraphedElement e:tempElements)e.setLocalPeriod(localPeriod);
+    	if(isElement)for(IGraphedElement e:tempElements)e.setLocalPeriod(localPeriod);
+    	else if(isSwitch)current.setLocalPeriod(localPeriod);
     }
     
     /**
@@ -866,7 +868,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     }
     
     public void setStretching(boolean b){
-    	for(IGraphedElement e:tempElements)e.setStretching(b);
+    	if(isElement)for(IGraphedElement e:tempElements)e.setStretching(b);
+    	else if(isSwitch)current.setStretching(b);
     }
     
     static int lv=0;