浏览代码

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

Teh-Hai Julian Zheng 8 年之前
父节点
当前提交
0628044ca0
共有 4 个文件被更改,包括 47 次插入8 次删除
  1. 3 3
      src/ui/view/AlgorithmMenu.java
  2. 8 0
      src/ui/view/Console.java
  3. 20 4
      src/ui/view/GUI.java
  4. 16 1
      src/ui/view/UnitGraph.java

+ 3 - 3
src/ui/view/AlgorithmMenu.java

@@ -178,16 +178,16 @@ public class AlgorithmMenu extends JMenu {
 			if (t instanceof CpsAlgorithm) {
 				controller.setAlgorithm(t);
 			} else {
-				JOptionPane.showMessageDialog(null, "Class does not Implement CpsAlgorithm!", "Error!",
+				JOptionPane.showMessageDialog(null, "Class does not implement CpsAlgorithm!", "Error!",
 						JOptionPane.ERROR_MESSAGE);
 				noneItem.doClick();
 			}
 		} catch (Exception e) {
 			if (missingCompiler) {
-				JOptionPane.showMessageDialog(null, "Missing Compiiler! Please install JDK!", "Error!",
+				JOptionPane.showMessageDialog(null, "Missing Compiiler! Please install the JDK!", "Error!",
 						JOptionPane.ERROR_MESSAGE);
 			} else if (instantiationError) {
-				JOptionPane.showMessageDialog(null, "Class does not Implement CpsAlgorithm!", "Error!",
+				JOptionPane.showMessageDialog(null, "Class does not implement CpsAlgorithm!", "Error!",
 						JOptionPane.ERROR_MESSAGE);
 				noneItem.doClick();
 			} else {

+ 8 - 0
src/ui/view/Console.java

@@ -147,4 +147,12 @@ public class Console extends JScrollPane {
 	public void clearConsole() {
 		consoleText.setText("");
 	}
+	
+	/**
+	 * get the Console TextPane
+	 * @return 
+	 */
+	public JTextPane getConsoleText(){
+		return this.consoleText;
+	}
 }

+ 20 - 4
src/ui/view/GUI.java

@@ -578,16 +578,20 @@ public class GUI<E> implements CategoryListener {
 										.getComponent(0)).upperNode,
 								((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
 										.getComponent(0)).getMousePosition());
+						unitGraph.update(model.getSelectedCpsObjects());
+						((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport().getComponent(0))
+								.repaint();
 					} else {
 						controller.paste(null, canvas.getMousePosition());
 						unitGraph.update(model.getSelectedCpsObjects());
+						canvas.repaint();
 					}
 				} catch (HeadlessException | JsonParseException | UnsupportedFlavorException | IOException e1) {
 					// TODO Auto-generated catch block
 					JLabel message = new JLabel("The Clipboard information cannot be pasted into Application.");
 					JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE);
 				}
-				canvas.repaint();
+
 			}
 		};
 		actionMap.put(cntrlVDown, controlV);
@@ -1322,14 +1326,14 @@ public class GUI<E> implements CategoryListener {
 		/****************
 		 * Tree Stuff
 		 ****************/
-		
-		//Override Key Actions
+
+		// Override Key Actions
 		inputMap = tree.getInputMap();
 		inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
 		inputMap.put(KeyStroke.getKeyStroke("control V"), cntrlVDown);
 		inputMap.put(KeyStroke.getKeyStroke("control X"), cntrlXDown);
 		inputMap.put(KeyStroke.getKeyStroke("control A"), cntrlADown);
-		
+
 		TreeCellRenderer customRenderer = new TreeCellRenderer() {
 			@Override
 			public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
@@ -1982,6 +1986,18 @@ public class GUI<E> implements CategoryListener {
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
 
+		//focus canvas so copy/paste/cut and select all works
+		MouseAdapter focusCanvas = new MouseAdapter() {
+			@Override
+			public void mouseExited(MouseEvent e) {
+				contentPane.requestFocus();
+			}
+		};
+		
+		model.getTableHolonElement().addMouseListener(focusCanvas);
+		tableProperties.addMouseListener(focusCanvas);
+		console.getConsoleText().addMouseListener(focusCanvas);
+		
 		try {
 			controller.loadAutoSave(System.getProperty("user.home") + "/.config/HolonGUI/Category/Category.json");
 		} catch (IOException e1) {

+ 16 - 1
src/ui/view/UnitGraph.java

@@ -203,9 +203,22 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				g2.setStroke(new BasicStroke(2));
 				g2.setColor(Color.BLACK);
 				for (int i = 0; i < pointList.size() - 1; i++) {
+					// Left out of bounce
 					if ((i == 1 || i == 2) && pointList.get(i).getX() < 0) {
 						line = new Line2D.Double(border, pointList.get(i).getY() * scaleY, border,
 								pointList.get(i + 1).getY() * scaleY);
+					}
+					// Right out of bounce
+					else if (i == pointList.size() - 4 && pointList.get(pointList.size() - 3).getX() > width) {
+						line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
+								pointList.get(i).getY() * scaleY, this.getWidth() - border,
+								pointList.get(i + 1).getY() * scaleY);
+					} else if (i == pointList.size() - 3 && pointList.get(pointList.size() - 3).getX() > width) {
+						line = new Line2D.Double(this.getWidth() - border, pointList.get(i).getY() * scaleY,
+								this.getWidth() - border, pointList.get(i + 1).getY() * scaleY);
+					} else if (i == pointList.size() - 2 && pointList.get(pointList.size() - 2).getX() > width) {
+						line = new Line2D.Double(this.getWidth() - border, pointList.get(i).getY() * scaleY,
+								pointList.get(i + 1).getX() * scaleX + border, pointList.get(i + 1).getY() * scaleY);
 					} else {
 						line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
 								pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
@@ -243,7 +256,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 
 			}
 			// When the switch graph is dragged
-			if (tempP != null && pointDrag) {
+			if (tempP != null && pointDrag)
+
+			{
 				try {
 					int i;
 					for (i = 0; (i * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)