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

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


    }

    public void run( IProgressMonitor monitor ) throws Exception {
        if (command == null) {
            ILayer selectedLayer = handler.getEditLayer();
            EditBlackboard editBlackboard = handler.getEditBlackboard(selectedLayer);
           
            Coordinate destinationCoord=null;
            Point dest;
            destinationCoord = calculateDestinationPoint(editBlackboard, destinationCoord);
   
            dest=editBlackboard.toPoint(destinationCoord);
            int deltaX = dest.getX() - lastPoint.getX();
            int deltaY = dest.getY()
                    - lastPoint.getY();
            if( deltaX!=0 || deltaY!=0 ){
                editBlackboard.moveSelection(deltaX, deltaY, toMove);
            }
            editBlackboard.setCoords(dest, destinationCoord);
   
            deltaX = dest.getX() - start.getX();
            deltaY = dest.getY() - start.getY();
   
           
View Full Code Here


    CoordinateReferenceSystem crs = MapUtil.getCRS(map);
    Unit<?> mapUnits = GeoToolsUtils.getDefaultCRSUnit(crs);

    parallelContext.setUnits(mapUnits);

    EditBlackboard bb = handler.getEditBlackboard(handler.getEditLayer());
    Point currPoint = Point.valueOf(event.x, event.y);
    Coordinate coor = bb.toCoord(currPoint);

    // previous line exist, if we change the reference line also need to
    // reset the initial point.
    // needs to store the line before setting the initial point.
    if (this.parallelContext.getReferenceFeature() != null) {
View Full Code Here

  String holeOverlap = Messages.LegalShapeValidator_holeOverlap;
  String holeOutside = Messages.LegalShapeValidator_holeOutside;

  public String isValid(EditToolHandler handler, MapMouseEvent event,
      EventType type) {
    EditBlackboard editBlackboard = handler.getEditBlackboard(handler
        .getEditLayer());
    List<EditGeom> geoms = editBlackboard.getGeoms();
    for (EditGeom geom : geoms) {
      String message = test(geom);
      if (message != null) {
        return message;
      }
View Full Code Here

  private void repaint() {
    handler.setCurrentShape(null);
    handler.setCurrentState(EditState.NONE);

    final ILayer selectedLayer = handler.getContext().getSelectedLayer();
    EditBlackboard editBlackboard = handler.getEditBlackboard(selectedLayer);
    editBlackboard.clear();

    handler.repaint();
  }
View Full Code Here

    public static EditBlackboard getEditBlackboard( IToolContext context, ILayer layer2 ) {
        if( layer2==null || !ApplicationGIS.getOpenMaps().contains(layer2.getMap()))
            return EMPTY_BLACKBOARD;
        ILayer layer = layer2;

        EditBlackboard editBlackBoard;
        blackboardLock.lock();
        try {
            EditManager editManager = ((EditManager) context.getEditManager());
            if (editManager.getEditLayer() != null && editManager.isEditLayerLocked()) {
                layer = context.getEditManager().getEditLayer();
            }

            editBlackBoard = getEditBlackBoardFromLayer(layer);
           
            if (editBlackBoard == null) {

                MathTransform layerToMapTransform;
                try {
                    layerToMapTransform = layer.layerToMapTransform();
                } catch (IOException e) {
                    EditPlugin.log("", e); //$NON-NLS-1$
                    layerToMapTransform = IDENTITY;
                }
                editBlackBoard = new EditBlackboard(context.getMapDisplay().getWidth(), context
                        .getMapDisplay().getHeight(), context.worldToScreenTransform(),
                        layerToMapTransform);

                final EditBlackboard bb = editBlackBoard;

                context.getViewportPane().addPaneListener(new IMapDisplayListener(){

                    public void sizeChanged( MapDisplayEvent event ) {
                        if (event.getOldSize() != null
                                && event.getOldSize().width != event.getSize().width)
                            bb.setWidth(event.getSize().width);
                        if (event.getOldSize() != null
                                && event.getOldSize().height != event.getSize().height)
                            bb.setHeight(event.getSize().height);
                    }

                });

                layer.getBlackboard().put(EDIT_BLACKBOARD_KEY, editBlackBoard);
View Full Code Here

     * @param layer that needs to be updated.
     * @param monitor progress monitor
     * @param dirtyArea area that needs to be updated.
     */
    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;
                    }
                    monitor.worked(1);
                }
                if (!selectedFound) {
                    layer.getMap().getBlackboard().put(EditToolHandler.CURRENT_SHAPE, null);
                    editManager.setEditFeature(null, null);
                }
                bb.removeGeometries(toRemove);
            } finally {
                reader.close();
                monitor.done();
            }
        } catch (IOException e) {
View Full Code Here

        if (map != null) {
            blackboardLock.lock();
            try {
                List<ILayer> layers = map.getMapLayers();
                for( ILayer layer : layers ) {
                    EditBlackboard blackboard = getEditBlackBoardFromLayer(layer);
                    if (blackboard != null){
                        blackboard.clear();
                        layer.getBlackboard().put(EDIT_BLACKBOARD_KEY, null);
                    }
                }
            } finally {
                blackboardLock.unlock();
View Full Code Here

        this.map=map;
        context=ApplicationGIS.createContext(map);
        selection();

        map.getEditManager().addListener(editManagerListener);
        EditBlackboard editBlackboard = EditBlackboardUtil.getEditBlackboard(context, map.getEditManager().getSelectedLayer());
        editBlackboard.getListeners().add(listener);
    }
View Full Code Here

    /**
     * Sets the selection to be a selection of vertices and returns true if there are any, otherwise
     * return false.
     */
    private boolean selectVertices( ) {
        EditBlackboard editBlackboard = EditBlackboardUtil.getEditBlackboard(context, map.getEditManager().getSelectedLayer());
       
        if( editBlackboard==null || editBlackboard.getSelection().isEmpty() )
            return false;
        selection=new StructuredSelection(editBlackboard.getSelection().toArray());

        notifyListeners();
        return true;
    }
View Full Code Here

* @since 1.1.0
*/
public class PopulateCaches implements IStartup {

    public void earlyStartup() {
        @SuppressWarnings("unused")
        EditBlackboard bb = EditBlackboardUtil.EMPTY_BLACKBOARD;
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.tools.edit.support.EditBlackboard

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.