42 |
* |
* |
43 |
*/ |
*/ |
44 |
public class StyledFeatureCollectionTableModel extends |
public class StyledFeatureCollectionTableModel extends |
45 |
FeatureCollectionTableModel { |
FeatureCollectionTableModel { |
46 |
|
|
47 |
protected Map<Integer, AttributeMetaData> visibleAMD = null; |
protected Map<Integer, AttributeMetaData> visibleAMD = null; |
48 |
|
|
49 |
public StyledFeatureCollectionTableModel( |
public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map) { |
50 |
StyledFeatureCollectionInterface map) { |
this(map,Filter.INCLUDE); |
51 |
super(); |
} |
52 |
setFeatureCollection(map); |
|
53 |
} |
public StyledFeatureCollectionTableModel(StyledFeatureCollectionInterface map, Filter filter) { |
54 |
|
super(); |
55 |
public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) { |
setFeatureCollection(map, filter); |
56 |
super(); |
} |
57 |
setFeatureCollection(map); |
|
58 |
} |
public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) { |
59 |
|
this(map,Filter.INCLUDE); |
60 |
protected void setFeatureSource(FeatureSource fs, |
} |
61 |
Map<Integer, AttributeMetaData> amd) throws Exception { |
|
62 |
FeatureCollection fc = null; |
public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map, Filter filter) { |
63 |
this.visibleAMD = null; |
super(); |
64 |
if (fs != null) { |
setFeatureCollection(map, filter); |
65 |
Query query = new DefaultQuery(); |
} |
66 |
if (amd != null) { |
|
67 |
// determine the names of the visible Attributes |
protected void setFeatureSource(FeatureSource fs, Map<Integer, AttributeMetaData> amd, Filter filter) throws Exception { |
68 |
this.visibleAMD = StyledMapUtil.getVisibleAttributeMetaData( |
this.visibleAMD = null; |
69 |
amd, true); |
if ( filter == null ) |
70 |
Vector<String> visibleAttrNames = new Vector<String>(); |
filter = Filter.INCLUDE; |
71 |
|
|
72 |
// Add the column with the geometry (usually "the_geom") |
FeatureCollection fc = null; |
73 |
visibleAttrNames.add(fs.getSchema().getDefaultGeometry() |
if (fs != null) { |
74 |
.getLocalName()); |
Query query = new DefaultQuery(); |
75 |
|
if (amd != null) { |
76 |
for (int attrIdx : visibleAMD.keySet()) |
// determine the names of the visible Attributes |
77 |
visibleAttrNames.add(fs.getSchema().getAttributeType( |
this.visibleAMD = StyledMapUtil.getVisibleAttributeMetaData(amd, true); |
78 |
attrIdx).getLocalName()); |
Vector<String> visibleAttrNames = new Vector<String>(); |
79 |
|
// Add the column with the geometry (usually "the_geom") |
80 |
// create a query for the visible attributes |
visibleAttrNames.add(fs.getSchema().getDefaultGeometry().getLocalName()); |
81 |
String[] properties = visibleAttrNames.toArray(new String[0]); |
for (int attrIdx : visibleAMD.keySet()) |
82 |
|
visibleAttrNames.add(fs.getSchema().getAttributeType(attrIdx).getLocalName()); |
83 |
query = new DefaultQuery(fs.getSchema().getTypeName(), |
|
84 |
Filter.INCLUDE, properties); |
// create a query for the visible attributes |
85 |
} |
String[] properties = visibleAttrNames.toArray(new String[0]); |
86 |
fc = fs.getFeatures(query); |
query = new DefaultQuery(fs.getSchema().getTypeName(), filter, properties); |
87 |
} |
} |
88 |
setFeatureCollection(fc); |
fc = fs.getFeatures(query); |
89 |
} |
} |
90 |
|
setFeatureCollection(fc); |
91 |
public void setFeatureCollection(StyledFeatureCollectionInterface map) { |
} |
92 |
try { |
|
93 |
if (map == null) |
public void setFeatureCollection(StyledFeatureCollectionInterface map, Filter filter) { |
94 |
setFeatureSource(null, null); |
try { |
95 |
else { |
if (map == null) |
96 |
FeatureCollection fc = map.getGeoObject(); |
setFeatureSource(null, null, null); |
97 |
String fcName = fc.getFeatureType().getTypeName(); |
else { |
98 |
FeatureSource fs = new MemoryDataStore(fc) |
FeatureCollection fc = map.getGeoObject(); |
99 |
.getFeatureSource(fcName); |
String fcName = fc.getFeatureType().getTypeName(); |
100 |
setFeatureSource(fs, map.getAttributeMetaDataMap()); |
FeatureSource fs = new MemoryDataStore(fc).getFeatureSource(fcName); |
101 |
} |
setFeatureSource(fs, map.getAttributeMetaDataMap(), filter); |
102 |
} catch (Exception err) { |
} |
103 |
throw new RuntimeException(err); |
} catch (Exception err) { |
104 |
} |
throw new RuntimeException(err); |
105 |
} |
} |
106 |
|
} |
107 |
public void setFeatureCollection(StyledFeatureSourceInterface map) { |
|
108 |
try { |
public void setFeatureCollection(StyledFeatureSourceInterface map, Filter filter) { |
109 |
if (map == null) |
try { |
110 |
setFeatureSource(null, null); |
if (map == null) |
111 |
else |
setFeatureSource(null, null, null); |
112 |
setFeatureSource(map.getGeoObject(), map |
else |
113 |
.getAttributeMetaDataMap()); |
setFeatureSource(map.getGeoObject(), map.getAttributeMetaDataMap(), filter); |
114 |
} catch (Exception err) { |
} catch (Exception err) { |
115 |
throw new RuntimeException(err); |
throw new RuntimeException(err); |
116 |
} |
} |
117 |
} |
} |
118 |
|
|
119 |
@Override |
@Override |
120 |
public void reorganize() { |
public void reorganize() { |
121 |
super.reorganize(); |
super.reorganize(); |
122 |
// translate the column names |
// translate the column names |
123 |
if (visibleAMD != null) { |
if (visibleAMD != null) { |
124 |
Iterator<Integer> keys = visibleAMD.keySet().iterator(); |
Iterator<Integer> keys = visibleAMD.keySet().iterator(); |
125 |
for (int i = 0; i < colNames.length && keys.hasNext(); i++) { |
for (int i = 0; i < colNames.length && keys.hasNext(); i++) { |
126 |
Translation title = visibleAMD.get(keys.next()).getTitle(); |
Translation title = visibleAMD.get(keys.next()).getTitle(); |
127 |
if (!I8NUtil.isEmpty(title)) { |
if (!I8NUtil.isEmpty(title)) { |
128 |
System.out.println("set colname " + i + " to " |
System.out.println("set colname " + i + " to " + title.toString()); |
129 |
+ title.toString()); |
colNames[i] = title.toString(); |
130 |
colNames[i] = title.toString(); |
} |
131 |
} |
} |
132 |
} |
} |
133 |
} |
fireTableStructureChanged(); |
134 |
fireTableStructureChanged(); |
} |
|
} |
|
135 |
} |
} |