svn-document-layout / branches / usability_v2 / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / listener / LayoutAddRectangleWithDialogListener.java @ 145
History | View | Annotate | Download (2.75 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.project.documents.layout.tools.listener; |
23 |
|
24 |
import java.awt.geom.Rectangle2D; |
25 |
|
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
28 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
29 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
30 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
31 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
32 |
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent; |
33 |
|
34 |
/**
|
35 |
* @author gvSIG Team
|
36 |
* @version $Id$
|
37 |
*
|
38 |
*/
|
39 |
public abstract class LayoutAddRectangleWithDialogListener extends |
40 |
LayoutAddRectangleListener { |
41 |
|
42 |
/**
|
43 |
* @param layoutPanel
|
44 |
*/
|
45 |
public LayoutAddRectangleWithDialogListener(LayoutPanel layoutPanel) {
|
46 |
super(layoutPanel);
|
47 |
} |
48 |
|
49 |
public void rectangle(EnvelopeEvent event) throws BehaviorException { |
50 |
IFFrame fframe = layoutManager.createFrame(getFFrameName()); |
51 |
fframe.setLayoutPanel(layoutPanel); |
52 |
fframe.setLayoutContext(layoutPanel.getLayoutContext()); |
53 |
fframe.setLayoutControl(layoutPanel.getLayoutControl()); |
54 |
Rectangle2D r = new Rectangle2D.Double(); |
55 |
|
56 |
r = getRectangle(TOLERANCE); |
57 |
fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layoutPanel |
58 |
.getLayoutControl().getAT())); |
59 |
IFFrameDialog fframedialog = |
60 |
layoutManager.createFFrameDialog(fframe, layoutPanel); |
61 |
if (fframedialog != null) { |
62 |
PluginServices.getMDIManager().addWindow(fframedialog); |
63 |
} |
64 |
|
65 |
IFFrame newFrame = fframedialog.getFFrame(); |
66 |
if (newFrame != null) { |
67 |
layoutPanel.getLayoutContext().addFFrame(newFrame, true, true); |
68 |
} |
69 |
PluginServices.getMainFrame().enableControls(); |
70 |
layoutPanel.getLayoutControl().refresh(); |
71 |
} |
72 |
|
73 |
public abstract String getFFrameName(); |
74 |
} |