@Override protected void addPoint( PipeCADToolContext context, double pointX, double pointY, InputEvent event) { PipeCADTool ctxt = context.getOwner(); PipeCADToolState endState = context.getState(); context.clearState(); try { ctxt.addPoint(pointX, pointY, event); } finally { if (validStartEnd(pointX, pointY)) { try { ctxt.endGeometry(); ctxt.end(); ctxt.fireEndGeometry(); } finally { context.setState(Polyline.FirstPoint); (context.getState()).Entry(context); } } else { context.setState(endState); (context.getState()).Entry(context); } } return; }
@Override protected void removePoint(PipeCADToolContext context, InputEvent event, int numPoints) { PipeCADTool ctxt = context.getOwner(); if (numPoints > 1) { PipeCADToolState endState = context.getState(); context.clearState(); try { ctxt.removePoint(event); } finally { context.setState(endState); (context.getState()).Entry(context); } } else if (numPoints == 1) { (context.getState()).Exit(context); context.clearState(); try { ctxt.removePoint(event); } finally { context.setState(Polyline.FirstPoint); (context.getState()).Entry(context); } } else { super.removePoint(context, event, numPoints); } return; }
@Override protected void addOption(PipeCADToolContext context, String s) { PipeCADTool ctxt = context.getOwner(); if (s.equals(PluginServices.getText(this, "cancel"))) { boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName()); if (loopbackFlag == false) { (context.getState()).Exit(context); } context.clearState(); try { ctxt.cancel(); } finally { context.setState(Polyline.FirstPoint); if (loopbackFlag == false) { (context.getState()).Entry(context); } } } else if (s.equals("")) { boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName()); if (loopbackFlag == false) { (context.getState()).Exit(context); } context.clearState(); try { ctxt.endGeometry(); } finally { context.setState(Polyline.FirstPoint); if (loopbackFlag == false) { (context.getState()).Entry(context); } } } else { ctxt.throwOptionException(PluginServices.getText(this, "incorrect_option"), s); } return; }
@Override protected void addOption(PipeCADToolContext context, String s) { PipeCADTool ctxt = context.getOwner(); if (s.equals("A") || s.equals("a") || s.equals(PluginServices.getText(this, "inter_arc"))) { (context.getState()).Exit(context); context.clearState(); try { ctxt.addOption(s); } finally { context.setState(Polyline.NextPointOrLine); (context.getState()).Entry(context); } } else { super.addOption(context, s); } return; }
@Override protected void removePoint(PipeCADToolContext context, InputEvent event, int numPoints) { PipeCADTool ctxt = context.getOwner(); boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName()); if (loopbackFlag == false) { (context.getState()).Exit(context); } context.clearState(); try { ctxt.throwNoPointsException(PluginServices.getText(this, "no_points")); } finally { context.setState(Polyline.FirstPoint); if (loopbackFlag == false) { (context.getState()).Entry(context); } } return; }
@Override protected void addValue(PipeCADToolContext context, double d) { PipeCADTool ctxt = context.getOwner(); boolean loopbackFlag = context.getState().getName().equals(Polyline.FirstPoint.getName()); if (loopbackFlag == false) { (context.getState()).Exit(context); } context.clearState(); try { ctxt.throwValueException(PluginServices.getText(this, "incorrect_value"), d); } finally { context.setState(Polyline.FirstPoint); if (loopbackFlag == false) { (context.getState()).Entry(context); } } return; }
@Override protected void addPoint( PipeCADToolContext context, double pointX, double pointY, InputEvent event) { PipeCADTool ctxt = context.getOwner(); if (validStartEnd(pointX, pointY)) { (context.getState()).Exit(context); context.clearState(); try { ctxt.addPoint(pointX, pointY, event); } finally { context.setState(Polyline.NextPointOrArc); (context.getState()).Entry(context); } } else { JOptionPane.showMessageDialog( null, PluginServices.getText(this, "invalid_line_start"), PluginServices.getText(this, "error_title"), JOptionPane.ERROR_MESSAGE); } return; }