Statistics
| Revision:

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

History | View | Annotate | Download (3.45 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
import java.awt.event.MouseEvent;
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
        public static final int DEFAULT_LEVELS = 6;
33

    
34
        private int             levels         = DEFAULT_LEVELS;
35
        
36
        /**
37
         * Constructor. Asigna el valor de color a la l?nea
38
         * @param c Color
39
         */
40
        public DensitySlicingLine(Color c) {
41
                this(c, DEFAULT_LEVELS);
42
        }
43
        
44
        /**
45
         * Constructor. Asigna el valor de color a la l?nea
46
         * @param c Color
47
         */
48
        public DensitySlicingLine(Color c, int levels) {
49
                super(c);
50
                setShowSquares(false);
51
                setShape(levels);
52
        }
53
        
54
        /**
55
         * Pone la forma a la l?nea escalonada dependiendo del n?mero de 
56
         * escalones existentes.
57
         * 
58
         * @param levels
59
         */
60
        public void setShape(int levels) {
61
                this.levels = levels;
62
                listSquare.clear();
63

    
64
                if (levels <= 1)
65
                        return;
66

    
67
                int nSquares = (levels * 2);
68

    
69
                double posX = 0.0D;
70
                double posY = 0.0D;
71
                double contX = 0.0D;
72
                double contY = 0.0D;
73
                for (int i = 0; i < nSquares; i++) {
74
                        posX = contX / (double) levels;
75
                        posY = contY / (double) (levels - 1.0D);
76
                        listSquare.add(new Square(posX, posY));
77
                        if ((i % 2) != 0)
78
                                contY++;
79
                        else
80
                                contX++;
81
                }
82
        }
83

    
84
        /**
85
         * @return the levels
86
         */
87
        public int getLevels() {
88
                return levels;
89
        }
90

    
91
        /*
92
         * (non-Javadoc)
93
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#getFunctionType()
94
         */
95
        public int getFunctionType() {
96
                return 3;
97
        }
98
        
99
        /*
100
         * (non-Javadoc)
101
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#getValueFunction()
102
         */
103
        public double getValueFunction() {
104
                return levels;
105
        }
106
        
107
        /* (non-Javadoc)
108
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#mouseDragged(java.awt.event.MouseEvent)
109
         */
110
        public boolean mouseDragged(MouseEvent e) {
111
                return true;
112
        }
113

    
114
        /* (non-Javadoc)
115
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#mouseMoved(java.awt.event.MouseEvent)
116
         */
117
        public boolean mouseMoved(MouseEvent e) {
118
                return true;
119
        }
120

    
121
        /* (non-Javadoc)
122
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#mousePressed(java.awt.event.MouseEvent)
123
         */
124
        public boolean mousePressed(MouseEvent e) {
125
                return true;
126
        }
127

    
128
        /* (non-Javadoc)
129
         * @see org.gvsig.raster.beans.canvas.layers.functions.StraightLine#mouseReleased(java.awt.event.MouseEvent)
130
         */
131
        public boolean mouseReleased(MouseEvent e) {
132
                return true;
133
        }
134

    
135
        public void firstDrawActions() {}
136
}