diff --git a/main/DrawHalfEdge.pde b/main/DrawHalfEdge.pde index c335c73..1011e3e 100644 --- a/main/DrawHalfEdge.pde +++ b/main/DrawHalfEdge.pde @@ -4,7 +4,7 @@ public class DrawHalfEdge { line(v1.getX(), v1.getY(), v2.getX(), v2.getY()); } public void drawpoint(Vertex v) { - point(v.getX(), v.getY()); + ellipse(v.getX(), v.getY(),25,25); } public void drawGraph(ArrayList vlist) { @@ -17,13 +17,19 @@ public class DrawHalfEdge { public void drawConnectedGraph(Vertex vertex) { ArrayList edges = vertex.getAllLeavingEdges(); drawpoint(vertex); - for(HalfEdge edge: edges) { - drawConnection(edge, vertex); + if(edges != null) { + System.out.println("edges are not null"); + for(HalfEdge edge: edges) { + drawConnection(edge, vertex); + } } } public void drawConnection(HalfEdge edge, Vertex v1) { + System.out.println("drawing connection"); Vertex v2 = edge.getOrigin(); + System.out.println(v1); + System.out.println(v2); drawpoint(v2); drawline(v1, v2); } diff --git a/main/Vertex.pde b/main/Vertex.pde index 575f6f9..a215301 100644 --- a/main/Vertex.pde +++ b/main/Vertex.pde @@ -28,6 +28,9 @@ public class Vertex { return halfedge; } public ArrayList getAllLeavingEdges() { + if(halfedge == null) { + return null; + } return halfedge.getHalfEdgesAlsoLeaving(); } public void setIncidentEdge(HalfEdge e) { @@ -125,4 +128,8 @@ public class Vertex { } + public String toString() { + return "x: " + x + "\n" + "y: " + y; + } + } \ No newline at end of file diff --git a/main/main.pde b/main/main.pde index 5d3050c..db10ee7 100644 --- a/main/main.pde +++ b/main/main.pde @@ -4,12 +4,25 @@ public void settings() { public void setup() { background(255); fill(0,0); + translate(width/2, height/2); + VertexList list = new VertexList(); + Vertex v = new Vertex(0,0); + Vertex v1 = new Vertex(0,200); + Vertex v2 = new Vertex(100,100); + Vertex v3 = new Vertex(200,0); + list.addVertex(v); + list.addVertex(v1); + list.addVertex(v2); + list.addVertex(v3); + DrawHalfEdge draw = new DrawHalfEdge(); + HalfEdge h1 = new HalfEdge(v, v1); + draw.drawGraph(list.getVertexList()); } -public void draw() { +/*public void draw() { fill(0,0,255,40); noStroke(); pushMatrix(); // store the default translation matrix translate(width/2, height/2); // alter the current translation - ellipse(0,0,100,100); //place the sphere in center of current translation + //ellipse(0,0,100,100); //place the sphere in center of current translation popMatrix(); // return to default translation -} \ No newline at end of file +}*/ \ No newline at end of file