Kevin Trometer 8 роки тому
батько
коміт
9fc4349625

+ 8 - 3
src/classes/HolonSwitch.java

@@ -68,10 +68,15 @@ public class HolonSwitch extends AbstractCpsObject {
 	public HolonSwitch(AbstractCpsObject obj) {
 		super(obj);
 		super.setName(obj.getName());
-		setManualState(true);
+		setManualState(((HolonSwitch)obj).getActiveManual());
 		setAutoState(true);
-		setActiveAt(true);
-		setManualMode(false);
+		for (int i = 0; i < activeAt.length; i++) {
+			activeAt[i] = ((HolonSwitch)obj).getActiveAt()[i];
+		}
+		for (Point p :((HolonSwitch)obj).getGraphPoints()) {
+			
+		}
+		setManualMode(((HolonSwitch)obj).getManualMode());
 	}
 
 	/**

+ 0 - 5
src/ui/controller/CanvasController.java

@@ -141,7 +141,6 @@ public class CanvasController {
 	 *            the mouse Position
 	 */
 	public void pasteObjects(Point p) {
-		System.out.println("paste");
 		model.getSelectedCpsObjects().clear();
 		AbstractCpsObject tCps = null;
 		int x = Integer.MAX_VALUE, y = Integer.MAX_VALUE;
@@ -176,7 +175,6 @@ public class CanvasController {
 		// Edges
 		boolean newEdge = true;
 		for (AbstractCpsObject cps : model.getClipboradObjects()) {
-			System.out.println("Object edges: " + cps.getConnectedTo().size());
 			for (CpsEdge e : cps.getConnectedTo()) {
 				// A and B of e in the copied Elements?
 				if (model.getClipboradObjects().indexOf(e.getA()) != -1
@@ -187,19 +185,16 @@ public class CanvasController {
 					for (CpsEdge et : tempList.get(model.getClipboradObjects().indexOf(cps)).getConnectedTo()) {
 						for (CpsEdge etA : et.getA().getConnectedTo()) {
 							if (et.getA() == a && et.getB() == b) {
-								System.out.println("false");
 								newEdge = false;
 							}
 						}
 						for (CpsEdge etB : et.getB().getConnectedTo()) {
 							if (et.getA() == a && et.getB() == b) {
-								System.out.println("false");
 								newEdge = false;
 							}
 						}
 					}
 					if (newEdge) {
-						System.out.println("new edge");
 						CpsEdge tempE = new CpsEdge(tempList.get(model.getClipboradObjects().indexOf(e.getA())), // A
 								tempList.get(model.getClipboradObjects().indexOf(e.getB())), /* B */
 								e.getCapacity());

+ 21 - 23
src/ui/view/GUI.java

@@ -60,8 +60,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeCellRenderer;
 
-import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
-
 import classes.Category;
 import classes.CpsEdge;
 import classes.AbstractCpsObject;
@@ -102,7 +100,7 @@ public class GUI<E> implements CategoryListener {
 	private final JMenuItem canvasSize = new JMenuItem("View Size");
 	private final JSplitPane splitPane = new JSplitPane();
 	private final JSplitPane splitPane1 = new JSplitPane();
-	private final JSplitPane splitPaneTreeConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+	private final JSplitPane splitPaneCanvasConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
 
 	private final JScrollPane canvasSP = new JScrollPane();
 	private final JScrollPane scrollPane1 = new JScrollPane();
@@ -305,7 +303,6 @@ public class GUI<E> implements CategoryListener {
 						}
 					}
 					unitGraph.empty();
-					controller.addTextToConsole("undo", Color.BLACK, 12, false, false, true);
 				} catch (IOException eex) {
 					// TODO Auto-generated catch block
 					eex.printStackTrace();
@@ -339,7 +336,6 @@ public class GUI<E> implements CategoryListener {
 						}
 					}
 					unitGraph.empty();
-					controller.addTextToConsole("redo", Color.BLACK, 12, false, false, true);
 				} catch (IOException ex) {
 					// TODO Auto-generated catch block
 					ex.printStackTrace();
@@ -529,8 +525,7 @@ public class GUI<E> implements CategoryListener {
 				JOptionPane.showMessageDialog(null, myPanel);
 				controller.setCanvasX(Integer.parseInt(field1.getText()));
 				controller.setCanvasY(Integer.parseInt(field2.getText()));
-				canvas.setPreferredSize(
-						new Dimension(model.getCanvasX(), model.getCanvasY()));
+				canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
 				canvas.repaint();
 			}
 		});
@@ -913,7 +908,7 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
 					boolean leaf, int row, boolean hasFocus) {
-				JLabel label = new JLabel(); 
+				JLabel label = new JLabel();
 				Image imgR = null;
 				if (leaf) {
 					for (Category cat : model.getCategories()) {
@@ -1481,12 +1476,12 @@ public class GUI<E> implements CategoryListener {
 		splitPane.setRightComponent(splitPane1);
 		splitPane.setDividerLocation(200);
 		splitPane1.setDividerLocation(500);
-		splitPaneTreeConsole.setDividerLocation(500);
+		splitPaneCanvasConsole.setDividerLocation(500);
 
-		splitPane.setLeftComponent(splitPaneTreeConsole);
-		splitPaneTreeConsole.setLeftComponent(scrollPane1);
-		splitPaneTreeConsole.setRightComponent(console);
-		splitPane1.setLeftComponent(canvasSP);
+		splitPane.setLeftComponent(scrollPane1);
+		splitPaneCanvasConsole.setLeftComponent(canvasSP);
+		splitPaneCanvasConsole.setRightComponent(console);
+		splitPane1.setLeftComponent(splitPaneCanvasConsole);
 		splitPane1.setRightComponent(splitHolonElPro);
 
 		splitHolonElPro.setDividerLocation(400);
@@ -1505,7 +1500,7 @@ public class GUI<E> implements CategoryListener {
 		scrollElements.setBorder(null);
 		splitPane.setBorder(null);
 		splitPane1.setBorder(null);
-		splitPaneTreeConsole.setBorder(null);
+		splitPaneCanvasConsole.setBorder(null);
 		splitHolonElPro.setBorder(null);
 		splitGraphHolonEl.setBorder(null);
 		panelHolonEl.setBorder(null);
@@ -1513,16 +1508,17 @@ public class GUI<E> implements CategoryListener {
 		tableHolonElementScrollPane.setBorder(null);
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
-		
+
 		String autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
 		File dest = new File(autoPath);
-		if(dest.listFiles().length>1){
+		if (dest.listFiles().length > 1) {
 			int dialogButton = JOptionPane.YES_NO_OPTION;
-			int dialogResult = JOptionPane.showConfirmDialog (null, "Old autosave file was found, should it be loaded?", "Warning",dialogButton);
-			if(dialogResult == JOptionPane.YES_OPTION){
-				model.setAutoSaveNr(dest.listFiles().length-1);
+			int dialogResult = JOptionPane.showConfirmDialog(null, "Old autosave file was found, should it be loaded?",
+					"Warning", dialogButton);
+			if (dialogResult == JOptionPane.YES_OPTION) {
+				model.setAutoSaveNr(dest.listFiles().length - 1);
 				mntmRedo.doClick();
-			}else{
+			} else {
 				controller.deleteDirectory(dest);
 				dest.mkdirs();
 				try {
@@ -1532,7 +1528,7 @@ public class GUI<E> implements CategoryListener {
 					e1.printStackTrace();
 				}
 			}
-			
+
 		}
 	}
 
@@ -1792,8 +1788,10 @@ public class GUI<E> implements CategoryListener {
 	/**
 	 * Adds a Popup.
 	 * 
-	 * @param component Component
-	 * @param popup PopupMenu
+	 * @param component
+	 *            Component
+	 * @param popup
+	 *            PopupMenu
 	 */
 	private static void addPopup(Component component, final JPopupMenu popup) {
 		component.addMouseListener(new MouseAdapter() {