/*********************************************************************************
 JPlotJFunction.h
 
	Interface for the JPlotJFunction class.
 
	Copyright @ 1997 by Glenn W. Bach. All rights reserved.

 ********************************************************************************/
 
#ifndef _H_JPlotJFunction
#define _H_JPlotJFunction

#include <JPlotFunctionBase.h>

class JVariableList;
class JFunction;

class JPlotJFunction : public JPlotFunctionBase
{
public:

	static JBoolean Create(	JPlotJFunction **plotfunction, J2DPlotWidget* plot,
							JVariableList* varList, const JCharacter* function, 
							const JIndex xIndex, const JFloat xMin, const JFloat xMax);

	JPlotJFunction(	J2DPlotWidget* plot, JVariableList* varList, JFunction* f,
					const JBoolean ownsFn, const JIndex xIndex,
					const JFloat xMin, const JFloat xMax);

	virtual ~JPlotJFunction();

	const JFunction&	GetFunction() const;
	virtual JString		GetFunctionString() const;
	virtual JBoolean	GetYValue(const JFloat x, JFloat* y) const;

protected:

	virtual void	Receive(JBroadcaster* sender, const Message& message);

private:

	JVariableList*	itsVarList;		// not owned
	JFunction*		itsFunction;
	JBoolean		itsOwnsFnFlag;	// kTrue => delete itsFunction when destructed
	JIndex 			itsXIndex;
};


/*********************************************************************************
 GetFunction

 ********************************************************************************/

inline const JFunction&
JPlotJFunction::GetFunction()
	const
{
	return *itsFunction;
}

#endif
