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 Entry(SplineCADToolContext context) {
        SplineCADTool ctxt = context.getOwner();

        ctxt.setQuestion(PluginServices.getText(this, "insert_first_point"));
        ctxt.setDescription(new String[] {"cancel"});
        return;
      }
예제 #3
0
 /**
  * Equivale al transition del prototipo pero sin pasarle como parámetro el editableFeatureSource
  * que ya estará creado.
  *
  * @param sel Bitset con las geometrías que estén seleccionadas.
  * @param x parámetro x del punto que se pase en esta transición.
  * @param y parámetro y del punto que se pase en esta transición.
  */
 public void addPoint(double x, double y, InputEvent event) {
   SplineCADToolState actualState = (SplineCADToolState) _fsm.getPreviousState();
   String status = actualState.getName();
   if (status.equals("Spline.NextPoint") || status.equals("Spline.FirstPoint")) {
     list.add(new Point2D.Double(x, y));
     Geometry spline = createSpline((Point2D[]) list.toArray(new Point2D[0]));
     addTemporalCache(spline);
   }
 }
      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;
      }
예제 #5
0
  /**
   * Método para dibujar lo necesario para el estado en el que nos encontremos.
   *
   * @param g Graphics sobre el que dibujar.
   * @param selectedGeometries BitSet con las geometrías seleccionadas.
   * @param x parámetro x del punto que se pase para dibujar.
   * @param y parámetro x del punto que se pase para dibujar.
   */
  public void drawOperation(Graphics g, double x, double y) {
    SplineCADToolState actualState = _fsm.getState();
    String status = actualState.getName();
    if (status.equals("Spline.NextPoint") || status.equals("Spline.FirstPoint")) {
      //        	ArrayList points=new ArrayList();
      Point2D[] points = new Point2D[list.size() + 1];
      Point2D[] auxPoints = (Point2D[]) list.toArray(new Point2D[0]);
      for (int i = 0; i < auxPoints.length; i++) {
        points[i] = (Point2D) auxPoints[i].clone();
      }

      //        	points.addAll(list);
      points[points.length - 1] = new Point2D.Double(x, y);
      Geometry spline = createSpline(points);
      ViewPort vp = getCadToolAdapter().getMapControl().getViewPort();
      DrawOperationContext doc = new DrawOperationContext();
      doc.setGraphics((Graphics2D) g);
      doc.setViewPort(vp);
      doc.setSymbol(DefaultCADTool.selectionSymbol);
      try {
        spline.invokeOperation(Draw.CODE, doc);
      } catch (GeometryOperationNotSupportedException e) {
        e.printStackTrace();
      } catch (GeometryOperationException e) {
        e.printStackTrace();
      }

      //        	spline.draw((Graphics2D)g,vp,DefaultCADTool.selectionSymbol);
    }
    VectorialLayerEdited vle = getVLE();
    if (!vle.getLayer().isVisible()) return;
    try {
      Image imgSel = vle.getSelectionImage();
      if (imgSel != null) g.drawImage(imgSel, 0, 0, null);
      Image imgHand = vle.getHandlersImage();
      if (imgHand != null) g.drawImage(imgHand, 0, 0, null);
    } catch (Exception e) {
    }
  }
    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;
    }
예제 #8
0
 public void endTransition(double x, double y, MouseEvent event) {
   _fsm.endPoint(x, y, event);
 }
예제 #9
0
 /* (non-Javadoc)
  * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
  */
 public void transition(String s) throws CommandException {
   if (!super.changeCommand(s)) {
     _fsm.addOption(s);
   }
 }
예제 #10
0
 /* (non-Javadoc)
  * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
  */
 public void transition(double d) {
   _fsm.addValue(d);
 }
예제 #11
0
 /* (non-Javadoc)
  * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
  */
 public void transition(double x, double y, InputEvent event) {
   _fsm.addPoint(x, y, event);
 }
    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 Default(SplineCADToolContext context) {
   throw (new statemap.TransitionUndefinedException(
       "State: " + context.getState().getName() + ", Transition: " + context.getTransition()));
 }