root / trunk / libraries / libCq_CMS_praster / src / org / cresques / px / gml / Feature.java @ 8026
History | View | Annotate | Download (3.08 KB)
1 | 8026 | nacho | /*
|
---|---|---|---|
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.cresques.px.gml; |
||
25 | |||
26 | import org.cresques.geo.ViewPortData; |
||
27 | |||
28 | import org.cresques.px.Drawable; |
||
29 | import org.cresques.px.Extent; |
||
30 | import org.cresques.px.PxObj; |
||
31 | |||
32 | import java.awt.Graphics2D; |
||
33 | |||
34 | import java.util.Hashtable; |
||
35 | |||
36 | |||
37 | /**
|
||
38 | * Feature de .gml y .shp
|
||
39 | * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
||
40 | */
|
||
41 | public class Feature extends PxObj { |
||
42 | Hashtable property = null; |
||
43 | Geometry geometry = null;
|
||
44 | |||
45 | /**
|
||
46 | * Constructor de la clase Feature.
|
||
47 | */
|
||
48 | public Feature() {
|
||
49 | property = new Hashtable(); |
||
50 | } |
||
51 | |||
52 | /**
|
||
53 | * Establece los atributos de las Features.
|
||
54 | * @param prop, Nombre del atributo.
|
||
55 | * @param value, Valor que toma este atributo para esta Feature.
|
||
56 | */
|
||
57 | public void setProp(String prop, String value) { |
||
58 | property.put(prop, value); |
||
59 | } |
||
60 | |||
61 | /**
|
||
62 | * Devuelve el valor de un determinado atributo del Feature.
|
||
63 | * @param prop, Nombre del atributo del cual queremos conocer el valor.
|
||
64 | * @return String, Valor del atributo para esta Feature.
|
||
65 | */
|
||
66 | public String getProp(String prop) { |
||
67 | return (String) property.get(prop); |
||
68 | } |
||
69 | |||
70 | /**
|
||
71 | * Establece la geometr?a a la que est? asociada este Feature.
|
||
72 | * @param geom, la geometr?a que caracteriza a este Feature.
|
||
73 | */
|
||
74 | public void setGeometry(Geometry geom) { |
||
75 | geometry = geom; |
||
76 | } |
||
77 | |||
78 | /**
|
||
79 | * Devuelve la geometr?a asociada a este Feature.
|
||
80 | * @return Geometry, la geometr?a que caracteriza a este Feature.
|
||
81 | */
|
||
82 | public Geometry getGeometry() {
|
||
83 | return geometry;
|
||
84 | } |
||
85 | |||
86 | /**
|
||
87 | * Devuelve el extent de la geometr?a que caracteriza al Feature.
|
||
88 | * @return Extent, rect?ngulo en el que est? ubicado la geometr?a caracter?stica
|
||
89 | * del Feature.
|
||
90 | */
|
||
91 | public Extent getExtent() {
|
||
92 | if (geometry != null) { |
||
93 | return geometry.getExtent();
|
||
94 | } |
||
95 | |||
96 | return null; |
||
97 | } |
||
98 | |||
99 | /**
|
||
100 | * Permite dibujar le geometr?a caracter?stica del Feature.
|
||
101 | */
|
||
102 | public void draw(Graphics2D g, ViewPortData vp) { |
||
103 | Geometry geo = getGeometry(); |
||
104 | |||
105 | if (geo != null) { |
||
106 | if (geo instanceof Point) { |
||
107 | ((Point) geo).text = getProp("NOMBRE"); |
||
108 | } |
||
109 | |||
110 | geo.draw(g, vp); |
||
111 | } |
||
112 | } |
||
113 | } |