Revision 35485
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/operations/InfoByPoint.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package org.gvsig.fmap.mapcontext.layers.operations; |
42 | 42 |
|
43 |
import java.awt.Point; |
|
44 | 43 |
|
45 | 44 |
import org.gvsig.fmap.dal.exception.DataException; |
45 |
import org.gvsig.fmap.geom.primitive.Point; |
|
46 | 46 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
47 | 47 |
import org.gvsig.tools.dynobject.DynObjectSet; |
48 | 48 |
import org.gvsig.tools.task.Cancellable; |
... | ... | |
82 | 82 |
* TODO |
83 | 83 |
* @throws LoadLayerException |
84 | 84 |
* any exception produced using the driver. |
85 |
* |
|
86 |
* @deprecated use instead {@link #getInfo(Point, double)} |
|
85 | 87 |
*/ |
86 |
public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel) |
|
88 |
public DynObjectSet getInfo(java.awt.Point p, double tolerance, Cancellable cancel)
|
|
87 | 89 |
throws LoadLayerException, DataException; |
88 | 90 |
|
89 | 91 |
/** |
... | ... | |
118 | 120 |
* TODO |
119 | 121 |
* @throws LoadLayerException |
120 | 122 |
* any exception produced using the driver. |
123 |
* |
|
124 |
* @deprecated use instead {@link #getInfo(Point, double)} |
|
121 | 125 |
*/ |
122 |
public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel, |
|
126 |
public DynObjectSet getInfo(java.awt.Point p, double tolerance, Cancellable cancel,
|
|
123 | 127 |
boolean fast) throws LoadLayerException, DataException; |
128 |
|
|
129 |
/** |
|
130 |
* <p> |
|
131 |
* Executes a consultation about information of a point on the layer. |
|
132 |
* </p> |
|
133 |
* |
|
134 |
* <p> |
|
135 |
* There is an area around the point where will got the information. |
|
136 |
* </p> |
|
137 |
* |
|
138 |
* @param p |
|
139 |
* point in map coordinates where is the consultation |
|
140 |
* @param tolerance |
|
141 |
* permissible margin around the coordinates of the point where |
|
142 |
* the method will got the information. Each |
|
143 |
* singular implementation of this method would use it in a |
|
144 |
* different way. The unit are in map coordinates. |
|
145 |
*/ |
|
146 |
public DynObjectSet getInfo(Point p, double tolerance) throws LoadLayerException, DataException; |
|
124 | 147 |
} |
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java | ||
---|---|---|
1236 | 1236 |
return (FeatureStore) getDataStore(); |
1237 | 1237 |
} |
1238 | 1238 |
|
1239 |
/** |
|
1240 |
* @deprecated use instead {@link #queryByPoint(org.gvsig.fmap.geom.primitive.Point, double, FeatureType)} |
|
1241 |
*/ |
|
1239 | 1242 |
public FeatureSet queryByPoint(Point2D mapPoint, |
1240 | 1243 |
double tol, |
1241 | 1244 |
FeatureType featureType) throws DataException { |
1245 |
logger.warn("Deprecated use of queryByPoint."); |
|
1242 | 1246 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
1243 | 1247 |
org.gvsig.fmap.geom.primitive.Point center; |
1244 | 1248 |
try { |
... | ... | |
1256 | 1260 |
} |
1257 | 1261 |
} |
1258 | 1262 |
|
1263 |
public FeatureSet queryByPoint(org.gvsig.fmap.geom.primitive.Point point, |
|
1264 |
double tol, |
|
1265 |
FeatureType featureType) throws DataException { |
|
1266 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
1267 |
try { |
|
1268 |
Circle circle = |
|
1269 |
(Circle) manager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
|
1270 |
circle.setPoints(point, tol); |
|
1271 |
return queryByGeometry(circle, featureType); |
|
1272 |
} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) { |
|
1273 |
throw new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e); |
|
1274 |
} |
|
1275 |
} |
|
1276 |
|
|
1259 | 1277 |
public FeatureSet queryByGeometry(Geometry geom, FeatureType featureType) throws DataException { |
1260 | 1278 |
FeatureQuery featureQuery = featureStore.createFeatureQuery(); |
1261 | 1279 |
String geomName = |
... | ... | |
1316 | 1334 |
getFeatureStore().getDefaultFeatureType()).getDynObjectSet(fast); |
1317 | 1335 |
} |
1318 | 1336 |
|
1337 |
public DynObjectSet getInfo(org.gvsig.fmap.geom.primitive.Point p, |
|
1338 |
double tolerance) throws LoadLayerException, DataException { |
|
1339 |
return queryByPoint(p,tolerance, getFeatureStore().getDefaultFeatureType()).getDynObjectSet(true); |
|
1340 |
} |
|
1341 |
|
|
1319 | 1342 |
public void legendCleared(LegendClearEvent event) { |
1320 | 1343 |
// this.updateDrawVersion(); TODO |
1321 | 1344 |
LegendChangedEvent e = |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/InitializeApplicationExtension.java | ||
---|---|---|
12 | 12 |
import org.gvsig.andami.PluginServices; |
13 | 13 |
import org.gvsig.andami.plugins.Extension; |
14 | 14 |
import org.gvsig.app.ApplicationLocator; |
15 |
import org.gvsig.app.project.documents.view.toolListeners.InfoListener; |
|
15 | 16 |
import org.gvsig.app.tools.swing.serv.field.crs.JCRSDynFieldComponentFactory; |
16 | 17 |
import org.gvsig.app.tools.swing.serv.field.date.JDateDynFieldComponentFactory; |
17 | 18 |
import org.gvsig.app.tools.swing.serv.field.number.JNumberDynFieldComponentFactory; |
... | ... | |
39 | 40 |
DALLocator.getDataManager().registerDefaultEvaluator( |
40 | 41 |
SQLJEPEvaluator.class); |
41 | 42 |
|
43 |
InfoListener.initializeExtensionPoint(); |
|
42 | 44 |
addToLogInfo(); |
43 | 45 |
registerIcons(); |
44 | 46 |
} |
... | ... | |
199 | 201 |
} |
200 | 202 |
|
201 | 203 |
|
202 |
|
|
203 |
writer.write("gvSIG version: " + Version.longFormat() + "\n");
|
|
204 |
Version version = new Version(); |
|
205 |
writer.write("gvSIG version: " + version.getLongFormat() + "\n");
|
|
204 | 206 |
writer.write(" gvSIG app exec path: " + andamiPath + "\n"); |
205 | 207 |
writer.write(" gvSIG user app home: " + Launcher.getAppHomeDir() + "\n"); |
206 | 208 |
writer.write(" gvSIG extension path: " + extensionsPath + "\n"); |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/InfoToolExtension.java | ||
---|---|---|
46 | 46 |
*/ |
47 | 47 |
package org.gvsig.app.extension; |
48 | 48 |
|
49 |
import org.slf4j.Logger; |
|
50 |
import org.slf4j.LoggerFactory; |
|
51 |
|
|
49 | 52 |
import org.gvsig.andami.PluginServices; |
50 | 53 |
import org.gvsig.andami.plugins.Extension; |
51 |
import org.gvsig.app.project.documents.AbstractDocument;
|
|
52 |
import org.gvsig.app.project.documents.view.ViewDocument;
|
|
53 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
|
|
54 |
import org.gvsig.andami.ui.mdiManager.IWindow;
|
|
55 |
import org.gvsig.app.ApplicationLocator;
|
|
56 |
import org.gvsig.app.project.documents.view.gui.IView;
|
|
54 | 57 |
import org.gvsig.fmap.mapcontext.MapContext; |
55 | 58 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
56 | 59 |
import org.gvsig.fmap.mapcontrol.MapControl; |
57 |
import org.slf4j.Logger; |
|
58 |
import org.slf4j.LoggerFactory; |
|
59 | 60 |
|
60 | 61 |
|
61 | 62 |
|
... | ... | |
67 | 68 |
private static final Logger logger = LoggerFactory |
68 | 69 |
.getLogger(InfoToolExtension.class); |
69 | 70 |
|
71 |
public void initialize() { |
|
72 |
registerIcons(); |
|
73 |
} |
|
74 |
|
|
75 |
private void registerIcons(){ |
|
76 |
PluginServices.getIconTheme().registerDefault( |
|
77 |
"view-query-information", |
|
78 |
InfoToolExtension.class.getClassLoader().getResource("images/Identify.png") |
|
79 |
); |
|
80 |
} |
|
81 |
|
|
70 | 82 |
public void execute(String s) { |
71 |
AbstractViewPanel vista = (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
72 |
MapControl mapCtrl = vista.getMapControl(); |
|
73 |
logger.debug("Comand : " + s); |
|
83 |
logger.debug("Comand : " + s); |
|
74 | 84 |
|
75 |
if (s.compareTo("INFO") == 0) { |
|
76 |
mapCtrl.setTool("info"); |
|
77 |
((AbstractDocument)vista.getModel()).setModified(true); |
|
78 |
} |
|
85 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
|
86 |
if( window instanceof IView ) { |
|
87 |
IView view = (IView) window; |
|
88 |
MapControl mapCtrl = view.getMapControl(); |
|
89 |
|
|
90 |
if (s.compareTo("INFO") == 0) { |
|
91 |
mapCtrl.setTool("info"); |
|
92 |
view.getDocument().setModified(true); |
|
93 |
} |
|
94 |
} |
|
79 | 95 |
} |
80 | 96 |
|
81 |
|
|
82 |
/** |
|
83 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible() |
|
84 |
*/ |
|
85 | 97 |
public boolean isEnabled() { |
86 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
87 |
.getActiveWindow(); |
|
98 |
IWindow window = ApplicationLocator.getManager().getActiveWindow(); |
|
88 | 99 |
|
89 |
if (f == null) {
|
|
100 |
if (window == null) {
|
|
90 | 101 |
return false; |
91 | 102 |
} |
92 | 103 |
|
93 |
if (f instanceof AbstractViewPanel) { |
|
94 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
|
95 |
ViewDocument model = vista.getModel(); |
|
96 |
MapContext mapa = model.getMapContext(); |
|
104 |
if (window instanceof IView) { |
|
105 |
IView view = (IView) window; |
|
106 |
MapContext mapa = view.getViewDocument().getMapContext(); |
|
97 | 107 |
|
98 | 108 |
FLayer[] layers =mapa.getLayers().getActives(); |
99 | 109 |
for (int i=0;i<layers.length;i++) { |
100 |
if (layers[i].isAvailable()) return true; |
|
110 |
if (layers[i].isAvailable()) { |
|
111 |
return true; |
|
112 |
} |
|
101 | 113 |
} |
102 | 114 |
} |
103 | 115 |
return false; |
104 | 116 |
} |
105 | 117 |
|
106 |
/** |
|
107 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
108 |
*/ |
|
109 |
public void initialize() { |
|
110 |
registerIcons(); |
|
111 |
} |
|
112 |
|
|
113 |
private void registerIcons(){ |
|
114 |
PluginServices.getIconTheme().registerDefault( |
|
115 |
"view-query-information", |
|
116 |
InfoToolExtension.class.getClassLoader().getResource("images/Identify.png") |
|
117 |
); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
122 |
*/ |
|
123 | 118 |
public boolean isVisible() { |
124 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
|
|
119 |
IWindow window = ApplicationLocator.getManager().getActiveWindow();
|
|
125 | 120 |
|
126 |
if (f == null) {
|
|
127 |
return false;
|
|
128 |
}
|
|
121 |
if (window == null) {
|
|
122 |
return false;
|
|
123 |
}
|
|
129 | 124 |
|
130 |
if (f instanceof AbstractViewPanel) { |
|
131 |
AbstractViewPanel vista = (AbstractViewPanel) f; |
|
132 |
ViewDocument model = vista.getModel(); |
|
133 |
MapContext mapa = model.getMapContext(); |
|
125 |
if (window instanceof IView) { |
|
126 |
IView view = (IView) window; |
|
127 |
MapContext mapa = view.getViewDocument().getMapContext(); |
|
134 | 128 |
return mapa.getLayers().getLayersCount() > 0; |
135 | 129 |
} else { |
136 | 130 |
return false; |
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/toolListeners/InfoListener.java | ||
---|---|---|
41 | 41 |
package org.gvsig.app.project.documents.view.toolListeners; |
42 | 42 |
|
43 | 43 |
import java.awt.Image; |
44 |
import java.awt.Point; |
|
45 | 44 |
import java.util.HashMap; |
46 | 45 |
import java.util.Map; |
47 | 46 |
|
48 | 47 |
import javax.swing.JDialog; |
48 |
import javax.swing.JPanel; |
|
49 | 49 |
|
50 | 50 |
import org.gvsig.andami.PluginServices; |
51 | 51 |
import org.gvsig.andami.messages.NotificationManager; |
52 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
53 |
import org.gvsig.app.ApplicationLocator; |
|
54 |
import org.gvsig.app.ApplicationManager; |
|
52 | 55 |
import org.gvsig.app.project.documents.view.info.gui.FInfoDialog; |
56 |
import org.gvsig.fmap.geom.primitive.Point; |
|
53 | 57 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
54 | 58 |
import org.gvsig.fmap.mapcontext.layers.operations.InfoByPoint; |
55 | 59 |
import org.gvsig.fmap.mapcontrol.MapControl; |
... | ... | |
58 | 62 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
59 | 63 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
60 | 64 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener; |
65 |
import org.gvsig.tools.ToolsLocator; |
|
61 | 66 |
import org.gvsig.tools.dynobject.DynObjectSet; |
67 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
68 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
69 |
import org.gvsig.tools.extensionpoint.ExtensionSingleton; |
|
62 | 70 |
|
63 | 71 |
/** |
64 | 72 |
* Listener that looks for information at the point selected by one |
... | ... | |
76 | 84 |
*/ |
77 | 85 |
// private static final Logger logger = LoggerFactory.getLogger(InfoListener.class); |
78 | 86 |
|
87 |
private static final String EP_INFOTOOL_NAME = "org.gvsig.app.infotool"; |
|
88 |
private static final String EP_INFOTOOL_RENDERER = "renderer"; |
|
89 |
|
|
90 |
public static void initializeExtensionPoint() { |
|
91 |
ExtensionPointManager manager = ToolsLocator.getExtensionPointManager(); |
|
92 |
ExtensionPoint point = manager.add(EP_INFOTOOL_NAME, "Register of data relative to infotool"); |
|
93 |
point.append( |
|
94 |
EP_INFOTOOL_RENDERER, |
|
95 |
"Renderer used to show in a panel the info by point tool.", |
|
96 |
new DefaultInfoByPointRenderer() |
|
97 |
); |
|
98 |
} |
|
99 |
|
|
79 | 100 |
/** |
80 | 101 |
* The image to display when the cursor is active. |
81 | 102 |
*/ |
... | ... | |
107 | 128 |
|
108 | 129 |
public void point(PointEvent event) throws BehaviorException { |
109 | 130 |
try { |
110 |
|
|
111 |
Point imagePoint = |
|
112 |
new Point((int) event.getPoint().getX(), (int) event.getPoint() |
|
113 |
.getY()); |
|
114 |
|
|
131 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
115 | 132 |
int numLayersInfoable = 0; |
116 |
double tol = mapCtrl.getViewPort().toMapDistance(TOL); |
|
133 |
Point point = event.getMapPoint(); |
|
134 |
double tolerance = mapCtrl.getViewPort().toMapDistance(TOL); |
|
117 | 135 |
|
118 | 136 |
FLayer[] sel = mapCtrl.getMapContext().getLayers().getActives(); |
119 | 137 |
Map<String, DynObjectSet> layer2info = |
... | ... | |
123 | 141 |
FLayer laCapa = sel[i]; |
124 | 142 |
if (laCapa instanceof InfoByPoint) { |
125 | 143 |
InfoByPoint layer = (InfoByPoint) laCapa; |
126 |
DynObjectSet info = |
|
127 |
layer.getInfo(imagePoint, tol, null, false); |
|
144 |
DynObjectSet info = layer.getInfo(point, tolerance); |
|
128 | 145 |
layer2info.put(laCapa.getName(), info); |
129 | 146 |
numLayersInfoable++; |
130 | 147 |
} |
131 | 148 |
} |
132 | 149 |
|
133 |
// TODO: set the writable parameter to true to activate |
|
134 |
// edition of the info by point information. |
|
135 |
LayersDynObjectSetComponent infoComponent = |
|
136 |
MapControlLocator.getMapControlManager() |
|
137 |
.createLayersDynObjectSetComponent(layer2info, false); |
|
138 |
FInfoDialog dlgInfo = new FInfoDialog(infoComponent); |
|
139 |
|
|
150 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
151 |
InfoByPointRenderer renderer = (InfoByPointRenderer)extensionPoints.get(EP_INFOTOOL_NAME).create(EP_INFOTOOL_RENDERER); |
|
152 |
IWindow window = renderer.getPanel(layer2info); |
|
153 |
|
|
140 | 154 |
if (numLayersInfoable > 0) { |
141 |
if (PluginServices.getMainFrame() == null) { |
|
155 |
if (PluginServices.getMainFrame() == null) { // ????????????????????? |
|
156 |
JPanel panel = (JPanel) window; |
|
142 | 157 |
JDialog dialog = new JDialog(); |
143 |
dlgInfo.setPreferredSize(dlgInfo.getSize());
|
|
144 |
dialog.getContentPane().add(dlgInfo);
|
|
158 |
panel.setPreferredSize(panel.getSize());
|
|
159 |
dialog.getContentPane().add(panel);
|
|
145 | 160 |
dialog.setModal(false); |
146 | 161 |
dialog.pack(); |
147 | 162 |
dialog.setVisible(true); |
148 | 163 |
|
149 | 164 |
} else { |
150 |
dlgInfo = |
|
151 |
(FInfoDialog) PluginServices.getMDIManager().addWindow( |
|
152 |
dlgInfo); |
|
165 |
application.getUIManager().addWindow(window); |
|
153 | 166 |
} |
154 | 167 |
|
155 | 168 |
} |
... | ... | |
170 | 183 |
public void pointDoubleClick(PointEvent event) throws BehaviorException { |
171 | 184 |
// Nothing to do |
172 | 185 |
} |
186 |
|
|
187 |
public interface InfoByPointRenderer { |
|
188 |
public IWindow getPanel( Map<String, DynObjectSet> layersInfo); |
|
189 |
} |
|
190 |
|
|
191 |
public static class DefaultInfoByPointRenderer implements InfoByPointRenderer, ExtensionSingleton { |
|
192 |
public IWindow getPanel(Map<String, DynObjectSet> layersInfo) { |
|
193 |
// TODO: set the writable parameter to true to activate |
|
194 |
// edition of the info by point information. |
|
195 |
LayersDynObjectSetComponent infoComponent = |
|
196 |
MapControlLocator.getMapControlManager() |
|
197 |
.createLayersDynObjectSetComponent(layersInfo, false); |
|
198 |
FInfoDialog dlgInfo = new FInfoDialog(infoComponent); |
|
199 |
return dlgInfo; |
|
200 |
} |
|
201 |
|
|
202 |
} |
|
203 |
|
|
204 |
|
|
173 | 205 |
} |
Also available in: Unified diff