Esempio n. 1
0
  /** Draws the regression equation into the regression equation JLabel icon */
  public void setRegressionEquationLabel() {

    // get the LaTeX string for the regression equation

    String eqn;
    // GeoElement geoRegression = statDialog.getRegressionModel();

    try {
      // prepare number format
      StringTemplate highPrecision;
      if (daModel.getPrintDecimals() >= 0)
        highPrecision =
            StringTemplate.printDecimals(StringType.LATEX, daModel.getPrintDecimals(), false);
      else
        highPrecision =
            StringTemplate.printFigures(StringType.LATEX, daModel.getPrintFigures(), false);

      // no regression
      if (daModel.getRegressionMode().equals(Regression.NONE)
          || statDialog.getRegressionModel() == null) {
        eqn = "";
      }

      // nonlinear
      else {
        eqn = "y = " + statDialog.getRegressionModel().getFormulaString(highPrecision, true);
      }

    } catch (Exception e) {
      e.printStackTrace();
      eqn = "\\text{" + loc.getPlain("NotAvailable") + "}";
    }

    // create an icon with the LaTeX string
    ImageIcon icon =
        GeoGebraIconD.createLatexIcon(app, eqn, this.getFont(), false, Color.RED, null);

    // set the label icon with our equation string
    lblRegEquation.setIcon(icon);
    lblRegEquation.revalidate();

    updateGUI();
  }
Esempio n. 2
0
 private void printParts(Label label, double val, boolean degrees) {
   if (degrees) {
     label.setText(kernel.formatAngle(val, StringTemplate.defaultTemplate, true).toString());
     return;
   }
   parts = StringTemplate.printLimitedWidth(val, kernel, parts);
   if (parts[1] == null) {
     label.setText(parts[0]);
   } else {
     label.setText(parts[0] + "\u00D7 10");
     Element exponent = DOM.createElement("sup");
     exponent.setInnerText(parts[1]);
     label.getElement().appendChild(exponent);
   }
 }