List<CPoint> points1 = new ArrayList<CPoint>();
List<CPoint> points2 = new ArrayList<CPoint>();
for (int i = 0, n = points.size() - 1; i < n; i++)
{
LineSegment lseg = new LineSegment(points.getCoordinate(i), points.getCoordinate(i+1));
if (lseg.onLineSegment(p))
{
List<CPoint> tpoints = subList(points, 0, i + 1);
points1.addAll(tpoints);
points1.add(p);