Tom Troppmann il y a 6 ans
Parent
commit
457fae9750
3 fichiers modifiés avec 43 ajouts et 6 suppressions
  1. 8 2
      src/classes/HolonElement.java
  2. 7 2
      src/classes/HolonSwitch.java
  3. 28 2
      src/ui/view/UnitGraph.java

+ 8 - 2
src/classes/HolonElement.java

@@ -2,6 +2,7 @@ package classes;
 
 import com.google.gson.annotations.Expose;
 
+import interfaces.GraphEditable;
 import interfaces.IGraphedElement;
 import ui.model.Model;
 import ui.view.IndexTranslator;
@@ -9,7 +10,6 @@ import ui.view.UnitGraph;
 
 import java.awt.*;
 import java.awt.geom.Point2D;
-import java.util.Iterator;
 import java.util.LinkedList;
 
 /**
@@ -18,7 +18,7 @@ import java.util.LinkedList;
  *
  * @author Gruppe14
  */
-public class HolonElement implements IGraphedElement{
+public class HolonElement implements IGraphedElement, GraphEditable{
 
     /** Points on the UnitGraph */
     private LinkedList<Point> graphPoints;
@@ -454,4 +454,10 @@ public class HolonElement implements IGraphedElement{
 	public void setTestGraphPoints(LinkedList<Point2D.Double> testGraphPoints) {
 		this.testGraphPoints = testGraphPoints;
 	}
+
+
+	@Override
+	public Graphtype getGraphType() {
+		return Graphtype.floatGraph;
+	}
 }

+ 7 - 2
src/classes/HolonSwitch.java

@@ -4,7 +4,7 @@ import java.awt.Point;
 import java.util.LinkedList;
 
 import com.google.gson.annotations.Expose;
-
+import interfaces.GraphEditable;
 import interfaces.IGraphedElement;
 import ui.controller.SingletonControl;
 import ui.view.IndexTranslator;
@@ -16,7 +16,7 @@ import ui.view.UnitGraph;
  * @author Gruppe14
  *
  */
-public class HolonSwitch extends AbstractCpsObject implements IGraphedElement {
+public class HolonSwitch extends AbstractCpsObject implements IGraphedElement, GraphEditable {
 
 	/**
 	 * The class HolonSwitch represents an Object in the system, that has the
@@ -277,4 +277,9 @@ public class HolonSwitch extends AbstractCpsObject implements IGraphedElement {
 	public void setStretching(boolean stretch) {
 		this.stretch=stretch;
 	}
+
+	@Override
+	public Graphtype getGraphType() {
+		return Graphtype.boolGraph;
+	}
 }

+ 28 - 2
src/ui/view/UnitGraph.java

@@ -12,6 +12,7 @@ import java.awt.event.*;
 import java.awt.geom.CubicCurve2D;
 import java.awt.geom.GeneralPath;
 import java.awt.geom.Line2D;
+import java.awt.geom.Path2D;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -58,6 +59,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     private int textWidth = 0;
     
 	private IGraphedElement current;
+	
+	//NEW ERA
+	
+	
+	
 
     /**
      * Constructor.
@@ -85,8 +91,26 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
     public void paintComponent(Graphics g) {
         super.paintComponent(g);
-//        
-//        System.out.println("paint");
+        
+        System.out.println("paint");
+        Graphics2D g2D = (Graphics2D) g;
+        g2D.setColor(Color.BLACK);
+        int höhe = this.getHeight();
+        int breite = this.getWidth();
+        g2D.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
+        g2D.setStroke(new BasicStroke(1));
+       // g2D.drawLine(0, 0,breite, höhe);
+        //generate Path --> maybe als Methode auslagern
+        
+        //Good Source for basic understanding for Bezier Curves
+        //http://www.theappguruz.com/blog/bezier-curve-in-games
+        
+        
+        Path2D.Double mypath = new Path2D.Double();
+        mypath.moveTo(0, 0);
+        mypath.curveTo(breite, breite, breite, breite, breite, höhe);
+        
+        g2D.draw(mypath);
 //        g2 = (Graphics2D) g;
 //        RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 //        g2.setRenderingHints(rh);
@@ -528,6 +552,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     public void componentResized(ComponentEvent e) {
     	System.out.println("componentResized");
         // Wenn ein anderes Element genommen wird
+    	/*
         if (init) {
             init = false;
             // for scale on the first initialisation
@@ -546,6 +571,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
         // Scale
         scaleX = (this.getWidth() - (border * 2)) / width;
         scaleY = (this.getHeight() - (border * 2)) / height;
+        */
         repaint();
     }