Revision 2402

View differences:

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;
56 55

  
57 56
        public DensityAlgorithm(int distance) {
58 57
            this.setDistance(distance);
59
            this.correction = 1000000;
60 58
        }
61 59

  
62 60
        public void setDistance(int distance) {
......
80 78
        public int getDistance() {
81 79
            return this.distance;
82 80
        }
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
        }
98 81

  
99 82
        public void init(int with, int height) {
100 83
            this.with = with;
......
207 190
    private Color rampHotColor;
208 191
    private int rampNumColors;
209 192
    private Geometry roi;
210
    private boolean fixedDistance;
211 193
    
212 194
    public DefaultHeatmapLegend() {
213 195
        
......
220 202
        this.imageLegend = null;
221 203
        this.hmColorTable = null;
222 204
        this.fieldName = null;
223
        this.fixedDistance = false;
224 205
    }
225 206

  
226

  
227
    
228 207
    @Override
229 208
    protected String[] getRequiredFeatureAttributeNames(FeatureStore featureStore) throws DataException {
230 209
        FeatureType ftype = featureStore.getDefaultFeatureType();
......
247 226
    @Override
248 227
    public void setDefaultSymbol(ISymbol is) {
249 228
    }
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
    
229

  
259 230
    @Override
260 231
    public ISymbol getSymbolByFeature(Feature ftr) throws MapContextException {
261 232
        return this.defaultSymbol;
......
287 258
    @Override
288 259
    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 {
289 260
        int saved_distance = this.algorithm.getDistance();
290
        
291 261
        try {
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
            }
262
            int distance = (int) (this.algorithm.getDistance() * (dpi / 72));
298 263
            Geometry theROI = null;
299 264
            if (this.roi!=null) {
300 265
                theROI = this.roi.cloneGeometry();
......
321 286
        try {
322 287
            double dpi = viewPort.getDPI();
323 288
            // Ver CartographicSupportToolkit.getCartographicLength
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
            }
289
            int distance = (int) (this.algorithm.getDistance() * (dpi / 72));
330 290
            Geometry theROI = null;
331 291
            if (this.roi!=null) {
332 292
                theROI = this.roi.cloneGeometry();
......
401 361
    @Override
402 362
    public int getDistance() {
403 363
        return this.algorithm.getDistance();
404
    }   
364
    }
405 365

  
406 366
    /**
407 367
     * @param distance the distance to set
......
520 480
        return this.roi;
521 481
    }
522 482
    
523
    public void setUseFixedViz(boolean fixedDistance) {
524
        this.fixedDistance = fixedDistance;
525
    }
526
    
527 483
    @Override
528 484
    public Image getImageLegend() {
529 485
        if( this.imageLegend==null ) {

Also available in: Unified diff