svn-gvsig-desktop / tags / v10_RC2c / extensions / extAddEventTheme / src / com / iver / gvsig / addeventtheme / AddEventThemListener.java @ 8745
History | View | Annotate | Download (3.92 KB)
1 |
package com.iver.gvsig.addeventtheme; |
---|---|
2 |
|
3 |
import java.awt.geom.PathIterator; |
4 |
import java.io.IOException; |
5 |
|
6 |
import com.hardcode.driverManager.DriverLoadException; |
7 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
8 |
import com.hardcode.gdbms.engine.values.NumericValue; |
9 |
import com.hardcode.gdbms.engine.values.Value; |
10 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
11 |
import com.iver.cit.gvsig.fmap.DriverException; |
12 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
13 |
import com.iver.cit.gvsig.fmap.core.GeneralPathXIterator; |
14 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
15 |
import com.iver.cit.gvsig.fmap.core.IRow; |
16 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
17 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
18 |
import com.iver.cit.gvsig.fmap.edition.AfterFieldEditEvent; |
19 |
import com.iver.cit.gvsig.fmap.edition.AfterRowEditEvent; |
20 |
import com.iver.cit.gvsig.fmap.edition.BeforeFieldEditEvent; |
21 |
import com.iver.cit.gvsig.fmap.edition.BeforeRowEditEvent; |
22 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
23 |
import com.iver.cit.gvsig.fmap.edition.IEditionListener; |
24 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
25 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
26 |
import com.iver.cit.gvsig.fmap.layers.LayerEvent; |
27 |
import com.iver.cit.gvsig.fmap.layers.LayerListener; |
28 |
import com.iver.utiles.DoubleUtilities; |
29 |
|
30 |
public class AddEventThemListener implements LayerListener,IEditionListener{ |
31 |
|
32 |
|
33 |
public void visibilityChanged(LayerEvent e) { |
34 |
|
35 |
} |
36 |
|
37 |
public void activationChanged(LayerEvent e) { |
38 |
|
39 |
} |
40 |
|
41 |
public void nameChanged(LayerEvent e) { |
42 |
|
43 |
} |
44 |
|
45 |
public void editionChanged(LayerEvent e) { |
46 |
if (e.getSource().isEditing()){
|
47 |
VectorialEditableAdapter vea = |
48 |
(VectorialEditableAdapter)((FLyrVect)e.getSource()).getSource(); |
49 |
vea.addEditionListener(this);
|
50 |
} |
51 |
} |
52 |
|
53 |
public void processEvent(EditionEvent e) { |
54 |
// TODO Auto-generated method stub
|
55 |
|
56 |
} |
57 |
|
58 |
public void beforeRowEditEvent(IRow feat,BeforeRowEditEvent e) { |
59 |
if (EditionEvent.CHANGE_TYPE_MODIFY == e.getChangeType()) {
|
60 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) e |
61 |
.getSource(); |
62 |
int numRow = (int) e.getNumRow(); |
63 |
//DefaultFeature df = null;
|
64 |
try {
|
65 |
//df = (DefaultFeature) vea.getFeature(numRow);
|
66 |
|
67 |
if (EditionEvent.GRAPHIC == e.getSourceType()) {
|
68 |
double[] d = new double[4]; |
69 |
IGeometry g = ((DefaultFeature)feat).getGeometry(); |
70 |
g.getPathIterator(null).currentSegment(d);
|
71 |
int[] xy = ((AddEventThemeDriver) vea.getDriver()) |
72 |
.getFieldsIndex(); |
73 |
Value[] values = ((DefaultFeature)feat).getAttributes();
|
74 |
values[xy[0]] = ValueFactory.createValue(DoubleUtilities.format(d[0],".".charAt(0),6)); |
75 |
values[xy[1]] = ValueFactory.createValue(DoubleUtilities.format(d[1],".".charAt(0),6)); |
76 |
//feat = new DefaultFeature(g, values);
|
77 |
//Value value0=vea.getRecordset().getFieldValue(numRow,xy[0]);
|
78 |
//((DoubleValue)value0).setValue(d[0]);
|
79 |
//Value value1=vea.getRecordset().getFieldValue(numRow,xy[1]);
|
80 |
//((DoubleValue)value1).setValue(d[1]);
|
81 |
//vea.setRow(numRow, df);
|
82 |
} else if (EditionEvent.ALPHANUMERIC == e.getSourceType()) { |
83 |
IGeometry g = ((DefaultFeature)feat).getGeometry(); |
84 |
int[] xy = ((AddEventThemeDriver) vea.getDriver()) |
85 |
.getFieldsIndex(); |
86 |
NumericValue x = (NumericValue) ((DefaultFeature) feat) |
87 |
.getAttribute(xy[0]);
|
88 |
NumericValue y = (NumericValue) ((DefaultFeature) feat) |
89 |
.getAttribute(xy[1]);
|
90 |
g = ShapeFactory.createPoint2D(x.doubleValue(), y |
91 |
.doubleValue()); |
92 |
((DefaultFeature)feat).setGeometry(g); |
93 |
//feat = new DefaultFeature(g, ((DefaultFeature) feat)
|
94 |
// .getAttributes());
|
95 |
//vea.setRow(numRow, df);
|
96 |
} |
97 |
} catch (DriverLoadException e1) {
|
98 |
e1.printStackTrace(); |
99 |
} |
100 |
} |
101 |
} |
102 |
|
103 |
public void afterRowEditEvent(IRow feat, AfterRowEditEvent e) { |
104 |
|
105 |
|
106 |
} |
107 |
|
108 |
public void beforeFieldEditEvent(BeforeFieldEditEvent e) { |
109 |
// TODO Auto-generated method stub
|
110 |
|
111 |
} |
112 |
|
113 |
public void afterFieldEditEvent(AfterFieldEditEvent e) { |
114 |
// TODO Auto-generated method stub
|
115 |
|
116 |
} |
117 |
|
118 |
|
119 |
|
120 |
} |