private GeoElement[] processParametric(Parametric par) throws CircularDefinitionException {

    /*
    ExpressionValue temp = P.evaluate();
          if (!temp.isVectorValue()) {
              String [] str = { "VectorExpected", temp.toString() };
              throw new MyParseError(kernel.getApplication(), str);
          }

          v.resolveVariables();
          temp = v.evaluate();
          if (!(temp instanceof VectorValue)) {
              String [] str = { "VectorExpected", temp.toString() };
              throw new MyParseError(kernel.getApplication(), str);
          } */

    // point and vector are created silently
    boolean oldMacroMode = cons.isSuppressLabelsActive();
    cons.setSuppressLabelCreation(true);

    // get point
    ExpressionNode node = par.getP();
    node.setForcePoint();
    GeoElement[] temp = processExpressionNode(node);
    GeoPoint P = (GeoPoint) temp[0];

    //	get vector
    node = par.getv();
    node.setForceVector();
    temp = processExpressionNode(node);
    GeoVector v = (GeoVector) temp[0];

    // switch back to old mode
    cons.setSuppressLabelCreation(oldMacroMode);

    // Line through P with direction v
    GeoLine line;
    // independent line
    if (P.isConstant() && v.isConstant()) {
      line = new GeoLine(cons);
      line.setCoords(-v.y, v.x, v.y * P.inhomX - v.x * P.inhomY);
    }
    // dependent line
    else {
      line = kernel.Line(par.getLabel(), P, v);
    }
    line.setToParametric(par.getParameter());
    line.updateRepaint();
    GeoElement[] ret = {line};
    return ret;
  }
  protected GeoElement[] processLine(Equation equ, boolean inequality) {
    double a = 0, b = 0, c = 0;
    GeoLine line;
    GeoElement[] ret = new GeoElement[1];
    String label = equ.getLabel();
    Polynomial lhs = equ.getNormalForm();
    boolean isExplicit = equ.isExplicit("y");
    boolean isIndependent = lhs.isConstant();

    if (isIndependent) {
      // get coefficients
      a = lhs.getCoeffValue("x");
      b = lhs.getCoeffValue("y");
      c = lhs.getCoeffValue("");
      line = kernel.Line(label, a, b, c);
    } else line = kernel.DependentLine(label, equ);

    if (isExplicit) {
      line.setToExplicit();
      line.updateRepaint();
    }
    ret[0] = line;
    return ret;
  }
 @Override
 public final String toString() {
   // Michael Borcherds 2008-03-30
   // simplified to allow better Chinese translation
   return app.getPlain("DistanceOfAandB", g.getLabel(), h.getLabel());
 }
 // calc length of vector v
 @Override
 public final void compute() {
   dist.setValue(g.distance(h));
 }
Beispiel #5
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);
    }
  }