Building Parsers with Java

sjm.examples.sling
Class Renderable

java.lang.Object
  |
  +--sjm.examples.sling.Renderable

public class Renderable
extends java.lang.Object

This class contains a Sling function and the number of lines to use in rendering the function. Note that the number of lines may itself be a function. Also note that the number of lines to use when rendering will be evaluated at the beginning of a plot, when time = 0. At rendering time, the number of lines is:

     nLine.eval().f(0).y
 
For example, nLine might be 100*s1 + t. Say the slider is halfway over. At rendering time, t = 0 and nLine will evaluate to 100*.5 + 0, or 50. The function f(0) returns a point, which will be (0, 50). The y value of this point is 50 and thus the number of lines to use will be 50.


Field Summary
protected  SlingFunction function
           
protected  SlingFunction nLine
           
 
Constructor Summary
Renderable(SlingFunction function, SlingFunction nLine)
          Create a function that will be rendered with the given number of lines.
 
Method Summary
 Extrema getExtrema()
          Find the upper and lower points the function will reach, given the number of points used to plot it.
 int nLine()
          Return the number of lines to use to render this function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

function

protected SlingFunction function

nLine

protected SlingFunction nLine
Constructor Detail

Renderable

public Renderable(SlingFunction function,
                  SlingFunction nLine)
Create a function that will be rendered with the given number of lines.
Parameters:
function - the sling function to render
nLine - the number of lines to use when rendering; this may be any function
Method Detail

getExtrema

public Extrema getExtrema()
Find the upper and lower points the function will reach, given the number of points used to plot it.
Returns:
a pairing of the upper and lower points the function will reach, given the number of points used to plot it

nLine

public int nLine()
Return the number of lines to use to render this function.
Returns:
the number of lines to use to render this function.

by Steve Metsker