protected void addOption(SplineCADToolContext context, String s) {
      SplineCADTool ctxt = context.getOwner();

      if (s.equals(PluginServices.getText(this, "cancel"))) {
        boolean loopbackFlag = context.getState().getName().equals(Spline.FirstPoint.getName());

        if (loopbackFlag == false) {
          (context.getState()).Exit(context);
        }

        context.clearState();
        try {
          ctxt.cancel();
        } finally {
          context.setState(Spline.FirstPoint);

          if (loopbackFlag == false) {
            (context.getState()).Entry(context);
          }
        }
      } else if (s.equals("")) {
        boolean loopbackFlag = context.getState().getName().equals(Spline.FirstPoint.getName());

        if (loopbackFlag == false) {
          (context.getState()).Exit(context);
        }

        context.clearState();
        try {
          ctxt.endGeometry();
        } finally {
          context.setState(Spline.FirstPoint);

          if (loopbackFlag == false) {
            (context.getState()).Entry(context);
          }
        }
      } else {
        boolean loopbackFlag = context.getState().getName().equals(Spline.FirstPoint.getName());

        if (loopbackFlag == false) {
          (context.getState()).Exit(context);
        }

        context.clearState();
        try {
          ctxt.throwOptionException(PluginServices.getText(this, "incorrect_option"), s);
        } finally {
          context.setState(Spline.FirstPoint);

          if (loopbackFlag == false) {
            (context.getState()).Entry(context);
          }
        }
      }

      return;
    }
      protected void addPoint(
          SplineCADToolContext context, double pointX, double pointY, InputEvent event) {
        SplineCADTool ctxt = context.getOwner();

        SplineCADToolState endState = context.getState();

        context.clearState();
        try {
          ctxt.setQuestion(
              PluginServices.getText(this, "insert_next_point")
                  + ", "
                  + PluginServices.getText(this, "close")
                  + " "
                  + "["
                  + PluginServices.getText(this, "SplineCADTool.close")
                  + "] "
                  + PluginServices.getText(this, "cad.or")
                  + " "
                  + PluginServices.getText(this, "end")
                  + " "
                  + "["
                  + PluginServices.getText(this, "SplineCADTool.end")
                  + "]");
          ctxt.setDescription(new String[] {"close", "terminate", "cancel"});
          ctxt.addPoint(pointX, pointY, event);
        } finally {
          context.setState(endState);
        }
        return;
      }
      protected void addOption(SplineCADToolContext context, String s) {
        SplineCADTool ctxt = context.getOwner();

        if (s.equalsIgnoreCase(PluginServices.getText(this, "SplineCADTool.close"))
            || s.equals(PluginServices.getText(this, "close"))) {

          (context.getState()).Exit(context);
          context.clearState();
          try {
            ctxt.addOption(s);
            ctxt.closeGeometry();
            ctxt.endGeometry();
            ctxt.end();
          } finally {
            context.setState(Spline.FirstPoint);
            (context.getState()).Entry(context);
          }
        } else if (s.equalsIgnoreCase(PluginServices.getText(this, "SplineCADTool.end"))
            || s.equals(PluginServices.getText(this, "terminate"))) {

          (context.getState()).Exit(context);
          context.clearState();
          try {
            ctxt.addOption(s);
            ctxt.endGeometry();
            ctxt.end();
          } finally {
            context.setState(Spline.FirstPoint);
            (context.getState()).Entry(context);
          }
        } else {
          super.addOption(context, s);
        }

        return;
      }
    protected void addValue(SplineCADToolContext context, double d) {
      SplineCADTool ctxt = context.getOwner();

      boolean loopbackFlag = context.getState().getName().equals(Spline.FirstPoint.getName());

      if (loopbackFlag == false) {
        (context.getState()).Exit(context);
      }

      context.clearState();
      try {
        ctxt.throwValueException(PluginServices.getText(this, "incorrect_value"), d);
      } finally {
        context.setState(Spline.FirstPoint);

        if (loopbackFlag == false) {
          (context.getState()).Entry(context);
        }
      }
      return;
    }
    protected void endPoint(
        SplineCADToolContext context, double pointX, double pointY, InputEvent event) {
      SplineCADTool ctxt = context.getOwner();

      boolean loopbackFlag = context.getState().getName().equals(Spline.FirstPoint.getName());

      if (loopbackFlag == false) {
        (context.getState()).Exit(context);
      }

      context.clearState();
      try {
        ctxt.addPoint(pointX, pointY, event);
        ctxt.endGeometry();
      } finally {
        context.setState(Spline.FirstPoint);

        if (loopbackFlag == false) {
          (context.getState()).Entry(context);
        }
      }
      return;
    }