Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [udig-devel] Drag and drop feature

Title: Message
Hi!
 
I wanted this too, to be able to just click and drag on an icon (point).
I basically wanted to simplify what now seems quite complex for the user:
    select the layer
    select the point with the selection tool
    move the point with the edit tool
    commit - to force the redraw and display the icon correctly.
 
In the end I wrote my own tool to do this using mouse events (could not figure out how to use the drag and drop events on the map).
 
Basically:
 
On MousePressed I located the correct point by searching the layers for points within the mouse x, y (+icon size).
(I did not want users to have to select the layer first).
 
On mouse Dragged I changed the mouse pointer to a hand (boolean check so this is only done once).
 
On Mouse Released I set the cursor back to normal and moved the point with the following code:
 
    (Note: oCurrentFeature, layer and map  variables are set from the mousePressed map search method)
 
    private void handleMove() {
       try {
            EditManager manager = (EditManager)map.getEditManager();  
           manager.setEditFeature(oCurrentFeature, layer);        

           Coordinate coord = map.getViewportModel().pixelToWorld(x, y);       
           GeometryFactory geomFactory = new GeometryFactory();
           com.vividsolutions.jts.geom.Point point = geomFactory.createPoint(coord); 
       
           oCurrentFeature.setAttribute(0, point); 
           manager.commitTransaction(); //forces a repaint
       } catch (Exception e) {
           final Exception fe = e;
                Display.getDefault().syncExec( new Runnable(){                   
                  public void run(){
                      MessageDialog.openWarning(shell, "Move Icon Point", "ERROR saving new position due to: "+fe.getMessage());          
                 }
             });       
         }
    }
 
 
Don't know if that help you.
 
Michelle
 
 
 
-----Original Message-----
From: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx [mailto:udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jonathan Magtalas
Sent: 26 April 2006 01:22
To: udig-devel@xxxxxxxxxxxxxxxxxxxxx
Subject: [udig-devel] Drag and drop feature

Hi,
 
I'm currently using uDig 1.1M7 and have been experimenting with feature styles using SLD.
I have a cities layer that is being represented by graphic icons and their default geometries are Point.
The only way I've found to drag these features is to use the Edit Geometry tool to select the point of
the feature and drag it. This initially drags the point by itself without the graphic icon. It is when I click
the mouse again that the icon is redrawn at the new location of the point. I'd like to modify this drag drop
functionality to just select and drag the feature and have the graphic icon move with the mouse until
I drop it. Is the ArrowSelection tool suppose to be able to do this? I looked at the code but cannot see
how it handles the drag and drop. Any help would be appreciated.
 
Regards,
Jonathan

Back to the top