I have a javafx app which generates mazes using a binary tree algorithm . However, I want to move alot of the methods outside of the main class and then just call them from the main class to make the code more readable . I have tried using interfaces to try and simulate multiple inheritance to access the methods but this didnt work because interfaces have no body. I then tried making instances of the other classes then calling the method but this just hung the ui because the new instance made a new object . Below is one of the methods I want to move into another class called 'delNode' it works by taking in start and end coordinates of the line then removing it from the pane. Anyway basically to keep it simple is there a way of calling non static methods from another class('s) without having to make an instance of the class?
public void delNode(int Sx, int Sy, int Ex, int Ey) {
//System.out.println("run me");
ObservableList<Node> nodes = pane.getChildren();
sizeN = nodes.size();
//System.out.println(sizeN);
List<List<Integer>> cells = new ArrayList<>();
int j = 0;
for (int i = 0; i < sizeN; i++) {
//check if size of list is greater than 0 is to esnure no out of bounds error
Node val = nodes.get(i);
List<Integer> preCells = new ArrayList<>();
double valx = (val.getLayoutBounds().getMinX() + 0.5);
double valy = (val.getLayoutBounds().getMinY() + 0.5);
double endx = (val.getLayoutBounds().getMaxX() - 0.5);
double endy = (val.getLayoutBounds().getMaxY() - 0.5);
//System.out.println("cell (" + valx + ',' + valy + ')');
preCells.add((int) valx);
preCells.add((int) valy);
preCells.add((int) endx);
preCells.add((int) endy);
//System.out.println(preCells);
cells.add(preCells);
}
//System.out.println(cells);
boolean done = false;
while (!done) {
if (j > cells.size() - 1) break;
int xF = cells.get(j).get(0);
int yF = cells.get(j).get(1);
int eXf = cells.get(j).get(2);
int eYf = cells.get(j).get(3);
//System.out.println(cells);
if (Sx == xF && Sy == yF && Ex == eXf && Ey == eYf) {
pane.getChildren().remove(j);
//System.out.println(Sx);
//System.out.println("removed");
//break;
done = true;
j = 0;
//System.out.println("DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE DONE ");
}
j++;
}
}