Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / beans / canvas / layers / ExponentialLine.java @ 19319

History | View | Annotate | Download (2.35 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;
20

    
21
import java.awt.Color;
22
import java.awt.Graphics;
23

    
24
import org.gvsig.raster.beans.canvas.DrawableElement;
25
import org.gvsig.raster.beans.canvas.GCanvas;
26

    
27

    
28
/**
29
 * Representa una linea con incremento exponencial.
30
 *
31
 * 14-oct-2007
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 */
34
public class ExponentialLine extends DrawableElement {
35
        int[]                    xPoints = null;
36
        int[]                    yPoints = null;
37
        
38
        /**
39
         * Constructor. Asigna el color
40
         * @param c
41
         */
42
        public ExponentialLine(Color c) {
43
                setColor(c);
44
        }
45
        
46
        /*
47
         *  (non-Javadoc)
48
         * @see org.gvsig.gui.beans.canvas.DrawableElement#firstDraw()
49
         */
50
        public void firstDrawActions() {
51
                int value = Math.min(canvas.getCanvasWidth(), canvas.getCanvasHeight());
52
                xPoints = new int[value];
53
                yPoints = new int[value];
54
                for (int i = canvas.getCanvasMinY(); i <  canvas.getCanvasMaxY(); i++) {
55
                        yPoints[i] = value - (int)(value * Math.exp((double)i / 64) / Math.exp(3));
56
                        xPoints[i] = i;
57
                        //System.out.println(xPoints[i] + " " + yPoints[i]);
58
                        //System.out.println(Math.exp((double)i/85));
59
                }
60
        }
61
        
62
        /**
63
         * Dibujado de la l?nea de incremento exponencial sobre el canvas.
64
         */
65
        protected void paint(Graphics g) {
66
                g.setColor(color);
67
                g.drawPolyline(xPoints, yPoints, xPoints.length);
68
        }
69

    
70
        /**
71
         * Asigna el objeto JComponent donde se pintan los elementos. Inicializa los puntos
72
         * de inicio y fin de l?nea y asigna los listener
73
         * @param canvas
74
         */
75
        public void setCanvas(GCanvas canvas) {
76
                super.setCanvas(canvas);
77
        }
78
}