Examples of PrimitiveShape


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

    return Messages.AddVertexCommand_name + toAdd;
  }

  @Override
  public void run(IProgressMonitor monitor) throws Exception {
    PrimitiveShape shape = this.shape;
    handler.setCurrentShape(shape);
    boolean collapseVertices = board.isCollapseVertices();
    try {
      board.setCollapseVertices(false);
      board.addCoordinate(toAdd, shape);
      addedCoord = toAdd;
      index = shape.getNumPoints() - 1;
    } finally {
      board.setCollapseVertices(collapseVertices);
    }
    if (handler.getContext().getMapDisplay() != null && showAnimation) {
      IAnimation animation = new AddVertexAnimation(point.getX(), point.getY());
View Full Code Here

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

*/
public class PolygonCreationValidator implements IEditValidator {

    public String isValid( EditToolHandler handler, MapMouseEvent event, EventType type ) {

        PrimitiveShape shell = handler.getCurrentShape();
       
        assert shell==shell.getEditGeom().getShell();
       
        Point newPoint = Point.valueOf(event.x, event.y);
        int lastPointIndex = shell.getNumPoints()-1;
        if( shell.getNumPoints()>2 && EditUtils.instance.intersection(shell.getPoint(lastPointIndex), newPoint, shell, 0, lastPointIndex) ){
            return Messages.ValidHoleValidator_selfIntersection;
        }
        return null;
    }
View Full Code Here

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

   * @throws SplitFeaturesCommandException
   */
  private  LineString getSplittingLineInMapCRS(final EditToolHandler handler)
    throws SplitFeaturesCommandException {

      final PrimitiveShape currentShape = handler.getCurrentShape();
      final LineString lineInLayerCrs = GeometryCreationUtil.createGeom(LineString.class, currentShape, false);
      final CoordinateReferenceSystem mapCrs = MapUtil.getCRS(handler.getContext().getMap());

      LineString splittingLine = reprojectSplitLine(lineInLayerCrs, mapCrs);

View Full Code Here

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

    /**
     * Returns <code>true</code> if there's a linestring in the {@link EditBlackboard}'s
     * {@link EditToolHandler} to use as splitting line
     */
    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

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

* @since 1.1.0
*/
public class ValidHoleValidator implements IEditValidator {

    public String isValid( EditToolHandler handler, MapMouseEvent event, EventType type ) {
        PrimitiveShape shell = handler.getCurrentGeom().getShell();
        PrimitiveShape hole = handler.getCurrentShape();

        assert hole!=shell;
       
        // check the new edge (that will be created by event) to see if it intersect with the
        // rest of the hole
       
        Point newPoint = Point.valueOf(event.x, event.y);
        int lastPointIndex = hole.getNumPoints()-1;
        if( hole.getNumPoints()>2 && EditUtils.instance.intersection(hole.getPoint(lastPointIndex), newPoint, hole, 0, lastPointIndex) ){
            return Messages.ValidHoleValidator_selfIntersection;
        }
        if( !shell.contains(newPoint, true) )
            return Messages.ValidHoleValidator_outsideShell;
       
View Full Code Here

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

    public static void updateFeatures( ILayer layer, IProgressMonitor monitor, Envelope dirtyArea ) {
        EditBlackboard bb = getEditBlackBoardFromLayer(layer);
        List<EditGeom> geoms = bb.getGeoms();
        monitor.beginTask(Messages.EditBlackboardUtil_updating_selected_features, geoms.size());

        PrimitiveShape shape = (PrimitiveShape) layer.getMap().getBlackboard().get(
                EditToolHandler.CURRENT_SHAPE);
        EditManager editManager = (EditManager) layer.getMap().getEditManager();

        FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Set<Identifier> ids = new HashSet<Identifier>();
        for( EditGeom geom : geoms ) {
          ids.add(factory.featureId(geom.getFeatureIDRef().get()));
        }
        Id fidFilter = factory.id(ids);
        Filter filter =factory.and(fidFilter, layer.createBBoxFilter(dirtyArea, new NullProgressMonitor()));
         
        try {
            FeatureSource<SimpleFeatureType, SimpleFeature> fs = layer.getResource(FeatureSource.class, monitor);
            FeatureCollection<SimpleFeatureType, SimpleFeature>  results = fs.getFeatures(filter);
            FeatureIterator<SimpleFeature> reader = results.features();
            try {
                int read = 0;
                boolean selectedFound = false;
                List<EditGeom> toRemove = new ArrayList<EditGeom>();
                while( reader.hasNext() ) {
                  int count = geoms.size() - read;
                    monitor.setTaskName(MessageFormat.format(Messages.EditBlackboardUtil_count_remaining, new Object[] {count}));
                    read++;
                    SimpleFeature feature = reader.next();

                    for( EditGeom geom : geoms ) {
                        if (feature.getID().equals(geom.getFeatureIDRef().get())) {
                            toRemove.add(geom);
                        }
                    }

                    Map<Geometry, EditGeom> mapping = bb.addGeometry((Geometry) feature.getDefaultGeometry(),
                            feature.getID());
                    if (feature.getID().equals(shape.getEditGeom().getFeatureIDRef().get())) {
                        editManager.setEditFeature(feature, (Layer) layer);
                        layer.getMap().getBlackboard().put(EditToolHandler.CURRENT_SHAPE,
                                mapping.values().iterator().next().getShell());
                        selectedFound = true;
                    }
View Full Code Here

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

        switch( event.getType() ) {
        case EditManagerEvent.PRE_COMMIT:{
            Tool tool = ApplicationGIS.getToolManager().getActiveTool();
            if (tool instanceof AbstractEditTool) {
                AbstractEditTool aet = (AbstractEditTool) tool;
                PrimitiveShape shape = aet.getHandler().getCurrentShape();
                if (shape != null && shape.getEditGeom().isChanged())
                    aet.getContext()
                            .sendSyncCommand(
                                    aet.getHandler().getCommand(
                                            aet.getHandler().getAcceptBehaviours()));
                committing=event.getSource();
View Full Code Here

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

    private boolean active() {
        return ApplicationGIS.getToolManager().getActiveTool() instanceof AbstractEditTool;
    }
    private void setCurrentShape( ILayer layer ) {
      PrimitiveShape shapeToRestoreToCurrent;
      if( layer==null ){
        // Can't edit this layer but we don't want a shape from another layer to show up so
        // set the current shape to null;
        shapeToRestoreToCurrent = null;
      }else{
View Full Code Here

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

      handler.setCurrentShape(shapeToRestoreToCurrent);
    }

    private void storeCurrentShape( ILayer layer ) {
      if( layer!=null ){
          PrimitiveShape currentShape = handler.getCurrentShape();
          layer.getBlackboard().put(EditToolHandler.STORED_CURRENT_SHAPE, currentShape);
      }
    }
View Full Code Here

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

    public boolean isTrue( Object object, String value ) {
        IMap map = ApplicationGIS.getActiveMap();
        if( map==ApplicationGIS.NO_MAP || map.getMapLayers().size()==0 )
            return false;
        PrimitiveShape shape = (PrimitiveShape) map.getBlackboard().get(EditToolHandler.CURRENT_SHAPE);
        if( shape==null )
            return false;
       
        return shape.getEditGeom()!=null && shape.getEditGeom().getShapeType().toString().equalsIgnoreCase(value.trim());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.