svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameGraphicsDialog.java @ 1714
History | View | Annotate | Download (7.62 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.fframes.gui.dialogs; |
23 |
|
24 |
import java.awt.Dimension; |
25 |
import java.awt.event.ActionEvent; |
26 |
import java.awt.event.ActionListener; |
27 |
import java.awt.geom.Rectangle2D; |
28 |
import javax.swing.JComponent; |
29 |
|
30 |
import org.slf4j.Logger; |
31 |
import org.slf4j.LoggerFactory; |
32 |
|
33 |
import org.gvsig.andami.PluginServices; |
34 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
35 |
import org.gvsig.app.gui.styling.SymbolSelector; |
36 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
37 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics; |
38 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
39 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
40 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
41 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
42 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
43 |
import org.gvsig.tools.observer.ObservableHelper; |
44 |
import org.gvsig.tools.observer.Observer; |
45 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
46 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
47 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
48 |
|
49 |
/**
|
50 |
* Di?logo de las propiedades de los gr?ficos.
|
51 |
*
|
52 |
* @author Vicente Caballero Navarro
|
53 |
*/
|
54 |
public class FFrameGraphicsDialog extends SymbolSelector implements IFFrameDialog { |
55 |
|
56 |
private static final long serialVersionUID = 7473813303719944579L; |
57 |
|
58 |
private static final Logger LOG = LoggerFactory |
59 |
.getLogger(FFrameGraphicsDialog.class); |
60 |
|
61 |
private Rectangle2D rect = new Rectangle2D.Double(); |
62 |
private LayoutPanel m_layout = null; |
63 |
|
64 |
private boolean isAcepted = false; |
65 |
private FFrameGraphics fframegraphics = null; |
66 |
private JPRotation pRotation = null; |
67 |
private FFrameGraphics newFFrameGraphics;
|
68 |
private ObservableHelper observableHelper = new ObservableHelper(); |
69 |
|
70 |
private ActionListenerSupport actionListenerSupportHelper;
|
71 |
|
72 |
public FFrameGraphicsDialog(LayoutPanel layout, FFrameGraphics fframe) {
|
73 |
super(fframe.getFSymbol(), fframe.getType(), null, true); |
74 |
m_layout = layout; |
75 |
fframegraphics = fframe; |
76 |
initialize(); |
77 |
} |
78 |
|
79 |
/**
|
80 |
* This method initializes this
|
81 |
*/
|
82 |
private void initialize() { |
83 |
|
84 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
85 |
actionListenerSupportHelper = toolsSwingManager.createActionListenerSupport(); |
86 |
|
87 |
this.setSize(650, 700); |
88 |
getPRotation().setRotation(fframegraphics.getRotation()); |
89 |
((GridBagLayoutPanel) getJPanelOptions()).addComponent(getPRotation()); |
90 |
|
91 |
ActionListener okAction = new ActionListener() { |
92 |
|
93 |
public void actionPerformed(ActionEvent e) { |
94 |
try {
|
95 |
newFFrameGraphics = (FFrameGraphics) fframegraphics.clone(); |
96 |
newFFrameGraphics.setBoundBox(fframegraphics.getBoundBox()); |
97 |
newFFrameGraphics.setSymbol((ISymbol) getSelectedObject()); |
98 |
newFFrameGraphics.setRotation(getPRotation().getRotation()); |
99 |
LayoutContext layoutContext = m_layout.getLayoutContext(); |
100 |
layoutContext.delFFrame(fframegraphics); |
101 |
layoutContext.addFFrame(newFFrameGraphics, false, true); |
102 |
layoutContext.updateFFrames(); |
103 |
m_layout.getLayoutControl().refresh(); |
104 |
isAcepted = true;
|
105 |
FFrameGraphicsDialog.this.notifyDialogClosed(); |
106 |
} catch (CloneNotSupportedException e1) { |
107 |
LOG.error("It is not possible clonate the object", e);
|
108 |
} |
109 |
} |
110 |
}; |
111 |
|
112 |
ActionListener cancelAction = new ActionListener() { |
113 |
public void actionPerformed(ActionEvent e) { |
114 |
isAcepted = false;
|
115 |
FFrameGraphicsDialog.this.notifyDialogClosed(); |
116 |
} |
117 |
}; |
118 |
|
119 |
okCancelPanel.addOkButtonActionListener(okAction); |
120 |
okCancelPanel.addCancelButtonActionListener(cancelAction); |
121 |
|
122 |
} |
123 |
|
124 |
/**
|
125 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
|
126 |
*/
|
127 |
public Object getViewModel() { |
128 |
return "FPanelLegendDefault"; |
129 |
} |
130 |
|
131 |
/**
|
132 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
133 |
*/
|
134 |
public WindowInfo getWindowInfo() {
|
135 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
136 |
m_viewinfo |
137 |
.setTitle(PluginServices.getText(this, "propiedades_grafico")); |
138 |
|
139 |
m_viewinfo.setWidth(650);
|
140 |
m_viewinfo.setHeight(625);
|
141 |
|
142 |
|
143 |
return m_viewinfo;
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#setRectangle(java.awt.geom.Rectangle2D)
|
148 |
*/
|
149 |
public void setRectangle(Rectangle2D r) { |
150 |
rect.setRect(r); |
151 |
} |
152 |
|
153 |
/**
|
154 |
* @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
|
155 |
*/
|
156 |
public boolean getIsAcepted() { |
157 |
return isAcepted;
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
162 |
*/
|
163 |
public void viewActivated() { |
164 |
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* This method initializes pRotation
|
169 |
*
|
170 |
* @return javax.swing.JPanel
|
171 |
*/
|
172 |
private JPRotation getPRotation() {
|
173 |
if (pRotation == null) { |
174 |
pRotation = new JPRotation();
|
175 |
pRotation.setPreferredSize(new Dimension(120, 120)); |
176 |
} |
177 |
return pRotation;
|
178 |
} |
179 |
|
180 |
public IFFrame getFFrame() {
|
181 |
return newFFrameGraphics;
|
182 |
} |
183 |
|
184 |
|
185 |
public void addObserver(Observer observer) { |
186 |
observableHelper.addObserver(observer); |
187 |
} |
188 |
|
189 |
public void deleteObserver(Observer observer) { |
190 |
observableHelper.deleteObserver(observer); |
191 |
} |
192 |
|
193 |
public void deleteObservers() { |
194 |
observableHelper.deleteObservers(); |
195 |
} |
196 |
|
197 |
protected void notifyDialogClosed() { |
198 |
observableHelper.notifyObservers(this, new FFrameDialogNotification(FFrameDialogNotification.DIALOG_CLOSED)); |
199 |
} |
200 |
|
201 |
@Override
|
202 |
public void addActionListener(ActionListener listener) { |
203 |
actionListenerSupportHelper.addActionListener(listener); |
204 |
|
205 |
} |
206 |
|
207 |
@Override
|
208 |
public boolean hasActionListeners() { |
209 |
return actionListenerSupportHelper.hasActionListeners();
|
210 |
} |
211 |
|
212 |
|
213 |
@Override
|
214 |
public ActionListener[] getActionListeners() { |
215 |
return actionListenerSupportHelper.getActionListeners();
|
216 |
} |
217 |
|
218 |
@Override
|
219 |
public void removeActionListener(ActionListener listener) { |
220 |
actionListenerSupportHelper.removeActionListener(listener); |
221 |
|
222 |
} |
223 |
|
224 |
@Override
|
225 |
public void removeAllActionListener() { |
226 |
actionListenerSupportHelper.removeAllActionListener(); |
227 |
|
228 |
} |
229 |
|
230 |
@Override
|
231 |
public void fireActionEvent(ActionEvent event) { |
232 |
actionListenerSupportHelper.fireActionEvent(event); |
233 |
} |
234 |
|
235 |
@Override
|
236 |
public String getTitle() { |
237 |
return getWindowInfo().getTitle();
|
238 |
} |
239 |
|
240 |
@Override
|
241 |
public JComponent asJComponent() { |
242 |
return this; |
243 |
} |
244 |
|
245 |
} |