svn-gvsig-desktop / branches / v10 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / FGraphic.java @ 20100
History | View | Annotate | Download (5.36 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-sep-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, USA.
|
21 |
*
|
22 |
* 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 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.fmap.rendering; |
45 |
|
46 |
import java.awt.Graphics2D; |
47 |
|
48 |
import com.iver.cit.gvsig.fmap.ViewPort; |
49 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
50 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
51 |
|
52 |
/**
|
53 |
* <p><code>FGraphic</code> defines a graphic symbol.</p>
|
54 |
*
|
55 |
* <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 |
*/
|
58 |
public class FGraphic { |
59 |
/**
|
60 |
* <p>Identifies this graphic symbol.</p>
|
61 |
*
|
62 |
* @see #getIdSymbol()
|
63 |
* @see #setIdSymbol(int)
|
64 |
*/
|
65 |
int idSymbol;
|
66 |
|
67 |
/**
|
68 |
* <p>Geometry of this graphic symbol.</p>
|
69 |
*
|
70 |
* @see #getGeom()
|
71 |
* @see #setGeom(IGeometry)
|
72 |
*/
|
73 |
IGeometry geom; |
74 |
|
75 |
/**
|
76 |
* <p>Optional text associated to this graphic symbol as a tag.</p>
|
77 |
*
|
78 |
* @see #getTag()
|
79 |
* @see #setTag(String)
|
80 |
*/
|
81 |
String tag;
|
82 |
|
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 |
Object objectTag;
|
90 |
|
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 |
public FGraphic(IGeometry geom, int idSymbol) |
98 |
{ |
99 |
this.idSymbol = idSymbol;
|
100 |
this.geom = geom;
|
101 |
} |
102 |
|
103 |
/**
|
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 |
public String getTag() { |
111 |
return tag;
|
112 |
} |
113 |
|
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 |
public void setTag(String tag) { |
122 |
this.tag = tag;
|
123 |
} |
124 |
|
125 |
/**
|
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 |
public IGeometry getGeom() {
|
133 |
return geom;
|
134 |
} |
135 |
|
136 |
/**
|
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 |
public void setGeom(IGeometry geom) { |
144 |
this.geom = geom;
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* <p>Gets the identifier of this symbol.</p>
|
149 |
*
|
150 |
* @return the identifier of this symbol
|
151 |
*
|
152 |
* @see #setIdSymbol(int)
|
153 |
*/
|
154 |
public int getIdSymbol() { |
155 |
return idSymbol;
|
156 |
} |
157 |
|
158 |
/**
|
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 |
public void setIdSymbol(int idSymbol) { |
166 |
this.idSymbol = idSymbol;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* <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 |
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); |
185 |
} |
186 |
} |
187 |
|
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 |
public Object getObjectTag() { |
196 |
return objectTag;
|
197 |
} |
198 |
|
199 |
/**
|
200 |
* <p>Sets an object tag associated to this symbol.</p>
|
201 |
*
|
202 |
* @param objectTag the object tag associated to this symbol
|
203 |
*
|
204 |
* @see #getObjectTag()
|
205 |
*/
|
206 |
public void setObjectTag(Object objectTag) { |
207 |
this.objectTag = objectTag;
|
208 |
} |
209 |
} |