public void doConstruction(ConstructionStep step) {
if (step.getConstructionType() == THREE_POINTS) {
Point P1 = (Point)step.getInputs()[0];
Point P2 = (Point)step.getInputs()[1];
Point P3 = (Point)step.getInputs()[2];
Line line12 = new Line(P1, P2);
Line line23 = new Line(P2, P3);
if (!((line12.getSlope().equalTo(line23.getSlope()))||(P1.equalTo(P2))
|| (P2.equalTo(P3)) || (P3.equalTo(P1)))) {
Triangle newTriangle = new Triangle(P1, P2, P3);
newTriangle.addToObjects(objects);
clearAndHide();
step.setOutputs(new Object[]
{newTriangle.getSides()[0], newTriangle.getSides()[1],
newTriangle.getSides()[2], newTriangle});
fireUndoableEditUpdate(new UndoableEditEvent(this, step));
}
else {
JOptionPane.showMessageDialog(this, "Please select three distinct"+
" non-collinear points", "Try Again", JOptionPane.ERROR_MESSAGE);
initDialog();
}
}
else if (step.getConstructionType() == POINT_LINE) {
Point P1 = (Point)step.getInputs()[0];
Line L1 = (Line)step.getInputs()[1];
if (!(P1.canIntersect(L1))) {
Triangle newTriangle = new Triangle(P1, L1);
newTriangle.addToObjects(objects);
clearAndHide();
step.setOutputs(new Object[]