Esempio n. 1
0
  // Drawing the box
  void display() {
    // We look at each body and get its screen position
    Vec2 pos = box2d.getBodyPixelCoord(body);
    // Get its angle of rotation
    float a = body.getAngle();

    parent.rectMode(PConstants.CENTER);
    parent.pushMatrix();
    parent.translate(pos.x, pos.y);
    parent.rotate(-a);
    parent.fill(127);
    parent.stroke(0);
    parent.strokeWeight(2);
    parent.rect(0, 0, w, h);
    parent.popMatrix();
  }
  public void draw() {
    p.pushMatrix();
    p.pushStyle();
    p.fill(100, 100, 0);
    p.rect(0, 0, width, height);
    //  p.scale((float)ppHor, (float)ppVert);
    // p.translate(x, y);
    // p.sca
    // p.stroke(0);
    // p.strokeWeight(1.0f);
    p.noStroke();
    p.rectMode(PApplet.CORNER);

    // p.line(0, 0, 100, 100);

    // TODO: block on datset change here.
    if (d.getNumDatapoints() > minInd) {
      int which = 0;
      int i = minInd;
      for (; (i <= maxInd && i < d.getNumDatapoints()); i++) {
        Double v = d.getParam(i, myId);
        if (!v.isNaN()) {
          if (i >= minSelected && i <= maxSelected) {
            // p.stroke(0, 0, 256);
            p.noStroke();
            p.fill(hues[(int) d.getParam(i, myId)], 150, 256);
          } else {
            p.noStroke();
            p.fill(hues[(int) d.getParam(i, myId)], 256, 256);
          }
        } else {
          if (i >= minSelected && i <= maxSelected) {
            // p.stroke(0, 0, 256);
            p.noStroke();
            p.fill(200);
          } else {
            p.noStroke();
            p.fill(0);
          }
        }
        p.rect((ppHor * which++), 0, ppHor, height);
      }
    }

    p.popStyle();
    p.popMatrix();
  }