Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / beans / canvas / layers / functions / DensitySlicingLine.java @ 19559

History | View | Annotate | Download (2.43 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.raster.beans.canvas.layers.functions;
20

    
21
import java.awt.Color;
22

    
23
/**
24
 * Representa una l?nea escalonada para el realce de density slicing.
25
 * Esta hereda de StraightLine porque es b?sicamente la misma pero con una
26
 * forma determinada.
27
 * 
28
 * 11/03/2008
29
 * @author Nacho Brodin nachobrodin@gmail.com
30
 */
31
public class DensitySlicingLine extends StraightLine {
32

    
33
        public static final int               DEFAULT_LEVELS  = 6;
34
        
35
        private int                           levels          = DEFAULT_LEVELS;
36
        
37
        /**
38
         * Constructor. Asigna el valor de color a la l?nea
39
         * @param c Color
40
         */
41
        public DensitySlicingLine(Color c) {
42
                super(c);
43
        }
44
        
45
        /**
46
         * Constructor. Asigna el valor de color a la l?nea
47
         * @param c Color
48
         */
49
        public DensitySlicingLine(Color c, int levels) {
50
                super(c);
51
                this.levels = levels;
52
        }
53
        
54
        /*
55
         * (non-Javadoc)
56
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#firstDrawActions()
57
         */
58
        public void firstDrawActions() {
59
                setShape(levels);
60
        }
61
        
62
        /**
63
         * Pone la forma a la l?nea escalonada dependiendo del n?mero de 
64
         * escalones existentes.
65
         * 
66
         * @param levels
67
         */
68
        public void setShape(int levels) {
69
                this.levels = levels;
70
                listSquare.clear();
71
                int nSquares = (levels * 2) + 1;
72
                
73
                if(canvas == null || levels <= 1)
74
                        return;
75
                
76
                int distX = canvas.getCanvasWidth() / levels;
77
                int distY = canvas.getCanvasHeight() / (levels - 1);
78
                
79
                int posX = canvas.getCanvasMinX();
80
                int posY = canvas.getCanvasMaxY();
81
                for (int i = 0; i <= nSquares; i++) {
82
                        listSquare.add(new Square(posX, posY));
83
                        if((i % 2) != 0) 
84
                                posY -= distY;
85
                        else 
86
                                posX += distX;
87
                }
88
        }
89
}