Пример #1
0
  /** Draws the histogram labels */
  protected void drawHistLabels() {
    parent.pushStyle();
    parent.textMode(MODEL);
    parent.textFont(font);
    parent.textSize(fontSize);
    parent.fill(fontColor);
    parent.noStroke();

    if (type == GPlot.VERTICAL) {
      if (rotateLabels) {
        parent.textAlign(RIGHT, CENTER);

        for (int i = 0; i < plotPoints.getNPoints(); i++) {
          if (plotPoints.isValid(i) && plotPoints.getX(i) >= 0 && plotPoints.getX(i) <= dim[0]) {
            parent.pushMatrix();
            parent.translate(plotPoints.getX(i), labelsOffset);
            parent.rotate(-HALF_PI);
            parent.text(plotPoints.getLabel(i), 0, 0);
            parent.popMatrix();
          }
        }
      } else {
        parent.textAlign(CENTER, TOP);

        for (int i = 0; i < plotPoints.getNPoints(); i++) {
          if (plotPoints.isValid(i) && plotPoints.getX(i) >= 0 && plotPoints.getX(i) <= dim[0]) {
            parent.text(plotPoints.getLabel(i), plotPoints.getX(i), labelsOffset);
          }
        }
      }
    } else {
      if (rotateLabels) {
        parent.textAlign(CENTER, BOTTOM);

        for (int i = 0; i < plotPoints.getNPoints(); i++) {
          if (plotPoints.isValid(i) && -plotPoints.getY(i) >= 0 && -plotPoints.getY(i) <= dim[1]) {
            parent.pushMatrix();
            parent.translate(-labelsOffset, plotPoints.getY(i));
            parent.rotate(-HALF_PI);
            parent.text(plotPoints.getLabel(i), 0, 0);
            parent.popMatrix();
          }
        }
      } else {
        parent.textAlign(RIGHT, CENTER);

        for (int i = 0; i < plotPoints.getNPoints(); i++) {
          if (plotPoints.isValid(i) && -plotPoints.getY(i) >= 0 && -plotPoints.getY(i) <= dim[1]) {
            parent.text(plotPoints.getLabel(i), -labelsOffset, plotPoints.getY(i));
          }
        }
      }
    }

    parent.popStyle();
  }
Пример #2
0
    public void display(PApplet theApplet, Controller theController) {
      theApplet.translate(_myRadius, _myRadius);

      theApplet.pushMatrix();
      theApplet.pushStyle();
      theApplet.ellipseMode(PApplet.CENTER);
      theApplet.noStroke();
      theApplet.fill(color().colorBackground);
      theApplet.ellipse(0, 0, _myRadius * 2, _myRadius * 2);
      theApplet.popMatrix();

      theApplet.pushMatrix();
      if (displayStyle == LINE) {
        theApplet.rotate(myAngle);
        theApplet.stroke(color().colorForeground);
        theApplet.line(0, 0, _myRadius, 0);
      } else if (displayStyle == ELLIPSE) {
        theApplet.rotate(myAngle);
        theApplet.noStroke();
        theApplet.fill(color().colorForeground);
        theApplet.ellipse(_myRadius * 0.75f, 0, _myRadius * 0.2f, _myRadius * 0.2f);
      } else if (displayStyle == ARC) {
        theApplet.noStroke();
        theApplet.fill(color().colorForeground);
        theApplet.arc(0, 0, _myRadius * 1.8f, _myRadius * 1.8f, startAngle, myAngle);
        theApplet.fill(color().colorBackground);
        theApplet.ellipse(0, 0, _myRadius * 1.2f, _myRadius * 1.2f);
      }
      theApplet.popMatrix();

      theApplet.pushMatrix();
      theApplet.rotate(startAngle);

      if (isShowTickMarks) {
        float step = range / _myTickMarksNum;
        theApplet.stroke(color().colorForeground);
        theApplet.strokeWeight(myTickMarkWeight);
        for (int i = 0; i <= _myTickMarksNum; i++) {
          theApplet.line(_myRadius + 2, 0, _myRadius + myTickMarkLength + 2, 0);
          theApplet.rotate(step);
        }
      } else {
        if (isShowRange) {
          theApplet.stroke(color().colorForeground);
          theApplet.strokeWeight(myTickMarkWeight);
          theApplet.line(_myRadius + 2, 0, _myRadius + myTickMarkLength + 2, 0);
          theApplet.rotate(range);
          theApplet.line(_myRadius + 2, 0, _myRadius + myTickMarkLength + 2, 0);
        }
      }
      theApplet.noStroke();
      theApplet.popStyle();
      theApplet.popMatrix();
    }
Пример #3
0
 /** @param theApplet PApplet */
 @ControlP5.Invisible
 public void draw(PApplet theApplet) {
   theApplet.pushMatrix();
   theApplet.translate(position.x, position.y);
   _myControllerView.display(theApplet, this);
   theApplet.popMatrix();
 }
Пример #4
0
 public void displayByArea(DisplayArea area) {
   changeMode();
   position.add(direction);
   if (position.z > 300 || position.z < -300) { // ograniczenie poruszania się obszaru wyświetlania
     direction.mult(-1);
   }
   area.moveCenterTo(position);
   pApplet.stroke(255, 0, 0);
   pApplet.pushMatrix();
   for (int j = 0; j < model.getSegmentCount(); j++) {
     Segment segment = model.getSegment(j);
     Face[] faces = segment.getFaces();
     pApplet.beginShape(PConstants.QUADS);
     for (Face face : faces) {
       if (area.isColliding(face.getCenter())) {
         PVector[] v = face.getVertices();
         PVector[] n = face.getNormals();
         for (int k = 0; k < v.length; k++) {
           pApplet.normal(n[k].x, n[k].y, n[k].z);
           pApplet.vertex(v[k].x, v[k].y, v[k].z);
         }
       }
     }
     pApplet.endShape();
   }
   pApplet.popMatrix();
 }
Пример #5
0
 public void drawJunction() {
   parent.pushMatrix();
   parent.translate(x, y, z);
   parent.stroke(255, 255, 255);
   parent.fill(255); // 0, 0, 0, 0);
   parent.box(x_dim, y_dim, z_dim);
   parent.popMatrix();
 }
Пример #6
0
 public void draw() {
   p.pushMatrix();
   p.translate(position.x, position.y);
   p.rotate(p.PI / 10);
   drawImage();
   p.popMatrix();
   // drawCollisionShapes();
 }
Пример #7
0
  public void draw() {
    PVector v = getBezierPoint3D();

    p.stroke(color, 50);
    p.pushMatrix();
    p.translate(v.x, v.y, v.z);
    p.sphere(2);
    p.popMatrix();
  }
Пример #8
0
 protected void drawLabel(PApplet theApplet) {
   theApplet.pushMatrix();
   theApplet.fill(isInside ? color.colorForeground : color.colorBackground);
   if (isActive) {
     theApplet.fill(color.colorActive);
   }
   theApplet.rect(_myOffsetX, _myOffsetY, _myWidth - 1 + _myRightBorder, _myHeight);
   _myLabel.draw(theApplet, _myOffsetX + 4, _myOffsetY + 5);
   theApplet.popMatrix();
 }
Пример #9
0
  /**
   * Updates the particle view. This should be called on each draw cycle in order to update the
   * positions of all nodes and edges in the viewer. If you need to update the positions of
   * particles without drawing it (e.g. to speed up movement, call updateParticles() instead.
   */
  public void draw() {
    parent.pushStyle();
    parent.pushMatrix();
    zoomer.transform();
    updateCentroid();
    centroid.tick();

    parent.translate(width / 2, height / 2);
    parent.scale(centroid.getZ());
    parent.translate(-centroid.getX(), -centroid.getY());

    if (!isPaused) {
      updateParticles();
    }

    // Ensure that any selected element is positioned at the mouse location.
    if (selectedNode != null) {
      Particle p = nodes.get(selectedNode);
      p.makeFixed();
      float mX = (zoomer.getMouseCoord().x - (width / 2)) / centroid.getZ() + centroid.getX();
      float mY = (zoomer.getMouseCoord().y - (height / 2)) / centroid.getZ() + centroid.getY();
      p.position().set(mX, mY, 0);
    }

    // Draw edges if we have positive stroke weight.
    if (parent.g.strokeWeight > 0) {
      parent.stroke(0, 180);
      parent.noFill();

      for (Map.Entry<E, Spring> row : edges.entrySet()) {
        E edge = row.getKey();
        Spring spring = row.getValue();
        Vector3D p1 = spring.getOneEnd().position();
        Vector3D p2 = spring.getTheOtherEnd().position();
        edge.draw(parent, p1.x(), p1.y(), p2.x(), p2.y());
      }
    }

    // Draw nodes.
    parent.noStroke();
    parent.fill(120, 50, 50, 180);

    for (Map.Entry<N, Particle> row : nodes.entrySet()) {
      N node = row.getKey();
      Vector3D p = row.getValue().position();
      node.draw(parent, p.x(), p.y());
    }

    parent.popMatrix();
    parent.popStyle();
  }
Пример #10
0
 /**
  * @exclude
  * @param theApplet PApplet
  */
 @ControlP5.Invisible
 public final void draw(PApplet theApplet) {
   if (isVisible) {
     theApplet.pushMatrix();
     theApplet.translate(position.x, position.y);
     preDraw(theApplet);
     drawControllers(theApplet);
     postDraw(theApplet);
     if (_myValueLabel != null) {
       _myValueLabel.draw(theApplet, 2, 2, this);
     }
     theApplet.popMatrix();
   }
 }
Пример #11
0
  public void drawJunction() {
    parent.pushMatrix();
    if (stroke_color[0] != -1) {
      int[] rgb = RecursiveTower.hsvToRgb(stroke_color[0], stroke_color[1], stroke_color[2]);
      parent.stroke(rgb[0], rgb[1], rgb[2]);
    } else {
      parent.noStroke();
    }
    if (fill_color[0] != -1) {
      int[] rgb = RecursiveTower.hsvToRgb(fill_color[0], fill_color[1], fill_color[2]);
      parent.fill(rgb[0], rgb[1], rgb[2]);
    } else {
      parent.noFill();
    }
    switch (tower_orientation) {
      case 0:
        // moving in +x direction
        // +x becomes +y, +y becomes +z, +z becomes +x
        parent.translate(z, x, y);
        parent.box(z_dim, x_dim, y_dim);
        break;
      case 1:
        // moving in -x direction
        // +x becomes +y, +y becomes +z, +z becomes -x
        parent.translate(-z, x, y);
        parent.box(z_dim, x_dim, y_dim);
        break;
      case 2:
        // moving in +y direction
        // x stays the same, +y becomes +z, +z becomes +y
        parent.translate(x, z, y);
        parent.box(x_dim, z_dim, y_dim);
        break;
      case 3:
        // moving in -y direction
        // x stays the same, +y becomes +z, +z becomes -y
        parent.translate(x, -z, y);
        parent.box(x_dim, z_dim, y_dim);
        break;
      case 4:
        // moving in +z direction
        // xyz coordinates stay the same
        parent.translate(x, y, z);
        parent.box(x_dim, y_dim, z_dim);
        break;
    }

    parent.popMatrix();
  }
Пример #12
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();
  }
Пример #13
0
  /**
   * Draws the control where if should be drawn
   *
   * @param p
   */
  public void draw() {
    p.pushMatrix();
    p.pushStyle();

    p.translate(x, y);
    p.fill(textColor);

    // AlignUtils.positionText(p, width, height, xAlign, yAlign);
    p.textAlign(PApplet.LEFT, PApplet.CENTER);

    p.text(name, 0, height / 2);
    // p.text(name, 0, 0);

    p.popStyle();
    p.popMatrix();
  }
Пример #14
0
  public void draw(float x, float y) {

    x = x + layer.x();
    y = y + layer.y();

    applet.pushMatrix();
    doTransformation(x, y);
    if (mesh != null) {
      mesh.draw();
    }
    drawChildLayers(
        x,
        y); // This used to come AFTER popMatrix, but it seems that the parent layer needs to pass
    // on it's own scaling and such
    applet.popMatrix();
  }
Пример #15
0
  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();
  }
Пример #16
0
 public void display(PApplet theApplet, Controller<?> theController) {
   _myHeight = _myLabel.getHeight();
   theApplet.fill(_myBackgroundColor, _myAlpha);
   theApplet.rect(0, 0, getWidth() + _myBorder * 2, _myHeight + _myBorder * 2);
   theApplet.pushMatrix();
   if (_myAlignH == ControlP5.RIGHT) {
     theApplet.translate(6, 0);
   } else {
     theApplet.translate(getWidth() - 6, 0);
   }
   theApplet.triangle(0, 0, 4, -4, 8, 0);
   theApplet.popMatrix();
   int a = (int) (PApplet.map(_myAlpha, 0, _myMaxAlpha, 0, 255));
   _myLabel.setColor(
       a << 24 | (_myColor >> 16) << 16 | (_myColor >> 8) << 8 | (_myColor >> 0) << 0);
   _myLabel.draw(theApplet, 0, 0, theController);
 }
Пример #17
0
 public void render(float _f) {
   parent.pushMatrix();
   parent.scale(_f, -_f, _f);
   for (int i = 0; i < faces.length; i++) {
     parent.beginShape(TRIANGLES);
     for (int j = 0; j < 3; j++) {
       int vt = faces[i][j];
       PVector dis;
       if (apply == -1) {
         dis = new PVector(0.0f, 0.0f, 0.0f);
       } else {
         dis = auList[apply].getMotion(vt);
       }
       parent.vertex(vertices[vt].x + dis.x, vertices[vt].y + dis.y, vertices[vt].z + dis.z);
     }
     parent.endShape();
   }
   parent.popMatrix();
 }
Пример #18
0
 public void moveNormals() {
   changeMode();
   pApplet.pushMatrix();
   for (int j = 0; j < model.getSegmentCount(); j++) {
     Segment segment = model.getSegment(j);
     Face[] faces = segment.getFaces();
     pApplet.beginShape(PConstants.QUADS);
     for (int i = 0; i < faces.length; i++) {
       PVector[] vertices = faces[i].getVertices();
       PVector normal = faces[i].getNormal();
       float nor = PApplet.abs(PApplet.sin(PApplet.radians((pApplet.frameCount + i))) * 100);
       for (PVector vertex : vertices) {
         pApplet.vertex(
             vertex.x + (normal.x * nor),
             vertex.y + (normal.y * nor),
             vertex.z + (normal.z * nor));
       }
     }
     pApplet.endShape();
   }
   pApplet.popMatrix();
 }
Пример #19
0
  // draw method for all of the parts of the lamp
  public void draw(float zoom, float color, boolean shadeDraw, boolean partsDraw) {
    myParent.background(100, 100, 100);

    if (shadeDraw) {
      myParent.pushMatrix();
      myParent.translate(0, 0, zoom);
      for (int j = 0; j < shade.edges.size(); j++) {
        DCHalfEdge edge = shade.edges.get(j);
        float edgeStartX = (float) (edge.start.getX());
        float edgeStartY = (float) (edge.start.getY());

        float edgeEndX = (float) (edge.end.getX());
        float edgeEndY = (float) (edge.end.getY());
        myParent.stroke(color);
        myParent.strokeWeight(3);

        myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY);
      }
      myParent.popMatrix();
    }
    if (partsDraw) {
      myParent.pushMatrix();
      myParent.translate(myParent.width / 2 - 350, myParent.height / 2, zoom);
      for (int j = 0; j < rib.edges.size(); j++) {
        DCHalfEdge edge = rib.edges.get(j);
        float edgeStartX = (float) (edge.start.getX());
        float edgeStartY = (float) (edge.start.getY());

        float edgeEndX = (float) (edge.end.getX());
        float edgeEndY = (float) (edge.end.getY());

        myParent.stroke(color);
        myParent.strokeWeight(3);
        if (edge.inner) {
          myParent.stroke(255, 0, 0);
        }
        myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY);
      }
      myParent.popMatrix();

      myParent.pushMatrix();
      myParent.translate(100, 40, zoom);
      for (int j = 0; j < bottomBase.edges.size(); j++) {
        DCHalfEdge edge = bottomBase.edges.get(j);
        float edgeStartX = (float) (edge.start.getX());
        float edgeStartY = (float) (edge.start.getY());

        float edgeEndX = (float) (edge.end.getX());
        float edgeEndY = (float) (edge.end.getY());
        myParent.stroke(color);
        myParent.strokeWeight(3);
        if (edge.inner) {
          myParent.stroke(255, 0, 0);
        }
        myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY);
        myParent.stroke(255, 0, 0);
      }
      myParent.popMatrix();

      myParent.pushMatrix();
      myParent.translate(100, myParent.height - 150, zoom);
      for (int j = 0; j < topBase.edges.size(); j++) {

        DCHalfEdge edge = topBase.edges.get(j);
        float edgeStartX = (float) (edge.start.getX());
        float edgeStartY = (float) (edge.start.getY());

        float edgeEndX = (float) (edge.end.getX());
        float edgeEndY = (float) (edge.end.getY());
        myParent.stroke(color);
        myParent.strokeWeight(3);
        if (edge.inner) {
          myParent.stroke(255, 0, 0);
        }
        myParent.line(edgeStartX, edgeStartY, edgeEndX, edgeEndY);
        myParent.stroke(255, 0, 0);
      }
      myParent.popMatrix();
    }
  }