Package urban.transformers

Source Code of urban.transformers.ShapeToRuleTransformer

package urban.transformers;

import urban.model.GeneratorStatement;
import urban.model.Model;
import urban.model.Statement;
import urban.model.info.ModelInfo;
import urban.shapes.RuleFactory;

/**
* Creates rules from generators and shapes in the model
*/
public class ShapeToRuleTransformer implements ModelTransformer {

  @Override
  public Model transform(Model in) {
    Model out = new Model();
    final RuleFactory ruleFactory = new RuleFactory(new ModelInfo(in.getLines()).getShapeParameters());
   
    for(Statement line : in.getLines()){
      out.addStatement(line);
      if (line instanceof GeneratorStatement)
        out.addStatements(ruleFactory.generateRules((((GeneratorStatement)line).getGenerator())));
    }
    return out;
  }

}
TOP

Related Classes of urban.transformers.ShapeToRuleTransformer

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.