Ejemplo n.º 1
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) {
    }
  }