Revision 36005
branches/v2_0_0_prep/extensions/extEditing/config/plugin-persistence.def | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of plugin persistence org.gvsig.editing. |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.editing"> |
|
9 |
<description>Persistence for the edition plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="default_editing_handler_symbol" type="object" classOfValue="org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol" mandatory="false"> |
|
12 |
<description>Symbol used to draw a geometry handler</description> |
|
13 |
</field> |
|
14 |
<field name="default_editing_axis_references_symbol" type="object" classOfValue="org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol" mandatory="false"> |
|
15 |
<description>Symbol used to draw the edition axis</description> |
|
16 |
</field> |
|
17 |
<field name="default_editing_rectangle_selection_symbol" type="object" classOfValue="org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol" mandatory="false"> |
|
18 |
<description>Symbol used in the complex edition tool</description> |
|
19 |
</field> |
|
20 |
</fields> |
|
21 |
</class> |
|
22 |
</classes> |
|
23 |
</definitions> |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/SelectionCADTool.java | ||
---|---|---|
87 | 87 |
|
88 | 88 |
protected String nextState; |
89 | 89 |
// Registros de los que se ha seleccionado alg?n handler. |
90 |
protected ArrayList rowselectedHandlers=new ArrayList(); |
|
91 |
protected String type=PluginServices.getText(this,"simple"); |
|
92 |
// protected ArrayList pointsPolygon=new ArrayList(); |
|
90 |
protected ArrayList rowselectedHandlers = new ArrayList(); |
|
91 |
protected String type = PluginServices.getText(this,"simple"); |
|
93 | 92 |
|
94 | 93 |
protected boolean multipleSelection=false; |
94 |
|
|
95 | 95 |
/** |
96 | 96 |
* Crea un nuevo SelectionCADTool. |
97 | 97 |
*/ |
98 | 98 |
public SelectionCADTool() { |
99 |
|
|
99 | 100 |
} |
101 |
|
|
100 | 102 |
/** |
101 | 103 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una |
102 | 104 |
* carga previa a la utilizaci?n de la herramienta. |
... | ... | |
107 | 109 |
setType(PluginServices.getText(this,"simple")); |
108 | 110 |
} |
109 | 111 |
|
110 |
/* |
|
111 |
* (non-Javadoc) |
|
112 |
* |
|
113 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, |
|
114 |
* double, double) |
|
115 |
*/ |
|
116 | 112 |
public void transition(double x, double y, InputEvent event) { |
117 | 113 |
System.out.println("TRANSICION DESDE ESTADO " + _fsm.getState() |
118 | 114 |
+ " x= " + x + " y=" + y); |
... | ... | |
127 | 123 |
// ESTO LO QUITO POR AHORA, PERO PUEDE QUE LO NECESITEMOS VOLVER A PONER. |
128 | 124 |
// Lo he quitado porque cuando seleccionas algo con CAD, molesta que |
129 | 125 |
// te hagan un redibujado. |
130 |
FLyrVect lv=(FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer(); |
|
131 |
//lv.getSource().getRecordset().getSelectionSupport().fireSelectionEvents(); |
|
126 |
FLyrVect lv = (FLyrVect)((VectorialLayerEdited)CADExtension.getEditionManager().getActiveLayerEdited()).getLayer(); |
|
132 | 127 |
org.gvsig.andami.ui.mdiManager.IWindow[] views = PluginServices.getMDIManager().getAllWindows(); |
133 | 128 |
|
134 | 129 |
for (int i=0 ; i<views.length ; i++){ |
... | ... | |
141 | 136 |
} |
142 | 137 |
} |
143 | 138 |
|
144 |
/* |
|
145 |
* (non-Javadoc) |
|
146 |
* |
|
147 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, |
|
148 |
* double) |
|
149 |
*/ |
|
150 | 139 |
public void transition(double d) { |
151 | 140 |
_fsm.addValue(d); |
152 | 141 |
} |
153 | 142 |
|
154 |
/* |
|
155 |
* (non-Javadoc) |
|
156 |
* |
|
157 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, |
|
158 |
* java.lang.String) |
|
159 |
*/ |
|
160 | 143 |
public void transition(String s) throws CommandException { |
161 | 144 |
if (!super.changeCommand(s)){ |
162 | 145 |
_fsm.addOption(s); |
... | ... | |
168 | 151 |
} |
169 | 152 |
|
170 | 153 |
protected void pointDoubleClick(MapContext map) throws ReadException { |
171 |
FLayer[] actives = map |
|
172 |
.getLayers().getActives(); |
|
173 |
// for (int i=0; i < actives.length; i++){ |
|
174 |
// if (actives[i] instanceof FLyrAnnotation && actives[i].isEditing()) { |
|
175 |
// FLyrAnnotation lyrAnnotation = (FLyrAnnotation) actives[i]; |
|
176 |
// lyrAnnotation.setSelectedEditing(); |
|
177 |
// lyrAnnotation.setInEdition(lyrAnnotation.getRecordset().getSelection().nextSetBit(0)); |
|
178 |
// FLabel fl=lyrAnnotation.getLabel(lyrAnnotation.getInEdition()); |
|
179 |
// if (fl!=null){ |
|
180 |
// View vista=(View)PluginServices.getMDIManager().getActiveWindow(); |
|
181 |
// TextFieldEdit tfe=new TextFieldEdit(lyrAnnotation); |
|
182 |
// tfe.show(vista.getMapControl().getViewPort().fromMapPoint(fl.getOrig()),vista.getMapControl()); |
|
183 |
// } |
|
184 |
// } |
|
185 |
// } |
|
154 |
FLayer[] actives = map.getLayers().getActives(); |
|
186 | 155 |
} |
156 |
|
|
187 | 157 |
/** |
188 | 158 |
* Equivale al transition del prototipo pero sin pasarle como par? metro el |
189 | 159 |
* editableFeatureSource que ya estar? creado. |
... | ... | |
199 | 169 |
SelectionCADToolState actualState = (SelectionCADToolState) _fsm.getPreviousState(); |
200 | 170 |
String status = actualState.getName(); |
201 | 171 |
System.out.println("PREVIOUSSTATE =" + status); |
202 |
VectorialLayerEdited vle = getVLE(); |
|
203 |
FeatureStore featureStore = null; |
|
204 |
DisposableIterator iterator = null; |
|
205 |
try { |
|
206 |
featureStore = vle.getFeatureStore(); |
|
207 |
|
|
208 |
ArrayList selectedHandler = vle.getSelectedHandler(); |
|
209 |
FeatureSet selection = (FeatureSet) featureStore.getSelection(); |
|
172 |
VectorialLayerEdited vle = getVLE(); |
|
173 |
try { |
|
210 | 174 |
System.out.println("STATUS ACTUAL = " + _fsm.getTransition()); |
211 | 175 |
if (status.equals("Selection.FirstPoint")) { |
212 | 176 |
firstPoint = new Point2D.Double(x, y); |
213 | 177 |
} else if (status.equals("Selection.SecondPoint")) { |
214 | 178 |
} else if (status.equals("Selection.WithFeatures")) { |
215 |
} else if (status.equals("Selection.WithHandlers")) { |
|
216 |
addPointWithHandlers(x, y, featureStore, vle.getSelectedHandler());
|
|
179 |
} else if (status.equals("Selection.WithHandlers")) {
|
|
180 |
addPointWithHandlers(x, y, vle.getFeatureStore(), vle.getSelectedHandler());
|
|
217 | 181 |
} |
218 | 182 |
} catch (DataException e) { |
219 | 183 |
LOG.error("Error reding the store", e); |
220 |
} finally { |
|
221 |
if (iterator != null) { |
|
222 |
iterator.dispose(); |
|
223 |
} |
|
224 | 184 |
} |
225 | 185 |
} |
226 | 186 |
|
... | ... | |
381 | 341 |
SelectionCADToolState actualState = (SelectionCADToolState) _fsm |
382 | 342 |
.getPreviousState(); |
383 | 343 |
String status = actualState.getName(); |
384 |
System.out.println("PREVIOUSSTATE =" + status); // + "ESTADO ACTUAL: " + |
|
385 |
// _fsm.getState()); |
|
344 |
System.out.println("PREVIOUSSTATE =" + status); |
|
386 | 345 |
System.out.println("STATUS ACTUAL = " + _fsm.getTransition()); |
387 | 346 |
if (s.equals(PluginServices.getText(this,"cancel"))){ |
388 | 347 |
init(); |
... | ... | |
395 | 354 |
init(); |
396 | 355 |
} |
397 | 356 |
|
398 |
|
|
399 |
|
|
400 |
|
|
401 | 357 |
/* |
402 | 358 |
* (non-Javadoc) |
403 | 359 |
* |
... | ... | |
418 | 374 |
} |
419 | 375 |
} |
420 | 376 |
|
421 |
|
|
422 |
|
|
423 | 377 |
public void end() { |
424 | 378 |
if (!getNextTool().equals("selection")) { |
425 | 379 |
CADExtension.setCADTool(getNextTool(),false); |
... | ... | |
431 | 385 |
} |
432 | 386 |
|
433 | 387 |
public boolean selectFeatures(double x, double y, InputEvent event) { |
434 |
SelectionCADToolState actualState = _fsm |
|
435 |
.getState(); |
|
388 |
SelectionCADToolState actualState = _fsm.getState(); |
|
436 | 389 |
|
437 | 390 |
String status = actualState.getName(); |
438 | 391 |
VectorialLayerEdited vle = getVLE(); |
439 |
multipleSelection=event.isControlDown();
|
|
392 |
multipleSelection = event.isControlDown();
|
|
440 | 393 |
|
441 | 394 |
if ((status.equals("Selection.FirstPoint")) |
442 | 395 |
|| (status.equals("Selection.WithSelectedFeatures"))) { |
... | ... | |
444 | 397 |
firstPoint = new Point2D.Double(x, y); |
445 | 398 |
try { |
446 | 399 |
vle.getFeatureStore().beginEditingGroup(getName()); |
447 |
vle.selectWithPoint(x,y,multipleSelection);
|
|
400 |
vle.selectWithPoint(x, y, multipleSelection);
|
|
448 | 401 |
vle.getFeatureStore().endEditingGroup(); |
449 | 402 |
} catch (NeedEditingModeException e) { |
450 | 403 |
NotificationManager.showMessageError(getName(), e); |
... | ... | |
453 | 406 |
} |
454 | 407 |
PluginServices.getMDIManager().restoreCursor(); |
455 | 408 |
} |
456 |
FeatureSet selection=null;
|
|
409 |
FeatureSet selection = null;
|
|
457 | 410 |
try { |
458 | 411 |
selection = (FeatureSet)vle.getFeatureStore().getSelection(); |
459 |
|
|
460 |
// ArrayList selectedRow = vle.getSelectedRow(); |
|
461 | 412 |
long countSel=selection.getSize(); |
462 | 413 |
if (countSel > 0) { |
463 | 414 |
nextState = "Selection.WithSelectedFeatures"; |
... | ... | |
469 | 420 |
} |
470 | 421 |
} |
471 | 422 |
} catch (ReadException e) { |
472 |
e.printStackTrace();
|
|
423 |
LOG.error("Error selecting the features", e);
|
|
473 | 424 |
return false; |
474 | 425 |
} catch (DataException e) { |
475 |
e.printStackTrace();
|
|
426 |
LOG.error("Error selecting the features", e);
|
|
476 | 427 |
return false; |
477 | 428 |
} |
478 | 429 |
} |
... | ... | |
539 | 490 |
}else{ |
540 | 491 |
this.type = type; |
541 | 492 |
} |
542 |
// pointsPolygon.clear(); |
|
543 | 493 |
} |
544 | 494 |
|
545 | 495 |
public String toString() { |
546 | 496 |
return "_selection"; |
547 | 497 |
} |
498 |
|
|
548 | 499 |
public void multipleSelection(boolean b) { |
549 | 500 |
multipleSelection=b; |
550 | 501 |
|
551 | 502 |
} |
552 |
|
|
553 | 503 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/CADToolAdapter.java | ||
---|---|---|
17 | 17 |
import java.util.prefs.Preferences; |
18 | 18 |
|
19 | 19 |
import org.cresques.cts.IProjection; |
20 |
import org.slf4j.Logger; |
|
21 |
import org.slf4j.LoggerFactory; |
|
22 |
|
|
20 | 23 |
import org.gvsig.andami.PluginServices; |
21 | 24 |
import org.gvsig.andami.messages.NotificationManager; |
22 | 25 |
import org.gvsig.andami.ui.mdiFrame.MainFrame; |
... | ... | |
30 | 33 |
import org.gvsig.editing.layers.VectorialLayerEdited; |
31 | 34 |
import org.gvsig.fmap.dal.exception.DataException; |
32 | 35 |
import org.gvsig.fmap.dal.exception.ReadException; |
33 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
34 | 36 |
import org.gvsig.fmap.dal.feature.Feature; |
35 | 37 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
36 | 38 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
... | ... | |
49 | 51 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
50 | 52 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
51 | 53 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
54 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
52 | 55 |
import org.gvsig.utils.console.JConsole; |
53 |
import org.slf4j.Logger; |
|
54 |
import org.slf4j.LoggerFactory; |
|
55 | 56 |
|
56 | 57 |
/** |
57 | 58 |
* <p> |
... | ... | |
380 | 381 |
p = getMapControl().getViewPort().toMapPoint(adjustedPoint); |
381 | 382 |
} |
382 | 383 |
|
384 |
//If the stack is empty, return |
|
385 |
if (cadToolStack.isEmpty()){ |
|
386 |
return; |
|
387 |
} |
|
388 |
|
|
383 | 389 |
if (((CADTool) cadToolStack.peek()).getVLE() == null){ |
384 | 390 |
return; |
385 | 391 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/preferences/EditingPage.java | ||
---|---|---|
186 | 186 |
import javax.swing.event.ChangeListener; |
187 | 187 |
|
188 | 188 |
import org.gvsig.andami.PluginServices; |
189 |
import org.gvsig.andami.PluginsLocator; |
|
190 |
import org.gvsig.andami.PluginsManager; |
|
189 | 191 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
190 | 192 |
import org.gvsig.andami.preferences.StoreException; |
191 | 193 |
import org.gvsig.app.gui.panels.ColorChooserPanel; |
194 |
import org.gvsig.editing.CADExtension; |
|
192 | 195 |
import org.gvsig.fmap.geom.Geometry; |
193 | 196 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
194 | 197 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
195 | 198 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
196 | 199 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
197 | 200 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
201 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
|
198 | 202 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
199 |
import org.gvsig.utils.StringUtilities; |
|
200 |
import org.gvsig.utils.XMLEntity; |
|
203 |
import org.gvsig.tools.dynobject.DynObject; |
|
201 | 204 |
|
202 | 205 |
|
206 |
|
|
203 | 207 |
/** |
204 | 208 |
* Editing configuration page. |
205 | 209 |
* <b><b> |
... | ... | |
210 | 214 |
* @author Vicente Caballero Navarro |
211 | 215 |
*/ |
212 | 216 |
public class EditingPage extends AbstractPreferencePage { |
217 |
private static final long serialVersionUID = -6126280933781398092L; |
|
213 | 218 |
|
214 |
public static String DEFAULT_HANDLER_COLOR = "default_editing_handler_color"; |
|
215 |
public static String DEFAULT_HANDLER_OUTLINE_COLOR = "default_editing_handler_outline_color"; |
|
219 |
public static String DEFAULT_HANDLER_SYMBOL = "default_editing_handler_symbol"; |
|
220 |
public static String DEFAULT_AXIS_REFERENCES_SYMBOL = "default_editing_axis_references_symbol"; |
|
221 |
public static String DEFAULT_RECTANGLE_SELECTION_SYMBOL = "default_editing_rectangle_selection_symbol"; |
|
216 | 222 |
|
217 |
public static String DEFAULT_SELECTION_COLOR = "default_editing_selection_color"; |
|
218 |
// public static String DEFAULT_SELECTION_OUTLINE_COLOR = "default_editing_selection_outline_color"; |
|
219 |
|
|
220 |
public static String DEFAULT_AXIS_REFERENCES_COLOR = "default_editing_axis_references_color"; |
|
221 |
// public static String DEFAULT_AXIS_REFERENCES_OUTLINE_COLOR = "default_editing_axis_references_outline_color"; |
|
222 |
|
|
223 |
public static String DEFAULT_RECTANGLE_SELECTION_COLOR = "default_editing_rectangle_selection_color"; |
|
224 |
// public static String DEFAULT_GEOMETRY_SELECTION_OUTLINE_COLOR = "default_editing_geometry_selection_outline_color"; |
|
225 |
|
|
226 | 223 |
protected String id; |
227 |
private ImageIcon icon; |
|
228 |
private ColorChooserPanel jccDefaultSelectionColor; |
|
229 |
// private ColorChooserPanel jccDefaultSelectionOutLineColor; |
|
224 |
private ImageIcon icon; |
|
230 | 225 |
private ColorChooserPanel jccDefaultAxisReferencesColor; |
231 |
// private ColorChooserPanel jccDefaultAxisReferencesOutLineColor; |
|
232 | 226 |
private ColorChooserPanel jccDefaultGeometrySelectionColor; |
233 |
// private ColorChooserPanel jccDefaultGeometrySelectionOutLineColor; |
|
234 |
|
|
235 | 227 |
private ColorChooserPanel jccDefaultHandlerColor; |
236 |
private ColorChooserPanel jccDefaultHandlerOutLineColor; |
|
237 | 228 |
|
238 |
private boolean panelStarted = false; |
|
239 |
private JSlider jsDefaultSelectionAlpha; |
|
229 |
private boolean panelStarted = false; |
|
240 | 230 |
private JSlider jsDefaultAxisReferencesAlpha; |
241 | 231 |
private JSlider jsDefaultGeometrySelectionAlpha; |
242 | 232 |
private JSlider jsDefaultHandlerAlpha; |
... | ... | |
257 | 247 |
public void initializeValues() { |
258 | 248 |
if (!panelStarted) getPanel(); |
259 | 249 |
|
260 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
261 |
XMLEntity xml = ps.getPersistentXML(); |
|
250 |
//The values has beed retrieved in the CADExtension. |
|
262 | 251 |
|
263 |
// Default selection color |
|
264 |
if (xml.contains(DEFAULT_SELECTION_COLOR)) { |
|
265 |
Color color=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_SELECTION_COLOR)); |
|
266 |
jccDefaultSelectionColor.setColor(color); |
|
267 |
jccDefaultSelectionColor.setAlpha(color.getAlpha()); |
|
268 |
// Color colorOutLine=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_SELECTION_OUTLINE_COLOR)); |
|
269 |
// jccDefaultSelectionOutLineColor.setColor(colorOutLine); |
|
270 |
// jccDefaultSelectionOutLineColor.setAlpha(color.getAlpha()); |
|
271 |
jsDefaultSelectionAlpha.setValue(color.getAlpha()); |
|
272 |
mapControlManager.setSelectionSymbol(symbolManager.createSymbol( |
|
273 |
Geometry.TYPES.GEOMETRY, color)); |
|
274 |
// DefaultCADTool.selectionSymbol.setOutlineColor(colorOutLine); |
|
275 |
}else{ |
|
276 |
Color color=Color.RED; |
|
277 |
jccDefaultSelectionColor.setColor(color); |
|
278 |
jccDefaultSelectionColor.setAlpha(color.getAlpha()); |
|
279 |
// jccDefaultSelectionOutLineColor.setColor(color.darker()); |
|
280 |
// jccDefaultSelectionOutLineColor.setAlpha(color.getAlpha()); |
|
281 |
jsDefaultSelectionAlpha.setValue(color.getAlpha()); |
|
282 |
mapControlManager.setSelectionSymbol(symbolManager.createSymbol( |
|
283 |
Geometry.TYPES.GEOMETRY, color)); |
|
284 |
// DefaultCADTool.selectionSymbol.setOutlineColor(color.darker()); |
|
285 |
} |
|
286 |
|
|
287 |
|
|
288 | 252 |
// Default axis references color |
289 |
if (xml.contains(DEFAULT_AXIS_REFERENCES_COLOR)) { |
|
290 |
Color color=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_AXIS_REFERENCES_COLOR)); |
|
291 |
jccDefaultAxisReferencesColor.setColor(color); |
|
292 |
jccDefaultAxisReferencesColor.setAlpha(color.getAlpha()); |
|
293 |
// Color colorOutLine=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_AXIS_REFERENCES_OUTLINE_COLOR)); |
|
294 |
// jccDefaultAxisReferencesOutLineColor.setColor(colorOutLine); |
|
295 |
// jccDefaultAxisReferencesOutLineColor.setAlpha(color.getAlpha()); |
|
296 |
jsDefaultAxisReferencesAlpha.setValue(color.getAlpha()); |
|
297 |
ISymbol symbol = |
|
298 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, color); |
|
299 |
mapControlManager.setAxisReferenceSymbol(symbol); |
|
300 |
}else{ |
|
301 |
Color color=new Color(100, 100, 100, 100); |
|
302 |
jccDefaultAxisReferencesColor.setColor(color); |
|
303 |
jccDefaultAxisReferencesColor.setAlpha(color.getAlpha()); |
|
304 |
// jccDefaultAxisReferencesOutLineColor.setColor(color.darker()); |
|
305 |
// jccDefaultAxisReferencesOutLineColor.setAlpha(color.getAlpha()); |
|
306 |
jsDefaultAxisReferencesAlpha.setValue(color.getAlpha()); |
|
307 |
ISymbol symbol = |
|
308 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, color); |
|
309 |
mapControlManager.setAxisReferenceSymbol(symbol); |
|
310 |
} |
|
253 |
ISymbol axisReferenceSymbol = mapControlManager.getAxisReferenceSymbol(); |
|
254 |
jccDefaultAxisReferencesColor.setColor(axisReferenceSymbol.getColor()); |
|
255 |
jccDefaultAxisReferencesColor.setAlpha(axisReferenceSymbol.getColor().getAlpha()); |
|
256 |
jsDefaultAxisReferencesAlpha.setValue(axisReferenceSymbol.getColor().getAlpha()); |
|
311 | 257 |
|
312 | 258 |
// Default geometry selection color |
313 |
if (xml.contains(DEFAULT_RECTANGLE_SELECTION_COLOR)) { |
|
314 |
Color color=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_RECTANGLE_SELECTION_COLOR)); |
|
315 |
jccDefaultGeometrySelectionColor.setColor(color); |
|
316 |
jccDefaultGeometrySelectionColor.setAlpha(color.getAlpha()); |
|
317 |
// Color colorOutLine=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_GEOMETRY_SELECTION_OUTLINE_COLOR)); |
|
318 |
// jccDefaultGeometrySelectionOutLineColor.setColor(colorOutLine); |
|
319 |
// jccDefaultGeometrySelectionOutLineColor.setAlpha(color.getAlpha()); |
|
320 |
jsDefaultGeometrySelectionAlpha.setValue(color.getAlpha()); |
|
321 |
ISymbol symbol = |
|
322 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, color); |
|
323 |
mapControlManager.setGeometrySelectionSymbol(symbol); |
|
324 |
}else{ |
|
325 |
Color color=new Color(255, 0,0, 100); |
|
326 |
jccDefaultGeometrySelectionColor.setColor(color); |
|
327 |
jccDefaultGeometrySelectionColor.setAlpha(color.getAlpha()); |
|
328 |
// jccDefaultGeometrySelectionOutLineColor.setColor(color.darker()); |
|
329 |
// jccDefaultGeometrySelectionOutLineColor.setAlpha(color.getAlpha()); |
|
330 |
jsDefaultGeometrySelectionAlpha.setValue(color.getAlpha()); |
|
331 |
ISymbol symbol = |
|
332 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, color); |
|
333 |
mapControlManager.setGeometrySelectionSymbol(symbol); |
|
334 |
} |
|
259 |
ISymbol geometrySelectionSymbol = mapControlManager.getGeometrySelectionSymbol(); |
|
260 |
jccDefaultGeometrySelectionColor.setColor(geometrySelectionSymbol.getColor()); |
|
261 |
jccDefaultGeometrySelectionColor.setAlpha(geometrySelectionSymbol.getColor().getAlpha()); |
|
262 |
jsDefaultGeometrySelectionAlpha.setValue(geometrySelectionSymbol.getColor().getAlpha()); |
|
335 | 263 |
|
336 | 264 |
// Default handler color |
337 |
if (xml.contains(DEFAULT_HANDLER_COLOR)) { |
|
338 |
Color color=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_HANDLER_COLOR)); |
|
339 |
jccDefaultHandlerColor.setColor(color); |
|
340 |
jccDefaultHandlerColor.setAlpha(color.getAlpha()); |
|
341 |
Color colorOutLine=StringUtilities.string2Color(xml.getStringProperty(DEFAULT_HANDLER_OUTLINE_COLOR)); |
|
342 |
jccDefaultHandlerOutLineColor.setColor(colorOutLine); |
|
343 |
jccDefaultHandlerOutLineColor.setAlpha(color.getAlpha()); |
|
344 |
jsDefaultGeometrySelectionAlpha.setValue(color.getAlpha()); |
|
345 |
ISymbol symbol = |
|
346 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, color); |
|
347 |
mapControlManager.setHandlerSymbol(symbol); |
|
348 |
if (mapControlManager.getHandlerSymbol()instanceof ILineSymbol) { |
|
349 |
((ILineSymbol)mapControlManager.getHandlerSymbol()).setLineColor(colorOutLine); |
|
350 |
} |
|
351 |
}else{ |
|
352 |
Color color=Color.ORANGE; |
|
353 |
jccDefaultHandlerColor.setColor(color); |
|
354 |
jccDefaultHandlerColor.setAlpha(color.getAlpha()); |
|
355 |
jccDefaultHandlerOutLineColor.setColor(color.darker()); |
|
356 |
jccDefaultHandlerOutLineColor.setAlpha(color.getAlpha()); |
|
357 |
jsDefaultHandlerAlpha.setValue(color.getAlpha()); |
|
358 |
ISymbol symbol = |
|
359 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, color); |
|
360 |
mapControlManager.setHandlerSymbol(symbol); |
|
361 |
if (mapControlManager.getHandlerSymbol() instanceof ILineSymbol) { |
|
362 |
((ILineSymbol)mapControlManager.getHandlerSymbol()).setLineColor(color.darker()); |
|
363 |
} |
|
364 |
} |
|
265 |
ISymbol handlerSymbol = mapControlManager.getHandlerSymbol(); |
|
266 |
jccDefaultHandlerColor.setColor(((IFillSymbol)handlerSymbol).getColor()); |
|
267 |
jccDefaultHandlerColor.setAlpha(((IFillSymbol)handlerSymbol).getColor().getAlpha()); |
|
268 |
jsDefaultHandlerAlpha.setValue(geometrySelectionSymbol.getColor().getAlpha()); |
|
269 |
|
|
365 | 270 |
} |
366 | 271 |
|
367 | 272 |
public String getID() { |
... | ... | |
380 | 285 |
addComponent(new JLabel(" ")); |
381 | 286 |
|
382 | 287 |
addComponent(new JLabel(PluginServices.getText(this,"change_the_editing_colors"))); |
383 |
// default selection color chooser |
|
384 |
JPanel selectionPanel = new JPanel(); |
|
385 |
selectionPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.editing.default_selection_color"))); |
|
386 |
selectionPanel.setLayout(new GridBagLayout()); |
|
387 |
selectionPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
|
388 |
selectionPanel.add(jccDefaultSelectionColor = new ColorChooserPanel()); |
|
389 |
// selectionPanel.add(new JLabel(PluginServices.getText(this,"outline"))); |
|
390 |
// selectionPanel.add(jccDefaultSelectionOutLineColor=new ColorChooserPanel()); |
|
391 | 288 |
|
392 | 289 |
|
393 |
// JPanel alphaSelectionPanel= new JPanel(); |
|
394 |
selectionPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
|
395 |
selectionPanel.add(jsDefaultSelectionAlpha = new JSlider(0,255)); |
|
396 |
jsDefaultSelectionAlpha.setPreferredSize(new Dimension(100,30)); |
|
397 |
|
|
398 |
jsDefaultSelectionAlpha.addChangeListener(new ChangeListener(){ |
|
399 |
public void stateChanged(ChangeEvent e) { |
|
400 |
jccDefaultSelectionColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
401 |
// jccDefaultSelectionOutLineColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
402 |
|
|
403 |
}}); |
|
404 |
|
|
405 |
addComponent(selectionPanel); |
|
406 |
addComponent(new JLabel(" ")); |
|
407 |
|
|
408 | 290 |
// default selection color chooser |
409 | 291 |
JPanel modifyPanel = new JPanel(); |
410 | 292 |
modifyPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.editing.default_axis_references_color"))); |
411 | 293 |
modifyPanel.setLayout(new GridBagLayout()); |
412 | 294 |
modifyPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
413 | 295 |
modifyPanel.add(jccDefaultAxisReferencesColor = new ColorChooserPanel()); |
414 |
// modifyPanel.add(new JLabel(PluginServices.getText(this,"outline"))); |
|
415 |
// modifyPanel.add(jccDefaultAxisReferencesOutLineColor=new ColorChooserPanel()); |
|
416 | 296 |
|
417 | 297 |
// JPanel alphaModifyPanel= new JPanel(); |
418 |
// alphaModifyPanel.setPreferredSize(new Dimension(120,30)); |
|
419 | 298 |
modifyPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
420 | 299 |
modifyPanel.add(jsDefaultAxisReferencesAlpha = new JSlider(0,255)); |
421 | 300 |
jsDefaultAxisReferencesAlpha.setPreferredSize(new Dimension(100,30)); |
... | ... | |
423 | 302 |
jsDefaultAxisReferencesAlpha.addChangeListener(new ChangeListener(){ |
424 | 303 |
public void stateChanged(ChangeEvent e) { |
425 | 304 |
jccDefaultAxisReferencesColor.setAlpha(((JSlider)e.getSource()).getValue()); |
426 |
// jccDefaultAxisReferencesOutLineColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
427 | 305 |
|
428 | 306 |
}}); |
429 | 307 |
|
... | ... | |
436 | 314 |
drawingPanel.setLayout(new GridBagLayout()); |
437 | 315 |
drawingPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
438 | 316 |
drawingPanel.add(jccDefaultGeometrySelectionColor = new ColorChooserPanel()); |
439 |
// drawingPanel.add(new JLabel(PluginServices.getText(this,"outline"))); |
|
440 |
// drawingPanel.add(jccDefaultGeometrySelectionOutLineColor=new ColorChooserPanel()); |
|
441 | 317 |
|
442 | 318 |
// JPanel alphaDrawingPanel= new JPanel(); |
443 |
// alphaDrawingPanel.setPreferredSize(new Dimension(120,30)); |
|
444 | 319 |
drawingPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
445 | 320 |
drawingPanel.add(jsDefaultGeometrySelectionAlpha = new JSlider(0,255)); |
446 | 321 |
jsDefaultGeometrySelectionAlpha.setPreferredSize(new Dimension(100,30)); |
... | ... | |
448 | 323 |
jsDefaultGeometrySelectionAlpha.addChangeListener(new ChangeListener(){ |
449 | 324 |
public void stateChanged(ChangeEvent e) { |
450 | 325 |
jccDefaultGeometrySelectionColor.setAlpha(((JSlider)e.getSource()).getValue()); |
451 |
// jccDefaultGeometrySelectionOutLineColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
452 |
|
|
453 | 326 |
}}); |
454 | 327 |
|
455 | 328 |
addComponent(drawingPanel); |
... | ... | |
460 | 333 |
handlerPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.editing.default_handler_color"))); |
461 | 334 |
handlerPanel.setLayout(new GridBagLayout()); |
462 | 335 |
handlerPanel.add(new JLabel(PluginServices.getText(this,"fill"))); |
463 |
handlerPanel.add(jccDefaultHandlerColor = new ColorChooserPanel()); |
|
464 |
handlerPanel.add(new JLabel(PluginServices.getText(this,"outline"))); |
|
465 |
handlerPanel.add(jccDefaultHandlerOutLineColor=new ColorChooserPanel()); |
|
336 |
handlerPanel.add(jccDefaultHandlerColor = new ColorChooserPanel()); |
|
466 | 337 |
|
467 |
// JPanel alphaModifyPanel= new JPanel(); |
|
468 |
// alphaModifyPanel.setPreferredSize(new Dimension(120,30)); |
|
469 | 338 |
handlerPanel.add(new JLabel(PluginServices.getText(this,"alpha"))); |
470 | 339 |
handlerPanel.add(jsDefaultHandlerAlpha = new JSlider(0,255)); |
471 | 340 |
jsDefaultHandlerAlpha.setPreferredSize(new Dimension(100,30)); |
472 | 341 |
|
473 | 342 |
jsDefaultHandlerAlpha.addChangeListener(new ChangeListener(){ |
474 | 343 |
public void stateChanged(ChangeEvent e) { |
475 |
jccDefaultHandlerColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
476 |
jccDefaultHandlerOutLineColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
477 |
|
|
344 |
jccDefaultHandlerColor.setAlpha(((JSlider)e.getSource()).getValue()); |
|
478 | 345 |
}}); |
479 | 346 |
|
480 | 347 |
addComponent(handlerPanel); |
... | ... | |
485 | 352 |
} |
486 | 353 |
|
487 | 354 |
public void storeValues() throws StoreException { |
488 |
Color selectionColor, modifyColor, drawingColor, handlerColor, handlerOutLineColor;// selectionOutLineColor, modifyOutLineColor, drawingOutLineColor; |
|
489 |
selectionColor = jccDefaultSelectionColor.getColor(); |
|
490 |
// selectionOutLineColor = jccDefaultSelectionOutLineColor.getColor(); |
|
491 |
modifyColor = jccDefaultAxisReferencesColor.getColor(); |
|
492 |
// modifyOutLineColor = jccDefaultAxisReferencesOutLineColor.getColor(); |
|
493 |
drawingColor = jccDefaultGeometrySelectionColor.getColor(); |
|
494 |
// drawingOutLineColor = jccDefaultGeometrySelectionOutLineColor.getColor(); |
|
355 |
Color axisReferencesColor, geometrySelectionColor, handlerColor, handlerOutLineColor; |
|
356 |
axisReferencesColor = jccDefaultAxisReferencesColor.getColor(); |
|
357 |
geometrySelectionColor = jccDefaultGeometrySelectionColor.getColor(); |
|
358 |
handlerColor = jccDefaultHandlerColor.getColor(); |
|
495 | 359 |
|
496 |
handlerColor = jccDefaultHandlerColor.getColor();
|
|
497 |
handlerOutLineColor = jccDefaultHandlerOutLineColor.getColor();
|
|
360 |
PluginsManager pluginsManager = PluginsLocator.getManager();
|
|
361 |
DynObject dynObject = pluginsManager.getPlugin(CADExtension.class).getPluginProperties();
|
|
498 | 362 |
|
363 |
//Symbol for the AxisReferences |
|
364 |
ISymbol axisReferencesSymbol = |
|
365 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, axisReferencesColor); |
|
366 |
if (axisReferencesSymbol instanceof IFillSymbol){ |
|
367 |
((IFillSymbol)axisReferencesSymbol).setFillColor(axisReferencesColor); |
|
368 |
} |
|
369 |
mapControlManager.setAxisReferenceSymbol(axisReferencesSymbol); |
|
370 |
dynObject.setDynValue(DEFAULT_AXIS_REFERENCES_SYMBOL, axisReferencesSymbol); |
|
499 | 371 |
|
500 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
501 |
XMLEntity xml = ps.getPersistentXML(); |
|
502 |
xml.putProperty(DEFAULT_SELECTION_COLOR, |
|
503 |
StringUtilities.color2String(selectionColor)); |
|
504 |
// xml.putProperty(DEFAULT_SELECTION_OUTLINE_COLOR, |
|
505 |
// StringUtilities.color2String(selectionOutLineColor)); |
|
506 |
ISymbol symbol = |
|
507 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, |
|
508 |
selectionColor); |
|
509 |
mapControlManager.setSelectionSymbol(symbol); |
|
510 |
|
|
511 |
// DefaultCADTool.selectionSymbol.setOutlineColor(selectionOutLineColor); |
|
512 |
|
|
513 |
xml.putProperty(DEFAULT_AXIS_REFERENCES_COLOR, |
|
514 |
StringUtilities.color2String(modifyColor)); |
|
515 |
// xml.putProperty(DEFAULT_AXIS_REFERENCES_OUTLINE_COLOR, |
|
516 |
// StringUtilities.color2String(modifyOutLineColor)); |
|
517 |
ISymbol symbol2 = |
|
518 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, modifyColor); |
|
519 |
mapControlManager.setAxisReferenceSymbol(symbol2); |
|
520 |
// DefaultCADTool.axisReferencesSymbol.setOutlineColor(modifyOutLineColor); |
|
521 |
|
|
522 |
xml.putProperty(DEFAULT_RECTANGLE_SELECTION_COLOR, |
|
523 |
StringUtilities.color2String(drawingColor)); |
|
524 |
// xml.putProperty(DEFAULT_GEOMETRY_SELECTION_OUTLINE_COLOR, |
|
525 |
// StringUtilities.color2String(drawingOutLineColor)); |
|
526 |
ISymbol symbol3 = |
|
527 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, |
|
528 |
drawingColor); |
|
529 |
mapControlManager.setGeometrySelectionSymbol(symbol3); |
|
530 |
|
|
531 |
// DefaultCADTool.geometrySelectSymbol.setOutlineColor(drawingOutLineColor); |
|
532 |
|
|
533 |
xml.putProperty(DEFAULT_HANDLER_COLOR, |
|
534 |
StringUtilities.color2String(handlerColor)); |
|
535 |
xml.putProperty(DEFAULT_HANDLER_OUTLINE_COLOR, |
|
536 |
StringUtilities.color2String(handlerOutLineColor)); |
|
537 |
|
|
538 |
ISymbol symbol4 = |
|
539 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, |
|
540 |
handlerColor); |
|
541 |
mapControlManager.setHandlerSymbol(symbol4); |
|
542 |
|
|
543 |
if (mapControlManager.getHandlerSymbol() instanceof ILineSymbol) { |
|
544 |
((ILineSymbol)mapControlManager.getHandlerSymbol()).setLineColor(handlerOutLineColor); |
|
372 |
//Symbol for the geometry used in the edition selection |
|
373 |
ISymbol geometrySelectionSymbol = |
|
374 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, geometrySelectionColor); |
|
375 |
if (geometrySelectionSymbol instanceof IFillSymbol){ |
|
376 |
((IFillSymbol)geometrySelectionSymbol).setFillColor(geometrySelectionColor); |
|
545 | 377 |
} |
378 |
if (geometrySelectionSymbol instanceof ILineSymbol){ |
|
379 |
((ILineSymbol)geometrySelectionSymbol).setLineColor(geometrySelectionColor); |
|
380 |
} |
|
381 |
mapControlManager.setGeometrySelectionSymbol(geometrySelectionSymbol); |
|
382 |
dynObject.setDynValue(DEFAULT_RECTANGLE_SELECTION_SYMBOL, geometrySelectionSymbol); |
|
383 |
|
|
384 |
//Symbol for the handlers |
|
385 |
ISymbol handlerSymbol = |
|
386 |
symbolManager.createSymbol(Geometry.TYPES.GEOMETRY, handlerColor); |
|
387 |
if (axisReferencesSymbol instanceof IFillSymbol){ |
|
388 |
((IFillSymbol)handlerSymbol).setFillColor(handlerColor); |
|
389 |
} |
|
390 |
mapControlManager.setHandlerSymbol(handlerSymbol); |
|
391 |
dynObject.setDynValue(DEFAULT_HANDLER_SYMBOL, handlerSymbol); |
|
546 | 392 |
} |
547 | 393 |
|
548 |
|
|
549 |
public void initializeDefaults() { |
|
550 |
jccDefaultSelectionColor.setColor(Color.ORANGE); |
|
551 |
// jccDefaultSelectionOutLineColor.setColor(Color.ORANGE.darker()); |
|
552 |
jsDefaultSelectionAlpha.setValue(255); |
|
553 |
|
|
394 |
public void initializeDefaults() { |
|
554 | 395 |
jccDefaultAxisReferencesColor.setColor(new Color(100, 100, 100, 100)); |
555 |
// jccDefaultAxisReferencesOutLineColor.setColor(new Color(100, 100, 100, 100).darker()); |
|
556 | 396 |
jsDefaultAxisReferencesAlpha.setValue(100); |
557 | 397 |
|
558 | 398 |
jccDefaultGeometrySelectionColor.setColor(new Color(255, 0,0, 100)); |
559 |
// jccDefaultGeometrySelectionOutLineColor.setColor(new Color(255, 0, 0, 100).darker()); |
|
560 | 399 |
jsDefaultGeometrySelectionAlpha.setValue(100); |
561 | 400 |
|
562 |
jccDefaultHandlerColor.setColor(new Color(255, 0,0, 100)); |
|
563 |
jccDefaultHandlerOutLineColor.setColor(new Color(255, 0, 0, 100).darker()); |
|
401 |
jccDefaultHandlerColor.setColor(new Color(255, 0,0, 100)); |
|
564 | 402 |
jsDefaultHandlerAlpha.setValue(100); |
565 |
|
|
566 | 403 |
} |
567 | 404 |
|
568 | 405 |
public ImageIcon getIcon() { |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/layers/VectorialLayerEdited.java | ||
---|---|---|
1 | 1 |
package org.gvsig.editing.layers; |
2 | 2 |
|
3 |
import java.awt.Graphics2D; |
|
4 | 3 |
import java.awt.Image; |
5 | 4 |
import java.awt.geom.Point2D; |
6 |
import java.awt.image.BufferedImage; |
|
7 | 5 |
import java.util.ArrayList; |
8 | 6 |
import java.util.ConcurrentModificationException; |
9 | 7 |
import java.util.EmptyStackException; |
... | ... | |
29 | 27 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
30 | 28 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
31 | 29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
30 |
import org.gvsig.fmap.geom.Geometry; |
|
32 | 31 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
33 | 32 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
34 | 33 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
52 | 51 |
import org.gvsig.fmap.mapcontext.layers.vectorial.IntersectsGeometryEvaluator; |
53 | 52 |
import org.gvsig.fmap.mapcontext.layers.vectorial.OutGeometryEvaluator; |
54 | 53 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
54 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
55 | 55 |
import org.gvsig.fmap.mapcontrol.MapControl; |
56 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
|
56 | 57 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
57 | 58 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
58 | 59 |
import org.gvsig.tools.dispose.DisposableIterator; |
... | ... | |
64 | 65 |
public class VectorialLayerEdited extends DefaultLayerEdited implements |
65 | 66 |
LayerDrawingListener, Observer { |
66 | 67 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
67 |
private static final Logger logger = LoggerFactory.getLogger(VectorialLayerEdited.class);
|
|
68 |
private static final MapControlManager mapControlManager = MapControlLocator.getMapControlManager();
|
|
68 |
private static final Logger LOG = LoggerFactory.getLogger(VectorialLayerEdited.class);
|
|
69 |
private static final MapControlManager MAP_CONTROL_MANAGER = MapControlLocator.getMapControlManager();
|
|
69 | 70 |
private ArrayList selectedHandler = new ArrayList(); |
70 | 71 |
private Point2D lastPoint; |
71 | 72 |
private Point2D firstPoint; |
... | ... | |
105 | 106 |
firstPoint = new Point2D.Double(x, y); |
106 | 107 |
FeatureStore featureStore = getFeatureStore(); |
107 | 108 |
// Se comprueba si se pincha en una gemometr�a |
108 |
ViewPort vp = getLayer().getMapContext().getViewPort();
|
|
109 |
double tol = vp.toMapDistance(mapControlManager.getTolerance());
|
|
109 |
ViewPort viewPort = getLayer().getMapContext().getViewPort();
|
|
110 |
double tol = viewPort.toMapDistance(MAP_CONTROL_MANAGER.getTolerance());
|
|
110 | 111 |
|
111 | 112 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
112 | 113 |
Point center = (org.gvsig.fmap.geom.primitive.Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D); |
... | ... | |
115 | 116 |
Circle circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D); |
116 | 117 |
circle.setPoints(center, tol); |
117 | 118 |
|
118 |
FeatureQuery fq = featureStore.createFeatureQuery();
|
|
119 |
fq.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
120 |
Evaluator evaluator = new IntersectsGeometryEvaluator(circle, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
121 |
fq.setFilter(evaluator);
|
|
122 |
set = featureStore.getFeatureSet(fq);
|
|
119 |
FeatureQuery featureQuery = featureStore.createFeatureQuery();
|
|
120 |
featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
121 |
Evaluator evaluator = new IntersectsGeometryEvaluator(circle, viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
122 |
featureQuery.setFilter(evaluator);
|
|
123 |
set = featureStore.getFeatureSet(featureQuery);
|
|
123 | 124 |
if (!multipleSelection && set.getSize()>1){ |
124 |
SelectRowPanel selectionPanel=new SelectRowPanel(set, this);
|
|
125 |
SelectRowPanel selectionPanel = new SelectRowPanel(set, this);
|
|
125 | 126 |
PluginServices.getMDIManager().addCentredWindow(selectionPanel); |
126 | 127 |
} |
127 |
selectGeometries(featureStore, set, vp, multipleSelection);
|
|
128 |
selectGeometries(featureStore, set, viewPort, multipleSelection);
|
|
128 | 129 |
} catch (ReadException e) { |
129 | 130 |
NotificationManager.addError(e.getMessage(), e); |
130 | 131 |
} catch (GeometryOperationNotSupportedException e) { |
... | ... | |
145 | 146 |
try { |
146 | 147 |
FeatureStore featureStore = getFeatureStore(); |
147 | 148 |
lastPoint = new Point2D.Double(x, y); |
148 |
ViewPort vp = getLayer().getMapContext().getViewPort();
|
|
149 |
ViewPort viewPort = getLayer().getMapContext().getViewPort();
|
|
149 | 150 |
double x1; |
150 | 151 |
double y1; |
151 | 152 |
double w1; |
... | ... | |
169 | 170 |
|
170 | 171 |
Envelope envelope = geomManager.createEnvelope(x1, y1, x1 + w1, y1 + h1, SUBTYPES.GEOM2D); |
171 | 172 |
|
172 |
FeatureQuery fq = featureStore.createFeatureQuery();
|
|
173 |
fq.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
173 |
FeatureQuery featureQuery = featureStore.createFeatureQuery();
|
|
174 |
featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
174 | 175 |
Evaluator evaluator=null; |
175 | 176 |
if (firstPoint.getX() < lastPoint.getX()) { |
176 |
evaluator = new IntersectsGeometryEvaluator(envelope.getGeometry(), vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
177 |
evaluator = new IntersectsGeometryEvaluator(envelope.getGeometry(), viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
177 | 178 |
}else{ |
178 |
evaluator = new IntersectsGeometryEvaluator(envelope.getGeometry(), vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
179 |
evaluator = new IntersectsGeometryEvaluator(envelope.getGeometry(), viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
179 | 180 |
} |
180 |
fq.setFilter(evaluator);
|
|
181 |
set = featureStore.getFeatureSet(fq);
|
|
182 |
selectGeometries(featureStore, set, vp, false);
|
|
181 |
featureQuery.setFilter(evaluator);
|
|
182 |
set = featureStore.getFeatureSet(featureQuery);
|
|
183 |
selectGeometries(featureStore, set, viewPort, false);
|
|
183 | 184 |
} catch (ReadException e) { |
184 | 185 |
NotificationManager.addError(e.getMessage(), e); |
185 | 186 |
} catch (GeometryOperationNotSupportedException e) { |
... | ... | |
199 | 200 |
FeatureSet set = null; |
200 | 201 |
try { |
201 | 202 |
FeatureStore featureStore = getFeatureStore(); |
202 |
ViewPort vp = getLayer().getMapContext().getViewPort();
|
|
203 |
FeatureQuery fq = featureStore.createFeatureQuery();
|
|
204 |
fq.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
205 |
Evaluator evaluator = new ContainsGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
206 |
fq.setFilter(evaluator);
|
|
207 |
set = featureStore.getFeatureSet(fq);
|
|
208 |
selectGeometries(featureStore, set, vp, false);
|
|
203 |
ViewPort viewPort = getLayer().getMapContext().getViewPort();
|
|
204 |
FeatureQuery featureQuery = featureStore.createFeatureQuery();
|
|
205 |
featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
206 |
Evaluator evaluator = new ContainsGeometryEvaluator(polygon, viewPort.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName());
|
|
207 |
featureQuery.setFilter(evaluator);
|
|
208 |
set = featureStore.getFeatureSet(featureQuery);
|
|
209 |
selectGeometries(featureStore, set, viewPort, false);
|
|
209 | 210 |
} catch (ReadException e) { |
210 | 211 |
NotificationManager.addError(e.getMessage(), e); |
211 | 212 |
} catch (DataException e) { |
... | ... | |
218 | 219 |
DisposeUtils.dispose(set); |
219 | 220 |
} |
220 | 221 |
} |
222 |
|
|
221 | 223 |
private void selectGeometries(FeatureStore featureStore, FeatureSet set, ViewPort vp, boolean multipleSelection) throws DataException, GeometryOperationNotSupportedException, GeometryOperationException{ |
222 |
BufferedImage selectionImage = null; |
|
223 |
BufferedImage handlersImage = null; |
|
224 |
// if (!multipleSelection) { |
|
225 |
// clearSelection(); |
|
226 |
// } |
|
227 |
if (multipleSelection && getSelectionImage() != null |
|
228 |
&& getHandlersImage() != null) { |
|
229 |
selectionImage = (BufferedImage) getSelectionImage(); |
|
230 |
handlersImage = (BufferedImage) getHandlersImage(); |
|
231 |
} else { |
|
232 |
selectionImage = |
|
233 |
new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), |
|
234 |
BufferedImage.TYPE_INT_ARGB); |
|
235 |
handlersImage = |
|
236 |
new BufferedImage(vp.getImageWidth(), vp.getImageHeight(), |
|
237 |
BufferedImage.TYPE_INT_ARGB); |
|
238 |
} |
|
239 |
Graphics2D gs = selectionImage.createGraphics(); |
|
240 |
Graphics2D gh = handlersImage.createGraphics(); |
|
241 | 224 |
FeatureSelection featureSelection = null; |
242 | 225 |
if (multipleSelection) { |
243 | 226 |
featureSelection = (FeatureSelection) featureStore.getSelection(); |
... | ... | |
247 | 230 |
featureSelection.select(set); |
248 | 231 |
featureStore.setSelection(featureSelection); |
249 | 232 |
} |
233 |
//Draw the geometries with the edition symbology |
|
234 |
|
|
250 | 235 |
} |
251 | 236 |
|
252 | 237 |
public void selectIntersectsSurface(org.gvsig.fmap.geom.Geometry polygon) { |
... | ... | |
254 | 239 |
try { |
255 | 240 |
FeatureStore featureStore = getFeatureStore(); |
256 | 241 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
257 |
FeatureQuery fq = featureStore.createFeatureQuery();
|
|
258 |
fq.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
242 |
FeatureQuery featureQuery = featureStore.createFeatureQuery();
|
|
243 |
featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
259 | 244 |
Evaluator evaluator = new IntersectsGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()); |
260 |
fq.setFilter(evaluator);
|
|
261 |
set = featureStore.getFeatureSet(fq);
|
|
245 |
featureQuery.setFilter(evaluator);
|
|
246 |
set = featureStore.getFeatureSet(featureQuery);
|
|
262 | 247 |
selectGeometries(featureStore,set,vp,false); |
263 | 248 |
} catch (ReadException e) { |
264 | 249 |
NotificationManager.addError(e.getMessage(), e); |
... | ... | |
278 | 263 |
try { |
279 | 264 |
FeatureStore featureStore = getFeatureStore(); |
280 | 265 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
281 |
FeatureQuery fq = featureStore.createFeatureQuery();
|
|
282 |
fq.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
266 |
FeatureQuery featureQuery = featureStore.createFeatureQuery();
|
|
267 |
featureQuery.setAttributeNames(new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()});
|
|
283 | 268 |
Evaluator evaluator=new OutGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()); |
284 |
fq.setFilter(evaluator);
|
|
285 |
set = featureStore.getFeatureSet(fq);
|
|
269 |
featureQuery.setFilter(evaluator);
|
|
270 |
set = featureStore.getFeatureSet(featureQuery);
|
|
286 | 271 |
selectGeometries(featureStore, set, vp, false); |
287 | 272 |
|
288 | 273 |
} catch (ReadException e) { |
... | ... | |
302 | 287 |
FeatureSet set = null; |
303 | 288 |
try { |
304 | 289 |
FeatureStore featureStore = getFeatureStore(); |
305 |
ViewPort vp = getLayer().getMapContext().getViewPort();
|
|
290 |
ViewPort viewPort = getLayer().getMapContext().getViewPort();
|
|
306 | 291 |
set = featureStore.getFeatureSet(); |
307 |
selectGeometries(featureStore, set, vp, false);
|
|
292 |
selectGeometries(featureStore, set, viewPort, false);
|
|
308 | 293 |
} catch (ReadException e) { |
309 | 294 |
NotificationManager.addError(e.getMessage(), e); |
310 | 295 |
} catch (DataException e) { |
... | ... | |
320 | 305 |
|
321 | 306 |
public void drawHandlers(org.gvsig.fmap.geom.Geometry geom, |
322 | 307 |
ViewPort vp) { |
323 |
Handler[] handlers = geom |
|
324 |
.getHandlers(org.gvsig.fmap.geom.Geometry.SELECTHANDLER); |
|
308 |
Handler[] handlers = geom.getHandlers(org.gvsig.fmap.geom.Geometry.SELECTHANDLER); |
|
325 | 309 |
mapControl.getMapControlDrawer().drawHandlers(handlers, vp.getAffineTransform(), |
326 |
mapControlManager.getHandlerSymbol());
|
|
310 |
MAP_CONTROL_MANAGER.getHandlerSymbol());
|
|
327 | 311 |
} |
328 | 312 |
|
329 | 313 |
public Image getSelectionImage() { |
... | ... | |
353 | 337 |
try { |
354 | 338 |
featureStore = getFeatureStore(); |
355 | 339 |
if (featureStore.isEditing()) { |
356 |
ViewPort vp = getLayer().getMapContext().getViewPort();
|
|
357 |
iterator = featureStore.getFeatureSelection() |
|
358 |
.iterator();
|
|
340 |
ViewPort viewPort = getLayer().getMapContext().getViewPort();
|
|
341 |
iterator = featureStore.getFeatureSelection().fastIterator();
|
|
342 |
MapControlDrawer mapControlDrawer = mapControl.getMapControlDrawer();
|
|
359 | 343 |
try { |
360 | 344 |
while (iterator.hasNext()) { |
361 | 345 |
Feature feature = (Feature) iterator.next(); |
362 |
org.gvsig.fmap.geom.Geometry geom = feature |
|
363 |
.getDefaultGeometry(); |
|
364 |
mapControl.getMapControlDrawer().startDrawing(this); |
|
365 |
mapControl.getMapControlDrawer().setGraphics(e.getGraphics()); |
|
366 |
drawHandlers(geom.cloneGeometry(), vp); |
|
367 |
mapControl.getMapControlDrawer().stopDrawing(this); |
|
346 |
Geometry geometry = feature.getDefaultGeometry(); |
|
347 |
mapControlDrawer.startDrawing(this); |
|
348 |
mapControlDrawer.setGraphics(e.getGraphics()); |
|
349 |
drawHandlers(geometry.cloneGeometry(), viewPort); |
|
350 |
mapControlDrawer.stopDrawing(this); |
|
368 | 351 |
} |
369 | 352 |
} catch (ConcurrentModificationException e1) { |
370 | 353 |
// throw new CancelationException(e1); |
... | ... | |
374 | 357 |
} |
375 | 358 |
} |
376 | 359 |
} catch (Exception e2) { |
377 |
e2.printStackTrace();
|
|
360 |
LOG.error("Error drawing the selected geometry", e2);
|
|
378 | 361 |
} finally { |
379 | 362 |
if (iterator != null) { |
380 | 363 |
iterator.dispose(); |
... | ... | |
382 | 365 |
} |
383 | 366 |
} |
384 | 367 |
|
385 |
public void beforeGraphicLayerDraw(LayerDrawEvent e)
|
|
368 |
public void beforeGraphicLayerDraw(LayerDrawEvent e)
|
|
386 | 369 |
throws CancelationException { |
387 | 370 |
} |
388 | 371 |
|
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/CADExtension.java | ||
---|---|---|
56 | 56 |
import javax.swing.text.JTextComponent; |
57 | 57 |
|
58 | 58 |
import org.gvsig.andami.PluginServices; |
59 |
import org.gvsig.andami.PluginsLocator; |
|
60 |
import org.gvsig.andami.PluginsManager; |
|
59 | 61 |
import org.gvsig.andami.plugins.Extension; |
60 | 62 |
import org.gvsig.andami.preferences.IPreference; |
61 | 63 |
import org.gvsig.andami.preferences.IPreferenceExtension; |
... | ... | |
74 | 76 |
import org.gvsig.editing.gui.preferences.EditingPage; |
75 | 77 |
import org.gvsig.editing.project.documents.view.toc.MenuEntry; |
76 | 78 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
79 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
77 | 80 |
import org.gvsig.fmap.mapcontrol.MapControl; |
81 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
|
82 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
|
83 |
import org.gvsig.tools.dynobject.DynObject; |
|
78 | 84 |
import org.gvsig.utils.console.JConsole; |
79 | 85 |
import org.gvsig.utils.console.ResponseListener; |
80 | 86 |
import org.gvsig.utils.console.jedit.JEditTextArea; |
... | ... | |
134 | 140 |
|
135 | 141 |
// Registramos los Popup menus: |
136 | 142 |
MenuEntry.register(); |
137 |
// Fijamos que los s?mbolos de dibujo tengan outline |
|
138 |
// TODO: Esto se debe configurar en el cuadro de di?logo de preferencias |
|
139 |
// jaume, this should be unnecessary |
|
140 |
// CADTool.drawingSymbol.setOutlined(true); |
|
141 |
// CADTool.drawingSymbol.setOutlineColor(CADTool.drawingSymbol.getColor().darker()); |
|
142 |
// CADTool.modifySymbol.setOutlined(true); |
|
143 |
// CADTool.modifySymbol.setOutlineColor(CADTool.modifySymbol.getColor().darker()); |
|
144 |
// CADTool.selectSymbol.setOutlined(true); |
|
145 |
// CADTool.selectSymbol.setOutlineColor(CADTool.selectSymbol.getColor().darker()); |
|
146 | 143 |
|
147 |
|
|
148 | 144 |
CopyCADTool copy = new CopyCADTool(); |
149 | 145 |
RotateCADTool rotate = new RotateCADTool(); |
150 | 146 |
ScaleCADTool scale = new ScaleCADTool(); |
... | ... | |
179 | 175 |
registerIcons(); |
180 | 176 |
} |
181 | 177 |
|
182 |
private void registerIcons(){ |
|
178 |
@Override |
|
179 |
public void postInitialize() { |
|
180 |
//Register the edition symbology |
|
181 |
registerEditionSymbology(); |
|
182 |
} |
|
183 |
|
|
184 |
/** |
|
185 |
* It registers the default symbology used in edition |
|
186 |
*/ |
|
187 |
private void registerEditionSymbology() { |
|
188 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
189 |
DynObject dynObject = pluginsManager.getPlugin(getClass()).getPluginProperties(); |
|
190 |
|
|
191 |
MapControlManager mapControlManager = MapControlLocator.getMapControlManager(); |
|
192 |
|
|
193 |
if (dynObject.hasDynValue(EditingPage.DEFAULT_AXIS_REFERENCES_SYMBOL)){ |
|
194 |
mapControlManager.setAxisReferenceSymbol( |
|
195 |
(ISymbol)dynObject.getDynValue(EditingPage.DEFAULT_AXIS_REFERENCES_SYMBOL)); |
|
196 |
} |
|
197 |
|
|
198 |
if (dynObject.hasDynValue(EditingPage.DEFAULT_RECTANGLE_SELECTION_SYMBOL)) { |
|
199 |
mapControlManager.setGeometrySelectionSymbol( |
|
200 |
(ISymbol)dynObject.getDynValue(EditingPage.DEFAULT_RECTANGLE_SELECTION_SYMBOL)); |
|
201 |
} |
|
202 |
|
|
203 |
if (dynObject.hasDynValue(EditingPage.DEFAULT_HANDLER_SYMBOL)) { |
|
204 |
mapControlManager.setHandlerSymbol( |
|
205 |
(ISymbol)dynObject.getDynValue(EditingPage.DEFAULT_HANDLER_SYMBOL)); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
private void registerIcons(){ |
|
183 | 210 |
PluginServices.getIconTheme().registerDefault( |
184 | 211 |
"edition-geometry-copy", |
185 | 212 |
this.getClass().getClassLoader().getResource("images/Copy.png") |
Also available in: Unified diff