<%
// Copy this code definition to a file named SplineRiskLines.jsp
// so it can be included in the RiskMapPlot sample program for
// the Basic Spline Risk Map.
// This code creates a list of points that the SplineRiskMap will use to
// create a spline that represents the boundary of a risk category. The points
// are calculated to represent a width and a height along the bmi curve.
final int POINTS_PER_LINE = 5;
final double MIN_WEIGHT = 25;
final double MAX_WEIGHT = 400;
final double UNDERWEIGHT_LIMIT = 18.5;
final double NORMAL_LIMIT = 25;
final double OVERWEIGHT_LIMIT = 30;
// Create line1 for an UNDERWEIGHT_LIMIT
ArrayList<Point2D.Double> line1 = new ArrayList<Point2D.Double>();
double weight1 = MIN_WEIGHT;
double weightInc1 = (MAX_WEIGHT - MIN_WEIGHT) / (POINTS_PER_LINE-1);
for (int i=0; i<POINTS_PER_LINE; i++)
{
double height1 = Math.sqrt(weight1 / (UNDERWEIGHT_LIMIT/703d));
line1.add(new Point2D.Double(weight1, height1));
weight1 += weightInc1;
}
// Create line2 for a NORMAL_LIMIT
ArrayList<Point2D.Double> line2 = new ArrayList<Point2D.Double>();
double weight2 = MIN_WEIGHT;
double weightInc2 = (MAX_WEIGHT - MIN_WEIGHT) / (POINTS_PER_LINE-1);
for (int i=0; i<POINTS_PER_LINE; i++)
{
double height2 = Math.sqrt(weight2 / (NORMAL_LIMIT/703d));
line2.add(new Point2D.Double(weight2, height2));
weight2 += weightInc2;
}
// Create line3 for an OVERWEIGHT_LIMIT
ArrayList<Point2D.Double> line3 = new ArrayList<Point2D.Double>();
double weight3 = MIN_WEIGHT;
double weightInc3 = (MAX_WEIGHT - MIN_WEIGHT) / (POINTS_PER_LINE-1);
for (int i=0; i<POINTS_PER_LINE; i++)
{
double height3 = Math.sqrt(weight3 / (OVERWEIGHT_LIMIT/703d));
line3.add(new Point2D.Double(weight3, height3));
weight3 += weightInc3;
}
%>