com.brusoftware.plot4j
Class FunctionGraph

java.lang.Object
  extended by com.brusoftware.plot4j.Graph
      extended by com.brusoftware.plot4j.FunctionGraph

public class FunctionGraph
extends Graph

This class represents the graph of a two-variables function.

To generate the graph, a function must be provided, following the JavaScript syntax and using the Math object. That is:


For more informations, see W3Schools site.

Version:
0.1
Author:
Alessandro Brunelli

Constructor Summary
FunctionGraph(java.lang.String function, java.lang.String var_name)
          Creates a new FunctionGraph.
 
Method Summary
 java.lang.String getFunction()
          Returns the function represented by this FunctionGraph.
 int getNumOfPoints()
          Returns the number of interpolation points.
 void setFunction(java.lang.String f)
          Sets a new function to this FunctionGraph.
 void setNumOfPoints(int n)
          Sets the number of interpolation points.
 
Methods inherited from class com.brusoftware.plot4j.Graph
getGraphColor, getPoints, setGraphColor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionGraph

public FunctionGraph(java.lang.String function,
                     java.lang.String var_name)
Creates a new FunctionGraph.

Parameters:
function - the function represented by this FunctionGraph
var_name - the name of the free variable (case sensitive)
Method Detail

setFunction

public void setFunction(java.lang.String f)
Sets a new function to this FunctionGraph.
To perform the change of the function, the method refresh() of the Diagram containing this FunctionGraph must be called.

Parameters:
f - the new function
See Also:
Diagram.refresh()

getFunction

public java.lang.String getFunction()
Returns the function represented by this FunctionGraph.

Returns:
the function represented by this FunctionGraph

setNumOfPoints

public void setNumOfPoints(int n)
                    throws WrongValueException
Sets the number of interpolation points.
The field num_of_points specifies the number of interpolation points used to visualize the function represented by this FunctionGraph.
More points correspond to more precision.
The default value is 400.
If n < 2 an Exception will be thrown.

Parameters:
n - the number of interpolation points
Throws:
WrongValueException - if n < 2
See Also:
Graph.getPoints()

getNumOfPoints

public int getNumOfPoints()
Returns the number of interpolation points.

Returns:
the number of interpolation points
See Also:
setNumOfPoints(int), Graph.getPoints()