Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / mapcontrol / swing / dynfield / GeometryDynFieldComponent.java @ 38605

History | View | Annotate | Download (2.87 KB)

1 38605 jldominguez
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.mapcontrol.swing.dynfield;
24
25
import javax.swing.JComponent;
26
import javax.swing.JLabel;
27
28
import org.gvsig.fmap.geom.Geometry;
29
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
30
import org.gvsig.fmap.geom.Geometry.TYPES;
31
import org.gvsig.i18n.Messages;
32
import org.gvsig.tools.dynobject.DynField;
33
import org.gvsig.tools.service.ServiceException;
34
import org.gvsig.tools.swing.api.dynobject.dynfield.ValueField;
35
import org.gvsig.tools.swing.spi.AbstractJDynFieldComponent;
36
37
38
/**
39
 *
40
 * This class provides a swing component
41
 * to represent {@link Geometry} objects in dialogs/forms
42
 *
43
 *
44
 * @author jldominguez
45
 *
46
 */
47
public class GeometryDynFieldComponent extends
48
AbstractJDynFieldComponent {
49
50
    private JLabel label = null;
51
52
    public GeometryDynFieldComponent(
53
        DynField definition,
54
        ValueField value,
55
        boolean writeable) throws ServiceException {
56
57
        super(definition, value, false /* cannot edit geometry. writeable*/);
58
        init();
59
    }
60
61
62
63
64
65
    public void setEnabled(boolean isEnabled) {
66
    }
67
68
    public void requestFocus() {
69
    }
70
71
    public JComponent asJComponent() {
72
        return label;
73
    }
74
75
    public Object getValue() {
76
        return this.getFieldValue();
77
    }
78
79
    protected void setJDynFieldComponentListeners() {
80
    }
81
82
    protected void afterUI() {
83
    }
84
85
    protected void initData() {
86
    }
87
88
    protected void initUI() {
89
        Object val = this.getFieldValue();
90
        if (val == null || (!(val instanceof Geometry))) {
91
            label = new JLabel("[" + Messages.getText("_Null") + "]");
92
        } else {
93
            Geometry geom = (Geometry) val;
94
            label = new JLabel(geom.getGeometryType().getName());
95
        }
96
    }
97
98
    protected void setNonNullValue(Object value) {
99
    }
100
101
    protected void setNullValue() {
102
    }
103
104
    protected void setReadOnly() {
105
    }
106
107
}