private float getKineticEnergy() { float total = 0; for (Node n : nodes) { total += n.getKineticEnergy(); } return total; }
private void addBackingDatums(ArrayList<Node> nodes) { for (Node n : nodes) { n.datumsEncapsulated = new ArrayList<Datum>(); for (Datum d : getData()) { if (n.id.equals(d.destIP) || n.id.equals(d.sourceIP)) { n.datumsEncapsulated.add(d); } } } }
public ArrayList<Datum> getHoveredDatums() { ArrayList<Datum> toReturn = new ArrayList<Datum>(); for (Node n : fdg.getNodes()) { if (n.containsPoint(mouseX, mouseY)) { for (Datum d : n.datumsEncapsulated) { toReturn.add(d); } } } return toReturn; }
private int getNodeColor(Node n) { return n.containsPoint(mouseX, mouseY) ? MOUSED_NODE_COLOR : EMPTY_NODE_COLOR; }
public void setAllBounds(Rect r) { for (Node n : nodes) { n.setBounds(r); } }
private void setAllBounds(ArrayList<Node> nodes, Rect myBounds) { for (Node n : nodes) { n.setBounds(myBounds); } }
// applies nodes' velocities to t private void updatePositions(float dt) { for (Node n : nodes) { n.updatePosition(dt); } }
public void applyForce() { Vector velocity = node.vel.copy().scale(-K, -K); node.addForce(velocity); }