Revision 2401
org.gvsig.legend.heatmap/trunk/org.gvsig.legend.heatmap/org.gvsig.legend.heatmap.lib/org.gvsig.legend.heatmap.lib.impl/src/main/java/org/gvsig/legend/heatmap/lib/impl/DefaultHeatmapLegend.java | ||
---|---|---|
52 | 52 |
private int with; |
53 | 53 |
private double maxValue; |
54 | 54 |
private double minValue; |
55 |
private int correction; |
|
55 | 56 |
|
56 | 57 |
public DensityAlgorithm(int distance) { |
57 | 58 |
this.setDistance(distance); |
59 |
this.correction = 1000000; |
|
58 | 60 |
} |
59 | 61 |
|
60 | 62 |
public void setDistance(int distance) { |
... | ... | |
78 | 80 |
public int getDistance() { |
79 | 81 |
return this.distance; |
80 | 82 |
} |
83 |
public int getCorrectionFixedViz() { |
|
84 |
return this.correction; |
|
85 |
} |
|
86 |
|
|
87 |
public void setCorrectionFixedViz(int correction) { |
|
88 |
this.correction = correction; |
|
89 |
} |
|
90 |
|
|
91 |
public int getDistanceForFixedViz(double scale) { |
|
92 |
double dReal = this.getDistance() * this.getCorrectionFixedViz() * (1/scale); |
|
93 |
if (dReal < 0 || dReal > 300) { |
|
94 |
return 300; |
|
95 |
} |
|
96 |
return (int) dReal; |
|
97 |
} |
|
81 | 98 |
|
82 | 99 |
public void init(int with, int height) { |
83 | 100 |
this.with = with; |
... | ... | |
190 | 207 |
private Color rampHotColor; |
191 | 208 |
private int rampNumColors; |
192 | 209 |
private Geometry roi; |
210 |
private boolean fixedDistance; |
|
193 | 211 |
|
194 | 212 |
public DefaultHeatmapLegend() { |
195 | 213 |
|
... | ... | |
202 | 220 |
this.imageLegend = null; |
203 | 221 |
this.hmColorTable = null; |
204 | 222 |
this.fieldName = null; |
223 |
this.fixedDistance = false; |
|
205 | 224 |
} |
206 | 225 |
|
226 |
|
|
227 |
|
|
207 | 228 |
@Override |
208 | 229 |
protected String[] getRequiredFeatureAttributeNames(FeatureStore featureStore) throws DataException { |
209 | 230 |
FeatureType ftype = featureStore.getDefaultFeatureType(); |
... | ... | |
226 | 247 |
@Override |
227 | 248 |
public void setDefaultSymbol(ISymbol is) { |
228 | 249 |
} |
229 |
|
|
250 |
|
|
251 |
public void setCorrectionFixedViz(int correction) { |
|
252 |
this.algorithm.setCorrectionFixedViz(correction); |
|
253 |
} |
|
254 |
|
|
255 |
public int getCorrectionFixedViz() { |
|
256 |
return this.algorithm.getCorrectionFixedViz(); |
|
257 |
} |
|
258 |
|
|
230 | 259 |
@Override |
231 | 260 |
public ISymbol getSymbolByFeature(Feature ftr) throws MapContextException { |
232 | 261 |
return this.defaultSymbol; |
... | ... | |
258 | 287 |
@Override |
259 | 288 |
protected void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, Map queryParameters, ICoordTrans coordTrans, FeatureStore featureStore, FeatureQuery featureQuery, double dpi) throws LegendException { |
260 | 289 |
int saved_distance = this.algorithm.getDistance(); |
290 |
|
|
261 | 291 |
try { |
262 |
int distance = (int) (this.algorithm.getDistance() * (dpi / 72)); |
|
292 |
int distance = 0; |
|
293 |
if (this.fixedDistance) { |
|
294 |
distance = (int) (this.algorithm.getDistanceForFixedViz(scale) * (dpi / 72)); |
|
295 |
} else { |
|
296 |
distance = (int) (this.algorithm.getDistance() * (dpi / 72)); |
|
297 |
} |
|
263 | 298 |
Geometry theROI = null; |
264 | 299 |
if (this.roi!=null) { |
265 | 300 |
theROI = this.roi.cloneGeometry(); |
... | ... | |
286 | 321 |
try { |
287 | 322 |
double dpi = viewPort.getDPI(); |
288 | 323 |
// Ver CartographicSupportToolkit.getCartographicLength |
289 |
int distance = (int) (this.algorithm.getDistance() * (dpi / 72)); |
|
324 |
int distance = 0; |
|
325 |
if (this.fixedDistance) { |
|
326 |
distance = (int) (this.algorithm.getDistanceForFixedViz(scale) * (dpi / 72)); |
|
327 |
} else { |
|
328 |
distance = (int) (this.algorithm.getDistance() * (dpi / 72)); |
|
329 |
} |
|
290 | 330 |
Geometry theROI = null; |
291 | 331 |
if (this.roi!=null) { |
292 | 332 |
theROI = this.roi.cloneGeometry(); |
... | ... | |
361 | 401 |
@Override |
362 | 402 |
public int getDistance() { |
363 | 403 |
return this.algorithm.getDistance(); |
364 |
} |
|
404 |
}
|
|
365 | 405 |
|
366 | 406 |
/** |
367 | 407 |
* @param distance the distance to set |
... | ... | |
480 | 520 |
return this.roi; |
481 | 521 |
} |
482 | 522 |
|
523 |
public void setUseFixedViz(boolean fixedDistance) { |
|
524 |
this.fixedDistance = fixedDistance; |
|
525 |
} |
|
526 |
|
|
483 | 527 |
@Override |
484 | 528 |
public Image getImageLegend() { |
485 | 529 |
if( this.imageLegend==null ) { |
Also available in: Unified diff