Revision 40491
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/AbstractVectorialLegend.java | ||
---|---|---|
47 | 47 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
48 | 48 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
49 | 49 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
50 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
50 | 51 |
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException; |
51 | 52 |
import org.gvsig.fmap.geom.Geometry; |
52 | 53 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
154 | 155 |
@SuppressWarnings("unchecked") |
155 | 156 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
156 | 157 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
157 |
FeatureStore featureStore, FeatureQuery featureQuery, PrintAttributes properties)
|
|
158 |
FeatureStore featureStore, FeatureQuery fquery, PrintAttributes properties)
|
|
158 | 159 |
throws LegendException { |
159 | 160 |
double dpi = 72; |
160 | 161 |
|
... | ... | |
176 | 177 |
|
177 | 178 |
int mapLevelCount = (useZSort) ? zSort.getLevelCount() : 1; |
178 | 179 |
for (int mapPass = 0; mapPass < mapLevelCount; mapPass++) { |
179 |
// Get the iterator over the visible features |
|
180 |
String[] fieldNames = getRequiredFeatureAttributeNames(featureStore); |
|
181 |
|
|
182 |
if (featureQuery == null){ |
|
183 |
featureQuery = featureStore.createFeatureQuery(); |
|
180 |
|
|
181 |
Envelope vp_env_in_store_crs = null; |
|
182 |
IProjection store_crs = null; |
|
183 |
if (coordTrans != null) { |
|
184 |
// 'coordTrans' is from store crs to vp crs |
|
185 |
ICoordTrans inv = coordTrans.getInverted(); |
|
186 |
Envelope aux = viewPort.getAdjustedEnvelope(); |
|
187 |
vp_env_in_store_crs = aux.convert(inv); |
|
188 |
store_crs = coordTrans.getPOrig(); |
|
189 |
} else { |
|
190 |
vp_env_in_store_crs = viewPort.getAdjustedEnvelope(); |
|
191 |
store_crs = viewPort.getProjection(); |
|
184 | 192 |
} |
185 |
featureQuery.setAttributeNames(fieldNames); |
|
186 |
featureQuery.setScale(scale); |
|
187 |
|
|
188 |
IntersectsEnvelopeEvaluator iee = new IntersectsEnvelopeEvaluator( |
|
189 |
viewPort.getAdjustedEnvelope(), |
|
190 |
viewPort.getProjection(), |
|
191 |
featureStore.getDefaultFeatureType(), featureStore |
|
192 |
.getDefaultFeatureType() |
|
193 |
.getDefaultGeometryAttributeName()); |
|
194 |
featureQuery.addFilter(iee); |
|
195 |
featureSet = featureStore.getFeatureSet(featureQuery); |
|
193 |
|
|
194 |
FeatureQuery feat_query = fquery; |
|
195 |
Envelope store_env = featureStore.getEnvelope(); |
|
196 |
boolean use_intersection_cond = false; |
|
197 |
if (store_env == null) { |
|
198 |
// Store does not know its envelope, so we must: |
|
199 |
use_intersection_cond = true; |
|
200 |
} else { |
|
201 |
if (vp_env_in_store_crs.contains(store_env)) { |
|
202 |
use_intersection_cond = false; |
|
203 |
} else { |
|
204 |
use_intersection_cond = true; |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
if (use_intersection_cond) { |
|
209 |
FeatureType ft = featureStore.getDefaultFeatureType(); |
|
210 |
IntersectsEnvelopeEvaluator iee = |
|
211 |
new IntersectsEnvelopeEvaluator( |
|
212 |
vp_env_in_store_crs, |
|
213 |
store_crs, |
|
214 |
ft, ft.getDefaultGeometryAttributeName()); |
|
215 |
if (feat_query == null) { |
|
216 |
feat_query = featureStore.createFeatureQuery(); |
|
217 |
String[] fns = getRequiredFeatureAttributeNames(featureStore); |
|
218 |
feat_query.setAttributeNames(fns); |
|
219 |
} |
|
220 |
feat_query.addFilter(iee); |
|
221 |
} |
|
222 |
|
|
223 |
// 'feat_query' can still be NULL here, so we only filter |
|
224 |
// the featureStore if it's not null |
|
225 |
if (feat_query == null) { |
|
226 |
featureSet = featureStore.getFeatureSet(); |
|
227 |
} else { |
|
228 |
featureSet = featureStore.getFeatureSet(feat_query); |
|
229 |
} |
|
230 |
|
|
196 | 231 |
it = featureSet.fastIterator(); |
197 |
|
|
198 | 232 |
// Iteration over each feature |
199 | 233 |
while (!cancel.isCanceled() && it.hasNext()) { |
200 | 234 |
Feature feat = (Feature) it.next(); |
201 | 235 |
Geometry geom = feat.getDefaultGeometry(); |
236 |
// Reprojection if needed |
|
237 |
if (coordTrans != null) { |
|
238 |
geom = geom.cloneGeometry(); |
|
239 |
geom.reProject(coordTrans); |
|
240 |
} |
|
202 | 241 |
|
203 | 242 |
// retrieve the symbol associated to such feature |
204 | 243 |
ISymbol sym = getSymbolByFeature(feat); |
Also available in: Unified diff