Пример #1
0
    private float getKineticEnergy() {
      float total = 0;

      for (Node n : nodes) {
        total += n.getKineticEnergy();
      }

      return total;
    }
Пример #2
0
 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);
       }
     }
   }
 }
Пример #3
0
    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;
    }
Пример #4
0
 private int getNodeColor(Node n) {
   return n.containsPoint(mouseX, mouseY) ? MOUSED_NODE_COLOR : EMPTY_NODE_COLOR;
 }
Пример #5
0
 public void setAllBounds(Rect r) {
   for (Node n : nodes) {
     n.setBounds(r);
   }
 }
Пример #6
0
 private void setAllBounds(ArrayList<Node> nodes, Rect myBounds) {
   for (Node n : nodes) {
     n.setBounds(myBounds);
   }
 }
Пример #7
0
 // applies nodes' velocities to t
 private void updatePositions(float dt) {
   for (Node n : nodes) {
     n.updatePosition(dt);
   }
 }
Пример #8
0
 public void applyForce() {
   Vector velocity = node.vel.copy().scale(-K, -K);
   node.addForce(velocity);
 }