Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / gui / cad / tools / PointCadTool.java @ 1763

History | View | Annotate | Download (3.54 KB)

1 1487 fernando
/*
2
 * Created on 07-feb-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
21
   USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.gui.cad.tools;
46
47
import java.awt.Graphics;
48
import java.io.IOException;
49
50
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
51
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
52
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource;
53
import com.iver.cit.gvsig.fmap.edition.cad.Status;
54
import com.iver.cit.gvsig.fmap.layers.FBitSet;
55
import com.iver.cit.gvsig.gui.cad.automaton.Punto;
56 1489 fernando
import com.iver.fsac.Automaton;
57 1487 fernando
58
59
/**
60 1634 vcaballero
 * Herramienta para a?adir una geometr?a de tipo punto.
61 1487 fernando
 *
62
 * @author Vicente Caballero Navarro
63
 */
64
public class PointCadTool extends AbstractCadTool {
65 1763 vcaballero
        private static Status[] STATUS = {
66
                        new Status("Precise un punto"),
67
                        new Status("Precise un punto") };
68 1487 fernando
        private Punto pointStatus = new Punto();
69
70
        /**
71
         * @see com.iver.cit.gvsig.gui.cad.CadTool#transition(java.lang.String,
72
         *                 com.iver.cit.gvsig.fmap.edition.EditableFeatureSource,
73
         *                 com.iver.cit.gvsig.fmap.layers.FBitSet, double[])
74
         */
75
        public int transition(String text, EditableFeatureSource editingSource,
76
                FBitSet selectedGeometries, double[] values) {
77
                int ret = pointStatus.transition(text);
78
79
                int status = pointStatus.getStatus();
80 1492 vcaballero
                if (status == 0){
81
82
                }else if (status == 1) {
83 1487 fernando
                        try {
84
                                if (values.length != 0) {
85
                                        editingSource.addGeometry(ShapeFactory.createPoint2D(
86
                                                        values[0], values[1]));
87
                                }
88
                        } catch (DriverIOException e) {
89
                                e.printStackTrace();
90
                        } catch (IOException e) {
91
                                e.printStackTrace();
92
                        }
93
                }
94
95
                return ret;
96
        }
97
98
        /**
99
         * @see com.iver.cit.gvsig.gui.cad.CadTool#drawOperation(java.awt.Graphics,
100
         *                 com.iver.cit.gvsig.fmap.edition.EditableFeatureSource,
101
         *                 com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
102
         */
103
        public void drawOperation(Graphics g, EditableFeatureSource efs,
104
                FBitSet selectedGeometries, double x, double y) {
105
        }
106
107
        /**
108
         * @see com.iver.cit.gvsig.gui.cad.CadTool#getQuestion()
109
         */
110
        public String getQuestion() {
111
                return STATUS[pointStatus.getStatus()].getQuestion();
112
        }
113
114
        /**
115
         * @see com.iver.cit.gvsig.gui.cad.CadTool#initializeStatus()
116
         */
117
        public void initializeStatus() {
118
                pointStatus.initialize();
119
        }
120 1489 fernando
121
        /**
122
         * @see com.iver.cit.gvsig.gui.cad.CadTool#getAutomaton()
123
         */
124
        public Automaton getAutomaton() {
125
                return pointStatus;
126
        }
127 1763 vcaballero
128
        /**
129
         * @see com.iver.cit.gvsig.gui.cad.CadTool#getName()
130
         */
131
        public String getName() {
132
                return "PUNTO";
133
        }
134 1487 fernando
135
136
}