svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutGraphicControls.java @ 46
History | View | Annotate | Download (5.24 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.slf4j.Logger; |
25 |
import org.slf4j.LoggerFactory; |
26 |
|
27 |
import org.gvsig.andami.IconThemeHelper; |
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.app.project.documents.layout.FLayoutGraphics; |
32 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
33 |
|
34 |
/**
|
35 |
* Extensi?n que actua sobre el Layout para controlas las diferentes
|
36 |
* operaciones sobre los gr?ficos.
|
37 |
*
|
38 |
* @author Vicente Caballero Navarro
|
39 |
*/
|
40 |
public class LayoutGraphicControls extends Extension { |
41 |
|
42 |
private static final Logger logger = LoggerFactory |
43 |
.getLogger(LayoutGraphicControls.class); |
44 |
private LayoutPanel layout = null; |
45 |
|
46 |
/**
|
47 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
48 |
*/
|
49 |
public void execute(String s) { |
50 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
51 |
FLayoutGraphics lg = new FLayoutGraphics(layout);
|
52 |
logger.debug("Comand : " + s);
|
53 |
|
54 |
if (s.compareTo("layout-graphic-group") == 0) { |
55 |
layout.getLayoutContext().getFrameCommandsRecord() |
56 |
.startComplex(PluginServices.getText(this, "group")); |
57 |
lg.grouping(); |
58 |
layout.getLayoutContext().getFrameCommandsRecord().endComplex(); |
59 |
layout.getDocument().setModified(true);
|
60 |
} else
|
61 |
if (s.compareTo("layout-graphic-ungroup") == 0) { |
62 |
lg.ungrouping(); |
63 |
layout.getDocument().setModified(true);
|
64 |
} else
|
65 |
if (s.compareTo("layout-graphic-properties") == 0) { |
66 |
if (lg.openFFrameDialog()) {
|
67 |
layout.getDocument().setModified(true);
|
68 |
} |
69 |
} else
|
70 |
if (s.compareTo("layout-graphic-align") == 0) { |
71 |
lg.aligning(); |
72 |
layout.getDocument().setModified(true);
|
73 |
} else
|
74 |
if (s.compareTo("layout-graphic-send-back") == 0) { |
75 |
lg.behind(); |
76 |
layout.getDocument().setModified(true);
|
77 |
} else
|
78 |
if (s.compareTo("layout-graphic-bring-to-front") == 0) { |
79 |
lg.before(); |
80 |
layout.getDocument().setModified(true);
|
81 |
} else
|
82 |
if (s.compareTo("layout-graphic-add-border") == 0) { |
83 |
if (lg.border()) {
|
84 |
layout.getDocument().setModified(true);
|
85 |
} |
86 |
} else
|
87 |
if (s.compareTo("layout-graphic-position") == 0) { |
88 |
lg.position(); |
89 |
layout.getDocument().setModified(true);
|
90 |
} |
91 |
} |
92 |
|
93 |
/**
|
94 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
95 |
*/
|
96 |
public boolean isVisible() { |
97 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
98 |
|
99 |
if (f == null) { |
100 |
return false; |
101 |
} |
102 |
|
103 |
if (f instanceof LayoutPanel) { |
104 |
return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() |
105 |
// > 0;
|
106 |
} |
107 |
return false; |
108 |
} |
109 |
|
110 |
/**
|
111 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
112 |
*/
|
113 |
public void initialize() { |
114 |
registerIcons(); |
115 |
} |
116 |
|
117 |
private void registerIcons() { |
118 |
|
119 |
IconThemeHelper.registerIcon("action", "layout-graphic-group", this); |
120 |
IconThemeHelper.registerIcon("action", "layout-graphic-ungroup", this); |
121 |
IconThemeHelper.registerIcon("action", "layout-graphic-bring-to-front", this); |
122 |
IconThemeHelper.registerIcon("action", "layout-graphic-send-back", this); |
123 |
IconThemeHelper.registerIcon("action", "layout-graphic-position", this); |
124 |
IconThemeHelper.registerIcon("action", "layout-graphic-add-border", this); |
125 |
} |
126 |
|
127 |
/**
|
128 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
129 |
*/
|
130 |
public boolean isEnabled() { |
131 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
132 |
if (!layout.getLayoutContext().isEditable())
|
133 |
return false; |
134 |
return true; |
135 |
} |
136 |
} |