svn-gvsig-desktop / import / ext3D / branches / ext3D_v1.1 / extensions / extAnimationGUI / src / com / iver / ai2 / animationgui / gui / toc / TocAnimationDate.java @ 15502
History | View | Annotate | Download (5.04 KB)
1 |
package com.iver.ai2.animationgui.gui.toc; |
---|---|
2 |
|
3 |
import java.sql.Date; |
4 |
|
5 |
import com.iver.andami.PluginServices; |
6 |
import com.iver.andami.plugins.IExtension; |
7 |
import com.iver.andami.ui.mdiManager.IWindow; |
8 |
import com.iver.cit.gvsig.ProjectExtension; |
9 |
import com.iver.cit.gvsig.animation.AnimationContainer; |
10 |
import com.iver.cit.gvsig.animation.date.AnimationDate3D; |
11 |
import com.iver.cit.gvsig.animation.interval.AnimationDatedInterval; |
12 |
import com.iver.cit.gvsig.animation.traks.AnimationDatedTrack; |
13 |
import com.iver.cit.gvsig.animation.traks.IAnimationTrack; |
14 |
import com.iver.cit.gvsig.fmap.MapContext; |
15 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
16 |
import com.iver.cit.gvsig.project.Project; |
17 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
18 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
19 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
20 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
21 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
22 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
23 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
24 |
|
25 |
public class TocAnimationDate extends AbstractTocContextMenuAction { |
26 |
|
27 |
private AnimationDatedTrack adt;
|
28 |
|
29 |
FLayer layer; |
30 |
|
31 |
public String getGroup() { |
32 |
return "group6"; // FIXME |
33 |
} |
34 |
|
35 |
public int getGroupOrder() { |
36 |
return 60; |
37 |
} |
38 |
|
39 |
public int getOrder() { |
40 |
return 10; |
41 |
} |
42 |
|
43 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
44 |
// return selectedItems.length == 1;
|
45 |
|
46 |
// return true;
|
47 |
|
48 |
boolean enable = false; |
49 |
|
50 |
if (selectedItems.length > 0) |
51 |
enable = true;
|
52 |
|
53 |
return enable;
|
54 |
|
55 |
} |
56 |
|
57 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
58 |
// return true;
|
59 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices |
60 |
.getMDIManager().getActiveWindow(); |
61 |
|
62 |
if (f == null) { |
63 |
return false; |
64 |
} |
65 |
|
66 |
if (!isTocItemBranch(item))
|
67 |
return false; |
68 |
|
69 |
BaseView vista = (BaseView) f; |
70 |
|
71 |
IProjectView model = vista.getModel(); |
72 |
MapContext mapa = model.getMapContext(); |
73 |
|
74 |
return mapa.getLayers().getLayersCount() > 0; |
75 |
} |
76 |
|
77 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
78 |
System.out
|
79 |
.println("MENU CONTEXTUAL DE GENERACION DE ANIMACIONES DE FECHAS");
|
80 |
|
81 |
// // Getting view3
|
82 |
// com.iver.andami.ui.mdiManager.IWindow view = PluginServices
|
83 |
// .getMDIManager().getActiveWindow();
|
84 |
// BaseView vista3D = (BaseView) view;
|
85 |
// MapControl model = (MapControl)vista3D.getModel();
|
86 |
// model.setEnabled(true);
|
87 |
|
88 |
layer = selectedItems[0];
|
89 |
|
90 |
// Generate animation using filters
|
91 |
generateAniamtionDate(); |
92 |
|
93 |
// introducir layer
|
94 |
|
95 |
// this.adt.setAnimatedObject(layer);
|
96 |
// Show the animation control player
|
97 |
// AnimationDateModePanel = new AnimationDateModePanel();
|
98 |
// AnimationDateModePanel.setModal(true);
|
99 |
// AnimationDateModePanel.pack();
|
100 |
// AnimationDateModePanel.setVisible(true);
|
101 |
|
102 |
|
103 |
AnimationDateModePanel fp = new AnimationDateModePanel(adt.getAnimationType());
|
104 |
PluginServices.getMDIManager().addWindow((IWindow) fp); |
105 |
|
106 |
|
107 |
} |
108 |
|
109 |
public String getText() { |
110 |
// Name that appears in toc menu
|
111 |
return "Animacion de fecha"; |
112 |
} |
113 |
|
114 |
private Project getProject() {
|
115 |
IExtension extension = PluginServices |
116 |
.getExtension(com.iver.cit.gvsig.ProjectExtension.class); |
117 |
ProjectExtension pe = (ProjectExtension) extension; |
118 |
return pe.getProject();
|
119 |
} |
120 |
|
121 |
private void generateAniamtionDate() { |
122 |
// TODO Auto-generated method stub
|
123 |
// traerse el contenedor
|
124 |
Project project = this.getProject();
|
125 |
AnimationContainer ac = (AnimationContainer) project.getAnimationContainer(); |
126 |
// desactivar los track existentes
|
127 |
|
128 |
// crear el track
|
129 |
adt = getAnimationDateTrack("Date-track", ac);
|
130 |
// generar un intervalo por cada fecha
|
131 |
|
132 |
// DEBUGGGGG!!!!
|
133 |
System.out.println(ac);
|
134 |
} |
135 |
|
136 |
private AnimationDatedTrack getAnimationDateTrack(String name, |
137 |
AnimationContainer ac) { |
138 |
AnimationDatedTrack at = null;
|
139 |
IAnimationTrack aa = ac.findTrack(name); |
140 |
if (aa == null) { |
141 |
|
142 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
143 |
.getInstance(); |
144 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints |
145 |
.get("Animation"));
|
146 |
|
147 |
// traerse el tipo de animacion
|
148 |
AnimationDate3D animationDate3D = null;
|
149 |
try {
|
150 |
animationDate3D = (AnimationDate3D) extPoint |
151 |
.create("AnimationDate3D");
|
152 |
} catch (InstantiationException e) { |
153 |
// TODO Auto-generated catch block
|
154 |
e.printStackTrace(); |
155 |
} catch (IllegalAccessException e) { |
156 |
// TODO Auto-generated catch block
|
157 |
e.printStackTrace(); |
158 |
} |
159 |
animationDate3D.setAnimatedObject(layer); |
160 |
at = (AnimationDatedTrack) ac.CreateDatedTrack(animationDate3D); |
161 |
at.setName(name); |
162 |
at.setEnabale(true);
|
163 |
|
164 |
//crear el intervalo
|
165 |
AnimationDatedInterval adi = (AnimationDatedInterval) at.createInterval(); |
166 |
adi.setBeginDateInterval(Date.valueOf("2000-01-01")); |
167 |
adi.setEndDateInterval(Date.valueOf("2000-01-04")); |
168 |
|
169 |
|
170 |
// at.setAnimatedObject(layer);
|
171 |
// at.setAnimationType(animationDate3D);
|
172 |
} |
173 |
|
174 |
return at;
|
175 |
|
176 |
} |
177 |
|
178 |
} |