Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / gui / cad / tools / PointCADTool.java @ 26329

History | View | Annotate | Download (4.82 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 org.gvsig.fmap.geom.Geometry;
47
import org.gvsig.fmap.geom.GeometryFactory;
48
import org.gvsig.fmap.geom.GeometryLocator;
49
import org.gvsig.fmap.geom.GeometryManager;
50

    
51
import com.iver.andami.PluginServices;
52
import com.iver.cit.gvsig.gui.cad.DefaultCADTool;
53
import com.iver.cit.gvsig.gui.cad.exception.CommandException;
54
import com.iver.cit.gvsig.gui.cad.tools.smc.PointCADToolContext;
55
import com.iver.cit.gvsig.gui.cad.tools.smc.PointCADToolContext.PointCADToolState;
56

    
57

    
58
/**
59
 * DOCUMENT ME!
60
 *
61
 * @author Vicente Caballero Navarro
62
 */
63
public class PointCADTool extends DefaultCADTool {
64
    private PointCADToolContext _fsm;
65
    private GeometryFactory geomFactory = GeometryLocator.getGeometryManager().getGeometryFactory();
66

    
67
    /**
68
     * Crea un nuevo PointCADTool.
69
     */
70
    public PointCADTool() {
71

    
72
    }
73

    
74
    /**
75
     * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
76
     * carga previa a la utilizaci?n de la herramienta.
77
     */
78
    public void init() {
79
            _fsm = new PointCADToolContext(this);
80
    }
81

    
82
    /**
83
     * DOCUMENT ME!
84
     * @param x DOCUMENT ME!
85
     * @param y DOCUMENT ME!
86
     * @param sel DOCUMENT ME!
87
     */
88
    public void transition(double x, double y, InputEvent event) {
89
        _fsm.addPoint(x, y, event);
90
    }
91

    
92
    /* (non-Javadoc)
93
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
94
     */
95
    public void transition(double d) {
96
        _fsm.addValue(d);
97
    }
98

    
99
    /* (non-Javadoc)
100
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
101
     */
102
    public void transition(String s) throws CommandException {
103
            if (!super.changeCommand(s)){
104
                    _fsm.addOption(s);
105
            }
106
    }
107

    
108
    /**
109
     * Equivale al transition del prototipo pero sin pasarle como par? metro el
110
     * editableFeatureSource que ya estar? creado.
111
     *
112
     * @param sel Bitset con las geometr?as que est?n seleccionadas.
113
     * @param x par?metro x del punto que se pase en esta transici?n.
114
     * @param y par?metro y del punto que se pase en esta transici?n.
115
     */
116
    public void addPoint(double x, double y,InputEvent event) {
117
        PointCADToolState actualState = (PointCADToolState) _fsm.getPreviousState();
118
        String status = actualState.getName();
119

    
120
        if (status.equals("Point.FirstPoint")) {
121
            insertGeometry(geomFactory.createPoint2D(x, y));
122
        }
123
    }
124

    
125
    /**
126
     * M?todo para dibujar la lo necesario para el estado en el que nos
127
     * encontremos.
128
     *
129
     * @param g Graphics sobre el que dibujar.
130
     * @param selectedGeometries BitSet con las geometr?as seleccionadas.
131
     * @param x par?metro x del punto que se pase para dibujar.
132
     * @param y par?metro x del punto que se pase para dibujar.
133
     */
134
    public void drawOperation(Graphics g, double x,
135
        double y) {
136
    }
137

    
138
    /**
139
     * Add a diferent option.
140
     *
141
     * @param sel DOCUMENT ME!
142
     * @param s Diferent option.
143
     */
144
    public void addOption(String s) {
145
        // TODO Auto-generated method stub
146
    }
147

    
148
    /* (non-Javadoc)
149
     * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
150
     */
151
    public void addValue(double d) {
152
        // TODO Auto-generated method stub
153
    }
154

    
155
        public String getName() {
156
                return PluginServices.getText(this,"point_");
157
        }
158

    
159
        public String toString() {
160
                return "_point";
161
        }
162
        public boolean isApplicable(int shapeType) {
163
                switch (shapeType) {
164
                case Geometry.TYPES.SURFACE:
165
                case Geometry.TYPES.CURVE:
166
                case Geometry.TYPES.MULTIPOINT:
167
                        return false;
168
                }
169
                return true;
170
        }
171
}