Ejemplo n.º 1
0
  /** Compute circumference by adding up the length of it's segemnts. */
  @Override
  public final void compute() {
    if (!polygon.isDefined()) {
      circum.setUndefined();
      return;
    }

    GeoSegmentND[] segment = polygon.getSegments();
    double length = 0;
    for (int i = 0; i < segment.length; i++) {
      length = length + (segment[i].getLength());
    }
    circum.setValue(length);
  }
Ejemplo n.º 2
0
  public AlgoTextLength(Construction cons, String label, GeoText text) {
    super(cons);
    this.text = text;

    length = new GeoNumeric(cons);

    setInputOutput();
    compute();
    length.setLabel(label);
  }
Ejemplo n.º 3
0
  public AlgoDistanceLineLine(Construction cons, String label, GeoLine g, GeoLine h) {
    super(cons);
    this.h = h;
    this.g = g;
    dist = new GeoNumeric(cons);
    setInputOutput(); // for AlgoElement

    // compute length
    compute();
    dist.setLabel(label);
  }
Ejemplo n.º 4
0
  /**
   * Creates new drawable for slope
   *
   * @param view
   * @param slope
   */
  public DrawSlope(EuclidianView view, GeoNumeric slope) {
    this.view = view;
    kernel = view.getKernel();
    this.slope = slope;
    geo = slope;

    slope.setDrawable(true);

    // get parent line
    init();
    update();
  }
Ejemplo n.º 5
0
  public final void draw(Graphics2D g2) {
    if (isVisible) {
      fill(g2, gp, false); // fill using default/hatching/image as appropriate

      if (geo.doHighlighting()) {
        g2.setPaint(geo.getSelColor());
        g2.setStroke(selStroke);
        g2.draw(gp);
      }

      if (geo.lineThickness > 0) {
        g2.setPaint(slope.getObjectColor());
        g2.setStroke(objStroke);
        g2.draw(gp);
      }

      if (labelVisible) {
        g2.setPaint(slope.getLabelColor());
        g2.setFont(view.fontLine);
        drawLabel(g2);
        g2.drawString(horLabel, xLabelHor, yLabelHor);
      }
    }
  }
Ejemplo n.º 6
0
 @Override
 public final void compute() {
   if (text.isDefined()) length.setValue(text.getTextString().length());
   else length.setUndefined();
 }
Ejemplo n.º 7
0
 // calc length of vector v
 @Override
 public final void compute() {
   dist.setValue(g.distance(h));
 }
Ejemplo n.º 8
0
  public final void update() {
    isVisible = geo.isEuclidianVisible();
    if (isVisible) {
      if (!geo.getDrawAlgorithm().equals(geo.getParentAlgorithm())) init();
      int slopeTriangleSize = slope.getSlopeTriangleSize();
      double rwHeight = slope.getValue() * slopeTriangleSize;
      double height = view.yscale * rwHeight;
      if (Math.abs(height) > Float.MAX_VALUE) {
        isVisible = false;
        return;
      }

      // get point on line g
      g.getInhomPointOnLine(coords);
      if (g.getStartPoint() == null) {
        // get point on y-axis and line g
        coords[0] = 0.0d;
        coords[1] = -g.z / g.y;
      }
      view.toScreenCoords(coords);

      // draw slope triangle
      double x = coords[0];
      double y = coords[1];
      double xright = x + view.xscale * slopeTriangleSize;
      if (gp == null) gp = new GeneralPathClipped(view);
      gp.reset();
      gp.moveTo(x, y);
      gp.lineTo(xright, y);
      gp.lineTo(xright, y - height);

      // gp on screen?
      if (!gp.intersects(0, 0, view.width, view.height)) {
        isVisible = false;
        // don't return here to make sure that getBounds() works for offscreen points too
      }

      // label position
      labelVisible = geo.isLabelVisible();
      if (labelVisible) {
        if (slopeTriangleSize > 1) {
          StringBuilder sb = new StringBuilder();
          switch (slope.getLabelMode()) {
            case GeoElement.LABEL_NAME_VALUE:
              sb.append(slopeTriangleSize);
              sb.append(' ');
              sb.append(geo.getLabel());
              sb.append(" = ");
              sb.append(kernel.format(rwHeight));
              break;

            case GeoElement.LABEL_VALUE:
              sb.append(kernel.format(rwHeight));
              break;

            default: // case GeoElement.LABEL_NAME:
              sb.append(slopeTriangleSize);
              sb.append(' ');
              sb.append(geo.getLabel());
              break;
          }
          labelDesc = sb.toString();
        } else {
          labelDesc = geo.getLabelDescription();
        }
        yLabel = (int) (y - height / 2.0f + 6);
        xLabel = (int) (xright) + 5;
        addLabelOffset();

        // position off horizontal label (i.e. slopeTriangleSize)
        xLabelHor = (int) ((x + xright) / 2.0);
        yLabelHor = (int) (y + view.fontSize + 2);
        StringBuilder sb = new StringBuilder();
        sb.append(slopeTriangleSize);
        horLabel = sb.toString();
      }
      updateStrokes(slope);
    }
  }
Ejemplo n.º 9
0
 private void init() {
   g = ((AlgoSlope) slope.getDrawAlgorithm()).getg();
 }
Ejemplo n.º 10
0
 public AlgoPerimeterPoly(Construction cons, String label, GeoPolygon polygon) {
   this(cons, polygon);
   circum.setLabel(label);
 }