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
}