Revision 25501

View differences:

tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/Object3DMarkerSymbol.java
1
/* 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
package com.iver.ai2.gvsig3d.legend;
109

  
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
import org.gvsig.osgvp.Vec3;
121

  
122
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
123
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
124
import com.iver.andami.PluginServices;
125
import com.iver.andami.ui.mdiManager.IWindow;
126
import com.iver.cit.gvsig.fmap.MapContext;
127
import com.iver.cit.gvsig.fmap.Messages;
128
import com.iver.cit.gvsig.fmap.core.FShape;
129
import com.iver.cit.gvsig.fmap.core.IGeometry;
130
import com.iver.cit.gvsig.fmap.core.symbols.AbstractMarkerSymbol;
131
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
132
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException;
133
import com.iver.cit.gvsig.fmap.layers.FLayer;
134
import com.iver.cit.gvsig.fmap.layers.FLayers;
135
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
136
import com.iver.utiles.XMLEntity;
137
import com.iver.utiles.swing.threads.Cancellable;
138

  
139
public class Object3DMarkerSymbol extends AbstractMarkerSymbol {
140
	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
	private String tempScreenshotimage;
148

  
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
		// FPoint2D p = (FPoint2D) shp;
201
		// double x, y;
202
		// int size = (int) Math.round(getSize());
203
		// double halfSize = getSize()/2;
204
		// x = p.getX() - halfSize;
205
		// y = p.getY() - halfSize;
206
		// int xOffset = (int) getOffset().getX();
207
		// int yOffset = (int) getOffset().getY();
208
		//
209
		// if (size > 0) {
210
		// BackgroundFileStyle bg = (!selected) ? bgImage : bgSelImage ;
211
		// Rectangle rect = new Rectangle( size, size );
212
		// g.translate(x+xOffset, y+yOffset);
213
		// g.rotate(getRotation(), halfSize, halfSize);
214
		// try {
215
		// bg.drawInsideRectangle(g, rect);
216
		// } catch (SymbolDrawingException e) {
217
		// Logger.getLogger(getClass()).warn(Messages.getString(
218
		// "label_style_could_not_be_painted"), e);
219
		// }
220
		// g.rotate(-getRotation(), halfSize, halfSize);
221
		// g.translate(-(x+xOffset), -(y+yOffset));
222
		//
223
		// }
224

  
225
	}
226

  
227
	@Override
228
	public void drawInsideRectangle(Graphics2D g,
229
			AffineTransform scaleInstance, Rectangle r)
230
			throws SymbolDrawingException {
231
		// TODO Auto-generated method stub
232
		// super.drawInsideRectangle(g, scaleInstance, r);
233

  
234
		ImageIcon image;
235
		// Setting the size symbol
236
		int size = 30;
237

  
238
		// Generating the image
239
//		image = new ImageIcon(
240
//				"c:/Documents and Settings/Julio.IVER/Escritorio/img.png");
241
		image = new ImageIcon(tempScreenshotimage);
242
		int x = 0;
243
		int y = 0;
244
		if (g.getClipBounds() != null) {
245
			x = (int) (g.getClipBounds().getCenterX() - (size / 2));
246
			y = (int) (g.getClipBounds().getCenterY() - (size / 2));
247
		}
248
		g.drawImage(image.getImage(), x, y, size, size, null, null);
249

  
250
	}
251

  
252
	public XMLEntity getXMLEntity() {
253
		XMLEntity xml = new XMLEntity();
254
		xml.putProperty("className", getClassName());
255
		xml.putProperty("isShapeVisible", isShapeVisible());
256
		xml.putProperty("desc", getDescription());
257
		xml.putProperty("imagePath", object3DPath);
258
		xml.putProperty("tempScreenshotimage",tempScreenshotimage);
259

  
260
		xml.putProperty("scalex", scale.x());
261
		xml.putProperty("scaley", scale.y());
262
		xml.putProperty("scalez", scale.z());
263
		
264
		xml.putProperty("rotationx", rotation.x());
265
		xml.putProperty("rotationy", rotation.y());
266
		xml.putProperty("rotationz", rotation.z());
267
		
268
		xml.putProperty("autoRotate", isAutoRotate());
269
		
270

  
271
		return xml;
272
	}
273

  
274
	@Override
275
	public boolean isSuitableFor(IGeometry geom) {
276
		boolean suitable = false;
277
		com.iver.andami.ui.mdiManager.IWindow[] f = PluginServices
278
				.getMDIManager().getAllWindows();
279
		if (f == null) {
280
			return false;
281
		}
282
		for (int i = 0; i < f.length; i++) {
283
			if (f[i] instanceof BaseView) {
284
				BaseView view = (BaseView) f[i];
285
				MapContext mapContext = view.getMapControl().getMapContext();
286
				FLayers layer = mapContext.getLayers();
287
				FLayer[] actives = layer.getActives();
288
				if (actives.length == 1) {
289
					Layer3DProps props3D = Layer3DProps
290
							.getLayer3DProps(actives[0]);
291
					if ((props3D != null)
292
							&& (props3D.getType() == Layer3DProps.layer3DVector)) {
293
						suitable = true;
294
					} else {
295
						suitable = false;
296
					}
297
				}
298
			}
299

  
300
		}
301
		System.out.println("is suitable " + suitable);
302
		return suitable;
303
	}
304

  
305
	public String getClassName() {
306
		return getClass().getName();
307
	}
308

  
309
	public void setXMLEntity(XMLEntity xml) {
310
		setDescription(xml.getStringProperty("desc"));
311
		setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
312
		object3DPath = xml.getStringProperty("imagePath");
313
		tempScreenshotimage = xml.getStringProperty("tempScreenshotimage");
314
//		setRotation(xml.getDoubleProperty("rotation"));
315
		
316
		this.scale = new Vec3();
317
		scale.setX(xml.getDoubleProperty("scalex"));
318
		scale.setY(xml.getDoubleProperty("scaley"));
319
		scale.setZ(xml.getDoubleProperty("scalez"));
320

  
321
		this.rotation = new Vec3();
322
		rotation.setX(xml.getDoubleProperty("rotationx"));
323
		rotation.setY(xml.getDoubleProperty("rotationy"));
324
		rotation.setZ(xml.getDoubleProperty("rotationz"));
325
		
326
		setAutoRotate(xml.getBooleanProperty("autoRotate"));
327
		
328

  
329
		try {
330
			setObject3DPath(new URL(object3DPath));
331
		} catch (MalformedURLException e) {
332
			Logger.getLogger(getClass()).error(
333
					Messages.getString("invalid_url"));
334
		} catch (IOException e) {
335
			Logger.getLogger(getClass()).error(
336
					Messages.getString("invalid_url"));
337

  
338
		}
339

  
340
	}
341

  
342
	public void print(Graphics2D g, AffineTransform at, FShape shape)
343
			throws ReadDriverException {
344
		// TODO Implement it
345
		throw new Error("Not yet implemented!");
346

  
347
	}
348

  
349
	/**
350
	 * Returns the path of the image that is used as a marker symbol
351
	 * 
352
	 * @return imagePath,String
353
	 */
354
	public String getObject3DPath() {
355
		return object3DPath;
356
	}
357

  
358
	public void setScale(Vec3 scale) {
359
		this.scale = scale;
360
		
361
	}
362

  
363
	public void setRotation(Vec3 rotation) {
364
		this.rotation = rotation;
365
		
366
	}
367

  
368
	public Vec3 getScale() {
369
		return this.scale;
370
	}
371

  
372
	public Vec3 getRotationObject() {
373
		return this.rotation;
374
	
375
	}
376

  
377
	public void setSnapshot(String tempScreenshotimage) {
378
		this.tempScreenshotimage = tempScreenshotimage;
379
		
380
	}
381

  
382
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/ExtrusionLineSymbol.java
1
package com.iver.ai2.gvsig3d.legend.symbols;
2

  
3
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol;
4

  
5
public class ExtrusionLineSymbol extends SimpleLineSymbol implements IExtrusionSymbol {
6

  
7
	
8
	private double extrusion = 0.0;
9
	
10
	public ExtrusionLineSymbol() {
11
		// TODO Auto-generated constructor stub
12
	}
13
	
14
	public double getExtrusion() {
15
		return this.extrusion;
16
	}
17

  
18
	public void setExtrusion(double extrusion) {
19
		this.extrusion = extrusion;
20
	}
21

  
22

  
23
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/ExtrusionPolygonSymbol.java
1
package com.iver.ai2.gvsig3d.legend.symbols;
2

  
3
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol;
4

  
5
public class ExtrusionPolygonSymbol extends SimpleFillSymbol implements
6
		IExtrusionSymbol {
7

  
8
	private double extrusion = 0.0;
9

  
10
	public ExtrusionPolygonSymbol() {
11
		// TODO Auto-generated constructor stub
12
	}
13
	
14
	public double getExtrusion() {
15
		return this.extrusion;
16
	}
17

  
18
	public void setExtrusion(double extrusion) {
19
		this.extrusion = extrusion;
20
	}
21

  
22
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/IExtrusionSymbol.java
1
package com.iver.ai2.gvsig3d.legend.symbols;
2

  
3
public interface IExtrusionSymbol {
4
	
5
	public void setExtrusion(double extrusion);
6
	
7
	public  double getExtrusion();
8

  
9
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/ExtrusionPointSymbol.java
1
package com.iver.ai2.gvsig3d.legend.symbols;
2

  
3
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol;
4

  
5
public class ExtrusionPointSymbol extends SimpleMarkerSymbol implements IExtrusionSymbol{
6

  
7
	private double extrusion = 0.0;
8
	
9
	public ExtrusionPointSymbol() {
10
		// TODO Auto-generated constructor stub
11
	}
12
	
13
	public double getExtrusion() {
14
		return this.extrusion;
15
	}
16

  
17
	public void setExtrusion(double extrusion) {
18
		this.extrusion = extrusion;
19
	}
20

  
21
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/symbols/BaseExtrusionSymbol.java
1
package com.iver.ai2.gvsig3d.legend.symbols;
2

  
3
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol;
4
import com.iver.utiles.XMLEntity;
5

  
6
public class BaseExtrusionSymbol extends SimpleFillSymbol implements
7
		IExtrusionSymbol {
8

  
9
	private double extrusion = 0.0;
10

  
11
	public double getExtrusion() {
12
		return this.extrusion;
13
	}
14

  
15
	public void setExtrusion(double extrusion) {
16
		this.extrusion = extrusion;
17
	}
18

  
19
	public BaseExtrusionSymbol(double extrusion) {
20
		super();
21
		this.extrusion = extrusion;
22
	}
23
	
24

  
25
	public String getClassName() {
26
		return getClass().getName();
27
	}
28

  
29
	public XMLEntity getXMLEntity() {
30
		XMLEntity xml = super.getXMLEntity();
31
		xml.putProperty("extrusion", this.extrusion);
32
		return xml;
33
	}
34

  
35
	public void setXMLEntity(XMLEntity xml) {
36
		super.setXMLEntity(xml);
37
		if (xml.contains("extrusion"))
38
			extrusion = xml.getDoubleProperty("extrusion");
39
	}
40

  
41
	
42
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/Prove.java
1
package com.iver.ai2.gvsig3d.legend;
2

  
3
import org.gvsig.operators.Abs;
4
import org.gvsig.operators.Acos;
5
import org.gvsig.operators.After;
6
import org.gvsig.operators.Area;
7
import org.gvsig.operators.Asin;
8
import org.gvsig.operators.Atan;
9
import org.gvsig.operators.Before;
10
import org.gvsig.operators.Ceil;
11
import org.gvsig.operators.Cos;
12
import org.gvsig.operators.Distinct;
13
import org.gvsig.operators.Division;
14
import org.gvsig.operators.E;
15
import org.gvsig.operators.EndsWith;
16
import org.gvsig.operators.Equal;
17
import org.gvsig.operators.Equals;
18
import org.gvsig.operators.Exp;
19
import org.gvsig.operators.Geometry;
20
import org.gvsig.operators.GetTimeDate;
21
import org.gvsig.operators.IndexOf;
22
import org.gvsig.operators.IsNumber;
23
import org.gvsig.operators.LastIndexOf;
24
import org.gvsig.operators.Length;
25
import org.gvsig.operators.LessEquals;
26
import org.gvsig.operators.LessThan;
27
import org.gvsig.operators.Log;
28
import org.gvsig.operators.Max;
29
import org.gvsig.operators.Min;
30
import org.gvsig.operators.Minus;
31
import org.gvsig.operators.MoreEquals;
32
import org.gvsig.operators.MoreThan;
33
import org.gvsig.operators.Perimeter;
34
import org.gvsig.operators.Pi;
35
import org.gvsig.operators.Plus;
36
import org.gvsig.operators.PointX;
37
import org.gvsig.operators.PointY;
38
import org.gvsig.operators.Pow;
39
import org.gvsig.operators.Random;
40
import org.gvsig.operators.Replace;
41
import org.gvsig.operators.Round;
42
import org.gvsig.operators.SetTimeDate;
43
import org.gvsig.operators.Sin;
44
import org.gvsig.operators.Sqrt;
45
import org.gvsig.operators.StartsWith;
46
import org.gvsig.operators.SubString;
47
import org.gvsig.operators.Tan;
48
import org.gvsig.operators.Times;
49
import org.gvsig.operators.ToDate;
50
import org.gvsig.operators.ToDegrees;
51
import org.gvsig.operators.ToLowerCase;
52
import org.gvsig.operators.ToNumber;
53
import org.gvsig.operators.ToRadians;
54
import org.gvsig.operators.ToString;
55
import org.gvsig.operators.ToUpperCase;
56
import org.gvsig.operators.Trim;
57

  
58
import com.iver.utiles.extensionPoints.ExtensionPoints;
59
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
60

  
61
public class Prove {
62
	
63
	public static void registerOperations() {
64
    	ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
65

  
66
//    	extensionPoints.add("cad_editing_properties_pages","fieldExpression",FieldExpressionPage.class);
67

  
68
    	extensionPoints.add("ColumnOperatorsExtension",Abs.class.toString(),Abs.class);
69
        extensionPoints.add("ColumnOperatorsExtension",Acos.class.toString(),Acos.class);
70
        extensionPoints.add("ColumnOperatorsExtension",After.class.toString(),After.class);
71
        extensionPoints.add("ColumnOperatorsExtension",Area.class.toString(),Area.class);
72
        extensionPoints.add("ColumnOperatorsExtension",Asin.class.toString(),Asin.class);
73
        extensionPoints.add("ColumnOperatorsExtension",Atan.class.toString(),Atan.class);
74
        extensionPoints.add("ColumnOperatorsExtension",Acos.class.toString(),Acos.class);
75
        extensionPoints.add("ColumnOperatorsExtension",Before.class.toString(),Before.class);
76
        extensionPoints.add("ColumnOperatorsExtension",Ceil.class.toString(),Ceil.class);
77
        extensionPoints.add("ColumnOperatorsExtension",Cos.class.toString(),Cos.class);
78
    	extensionPoints.add("ColumnOperatorsExtension",Distinct.class.toString(),Distinct.class);
79
     	extensionPoints.add("ColumnOperatorsExtension",Division.class.toString(),Division.class);
80
     	extensionPoints.add("ColumnOperatorsExtension",E.class.toString(),E.class);
81
     	extensionPoints.add("ColumnOperatorsExtension",EndsWith.class.toString(),EndsWith.class);
82
     	extensionPoints.add("ColumnOperatorsExtension",Equal.class.toString(),Equal.class);
83
     	extensionPoints.add("ColumnOperatorsExtension",Equals.class.toString(),Equals.class);
84
     	extensionPoints.add("ColumnOperatorsExtension",Exp.class.toString(),Exp.class);
85
     	extensionPoints.add("ColumnOperatorsExtension",Geometry.class.toString(),Geometry.class);
86
     	extensionPoints.add("ColumnOperatorsExtension",GetTimeDate.class.toString(),GetTimeDate.class);
87
     	extensionPoints.add("ColumnOperatorsExtension",IndexOf.class.toString(),IndexOf.class);
88
     	extensionPoints.add("ColumnOperatorsExtension",IsNumber.class.toString(),IsNumber.class);
89
     	extensionPoints.add("ColumnOperatorsExtension",LastIndexOf.class.toString(),LastIndexOf.class);
90
     	extensionPoints.add("ColumnOperatorsExtension",Length.class.toString(),Length.class);
91
     	extensionPoints.add("ColumnOperatorsExtension",LessEquals.class.toString(),LessEquals.class);
92
     	extensionPoints.add("ColumnOperatorsExtension",LessThan.class.toString(),LessThan.class);
93
     	extensionPoints.add("ColumnOperatorsExtension",Log.class.toString(),Log.class);
94
     	extensionPoints.add("ColumnOperatorsExtension",Max.class.toString(),Max.class);
95
     	extensionPoints.add("ColumnOperatorsExtension",Min.class.toString(),Min.class);
96
     	extensionPoints.add("ColumnOperatorsExtension",Minus.class.toString(),Minus.class);
97
     	extensionPoints.add("ColumnOperatorsExtension",MoreEquals.class.toString(),MoreEquals.class);
98
     	extensionPoints.add("ColumnOperatorsExtension",MoreThan.class.toString(),MoreThan.class);
99
     	extensionPoints.add("ColumnOperatorsExtension",Perimeter.class.toString(),Perimeter.class);
100
     	extensionPoints.add("ColumnOperatorsExtension",Pi.class.toString(),Pi.class);
101
    	extensionPoints.add("ColumnOperatorsExtension",Plus.class.toString(),Plus.class);
102
     	extensionPoints.add("ColumnOperatorsExtension",PointX.class.toString(),PointX.class);
103
     	extensionPoints.add("ColumnOperatorsExtension",PointY.class.toString(),PointY.class);
104
     	extensionPoints.add("ColumnOperatorsExtension",Pow.class.toString(),Pow.class);
105
     	extensionPoints.add("ColumnOperatorsExtension",Random.class.toString(),Random.class);
106
     	extensionPoints.add("ColumnOperatorsExtension",Replace.class.toString(),Replace.class);
107
     	extensionPoints.add("ColumnOperatorsExtension",Round.class.toString(),Round.class);
108
     	extensionPoints.add("ColumnOperatorsExtension",SetTimeDate.class.toString(),SetTimeDate.class);
109
     	extensionPoints.add("ColumnOperatorsExtension",Sin.class.toString(),Sin.class);
110
     	extensionPoints.add("ColumnOperatorsExtension",Sqrt.class.toString(),Sqrt.class);
111
     	extensionPoints.add("ColumnOperatorsExtension",StartsWith.class.toString(),StartsWith.class);
112
     	extensionPoints.add("ColumnOperatorsExtension",SubString.class.toString(),SubString.class);
113
     	extensionPoints.add("ColumnOperatorsExtension",Tan.class.toString(),Tan.class);
114
    	extensionPoints.add("ColumnOperatorsExtension",Times.class.toString(),Times.class);
115
    	extensionPoints.add("ColumnOperatorsExtension",ToDate.class.toString(),ToDate.class);
116
    	extensionPoints.add("ColumnOperatorsExtension",ToDegrees.class.toString(),ToDegrees.class);
117
    	extensionPoints.add("ColumnOperatorsExtension",ToLowerCase.class.toString(),ToLowerCase.class);
118
    	extensionPoints.add("ColumnOperatorsExtension",ToNumber.class.toString(),ToNumber.class);
119
    	extensionPoints.add("ColumnOperatorsExtension",ToRadians.class.toString(),ToRadians.class);
120
    	extensionPoints.add("ColumnOperatorsExtension",ToString.class.toString(),ToString.class);
121
    	extensionPoints.add("ColumnOperatorsExtension",ToUpperCase.class.toString(),ToUpperCase.class);
122
    	extensionPoints.add("ColumnOperatorsExtension",Trim.class.toString(),Trim.class);
123
 }
124
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/ExtrusionProve.java
1
package com.iver.ai2.gvsig3d.legend;
2

  
3
import java.awt.BorderLayout;
4

  
5
import javax.swing.ImageIcon;
6
import javax.swing.JPanel;
7

  
8
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
9
import com.iver.andami.PluginServices;
10
import com.iver.andami.messages.NotificationManager;
11
import com.iver.cit.gvsig.ProjectExtension;
12
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
13
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
14
import com.iver.cit.gvsig.fmap.layers.FLayer;
15
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
16
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
17
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
18
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
19
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial;
20
import com.iver.cit.gvsig.fmap.rendering.ILegend;
21
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
22
import com.iver.cit.gvsig.project.ProjectFactory;
23
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
24
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory;
25
import com.iver.cit.gvsig.project.documents.table.gui.Table;
26
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
27
import com.iver.cit.gvsig.project.documents.view.legend.gui.ILegendPanel;
28
import com.iver.cit.gvsig.project.documents.view.legend.gui.SymbolTable;
29

  
30
public class ExtrusionProve implements ILegendPanel{
31

  
32
	public String getDescription() {
33
		// TODO Auto-generated method stub
34
		return null;
35
	}
36

  
37
	public ImageIcon getIcon() {
38
		// TODO Auto-generated method stub
39
		return null;
40
	}
41

  
42
	public ILegend getLegend() {
43
		// TODO Auto-generated method stub
44
		return null;
45
	}
46

  
47
	public Class getLegendClass() {
48
		// TODO Auto-generated method stub
49
		return null;
50
	}
51

  
52
	public JPanel getPanel() {
53
		// TODO Auto-generated method stub
54
		return null;
55
	}
56

  
57
	public Class getParentClass() {
58
		// TODO Auto-generated method stub
59
		return null;
60
	}
61

  
62
	public String getTitle() {
63
		// TODO Auto-generated method stub
64
		return null;
65
	}
66

  
67
	public boolean isSuitableFor(FLayer layer) {
68
		// TODO Auto-generated method stub
69
		return false;
70
	}
71

  
72
	public void setData(FLayer lyr, ILegend legend) {
73
		// TODO Auto-generated method stub
74
		
75
	}
76

  
77
//	private ClassifiableVectorial layer;
78
//	private ExtrusionLegendPanel  extrusionPanel = null;
79
//
80
//	public String getDescription() {
81
//		return "Extrusion legend description";
82
//	}
83
//
84
//	public ImageIcon getIcon() {
85
//		// TODO Auto-generated method stub
86
//		return null;
87
//	}
88
//
89
//	public ILegend getLegend() {
90
//		// TODO Auto-generated method stub
91
//		return null;
92
//	}
93
//
94
//	public Class getLegendClass() {
95
//		// TODO Auto-generated method stub
96
//		return null;
97
//	}
98
//
99
//	public JPanel getPanel() {
100
//		// TODO Auto-generated method stub
101
//		if ( extrusionPanel == null){
102
//			extrusionPanel = new ExtrusionLegendPanel();
103
//		}
104
//		
105
//		return extrusionPanel;
106
//	}
107
//
108
//	public Class getParentClass() {
109
//		// TODO Auto-generated method stub
110
//		return null;
111
//	}
112
//
113
//	public String getTitle() {
114
//		// TODO Auto-generated method stub
115
//		return ("<html><b>"+ "Extrusi?n Legend"+ "</b></html>");
116
//	}
117
//
118
//	public boolean isSuitableFor(FLayer layer) {
119
//		// TODO Auto-generated method stub
120
//		return (layer instanceof FLyrVect);
121
//	}
122
//
123
//	public void setData(FLayer lyr, ILegend legend) {
124
//		// TODO Auto-generated method stub
125
//		this.layer = (ClassifiableVectorial) layer;
126
//		extrusionPanel.setLyr((FLyrVect) lyr);
127
//		
128
//	}
129
//	
130
//	
131
//	
132
//	public Table getAssociatedTable(FLyrVect lyr){
133
//		Table auxTable = null;
134
//		BaseView vista = (BaseView) PluginServices.getMDIManager().getActiveWindow();
135
//		FLayer[] actives = vista.getModel().getMapContext().getLayers()
136
//							.getActives();
137
//
138
//		try {
139
//			for (int i = 0; i < actives.length; i++) {
140
//				if (actives[i] instanceof AlphanumericData) {
141
//					AlphanumericData co = (AlphanumericData) actives[i];
142
//
143
//					//SelectableDataSource dataSource;
144
//					//dataSource = co.getRecordset();
145
//
146
//					ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
147
//
148
//					ProjectTable projectTable = ext.getProject().getTable(co);
149
//					EditableAdapter ea=null;
150
//					ReadableVectorial rv=((FLyrVect)actives[i]).getSource();
151
//					if (rv instanceof VectorialEditableAdapter){
152
//						ea=(EditableAdapter)((FLyrVect)actives[i]).getSource();
153
//					}else{
154
//						ea=new EditableAdapter();
155
//						SelectableDataSource sds=((FLyrVect)actives[i]).getRecordset();
156
//						ea.setOriginalDataSource(sds);
157
//					}
158
//
159
//					if (projectTable == null) {
160
//						projectTable = ProjectFactory.createTable(PluginServices.getText(this, "Tabla_de_Atributos") + ": " + actives[i].getName(),
161
//								ea);
162
//						projectTable.setProjectDocumentFactory(new ProjectTableFactory());
163
//						projectTable.setAssociatedTable(co);
164
//						ext.getProject().addDocument(projectTable);
165
//					}
166
//					projectTable.setModel(ea);
167
//					Table t = new Table();
168
//					t.setModel(projectTable);
169
////					if (ea.isEditing())
170
////						ea.getCommandRecord().addCommandListener(t);
171
////					t.getModel().setModified(true);
172
////					PluginServices.getMDIManager().addWindow(t);
173
//					auxTable = t;
174
//				}
175
//			}
176
//		} catch (ReadDriverException e) {
177
//            NotificationManager.addError(PluginServices.getText(this,"No_se_pudo_obtener_la_tabla_de_la_capa"), e);
178
//        }
179
//		return auxTable;
180
//	}
181

  
182
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/SymbolTableExtrusion.java
1
/* 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
package com.iver.ai2.gvsig3d.legend;
20

  
21
import java.awt.Component;
22
import java.awt.Dimension;
23
import java.awt.GridLayout;
24
import java.awt.Point;
25
import java.awt.Rectangle;
26
import java.awt.event.ActionListener;
27
import java.awt.event.MouseAdapter;
28
import java.awt.event.MouseEvent;
29
import java.util.ArrayList;
30
import java.util.Hashtable;
31

  
32
import javax.swing.JPanel;
33
import javax.swing.JScrollPane;
34
import javax.swing.event.ChangeEvent;
35
import javax.swing.table.DefaultTableModel;
36
import javax.swing.table.TableCellEditor;
37
import javax.swing.table.TableColumn;
38

  
39
import com.hardcode.gdbms.engine.values.NullValue;
40
import com.iver.andami.PluginServices;
41
import com.iver.andami.ui.mdiFrame.JMenuItem;
42
import com.iver.andami.ui.mdiFrame.JPopUpMenu;
43
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
44
import com.iver.cit.gvsig.fmap.rendering.NullIntervalValue;
45
import com.iver.cit.gvsig.fmap.rendering.NullUniqueValue;
46
import com.iver.cit.gvsig.project.documents.gui.SymbolCellEditor;
47
import com.iver.cit.gvsig.project.documents.gui.TableSymbolCellRenderer;
48
import com.iver.cit.gvsig.project.documents.view.legend.edition.gui.IntervalCellEditor;
49
import com.iver.cit.gvsig.project.documents.view.legend.edition.gui.ValueCellEditor;
50

  
51

  
52
import com.iver.utiles.swing.jtable.JTable;
53
import com.iver.utiles.swing.jtable.TextFieldCellEditor;
54

  
55
public class SymbolTableExtrusion  extends JPanel {
56
	private static final long serialVersionUID = -8694846716328735113L;
57
	private static Hashtable<String,TableCellEditor> cellEditors = new Hashtable<String,TableCellEditor>();
58

  
59
	public static final String VALUES_TYPE = "values";
60
	public static final String INTERVALS_TYPE = "intervals";
61
	private JTable table;
62
	private String type;
63
	private int shapeType;
64
	private OnTableMouseAdapter rightClickActions;
65

  
66
	/**
67
	 * Crea un nuevo FSymbolTable.
68
	 *
69
	 * @param type
70
	 *            tipo de valor si es intervalo: "intervals" y si es por
71
	 *            valores: "values".
72
	 */
73
	public SymbolTableExtrusion(Component ownerComponent, String type, int shapeType) {
74
		super(new GridLayout(1, 0));
75
		this.type = type;
76
		this.shapeType = shapeType;
77

  
78
		rightClickActions = new OnTableMouseAdapter();
79
		table = new JTable();
80
		table.setModel(new MyTableModel());
81
		table.setPreferredScrollableViewportSize(new Dimension(480, 110));
82

  
83
		initializeCellEditors();
84

  
85
		// Create the scroll pane and add the table to it.
86
		JScrollPane scrollPane = new JScrollPane(table);
87

  
88
		// Set up column sizes.
89
		// initColumnSizes(table);
90
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));
91

  
92
		if(cellEditors.get(type) == null)
93
			throw new Error("Symbol table type not set!");
94

  
95
		setUpValueColumn(table, table.getColumnModel().getColumn(0),cellEditors.get(this.type));
96
		setUpLabelColumn(table, table.getColumnModel().getColumn(1));
97

  
98
		// Add the scroll pane to this panel.
99
		add(scrollPane);
100
		table.setRowSelectionAllowed(true);
101
		table.addMouseListener(rightClickActions);
102
	}
103
	/**
104
	 * Inicializa los valores de los CellEditors que la SymbolTable poseer? por defecto
105
	 */
106
	private void initializeCellEditors() {
107
		this.cellEditors.put(this.INTERVALS_TYPE,new IntervalCellEditor());
108
		this.cellEditors.put(this.VALUES_TYPE, new ValueCellEditor());
109
	}
110
	/**
111
	 * A?ade un nuevo CellEditor a la lista de disponibles
112
	 *
113
	 * @param key String con el nombre identificativo del CellEditor
114
	 * @param cellEditor CellEditor que va a ser a?adido
115
	 */
116
	public static void addCellEditor(String key,TableCellEditor cellEditor ) {
117
		cellEditors.put(key, cellEditor);
118
	}
119
	/**
120
	 * Obtiene el valor de los elementos de una fila seleccionada
121
	 *
122
	 * @return Object[] Array con los objetos de cada una de las columnas de la fila seleccionada
123
	 */
124
	public Object[] getSelectedRowElements() {
125
		Object[] values = new Object[2];
126

  
127
		MyTableModel m = (MyTableModel) table.getModel();
128
		int[] selectedRows = table.getSelectedRows();
129

  
130
		if(selectedRows.length != 1)
131
			return null;
132

  
133
		for (int i = 0; i < 2; i++) {
134
			values[i] = m.getValueAt(selectedRows[0], i);
135
		}
136

  
137
		return values;
138
	}
139
	/**
140
	 * A?ade una fila al modelo.
141
	 *
142
	 * @param vector
143
	 *            Fila en forma de vector de Object para a?adir al modelo.
144
	 */
145
	public void addRow(Object[] vector) {
146
		MyTableModel m = (MyTableModel) table.getModel();
147
		m.addRow(vector);
148

  
149
	}
150

  
151
	/**
152
	 * Elimina la fila que tiene como clave el objeto que se pasa como
153
	 * par?metro.
154
	 *
155
	 * @param obj
156
	 *            clave del objeto a eliminar.
157
	 */
158
	public void removeRow(Object obj) {
159
		MyTableModel m = (MyTableModel) table.getModel();
160

  
161
		for (int i = 0; i < m.getRowCount(); i++) {
162
			if (m.getValueAt(i, 0) instanceof NullUniqueValue
163
					|| m.getValueAt(i, 0) instanceof NullIntervalValue) {
164
				m.removeRow(i);
165
			}
166
		}
167
	}
168

  
169
	/**
170
	 * Elimina las filas que est?n seleccionadas.
171
	 */
172
	public void removeSelectedRows() {
173
		if (table.getCellEditor() != null) {
174
			table.getCellEditor().cancelCellEditing();
175
		}
176

  
177
		MyTableModel m = (MyTableModel) table.getModel();
178
		int[] selectedRows = table.getSelectedRows();
179

  
180
		for (int i = selectedRows.length - 1; i >= 0; i--) {
181
			m.removeRow(selectedRows[i]);
182
		}
183
	}
184

  
185
	/**
186
	 * Rellena la tabla con los s?mbolos valores y descripciones que se pasan
187
	 * como par?metro.
188
	 *
189
	 * @param symbols
190
	 *            Array de s?mbolos
191
	 * @param values
192
	 *            Array de valores.
193
	 * @param descriptions
194
	 *            Array de descripciones.
195
	 */
196
	public void fillTableFromSymbolList(ISymbol[] symbols, Object[] values,
197
			Object[] descriptions) {
198
		ISymbol theSymbol;
199

  
200
		for (int i = 0; i < symbols.length; i++) {
201
			theSymbol = symbols[i];
202
			if(!(values[i] instanceof NullIntervalValue) && !(values[i] instanceof NullUniqueValue))
203
				addTableRecord(theSymbol, values[i], descriptions[i]);
204
		}
205
	}
206

  
207
	/**
208
	 * A?ade una fila con los objetos que se pasan como par?metros.
209
	 *
210
	 * @param symbol
211
	 *            s?mbolo de la fila.
212
	 * @param value
213
	 *            Valor de la fila.
214
	 * @param description
215
	 *            Descripci?n.
216
	 */
217
	public void addTableRecord(ISymbol symbol, Object value, Object description) {
218
		Object[] theRow = new Object[2];
219
		theRow[0] = value;
220
		theRow[1] = description;
221
		addRow(theRow);
222
	}
223

  
224
	/**
225
	 * Devuelve el valor a partie del n?mero de fila y columna.
226
	 *
227
	 * @param row
228
	 *            n?mero de fila.
229
	 * @param col
230
	 *            n?mero de columna.
231
	 *
232
	 * @return Objeto.
233
	 */
234
	public Object getFieldValue(int row, int col) {
235
		MyTableModel m = (MyTableModel) table.getModel();
236

  
237
		return m.getValueAt(row, col);
238
	}
239

  
240
	/**
241
	 * Devuelve el n?mero total de filas que contiene el modelo.
242
	 *
243
	 * @return N?mero de filas.
244
	 */
245
	public int getRowCount() {
246
		MyTableModel m = (MyTableModel) table.getModel();
247

  
248
		return m.getRowCount();
249
	}
250

  
251
	/**
252
	 * Elimina todas las filas del modelo.
253
	 */
254
	public void removeAllItems() {
255
		table.setModel(new MyTableModel());
256
		setUpValueColumn(table, table.getColumnModel().getColumn(0),cellEditors.get(this.type));
257
		setUpLabelColumn(table, table.getColumnModel().getColumn(1));
258
	}
259

  
260
	/**
261
	 * Inicializa el cell editor de tipo descripci?n de la columna que se pasa
262
	 * como par?metro.
263
	 *
264
	 * @param table2
265
	 *            Tabla.
266
	 * @param column
267
	 *            Columna.
268
	 */
269
	public void setUpLabelColumn(JTable table2, TableColumn column) {
270
		TextFieldCellEditor labeleditor = new TextFieldCellEditor();
271
		column.setCellEditor(labeleditor);
272
	}
273

  
274
	/**
275
	 * Inicializa el cell editor de tipo valor de la columna que se pasa como
276
	 * par?metro.
277
	 *
278
	 * @param table2
279
	 *            Tabla.
280
	 * @param column
281
	 *            Columna.
282
	 * @param tableCellEditor
283
	 */
284
	public void setUpValueColumn(JTable table2,TableColumn column, TableCellEditor tableCellEditor) {
285
		column.setCellEditor(tableCellEditor);
286
	}
287
	/**
288
	 * Inicializa el cell editor de tipo s?mbolo de la columna que se pasa como
289
	 * par?metro.
290
	 *
291
	 * @param table2
292
	 *            Tabla.
293
	 * @param column
294
	 *            Columna.
295
	 */
296
	public void setUpSymbolColumn(JTable table2, TableColumn column) {
297
		// Set up the editor
298
		column.setMaxWidth(100);
299
		column.setWidth(60);
300
		column.setPreferredWidth(60);
301
		column.setMinWidth(50);
302

  
303
		// FSymbolCellEditor symboleditor = new FSymbolCellEditor();
304
		SymbolCellEditor symboleditor = new SymbolCellEditor(shapeType);
305
		column.setCellEditor(symboleditor);
306

  
307
		TableSymbolCellRenderer renderer = new TableSymbolCellRenderer(true);
308
		column.setCellRenderer(renderer);
309
	}
310

  
311
	/**
312
	 * Modelo que propio que se aplica a la tabla.
313
	 *
314
	 * @author Vicente Caballero Navarro
315
	 */
316
	class MyTableModel extends DefaultTableModel {
317
		private static final long serialVersionUID = 1L;
318

  
319
		// AbstractTableModel {
320
		private String[] columnNames = {
321
				PluginServices.getText(this, "Valor_inicial"),
322
				PluginServices.getText(this, "Valor_extrusionado") };
323

  
324
		/**
325
		 * Devuelve el n?mero de columnas.
326
		 *
327
		 * @return N?mero de columnas.
328
		 */
329
		public int getColumnCount() {
330
			return columnNames.length;
331
		}
332

  
333
		/**
334
		 * Devuelve el String del valor de la columna.
335
		 *
336
		 * @param col
337
		 *            N?mero de columna.
338
		 *
339
		 * @return Nombre de la columna.
340
		 */
341
		public String getColumnName(int col) {
342
			return columnNames[col];
343
		}
344

  
345
		/**
346
		 * JTable uses this method to determine the default renderer/ editor for
347
		 * each cell. If we didn't implement this method, then the last column
348
		 * would contain text ("true"/"false"), rather than a check box.
349
		 */
350
		public Class getColumnClass(int c) {
351
			if (getValueAt(0, c) == null) {
352
				return NullValue.class;
353
			}
354
			return getValueAt(0, c).getClass();
355
		}
356

  
357
		/*
358
		 * Don't need to implement this method unless your table's editable.
359
		 */
360
		public boolean isCellEditable(int row, int col) {
361
			// Note that the data/cell address is constant,
362
			// no matter where the cell appears onscreen.
363
			// if (col > 0) {
364
			return true;
365
		}
366

  
367
		@Override
368
		public Object getValueAt(int row, int column) {
369
//			if(column == 1)
370
//				return ((ISymbol)getValueAt(row,0)).getDescription();
371

  
372
			return super.getValueAt(row, column);
373
		}
374

  
375
		@Override
376
		public void setValueAt(Object aValue, int row, int column) {
377

  
378
//			if(column == 1){
379
//				ISymbol symbol = (ISymbol) getValueAt(row,0);
380
//				symbol.setDescription((String) aValue);
381
//				setValueAt(symbol,row,0);
382
//			}
383

  
384
			super.setValueAt(aValue, row, column);
385
		}
386

  
387
	}
388

  
389
	private class OnTableMouseAdapter extends MouseAdapter {
390

  
391
		private JPopUpMenu menu = new JPopUpMenu();
392

  
393
		// group option
394
		private JMenuItem groupItem = new JMenuItem(
395
				PluginServices.getText(this, "group"));
396
		private ActionListener groupAction = new ActionListener() {
397
			public void actionPerformed(java.awt.event.ActionEvent e) {
398
				hidePopUp();
399
				int[] selectedRows = table.getSelectedRows();
400
				if (selectedRows.length > 1) {
401
					DefaultTableModel model = (DefaultTableModel) table
402
							.getModel();
403
					int theRow = selectedRows[0];
404
//					ISymbol symboToBeApplied = (ISymbol) model.getValueAt(
405
//							theRow, 0);
406
					String labelToBeApplied = (String) model.getValueAt(
407
							theRow, 1);
408
					ArrayList<Object> valuesToBeApplied = new ArrayList<Object>(
409
							selectedRows.length);
410
					for (int i = 0; i < selectedRows.length; i++) {
411
						valuesToBeApplied.add(model.getValueAt(selectedRows[i],
412
								0));
413
					}
414

  
415
					for (int i = selectedRows.length - 1; i > 0; i--) {
416
						model.removeRow(selectedRows[i]);
417
					}
418

  
419
//					model.setValueAt(symboToBeApplied, theRow, 0);
420
					model.setValueAt(labelToBeApplied, theRow, 1);
421
					table.clearSelection();
422
					table.doLayout();
423
				}
424
			}
425
		};
426

  
427
		// combine option
428
		private JMenuItem combineItem = new JMenuItem(
429
				PluginServices.getText(this, "combine"));
430
		private ActionListener combineAction = new ActionListener() {
431
			public void actionPerformed(java.awt.event.ActionEvent e) {
432
				hidePopUp();
433
				int[] selectedRows = table.getSelectedRows();
434
				if (selectedRows.length > 1) {
435
					DefaultTableModel model = (DefaultTableModel) table
436
							.getModel();
437
					int theRow = selectedRows[0];
438
//					ISymbol symboToBeApplied = (ISymbol) model.getValueAt(
439
//							theRow, 0);
440
					String labelToBeApplied = (String) model.getValueAt(
441
							theRow, 1);
442
					ArrayList<Object> valuesToBeApplied = new ArrayList<Object>(
443
							selectedRows.length);
444
					for (int i = 0; i < selectedRows.length; i++) {
445
						valuesToBeApplied.add(model.getValueAt(selectedRows[i],
446
								0));
447
					}
448

  
449
					for (int i = selectedRows.length - 1; i > 0; i--) {
450
						model.removeRow(selectedRows[i]);
451
					}
452

  
453
//					model.setValueAt(symboToBeApplied, theRow, 0);
454
					model.setValueAt(labelToBeApplied, theRow, 1);
455
					table.clearSelection();
456
					table.doLayout();
457
				}
458
			}
459
		};
460

  
461
		private boolean menuEmpty = false;
462

  
463

  
464
		{
465
			groupItem.addActionListener(groupAction);
466
			if (VALUES_TYPE.equals(type)) {
467
				menu.add(groupItem);
468
			} else if (INTERVALS_TYPE.equals(type)) {
469
				menu.add(combineItem);
470
			} else {
471
				menuEmpty = true;
472
			}
473

  
474
		}
475

  
476
		@Override
477
		public void mouseExited(MouseEvent e) {
478
			// if we click outside the popup menu
479
			if (menu.isVisible()) {
480
				Rectangle tableBounds = table.getBounds();
481
				tableBounds.setLocation(table.getLocationOnScreen());
482
				if (!tableBounds.contains(getClickLocation(e))) {
483
					hidePopUp();
484
				}
485
			}
486

  
487
		}
488

  
489
		@Override
490
		public void mouseClicked(MouseEvent e) {
491
			super.mouseClicked(e);
492

  
493
			// if we click outside the popup menu
494
			if (menu.isVisible()
495
					&& !menu.getBounds().contains(getClickLocation(e))) {
496
				hidePopUp();
497
			}
498

  
499
			if (e.getButton() == MouseEvent.BUTTON3) {
500
				e.consume();
501
				int[] selectedRows = table.getSelectedRows();
502
				if (selectedRows.length > 0) {
503
					Point realClickLocation = getClickLocation(e);
504
					menu.setLocation(realClickLocation);
505
					showPopUp();
506
				}
507
			}
508

  
509
		}
510

  
511
		private void showPopUp() {
512
			if (!menuEmpty) {
513
				table.setEnabled(false);
514
				table.editingCanceled(new ChangeEvent(table));
515
				menu.setVisible(true);
516
			}
517
		}
518

  
519
		private void hidePopUp() {
520
			if (!menuEmpty ) {
521
				menu.setVisible(false);
522
				table.setEnabled(true);
523
			}
524
		}
525

  
526
		private Point getClickLocation(MouseEvent e) {
527
			Point tableLocation = table.getLocationOnScreen();
528
			Point relativeClickPoint = e.getPoint();
529
			Point realClickLocation = new Point(tableLocation.x
530
					+ relativeClickPoint.x, tableLocation.y
531
					+ relativeClickPoint.y);
532
			return realClickLocation;
533
		}
534

  
535
	}
536

  
537
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/ExtrusionLegend.java
1
package com.iver.ai2.gvsig3d.legend;
2

  
3
import java.awt.Color;
4

  
5
import com.hardcode.gdbms.engine.values.Value;
6
import com.iver.ai2.gvsig3d.legend.symbols.BaseExtrusionSymbol;
7
import com.iver.cit.gvsig.fmap.core.IFeature;
8
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol;
9
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol;
10
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol;
11
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
12
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol;
13
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol;
14
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol;
15
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
16
import com.iver.utiles.XMLEntity;
17

  
18
public class ExtrusionLegend extends VectorialUniqueValueLegend {
19

  
20
	private BaseExtrusionSymbol defaultSimbolExtrusion;
21
	private double extrusionFactor;
22

  
23

  
24
	public ExtrusionLegend() {
25
	}
26
	public ExtrusionLegend(int shapeType) {
27
		super(shapeType);
28
	}
29
	public ISymbol getSymbolByFeature(IFeature feat) {
30
		return super.getSymbolByFeature(feat);
31
	}
32

  
33
	public ISymbol getSymbolByValue(Value key) {
34
		ISymbol theSymbol = super.getSymbolByValue(key);
35

  
36
		if (theSymbol== null)
37
			return null;
38
		double extrusion = Double.parseDouble(theSymbol.getDescription());
39
		
40
		
41

  
42
		defaultSimbolExtrusion = new BaseExtrusionSymbol(extrusion);
43
		if (theSymbol.getClass().equals(SimpleFillSymbol.class)) {// Nuevo s?mbolo pol?gono
44
			Color color = ((IFillSymbol)theSymbol).getFillColor();
45
			defaultSimbolExtrusion.setFillColor(color);
46
		}
47
		else if (theSymbol.getClass().equals(SimpleLineSymbol.class)) {// Nuevo s?mbolo l?nea
48
			Color color = ((ILineSymbol)theSymbol).getColor();
49
			defaultSimbolExtrusion.setFillColor(color);
50
		}
51
		else if (theSymbol.getClass().equals(SimpleMarkerSymbol.class)) {// Nuevo s?mbolo punto
52
			Color color = ((IMarkerSymbol)theSymbol).getColor();
53
			defaultSimbolExtrusion.setFillColor(color);
54
		}
55

  
56
//		defaultSimbolExtrusion.setExtrusion(factorExtrusion);
57

  
58
		return defaultSimbolExtrusion;
59
	}
60
	
61
	public String getClassName() {
62
		return getClass().getName();
63
	}
64
	
65
	public double getExtrusionFactor() {
66
		return extrusionFactor;
67
	}
68
	
69
	public void setExtrusionFactor(double extrusionFactor) {
70
		this.extrusionFactor = extrusionFactor;
71
	}
72
	
73

  
74
	public XMLEntity getXMLEntity() {
75
		XMLEntity xml = super.getXMLEntity();
76
		xml.putProperty("extrusionFactor", this.extrusionFactor);
77
		return xml;
78

  
79
	}
80

  
81
	public void setXMLEntity(XMLEntity xml) {
82
		// TODO: It is necessary to insert here all the properties to load with the extrusion legend.
83
		super.setXMLEntity(xml);		
84
		if (xml.contains("extrusionFactor"))
85
			extrusionFactor = xml.getDoubleProperty("extrusionFactor");	
86
	}
87

  
88
}
tags/3D_Animation_v1_0alpha_Build_5/libraries/lib3DMap-share/src/main/java/com/iver/ai2/gvsig3d/legend/ExtrusionLegendPanel.java
1
package com.iver.ai2.gvsig3d.legend;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Component;
5
import java.awt.FlowLayout;
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8
import java.awt.event.ItemEvent;
9
import java.awt.event.ItemListener;
10
import java.awt.event.KeyEvent;
11
import java.awt.event.KeyListener;
12
import java.sql.Types;
13
import java.util.ArrayList;
14
import java.util.Random;
15

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff