33 |
/** |
/** |
34 |
* This class extends the the {@link FeatureCollectionTableModel} with the |
* This class extends the the {@link FeatureCollectionTableModel} with the |
35 |
* functionalities of the {@link AttributeMetaData} of |
* functionalities of the {@link AttributeMetaData} of |
36 |
* {@linkplain StyledMapInterface styled objects}. |
* {@linkplain StyledLayerInterface styled objects}. |
37 |
* <ul> |
* <ul> |
38 |
* <li>column names are translated according to |
* <li>column names are translated according to |
39 |
* {@link AttributeMetaData#getTitle()}</li> |
* {@link AttributeMetaData#getTitle()}</li> |
48 |
final static private Logger LOGGER = Logger |
final static private Logger LOGGER = Logger |
49 |
.getLogger(StyledFeatureCollectionTableModel.class); |
.getLogger(StyledFeatureCollectionTableModel.class); |
50 |
/** Holds the data source as styled map. */ |
/** Holds the data source as styled map. */ |
51 |
protected StyledMapInterface<?> map = null; |
protected StyledLayerInterface<?> layer = null; |
52 |
/** Contains only the visible elements of the {@link AttributeMetaData}-Map */ |
/** Contains only the visible elements of the {@link AttributeMetaData}-Map */ |
53 |
protected Map<Integer, AttributeMetaData> visibleAMD = null; |
protected Map<Integer, AttributeMetaData> visibleAMD = null; |
54 |
/** Holds the data source for the table as {@code FeatureSource}. */ |
/** Holds the data source for the table as {@code FeatureSource}. */ |
60 |
/** Holds the Bounds for all features. Only set once during the constructor **/ |
/** Holds the Bounds for all features. Only set once during the constructor **/ |
61 |
protected Envelope bounds; |
protected Envelope bounds; |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
/** |
/** |
66 |
* Creates a new table model for a styled map. |
* Creates a new table model for a styled map. |
67 |
* |
* |
68 |
* @param map |
* @param layer |
69 |
* the styled map |
* the styled layer |
70 |
*/ |
*/ |
71 |
public StyledFeatureCollectionTableModel( |
public StyledFeatureCollectionTableModel( |
72 |
StyledFeatureCollectionInterface map) { |
StyledFeatureCollectionInterface layer) { |
73 |
this(map, Filter.INCLUDE); |
this(layer, Filter.INCLUDE); |
74 |
} |
} |
75 |
|
|
76 |
/** |
/** |
77 |
* Creates a new table model for a styled map. |
* Creates a new table model for a styled map. |
78 |
* |
* |
79 |
* @param map |
* @param layer |
80 |
* the styled map |
* the styled layer |
81 |
* @param filter |
* @param filter |
82 |
* filter applied to the table |
* filter applied to the table |
83 |
*/ |
*/ |
84 |
public StyledFeatureCollectionTableModel( |
public StyledFeatureCollectionTableModel( |
85 |
StyledFeatureCollectionInterface map, Filter filter) { |
StyledFeatureCollectionInterface layer, Filter filter) { |
86 |
super(); |
super(); |
87 |
setFeatureCollection(map, filter); |
setFeatureCollection(layer, filter); |
88 |
} |
} |
89 |
|
|
90 |
|
|
91 |
/** |
/** |
92 |
* Creates a new table model for a styled map. |
* Creates a new table model for a styled map. |
93 |
* |
* |
94 |
* @param map |
* @param layer |
95 |
* the styled map |
* the styled layer |
96 |
*/ |
*/ |
97 |
public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map) { |
public StyledFeatureCollectionTableModel(StyledFeaturesInterface layer) { |
98 |
this(map, Filter.INCLUDE); |
this(layer, Filter.INCLUDE); |
99 |
} |
} |
100 |
|
|
101 |
/** |
/** |
102 |
* Creates a new table model for a styled map. |
* Creates a new table model for a styled map. |
103 |
* |
* |
104 |
* @param map |
* @param layer |
105 |
* the styled map |
* the styled layer |
106 |
* @param filter |
* @param filter |
107 |
* filter applied to the table |
* filter applied to the table |
108 |
*/ |
*/ |
109 |
public StyledFeatureCollectionTableModel(StyledFeatureSourceInterface map, |
public StyledFeatureCollectionTableModel(StyledFeaturesInterface layer, |
110 |
Filter filter) { |
Filter filter) { |
111 |
super(); |
super(); |
112 |
setFeatureCollection(map, filter); |
setFeatureCollection(layer, filter); |
113 |
} |
} |
114 |
|
|
115 |
/** |
/** |
140 |
Query query = new DefaultQuery(fs.getSchema().getTypeName(), filter); |
Query query = new DefaultQuery(fs.getSchema().getTypeName(), filter); |
141 |
if (amd != null) { |
if (amd != null) { |
142 |
// determine the names of the visible Attributes |
// determine the names of the visible Attributes |
143 |
this.visibleAMD = StyledMapUtil.getVisibleAttributeMetaData( |
this.visibleAMD = StyledLayerUtil.getVisibleAttributeMetaData( |
144 |
amd, true); |
amd, true); |
145 |
Vector<String> visibleAttrNames = new Vector<String>(); |
Vector<String> visibleAttrNames = new Vector<String>(); |
146 |
// Add the column with the geometry (usually "the_geom") |
// Add the column with the geometry (usually "the_geom") |
200 |
* {@link AttributeMetaData}-Map to define the visible attributes |
* {@link AttributeMetaData}-Map to define the visible attributes |
201 |
* and translation |
* and translation |
202 |
*/ |
*/ |
203 |
public void setFeatureCollection(StyledFeatureCollectionInterface map, |
public void setFeatureCollection(StyledFeaturesInterface layer, |
204 |
Filter filter) { |
Filter filter) { |
205 |
this.map = map; |
this.layer = layer; |
206 |
try { |
try { |
207 |
if (map == null) |
if (layer == null) |
208 |
setFeatureSource(null, null, null); |
setFeatureSource(null, null, null); |
209 |
else { |
else { |
210 |
FeatureCollection fc = map.getGeoObject(); |
FeatureCollection fc = layer.getFeatureCollection(); |
211 |
String fcName = fc.getSchema().getTypeName(); |
String fcName = fc.getSchema().getTypeName(); |
212 |
FeatureSource fs = new MemoryDataStore(fc) |
FeatureSource fs = new MemoryDataStore(fc) |
213 |
.getFeatureSource(fcName); |
.getFeatureSource(fcName); |
214 |
setFeatureSource(fs, map.getAttributeMetaDataMap(), filter); |
setFeatureSource(fs, layer.getAttributeMetaDataMap(), filter); |
215 |
} |
} |
216 |
} catch (Exception err) { |
} catch (Exception err) { |
217 |
throw new RuntimeException(err); |
throw new RuntimeException(err); |
228 |
* {@link AttributeMetaData}-Map to define the visible attributes |
* {@link AttributeMetaData}-Map to define the visible attributes |
229 |
* and translation |
* and translation |
230 |
*/ |
*/ |
231 |
public void setFeatureCollection(StyledFeatureSourceInterface map, |
public void setFeatureCollection(StyledFeatureSourceInterface layer, |
232 |
Filter filter) { |
Filter filter) { |
233 |
this.map = map; |
this.layer = layer; |
234 |
try { |
try { |
235 |
if (map == null) |
if (layer == null) |
236 |
setFeatureSource(null, null, null); |
setFeatureSource(null, null, null); |
237 |
else |
else |
238 |
setFeatureSource(map.getGeoObject(), map |
setFeatureSource(layer.getGeoObject(), layer |
239 |
.getAttributeMetaDataMap(), filter); |
.getAttributeMetaDataMap(), filter); |
240 |
} catch (Exception err) { |
} catch (Exception err) { |
241 |
throw new RuntimeException(err); |
throw new RuntimeException(err); |