svn-gvsig-desktop / tags / v1_1_Build_1012 / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / PointCADTool.java @ 12987
History | View | Annotate | Download (4.62 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.gui.cad.tools; |
42 |
|
43 |
import java.awt.Graphics; |
44 |
import java.awt.event.InputEvent; |
45 |
|
46 |
import com.iver.andami.PluginServices; |
47 |
import com.iver.cit.gvsig.fmap.core.FShape; |
48 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
49 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
50 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
51 |
import com.iver.cit.gvsig.gui.cad.tools.smc.PointCADToolContext; |
52 |
import com.iver.cit.gvsig.gui.cad.tools.smc.PointCADToolContext.PointCADToolState; |
53 |
|
54 |
|
55 |
/**
|
56 |
* DOCUMENT ME!
|
57 |
*
|
58 |
* @author Vicente Caballero Navarro
|
59 |
*/
|
60 |
public class PointCADTool extends DefaultCADTool { |
61 |
private PointCADToolContext _fsm;
|
62 |
|
63 |
/**
|
64 |
* Crea un nuevo PointCADTool.
|
65 |
*/
|
66 |
public PointCADTool() {
|
67 |
|
68 |
} |
69 |
|
70 |
/**
|
71 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una
|
72 |
* carga previa a la utilizaci?n de la herramienta.
|
73 |
*/
|
74 |
public void init() { |
75 |
_fsm = new PointCADToolContext(this); |
76 |
} |
77 |
|
78 |
/**
|
79 |
* DOCUMENT ME!
|
80 |
* @param x DOCUMENT ME!
|
81 |
* @param y DOCUMENT ME!
|
82 |
* @param sel DOCUMENT ME!
|
83 |
*/
|
84 |
public void transition(double x, double y, InputEvent event) { |
85 |
_fsm.addPoint(x, y, event); |
86 |
} |
87 |
|
88 |
/* (non-Javadoc)
|
89 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
|
90 |
*/
|
91 |
public void transition(double d) { |
92 |
_fsm.addValue(d); |
93 |
} |
94 |
|
95 |
/* (non-Javadoc)
|
96 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
|
97 |
*/
|
98 |
public void transition(String s) throws CommandException { |
99 |
if (!super.changeCommand(s)){ |
100 |
_fsm.addOption(s); |
101 |
} |
102 |
} |
103 |
|
104 |
/**
|
105 |
* Equivale al transition del prototipo pero sin pasarle como par? metro el
|
106 |
* editableFeatureSource que ya estar? creado.
|
107 |
*
|
108 |
* @param sel Bitset con las geometr?as que est?n seleccionadas.
|
109 |
* @param x par?metro x del punto que se pase en esta transici?n.
|
110 |
* @param y par?metro y del punto que se pase en esta transici?n.
|
111 |
*/
|
112 |
public void addPoint(double x, double y,InputEvent event) { |
113 |
PointCADToolState actualState = (PointCADToolState) _fsm.getPreviousState(); |
114 |
String status = actualState.getName();
|
115 |
|
116 |
if (status.equals("Point.FirstPoint")) { |
117 |
addGeometry(ShapeFactory.createPoint2D(x, y)); |
118 |
} |
119 |
} |
120 |
|
121 |
/**
|
122 |
* M?todo para dibujar la lo necesario para el estado en el que nos
|
123 |
* encontremos.
|
124 |
*
|
125 |
* @param g Graphics sobre el que dibujar.
|
126 |
* @param selectedGeometries BitSet con las geometr?as seleccionadas.
|
127 |
* @param x par?metro x del punto que se pase para dibujar.
|
128 |
* @param y par?metro x del punto que se pase para dibujar.
|
129 |
*/
|
130 |
public void drawOperation(Graphics g, double x, |
131 |
double y) {
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* Add a diferent option.
|
136 |
*
|
137 |
* @param sel DOCUMENT ME!
|
138 |
* @param s Diferent option.
|
139 |
*/
|
140 |
public void addOption(String s) { |
141 |
// TODO Auto-generated method stub
|
142 |
} |
143 |
|
144 |
/* (non-Javadoc)
|
145 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
|
146 |
*/
|
147 |
public void addValue(double d) { |
148 |
// TODO Auto-generated method stub
|
149 |
} |
150 |
|
151 |
public String getName() { |
152 |
return PluginServices.getText(this,"point_"); |
153 |
} |
154 |
|
155 |
public String toString() { |
156 |
return "_point"; |
157 |
} |
158 |
public boolean isApplicable(int shapeType) { |
159 |
switch (shapeType) {
|
160 |
case FShape.POLYGON:
|
161 |
case FShape.LINE:
|
162 |
case FShape.MULTIPOINT:
|
163 |
return false; |
164 |
} |
165 |
return true; |
166 |
} |
167 |
} |