root / branches / v2_0_0_prep / libraries / lib3DMap-share / src / main / java / com / iver / ai2 / gvsig3d / legend / symbols / Object3DMarkerSymbol.java @ 29940
History | View | Annotate | Download (9.5 KB)
1 | 23168 | jcampos | /* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib��ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | |||
42 | /* CVS MESSAGES:
|
||
43 | *
|
||
44 | * $Id: PictureMarkerSymbol.java 15593 2007-10-29 13:01:13Z jdominguez $
|
||
45 | * $Log$
|
||
46 | * Revision 1.17 2007-09-21 12:25:32 jaume
|
||
47 | * cancellation support extended down to the IGeometry and ISymbol level
|
||
48 | *
|
||
49 | * Revision 1.16 2007/09/19 16:22:04 jaume
|
||
50 | * removed unnecessary imports
|
||
51 | *
|
||
52 | * Revision 1.15 2007/09/11 07:46:55 jaume
|
||
53 | * *** empty log message ***
|
||
54 | *
|
||
55 | * Revision 1.14 2007/08/16 06:55:19 jvidal
|
||
56 | * javadoc updated
|
||
57 | *
|
||
58 | * Revision 1.13 2007/08/09 06:42:24 jvidal
|
||
59 | * javadoc
|
||
60 | *
|
||
61 | * Revision 1.12 2007/08/08 12:05:17 jvidal
|
||
62 | * javadoc
|
||
63 | *
|
||
64 | * Revision 1.11 2007/07/18 06:54:35 jaume
|
||
65 | * continuing with cartographic support
|
||
66 | *
|
||
67 | * Revision 1.10 2007/07/03 10:58:29 jaume
|
||
68 | * first refactor on CartographicSupport
|
||
69 | *
|
||
70 | * Revision 1.9 2007/06/29 13:07:01 jaume
|
||
71 | * +PictureLineSymbol
|
||
72 | *
|
||
73 | * Revision 1.8 2007/06/11 12:25:48 jaume
|
||
74 | * ISymbol drawing integration tests (markers and lines)
|
||
75 | *
|
||
76 | * Revision 1.7 2007/06/07 06:50:40 jaume
|
||
77 | * *** empty log message ***
|
||
78 | *
|
||
79 | * Revision 1.6 2007/05/29 15:46:37 jaume
|
||
80 | * *** empty log message ***
|
||
81 | *
|
||
82 | * Revision 1.5 2007/05/08 08:47:40 jaume
|
||
83 | * *** empty log message ***
|
||
84 | *
|
||
85 | * Revision 1.4 2007/03/21 17:36:22 jaume
|
||
86 | * *** empty log message ***
|
||
87 | *
|
||
88 | * Revision 1.3 2007/03/09 11:20:57 jaume
|
||
89 | * Advanced symbology (start committing)
|
||
90 | *
|
||
91 | * Revision 1.1.2.4 2007/02/21 07:34:09 jaume
|
||
92 | * labeling starts working
|
||
93 | *
|
||
94 | * Revision 1.1.2.3 2007/02/16 10:54:12 jaume
|
||
95 | * multilayer splitted to multilayerline, multilayermarker,and multilayerfill
|
||
96 | *
|
||
97 | * Revision 1.1.2.2 2007/02/15 16:23:44 jaume
|
||
98 | * *** empty log message ***
|
||
99 | *
|
||
100 | * Revision 1.1.2.1 2007/02/09 07:47:05 jaume
|
||
101 | * Isymbol moved
|
||
102 | *
|
||
103 | * Revision 1.1 2007/01/24 17:58:22 jaume
|
||
104 | * new features and architecture error fixes
|
||
105 | *
|
||
106 | *
|
||
107 | */
|
||
108 | 25860 | jcampos | package com.iver.ai2.gvsig3d.legend.symbols; |
109 | 23168 | jcampos | |
110 | import java.awt.Graphics2D; |
||
111 | import java.awt.Rectangle; |
||
112 | import java.awt.geom.AffineTransform; |
||
113 | import java.io.IOException; |
||
114 | import java.net.MalformedURLException; |
||
115 | import java.net.URL; |
||
116 | |||
117 | import javax.swing.ImageIcon; |
||
118 | |||
119 | import org.apache.log4j.Logger; |
||
120 | 29815 | jtorres | import org.gvsig.andami.PluginServices; |
121 | import org.gvsig.andami.messages.Messages; |
||
122 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
123 | import org.gvsig.app.project.documents.view.gui.BaseView; |
||
124 | 29316 | jtorres | import org.gvsig.fmap.dal.exception.ReadException; |
125 | import org.gvsig.fmap.geom.Geometry; |
||
126 | import org.gvsig.fmap.geom.primitive.FShape; |
||
127 | import org.gvsig.fmap.mapcontext.MapContext; |
||
128 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
129 | import org.gvsig.fmap.mapcontext.layers.FLayers; |
||
130 | 29940 | jtorres | import org.gvsig.fmap.mapcontext.rendering.symbols.AbstractMarkerSymbol; |
131 | 29316 | jtorres | import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
132 | import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
||
133 | 27001 | jtorres | import org.gvsig.osgvp.core.osg.Vec3; |
134 | 29815 | jtorres | import org.gvsig.tools.task.Cancellable; |
135 | import org.gvsig.utils.XMLEntity; |
||
136 | 23168 | jcampos | |
137 | import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps; |
||
138 | |||
139 | 29940 | jtorres | public class Object3DMarkerSymbol extends AbstractMarkerSymbol { |
140 | 23168 | jcampos | private static final float SELECTION_OPACITY_FACTOR = .3F; |
141 | // transient private Image img;
|
||
142 | private String object3DPath; |
||
143 | private boolean selected; |
||
144 | private Vec3 scale;
|
||
145 | private Vec3 rotation;
|
||
146 | private boolean autoRotate = false; |
||
147 | 23302 | jcampos | private String tempScreenshotimage; |
148 | 23168 | jcampos | |
149 | // transient private Image selImg;
|
||
150 | |||
151 | public boolean isAutoRotate() { |
||
152 | return autoRotate;
|
||
153 | } |
||
154 | |||
155 | public void setAutoRotate(boolean autoRotate) { |
||
156 | this.autoRotate = autoRotate;
|
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * Constructor method
|
||
161 | */
|
||
162 | public Object3DMarkerSymbol() {
|
||
163 | super();
|
||
164 | } |
||
165 | |||
166 | /**
|
||
167 | * Constructor method
|
||
168 | *
|
||
169 | * @param imageURL
|
||
170 | * , URL of the normal image
|
||
171 | * @param selImageURL
|
||
172 | * , URL of the image when it is selected in the map
|
||
173 | * @throws IOException
|
||
174 | */
|
||
175 | public Object3DMarkerSymbol(URL object3DURL) throws IOException { |
||
176 | setObject3DPath(object3DURL); |
||
177 | } |
||
178 | |||
179 | public Object3DMarkerSymbol(String object3DPath) throws IOException { |
||
180 | this.object3DPath = object3DPath;
|
||
181 | } |
||
182 | |||
183 | /**
|
||
184 | * Sets the file for the image to be used as a marker symbol
|
||
185 | *
|
||
186 | * @param imageFile
|
||
187 | * , File
|
||
188 | * @throws IOException
|
||
189 | */
|
||
190 | public void setObject3DPath(URL Object3DUrl) throws IOException { |
||
191 | object3DPath = Object3DUrl.toString(); |
||
192 | } |
||
193 | |||
194 | public ISymbol getSymbolForSelection() {
|
||
195 | return null; |
||
196 | } |
||
197 | |||
198 | public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, |
||
199 | Cancellable cancel) { |
||
200 | 29940 | jtorres | |
201 | 23168 | jcampos | |
202 | } |
||
203 | |||
204 | 29316 | jtorres | |
205 | 23168 | jcampos | public void drawInsideRectangle(Graphics2D g, |
206 | AffineTransform scaleInstance, Rectangle r) |
||
207 | throws SymbolDrawingException {
|
||
208 | // TODO Auto-generated method stub
|
||
209 | // super.drawInsideRectangle(g, scaleInstance, r);
|
||
210 | |||
211 | ImageIcon image;
|
||
212 | // Setting the size symbol
|
||
213 | int size = 30; |
||
214 | |||
215 | // Generating the image
|
||
216 | 23302 | jcampos | // image = new ImageIcon(
|
217 | // "c:/Documents and Settings/Julio.IVER/Escritorio/img.png");
|
||
218 | image = new ImageIcon(tempScreenshotimage); |
||
219 | 23168 | jcampos | int x = 0; |
220 | int y = 0; |
||
221 | if (g.getClipBounds() != null) { |
||
222 | x = (int) (g.getClipBounds().getCenterX() - (size / 2)); |
||
223 | y = (int) (g.getClipBounds().getCenterY() - (size / 2)); |
||
224 | } |
||
225 | g.drawImage(image.getImage(), x, y, size, size, null, null); |
||
226 | |||
227 | } |
||
228 | |||
229 | public XMLEntity getXMLEntity() {
|
||
230 | XMLEntity xml = new XMLEntity();
|
||
231 | xml.putProperty("className", getClassName());
|
||
232 | xml.putProperty("isShapeVisible", isShapeVisible());
|
||
233 | xml.putProperty("desc", getDescription());
|
||
234 | xml.putProperty("imagePath", object3DPath);
|
||
235 | 23302 | jcampos | xml.putProperty("tempScreenshotimage",tempScreenshotimage);
|
236 | 23168 | jcampos | |
237 | xml.putProperty("scalex", scale.x());
|
||
238 | xml.putProperty("scaley", scale.y());
|
||
239 | xml.putProperty("scalez", scale.z());
|
||
240 | |||
241 | xml.putProperty("rotationx", rotation.x());
|
||
242 | xml.putProperty("rotationy", rotation.y());
|
||
243 | xml.putProperty("rotationz", rotation.z());
|
||
244 | |||
245 | xml.putProperty("autoRotate", isAutoRotate());
|
||
246 | |||
247 | |||
248 | return xml;
|
||
249 | } |
||
250 | |||
251 | 29316 | jtorres | |
252 | public boolean isSuitableFor(Geometry geom) { |
||
253 | 23168 | jcampos | boolean suitable = false; |
254 | 29815 | jtorres | IWindow[] f = PluginServices
|
255 | 23168 | jcampos | .getMDIManager().getAllWindows(); |
256 | if (f == null) { |
||
257 | return false; |
||
258 | } |
||
259 | for (int i = 0; i < f.length; i++) { |
||
260 | if (f[i] instanceof BaseView) { |
||
261 | BaseView view = (BaseView) f[i]; |
||
262 | MapContext mapContext = view.getMapControl().getMapContext(); |
||
263 | FLayers layer = mapContext.getLayers(); |
||
264 | FLayer[] actives = layer.getActives();
|
||
265 | if (actives.length == 1) { |
||
266 | Layer3DProps props3D = Layer3DProps |
||
267 | .getLayer3DProps(actives[0]);
|
||
268 | if ((props3D != null) |
||
269 | && (props3D.getType() == Layer3DProps.layer3DVector)) { |
||
270 | suitable = true;
|
||
271 | } else {
|
||
272 | suitable = false;
|
||
273 | } |
||
274 | } |
||
275 | } |
||
276 | |||
277 | } |
||
278 | System.out.println("is suitable " + suitable); |
||
279 | return suitable;
|
||
280 | } |
||
281 | |||
282 | public String getClassName() { |
||
283 | return getClass().getName();
|
||
284 | } |
||
285 | |||
286 | public void setXMLEntity(XMLEntity xml) { |
||
287 | setDescription(xml.getStringProperty("desc"));
|
||
288 | setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
|
||
289 | object3DPath = xml.getStringProperty("imagePath");
|
||
290 | 23302 | jcampos | tempScreenshotimage = xml.getStringProperty("tempScreenshotimage");
|
291 | 23168 | jcampos | // setRotation(xml.getDoubleProperty("rotation"));
|
292 | |||
293 | this.scale = new Vec3(); |
||
294 | scale.setX(xml.getDoubleProperty("scalex"));
|
||
295 | scale.setY(xml.getDoubleProperty("scaley"));
|
||
296 | scale.setZ(xml.getDoubleProperty("scalez"));
|
||
297 | |||
298 | this.rotation = new Vec3(); |
||
299 | rotation.setX(xml.getDoubleProperty("rotationx"));
|
||
300 | rotation.setY(xml.getDoubleProperty("rotationy"));
|
||
301 | rotation.setZ(xml.getDoubleProperty("rotationz"));
|
||
302 | |||
303 | setAutoRotate(xml.getBooleanProperty("autoRotate"));
|
||
304 | |||
305 | |||
306 | try {
|
||
307 | setObject3DPath(new URL(object3DPath)); |
||
308 | } catch (MalformedURLException e) { |
||
309 | Logger.getLogger(getClass()).error(
|
||
310 | Messages.getString("invalid_url"));
|
||
311 | } catch (IOException e) { |
||
312 | Logger.getLogger(getClass()).error(
|
||
313 | Messages.getString("invalid_url"));
|
||
314 | |||
315 | } |
||
316 | |||
317 | } |
||
318 | |||
319 | public void print(Graphics2D g, AffineTransform at, FShape shape) |
||
320 | 29316 | jtorres | throws ReadException {
|
321 | 23168 | jcampos | // TODO Implement it
|
322 | throw new Error("Not yet implemented!"); |
||
323 | |||
324 | } |
||
325 | |||
326 | /**
|
||
327 | * Returns the path of the image that is used as a marker symbol
|
||
328 | *
|
||
329 | * @return imagePath,String
|
||
330 | */
|
||
331 | public String getObject3DPath() { |
||
332 | return object3DPath;
|
||
333 | } |
||
334 | |||
335 | public void setScale(Vec3 scale) { |
||
336 | this.scale = scale;
|
||
337 | |||
338 | } |
||
339 | |||
340 | public void setRotation(Vec3 rotation) { |
||
341 | this.rotation = rotation;
|
||
342 | |||
343 | } |
||
344 | |||
345 | public Vec3 getScale() {
|
||
346 | return this.scale; |
||
347 | } |
||
348 | |||
349 | public Vec3 getRotationObject() {
|
||
350 | return this.rotation; |
||
351 | |||
352 | } |
||
353 | |||
354 | 23302 | jcampos | public void setSnapshot(String tempScreenshotimage) { |
355 | this.tempScreenshotimage = tempScreenshotimage;
|
||
356 | |||
357 | } |
||
358 | |||
359 | 29316 | jtorres | public void draw(Graphics2D g, AffineTransform affineTransform, |
360 | Geometry geom, org.gvsig.tools.task.Cancellable cancel) { |
||
361 | // TODO Auto-generated method stub
|
||
362 | |||
363 | } |
||
364 | |||
365 | 23168 | jcampos | } |