Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / tools / PointCADTool.java @ 4892

History | View | Annotate | Download (4.34 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.ShapeFactory;
48
import com.iver.cit.gvsig.gui.cad.DefaultCADTool;
49
import com.iver.cit.gvsig.gui.cad.tools.smc.PointCADToolContext;
50
import com.iver.cit.gvsig.gui.cad.tools.smc.PointCADToolContext.PointCADToolState;
51

    
52

    
53
/**
54
 * DOCUMENT ME!
55
 *
56
 * @author Vicente Caballero Navarro
57
 */
58
public class PointCADTool extends DefaultCADTool {
59
    private PointCADToolContext _fsm;
60

    
61
    /**
62
     * Crea un nuevo PointCADTool.
63
     */
64
    public PointCADTool() {
65

    
66
    }
67

    
68
    /**
69
     * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
70
     * carga previa a la utilizaci?n de la herramienta.
71
     */
72
    public void init() {
73
            _fsm = new PointCADToolContext(this);
74
    }
75

    
76
    /**
77
     * DOCUMENT ME!
78
     * @param x DOCUMENT ME!
79
     * @param y DOCUMENT ME!
80
     * @param sel DOCUMENT ME!
81
     */
82
    public void transition(double x, double y, InputEvent event) {
83
        _fsm.addPoint(x, y, event);
84
    }
85

    
86
    /* (non-Javadoc)
87
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
88
     */
89
    public void transition(double d) {
90
        // TODO Auto-generated method stub
91
    }
92

    
93
    /* (non-Javadoc)
94
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
95
     */
96
    public void transition(String s) {
97
            if (!super.changeCommand(s)){
98
                    _fsm.addOption(s);
99
            }
100
    }
101

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

    
114
        if (status.equals("Point.FirstPoint")) {
115
            addGeometry(ShapeFactory.createPoint2D(x, y));
116
        }
117
    }
118

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

    
132
    /**
133
     * Add a diferent option.
134
     *
135
     * @param sel DOCUMENT ME!
136
     * @param s Diferent option.
137
     */
138
    public void addOption(String s) {
139
        // TODO Auto-generated method stub
140
    }
141

    
142
    /* (non-Javadoc)
143
     * @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
144
     */
145
    public void addValue(double d) {
146
        // TODO Auto-generated method stub
147
    }
148

    
149
        public String getName() {
150
                return PluginServices.getText(this,"point_");
151
        }
152

    
153
        public String toString() {
154
                return "_point";
155
        }
156

    
157
}