Exemplo n.º 1
0
 @SuppressWarnings("unused")
 private void drawFrameRate(int xp, int yp) {
   // draw frame rate!
   parent.textAlign(PConstants.LEFT, PConstants.TOP);
   parent.textFont(parent.font);
   parent.textSize(18);
   parent.fill(0);
   parent.text(parent.frametimer.getFrameRateAsText(), xp, yp);
   // System.out.println(frametimer.getFrameRateAsText());
 }
Exemplo n.º 2
0
  void draw() {
    if (record) {
      // Note that #### will be replaced with the frame number. Fancy!
      parent.beginRecord(PConstants.PDF, "frame-####.pdf");
      parent.textMode(PConstants.SHAPE);
      parent.font = parent.createFont("Verdana", 18); // recreate as a
      // shape
      parent.textFont(parent.font);
    }
    parent.background(130, 130, 130);

    if (currentLarge == null) {
      // draw the actual timeline
      for (TwitterFilteringComponent a : timePoints) {
        a.draw();
        drawLinksTo(a);
        // moveToPosition(a);
      }

      drawTimeLine();
      fixOverlaps();
      // draw visualisations!
    } else {
      currentLarge.draw();
    }
    if (record) {
      parent.endRecord();
      parent.textMode(PConstants.MODEL);
      record = false;
    }
    // drawFrameRate(0,25);
    // controlP5.draw();
  }
Exemplo n.º 3
0
  void drawLinksTo(TwitterFilteringComponent t) {
    parent.noStroke();
    parent.fill(170, 170, 255, 130);
    int targetY;

    targetY = (t.y < lineY ? (t.y + t.height) : t.y);

    // println(t.y + " and " + targetY);
    // draw links from timeline to this component
    parent.beginShape(PConstants.POLYGON);
    parent.vertex(
        PApplet.map(
            getHourOfYear(t.dateSelection.getStart()),
            getHourOfYear(timelineStartDate),
            getHourOfYear(timelineEndDate),
            lineStart,
            lineStop),
        lineY);
    parent.vertex(t.x, targetY);
    parent.vertex(t.x + t.width, targetY);
    parent.vertex(
        PApplet.map(
            getHourOfYear(t.dateSelection.getEnd()),
            getHourOfYear(timelineStartDate),
            getHourOfYear(timelineEndDate),
            lineStart,
            lineStop),
        lineY);
    parent.endShape();
  }
Exemplo n.º 4
0
 public void keyPressed() {
   if (currentLarge == null) {
     if (parent.key == '(') {
       parent.saveFrame("VASTMC2-####.png");
       record = true; // disable 'cos text should come first
     } else if (parent.key == ')') {
       addNew();
     }
   } else {
     /*
      * if(e.getKeyCode()==PConstants.ENTER){ //finish annotation! }
      */
   }
   /*
    * else if (parent.key == 'S') {
    * parent.saveFrame("VASTMC2-large-####.png"); record = true; } }
    */
 }
Exemplo n.º 5
0
  void drawTimeLine() {

    // draw the base timeline

    int minorTickHeight = (int) (20 * scaleFactorY);
    int majorTickHeight = (int) (40 * scaleFactorY);
    parent.strokeWeight(10);
    parent.stroke(0);
    parent.line(lineStart, lineY, lineStop, lineY);
    // draw days
    // int maxDays = Days.daysBetween(timelineStartDate,
    // timelineEndDate).getDays();
    int maxHours = Hours.hoursBetween(timelineStartDate, timelineEndDate).getHours();
    // println("Interval  is " + fullTimeInterval);
    // println("Period is " + Days.daysBetween(minDate, maxDate).getDays());
    // println("Max days is " + maxDays);

    DateTime tempdt = new DateTime(timelineStartDate);
    String previousMonth = timelineStartDate.monthOfYear().getAsText();
    int previousDay = -1; // =tempdt.dayOfYear().get();
    int monthStart = lineStart;
    parent.textAlign(PConstants.CENTER, PConstants.TOP);

    for (int a = 0; a < maxHours; a++) {
      // println(a);
      parent.textAlign(PConstants.CENTER, PConstants.TOP);
      // draw label
      parent.textFont(parent.font);
      parent.textSize(10 * fontScale);

      if (tempdt.dayOfYear().get() != previousDay) {
        int tx = (int) (PApplet.map(a, 0, maxHours, lineStart, lineStop));
        // draw tick
        parent.strokeWeight(1);
        parent.line(tx, lineY, tx, lineY + minorTickHeight);
        previousDay = tempdt.dayOfYear().get();
        parent.fill(0);
        if (tempdt.dayOfMonth().get() == 1) {
          // special case!
          parent.textSize(14 * fontScale);
          parent.text(
              tempdt.dayOfMonth().getAsString(),
              tx,
              lineY + majorTickHeight + parent.textDescent());
        } else {
          parent.text(
              tempdt.dayOfMonth().getAsString(),
              tx,
              lineY + minorTickHeight + parent.textDescent());
        }

        // check if need to draw monthName
        if (!previousMonth.equals(tempdt.monthOfYear().getAsText())) {
          // draw some visual markers!
          // line(monthStart, lineY, monthStart,
          // lineY+majorTickHeight);
          parent.line(tx, lineY, tx, lineY + majorTickHeight);
          // position halfway between monthStart and tx, draw
          // monthname
          parent.textSize(18 * fontScale);
          // check! do we overlap the next month? if so, change
          // alignment
          if (parent.textWidth(previousMonth) / 2 + monthStart > tx) {
            parent.textAlign(PConstants.RIGHT, PConstants.TOP);
          }
          parent.text(
              previousMonth,
              (tx + monthStart) / 2,
              lineY + minorTickHeight + 2 * (parent.textAscent() + parent.textDescent()));
          previousMonth = tempdt.monthOfYear().getAsText();
          monthStart = tx;
        }
      }
      tempdt = tempdt.plus(Period.hours(1));
    }
    // draw final day
    parent.line(lineStop, lineY, lineStop, lineY + minorTickHeight);
    if (tempdt.dayOfMonth().get() == 1) {
      // special case!
      parent.text(
          tempdt.dayOfMonth().getAsString(),
          lineStop,
          lineY + majorTickHeight + parent.textDescent());
    } else {
      parent.text(
          tempdt.dayOfMonth().getAsString(),
          lineStop,
          lineY + minorTickHeight + parent.textDescent());
    }
    // draw final month!
    parent.textSize(18 * fontScale);
    parent.text(
        tempdt.monthOfYear().getAsText(),
        (lineStop + monthStart) / 2,
        lineY + minorTickHeight + 2 * (parent.textAscent() + parent.textDescent()));
  }