コード例 #1
0
  public DrawInformationAlgo copy() {
    GeoBoolean b = (GeoBoolean) this.getIsCumulative();
    if (b != null) {
      b = (GeoBoolean) b.copy();
    }

    return new AlgoBinomialDistBarChart(
        (NumberValue) this.getP1().deepCopy(kernel),
        (NumberValue) this.getP2().deepCopy(kernel),
        b,
        (NumberValue) this.getA().deepCopy(kernel),
        (NumberValue) this.getB().deepCopy(kernel),
        Cloner.clone(getValues()),
        Cloner.clone(getLeftBorder()),
        getIntervals());
  }
コード例 #2
0
ファイル: AlgoIsInRegion.java プロジェクト: Serabe/geogebra
 /**
  * Creates new algo
  *
  * @param c
  * @param label
  * @param pi
  * @param region
  */
 public AlgoIsInRegion(Construction c, String label, GeoPointND pi, Region region) {
   super(c);
   this.pi = pi;
   this.region = region;
   result = new GeoBoolean(cons);
   setInputOutput();
   compute();
   result.setLabel(label);
 }
コード例 #3
0
  @Override
  public Component getTableCellEditorComponent(
      JTable table, Object value, boolean isSelected, int row, int column) {

    editGeo = (GeoBoolean) value;
    delegate.setValue(editGeo.getBoolean());
    editing = true;
    checkBox.setBackground(table.getBackground());
    checkBox.setHorizontalAlignment(SwingConstants.CENTER);

    // enabled == isIndependent
    checkBox.setEnabled(editGeo.isIndependent());

    if (editGeo.isLabelVisible()) {
      // checkBox.setText(editGeo.getCaption());
    }
    return editorComponent;
  }
コード例 #4
0
ファイル: AlgoLaTeX.java プロジェクト: tomasp8/geogebra
  // calc the current value of the arithmetic tree
  @Override
  public final void compute() {

    boolean useLaTeX = true;

    if (!geo.isDefined()
        || (substituteVars != null && !substituteVars.isDefined())
        || showName != null && !showName.isDefined()) {
      text.setTextString("");

    } else {
      boolean substitute = substituteVars == null ? true : substituteVars.getBoolean();
      boolean show = showName == null ? false : showName.getBoolean();

      text.setTemporaryPrintAccuracy();

      // Application.debug(geo.getFormulaString(StringType.LATEX, substitute ));
      if (show) {
        text.setTextString(geo.getLaTeXAlgebraDescription(substitute));
        if (text.getTextString() == null) {
          text.setTextString(geo.getAlgebraDescriptionTextOrHTML());
          useLaTeX = false;
        }
      } else {
        if (geo.isGeoText()) {
          // needed for eg Text commands eg FormulaText[Text[
          text.setTextString(((GeoText) geo).getTextString());
        } else {
          text.setTextString(geo.getFormulaString(StringType.LATEX, substitute));
        }
      }

      text.restorePrintAccuracy();
    }

    text.setLaTeX(useLaTeX, false);

    /*
    int tempCASPrintForm = kernel.getCASPrintForm();
    kernel.setCASPrintForm(StringType.LATEX);
    text.setTextString(geo.getCommandDescription());
    kernel.setCASPrintForm(tempCASPrintForm);*/
  }
コード例 #5
0
  @Override
  public boolean stopCellEditing() {

    try {
      if (editGeo.isIndependent()) {
        editGeo.setValue(checkBox.isSelected());
        editGeo.updateCascade();
      }
      // app.storeUndoInfo();

    } catch (Exception ex) {
      ex.printStackTrace();
      super.stopCellEditing();
      editing = false;
      return false;
    }

    editing = false;
    return super.stopCellEditing();
  }
コード例 #6
0
  @Override
  protected void setInputOutput() {

    // build array list of possible arguments
    ArrayList<GeoElement> inputList = new ArrayList<GeoElement>();
    inputList.add(a.toGeoElement());
    inputList.add(b.toGeoElement());
    if (c != null) {
      inputList.add(c.toGeoElement());
    }
    if (d != null) {
      inputList.add(d.toGeoElement());
    }
    if (isCumulative != null) {
      inputList.add(isCumulative.toGeoElement());
    }

    // convert to array
    input = new GeoElement[inputList.size()];
    inputList.toArray(input);

    setOnlyOutput(num);
    setDependencies(); // done by AlgoElement
  }
コード例 #7
0
ファイル: RelativeCopy.java プロジェクト: Miguelos/geogebra
  public static GeoElement doCopyNoStoringUndoInfo0(
      Kernel kernel, App app, GeoElement value, GeoElement oldValue, int dx, int dy)
      throws Exception {
    if (value == null) {
      if (oldValue != null) {
        MatchResult matcher =
            GeoElementSpreadsheet.spreadsheetPatternPart.exec(
                oldValue.getLabel(StringTemplate.defaultTemplate));
        int column = GeoElementSpreadsheet.getSpreadsheetColumn(matcher);
        int row = GeoElementSpreadsheet.getSpreadsheetRow(matcher);

        prepareAddingValueToTableNoStoringUndoInfo(kernel, app, null, oldValue, column, row);
      }
      return null;
    }
    String text = null;

    // make sure a/0.001 doesn't become a/0

    StringTemplate highPrecision = StringTemplate.maxPrecision;
    if (value.isPointOnPath() || value.isPointInRegion()) {
      text = value.getCommandDescription(highPrecision);
    } else if (value.isChangeable()) {
      text = value.toValueString(highPrecision);
    } else {
      text = value.getCommandDescription(highPrecision);
    }

    // handle GeoText source value
    if (value.isGeoText() && !((GeoText) value).isTextCommand()) {
      // enclose text in quotes if we are copying an independent GeoText,
      // e.g. "2+3"
      if (value.isIndependent()) {
        text = "\"" + text + "\"";
      } else {

        // check if 'text' parses to a GeoText
        GeoText testGeoText = kernel.getAlgebraProcessor().evaluateToText(text, false, false);

        // if it doesn't then force it to by adding +"" on the end
        if (testGeoText == null) {
          text = text + "+\"\"";
        }
      }
    }

    // for E1 = Polynomial[D1] we need value.getCommandDescription();
    // even though it's a GeoFunction
    if (value.isGeoFunction() && text.equals("")) {
      // we need the definition without A1(x)= on the front
      text = ((GeoFunction) value).toSymbolicString(highPrecision);
    }

    boolean freeImage = false;

    if (value.isGeoImage()) {
      GeoImage image = (GeoImage) value;
      if (image.getParentAlgorithm() == null) {
        freeImage = true;
      }
    }

    // Application.debug("before:"+text);
    text = updateCellReferences(value, text, dx, dy);
    // Application.debug("after:"+text);

    // condition to show object
    GeoBoolean bool = value.getShowObjectCondition();
    String boolText = null, oldBoolText = null;
    if (bool != null) {
      if (bool.isChangeable()) {
        oldBoolText = bool.toValueString(highPrecision);
      } else {
        oldBoolText = bool.getCommandDescription(highPrecision);
      }
    }

    if (oldBoolText != null) {
      boolText = updateCellReferences(bool, oldBoolText, dx, dy);
    }

    String startPoints[] = null;
    if (value instanceof Locateable) {
      Locateable loc = (Locateable) value;

      GeoPointND[] pts = loc.getStartPoints();

      startPoints = new String[pts.length];

      for (int i = 0; i < pts.length; i++) {
        startPoints[i] = ((GeoElement) pts[i]).getLabel(highPrecision);
        startPoints[i] = updateCellReferences((GeoElement) pts[i], startPoints[i], dx, dy);
      }
    }

    // dynamic color function
    GeoList dynamicColorList = value.getColorFunction();
    String colorText = null, oldColorText = null;
    if (dynamicColorList != null) {
      if (dynamicColorList.isChangeable()) {
        oldColorText = dynamicColorList.toValueString(highPrecision);
      } else {
        oldColorText = dynamicColorList.getCommandDescription(highPrecision);
      }
    }

    if (oldColorText != null) {
      colorText = updateCellReferences(dynamicColorList, oldColorText, dx, dy);
    }

    // allow pasting blank strings
    if (text.equals("")) {
      text = "\"\"";
    }

    // make sure that non-GeoText elements are copied when the
    // equalsRequired option is set
    if (!value.isGeoText() && app.getSettings().getSpreadsheet().equalsRequired()) {
      text = "=" + text;
    }

    // Application.debug("add text = " + text + ", name = " + (char)('A' +
    // column + dx) + (row + dy + 1));

    // create the new cell geo
    MatchResult matcher =
        GeoElementSpreadsheet.spreadsheetPatternPart.exec(
            value.getLabel(StringTemplate.defaultTemplate));
    int column0 = GeoElementSpreadsheet.getSpreadsheetColumn(matcher);
    int row0 = GeoElementSpreadsheet.getSpreadsheetRow(matcher);
    GeoElement value2;
    if (freeImage || value.isGeoButton()) {
      value2 = value.copy();
      if (oldValue != null) {
        oldValue.remove();
      }
      // value2.setLabel(table.getModel().getColumnName(column0 + dx)
      //		+ (row0 + dy + 1));
      value2.setLabel(GeoElementSpreadsheet.getSpreadsheetCellName(column0 + dx, row0 + dy + 1));
      value2.updateRepaint();
    } else {
      value2 =
          prepareAddingValueToTableNoStoringUndoInfo(
              kernel, app, text, oldValue, column0 + dx, row0 + dy);
    }
    value2.setAllVisualProperties(value, false);

    value2.setAuxiliaryObject(true);

    // attempt to set updated condition to show object (if it's changed)
    if ((boolText != null)) {
      // removed as doesn't work for eg "random()<0.5" #388
      // && !boolText.equals(oldBoolText)) {
      try {
        // Application.debug("new condition to show object: "+boolText);
        GeoBoolean newConditionToShowObject =
            kernel.getAlgebraProcessor().evaluateToBoolean(boolText);
        value2.setShowObjectCondition(newConditionToShowObject);
        value2.update(); // needed to hide/show object as appropriate
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
    }

    // attempt to set updated dynamic color function (if it's changed)
    if ((colorText != null)) {
      // removed as doesn't work for eg "random()" #388
      // && !colorText.equals(oldColorText)) {
      try {
        // Application.debug("new color function: "+colorText);
        GeoList newColorFunction = kernel.getAlgebraProcessor().evaluateToList(colorText);
        value2.setColorFunction(newColorFunction);
        // value2.update();
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
    }

    if (startPoints != null) {
      for (int i = 0; i < startPoints.length; i++) {
        ((Locateable) value2)
            .setStartPoint(
                kernel.getAlgebraProcessor().evaluateToPoint(startPoints[i], false, true), i);
      }

      value2.update();
    }

    // Application.debug((row + dy) + "," + column);
    // Application.debug("isGeoFunction()=" + value2.isGeoFunction());
    // Application.debug("row0 ="+row0+" dy="+dy+" column0= "+column0+" dx="+dx);

    return value2;
  }
コード例 #8
0
ファイル: AlgoIsInRegion.java プロジェクト: Serabe/geogebra
 @Override
 public void compute() {
   pi.updateCoords2D();
   result.setValue(region.isInRegion(pi.getX2D(), pi.getY2D()));
 }