Prechádzať zdrojové kódy

scrolling with mouse, touchpad and touch

Kevin Trometer 7 rokov pred
rodič
commit
a9b34c5f00
1 zmenil súbory, kde vykonal 9 pridanie a 1 odobranie
  1. 9 1
      src/ui/view/HolonCanvas.java

+ 9 - 1
src/ui/view/HolonCanvas.java

@@ -6,6 +6,8 @@ import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.awt.ScrollPane;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
 import java.util.ArrayList;
 
 import javax.swing.JPanel;
@@ -18,7 +20,7 @@ import classes.SubNet;
 import ui.controller.Control;
 import ui.model.Model;
 
-public class HolonCanvas extends JPanel {
+public class HolonCanvas extends JPanel implements MouseWheelListener {
 
 	/**
 	 * 
@@ -56,6 +58,7 @@ public class HolonCanvas extends JPanel {
 		currentTime = previousTime;
 		totalElapsedTime = 0;
 		frameCount = 0;
+		this.addMouseWheelListener(this);
 	}
 
 	// Start Render and Update Threads
@@ -230,4 +233,9 @@ public class HolonCanvas extends JPanel {
 		center.width /= 2;
 	}
 
+	@Override
+	public void mouseWheelMoved(MouseWheelEvent e) {
+		controller.setHolonBodyScale(model.getHolonBodyScale()+(-e.getScrollAmount()*e.getWheelRotation()));
+	}
+
 }