root / org.gvsig.dxf / trunk / org.gvsig.dxf / org.gvsig.dxf.lib / src / main / java / org / gvsig / dxf / px / gml / Feature.java @ 6
History | View | Annotate | Download (3.16 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.gvsig.dxf.px.gml; |
25 |
|
26 |
import java.awt.Graphics2D; |
27 |
import java.util.Hashtable; |
28 |
|
29 |
import org.cresques.geo.ViewPortData; |
30 |
import org.cresques.px.Extent; |
31 |
import org.gvsig.dxf.px.PxObj; |
32 |
|
33 |
|
34 |
/**
|
35 |
* Feature de .gml y .shp
|
36 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
37 |
*/
|
38 |
public class Feature extends PxObj { |
39 |
Hashtable property = null; |
40 |
Geometry geometry = null;
|
41 |
|
42 |
/**
|
43 |
* Constructor de la clase Feature.
|
44 |
*/
|
45 |
public Feature() {
|
46 |
property = new Hashtable(); |
47 |
} |
48 |
|
49 |
/**
|
50 |
* Establece los atributos de las Features.
|
51 |
* @param prop, Nombre del atributo.
|
52 |
* @param value, Valor que toma este atributo para esta Feature.
|
53 |
*/
|
54 |
public void setProp(String prop, String value) { |
55 |
property.put(prop, value); |
56 |
} |
57 |
|
58 |
/**
|
59 |
* Devuelve el valor de un determinado atributo del Feature.
|
60 |
* @param prop, Nombre del atributo del cual queremos conocer el valor.
|
61 |
* @return String, Valor del atributo para esta Feature.
|
62 |
*/
|
63 |
public String getProp(String prop) { |
64 |
return (String) property.get(prop); |
65 |
} |
66 |
|
67 |
/**
|
68 |
* Establece la geometr?a a la que est? asociada este Feature.
|
69 |
* @param geom, la geometr?a que caracteriza a este Feature.
|
70 |
*/
|
71 |
public void setGeometry(Geometry geom) { |
72 |
geometry = geom; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Devuelve la geometr?a asociada a este Feature.
|
77 |
* @return Geometry, la geometr?a que caracteriza a este Feature.
|
78 |
*/
|
79 |
public Geometry getGeometry() {
|
80 |
return geometry;
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* Devuelve el extent de la geometr?a que caracteriza al Feature.
|
85 |
* @return Extent, rect?ngulo en el que est? ubicado la geometr?a caracter?stica
|
86 |
* del Feature.
|
87 |
*/
|
88 |
public Extent getExtent() {
|
89 |
if (geometry != null) { |
90 |
return geometry.getExtent();
|
91 |
} |
92 |
|
93 |
return null; |
94 |
} |
95 |
|
96 |
/**
|
97 |
* Permite dibujar le geometr?a caracter?stica del Feature.
|
98 |
*/
|
99 |
public void draw(Graphics2D g, ViewPortData vp) { |
100 |
Geometry geo = getGeometry(); |
101 |
|
102 |
if (geo != null) { |
103 |
if (geo instanceof Point) { |
104 |
((Point) geo).text = getProp("NOMBRE"); |
105 |
} |
106 |
|
107 |
geo.draw(g, vp); |
108 |
} |
109 |
} |
110 |
} |