Jelajahi Sumber

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

dominik.rieder 7 tahun lalu
induk
melakukan
743bcb9895
2 mengubah file dengan 15 tambahan dan 6 penghapusan
  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.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 
 import javax.swing.ImageIcon;
 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
 		timeBtnPanel.setBorder(null);
 		timeBtnPanel.setBackground(Color.WHITE);
@@ -134,7 +143,7 @@ public class TimePanel extends JPanel {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getMinimum());
 				controller.setCurIteration(timeSlider.getValue());
-				//controller.calculateStateForCurrentTimeStep();
+				// controller.calculateStateForCurrentTimeStep();
 				controller.resetSimulation();
 			}
 		});
@@ -170,7 +179,7 @@ public class TimePanel extends JPanel {
 		/*
 		 * the backwards button isnt used anymore
 		 */
-		//timeBtnPanel.add(timeBackwardBtn);
+		// timeBtnPanel.add(timeBackwardBtn);
 		timeBtnPanel.add(timeForwardBtn);
 
 		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() {
 		pointList.removeAll(pointList);
 		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 {
 			pointList.addFirst(new Point(0, 0));
 			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
@@ -582,8 +582,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		isElement = false;
 		// First time clicked on the Element
 		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();
 	}