svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / beans / canvas / DrawableElement.java @ 19319
History | View | Annotate | Download (3.24 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; |
20 |
|
21 |
import java.awt.Color; |
22 |
import java.awt.Graphics; |
23 |
import java.awt.event.MouseEvent; |
24 |
|
25 |
import org.gvsig.raster.IProcessActions; |
26 |
|
27 |
|
28 |
/**
|
29 |
* Clase base para los gr?ficos a dibujar sobre el canvas
|
30 |
*
|
31 |
* 14-oct-2007
|
32 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
33 |
*/
|
34 |
public abstract class DrawableElement { |
35 |
|
36 |
protected Color color = Color.BLACK; |
37 |
/**
|
38 |
* Entorno donde se dibuja
|
39 |
*/
|
40 |
protected GCanvas canvas = null; |
41 |
private boolean firstDraw = true; |
42 |
protected IProcessActions actionsManager = null; |
43 |
|
44 |
/**
|
45 |
* Dibujado del elemento gr?fico desde el GCanvas. Llamar? antes de dibujar a la funci?n firstDrawActions
|
46 |
* @param g
|
47 |
*/
|
48 |
public void draw(Graphics g) { |
49 |
if(firstDraw) {
|
50 |
firstDrawActions(); |
51 |
firstDraw = false;
|
52 |
} |
53 |
paint(g); |
54 |
} |
55 |
/**
|
56 |
* Dibujado del elemento gr?fico
|
57 |
* @param g
|
58 |
*/
|
59 |
protected abstract void paint(Graphics g); |
60 |
|
61 |
/**
|
62 |
* Acciones a ejecutar antes del primer dibujado
|
63 |
*/
|
64 |
public abstract void firstDrawActions(); |
65 |
|
66 |
/**
|
67 |
* Asigna el objeto JComponent donde se pintan los elementos.
|
68 |
* @param canvas
|
69 |
*/
|
70 |
public void setCanvas(GCanvas canvas) { |
71 |
this.canvas = canvas;
|
72 |
} |
73 |
|
74 |
/**
|
75 |
* Asigna el color de la l?nea
|
76 |
* @param c Color
|
77 |
*/
|
78 |
public void setColor(Color c) { |
79 |
this.color = c;
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Asigna el gestor de acciones
|
84 |
* @param actionsManager
|
85 |
*/
|
86 |
public void setActionManager(IProcessActions actionsManager) { |
87 |
this.actionsManager = actionsManager;
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* Metodo que se ejecuta cuando se suelta el raton en el canvas
|
92 |
* @param e
|
93 |
* @return Si no se desea propagar el evento a otros drawables, devolver false.
|
94 |
*/
|
95 |
public boolean mouseReleased(MouseEvent e) { |
96 |
return true; |
97 |
} |
98 |
|
99 |
/**
|
100 |
* Metodo que se ejecuta cuando se presiona el raton en el canvas
|
101 |
* @param e
|
102 |
* @return Si no se desea propagar el evento a otros drawables, devolver false.
|
103 |
*/
|
104 |
public boolean mousePressed(MouseEvent e) { |
105 |
return true; |
106 |
} |
107 |
|
108 |
/**
|
109 |
* Metodo que se ejecuta cuando se esta dibujando con el raton en el canvas
|
110 |
* @param e
|
111 |
* @return Si no se desea propagar el evento a otros drawables, devolver false.
|
112 |
*/
|
113 |
public boolean mouseDragged(MouseEvent e) { |
114 |
return true; |
115 |
} |
116 |
|
117 |
/**
|
118 |
* Metodo que se ejecuta cuando se esta moviendo el raton sobre el canvas
|
119 |
* @param e
|
120 |
* @return Si no se desea propagar el evento a otros drawables, devolver false.
|
121 |
*/
|
122 |
public boolean mouseMoved(MouseEvent e) { |
123 |
return true; |
124 |
} |
125 |
} |