فهرست منبع

unitgraph update when loading, copy-pasted

Teh-Hai Julian Zheng 7 سال پیش
والد
کامیت
b4c372b92c
4فایلهای تغییر یافته به همراه23 افزوده شده و 11 حذف شده
  1. 5 1
      src/ui/controller/SaveController.java
  2. 5 4
      src/ui/view/GUI.java
  3. 8 5
      src/ui/view/MyCanvas.java
  4. 5 1
      src/ui/view/UpperNodeCanvas.java

+ 5 - 1
src/ui/controller/SaveController.java

@@ -193,7 +193,7 @@ public class SaveController {
 			}
 		}
 	}
-
+	
 	/**
 	 * Travers through all Objects via BFS and Stores everything relevant
 	 * 
@@ -239,6 +239,10 @@ public class SaveController {
 
 	}
 
+	private void storeStatistics(JsonObject file) {
+		
+	}
+
 	/**
 	 * Save wanted Data
 	 * 

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

@@ -291,9 +291,10 @@ public class GUI<E> implements CategoryListener {
 		statSplitPane = new StatPanel2(controller);
 		model.addGraphListener(statSplitPane);
 		statScrollPane = new JScrollPane(statSplitPane);
-		this.canvas = new MyCanvas(model, control);
-		this.holonCanvas = new HolonCanvas(model, control);
 		this.unitGraph = new UnitGraph(model, control);
+		this.canvas = new MyCanvas(model, control, unitGraph);
+		this.holonCanvas = new HolonCanvas(model, control);
+
 		control.initListener(this);
 		controller.setCanvas(canvas);
 		model.setConsole(console);
@@ -2108,9 +2109,9 @@ public class GUI<E> implements CategoryListener {
 			tabTemp = tabbedPane2;
 		}
 			if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport().getComponent(0) instanceof MyCanvas) {
-			unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp, "");
+			unc = new UpperNodeCanvas(model, controller, unitGraph, (CpsUpperNode) temp, "");
 		} else {
-			unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp,
+			unc = new UpperNodeCanvas(model, controller, unitGraph, (CpsUpperNode) temp,
 					((UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
 							.getComponent(0)).path + " -> ");
 		}

+ 8 - 5
src/ui/view/MyCanvas.java

@@ -64,6 +64,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	private float scalediv20;
 	private Position unPos;
 	private ArrayList<Position> savePos;
+	private UnitGraph unitGraph;
 
 	private UpdateController updCon;
 
@@ -117,11 +118,13 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	 *            the Model
 	 * @param control
 	 *            the Controller
+	 * @param unitGraph 
 	 */
-	public MyCanvas(Model mod, Control control) {
+	public MyCanvas(Model mod, Control control, UnitGraph unitGraph) {
 		toolTip = false;
 		this.controller = control;
 		this.model = mod;
+		this.unitGraph = unitGraph;
 
 		scalediv20 = model.getScale() / 20;
 
@@ -341,8 +344,9 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					if (cps instanceof CpsUpperNode) {
 						JTabbedPane tabbedPane = (JTabbedPane) getParent().getParent().getParent();
 						for (int i = 4; i < tabbedPane.getTabCount(); i++) {
-							if (tabbedPane.getComponentAt(i) != null && ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
-									.getComponent(0)).upperNode.getId() == cps.getId()) {
+							if (tabbedPane.getComponentAt(i) != null
+									&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
+											.getComponent(0)).upperNode.getId() == cps.getId()) {
 								tabbedPane.remove(i);
 								break;
 							}
@@ -360,7 +364,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				controller.cut(null);
-				;
 				itemPaste.setEnabled(true);
 				repaint();
 			}
@@ -380,7 +383,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			public void actionPerformed(ActionEvent e) {
 				try {
 					controller.paste(null, mousePosition);
-					
+					unitGraph.update(model.getSelectedCpsObjects());
 				} catch (JsonParseException | UnsupportedFlavorException | IOException e1) {
 					// TODO Auto-generated catch block
 					JLabel message = new JLabel("The Clipboard information cannot be pastet into Application.");

+ 5 - 1
src/ui/view/UpperNodeCanvas.java

@@ -117,6 +117,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 	private int animSteps = animDuration / animDelay; // animation Steps;
 	private Position unPos;
 	private ArrayList<Position> savePos;
+	private UnitGraph unitGraph;
 
 	/**
 	 * Constructor.
@@ -125,12 +126,14 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 	 *            the Model
 	 * @param control
 	 *            the Controller
+	 * @param unitGraph 
 	 */
-	public UpperNodeCanvas(Model mod, Control control, CpsUpperNode UpperNode, String parentPath) {
+	public UpperNodeCanvas(Model mod, Control control, UnitGraph unitGraph, CpsUpperNode UpperNode, String parentPath) {
 		toolTip = false;
 
 		this.controller = control;
 		this.model = mod;
+		this.unitGraph = unitGraph;
 
 		this.upperNode = UpperNode;
 		this.path = parentPath + upperNode.getName();
@@ -394,6 +397,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 			public void actionPerformed(ActionEvent e) {
 				try {
 					controller.paste(upperNode, mousePosition);
+					unitGraph.update(model.getSelectedCpsObjects());
 				} catch (JsonParseException | UnsupportedFlavorException | IOException e1) {
 					// TODO Auto-generated catch block
 					JLabel message = new JLabel("The Clipboard information cannot be pastet into Application.");