Browse Source

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons

dominik.rieder 7 years ago
parent
commit
743bcb9895
2 changed files with 15 additions and 6 deletions
  1. 11 2
      src/ui/view/TimePanel.java
  2. 4 4
      src/ui/view/UnitGraph.java

+ 11 - 2
src/ui/view/TimePanel.java

@@ -5,6 +5,8 @@ import java.awt.Color;
 import java.awt.Image;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 
 
 import javax.swing.ImageIcon;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JButton;
@@ -94,6 +96,13 @@ public class TimePanel extends JPanel {
 			}
 			}
 		});
 		});
 
 
+		timeSlider.addMouseListener(new MouseAdapter() {
+			@Override
+			public void mousePressed(MouseEvent e) {
+				controller.resetSimulation();
+			}
+		});
+
 		// Panel
 		// Panel
 		timeBtnPanel.setBorder(null);
 		timeBtnPanel.setBorder(null);
 		timeBtnPanel.setBackground(Color.WHITE);
 		timeBtnPanel.setBackground(Color.WHITE);
@@ -134,7 +143,7 @@ public class TimePanel extends JPanel {
 			public void actionPerformed(ActionEvent ae) {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getMinimum());
 				timeSlider.setValue(timeSlider.getMinimum());
 				controller.setCurIteration(timeSlider.getValue());
 				controller.setCurIteration(timeSlider.getValue());
-				//controller.calculateStateForCurrentTimeStep();
+				// controller.calculateStateForCurrentTimeStep();
 				controller.resetSimulation();
 				controller.resetSimulation();
 			}
 			}
 		});
 		});
@@ -170,7 +179,7 @@ public class TimePanel extends JPanel {
 		/*
 		/*
 		 * the backwards button isnt used anymore
 		 * the backwards button isnt used anymore
 		 */
 		 */
-		//timeBtnPanel.add(timeBackwardBtn);
+		// timeBtnPanel.add(timeBackwardBtn);
 		timeBtnPanel.add(timeForwardBtn);
 		timeBtnPanel.add(timeForwardBtn);
 
 
 		this.add(timeBtnPanel, BorderLayout.WEST);
 		this.add(timeBtnPanel, BorderLayout.WEST);

+ 4 - 4
src/ui/view/UnitGraph.java

@@ -517,8 +517,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void reset() {
 	public void reset() {
 		pointList.removeAll(pointList);
 		pointList.removeAll(pointList);
 		if (isSwitch) {
 		if (isSwitch) {
-			pointList.addFirst(new Point(0, (int)(height/6)));
-			pointList.addLast(new Point((int) (this.getWidth() / scaleX), (int)(height-height/6)));
+			pointList.addFirst(new Point(-4, (int)(height/6)));
+			pointList.addLast(new Point((int) (width)+4, (int) (height / 6)));
 		} else {
 		} else {
 			pointList.addFirst(new Point(0, 0));
 			pointList.addFirst(new Point(0, 0));
 			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
 			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
@@ -582,8 +582,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		isElement = false;
 		isElement = false;
 		// First time clicked on the Element
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 		if (pointList.isEmpty()) {
-			pointList.addFirst(new Point(0, (int) (height / 6)));
-			pointList.addLast(new Point((int) (width), (int) (height / 6)));
+			pointList.addFirst(new Point(-4, (int) (height / 6)));
+			pointList.addLast(new Point((int) (width)+4, (int) (height / 6)));
 		}
 		}
 		repaint();
 		repaint();
 	}
 	}