// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   Square.java

package lt.ktu.gmj.tasks;

import lt.ktu.gmj.*;
import lt.ktu.gmj.propertySheet.*;

// Referenced classes of package lt.ktu.gmj.tasks:
//			SquareDomain

public class Square extends AbstractTask
	implements TaskWithAnalyzers
{

	private SquareDomain domain;
	public double multiplier;
	public int function;

	public Square()
	{
		domain = new SquareDomain();
		multiplier = 1.0D;
		function = 0;
	}

	public Class[] analyzers()
		throws ClassNotFoundException
	{
		Class class1 = Class.forName("lt.ktu.gmj.analysis.Spectrum");
		return (new Class[] {
			class1
		});
	}

	public void customize(PropertyManager propertymanager)
	{
		String as[] = {
			"(sum_i(x[i]-0.5)**2)/ n"
		};
		propertymanager.add(new DoubleProperty("Multiplier", new FieldProvider(this, "multiplier"), 0.10000000000000001D, 1000D));
		propertymanager.add(new ChoiceProperty("Function", new FieldProvider(this, "function"), as));
	}

	public Domain domain()
	{
		return domain;
	}

	public IResult f(Point point)
	{
		double d = 0.0D;
		for(int i = 0; i < point.x.length - 1; i++)
			d += (point.x[i] - 0.5D) * (point.x[i] - 0.5D) * multiplier;

		return new SimpleResult(d / (double)(point.x.length - 1));
	}
}
