Procházet zdrojové kódy

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

Teh-Hai Julian Zheng před 8 roky
rodič
revize
2352c6d978

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

@@ -77,7 +77,7 @@ public class HolonCanvasController {
 		// adding new HolonBodys
 		for (int i = bodies.size(); i < subCount; i++) {
 			float radius = (subnets.get(i).getObjects().size() * 5 + 10) * HolonBodyScale / 100;
-			HolonBody temp = new HolonBody((float) (center.width + Math.pow(-1, i)), center.height + 1, radius,
+			HolonBody temp = new HolonBody((float) (center.width + Math.pow(-1, i)), (float)(center.height + Math.pow(-1, i)), radius,
 					(float) Math.pow((subnets.get(i).getObjects().size() + 1) * 5, 3), model.getSubNetColors().get(i));
 			temp.setId(i);
 			bodies.add(temp);

+ 7 - 7
src/ui/view/FlexibleData.java

@@ -16,7 +16,7 @@ public class FlexibleData extends JPanel {
 	private JLabel lblProdConsVal;
 	private JPanel subnetColorPanel;
 	public FlexibleData(String name, float prod, float cons, float maxProd, float maxCons) {
-		setPreferredSize(new Dimension(563, 100));
+		setPreferredSize(new Dimension(570, 100));
 		setMinimumSize(new Dimension(550, 100));
 		setLayout(null);
 		
@@ -28,22 +28,22 @@ public class FlexibleData extends JPanel {
 		
 		JLabel lblFlProd = new JLabel("Flex. Prod.:");
 		lblFlProd.setForeground(new Color(0, 204, 51));
-		lblFlProd.setBounds(31, 46, 64, 27);
+		lblFlProd.setBounds(10, 46, 85, 27);
 		add(lblFlProd);
 		
 		JLabel lblFlexCons = new JLabel("Flex. Cons.:\r\n");
 		lblFlexCons.setForeground(new Color(255, 0, 0));
-		lblFlexCons.setBounds(188, 46, 64, 27);
+		lblFlexCons.setBounds(188, 46, 85, 27);
 		add(lblFlexCons);
 		
 		JLabel lblProdCons = new JLabel("Prod./Cons.:");
 		lblProdCons.setForeground(new Color(218, 165, 32));
-		lblProdCons.setBounds(348, 46, 85, 27);
+		lblProdCons.setBounds(365, 46, 113, 27);
 		add(lblProdCons);
 		
 		prodVal = new JProgressBar();
 		setProd(maxProd, prod);
-		prodVal.setBounds(94, 46, 85, 24);
+		prodVal.setBounds(94, 48, 85, 24);
 		prodVal.setBorder(new EmptyBorder(0, 0, 0, 0));
 		prodVal.setStringPainted(true);
 		prodVal.setForeground(new Color(0, 204, 51));
@@ -51,7 +51,7 @@ public class FlexibleData extends JPanel {
 		
 		consVal = new JProgressBar();
 		setCons(maxCons, cons);
-		consVal.setBounds(253, 46, 85, 24);
+		consVal.setBounds(270, 46, 85, 24);
 		consVal.setBorder(new EmptyBorder(0, 0, 0, 0));
 		consVal.setStringPainted(true);
 		consVal.setForeground(Color.RED);
@@ -59,7 +59,7 @@ public class FlexibleData extends JPanel {
 		
 		lblProdConsVal = new JLabel();
 		setProdConsVal(prod, cons);
-		lblProdConsVal.setBounds(415, 46, 103, 24);
+		lblProdConsVal.setBounds(453, 46, 103, 24);
 		add(lblProdConsVal);
 		
 		subnetColorPanel = new JPanel();

+ 2 - 2
src/ui/view/HolonCanvas.java

@@ -141,7 +141,7 @@ public class HolonCanvas extends JPanel implements MouseWheelListener, MouseList
 			totalElapsedTime = 0;
 		}
 
-		// check if HolonBodys should bes sorted after size
+		// check if HolonBodys should be sorted after size
 		if (chckbxSort.isSelected() && sizeChange) {
 			hCController.rearrangeAfterSize();
 			sizeChange = false;
@@ -171,7 +171,7 @@ public class HolonCanvas extends JPanel implements MouseWheelListener, MouseList
 		this.g2.fillRect(0, 0, getWidth(), getHeight());
 
 		bodies = hCController.getBodies();
-		// Render Game Objects
+		// Render Objects
 		for (int i = 0; i < subCount; i++) {
 			bodyNr = bodies.get(i).getId();
 			switch (comboChoice) {

+ 11 - 6
src/ui/view/UnitGraph.java

@@ -203,9 +203,14 @@ 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++) {
-					line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
-							pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
-							pointList.get(i + 1).getY() * scaleY);
+					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);
+					} else {
+						line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
+								pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
+								pointList.get(i + 1).getY() * scaleY);
+					}
 					graphCurve.append(line, true);
 				}
 				g2.draw(graphCurve);
@@ -484,8 +489,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			if (deletePoint && tempP.getX() != 0
 					&& (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
 				int i = pointList.indexOf(tempP);
-				//If Right, else if Left
-				if (tempP.getY() == (int) (height / 6) && i < pointList.size() - 1 && i>0) {
+				// If Right, else if Left
+				if (tempP.getY() == (int) (height / 6) && i < pointList.size() - 1 && i > 0) {
 					pointList.remove(i);
 					pointList.remove(i - 1);
 					pointList.remove(i - 2);
@@ -682,7 +687,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 */
 	public void fillArrayofBooleans() {
 		for (int i = 0; i < arrayOfBooleans.length; i++) {
-			int t = (int) getYValueAt2((int) (i * width / (model.getIterations() - 1)));
+			int t = (int) getYValueAt((int) (i * width / (model.getIterations() - 1)));
 			if (t <= height / 2) {
 				arrayOfBooleans[i] = true;
 			} else {