gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / roi / ui / ROIWindow.java @ 2818
History | View | Annotate | Download (2.71 KB)
1 | 2480 | nbrodin | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2011-2012 Prodevelop S.L
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
18 | * MA 02110-1301, USA.
|
||
19 | *
|
||
20 | */
|
||
21 | package org.gvsig.raster.tools.app.basic.tool.roi.ui; |
||
22 | |||
23 | import java.awt.BorderLayout; |
||
24 | |||
25 | import javax.swing.JComponent; |
||
26 | import javax.swing.JPanel; |
||
27 | |||
28 | import org.gvsig.andami.PluginServices; |
||
29 | import org.gvsig.andami.ui.mdiManager.IWindow; |
||
30 | import org.gvsig.andami.ui.mdiManager.IWindowListener; |
||
31 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
32 | import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
||
33 | |||
34 | |||
35 | /**
|
||
36 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
37 | */
|
||
38 | public class ROIWindow extends JPanel implements IWindow, IWindowListener { |
||
39 | |||
40 | private static final long serialVersionUID = -4401123724140025094L; |
||
41 | |||
42 | private WindowInfo info;
|
||
43 | |||
44 | private Object profile = WindowInfo.EDITOR_PROFILE; |
||
45 | |||
46 | private IWindowListener listener;
|
||
47 | |||
48 | public ROIWindow(JComponent panel, String title, int w, int h) { |
||
49 | this.setLayout(new BorderLayout()); |
||
50 | add(panel, BorderLayout.CENTER);
|
||
51 | |||
52 | info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
|
||
53 | info.setTitle(title); |
||
54 | info.setWidth(w); |
||
55 | info.setHeight(h); |
||
56 | } |
||
57 | |||
58 | public void addIWindowListener(IWindowListener listener) { |
||
59 | this.listener = listener;
|
||
60 | } |
||
61 | |||
62 | public WindowInfo getWindowInfo() {
|
||
63 | return info;
|
||
64 | } |
||
65 | |||
66 | public Object getWindowProfile() { |
||
67 | return profile;
|
||
68 | } |
||
69 | |||
70 | public void close() { |
||
71 | try {
|
||
72 | PluginServices.getMDIManager().closeWindow(this);
|
||
73 | IWindow[] list = PluginServices.getMDIManager().getAllWindows();
|
||
74 | for (int i = 0; i < list.length; i++) { |
||
75 | if(list[i] instanceof AbstractViewPanel) { |
||
76 | ((AbstractViewPanel)list[i]).getMapControl().getMapContext().invalidate(); |
||
77 | } |
||
78 | } |
||
79 | } catch (ArrayIndexOutOfBoundsException e) { |
||
80 | //Si la ventana no se puede eliminar no hacemos nada
|
||
81 | } |
||
82 | } |
||
83 | |||
84 | public void windowActivated() { |
||
85 | if(listener != null) |
||
86 | listener.windowActivated(); |
||
87 | } |
||
88 | |||
89 | public void windowClosed() { |
||
90 | if(listener != null) |
||
91 | listener.windowClosed(); |
||
92 | } |
||
93 | } |