Package es.iiia.shapegrammar.rule

Source Code of es.iiia.shapegrammar.rule.RuleAddition

package es.iiia.shapegrammar.rule;

import org.w3c.dom.Element;

import es.iiia.shapegrammar.enums.ShapeGrammarRuleType;
import es.iiia.shapegrammar.execution.StateExecution;
import es.iiia.shapegrammar.model.ShapeGrammarModel;
import es.iiia.shapegrammar.shape.ShapeModel;

/**
* Created by Tomas Trescak, @ IIIA, UAB Barcelona.
* Date: Oct 27, 2008
* Time: 10:52:44 AM
*/
public class RuleAddition extends RuleModel {

  public RuleAddition(ShapeGrammarModel grammar) {
        super(grammar);
        this.ruleType = ShapeGrammarRuleType.Addition;

        this.setPropagateTransform(false);
    }
 
    public RuleAddition(ShapeGrammarModel grammar, Element element) {
        super(grammar, element);
        this.ruleType = ShapeGrammarRuleType.Addition;

        this.setPropagateTransform(false);
    }

    public RuleAddition(ShapeGrammarModel grammar, ShapeModel shape) {
        super(grammar, shape);
        this.ruleType = ShapeGrammarRuleType.Addition;

        this.setPropagateTransform(false);
    }

    // abstract method which for each different rule creates different results
    public ShapeModel execute(StateExecution state, boolean close) {
        ShapeModel returnShape = this.getRightShape().getCenteredShape();
        state.getAffineTransform().concatenate(this.getTransform());
        if (close) {
          state.setExecuted(true);
        }
        returnShape.transform(state.getAffineTransform());
        return returnShape;
    }


//    public RuleShapeModel setRightShape(ShapeModel rightShape) {
//        if (this.getRightShape() == null) {
//          return super.setRightShape(rightShape, null);
//        }
//        return null;
//    }

    // overriden methods

   
}
TOP

Related Classes of es.iiia.shapegrammar.rule.RuleAddition

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.