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