Beispiel #1
0
  public OperandToken evaluate(Token[] operands) {

    // exactly one operand
    if (getNArgIn(operands) != 1) throwMathLibException("fix: number of arguments != 1");

    // only works on numbers
    if (!(operands[0] instanceof DoubleNumberToken))
      throwMathLibException("fix: only works on numbers");

    Frame f = new Frame();
    ModalDialog m =
        new ModalDialog(f, "kk", "What do you want?", new String[] {"ok", "not ok", "maybe"});

    // f.show();
    m.show();

    debugLine("questdlg: " + m.str);

    DoubleNumberToken matrix = ((DoubleNumberToken) operands[0]);
    OperandToken temp = ((OperandToken) matrix.clone());

    double[][] reValues = matrix.getValuesRe();
    double[][] imValues = matrix.getValuesIm();
    for (int y = 0; y < matrix.getSizeY(); y++) {
      for (int x = 0; x < matrix.getSizeX(); x++) {
        if (reValues[y][x] >= 0) {
          // e.g. fix(3.2) => 3
          reValues[y][x] = java.lang.Math.floor(reValues[y][x]);
        } else {
          // e.g. fix(-3.2) => -3
          reValues[y][x] = java.lang.Math.ceil(reValues[y][x]);
        }
        if (imValues[y][x] >= 0) {
          // e.g. fix(3.2i) => 3
          imValues[y][x] = java.lang.Math.floor(imValues[y][x]);
        } else {
          // e.g. fix(-3.2i) => -3
          imValues[y][x] = java.lang.Math.ceil(imValues[y][x]);
        }
      }
    }
    return new DoubleNumberToken(reValues, imValues);
  }
Beispiel #2
0
 protected void setBackgroundColor(Color color) {
   super.setBackgroundColor(color);
   if (m_cmbUser != null) ((BasicComboBoxRenderer) m_cmbUser.getRenderer()).setBackground(color);
 }