From f7dc1abc7dc63ea498d950d6b9798e6731608886 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Thu, 7 Jul 2016 18:05:42 -0400 Subject: [PATCH] Added arcs so that nodes can point to themselves. --- .../cromer/estructuras/GrafoController.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/cl/cromer/estructuras/GrafoController.java b/src/cl/cromer/estructuras/GrafoController.java index ae81ae9..1f65c15 100644 --- a/src/cl/cromer/estructuras/GrafoController.java +++ b/src/cl/cromer/estructuras/GrafoController.java @@ -5,6 +5,8 @@ import javafx.fxml.Initializable; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Color; +import javafx.scene.shape.ArcType; import javafx.scene.text.Text; import java.net.URL; @@ -398,6 +400,29 @@ public class GrafoController implements Initializable { graphicsContext.setStroke(colores.getBorder()); + + + // Line between 0 and 0. + if (nodes[0] != null && grafoNoDirigido.edgeExists(nodes[0], nodes[0])) { + graphicsContext.strokeArc(15, 40, 29, 30, 145, 250, ArcType.OPEN); + } + // Line between 1 and 1. + if (nodes[1] != null && grafoNoDirigido.edgeExists(nodes[1], nodes[1])) { + graphicsContext.strokeArc(215, 40, 29, 30, 145, 250, ArcType.OPEN); + } + // Line between 2 and 2. + if (nodes[2] != null && grafoNoDirigido.edgeExists(nodes[2], nodes[2])) { + graphicsContext.strokeArc(15, 240, 29, 30, 145, 250, ArcType.OPEN); + } + // Line between 3 and 3. + if (nodes[3] != null && grafoNoDirigido.edgeExists(nodes[3], nodes[3])) { + graphicsContext.strokeArc(215, 240, 29, 30, 145, 250, ArcType.OPEN); + } + // Line between 4 and 4. + if (nodes[4] != null && grafoNoDirigido.edgeExists(nodes[4], nodes[4])) { + graphicsContext.strokeArc(110, 440, 29, 30, 145, 250, ArcType.OPEN); + } + // Line between 0 and 1. if (nodes[0] != null && nodes[1] != null && grafoNoDirigido.edgeExists(nodes[0], nodes[1])) { graphicsContext.strokeLine(50, 30, 210, 30);