@Override
  public VarType evaluate() {
    Drawable d = new Drawable();
    double start = startExpr.evaluate().asDouble().intValue();
    double stop = stopExpr.evaluate().asDouble().intValue();
    double increment = 1.0;
    if (incrementExpr != null) {
      increment = startExpr.evaluate().asDouble();
    }
    for (double i = start; i <= stop; i += increment) {
      scope.assign(identifier, new VarType(i));
      VarType returnValue = block.evaluate();

      if (returnValue.isDrawable() && lookup) {
        Drawable d2 = returnValue.asDrawable();
        d.addToGroup(d2);
        d2.removeFromCanvas();
        // System.out.println("added drawable in for loop at+"+i);

      }
      /*
      else if(returnValue != VarType.VOID ) {
          return returnValue;

      }*/
    }

    return VarType.VOID;
  }
Esempio n. 2
0
  @Override
  public VarType evaluate() {

    VarType a = lhs.evaluate();
    VarType b = rhs.evaluate();

    if (a.isBoolean() && b.isBoolean()) {
      return new VarType(a.asBoolean() && b.asBoolean());
    }
    if (a.isDrawable() && b.isDrawable()) {
      Drawable aP = a.asDrawable();
      Drawable bP = b.asDrawable();
      this.fireDrawableEvent(CustomEvent.REMOVE_DRAWABLE, aP);
      this.fireDrawableEvent(CustomEvent.REMOVE_DRAWABLE, bP);
      Drawable d = PolyBoolean.intersection(aP, bP);
      // TODO: add actual line number instead of 0 here
      this.fireDrawableEvent(CustomEvent.DRAWABLE_CREATED, d);
      // d.setLine(line);
      return new VarType(d);
    } else {
      throw new RuntimeException("illegal expression: " + this);
    }
  }