svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / gui / graphictools / ToolSelectGraphic.java @ 40557
History | View | Annotate | Download (4.01 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.editing.gui.graphictools; |
25 |
|
26 |
import java.awt.Image; |
27 |
import java.awt.geom.Point2D; |
28 |
import java.awt.geom.Rectangle2D; |
29 |
|
30 |
import org.gvsig.andami.PluginServices; |
31 |
//import org.gvsig.fmap.mapcontext.layers.FBitSet;
|
32 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
33 |
import org.gvsig.fmap.mapcontrol.MapControl; |
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
35 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
36 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener; |
37 |
|
38 |
|
39 |
|
40 |
/**
|
41 |
* <p>Listener that selects the items of a {@link GraphicLayer GraphicLayer} that their area
|
42 |
* intersects with the point selected on the associated <code>MapControl</code>.</p>
|
43 |
*
|
44 |
* <p>Listens a single click of any mouse's button.</p>
|
45 |
*/
|
46 |
public class ToolSelectGraphic implements PointListener{ |
47 |
|
48 |
// private final Image img = new ImageIcon(MapControl.class.getResource(
|
49 |
// "images/PointSelectCursor.gif")).getImage();
|
50 |
/**
|
51 |
* The image to display when the cursor is active.
|
52 |
*/
|
53 |
private final Image img = PluginServices.getIconTheme().get("cursor-select-by-polygon").getImage(); |
54 |
|
55 |
/**
|
56 |
* The cursor used to work with this tool listener.
|
57 |
*
|
58 |
* @see #getCursor()
|
59 |
*/
|
60 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(img,
|
61 |
// new Point(16, 16), "");
|
62 |
|
63 |
/**
|
64 |
* Reference to the <code>MapControl</code> object that uses.
|
65 |
*/
|
66 |
protected MapControl mapCtrl;
|
67 |
|
68 |
/**
|
69 |
* <p>Creates a new <code>ToolSelectGraphic</code> object.</p>
|
70 |
*
|
71 |
* @param mc the <code>MapControl</code> where will be applied the changes
|
72 |
*/
|
73 |
public ToolSelectGraphic(MapControl mc) {
|
74 |
this.mapCtrl = mc;
|
75 |
} |
76 |
|
77 |
/*
|
78 |
* (non-Javadoc)
|
79 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
80 |
*/
|
81 |
public void point(PointEvent event) throws BehaviorException { |
82 |
// Point2D p = event.getPoint();
|
83 |
// Point2D mapPoint = mapCtrl.getViewPort().toMapPoint((int) p.getX(), (int) p.getY());
|
84 |
//
|
85 |
// // Tolerancia de 3 pixels
|
86 |
// double tol = mapCtrl.getViewPort().toMapDistance(3);
|
87 |
// GraphicLayer gLyr = mapCtrl.getMapContext().getGraphicsLayer();
|
88 |
// Rectangle2D recPoint = new Rectangle2D.Double(mapPoint.getX() - (tol / 2),
|
89 |
// mapPoint.getY() - (tol / 2), tol, tol);
|
90 |
//
|
91 |
// FBitSet oldBitSet = gLyr.getSelection();
|
92 |
//
|
93 |
// FBitSet newBitSet = gLyr.queryByRect(recPoint);
|
94 |
// if (event.getEvent().isControlDown())
|
95 |
// newBitSet.xor(oldBitSet);
|
96 |
// gLyr.setSelection(newBitSet);
|
97 |
//
|
98 |
// mapCtrl.drawGraphics();
|
99 |
} |
100 |
|
101 |
/*
|
102 |
* (non-Javadoc)
|
103 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
104 |
*/
|
105 |
public void pointDoubleClick(PointEvent event) throws BehaviorException { |
106 |
// TODO Auto-generated method stub
|
107 |
|
108 |
} |
109 |
|
110 |
/*
|
111 |
* (non-Javadoc)
|
112 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
|
113 |
*/
|
114 |
public Image getImageCursor() { |
115 |
return img;
|
116 |
} |
117 |
|
118 |
/*
|
119 |
* (non-Javadoc)
|
120 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
|
121 |
*/
|
122 |
public boolean cancelDrawing() { |
123 |
return false; |
124 |
} |
125 |
} |
126 |
|
127 |
|