Package graphjx.algorithm

Source Code of graphjx.algorithm.Algorithm

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package graphjx.algorithm;

import graphjx.structure.Model;
import graphjx.structure.ValidationException;

/**
*
* @author Davide De Pasquale
*/
public abstract class Algorithm<T extends Model> {

    private T model;

    /**
     * Creates a new algorithm given a model.
     *
     * @param model
     */
    public Algorithm(T model) {
        this.model = model;
    }

    /**
     *
     * @return
     */
    public final T getDomain() {
        return this.model;
    }

    public abstract void init();

    public final Model process(Model model) throws ValidationException {
        if (!model.isValidated()) {
            model.validate();
        }
        if (!model.isValidated()) {
            throw new ValidationException("Cannot validate model");
        }

        Model m = doProcess(model);

        return m;
    }

    protected abstract Model doProcess(Model model);
}
TOP

Related Classes of graphjx.algorithm.Algorithm

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.