root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / FGraphic.java @ 38563
History | View | Annotate | Download (5.22 KB)
1 | 2901 | fjp | /*
|
---|---|---|---|
2 | * Created on 19-sep-2005
|
||
3 | *
|
||
4 | * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | 8142 | jaume | *
|
6 | 2901 | fjp | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 | 8142 | jaume | *
|
8 | 2901 | fjp | * 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 | 8142 | jaume | *
|
13 | 2901 | fjp | * 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 | 8142 | jaume | *
|
18 | 2901 | fjp | * 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, USA.
|
||
21 | 8142 | jaume | *
|
22 | 2901 | fjp | * For more information, contact:
|
23 | *
|
||
24 | * Generalitat Valenciana
|
||
25 | * Conselleria d'Infraestructures i Transport
|
||
26 | * Av. Blasco Ib??ez, 50
|
||
27 | * 46010 VALENCIA
|
||
28 | * SPAIN
|
||
29 | *
|
||
30 | * +34 963862235
|
||
31 | * gvsig@gva.es
|
||
32 | * www.gvsig.gva.es
|
||
33 | 8142 | jaume | *
|
34 | 2901 | fjp | * or
|
35 | 8142 | jaume | *
|
36 | 2901 | fjp | * IVER T.I. S.A
|
37 | * Salamanca 50
|
||
38 | * 46005 Valencia
|
||
39 | * Spain
|
||
40 | 8142 | jaume | *
|
41 | 2901 | fjp | * +34 963163400
|
42 | * dac@iver.es
|
||
43 | */
|
||
44 | package com.iver.cit.gvsig.fmap.rendering; |
||
45 | |||
46 | 3561 | fjp | import java.awt.Graphics2D; |
47 | |||
48 | import com.iver.cit.gvsig.fmap.ViewPort; |
||
49 | 2901 | fjp | import com.iver.cit.gvsig.fmap.core.IGeometry; |
50 | 9641 | jaume | import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
51 | 20098 | jmvivo | |
52 | 14259 | jvidal | /**
|
53 | 20098 | jmvivo | * <p><code>FGraphic</code> defines a graphic symbol.</p>
|
54 | 14259 | jvidal | *
|
55 | 20098 | jmvivo | * <p>That symbol represents a geometry capable to be painted, with an identifier, and can, optionally,
|
56 | * have attached a tag that can be a text or an object.</p>
|
||
57 | 14259 | jvidal | */
|
58 | 2901 | fjp | public class FGraphic { |
59 | 14259 | jvidal | /**
|
60 | 20098 | jmvivo | * <p>Identifies this graphic symbol.</p>
|
61 | 14259 | jvidal | *
|
62 | * @see #getIdSymbol()
|
||
63 | * @see #setIdSymbol(int)
|
||
64 | */
|
||
65 | int idSymbol;
|
||
66 | 20098 | jmvivo | |
67 | /**
|
||
68 | * <p>Geometry of this graphic symbol.</p>
|
||
69 | *
|
||
70 | * @see #getGeom()
|
||
71 | * @see #setGeom(IGeometry)
|
||
72 | */
|
||
73 | 14259 | jvidal | IGeometry geom; |
74 | 20098 | jmvivo | |
75 | /**
|
||
76 | * <p>Optional text associated to this graphic symbol as a tag.</p>
|
||
77 | *
|
||
78 | * @see #getTag()
|
||
79 | * @see #setTag(String)
|
||
80 | */
|
||
81 | 14259 | jvidal | String tag;
|
82 | 20098 | jmvivo | |
83 | /**
|
||
84 | * <p>Optional object <i>(example: an icon)</i> associated to this graphic symbol as a tag.</p>
|
||
85 | *
|
||
86 | * @see #getObjectTag()
|
||
87 | * @see #setObjectTag(Object)
|
||
88 | */
|
||
89 | 14259 | jvidal | Object objectTag;
|
90 | 20098 | jmvivo | |
91 | /**
|
||
92 | * <p>Creates a <code>geom</code> type <code>FGraphic</code> instance, identified by <code>idSymbol</code>.</p>
|
||
93 | *
|
||
94 | * @param geom the geometry that this symbol will represent
|
||
95 | * @param idSymbol this geometry identifier
|
||
96 | */
|
||
97 | 14259 | jvidal | public FGraphic(IGeometry geom, int idSymbol) |
98 | { |
||
99 | this.idSymbol = idSymbol;
|
||
100 | this.geom = geom;
|
||
101 | } |
||
102 | 8142 | jaume | |
103 | 20098 | jmvivo | /**
|
104 | * <p>Gets the text tag associated to this symbol.</p>
|
||
105 | *
|
||
106 | * @return the text tag associated to this symbol, or <code>null</code> if undefined
|
||
107 | *
|
||
108 | * @see #setTag(String)
|
||
109 | */
|
||
110 | 14259 | jvidal | public String getTag() { |
111 | return tag;
|
||
112 | } |
||
113 | 20098 | jmvivo | |
114 | /**
|
||
115 | * <p>Sets a text tag associated to this symbol.</p>
|
||
116 | *
|
||
117 | * @param tag a text tag associated to this symbol
|
||
118 | *
|
||
119 | * @see #getTag()
|
||
120 | */
|
||
121 | 14259 | jvidal | public void setTag(String tag) { |
122 | this.tag = tag;
|
||
123 | } |
||
124 | 2901 | fjp | |
125 | 20098 | jmvivo | /**
|
126 | * <p>Gets the geometry of this symbol.</p>
|
||
127 | *
|
||
128 | * @return an object indicating this component's geometry
|
||
129 | *
|
||
130 | * @see #setGeom(IGeometry)
|
||
131 | */
|
||
132 | 14259 | jvidal | public IGeometry getGeom() {
|
133 | return geom;
|
||
134 | } |
||
135 | 2901 | fjp | |
136 | 20098 | jmvivo | /**
|
137 | * <p>Replaces the geometry of this symbol by <code>geom</code></p>.
|
||
138 | *
|
||
139 | * @param geom an object indicating this symbol geometry
|
||
140 | *
|
||
141 | * @see #getGeom()
|
||
142 | */
|
||
143 | 14259 | jvidal | public void setGeom(IGeometry geom) { |
144 | this.geom = geom;
|
||
145 | } |
||
146 | 2901 | fjp | |
147 | 20098 | jmvivo | /**
|
148 | * <p>Gets the identifier of this symbol.</p>
|
||
149 | *
|
||
150 | * @return the identifier of this symbol
|
||
151 | *
|
||
152 | * @see #setIdSymbol(int)
|
||
153 | */
|
||
154 | 14259 | jvidal | public int getIdSymbol() { |
155 | return idSymbol;
|
||
156 | } |
||
157 | 2901 | fjp | |
158 | 20098 | jmvivo | /**
|
159 | * <p>Replaces the identifier of this symbol by <code>idSymbol</code></p>
|
||
160 | *
|
||
161 | * @param idSymbol the new identifier
|
||
162 | *
|
||
163 | * @see #getIdSymbol()
|
||
164 | */
|
||
165 | 14259 | jvidal | public void setIdSymbol(int idSymbol) { |
166 | this.idSymbol = idSymbol;
|
||
167 | } |
||
168 | 2901 | fjp | |
169 | 14259 | jvidal | /**
|
170 | 20098 | jmvivo | * <p>Defines the default logic of drawing a graphic symbol.</p>
|
171 | *
|
||
172 | * <p>Using the rendering defined in <code>g</code>, if <code>theSymbol</code> is visible,
|
||
173 | * that symbol will be drawn in <code>viewPort</code>.</p>
|
||
174 | *
|
||
175 | * @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
|
||
176 | * @param viewPort information for drawing this graphic item
|
||
177 | * @param theSymbol the symbol that will be drawn
|
||
178 | */
|
||
179 | 14259 | jvidal | public void draw(Graphics2D g, ViewPort viewPort, ISymbol theSymbol ) |
180 | { |
||
181 | if (theSymbol.isShapeVisible())
|
||
182 | { |
||
183 | IGeometry cloneGeom = geom.cloneGeometry(); |
||
184 | cloneGeom.draw(g,viewPort,theSymbol, null);
|
||
185 | } |
||
186 | } |
||
187 | 20098 | jmvivo | |
188 | /**
|
||
189 | * <p>Gets the object tag associated to this symbol.</p>
|
||
190 | *
|
||
191 | * @return the object tag associated to this symbol, or <code>null</code> if undefined
|
||
192 | *
|
||
193 | * @see #setObjectTag(Object)
|
||
194 | */
|
||
195 | 8616 | fjp | public Object getObjectTag() { |
196 | return objectTag;
|
||
197 | } |
||
198 | 20098 | jmvivo | |
199 | 14259 | jvidal | /**
|
200 | 20098 | jmvivo | * <p>Sets an object tag associated to this symbol.</p>
|
201 | 14259 | jvidal | *
|
202 | 20098 | jmvivo | * @param objectTag the object tag associated to this symbol
|
203 | 14259 | jvidal | *
|
204 | * @see #getObjectTag()
|
||
205 | */
|
||
206 | 8616 | fjp | public void setObjectTag(Object objectTag) { |
207 | this.objectTag = objectTag;
|
||
208 | } |
||
209 | 2901 | fjp | } |