Package org.locationtech.udig.tools.edit.support

Examples of org.locationtech.udig.tools.edit.support.PrimitiveShape$Mutator


    }
   
    @Test
    public void testHoleOutOfShell() throws Exception {
        EditGeom polygon = bb.newGeom("line", ShapeType.POLYGON); //$NON-NLS-1$
        PrimitiveShape shell = polygon.getShell();
       
        bb.addPoint(10, 10, shell);
        bb.addPoint(20, 10, shell);
        bb.addPoint(20, 20, shell);
        bb.addPoint(10, 20, shell);
        bb.addPoint(10, 10, shell);
       
        PrimitiveShape hole = polygon.newHole();
        bb.addPoint(12, 12, hole);
        bb.addPoint(18, 0, hole);
       
        assertEquals(Messages.LegalShapeValidator_holeOutside, validator.isValid(handler, null, null));
    }
View Full Code Here


    }
   
    @Test
    public void testHoleIntersections() throws Exception {
        EditGeom polygon = bb.newGeom("line", ShapeType.POLYGON); //$NON-NLS-1$
        PrimitiveShape shell = polygon.getShell();
       
        bb.addPoint(10, 10, shell);
        bb.addPoint(20, 10, shell);
        bb.addPoint(20, 20, shell);
        bb.addPoint(10, 20, shell);
        bb.addPoint(10, 10, shell);
       
        PrimitiveShape hole = polygon.newHole();
        bb.addPoint(13, 12, hole);
        bb.addPoint(18, 12, hole);
        bb.addPoint(18, 18, hole);
        bb.addPoint(13, 12, hole);
       
        PrimitiveShape hole2 = polygon.newHole();
        bb.addPoint(15, 15, hole2);
        bb.addPoint(19, 15, hole2);
        bb.addPoint(19, 19, hole2);
        bb.addPoint(15, 15, hole2);
       
View Full Code Here

        if (EventType.MOVED != eventType) {
            return false;
        }

        boolean editting = handler.getCurrentState() == EditState.CREATING;
        PrimitiveShape currentShape = handler.getCurrentShape();
        int nPoints = currentShape == null ? 0 : currentShape.getNumPoints();

        boolean isValid = editting && nPoints <= 2;
        if(!isValid){
            clearFeedback();
        }
View Full Code Here

     *
     * @return <code>null</code>, as no undoable map command is needed
     */
    public UndoableMapCommand getFeedbackCommand( EditToolHandler handler, MapMouseEvent e,
                                                  EventType eventType ) {
        final PrimitiveShape currentShape = handler.getCurrentShape();
        if (currentShape == null) {
            return getCancelCommand(handler);
        }
        final int numPoints = currentShape.getNumPoints();
        assert numPoints == 1 || numPoints == 2;

        Point point1 = currentShape.getPoint(0);
        Shape shape = null;
        if (numPoints == 1) {
            linearArc.setLine(point1.getX(), point1.getY(), e.x, e.y);
            shape = linearArc;
        } else {
            Point point2 = currentShape.getPoint(1);
            double x1 = point1.getX();
            double y1 = point1.getY();
            double x2 = point2.getX();
            double y2 = point2.getY();
            double x3 = e.x;
View Full Code Here

  /**
   * Valid if current shape is not null and has at least two coordinates
   */
  public boolean isValid(EditToolHandler handler) {
    PrimitiveShape currentShape = handler.getCurrentShape();
    if (currentShape == null) {
      return false;
    }
    int nCoords = currentShape.getNumCoords();
    return nCoords > 1;
  }
View Full Code Here

   * @throws OperationNotFoundException
   */
  private LineString getTrimmingLineInLayerCrs(EditToolHandler handler)
    throws OperationNotFoundException, TransformException {

    final PrimitiveShape currentShape = handler.getCurrentShape();
    final LineString line = GeometryCreationUtil.createGeom(LineString.class, currentShape, false);
    return line;
  }
View Full Code Here

  /**
   * Valid if current shape is not null and has exactly three points.
   */
  public boolean isValid(EditToolHandler handler) {
    PrimitiveShape currentShape = handler.getCurrentShape();
    if (currentShape == null) {
      return false;
    }
    int nCoords = currentShape.getNumCoords();
    return nCoords == 3;
  }
View Full Code Here

    int nCoords = currentShape.getNumCoords();
    return nCoords == 3;
  }

  public UndoableMapCommand getCommand(EditToolHandler handler) {
    final PrimitiveShape currentShape = handler.getCurrentShape();
    final ILayer editLayer = handler.getEditLayer();

    // need to use map coordinates in order to avoid
    // possible inconsistencies between what the user
    // drawn and the projected result
    GeometryFactory gf = new GeometryFactory();
    CoordinateReferenceSystem layerCrs = LayerUtil.getCrs(editLayer);
    CoordinateReferenceSystem mapCrs = editLayer.getMap().getViewportModel().getCRS();
    Point p1 = gf.createPoint(currentShape.getCoord(0));
    Point p2 = gf.createPoint(currentShape.getCoord(1));
    Point p3 = gf.createPoint(currentShape.getCoord(2));

    try {
      p1 = (Point) GeoToolsUtils.reproject(p1, layerCrs, mapCrs);
      p2 = (Point) GeoToolsUtils.reproject(p2, layerCrs, mapCrs);
      p3 = (Point) GeoToolsUtils.reproject(p3, layerCrs, mapCrs);
View Full Code Here

            return new DeselectEditGeomCommand(handler, intersectingGeoms);
        } else if (e.isShiftDown() && !intersectingGeoms.isEmpty()) {
            return null;
        }
        // Check to see if shape is already on the blackboard
        PrimitiveShape newShape = findOnBlackboard(handler, e);

        if (newShape != null && newShape != handler.getCurrentShape()) {
            List<UndoableMapCommand> commands = new ArrayList<UndoableMapCommand>();
            commands.add(new SetCurrentGeomCommand(handler, newShape));
            commands.add(new SetEditFeatureCommand(handler, Point.valueOf(e.x, e.y), newShape));
View Full Code Here

        //for overlapping geometries, select a different one on each click
        boolean cycleGeom = false;
        //set when the currently selected feature has been found
        boolean selectedFound = false;
        //for returning to the first match when we have the last match selected and click once more
        PrimitiveShape firstMatch = null;
        if (handler.getCurrentShape() != null && handler.getCurrentShape().contains(e.x, e.y) && countOnBlackboard(handler, e) > 1) {
            cycleGeom = true;
        }
           
        ILayer editLayer = handler.getEditLayer();
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.edit.support.PrimitiveShape$Mutator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.