Browse Source

fix und canvas size

Kevin Trometer 8 years ago
parent
commit
017030693a

+ 1 - 1
src/api/CpsAPI.java

@@ -1,4 +1,4 @@
-package API;
+package api;
 
 import java.awt.Color;
 import java.util.ArrayList;

+ 1 - 1
src/api/CpsAlgorithm.java

@@ -1,4 +1,4 @@
-package API;
+package api;
 /**
  * API Class for the CpsAlgorithm.
  * 

+ 1 - 1
src/interfaces/CategoryListener.java

@@ -1,4 +1,4 @@
-package Interfaces;
+package interfaces;
 
 import java.util.ArrayList;
 

+ 1 - 1
src/interfaces/ObjectListener.java

@@ -1,4 +1,4 @@
-package Interfaces;
+package interfaces;
 
 import java.util.ArrayList;
 

+ 2 - 2
src/ui/controller/CanvasController.java

@@ -9,8 +9,8 @@ import classes.AbstractCpsObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Position;
-import Interfaces.CategoryListener;
-import Interfaces.ObjectListener;
+import interfaces.CategoryListener;
+import interfaces.ObjectListener;
 import ui.model.Model;
 
 /**

+ 1 - 1
src/ui/controller/CategoryController.java

@@ -8,7 +8,7 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
-import Interfaces.CategoryListener;
+import interfaces.CategoryListener;
 import ui.model.Model;
 
 /**

+ 21 - 1
src/ui/controller/Control.java

@@ -12,7 +12,7 @@ import classes.CpsNode;
 import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
-import Interfaces.CategoryListener;
+import interfaces.CategoryListener;
 import ui.model.Model;
 import ui.view.MyCanvas;
 
@@ -640,4 +640,24 @@ public class Control {
 	public void setIsSimulation(boolean b) {
 		globalController.setIsSimulation(b);
 	}
+	
+	/**
+	 * Set the Canvas X Size.
+	 * 
+	 * @param canvasX the cANVAS_X to set
+	 */
+	public void setCanvasX(int canvasX) {
+		globalController.setCanvasX(canvasX);
+	}
+
+
+	/**
+	 * Set the Canvas Y Size.
+	 * 
+	 * @param canvasY the cANVAS_Y to set
+	 */
+	public void setCanvasY(int canvasY) {
+		globalController.setCanvasY(canvasY);
+	}
+	
 }

+ 10 - 19
src/ui/controller/GlobalController.java

@@ -99,30 +99,21 @@ public class GlobalController {
 	}
 
 	/**
-	 * @return the cANVAS_X
+	 * Set the Canvas X Size.
+	 * 
+	 * @param canvasX the cANVAS_X to set
 	 */
-	public int getCANVAS_X() {
-		return model.getCANVAS_X();
+	public void setCanvasX(int canvasX) {
+		model.setCanvasX(canvasX);
 	}
 
-	/**
-	 * @param cANVAS_X the cANVAS_X to set
-	 */
-	public void setCANVAS_X(int cANVAS_X) {
-		model.setCANVAS_X(cANVAS_X);
-	}
 
 	/**
-	 * @return the cANVAS_Y
-	 */
-	public int getCANVAS_Y() {
-		return model.getCANVAS_Y();
-	}
-
-	/**
-	 * @param cANVAS_Y the cANVAS_Y to set
+	 * Set the Canvas Y Size.
+	 * 
+	 * @param canvasY the cANVAS_Y to set
 	 */
-	public void setCANVAS_Y(int cANVAS_Y) {
-		model.setCANVAS_Y(cANVAS_Y);
+	public void setCanvasY(int canvasY) {
+		model.setCanvasY(canvasY);
 	}
 }

+ 2 - 2
src/ui/controller/StoreController.java

@@ -54,8 +54,8 @@ public class StoreController {
 
 		json.put("MODE", "ALL");
 		json.put("ID", IdCounter.getCounter());
-		json.put("SIZEX", model.getCANVAS_X());
-		json.put("SIZEY", model.getCANVAS_Y());
+		json.put("SIZEX", model.getCanvasX());
+		json.put("SIZEY", model.getCanvasY());
 		writeCategory(json);
 		writeCategoryObjects(json);
 		writeCanvasObjects(json);

+ 22 - 14
src/ui/model/Model.java

@@ -9,8 +9,8 @@ import classes.Category;
 import classes.CpsEdge;
 import classes.AbstractCpsObject;
 import classes.HolonElement;
-import Interfaces.CategoryListener;
-import Interfaces.ObjectListener;
+import interfaces.CategoryListener;
+import interfaces.ObjectListener;
 import ui.view.Console;
 
 /**
@@ -23,8 +23,8 @@ import ui.view.Console;
 public class Model {
 
 	// Global Variables
-	private int CANVAS_X;
-	private int CANVAS_Y;
+	private int canvasX = 1000;
+	private int canvasY = 1000;
 	private static int sCALE = 50; // Picture Scale
 	private static int sCALEdIV2 = sCALE / 2;
 	private static final int ITERATIONS = 100;
@@ -521,30 +521,38 @@ public class Model {
 	}
 
 	/**
+	 * Get Canvas X Size.
+	 * 
 	 * @return the cANVAS_X
 	 */
-	public int getCANVAS_X() {
-		return CANVAS_X;
+	public int getCanvasX() {
+		return canvasX;
 	}
 
 	/**
-	 * @param cANVAS_X the cANVAS_X to set
+	 * Set Canvas X Size.
+	 * 
+	 * @param canvasX the cANVAS_X to set
 	 */
-	public void setCANVAS_X(int cANVAS_X) {
-		CANVAS_X = cANVAS_X;
+	public void setCanvasX(int canvasX) {
+		this.canvasX = canvasX;
 	}
 
 	/**
+	 * get Canvas Y size.
+	 * 
 	 * @return the cANVAS_Y
 	 */
-	public int getCANVAS_Y() {
-		return CANVAS_Y;
+	public int getCanvasY() {
+		return canvasY;
 	}
 
 	/**
-	 * @param cANVAS_Y the cANVAS_Y to set
+	 * Set Canvas Y size.
+	 * 
+	 * @param canvasY the cANVAS_Y to set
 	 */
-	public void setCANVAS_Y(int cANVAS_Y) {
-		CANVAS_Y = cANVAS_Y;
+	public void setCanvasY(int canvasY) {
+		this.canvasY = canvasY;
 	}
 }

+ 7 - 3
src/ui/view/GUI.java

@@ -60,6 +60,8 @@ 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;
@@ -69,7 +71,7 @@ import classes.HolonSwitch;
 import classes.HolonTransformer;
 import classes.IdCounter;
 import classes.IdCounterElem;
-import Interfaces.CategoryListener;
+import interfaces.CategoryListener;
 import ui.controller.Control;
 import ui.model.Model;;
 
@@ -525,8 +527,10 @@ public class GUI<E> implements CategoryListener {
 				myPanel.add(field1);
 				myPanel.add(field2);
 				JOptionPane.showMessageDialog(null, myPanel);
+				controller.setCanvasX(Integer.parseInt(field1.getText()));
+				controller.setCanvasY(Integer.parseInt(field2.getText()));
 				canvas.setPreferredSize(
-						new Dimension(Integer.parseInt(field1.getText()), Integer.parseInt(field2.getText())));
+						new Dimension(model.getCanvasX(), model.getCanvasY()));
 				canvas.repaint();
 			}
 		});
@@ -552,7 +556,7 @@ public class GUI<E> implements CategoryListener {
 		mnHelp.add(aboutUs);
 
 		canvas.setBackground(Color.WHITE);
-		canvas.setPreferredSize(new Dimension(1000, 1000));
+		canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
 
 		/********************
 		 * RIGHT CONTAINER (INFORMATION)