예제 #1
0
  public boolean doBool(ArrayList<Drawable> drawables, int bT) {
    if (drawables.size() > 1) {
      Drawable d1 = drawables.get(0);
      Drawable d2 = drawables.get(1);
      boolType = bT;
      switch (boolType) {
        case UNION:
          createdDrawable = PolyBoolean.union(d1.copy(), d2.copy());
          break;
        case DIFF:
          createdDrawable = PolyBoolean.difference(d1.copy(), d2.copy());
          break;
        case XOR:
          createdDrawable = PolyBoolean.xor(d1.copy(), d2.copy());

          break;
        case CLIP:
          createdDrawable = PolyBoolean.intersection(d1.copy(), d2.copy());
          break;
      }
      this.fireToolEvent(CustomEvent.DRAWABLE_CREATED);
      this.fireToolEvent(CustomEvent.BOOL_PERFORMED);
      return true;

    } else {

      return false;
    }
  }
  @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;
  }
예제 #3
0
  @Override
  public VarType evaluate() {
    Drawable d = null;
    VarType v = null;

    // try{
    Drawable aP = params.get(0).evaluate().asDrawable();
    Drawable bP = params.get(1).evaluate().asDrawable();
    // this.drawableEvent(CustomEvent.REMOVE_DRAWABLE, aP);
    // this.drawableEvent(CustomEvent.REMOVE_DRAWABLE, bP);

    d = PolyBoolean.union(aP.copy(), bP.copy());
    aP.hide();
    bP.hide();

    // d.setIdentifier(aP.getIdentifier());

    this.fireDrawableEvent(CustomEvent.DRAWABLE_CREATED, d);

    v = new VarType(d);

    d.setLine(line);

    // }
    /*catch (ClassCastException e){
    	throw new RuntimeException("Illegal union function call at line:"+ line+" : " + this);
    }*/
    return v;
  }
예제 #4
0
  @Override
  public void handleCustomDrawableEvent(Object source, int eventType, Drawable d1, Drawable d2) {
    // System.out.println("drawable event called");
    switch (eventType) {
      case CustomEvent.SWAP_DRAWABLE:
        int i = this.drawables.indexOf(d1);
        drawables.set(i, d2);
        d2.addEventListener(this);
        System.out.println("drawable swapped");

        break;
    }
  }
예제 #5
0
  @Override
  public void handleCustomDrawableEvent(Object source, int eventType, Drawable d) {
    System.out.println("drawable event called");
    switch (eventType) {
      case CustomEvent.DRAWABLE_CREATED:
        this.addDrawable(d);
        d.addEventListener(this);
        // System.out.println("drawable created");
        break;

      case CustomEvent.REMOVE_DRAWABLE:
        this.removeDrawable(d);
        d.removeEventListener(this);
        // System.out.println("drawable removed");
        // System.out.println("condensing holes");
        break;

      case CustomEvent.SHAPE_LOAD_REQUESTED:
        this.fireDrawableEvent(CustomEvent.SHAPE_LOAD_REQUESTED, d);
        break;
    }
    System.out.println("num drawables=" + this.drawables.size());
  }
예제 #6
0
  @Override
  public VarType evaluate() {
    Drawable d;

    d = param.evaluate().asDrawable().copy();

    d.flatten(true, new Drawable());
    Drawable flattened = d.getFlattenedDrawable();
    flattened.setLine(line);
    this.fireDrawableEvent(CustomEvent.DRAWABLE_CREATED, d.getFlattenedDrawable());
    return new VarType(flattened);
    // throw new RuntimeException("Illegal function call: " + this);
  }