svn-gvsig-desktop / tags / J2ME_compat_v1_2_Build_1209 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / FGraphic.java @ 19509
History | View | Annotate | Download (5.29 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.symbols.ISymbol; |
51 |
/**
|
52 |
* <p>The class <code>FGraphic</code> defines a graphic symbol according to the <i>FMap philosophy</i>.</p>
|
53 |
*
|
54 |
* <p>This symbol represents a geometry ( which can be drawn) with an identifier, and can
|
55 |
* optionally have attached a tag that can be text or an object.</p>
|
56 |
*/
|
57 |
public class FGraphic { |
58 |
/**
|
59 |
* Identifies this graphic symbol.
|
60 |
*
|
61 |
* @see #getIdSymbol()
|
62 |
* @see #setIdSymbol(int)
|
63 |
*/
|
64 |
int idSymbol;
|
65 |
/**
|
66 |
* Geometry of this graphic symbol.
|
67 |
*
|
68 |
* @see #getGeom()
|
69 |
* @see #setGeom(IGeometry)
|
70 |
*/
|
71 |
IGeometry geom; |
72 |
/**
|
73 |
* Optional text associated to this graphic symbol as a tag.
|
74 |
*
|
75 |
* @see #getTag()
|
76 |
* @see #setTag(String)
|
77 |
*/
|
78 |
String tag;
|
79 |
/**
|
80 |
* Optional object <i>(example: an icon)</i> associated to this graphic symbol as a tag.
|
81 |
*
|
82 |
* @see #getObjectTag()
|
83 |
* @see #setObjectTag(Object)
|
84 |
*/
|
85 |
Object objectTag;
|
86 |
/**
|
87 |
* <p>Creates a graphic object according to the <i>FMap philosophy</i>, from a geometry and an identifier.</p>
|
88 |
*
|
89 |
* @param geom the geometry that this symbol will represent
|
90 |
* @param idSymbol the identifier
|
91 |
*/
|
92 |
public FGraphic(IGeometry geom, int idSymbol) |
93 |
{ |
94 |
this.idSymbol = idSymbol;
|
95 |
this.geom = geom;
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Gets the text tag associated to this symbol.
|
100 |
*
|
101 |
* @return the text tag associated to this symbol, or <code>null</code> if undefined
|
102 |
*
|
103 |
* @see #setTag(String)
|
104 |
*/
|
105 |
public String getTag() { |
106 |
return tag;
|
107 |
} |
108 |
/**
|
109 |
* Sets a text tag associated to this symbol.
|
110 |
*
|
111 |
* @param tag a text tag associated to this symbol
|
112 |
*
|
113 |
* @see #getTag()
|
114 |
*/
|
115 |
public void setTag(String tag) { |
116 |
this.tag = tag;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* Gets the geometry of this symbol.
|
121 |
*
|
122 |
* @return an object indicating this component's geometry
|
123 |
*
|
124 |
* @see #setGeom(IGeometry)
|
125 |
*/
|
126 |
public IGeometry getGeom() {
|
127 |
return geom;
|
128 |
} |
129 |
|
130 |
/**
|
131 |
* Changes the geometry of this symbol to the new one.
|
132 |
*
|
133 |
* @param geom an object indicating this component's geometry
|
134 |
*
|
135 |
* @see #getGeom()
|
136 |
*/
|
137 |
public void setGeom(IGeometry geom) { |
138 |
this.geom = geom;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Gets the identifier of this symbol.
|
143 |
*
|
144 |
* @return Returns the idSymbol.
|
145 |
*
|
146 |
* @see #setIdSymbol(int)
|
147 |
*/
|
148 |
public int getIdSymbol() { |
149 |
return idSymbol;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* Changes the identifier of this symbol to the new one.
|
154 |
*
|
155 |
* @param idSymbol the new identifier
|
156 |
*
|
157 |
* @see #getIdSymbol()
|
158 |
*/
|
159 |
public void setIdSymbol(int idSymbol) { |
160 |
this.idSymbol = idSymbol;
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* <p>Defines the default logic of drawing an <i>FMap</i> graphic symbol.</p>
|
165 |
*
|
166 |
* <p>Using the rendering defined in {@link Graphics2D Graphics2D}, the symbol will
|
167 |
* be drawn in the viewport. That symbol must be which has the id <code>idSymbol<code>
|
168 |
* if we want to draw which represents this class.</p>
|
169 |
*
|
170 |
* @param g for rendering 2-dimensional shapes, text and images on the Java(tm) platform
|
171 |
* @param viewPort information for drawing this graphic item
|
172 |
* @param theSymbol the symbol that will be drawn (this parameter is generally used indicating
|
173 |
* the object that has the identifier <code>idSymbol</code>)
|
174 |
*/
|
175 |
public void draw(Graphics2D g, ViewPort viewPort, ISymbol theSymbol ) |
176 |
{ |
177 |
if (theSymbol.isShapeVisible())
|
178 |
{ |
179 |
IGeometry cloneGeom = geom.cloneGeometry(); |
180 |
cloneGeom.draw(g,viewPort,theSymbol, null);
|
181 |
} |
182 |
} |
183 |
/**
|
184 |
* Gets the object tag associated to this symbol.
|
185 |
*
|
186 |
* @return the object tag associated to this symbol, or <code>null</code> if undefined
|
187 |
*
|
188 |
* @see #setObjectTag(Object)
|
189 |
*/
|
190 |
public Object getObjectTag() { |
191 |
return objectTag;
|
192 |
} |
193 |
/**
|
194 |
* Sets an object tag associated to this symbol.
|
195 |
*
|
196 |
* @param objectTag an object tag associated to this symbol
|
197 |
*
|
198 |
* @see #getObjectTag()
|
199 |
*/
|
200 |
public void setObjectTag(Object objectTag) { |
201 |
this.objectTag = objectTag;
|
202 |
} |
203 |
|
204 |
} |