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