Jelajahi Sumber

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

Kevin Trometer 7 tahun lalu
induk
melakukan
7212a44dcf
3 mengubah file dengan 18 tambahan dan 3 penghapusan
  1. 0 1
      src/ui/view/GUI.java
  2. 1 2
      src/ui/view/MyCanvas.java
  3. 17 0
      src/ui/view/TimePanel.java

+ 0 - 1
src/ui/view/GUI.java

@@ -1168,7 +1168,6 @@ public class GUI<E> implements CategoryListener {
 					int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
 					if (updCon.getActualCps() != null && selValueX != 0) {
 						temp = model.getPropertyTable().getValueAt(selValueY, selValueX);
-						System.out.println(temp);
 						if (updCon.getActualCps() instanceof HolonSwitch) {
 							btemp = model.getPropertyTable().getValueAt(mousePos.y / tableProperties.getRowHeight(),
 									mousePos.x / (tableProperties.getWidth() / 2));

+ 1 - 2
src/ui/view/MyCanvas.java

@@ -555,8 +555,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			// Border Highlighting
 			if (showedInformation[3]) {
 				g2.setColor(cps.getBorderColor());
-				if (!(cps instanceof CpsNode)){
-					//if (g2.getColor() != Color.WHITE) {
+					if (g2.getColor() != Color.WHITE && !(cps instanceof CpsNode)) {
 						g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
 								(int) (cps.getPosition().y - controller.getScaleDiv2() - scalediv20 - 3),
 								(int) (controller.getScale() + ((scalediv20 + 3) * 2)),

+ 17 - 0
src/ui/view/TimePanel.java

@@ -21,6 +21,10 @@ import javax.swing.event.CaretEvent;
 import javax.swing.event.CaretListener;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.plaf.SliderUI;
+import javax.swing.plaf.basic.BasicSliderUI;
+import javax.swing.plaf.metal.MetalSliderUI;
+import javax.swing.plaf.synth.SynthSliderUI;
 
 import ui.controller.Control;
 import ui.model.Model;
@@ -208,6 +212,19 @@ public class TimePanel extends JPanel {
 
 		this.add(timeBtnPanel, BorderLayout.WEST);
 		this.add(timeSlider);
+		
+		// Make the slider jump to mouse position on left click
+		timeSlider.setUI(new SynthSliderUI(timeSlider) {
+		    protected void scrollDueToClickInTrack(int direction) {
+		        int value = timeSlider.getValue(); 
+		        if (timeSlider.getOrientation() == JSlider.HORIZONTAL) {
+		            value = this.valueForXPosition(timeSlider.getMousePosition().x);
+		        } else if (timeSlider.getOrientation() == JSlider.VERTICAL) {
+		            value = ((BasicSliderUI)this).valueForYPosition(timeSlider.getMousePosition().y);
+		        }
+		        timeSlider.setValue(value);
+		    }
+		});
 	}
 
 	/**