Package org.locationtech.udig.project.ui.tool

Examples of org.locationtech.udig.project.ui.tool.IToolContext


     * @return the Point that is the closest vertex.
     */
    public Coordinate getClosestSnapPoint( EditToolHandler handler, EditBlackboard editBlackboard, Point centerPoint, boolean includeVerticesInCurrent,
            SnapBehaviour snapBehaviour, EditState stateAfterSearch ) {
       
        IToolContext context = handler.getContext();
        MinFinder minFinder = new MinFinder(editBlackboard.toCoord(centerPoint));
        SearchBoxAnimation anim = new SearchBoxAnimation(centerPoint, new IsBusyStateProvider(
                handler));

        try {
            handler.setCurrentState(EditState.BUSY);
            if (snapBehaviour != SnapBehaviour.OFF && snapBehaviour != SnapBehaviour.GRID)
                AnimationUpdater.runTimer(context.getMapDisplay(), anim);
            switch( snapBehaviour ) {
            case OFF:
                return null;
            case SELECTED:
                searchSelection(handler, editBlackboard, centerPoint, includeVerticesInCurrent,
                        minFinder);
                return minFinder.getMinCoord();
            case CURRENT_LAYER:
                searchSelection(handler, editBlackboard, centerPoint, includeVerticesInCurrent,
                        minFinder);
                minFinder.add(searchLayer(handler.getEditLayer(), context, centerPoint));
                break;
            case ALL_LAYERS:
                searchSelection(handler, editBlackboard, centerPoint, includeVerticesInCurrent,
                        minFinder);
                for( ILayer layer : context.getMapLayers() ) {
                    minFinder.add(searchLayer(layer, context, centerPoint));
                }
                break;
            case GRID:
                Coordinate worldCoord = snapToGrid(centerPoint, context.getMap());
                try {
                    return JTS.transform(worldCoord, null,
                            editBlackboard.pointCoordCalculator.mapToLayer);
                } catch (TransformException e) {
                    return null;
View Full Code Here


  private static final String  EXTENSION_ID  = "org.locationtech.udig.tools.split.SplitTool"//$NON-NLS-1$
 
  @Override
  public void setActive(final boolean active) {
    super.setActive(active);
    IToolContext context = getContext();
    if (active && context.getMapLayers().size() > 0) {
      String message = Messages.SplitTool_draw_line_to_split;
      StatusBar.setStatusBarMessage(context, message);
    } else {
      StatusBar.setStatusBarMessage(context, "");//$NON-NLS-1$
    }
View Full Code Here

        this.handler = handler;
    }

    public void run() {

        IToolContext context = null;

        // if the constructor #ClearSelection(EditToolHandler) isn't called, get the context using
        // getContext, else get the handler context.

        context = (handler == null) ? getContext() : handler.getContext();

        assert context != null;
        List<ILayer> layers = context.getMap().getMapLayers();
        for( ILayer layer : layers ) {
            EditBlackboardUtil.getEditBlackboard(context, layer).clear();
            layer.getBlackboard().put(ProjectBlackboardConstants.LAYER__RENDERING_FILTER, null);
        }
        context.getMap().getBlackboard().put(EditToolHandler.CURRENT_SHAPE, null);
        context.getMap().getBlackboard().put(EditToolHandler.EDITSTATE, EditState.NONE);
        context.getMap().getBlackboard().put(ProjectBlackboardConstants.MAP__RENDERING_FILTER,
                null);
        context.sendASyncCommand(context.getEditFactory().createNullEditFeatureCommand());
        context.sendASyncCommand(context.getSelectionFactory().createNoSelectCommand());

        // this code should not be necessary as it should be caught by the events
        // IRenderManager manager = getContext().getMap().getRenderManager();
        // if(manager!=null){
        // manager.refresh(null);
View Full Code Here

        String name = geometryDescriptor.getLocalName();
        Filter bboxFilter = getBboxFilter(name, newBounds);
        SelectionCommandFactory cmdFactory = SelectionCommandFactory.getInstance();
        UndoableMapCommand selectCommand = cmdFactory.createSelectCommand(layer, bboxFilter);
       
        IToolContext toolContext = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());
        toolContext.sendASyncCommand(selectCommand);
    }
View Full Code Here

            java.awt.Point start = viewPort.worldToPixel(coords[0]);
            java.awt.Point end = viewPort.worldToPixel(coords[coords.length - 1]);
            commands.add(new ArrowDrawCommand(new Coordinate(start.x, start.y), new Coordinate(end.x, end.y)));
        }

        IToolContext toolContext = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());
        IDrawCommand compositeCommand = toolContext.getDrawFactory().createCompositeDrawCommand(commands);
        toolContext.sendASyncCommand(compositeCommand);
    }
View Full Code Here

            UndoableMapCommand setGeometryCmd = cmdFactory.createSetGeomteryCommand(feature, selectedLayer, newGeometry);
            cmdList.add(setGeometryCmd);
            count++;
        }
        CompositeCommand compositeCommand = new CompositeCommand(cmdList);
        IToolContext toolContext = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());
        toolContext.sendSyncCommand(compositeCommand);

        showMessage(display, Messages.getString("ReverseFeatureOrientation_info"), //$NON-NLS-1$
                Messages.getString("ReverseFeatureOrientation_infomsg") + count, MSGTYPE.INFO); //$NON-NLS-1$

    }
View Full Code Here

        }

        /*
         * first copy things over and if that works, delete the old ones
         */
        IToolContext toolContext = ApplicationGIS.createContext(ApplicationGIS.getActiveMap());
        try {
            CompositeCommand compositeCommand = new CompositeCommand(copyOverList);
            toolContext.sendSyncCommand(compositeCommand);
        } catch (Exception e) {
            showMessage(display,
                    Messages.getString("OperationUtils_error"), Messages.getString("OperationUtils_copyproblem"), MSGTYPE.ERROR); //$NON-NLS-1$ //$NON-NLS-2$
            return;
        }
        try {
            CompositeCommand compositeCommand = new CompositeCommand(deleteOldList);
            toolContext.sendSyncCommand(compositeCommand);
            showMessage(
                    display,
                    Messages.getString("OperationUtils_info"), MessageFormat.format(Messages.getString("OperationUtils_movedinfo"), count), MSGTYPE.WARNING); //$NON-NLS-1$ //$NON-NLS-2$
        } catch (Exception e) {
            showMessage(display,
View Full Code Here

        }

        if (drawShapeCommand == null) {
            DrawCommandFactory dcf = DrawCommandFactory.getInstance();
            drawShapeCommand = dcf.createDrawShapeCommand(shape);
            IToolContext context = handler.getContext();
            ViewportPane viewportPane = context.getViewportPane();
            viewportPane.addDrawCommand(drawShapeCommand);
        } else {
            drawShapeCommand.setShape(shape);
        }
        handler.repaint();
View Full Code Here


    @Override
    public void setActive( final boolean active ) {
        super.setActive(active);
        IToolContext context = getContext();
        if (active && context.getMapLayers().size() > 0) {
            String message = "Arc Tool activated, specify first point";
            StatusBar.setStatusBarMessage(context, message);
        } else {
            StatusBar.setStatusBarMessage(context, "");//$NON-NLS-1$
        }
View Full Code Here

      IWorkbenchPage page = PlatformUI.getWorkbench()
          .getActiveWorkbenchWindow().getActivePage();
      IViewPart viewPart = page.findView(MergeView.ID);
      page.hideView(viewPart);
    } finally {
      IToolContext context = getContext();
      if(context != null){
        UndoableMapCommand clearSelectionCommand = context
            .getSelectionFactory().createNoSelectCommand();

        context.sendASyncCommand(clearSelectionCommand);
      }
    }

  }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.ui.tool.IToolContext

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.