svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / FFrameLegendExtension.java @ 46
History | View | Annotate | Download (3.08 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.extension; |
23 |
|
24 |
import org.gvsig.andami.PluginServices; |
25 |
import org.gvsig.andami.plugins.Extension; |
26 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
27 |
import org.gvsig.app.project.documents.layout.FLayoutGraphics; |
28 |
import org.gvsig.app.project.documents.layout.fframes.FFrameLegend; |
29 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
30 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
31 |
|
32 |
/**
|
33 |
* Extensi?n preparada para controlar las opciones que se pueden realizar sobre
|
34 |
* una vista a?adida en el Layout.
|
35 |
*
|
36 |
* @author Vicente Caballero Navarro
|
37 |
*/
|
38 |
public class FFrameLegendExtension extends Extension { |
39 |
|
40 |
private LayoutPanel layout = null; |
41 |
|
42 |
/**
|
43 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
44 |
*/
|
45 |
public void initialize() { |
46 |
} |
47 |
|
48 |
/**
|
49 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
50 |
*/
|
51 |
public void execute(String s) { |
52 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
53 |
FLayoutGraphics lg = new FLayoutGraphics(layout);
|
54 |
if (s.compareTo("layout-graphic-simplify-legend") == 0) { |
55 |
lg.simplify(); |
56 |
layout.getDocument().setModified(true);
|
57 |
} |
58 |
} |
59 |
|
60 |
/**
|
61 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
62 |
*/
|
63 |
public boolean isEnabled() { |
64 |
LayoutPanel l = |
65 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
66 |
IFFrame[] fframes = l.getLayoutContext().getFFrameSelected();
|
67 |
if (!l.getLayoutContext().isEditable())
|
68 |
return false; |
69 |
for (int i = 0; i < fframes.length; i++) { |
70 |
if (fframes[i] instanceof FFrameLegend) { |
71 |
return true; |
72 |
} |
73 |
} |
74 |
|
75 |
return false; |
76 |
} |
77 |
|
78 |
/**
|
79 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
80 |
*/
|
81 |
public boolean isVisible() { |
82 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
83 |
|
84 |
if (f == null) { |
85 |
return false; |
86 |
} |
87 |
|
88 |
if (f instanceof LayoutPanel) { |
89 |
return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() |
90 |
// > 0;
|
91 |
} else {
|
92 |
return false; |
93 |
} |
94 |
} |
95 |
} |