I remember I have seen that this package can deal with re-triangulation. Could you please give me some help? Thank you. The code I wrote is as below.
public static void testErrorCase() {
List<PolygonPoint> points = new ArrayList<PolygonPoint>();
PolygonPoint p1 = new PolygonPoint(0.0, 0.0);
PolygonPoint p2 = new PolygonPoint(1000.0, 0.0);
PolygonPoint p3 = new PolygonPoint(1000.0, 1000.0);
PolygonPoint p4 = new PolygonPoint(0.0, 1000.0);
points.add(p1);
points.add(p2);
points.add(p3);
points.add(p4);
Polygon polygon = new Polygon(points);
//
PolygonPoint q1;
PolygonPoint q2;
PolygonPoint q3;
PolygonPoint q4;
PolygonPoint q5;
PolygonPoint q6;
Polygon hole;
//
List<PolygonPoint> pointsForHole1 = new ArrayList<PolygonPoint>();
q1 = new PolygonPoint(244.8906951930522, 784.9009127526291);
q2 = new PolygonPoint(417.27284706091024, 633.4895106359271);
q3 = new PolygonPoint(437.80056771258273, 629.3750254650489);
q4 = new PolygonPoint(716.6601402050248, 813.2107179582445);
q5 = new PolygonPoint(690.2401226027848, 1000.0);
q6 = new PolygonPoint(262.25990550668615, 1000.0);
pointsForHole1.add(q1);
pointsForHole1.add(q2);
pointsForHole1.add(q3);
pointsForHole1.add(q4);
pointsForHole1.add(q5);
pointsForHole1.add(q6);
hole = new Polygon(pointsForHole1);
polygon.addHole(hole);
// If I comment the line below, it will be fine.
Poly2Tri.triangulate(polygon);
//
List<PolygonPoint> pointsForHole2 = new ArrayList<PolygonPoint>();
q1 = new PolygonPoint(245.22551393964045, 0.0);
q2 = new PolygonPoint(802.2744579508885, 0.0);
q3 = new PolygonPoint(828.2006326705192, 150.89951487587393);
q4 = new PolygonPoint(571.2499578357936, 376.5914529912652);
q5 = new PolygonPoint(218.81850471369796, 144.25415267198147);
pointsForHole2.add(q1);
pointsForHole2.add(q2);
pointsForHole2.add(q3);
pointsForHole2.add(q4);
pointsForHole2.add(q5);
hole = new Polygon(pointsForHole2);
polygon.addHole(hole);
Poly2Tri.triangulate(polygon);
}