root / branches / gvSIG_1.11.0_Mejoras_gvSIG-EIEL / extensions / extSeriesMapas / src / org / gvsig / eiel / print / series / EIELSeriesMapasExtension.java @ 34815
History | View | Annotate | Download (2.77 KB)
1 |
package org.gvsig.eiel.print.series; |
---|---|
2 |
|
3 |
|
4 |
import javax.swing.JOptionPane; |
5 |
|
6 |
import org.gvsig.eiel.print.series.gui.SeriesMapasSettingsPanel; |
7 |
import org.gvsig.eiel.print.series.model.MapSerieSettings; |
8 |
import org.gvsig.eiel.print.series.tool.MapSeriesGridListener; |
9 |
|
10 |
import com.iver.andami.PluginServices; |
11 |
import com.iver.andami.messages.NotificationManager; |
12 |
import com.iver.andami.plugins.Extension; |
13 |
import com.iver.andami.ui.mdiManager.IWindow; |
14 |
import com.iver.cit.gvsig.fmap.MapContext; |
15 |
import com.iver.cit.gvsig.fmap.MapControl; |
16 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
17 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
18 |
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior; |
19 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
20 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.RectangleSelectListener; |
21 |
|
22 |
// org.gvsig.eiel.print.series.EIELSeriesMapasExtension
|
23 |
public class EIELSeriesMapasExtension extends Extension { |
24 |
|
25 |
|
26 |
private int xx = 0; |
27 |
|
28 |
private static MapSeriesGridListener gridListener = null; |
29 |
|
30 |
public EIELSeriesMapasExtension() {
|
31 |
|
32 |
} |
33 |
|
34 |
public void initialize() { |
35 |
gridListener = new MapSeriesGridListener();
|
36 |
} |
37 |
|
38 |
public void postInitialize() { |
39 |
|
40 |
} |
41 |
|
42 |
|
43 |
public void terminate() { |
44 |
|
45 |
} |
46 |
|
47 |
|
48 |
public void execute(String actionCommand) { |
49 |
|
50 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
51 |
|
52 |
if (w != null && w instanceof View) { |
53 |
View v = (View) w; |
54 |
SeriesMapasSettingsPanel panel = new SeriesMapasSettingsPanel(v);
|
55 |
PluginServices.getMDIManager().addCentredWindow(panel); |
56 |
} else {
|
57 |
NotificationManager.showMessageError( |
58 |
"Bad window: " + w,
|
59 |
new Exception("Bad window: " + w)); |
60 |
} |
61 |
|
62 |
} |
63 |
|
64 |
|
65 |
public boolean isEnabled() { |
66 |
|
67 |
try {
|
68 |
IWindow w = PluginServices.getMDIManager().getActiveWindow(); |
69 |
|
70 |
if (w instanceof View) { |
71 |
View v = (View) w; |
72 |
MapControl mc = v.getMapControl(); |
73 |
MapContext mx = mc.getMapContext(); |
74 |
int lyrcnt = mx.getLayers().getLayersCount();
|
75 |
return (lyrcnt > 0); |
76 |
} |
77 |
} catch (Exception ex) { |
78 |
return false; |
79 |
} |
80 |
|
81 |
return false; |
82 |
|
83 |
} |
84 |
|
85 |
|
86 |
public boolean isVisible() { |
87 |
return isEnabled();
|
88 |
} |
89 |
|
90 |
public static void createMapSeries(MapSerieSettings mss) throws Exception { |
91 |
|
92 |
|
93 |
} |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
public static void setGridTool(MapSerieSettings mps) { |
101 |
|
102 |
MapControl mc = mps.getTheView().getMapControl(); |
103 |
// add if not present
|
104 |
if (!mc.hasTool(MapSeriesGridListener.MAP_SERIES_SET_GRID_TOOL_ID)) {
|
105 |
Behavior rect_beh = new RectangleBehavior(gridListener);
|
106 |
mc.addMapTool(MapSeriesGridListener.MAP_SERIES_SET_GRID_TOOL_ID, rect_beh); |
107 |
} |
108 |
mc.setTool(MapSeriesGridListener.MAP_SERIES_SET_GRID_TOOL_ID); |
109 |
} |
110 |
|
111 |
} |