From 740093d1e2b5a603c679c1411071deb8f87a0282 Mon Sep 17 00:00:00 2001 From: johnprif Date: Mon, 13 Feb 2023 23:06:08 +0200 Subject: [PATCH] create 3 plots in the same time --- src/Control/AlgorithmsHandler.java | 21 +- src/Control/GraphGUIHandler.java | 34 +-- src/Model/DataBase.java | 271 +++++------------- src/Model/GrahamScan.java | 1 - .../NearestNeighborVoronoiAlgorithm3.java | 62 ---- .../SmallestEnclosingCirlceAlgorithm1.java | 4 +- ...rithm2.java => VoronoiAlgorithm2and3.java} | 12 +- src/View/SmallestEnclosingCircleGraphGUI.java | 20 +- src/View/VoronoiGraphGUI.java | 10 +- 9 files changed, 116 insertions(+), 319 deletions(-) delete mode 100644 src/Model/NearestNeighborVoronoiAlgorithm3.java rename src/Model/{FarthestNeighborVoronoiAlgorithm2.java => VoronoiAlgorithm2and3.java} (85%) diff --git a/src/Control/AlgorithmsHandler.java b/src/Control/AlgorithmsHandler.java index 2a259b0..8bb8e61 100644 --- a/src/Control/AlgorithmsHandler.java +++ b/src/Control/AlgorithmsHandler.java @@ -1,8 +1,7 @@ package Control; import Model.SmallestEnclosingCirlceAlgorithm1; -import Model.FarthestNeighborVoronoiAlgorithm2; -import Model.NearestNeighborVoronoiAlgorithm3; +import Model.VoronoiAlgorithm2and3; import Model.DataBase; import Model.GrahamScan; @@ -10,24 +9,28 @@ public class AlgorithmsHandler { private GrahamScan grahamScan; private SmallestEnclosingCirlceAlgorithm1 algorithm1; - private FarthestNeighborVoronoiAlgorithm2 algorithm2; - private NearestNeighborVoronoiAlgorithm3 algorithm3; + private VoronoiAlgorithm2and3 nearestNeighbor; + private VoronoiAlgorithm2and3 farthestNeighbor; private DataBase dataBase; public AlgorithmsHandler() { dataBase = DataBase.getInstance(); + dataBase.createListOfKandE(); - grahamScan = new GrahamScan(); + grahamScan = new GrahamScan(); grahamScan.initialize(); algorithm1 = new SmallestEnclosingCirlceAlgorithm1(); + dataBase.prepareForAlgorithm(0); algorithm1.computeSmallestEnclosingCircle(); -// algorithm2 = new FarthestNeighborVoronoiAlgorithm2(); -// algorithm2.computeFarthestNeighborVoronoiDiagram(); + nearestNeighbor = new VoronoiAlgorithm2and3(); + dataBase.prepareForAlgorithm(1); + nearestNeighbor.computeVoronoiDiagram(); - algorithm3 = new NearestNeighborVoronoiAlgorithm3(); - algorithm3.computeNearestNeighborVoronoiDiagram(); + farthestNeighbor = new VoronoiAlgorithm2and3(); + dataBase.prepareForAlgorithm(2); + farthestNeighbor.computeVoronoiDiagram(); } } diff --git a/src/Control/GraphGUIHandler.java b/src/Control/GraphGUIHandler.java index 8066863..8d71e01 100644 --- a/src/Control/GraphGUIHandler.java +++ b/src/Control/GraphGUIHandler.java @@ -1,7 +1,6 @@ package Control; import Model.DataBase; -import Model.NearestNeighborVoronoiAlgorithm3; import View.SmallestEnclosingCircleGraphGUI; import View.VoronoiGraphGUI; @@ -11,47 +10,36 @@ public class GraphGUIHandler private DataBase dataBase; private SmallestEnclosingCircleGraphGUI circleGraphGUI; private VoronoiGraphGUI farthestNeighborVoronoiGraphGUI; - private VoronoiGraphGUI nearestNeighborVoronoiGraphGUI; public GraphGUIHandler(String path) { this.path = path; dataBase = DataBase.getInstance(); - makeCircleGraph(); -// makeFarthestNeighborVoronoiGraph(); - makeNearestNeighborVoronoiGraph(); + makeCircleGraph("Smallest Enclosing Circle", 0, 0); + makeVoronoiGraph("Nearest Neighbor Voronoi Diagram", 700, 0, 0); + makeVoronoiGraph("Farthest Neighbor Voronoi Diagram", 1400, 0, 1); } - private void makeCircleGraph() + private void makeCircleGraph(String title, int x, int y) { circleGraphGUI = new SmallestEnclosingCircleGraphGUI(path); + circleGraphGUI.setTitle(title); circleGraphGUI.setAllPoints(dataBase.getAllPoints()); circleGraphGUI.setConvexPoints(dataBase.getConvexPoints()); circleGraphGUI.setCirclePoints(dataBase.getCirclePoints()); circleGraphGUI.setCircleObject(dataBase.findCircle()); - circleGraphGUI.initialize(); + circleGraphGUI.initialize(x, y); } - private void makeFarthestNeighborVoronoiGraph() + private void makeVoronoiGraph(String title, int x, int y, int mode) { farthestNeighborVoronoiGraphGUI = new VoronoiGraphGUI(path); - farthestNeighborVoronoiGraphGUI.setTitle("Farthest Neighbor Voronoi Diagram"); + farthestNeighborVoronoiGraphGUI.setTitle(title); farthestNeighborVoronoiGraphGUI.setAllPointsSize(dataBase.getAllPointsSize()); farthestNeighborVoronoiGraphGUI.setConvexPoints(dataBase.getConvexPoints()); - farthestNeighborVoronoiGraphGUI.setK(dataBase.getK()); - farthestNeighborVoronoiGraphGUI.setE(dataBase.getE()); - farthestNeighborVoronoiGraphGUI.initialize(); - } - - private void makeNearestNeighborVoronoiGraph() - { - nearestNeighborVoronoiGraphGUI = new VoronoiGraphGUI(path); - nearestNeighborVoronoiGraphGUI.setTitle("Nearest Neighbor Voronoi Diagram"); - nearestNeighborVoronoiGraphGUI.setAllPointsSize(dataBase.getAllPointsSize()); - nearestNeighborVoronoiGraphGUI.setConvexPoints(dataBase.getConvexPoints()); - nearestNeighborVoronoiGraphGUI.setK(dataBase.getK()); - nearestNeighborVoronoiGraphGUI.setE(dataBase.getE()); - nearestNeighborVoronoiGraphGUI.initialize(); + farthestNeighborVoronoiGraphGUI.setK(dataBase.getK(mode)); + farthestNeighborVoronoiGraphGUI.setE(dataBase.getE(mode)); + farthestNeighborVoronoiGraphGUI.initialize(x, y); } } diff --git a/src/Model/DataBase.java b/src/Model/DataBase.java index a60c91c..7b0ae30 100644 --- a/src/Model/DataBase.java +++ b/src/Model/DataBase.java @@ -19,16 +19,7 @@ public class DataBase private ArrayList convexPoints; private ArrayList circlePoints; private static final DataBase instance = new DataBase(); - - private HashMap> neighbours; - private TreeMap radiusForEachNode; - private HashMap existingRadius; - - private Point2D currCustom; - private Point2D prevCustom; - private Point2D nextCustom; - private double maxAngleCustom; - private double maxRadiusCustom; + private int mode; private ArrayList K; private ArrayList> E; @@ -40,7 +31,9 @@ public class DataBase private Point2D nextCustom2; private double maxAngleCustom2; private double maxRadiusCustom2; - private ArrayList convexPoints2; + + private ArrayList> allK; + private ArrayList>> allE; private DataBase() { @@ -62,24 +55,21 @@ public ArrayList getConvexPoints() return convexPoints; } - public ArrayList getConvexPoints2() - { - return convexPoints2; - } - public ArrayList getCirclePoints() { return circlePoints; } - public ArrayList getK() + public ArrayList getK(int mode) { - return K; + return allK.get(mode); +// return K; } - public ArrayList> getE() + public ArrayList> getE(int mode) { - return E; + return allE.get(mode); +// return E; } public void setAllPoints(ArrayList allPoints) @@ -90,206 +80,92 @@ public void setAllPoints(ArrayList allPoints) public void setConvexPoints(ArrayList convexPoints) { this.convexPoints = new ArrayList(convexPoints); - convexPoints2 = new ArrayList(convexPoints); } public void setCirclePoints(ArrayList circlePoints) { this.circlePoints = new ArrayList(circlePoints); - //----------------------------------------------- + } + + public void prepareForAlgorithm(int mode) + { + this.mode = mode; loadMaps(); - loadMaps2(); - //----------------------------------------------- } // ----------O(nlog(n))--------------- private void loadMaps() { - int size = circlePoints.size(); + int size = getConvexPointsSize(); double radius; - neighbours = new HashMap>(); - radiusForEachNode = new TreeMap<>(); - existingRadius = new HashMap(); + neighbours2 = new HashMap>(); + radiusForEachNode2 = new TreeMap<>(); + existingRadius2 = new HashMap(); for (int i = 0; i < size; i++) { - Point2D prev = circlePoints.get((i + size - 1) % size); //O(1) - Point2D curr = circlePoints.get(i); //O(1) - Point2D next = circlePoints.get((i + 1) % size); //O(1) + Point2D prev = convexPoints.get((i + size - 1) % size); //O(1) + Point2D curr = convexPoints.get(i); //O(1) + Point2D next = convexPoints.get((i + 1) % size); //O(1) radius = getRadius(prev, curr, next); //O(1) ArrayList kati = new ArrayList(); kati.add(prev); kati.add(next); - neighbours.put(curr, kati); //O(1) - radiusForEachNode.put(radius, curr); //O(log(n)) - - existingRadius.put(radius, curr); + neighbours2.put(curr, kati); //O(1) + radiusForEachNode2.put(radius, curr); //O(log(n)) + existingRadius2.put(radius, curr); } } - -//----------O(log(n)) for each calling--------------- - public double findMaxP() + + //----------O(log(n)) for each calling--------------- + public Point2D findMaxP2() { - int size = neighbours.size(); //O(1) + int size = neighbours2.size(); //O(1) if (size <= 2) { - return -1; + return new Point2D(-1, -1); } - - maxRadiusCustom = radiusForEachNode.lastKey(); //O(1) - currCustom = radiusForEachNode.get(maxRadiusCustom); //O(log(n)) - prevCustom = neighbours.get(currCustom).get(0); //O(1) - nextCustom = neighbours.get(currCustom).get(1); //O(1) - maxAngleCustom = getAngle(prevCustom, currCustom, nextCustom); //O(1) - - return maxAngleCustom; - } - - //----------5*O(log(n)) for each calling--------------- - public void deleteMaxP() - { - ArrayList left = new ArrayList(); - ArrayList right = new ArrayList(); - - //---I found that has changed - Point2D leftCurr = neighbours.get(currCustom).get(0); - Point2D leftPrev = neighbours.get(leftCurr).get(0); - Point2D leftNext = neighbours.get(leftCurr).get(1); - - Point2D rightCurr = neighbours.get(currCustom).get(1); //O(1) - Point2D rightPrev = neighbours.get(rightCurr).get(0); //O(1) - Point2D rightNext = neighbours.get(rightCurr).get(1); //O(1) - - radiusForEachNode.remove(maxRadiusCustom); //O(log(n)) - radiusForEachNode.remove(getRadius(leftPrev, leftCurr, leftNext)); //O(log(n)) - radiusForEachNode.remove(getRadius(rightPrev, rightCurr, rightNext)); //O(log(n)) - - existingRadius.remove(maxRadiusCustom);//O(1) - existingRadius.remove(getRadius(leftPrev, leftCurr, leftNext)); //O(1) - existingRadius.remove(getRadius(rightPrev, rightCurr, rightNext)); //O(1)) - - neighbours.remove(leftCurr); //O(1) - neighbours.remove(currCustom); //O(1) - neighbours.remove(rightCurr); //O(1) - - left.add(leftPrev); //O(1) - left.add(rightCurr); //O(1) - - right.add(leftCurr); //O(1) - right.add(rightNext); //O(1) - - neighbours.put(leftCurr, left); //O(1) - neighbours.put(rightCurr, right); //O(1) - - double beforeRadius = getRadius(leftPrev, leftCurr, rightCurr); - double nextRadius = getRadius(leftCurr, rightCurr, rightNext); - Point2D currPoint; + + if(mode == 0 || mode == 2) //circle or nearest + { + maxRadiusCustom2 = radiusForEachNode2.lastKey(); //O(1) + }else //mode == 1 farthest + { + maxRadiusCustom2 = radiusForEachNode2.firstKey(); //O(1) + } + + currCustom2 = radiusForEachNode2.get(maxRadiusCustom2); //O(log(n)) + prevCustom2 = neighbours2.get(currCustom2).get(0); //O(1) + nextCustom2 = neighbours2.get(currCustom2).get(1); //O(1) + maxAngleCustom2 = getAngle(prevCustom2, currCustom2, nextCustom2); //O(1) - if(!existingRadius.containsKey(beforeRadius)) //O(1) - { - radiusForEachNode.put(beforeRadius, leftCurr); //O(log(n)) - existingRadius.put(beforeRadius, leftCurr);//O(1) - - }else - { - currPoint = existingRadius.get(beforeRadius);//O(1) - - if(getAngle(neighbours.get(leftCurr).get(0), leftCurr, neighbours.get(leftCurr).get(1)) >= getAngle(neighbours.get(currPoint).get(0), currPoint, neighbours.get(currPoint).get(1))) - { - radiusForEachNode.put(getRadius(neighbours.get(currPoint).get(0), currPoint, neighbours.get(currPoint).get(1)), leftCurr); //O(log(n)) - existingRadius.put(getRadius(neighbours.get(currPoint).get(0), currPoint, neighbours.get(currPoint).get(1)), leftCurr); //O(1) - } - } - if(!existingRadius.containsKey(nextRadius)) //O(1) - { - radiusForEachNode.put(nextRadius, rightCurr); //O(log(n)) - existingRadius.put(nextRadius, rightCurr);//O(1) - }else + if(mode == 0) { - currPoint = existingRadius.get(nextRadius);//O(1) - - if(getAngle(neighbours.get(rightCurr).get(0), rightCurr, neighbours.get(rightCurr).get(1)) >= getAngle(neighbours.get(currPoint).get(0), currPoint, neighbours.get(currPoint).get(1))) - { - radiusForEachNode.put(getRadius(neighbours.get(currPoint).get(0), currPoint, neighbours.get(currPoint).get(1)), rightCurr); //O(log(n)) - existingRadius.put(getRadius(neighbours.get(currPoint).get(0), currPoint, neighbours.get(currPoint).get(1)), rightCurr); //O(1) - } + return new Point2D(maxAngleCustom2, maxAngleCustom2); } + + return currCustom2; } public int getHashCirclePointsSize() { - return neighbours.size(); + return neighbours2.size(); } public void moveToCircleArray() { HashMap neighboursTemp = new HashMap(); - for (Point2D key : neighbours.keySet()) + for (Point2D key : neighbours2.keySet()) { neighboursTemp.put(key, key); } circlePoints = new ArrayList(neighboursTemp.values()); } - - -// ----------O(nlog(n))--------------- - private void loadMaps2() - { - int size = circlePoints.size(); - double radius; - - neighbours2 = new HashMap>(); - radiusForEachNode2 = new TreeMap<>(); - existingRadius2 = new HashMap(); - - for (int i = 0; i < size; i++) - { - Point2D prev = circlePoints.get((i + size - 1) % size); //O(1) - Point2D curr = circlePoints.get(i); //O(1) - Point2D next = circlePoints.get((i + 1) % size); //O(1) - - radius = getRadius(prev, curr, next); //O(1) - ArrayList kati = new ArrayList(); - kati.add(prev); - kati.add(next); - - neighbours2.put(curr, kati); //O(1) - radiusForEachNode2.put(radius, curr); //O(log(n)) - - existingRadius2.put(radius, curr); - } - } - - - //----------O(log(n)) for each calling--------------- - public Point2D findMaxP2() - { - int size = neighbours2.size(); //O(1) - - if (size <= 2) - { - return null; - } - -//------------------------------------------------------------------------------------------------- -// for Farthest Neighbor Voronoi Diagram -// maxRadiusCustom2 = radiusForEachNode2.lastKey(); //O(1) -//------------------------------------------------------------------------------------------------- -// for Nearest Neighbor Voronoi Diagram - maxRadiusCustom2 = radiusForEachNode2.firstKey(); //O(1) -//------------------------------------------------------------------------------------------------- - currCustom2 = radiusForEachNode2.get(maxRadiusCustom2); //O(log(n)) - prevCustom2 = neighbours2.get(currCustom2).get(0); //O(1) - nextCustom2 = neighbours2.get(currCustom2).get(1); //O(1) - maxAngleCustom2 = getAngle(prevCustom2, currCustom2, nextCustom2); //O(1) - - return currCustom2; - } public Point2D getPrev() { @@ -387,39 +263,9 @@ public int getCirclePointsSize() return circlePoints.size(); } - public void displayAllPoints() - { - System.out.println("The ArrayList '"+getAllPointsSize()+"' All Points is --> "); - for(int i=0; i "); - for(int i=0; i "); - for(int i=0; i>(); } + public void moveKandE() + { +// allK = new ArrayList>(); + allK.add(K); + +// allE = new ArrayList>>(); + allE.add(E); + } + + public void createListOfKandE() + { + allK = new ArrayList>(); + allE = new ArrayList>>(); + } + } diff --git a/src/Model/GrahamScan.java b/src/Model/GrahamScan.java index ebdc0b8..0f8bf0a 100644 --- a/src/Model/GrahamScan.java +++ b/src/Model/GrahamScan.java @@ -36,7 +36,6 @@ public void initialize() convexHullPoints = new ArrayList(computeGrahamScan(allPoints)); convexHullPoints.remove(convexHullPoints.size()-1); dataBase.setConvexPoints(convexHullPoints); - dataBase.setCirclePoints(convexHullPoints); } //----------------------------------O(nlogn)-------------------------------------- diff --git a/src/Model/NearestNeighborVoronoiAlgorithm3.java b/src/Model/NearestNeighborVoronoiAlgorithm3.java deleted file mode 100644 index a6705b9..0000000 --- a/src/Model/NearestNeighborVoronoiAlgorithm3.java +++ /dev/null @@ -1,62 +0,0 @@ -package Model; - -import javafx.geometry.Point2D; - -public class NearestNeighborVoronoiAlgorithm3 -{ - private DataBase dataBase; - public NearestNeighborVoronoiAlgorithm3() - { - dataBase = DataBase.getInstance(); - } - - public void computeNearestNeighborVoronoiDiagram() - { - System.out.println("I am the third algorithm!"); - int n = dataBase.getConvexPointsSize(); - //I have to make (K,E) ArrayLits for each K, E - dataBase.makeKandE(); - //for all p in S add u(p) to K; - dataBase.addAllUpToK(); - Point2D before_p; - Point2D p; - Point2D next_p; - Point2D c; - - if(n > 2) - { - System.out.println("Algorithm 3 started with = " + n); - do - { - //find p maximizing radius and angle - p = dataBase.findMaxP2(); - before_p = dataBase.getPrev(); - next_p = dataBase.getNext(); - c = dataBase.getCenter(before_p, p, next_p); - dataBase.addCtoK(c); - dataBase.addCandUtoE(c, dataBase.getUp(p)); - dataBase.addCandUtoE(c, dataBase.getUp(before_p)); - //u(q)=c; - dataBase.deleteMaxP2(); - n = n-1; - }while(n != 2); -// dataBase.addCandUtoE(dataBase.getUp2(before_p), dataBase.getUp2(next_p)); - dataBase.addCandUtoE(c, dataBase.getUp(next_p)); - }else - { - System.out.println("Algorithm 3 started with = " + n); - if(n == 2) //S={p1, p2} - { - Point2D p1 = dataBase.getConvexPoints().get(0); - Point2D p2 = dataBase.getConvexPoints().get(1); - - Point2D u_p1 = dataBase.getUp(p1); - Point2D u_p2 = dataBase.getUp(p2); - - //add (u(p1), u(p2)) to E; - dataBase.addCandUtoE(u_p1, u_p2); - } - } - System.out.println("Algorithm 3 finished!"); - } -} diff --git a/src/Model/SmallestEnclosingCirlceAlgorithm1.java b/src/Model/SmallestEnclosingCirlceAlgorithm1.java index cc154bd..f7f13d6 100644 --- a/src/Model/SmallestEnclosingCirlceAlgorithm1.java +++ b/src/Model/SmallestEnclosingCirlceAlgorithm1.java @@ -36,10 +36,10 @@ public void computeSmallestEnclosingCircle() finish = false; do { - maxAngle = dataBase.findMaxP(); + maxAngle = dataBase.findMaxP2().getX(); if(maxAngle>myPi2) { - dataBase.deleteMaxP(); + dataBase.deleteMaxP2(); }else { dataBase.moveToCircleArray(); diff --git a/src/Model/FarthestNeighborVoronoiAlgorithm2.java b/src/Model/VoronoiAlgorithm2and3.java similarity index 85% rename from src/Model/FarthestNeighborVoronoiAlgorithm2.java rename to src/Model/VoronoiAlgorithm2and3.java index 8e6d87c..669db4d 100644 --- a/src/Model/FarthestNeighborVoronoiAlgorithm2.java +++ b/src/Model/VoronoiAlgorithm2and3.java @@ -2,15 +2,16 @@ import javafx.geometry.Point2D; -public class FarthestNeighborVoronoiAlgorithm2 +public class VoronoiAlgorithm2and3 { private DataBase dataBase; - public FarthestNeighborVoronoiAlgorithm2() + + public VoronoiAlgorithm2and3() { dataBase = DataBase.getInstance(); } - public void computeFarthestNeighborVoronoiDiagram() + public void computeVoronoiDiagram() { System.out.println("I am the second algorithm!"); int n = dataBase.getConvexPointsSize(); @@ -29,7 +30,7 @@ public void computeFarthestNeighborVoronoiDiagram() do { //find p maximizing radius and angle - p = dataBase.findMaxP2(); + p = dataBase.findMaxP2(); //=0 for maximizing before_p = dataBase.getPrev(); next_p = dataBase.getNext(); c = dataBase.getCenter(before_p, p, next_p); @@ -41,7 +42,7 @@ public void computeFarthestNeighborVoronoiDiagram() n = n-1; }while(n != 2); // dataBase.addCandUtoE(dataBase.getUp2(before_p), dataBase.getUp2(next_p)); - dataBase.addCandUtoE(c, dataBase.getUp(next_p)); + dataBase.addCandUtoE(c, dataBase.getUp(next_p)); }else { System.out.println("Algorithm 2 started with = " + n); @@ -57,6 +58,7 @@ public void computeFarthestNeighborVoronoiDiagram() dataBase.addCandUtoE(u_p1, u_p2); } } + dataBase.moveKandE(); System.out.println("Algorithm 2 finished!"); } } diff --git a/src/View/SmallestEnclosingCircleGraphGUI.java b/src/View/SmallestEnclosingCircleGraphGUI.java index 47aa59c..f639bd4 100644 --- a/src/View/SmallestEnclosingCircleGraphGUI.java +++ b/src/View/SmallestEnclosingCircleGraphGUI.java @@ -33,6 +33,7 @@ public class SmallestEnclosingCircleGraphGUI private Stage circleStage; private String path; + private String title; private XYSeriesCollection dataset; @@ -46,6 +47,11 @@ public SmallestEnclosingCircleGraphGUI(String path) this.path = path; } + public void setTitle(String title) + { + this.title = title; + } + public void setAllPoints(ArrayList allPoints) { this.allPoints = allPoints; @@ -66,21 +72,21 @@ public void setCircleObject(Ellipse2D circle) this.circle = circle; } - public void initialize() + public void initialize(int x, int y) { - createStage(); + createStage(x, y); displaySmallestEnclosingCircle(); circleStage.show(); } - private void createStage() + private void createStage(int x, int y) { circleStage = new Stage(); - circleStage.setTitle("SmallestEnclosingCircle -> "+path+" -> "+(allPoints.size())+" points"); + circleStage.setTitle(title+" -> "+path+" -> "+(allPoints.size())+" points"); circleStage.setHeight(700); circleStage.setWidth(700); - circleStage.setX(0); - circleStage.setY(0); + circleStage.setX(x); + circleStage.setY(y); circleStage.setResizable(true); } @@ -182,7 +188,7 @@ private XYLineAndShapeRenderer makeRenderer() private JFreeChart makeChart() { JFreeChart chart = new JFreeChart(plot); - chart.setTitle("Smallest Enclosing Circle"); + chart.setTitle(title); //======================================================= chart.getTitle().setPaint(Color.decode("#006699")); chart.getTitle().setFont(new Font("Arial", Font.TRUETYPE_FONT, 24)); diff --git a/src/View/VoronoiGraphGUI.java b/src/View/VoronoiGraphGUI.java index 195c275..fb142b5 100644 --- a/src/View/VoronoiGraphGUI.java +++ b/src/View/VoronoiGraphGUI.java @@ -61,21 +61,21 @@ public void setE(ArrayList> E) this.E = E; } - public void initialize() + public void initialize(int x, int y) { - createStage(); + createStage(x, y); displaySmallestEnclosingCircle(); voronoiStage.show(); } - private void createStage() + private void createStage(int x, int y) { voronoiStage = new Stage(); voronoiStage.setTitle(title+" -> "+path+" -> "+(allPointsSize)+" points"); voronoiStage.setHeight(700); voronoiStage.setWidth(700); - voronoiStage.setX(700); - voronoiStage.setY(0); + voronoiStage.setX(x); + voronoiStage.setY(y); voronoiStage.setResizable(true); }