Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/model/Source.java
  • Loading branch information
alinourian committed Aug 4, 2020
2 parents 96f828e + dbf935c commit c584a77
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/controller/InputController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static InputController getInstance() {
private final ArrayList<VoltageSource> voltageSources = new ArrayList<>();
private final ArrayList<Element> elements = new ArrayList<>();
private final ArrayList<Source> sources = new ArrayList<>();
private Branch finalSuperiorBranch;

private double deltaV = 0;
private double deltaI = 0;
Expand Down Expand Up @@ -354,6 +355,10 @@ public double getTranTime() {
return tranTime;
}

public Branch getFinalSuperiorBranch() { return finalSuperiorBranch; }

public void setFinalSuperiorBranch(Branch finalSuperiorBranch) { this.finalSuperiorBranch = finalSuperiorBranch; }

public void setAllNodesNotVisited() {
for (Node node : nodes) {
node.setNotVisited();
Expand Down
29 changes: 26 additions & 3 deletions src/model/Branch.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
package model;

import java.util.ArrayList;

public class Branch {
protected final String name;
protected Node nodeP;
protected Node nodeN;
private Branch superiorBranch;
private ArrayList<Branch> subBranches = new ArrayList<>();
private int width;
private int height;

public Branch(String name, Node nodeP, Node nodeN) {
this.name = name;
this.nodeP = nodeP;
this.nodeN = nodeN;
}
this.superiorBranch = null;

public String getName() {
return name;
}


public void setWidth(int width) { this.width = width; }

public void setHeight(int height) { this.height = height; }

public void setSuperiorBranch(Branch superiorBranch) { this.superiorBranch = superiorBranch; }

public void setSubBranches(ArrayList<Branch> subBranches) { this.subBranches = subBranches; }

public ArrayList<Branch> getSubBranches() { return subBranches; }

public Branch getSuperiorBranch() { return superiorBranch; }

public String getName() { return name; }

public int getWidth() { return width; }

public int getHeight() { return height; }
}
2 changes: 2 additions & 0 deletions src/model/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public Element(String name, Node nodeP, Node nodeN) {
this.current = 0;
this.helpCurrent = 0;
this.currents = new ArrayList<>();
setHeight(1);
setWidth(1);
}

public void updateElementCurrent() {
Expand Down
8 changes: 0 additions & 8 deletions src/model/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import enums.Type;

import java.util.ArrayList;

public class Source extends Branch {
protected ArrayList<Double> currents;

public Source(String name, Node nodeP, Node nodeN) {
super(name, nodeP, nodeN);
currents = new ArrayList<>();
}

public double getVoltage(Node node) {
Expand Down Expand Up @@ -40,10 +36,6 @@ public Type getType() {
return Type.SOURCE;
}

public ArrayList<Double> getCurrents() {
return currents;
}

@Override
public String toString() {
return name + " " +
Expand Down
43 changes: 42 additions & 1 deletion src/view/fxml/DrawCircuit.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
public abstract class DrawCircuit {
private static double drawCircuitStep;
private static final Pane circuitPane = new Pane();
private static final InputController controller = InputController.getInstance();


private static final Image resistor = new Image("view/img/element/Resistor.png");
private static final Image capacitor = new Image("view/img/element/Capacitor.png");
private static final Image inductor = new Image("view/img/element/Inductor.png");
private static final Image inductor = new Image("view/img/element/Inductor.png");
private static final Image diode = new Image("view/img/element/Diode.png");
private static final Image gnd = new Image("view/img/element/Ground.png");
private static final Image vSource = new Image("view/img/element/VSource.png");
Expand All @@ -36,6 +38,11 @@ public static Pane drawCircuit() {
circuitPane.getChildren().add(new Circle(getXY(i), getXY(j), 1));
}
}


setTheFinalSuperiorBranch();


putGround();
putImage(resistor, 9, 3);
putImage(capacitor, 10, 4);
Expand All @@ -56,6 +63,40 @@ public static Pane drawCircuit() {
return circuitPane;
}


private static void setTheFinalSuperiorBranch()
{
ArrayList<Branch> allBranches = new ArrayList<>();

for (Source source : controller.getSources()) {
allBranches.add(source);
}

for (Element element : controller.getElements()) {
allBranches.add(element);
}


while (allBranches.size() != 1)
{




}



controller.setFinalSuperiorBranch(allBranches.get(0));

}

private static void incorporateParallelBranchesToNewBranch()
{

}


private static ArrayList<Branch> getBranches(Node node1, Node node2) {
ArrayList<Branch> branches = new ArrayList<>();
for (Element element : node1.getElements()) {
Expand Down

0 comments on commit c584a77

Please sign in to comment.