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

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


  @Override
  public IToolContext getContext() {
    if (this.mergeContext == null)
      return null;
    IToolContext itc = this.mergeContext.getToolContext();
    return itc;
  }
View Full Code Here


      // a different access
      // to current layer is adopted
      if (MergeContext.getInstance().getMergeMode() == MergeContext.MERGEMODE_TOOL) {
        // sets the command using the features present in the merge
        // builder
        IToolContext context = getContext();
        layer = context.getSelectedLayer();
      } else if (MergeContext.getInstance().getMergeMode() == MergeContext.MERGEMODE_OPERATION) {
        layer = ApplicationGIS.getActiveMap().getEditManager()
            .getSelectedLayer();
      }

      MergeFeatureBuilder mergeBuilder = mergeComposite.getMergeBuilder();
      final List<SimpleFeature> sourceFeatures = mergeBuilder
          .getSourceFeatures();
      final SimpleFeatureCollection sourceFeaturesCollection = DataUtilities
          .collection(sourceFeatures);

      final SimpleFeature mergedFeature = mergeBuilder
          .buildMergedFeature();

      mergeBuilder.removeFromSourceFeatures(sourceFeatures);

      MergeFeaturesCommand cmd = MergeFeaturesCommand.getInstance(layer,
          sourceFeaturesCollection, mergedFeature);

      context.getMap().sendCommandASync(cmd);

      StatusBar.setStatusBarMessage(context,
          Messages.MergeTool_successful);

      context.getViewportPane().repaint();

      close();
    }
View Full Code Here

    getContext().getViewportPane().repaint(validArea.x-2, validArea.y-2, validArea.width+4, validArea.height+4);
  }
 
  @Override
  protected void onMouseReleased(MapMouseEvent e) {
    IToolContext toolContext = getContext();

    // start animation
    AnimationUpdater.runTimer(toolContext.getMapDisplay(), new Pulse(e.getPoint()));
   
    ILayer mapGraphicLayer = findMapGraphicLayer(toolContext);
   
    FeatureIterator<SimpleFeature> features = null;
    try {
      Envelope bbox = toolContext.getBoundingBox(e.getPoint(), 4);
      ILayer selectedLayer = toolContext.getSelectedLayer();
      features = toolContext.getFeaturesInBbox(selectedLayer, bbox).features();
     
      ArrayList<ReferencedEnvelope> alerts = new ArrayList<ReferencedEnvelope>();
      ReferencedEnvelope bounds = new ReferencedEnvelope();
      while(features.hasNext()) {
        SimpleFeature feature = features.next();
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 = Messages.TrimTool_draw_line_to_trim;
            StatusBar.setStatusBarMessage(context, message);
        } else {
            StatusBar.setStatusBarMessage(context, "");//$NON-NLS-1$
        }
View Full Code Here

  @Test
  public void testWMSBasic() throws Exception {
    InfoTool infoTool = new InfoTool();
   
    IToolContext context = new TestToolContext(this.bufferedClickBbox,
        this.crs, this.viewportPane, this.layers, this.viewportModel
        );
   
    infoTool.setContext(context);
   
    MapMouseEvent e = new MapMouseEvent(null, 5, 5,
        MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.NONE);
   
        /*
         * box from from InfoTool.mouseReleased()
         */
        Envelope box = context.getBoundingBox( e.getPoint(), 5 );
        ReferencedEnvelope bbox;
        if( box instanceof ReferencedEnvelope) {
            bbox = (ReferencedEnvelope) box;
        }
        else {
            CoordinateReferenceSystem crs = context.getViewportModel().getCRS();
            bbox = new ReferencedEnvelope(box, crs);
           
        }
        /*
         * End InfoTool.mouseReleased() code
View Full Code Here

            ICommandService.class);
    private IHandler commandHandler;

    public void activate( EditToolHandler handler ) {
        Command command = service.getCommand(COMMAND_ID);
        IToolContext context = handler.getContext();
        commandHandler=new SnapBehaviourCommandHandler(context.getMapDisplay(), context.getMap());
        if (command != null)
            command.setHandler(commandHandler);
    }
View Full Code Here

     *
     * @param unselectedFeature
     */
    private void unselect(SimpleFeature unselectedFeature) {

        IToolContext context = this.mergeView.getContext();
        UndoableMapCommand unselectCommand = context.getSelectionFactory().createNoSelectCommand();

        context.sendASyncCommand(unselectCommand);
    }
View Full Code Here

    }

    public void run( IProgressMonitor monitor ) throws Exception {
        monitor.beginTask(Messages.SetGeomCommand_undoTask, 30);
        EditUtils.instance.cancelHideSelection(selectedLayer);
        IToolContext context = handler.getContext();

        this.refreshBounds=new ReferencedEnvelope(feature.getBounds());
        EditUtils.instance.refreshLayer(selectedLayer, feature, refreshBounds, false, true);

        unselectcommand = context.getSelectionFactory().createNoSelectCommand();
        command = context.getEditFactory().createSetEditFeatureCommand(feature,
                selectedLayer);
       
        unselectcommand.setMap(getMap());
        command.setMap(getMap());
       
View Full Code Here

        this.clickPoint = clickPoint;
        this.shape = shape;
    }
   
    public void run( IProgressMonitor monitor ) throws Exception {
        IToolContext context = handler.getContext();
        java.awt.Point point = new java.awt.Point(clickPoint.getX(), clickPoint.getY());
        ReferencedEnvelope bbox = handler.getContext().getBoundingBox(point,7);
        FeatureCollection<SimpleFeatureType, SimpleFeature> fc = context.getFeaturesInBbox(handler.getEditLayer(), bbox);
        FeatureIterator<SimpleFeature> it = fc.features();
        SimpleFeature feature = null;
        while (it.hasNext()) {
            SimpleFeature feat = it.next();
            if (feat.getID().equals(shape.getEditGeom().getFeatureIDRef().toString())) {
View Full Code Here

    public void run( IProgressMonitor monitor ) throws Exception {
        if (command != null) {
            // indicates a redo
            command.run(monitor);
        } else {
            IToolContext context = handler.getContext();
            ILayer editLayer = handler.getEditLayer();

            EditBlackboard editBlackboard = handler.getEditBlackboard(editLayer);
            editBlackboard.startBatchingEvents();
            BlockingSelectionAnim animation = new BlockingSelectionAnim(event.x, event.y);
            AnimationUpdater.runTimer(context.getMapDisplay(), animation);
            FeatureIterator<SimpleFeature> iter = getFeatureIterator();
            try {

                if (iter.hasNext()) {
                    runSelectionStrategies(monitor, iter);
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.