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 | 5 | jldominguez | /* 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 | 1714 | fdiaz | import javax.swing.JComponent; |
29 | 5 | jldominguez | |
30 | import org.slf4j.Logger; |
||
31 | import org.slf4j.LoggerFactory; |
||
32 | 670 | fdiaz | |
33 | 5 | jldominguez | import org.gvsig.andami.PluginServices; |
34 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
35 | import org.gvsig.app.gui.styling.SymbolSelector; |
||
36 | 670 | fdiaz | import org.gvsig.app.project.documents.layout.LayoutContext; |
37 | 5 | jldominguez | 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 | 250 | cmartinez | import org.gvsig.tools.observer.ObservableHelper; |
44 | import org.gvsig.tools.observer.Observer; |
||
45 | 670 | fdiaz | import org.gvsig.tools.swing.api.ActionListenerSupport; |
46 | 739 | fdiaz | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
47 | import org.gvsig.tools.swing.api.ToolsSwingManager; |
||
48 | 5 | jldominguez | |
49 | /**
|
||
50 | * Di?logo de las propiedades de los gr?ficos.
|
||
51 | 670 | fdiaz | *
|
52 | 5 | jldominguez | * @author Vicente Caballero Navarro
|
53 | */
|
||
54 | 1714 | fdiaz | public class FFrameGraphicsDialog extends SymbolSelector implements IFFrameDialog { |
55 | 5 | jldominguez | |
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 | 670 | fdiaz | private LayoutPanel m_layout = null; |
63 | 5 | jldominguez | |
64 | private boolean isAcepted = false; |
||
65 | private FFrameGraphics fframegraphics = null; |
||
66 | private JPRotation pRotation = null; |
||
67 | private FFrameGraphics newFFrameGraphics;
|
||
68 | 250 | cmartinez | private ObservableHelper observableHelper = new ObservableHelper(); |
69 | 5 | jldominguez | |
70 | 670 | fdiaz | private ActionListenerSupport actionListenerSupportHelper;
|
71 | 250 | cmartinez | |
72 | 5 | jldominguez | 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 | 739 | fdiaz | |
84 | ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
||
85 | actionListenerSupportHelper = toolsSwingManager.createActionListenerSupport(); |
||
86 | |||
87 | 5 | jldominguez | 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 | 739 | fdiaz | LayoutContext layoutContext = m_layout.getLayoutContext(); |
100 | layoutContext.delFFrame(fframegraphics); |
||
101 | layoutContext.addFFrame(newFFrameGraphics, false, true); |
||
102 | layoutContext.updateFFrames(); |
||
103 | 5 | jldominguez | m_layout.getLayoutControl().refresh(); |
104 | isAcepted = true;
|
||
105 | 250 | cmartinez | FFrameGraphicsDialog.this.notifyDialogClosed(); |
106 | 5 | jldominguez | } catch (CloneNotSupportedException e1) { |
107 | LOG.error("It is not possible clonate the object", e);
|
||
108 | } |
||
109 | } |
||
110 | }; |
||
111 | 670 | fdiaz | |
112 | 250 | cmartinez | ActionListener cancelAction = new ActionListener() { |
113 | public void actionPerformed(ActionEvent e) { |
||
114 | isAcepted = false;
|
||
115 | FFrameGraphicsDialog.this.notifyDialogClosed(); |
||
116 | } |
||
117 | }; |
||
118 | 670 | fdiaz | |
119 | 5 | jldominguez | okCancelPanel.addOkButtonActionListener(okAction); |
120 | 250 | cmartinez | okCancelPanel.addCancelButtonActionListener(cancelAction); |
121 | 739 | fdiaz | |
122 | 5 | jldominguez | } |
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 | 670 | fdiaz | |
139 | 118 | jldominguez | m_viewinfo.setWidth(650);
|
140 | m_viewinfo.setHeight(625);
|
||
141 | 5 | jldominguez | |
142 | 670 | fdiaz | |
143 | 5 | jldominguez | 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 | 670 | fdiaz | |
165 | 5 | jldominguez | } |
166 | |||
167 | /**
|
||
168 | * This method initializes pRotation
|
||
169 | 670 | fdiaz | *
|
170 | 5 | jldominguez | * @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 | 250 | cmartinez | |
184 | 670 | fdiaz | |
185 | 250 | cmartinez | 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 | 670 | fdiaz | |
197 | 250 | cmartinez | protected void notifyDialogClosed() { |
198 | observableHelper.notifyObservers(this, new FFrameDialogNotification(FFrameDialogNotification.DIALOG_CLOSED)); |
||
199 | } |
||
200 | 670 | fdiaz | |
201 | @Override
|
||
202 | public void addActionListener(ActionListener listener) { |
||
203 | actionListenerSupportHelper.addActionListener(listener); |
||
204 | |||
205 | } |
||
206 | |||
207 | @Override
|
||
208 | 724 | jjdelcerro | public boolean hasActionListeners() { |
209 | return actionListenerSupportHelper.hasActionListeners();
|
||
210 | } |
||
211 | |||
212 | 739 | fdiaz | |
213 | 724 | jjdelcerro | @Override
|
214 | 670 | fdiaz | 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 | 1714 | fdiaz | |
235 | @Override
|
||
236 | public String getTitle() { |
||
237 | return getWindowInfo().getTitle();
|
||
238 | } |
||
239 | |||
240 | @Override
|
||
241 | public JComponent asJComponent() { |
||
242 | return this; |
||
243 | } |
||
244 | |||
245 | 670 | fdiaz | } |