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