Browse Source

set bordercolor

Kevin Trometer 8 years ago
parent
commit
2ea4798547
2 changed files with 39 additions and 17 deletions
  1. 17 9
      src/classes/CpsObject.java
  2. 22 8
      src/ui/view/UnitGraph.java

+ 17 - 9
src/classes/CpsObject.java

@@ -27,7 +27,6 @@ public abstract class CpsObject {
 	/* a Tag that can be used */
 	ArrayList<Integer> tags;
 
-
 	/**
 	 * Constructor for an CpsObejct with an unique ID
 	 */
@@ -149,6 +148,15 @@ public abstract class CpsObject {
 		return BorderColor;
 	}
 
+	/**
+	 * Set the Border Color of this CpsObject
+	 * 
+	 * @param the BorderColor
+	 */
+	public void setBorderColor(Color c) {
+		this.BorderColor = c;
+	}
+
 	/**
 	 * @param Color
 	 *            the Color to set
@@ -156,20 +164,20 @@ public abstract class CpsObject {
 	public void setConnections(Color color) {
 		this.BorderColor = color;
 	}
-	
-	public void addTag(int tag){
+
+	public void addTag(int tag) {
 		this.tags.add(tag);
 	}
-	
-	public ArrayList<Integer> getTag(){
+
+	public ArrayList<Integer> getTag() {
 		return tags;
 	}
-	
-	public void resetTags(){
+
+	public void resetTags() {
 		this.tags = new ArrayList<Integer>();
 	}
-	
-	public void setTags(ArrayList<Integer> tags){
+
+	public void setTags(ArrayList<Integer> tags) {
 		this.tags = tags;
 	}
 }

+ 22 - 8
src/ui/view/UnitGraph.java

@@ -19,8 +19,6 @@ import java.awt.Point;
 
 import javax.swing.JPanel;
 
-import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
-
 import classes.HolonElement;
 import ui.controller.Control;
 import ui.model.Model;
@@ -33,12 +31,17 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	private static final long serialVersionUID = 1L;
 	private float MAXIMUM = 0;
 
+	// Information shown when a Point is Dragged
+	private String dragInformation = "";
+
+	// Points
 	private Point recSize = new Point(8, 8); // Point Size
 	private Graphics2D g2;
 	private CubicCurve2D c = new CubicCurve2D.Double();
 	private CubicCurve2D cr = new CubicCurve2D.Double();
 	private CubicCurve2D cl = new CubicCurve2D.Double();
 	private LinkedList<Point> pointList;
+	// Scale for the Graph
 	private double scaleX;
 	private double scaleY;
 
@@ -52,7 +55,6 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	private boolean isSwitch = false;
 
 	private ArrayList<HolonElement> tempElements = new ArrayList<>();
-	private HolonSwitch tempSwitch;
 	private Model model;
 	private Control controller;
 	private Line2D.Double line = null;
@@ -105,6 +107,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 		if (isElement) {
 			// array fillen
 			fillArrayofValue();
+	
 			if (arrayOfFloats != null) {
 				// Draw the Lines
 				g2.setStroke(new BasicStroke(2));
@@ -130,6 +133,12 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 							this.getHeight() - 10);
 				}
 			}
+			//drag Information
+			if (tempP != null) {
+				dragInformation = "" + convertToValueY(getYValueAt((int) tempP.getX()));
+				g2.drawString(dragInformation, (int) (tempP.getX()* scaleX)+10, (int) (tempP.getY()* scaleY)+10);
+			}
+			
 			/*
 			 * // Actual Iteration Point Visualization g2.setColor(Color.RED);
 			 * if (arrayOfValue != null) { for (int i = 0; i <
@@ -169,7 +178,12 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 							this.getHeight() - 10);
 				}
 			}
+			if (tempP != null) {
+				dragInformation = "model.get";
+				g2.drawString(dragInformation, (int) (getMousePosition().getX())+10, (int) (getMousePosition().getY())+10);
+			}
 		}
+		
 		// Iteration Line
 		g2.setColor(Color.BLUE);
 		g2.setStroke(new BasicStroke(1));
@@ -212,6 +226,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 				x = tempP.getX();
 			}
 			tempP.setLocation(x, y);
+
 			repaint();
 		}
 	}
@@ -334,7 +349,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 		boolean deletePoint = false;
 
 		double x = e.getX() / scaleX;
-		double y = e.getY() / scaleY;
+		e.getY();
 
 		// Halbe Iterations Distanz
 		double dist = (width / (model.getIterations() - 1)) / 2;
@@ -407,6 +422,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 			pointDrag = false;
 			tempP = null;
 		}
+		dragInformation = "";
 	}
 
 	public void componentResized(ComponentEvent e) {
@@ -443,12 +459,11 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	}
 
 	/*
-	 * Emptys the Graph
+	 * Empty the Graph
 	 */
 	public void empty() {
 		pointList = null;
 		tempElements = null;
-		tempSwitch = null;
 		arrayOfFloats = null;
 		arrayOfBooleans = null;
 		isSwitch = false;
@@ -501,7 +516,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 		isSwitch = false;
 		isElement = true;
 		MAXIMUM = selectedElement.get(selectedElement.size() - 1).getEnergy();
-  		// First time clicked on the Element
+		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 			pointList.addFirst(new Point(0, 0));
 			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
@@ -517,7 +532,6 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	 */
 	public void repaintWithNewSwitch(HolonSwitch s) {
 		arrayOfBooleans = s.getActiveAt();
-		tempSwitch = s;
 		pointList = s.getGraphPoints();
 		isSwitch = true;
 		isElement = false;