/** * */ package cortexrules; import java.awt.geom.*; /** * add a new point to a list of points * * @author John H. Krantz Ph.D * @version 0.1 * */ public class AddPointArray { // private routine to add a shape to a list public Point2D [][] addPoint(Point2D [][] points, Point2D [] curPoint){ if (curPoint != null){ // only add if real shape if (points == null){ points = new Point2D.Double [1] []; points[0] = new Point2D.Double[curPoint.length]; for (int i = 0; i < curPoint.length; i ++){ points[0][i] = curPoint[i]; } } else { Point2D hold [][] = new Point2D[points.length][]; // put current shapes in hold variable for (int i = 0; i < points.length; i ++) hold[i] = points[i]; points = new Point2D[hold.length+1][]; // increase // length of array // return shapes for (int i = 0; i < hold.length; i ++) points[i] = hold[i]; points[points.length-1] = curPoint; // add new shape } } return points; } }