Revision 15463

View differences:

import/ext3D/branches/ext3D_v1.1/extAnimationGUI/src/com/iver/ai2/animationgui/gui/toc/AnimationDateModePanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
package com.iver.ai2.animationgui.gui.toc;
42

  
43
import java.awt.Choice;
44
import java.awt.Dimension;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
47
import java.awt.Insets;
48
import java.awt.event.ActionListener;
49
import java.awt.event.ItemEvent;
50
import java.awt.event.ItemListener;
51
import java.awt.event.KeyListener;
52
import java.util.Dictionary;
53
import java.util.Hashtable;
54

  
55
import javax.swing.BorderFactory;
56
import javax.swing.JLabel;
57
import javax.swing.JPanel;
58
import javax.swing.JSlider;
59
import javax.swing.event.ChangeEvent;
60
import javax.swing.event.ChangeListener;
61

  
62
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
63
import org.gvsig.gui.beans.swing.JButton;
64

  
65
import com.iver.ai2.gvsig3d.ProjectView3D;
66
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
67
import com.iver.andami.PluginServices;
68
import com.iver.andami.ui.mdiManager.SingletonWindow;
69
import com.iver.andami.ui.mdiManager.WindowInfo;
70
import com.iver.cit.gvsig.animation.AnimationPlayer;
71
import com.iver.cit.gvsig.animation.IAnimationType;
72
import com.iver.cit.gvsig.animation.date.AnimationDate3D;
73
import com.iver.cit.gvsig.animation.dateFilter.DateFilter;
74
import com.iver.cit.gvsig.fmap.MapContext;
75
import com.iver.cit.gvsig.fmap.layers.FLayer;
76
import com.iver.cit.gvsig.project.documents.view.IProjectView;
77

  
78
/**
79
 * Dialogo donde se muestran las propiedades de una vista
80
 * 
81
 * @author Fernando Gonz?lez Cort?s
82
 */
83
public class AnimationDateModePanel extends GridBagLayoutPanel implements
84
		SingletonWindow, ItemListener{
85

  
86

  
87
	private int width = 250;
88

  
89
	private int height = 100;
90

  
91
	private GridBagLayoutPanel okCancelPanel;
92

  
93
	private JButton okButton;
94
	
95
	private Choice choice = null;
96

  
97
	private int animationMode;
98

  
99
	private int operation;
100

  
101
	private AnimationDate3D animationDay;
102

  
103
	/**
104
	 * This is the default constructor
105
	 * @param animationType 
106
	 * 
107
	 * @param f
108
	 *            Frame padre del dialogo
109
	 * @param v
110
	 *            Vista que se representa
111
	 */
112
	public AnimationDateModePanel(IAnimationType animationType) {
113

  
114
		animationDay = (AnimationDate3D)animationType;
115
		initialize();
116

  
117
	}
118

  
119
	/**
120
	 * This method initializes this
121
	 */
122
	private void initialize() {
123
		
124
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
125
		gridBagConstraints1.fill = GridBagConstraints.VERTICAL;
126
		gridBagConstraints1.gridy = 2;
127
		gridBagConstraints1.weightx = 1.0;
128
		gridBagConstraints1.gridx = 1;
129
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
130
		gridBagConstraints.gridx = 1;
131
		gridBagConstraints.gridheight = 2;
132
		gridBagConstraints.gridwidth = 2;
133
		gridBagConstraints.insets = new Insets(15, 0, 0, 0);
134
		gridBagConstraints.gridy = 3;
135
		
136
		this.add(getChoiceValue(), gridBagConstraints1);
137
		this.add(getOkCancelPanel(),gridBagConstraints);
138
		
139
		// Inicialize component
140
		setName(PluginServices.getText(this, "Transparency"));
141
		this.setPreferredSize(new Dimension(width, height));
142
		this.setSize(new Dimension(width, height));
143

  
144
	}
145

  
146
	
147
	private Choice getChoiceValue() {
148
		// TODO Auto-generated method stub
149
		if (choice == null) {
150
			choice = new Choice();
151
			// choice.addItem( textopru );
152
			choice.addItem("Intervalo");
153
			choice.addItem("Incremental");
154
			choice.addItem("Decremental");
155
			// choice.addItem( "modo3" );
156
			// choice.addItem( "modo4" );
157
			choice.addItemListener(this);
158
		}
159
		return choice;
160
	}
161

  
162

  
163
	private GridBagLayoutPanel getOkCancelPanel() {
164
		if (okCancelPanel == null) {
165
			ActionListener okAction, cancelAction, applyAction;
166
			okAction = new java.awt.event.ActionListener() {
167
				public void actionPerformed(java.awt.event.ActionEvent e) {
168
					
169
					//TODO settin animation mode
170
					
171
					animationDay.setFilterMode(animationMode);
172
					PluginServices.getMDIManager().closeWindow(
173
							AnimationDateModePanel.this);
174
				}
175
			};
176
			okCancelPanel = new GridBagLayoutPanel();
177
			okCancelPanel.setAlignmentX(GridBagLayoutPanel.RIGHT_ALIGNMENT);
178
			okButton = new JButton();
179
			okButton.setText("Aceptar");
180
			okButton.addActionListener(okAction);
181

  
182
			okCancelPanel.addComponent(okButton);
183
		}
184
		return okCancelPanel;
185
	}
186

  
187

  
188
	public WindowInfo getWindowInfo() {
189
		WindowInfo m_viewinfo = new WindowInfo();
190
		m_viewinfo.setTitle(PluginServices.getText(this, "Transparency"));
191
		m_viewinfo.setHeight(height);
192
		m_viewinfo.setWidth(width);
193
		return m_viewinfo;
194
	}
195

  
196
	public Object getWindowModel() {
197
		// TODO Auto-generated method stub
198
		return null;
199
	}
200

  
201
	public void itemStateChanged(ItemEvent event) {
202
		// TODO Auto-generated method stub
203
		Object obj = event.getSource();
204
		if (obj == choice) {
205
			operation = choice.getSelectedIndex(); // get select item.
206
			getMensaje(operation);
207
		} 
208
		
209
	}
210
	private void getMensaje(int option) {
211
		// TODO Auto-generated method stub
212
		String mode = choice.getItem(option);
213
		if (mode.equals("Intervalo")) {
214
			animationMode = DateFilter.BOTH;
215
		} else if (mode.equals("Incremental")) {
216
			animationMode = DateFilter.BEFORE_BEGIN;
217
		} else if (mode.equals("Decremental")) {
218
			animationMode = DateFilter.AFTER_END;
219
		}
220
		System.out.println("opcion: " + mode);
221
	}
222

  
223

  
224
}
import/ext3D/branches/ext3D_v1.1/extAnimationGUI/src/com/iver/ai2/animationgui/gui/toc/TocAnimationDate.java
1
package com.iver.ai2.animationgui.gui.toc;
2

  
3
import java.sql.Date;
4

  
5
import com.iver.ai2.animationgui.gui.AnimationContol3D;
6
import com.iver.ai2.gvsig3d.gui.VectorLayerMenu;
7
import com.iver.ai2.gvsig3d.gui.View3D;
8
import com.iver.ai2.gvsig3d.map3d.layers.Layer3DProps;
9
import com.iver.andami.PluginServices;
10
import com.iver.andami.plugins.IExtension;
11
import com.iver.andami.ui.mdiManager.IWindow;
12
import com.iver.cit.gvsig.ProjectExtension;
13
import com.iver.cit.gvsig.animation.AnimationContainer;
14
import com.iver.cit.gvsig.animation.AnimationPlayer;
15
import com.iver.cit.gvsig.animation.date.AnimationDate3D;
16
import com.iver.cit.gvsig.animation.interval.AnimationDatedInterval;
17
import com.iver.cit.gvsig.animation.traks.AnimationDatedTrack;
18
import com.iver.cit.gvsig.animation.traks.IAnimationTrack;
19
import com.iver.cit.gvsig.fmap.MapContext;
20
import com.iver.cit.gvsig.fmap.MapControl;
21
import com.iver.cit.gvsig.fmap.layers.FLayer;
22
import com.iver.cit.gvsig.project.Project;
23
import com.iver.cit.gvsig.project.documents.view.IProjectView;
24
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
25
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
26
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
27
import com.iver.utiles.extensionPoints.ExtensionPoint;
28
import com.iver.utiles.extensionPoints.ExtensionPoints;
29
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
30

  
31
public class TocAnimationDate extends AbstractTocContextMenuAction {
32

  
33
	private AnimationDatedTrack adt;
34
	
35
	FLayer layer;
36

  
37
	public String getGroup() {
38
		return "group6"; // FIXME
39
	}
40

  
41
	public int getGroupOrder() {
42
		return 60;
43
	}
44

  
45
	public int getOrder() {
46
		return 10;
47
	}
48

  
49
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
50
		// return selectedItems.length == 1;
51

  
52
		// return true;
53

  
54
		boolean enable = false;
55

  
56
		if (selectedItems.length > 0)
57
			enable = true;
58

  
59
		return enable;
60

  
61
	}
62

  
63
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
64
		// return true;
65
		com.iver.andami.ui.mdiManager.IWindow f = PluginServices
66
				.getMDIManager().getActiveWindow();
67

  
68
		if (f == null) {
69
			return false;
70
		}
71

  
72
		if (!isTocItemBranch(item))
73
			return false;
74

  
75
		BaseView vista = (BaseView) f;
76
		
77
		IProjectView model = vista.getModel();
78
		MapContext mapa = model.getMapContext();
79
	
80
		return mapa.getLayers().getLayersCount() > 0;
81
	}
82

  
83
	public void execute(ITocItem item, FLayer[] selectedItems) {
84
		System.out
85
				.println("MENU CONTEXTUAL DE GENERACION DE ANIMACIONES DE FECHAS");
86

  
87
//		// Getting view3
88
//		com.iver.andami.ui.mdiManager.IWindow view = PluginServices
89
//				.getMDIManager().getActiveWindow();
90
//		BaseView vista3D =  (BaseView) view;
91
//		 MapControl model = (MapControl)vista3D.getModel();
92
//		model.setEnabled(true);
93
		
94
		layer = selectedItems[0];
95
		
96
		// Generate animation using filters
97
		generateAniamtionDate();
98
		
99
		// introducir layer
100
		
101
//		this.adt.setAnimatedObject(layer);
102
		// Show the animation control player
103
//		AnimationDateModePanel = new AnimationDateModePanel();
104
//		AnimationDateModePanel.setModal(true);
105
//		AnimationDateModePanel.pack();
106
//		AnimationDateModePanel.setVisible(true);
107
		
108
		
109
		AnimationDateModePanel fp = new AnimationDateModePanel(adt.getAnimationType());
110
		PluginServices.getMDIManager().addWindow((IWindow) fp);
111
		
112
		
113
	}
114

  
115
	public String getText() {
116
		// Name that appears in toc menu
117
		return "Animacion de fecha";
118
	}
119

  
120
	private Project getProject() {
121
		IExtension extension = PluginServices
122
				.getExtension(com.iver.cit.gvsig.ProjectExtension.class);
123
		ProjectExtension pe = (ProjectExtension) extension;
124
		return pe.getProject();
125
	}
126

  
127
	private void generateAniamtionDate() {
128
		// TODO Auto-generated method stub
129
		// traerse el contenedor
130
		Project project = this.getProject();
131
		AnimationContainer ac = project.getAnimationContainer();
132
		// desactivar los track existentes
133

  
134
		// crear el track
135
		adt = getAnimationDateTrack("Date-track", ac);
136
		// generar un intervalo por cada fecha
137

  
138
		// DEBUGGGGG!!!!
139
		System.out.println(ac);
140
	}
141

  
142
	private AnimationDatedTrack getAnimationDateTrack(String name,
143
			AnimationContainer ac) {
144
		AnimationDatedTrack at = null;
145
		IAnimationTrack aa = ac.findTrack(name);
146
		if (aa == null) {
147

  
148
			ExtensionPoints extensionPoints = ExtensionPointsSingleton
149
					.getInstance();
150
			ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints
151
					.get("Animation"));
152

  
153
			// traerse el tipo de animacion
154
			AnimationDate3D animationDate3D = null;
155
			try {
156
				animationDate3D = (AnimationDate3D) extPoint
157
						.create("AnimationDate3D");
158
			} catch (InstantiationException e) {
159
				// TODO Auto-generated catch block
160
				e.printStackTrace();
161
			} catch (IllegalAccessException e) {
162
				// TODO Auto-generated catch block
163
				e.printStackTrace();
164
			}
165
			animationDate3D.setAnimatedObject(layer);
166
			at = (AnimationDatedTrack) ac.CreateDatedTrack(animationDate3D);
167
			at.setName(name);
168
			at.setEnabale(true);
169
			
170
			//crear el intervalo
171
			AnimationDatedInterval adi = (AnimationDatedInterval) at.createInterval();
172
			adi.setBeginDateInterval(Date.valueOf("2000-01-01"));
173
			adi.setEndDateInterval(Date.valueOf("2000-01-04"));
174
			
175
			
176
//			at.setAnimatedObject(layer);
177
			// at.setAnimationType(animationDate3D);
178
		}
179

  
180
		return at;
181

  
182
	}
183

  
184
}

Also available in: Unified diff