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 / FFrameViewDialog.java @ 918
History | View | Annotate | Download (23.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.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.awt.Insets; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.geom.Rectangle2D; |
29 |
|
30 |
import javax.swing.BorderFactory; |
31 |
import javax.swing.ButtonGroup; |
32 |
import javax.swing.JButton; |
33 |
import javax.swing.JCheckBox; |
34 |
import javax.swing.JLabel; |
35 |
import javax.swing.JOptionPane; |
36 |
import javax.swing.JPanel; |
37 |
import javax.swing.JRadioButton; |
38 |
import javax.swing.JTextField; |
39 |
|
40 |
import org.gvsig.andami.PluginsLocator; |
41 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
42 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
43 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
44 |
import org.gvsig.app.ApplicationLocator; |
45 |
import org.gvsig.app.ApplicationManager; |
46 |
import org.gvsig.app.project.ProjectManager; |
47 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
48 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
49 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid; |
50 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
51 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
52 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap.SCALE_TYPE; |
53 |
import org.gvsig.app.project.documents.layout.fframes.ListViewModel; |
54 |
import org.gvsig.app.project.documents.layout.fframes.gui.EnvelopePanel; |
55 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
56 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
57 |
import org.gvsig.app.project.documents.view.DefaultViewDocument; |
58 |
import org.gvsig.app.project.documents.view.ViewDocument; |
59 |
import org.gvsig.app.project.documents.view.ViewManager; |
60 |
import org.gvsig.fmap.geom.primitive.Envelope; |
61 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
62 |
import org.gvsig.i18n.Messages; |
63 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
64 |
|
65 |
/**
|
66 |
* Dialog to add a view to the Layout document, by means of a FFrameView
|
67 |
*
|
68 |
* @author Vicente Caballero Navarro
|
69 |
* @author Cesar Martinez Izquierdo
|
70 |
*/
|
71 |
@SuppressWarnings("UseSpecificCatch") |
72 |
public class FFrameViewDialog extends AbstractFFrameDialog implements |
73 |
IFFrameDialog, SingletonWindow { |
74 |
|
75 |
private static final long serialVersionUID = -7223804566537544559L; |
76 |
|
77 |
private final LayoutManager layoutManager; |
78 |
private javax.swing.JLabel lViews = null; |
79 |
private javax.swing.JScrollPane jScrollPane = null; |
80 |
private javax.swing.JList liViews = null; |
81 |
private javax.swing.JCheckBox chbSyncLayers = null; |
82 |
private javax.swing.JButton bAceptar = null; |
83 |
private javax.swing.JButton bCancelar = null; |
84 |
private javax.swing.JLabel lCalidad = null; |
85 |
private javax.swing.JComboBox cbCalidad = null; |
86 |
private ViewDocument m_projectView = null; |
87 |
private final Rectangle2D rect = new Rectangle2D.Double(); |
88 |
private FFrameView fframeview = null; |
89 |
private boolean isAcepted = false; |
90 |
private JPRotation rotation = null; |
91 |
private javax.swing.JButton bGrid = null; |
92 |
private javax.swing.JCheckBox chbShowGrid = null; |
93 |
private JPanel pnlFirstRow = null; |
94 |
private JCheckBox chbSyncExtent = null; |
95 |
|
96 |
private WindowInfo windowInfo = null; |
97 |
|
98 |
private GridBagLayoutPanel pnlSyncGroup = null; |
99 |
private GridBagLayoutPanel pnlScaleTypeGroup = null; |
100 |
private ButtonGroup grpScaleType = null; |
101 |
private JRadioButton btnNormalScale = null; |
102 |
private JRadioButton btnFixedScale = null; |
103 |
private JRadioButton btnFixedExtent = null; |
104 |
private JTextField fldScale = null; |
105 |
private EnvelopePanel pnlExtent = null; |
106 |
private JButton btConfigView = null; |
107 |
private JPanel pnlScale = null; |
108 |
private ViewDocument createdView = null; |
109 |
|
110 |
private FFrameView newFFrameView = null; |
111 |
private FFrameGrid fframeGrid = null; |
112 |
|
113 |
/**
|
114 |
* This is the default constructor
|
115 |
*
|
116 |
* @param layoutPanel Referencia al Layout.
|
117 |
* @param frame
|
118 |
*/
|
119 |
public FFrameViewDialog(LayoutPanel layoutPanel, IFFrame frame) {
|
120 |
super(layoutPanel, frame);
|
121 |
fframeview = (FFrameView) frame; |
122 |
fframeGrid = (FFrameGrid) fframeview.getGrid(); |
123 |
initComponents(); |
124 |
layoutManager = (LayoutManager) ProjectManager.getInstance()
|
125 |
.getDocumentManager("project.document.layout");
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* This method initializes this
|
130 |
*/
|
131 |
private void initComponents() { |
132 |
this.setLayout(new GridBagLayout()); |
133 |
GridBagConstraints c = new GridBagConstraints(); |
134 |
Insets insets = new Insets(5, 5, 5, 5); |
135 |
int row = 0; |
136 |
c.gridx = 0;
|
137 |
c.gridy = row++; |
138 |
c.insets = new Insets(0, 0, 0, 0); |
139 |
c.anchor = GridBagConstraints.LINE_START;
|
140 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
141 |
add(getFirstRowPnl(), c); |
142 |
c.insets = insets; |
143 |
c.gridx = 0;
|
144 |
c.gridy = row++; |
145 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
146 |
c.fill = GridBagConstraints.HORIZONTAL;
|
147 |
|
148 |
GridBagLayoutPanel pnl = getPnlSyncGroup(); |
149 |
pnl.addComponent(getChbSyncLayers(), insets); |
150 |
pnl.addComponent(getChbSyncExtent(), insets); |
151 |
add(pnl, c); |
152 |
|
153 |
getGrpScaleType().add(getBtnNormalScale()); |
154 |
getGrpScaleType().add(getBtnFixedScale()); |
155 |
getGrpScaleType().add(getBtnFixedExtent()); |
156 |
|
157 |
pnl = getPnlScaleTypeGroup(); |
158 |
pnl.addComponent(getBtnNormalScale(), insets); |
159 |
pnl.addComponent(getPnlScale(), insets); // pnlScale() contains btnFixedScale
|
160 |
pnl.addComponent(getBtnFixedExtent(), new Insets(5, 5, 0, 5)); |
161 |
pnl.addComponent(getPnlExtent(), GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5)); |
162 |
if (fframeview.getScaleType() == SCALE_TYPE.FIXED_SCALE) {
|
163 |
getBtnFixedScale().setSelected(true);
|
164 |
setScaleType(SCALE_TYPE.FIXED_SCALE); |
165 |
getChbSyncExtent().setEnabled(false);
|
166 |
} else if (fframeview.getScaleType() == SCALE_TYPE.FIXED_EXTENT) { |
167 |
getBtnFixedExtent().setSelected(true);
|
168 |
setScaleType(SCALE_TYPE.FIXED_EXTENT); |
169 |
getChbSyncExtent().setEnabled(false);
|
170 |
} else {
|
171 |
getBtnNormalScale().setSelected(true);
|
172 |
setScaleType(SCALE_TYPE.NORMAL); |
173 |
} |
174 |
|
175 |
c.gridy = row++; |
176 |
add(pnl, c); |
177 |
|
178 |
c.fill = GridBagConstraints.NONE;
|
179 |
c.gridx = 0;
|
180 |
c.gridy = row++; |
181 |
c.gridwidth = 1;
|
182 |
add(getLCalidad(), c); |
183 |
c.gridx = 1;
|
184 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
185 |
add(getCbCalidad(), c); |
186 |
c.gridx = 0;
|
187 |
c.gridy = row++; |
188 |
c.gridwidth = 1;
|
189 |
add(getChbShowGrid(), c); |
190 |
c.gridx = 1;
|
191 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
192 |
add(getBGrid(), c); |
193 |
JPanel acceptCancelPnl = new JPanel(new GridBagLayout()); |
194 |
c.anchor = GridBagConstraints.LINE_START;
|
195 |
c.gridx = 0;
|
196 |
c.gridy = 0;
|
197 |
c.gridwidth = 1;
|
198 |
acceptCancelPnl.add(getbAceptar(), c); |
199 |
c.gridx = 1;
|
200 |
acceptCancelPnl.add(getBCancelar(), c); |
201 |
c.gridx = 0;
|
202 |
c.gridy = row++; |
203 |
c.anchor = GridBagConstraints.LINE_END;
|
204 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
205 |
add(acceptCancelPnl, c); |
206 |
} |
207 |
|
208 |
@Override
|
209 |
public void setRectangle(Rectangle2D r) { |
210 |
rect.setRect(r); |
211 |
} |
212 |
|
213 |
private JPanel getFirstRowPnl() { |
214 |
if (pnlFirstRow == null) { |
215 |
pnlFirstRow = new JPanel(new GridBagLayout()); |
216 |
GridBagConstraints c = new GridBagConstraints(); |
217 |
Insets insets = new Insets(5, 5, 5, 5); |
218 |
Insets insetsTop = new Insets(12, 5, 5, 5); |
219 |
c.gridx = 0;
|
220 |
c.gridy = 0;
|
221 |
c.insets = insetsTop; |
222 |
c.anchor = GridBagConstraints.PAGE_START;
|
223 |
pnlFirstRow.add(getLViews(), c); |
224 |
c.gridx = 1;
|
225 |
pnlFirstRow.add(getScrolledViewList(), c); |
226 |
c.insets = insets; |
227 |
c.gridx = 2;
|
228 |
c.gridheight = 2;
|
229 |
pnlFirstRow.add(getPRotation(), c); |
230 |
c.anchor = GridBagConstraints.LINE_END;
|
231 |
c.gridy = 1;
|
232 |
c.gridx = 1;
|
233 |
c.gridheight = 1;
|
234 |
pnlFirstRow.add(getBtnConfigView(), c); |
235 |
} |
236 |
return pnlFirstRow;
|
237 |
} |
238 |
|
239 |
private JButton getBtnConfigView() { |
240 |
UsabilitySwingManager manager = org.gvsig.tools.swing.api.ToolsSwingLocator.getUsabilitySwingManager(); |
241 |
btConfigView = manager.createJButton(Messages.getText("Configure_view"));
|
242 |
btConfigView.addActionListener((ActionEvent e) -> {
|
243 |
ViewDocument view = getSelectedView(); |
244 |
if (view != null) { |
245 |
IWindow propWin = view.getPropertiesWindow(); |
246 |
ApplicationManager manager1 = ApplicationLocator.getManager(); |
247 |
manager1.getUIManager().addWindow(propWin); |
248 |
} |
249 |
}); |
250 |
return btConfigView;
|
251 |
} |
252 |
|
253 |
private javax.swing.JLabel getLViews() {
|
254 |
if (lViews == null) { |
255 |
lViews = new javax.swing.JLabel();
|
256 |
lViews.setText(Messages.getText("Vista"));
|
257 |
} |
258 |
|
259 |
return lViews;
|
260 |
} |
261 |
|
262 |
private javax.swing.JScrollPane getScrolledViewList() {
|
263 |
if (jScrollPane == null) { |
264 |
jScrollPane = new javax.swing.JScrollPane();
|
265 |
jScrollPane.setViewportView(getViewList()); |
266 |
jScrollPane.setPreferredSize(new java.awt.Dimension(300, 100)); |
267 |
} |
268 |
return jScrollPane;
|
269 |
} |
270 |
|
271 |
private javax.swing.JList getViewList() {
|
272 |
if (liViews == null) { |
273 |
ListViewModel listmodel = new ListViewModel();
|
274 |
listmodel.addCreateNewViewObj(); |
275 |
|
276 |
if (listmodel.addViews()) {
|
277 |
JOptionPane.showMessageDialog(
|
278 |
ApplicationLocator.getManager().getRootComponent(), |
279 |
Messages.getText("_Some_views_excluded_from_list_because_have_editing_layers"),
|
280 |
Messages.getText("propiedades_marco_vista"),
|
281 |
JOptionPane.WARNING_MESSAGE);
|
282 |
} |
283 |
|
284 |
liViews = new javax.swing.JList();
|
285 |
liViews.setModel(listmodel); |
286 |
liViews.setSelectedIndex(0);
|
287 |
|
288 |
for (int i = 1; i < liViews.getModel().getSize(); i++) { |
289 |
if (fframeview.getMapContext() != null) { |
290 |
|
291 |
DefaultViewDocument pvaux |
292 |
= (DefaultViewDocument) liViews.getModel().getElementAt( |
293 |
i); |
294 |
|
295 |
if (pvaux.getMapContext()
|
296 |
.equals(fframeview.getMapContext())) { |
297 |
liViews.setSelectedIndex(i); |
298 |
m_projectView |
299 |
= (DefaultViewDocument) liViews.getModel() |
300 |
.getElementAt(i); |
301 |
} |
302 |
} |
303 |
} |
304 |
|
305 |
} |
306 |
|
307 |
return liViews;
|
308 |
} |
309 |
|
310 |
protected ViewDocument getSelectedView() {
|
311 |
Object selected = this.getViewList().getSelectedValue(); |
312 |
ViewDocument view = null;
|
313 |
if (selected instanceof ViewDocument) { |
314 |
view = (ViewDocument) selected; |
315 |
} else if (selected == ListViewModel.CREATE_NEW_VIEW_OBJECT) { |
316 |
if (this.createdView == null) { |
317 |
view = createView(); |
318 |
} else {
|
319 |
view = this.createdView;
|
320 |
} |
321 |
} |
322 |
return view;
|
323 |
} |
324 |
|
325 |
private ViewDocument createView() {
|
326 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
327 |
ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
328 |
createdView = (ViewDocument) viewManager.createDocument(); |
329 |
ProjectManager.getInstance().getCurrentProject().addDocument(createdView); |
330 |
return createdView;
|
331 |
} |
332 |
|
333 |
private void deleteView() { |
334 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
335 |
ProjectManager.getInstance().getCurrentProject().removeDocument(createdView); |
336 |
createdView = null;
|
337 |
} |
338 |
|
339 |
private javax.swing.JCheckBox getChbSyncLayers() {
|
340 |
if (chbSyncLayers == null) { |
341 |
chbSyncLayers = new javax.swing.JCheckBox();
|
342 |
chbSyncLayers.setText(Messages.getText("Synchronize_layers"));
|
343 |
chbSyncLayers.setSelected(fframeview.getLayerSynced()); |
344 |
chbSyncLayers.addActionListener((ActionEvent e) -> {
|
345 |
if (chbSyncLayers.isSelected()) {
|
346 |
JOptionPane.showMessageDialog(FFrameViewDialog.this,
|
347 |
Messages.getText("Warning_Enabling_layer_synchronization_will_discard_any_change_not_present_in_associated_view"),
|
348 |
Messages.getText("Warning_Layer_sync"),
|
349 |
JOptionPane.WARNING_MESSAGE);
|
350 |
} |
351 |
}); |
352 |
} |
353 |
|
354 |
return chbSyncLayers;
|
355 |
} |
356 |
|
357 |
private javax.swing.JCheckBox getChbSyncExtent() {
|
358 |
if (chbSyncExtent == null) { |
359 |
chbSyncExtent = new javax.swing.JCheckBox();
|
360 |
chbSyncExtent.setText(Messages.getText("Synchronize_extents"));
|
361 |
chbSyncExtent.setSelected(fframeview.getExtentSynced()); |
362 |
} |
363 |
return chbSyncExtent;
|
364 |
} |
365 |
|
366 |
protected void disableChbSyncExtent() { |
367 |
getChbSyncExtent().setEnabled(false);
|
368 |
getChbSyncExtent().setToolTipText(Messages.getText("Extent_cant_be_synchronized_when_using_fixed_scale_or_fixed_extent"));
|
369 |
} |
370 |
|
371 |
protected void enableChbSyncExtent() { |
372 |
getChbSyncExtent().setEnabled(true);
|
373 |
getChbSyncExtent().setToolTipText(null);
|
374 |
} |
375 |
|
376 |
private javax.swing.JButton getbAceptar() {
|
377 |
if (bAceptar == null) { |
378 |
bAceptar = new javax.swing.JButton();
|
379 |
bAceptar.setText(Messages.getText("Aceptar"));
|
380 |
bAceptar.addActionListener((java.awt.event.ActionEvent e) -> { |
381 |
newFFrameView = (FFrameView) layoutManager.createFrame(FFrameView.PERSISTENCE_DEFINITION_NAME); |
382 |
newFFrameView.setLayoutContext(fframeview.getLayoutContext()); |
383 |
|
384 |
ViewDocument v = getSelectedView(); |
385 |
if (v != null) { |
386 |
m_projectView = v; |
387 |
} |
388 |
newFFrameView.setView(v); |
389 |
|
390 |
newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect( |
391 |
rect, layoutPanel.getLayoutControl().getAT()) |
392 |
); |
393 |
newFFrameView.setRotation(getPRotation().getRotation()); |
394 |
newFFrameView.setHasToc(true);
|
395 |
newFFrameView.setLayerSynced(getChbSyncLayers().isSelected()); |
396 |
newFFrameView.setExtentSynced( |
397 |
getChbSyncExtent().isEnabled() && getChbSyncExtent().isSelected() |
398 |
); |
399 |
try {
|
400 |
if (getBtnFixedScale().isSelected()) {
|
401 |
Double d = Double.parseDouble(getFldScale().getText()); |
402 |
newFFrameView.setScaleType(SCALE_TYPE.FIXED_SCALE, d); |
403 |
} else if (getBtnFixedExtent().isSelected()) { |
404 |
Envelope envelope = getPnlExtent().getEnvelope(); |
405 |
if (envelope != null) { |
406 |
newFFrameView.setScaleType(SCALE_TYPE.FIXED_EXTENT, envelope); |
407 |
} else {
|
408 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
409 |
} |
410 |
} else {
|
411 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
412 |
} |
413 |
} catch (Exception ex) { |
414 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
415 |
} |
416 |
if (createdView != null && createdView != getSelectedView()) { |
417 |
// a view was created but later de-selected
|
418 |
deleteView(); |
419 |
} |
420 |
if (fframeGrid != null) { |
421 |
newFFrameView.setGrid(fframeGrid); |
422 |
} |
423 |
if (m_projectView != null) { |
424 |
newFFrameView.setView(m_projectView); |
425 |
newFFrameView.setQuality(getCbCalidad().getSelectedIndex()); |
426 |
if (newFFrameView.getGrid() != null) { |
427 |
((FFrameGrid) newFFrameView.getGrid()).setFFrameDependence(newFFrameView); |
428 |
} |
429 |
newFFrameView.showGrid(getChbShowGrid().isSelected()); |
430 |
newFFrameView.setBoundBox( |
431 |
FLayoutUtilities.toSheetRect( |
432 |
rect, |
433 |
layoutPanel.getLayoutControl().getAT() |
434 |
) |
435 |
); |
436 |
} |
437 |
isAcepted = true;
|
438 |
ApplicationLocator.getManager().getUIManager().closeWindow( |
439 |
FFrameViewDialog.this |
440 |
); |
441 |
notifyDialogClosed(); |
442 |
PluginsLocator.getMainFrame().refreshControls(); |
443 |
layoutPanel.getLayoutControl().setDefaultTool(); |
444 |
|
445 |
fireActionEvent(new ActionEvent(FFrameViewDialog.this, 1, "accept")); |
446 |
}); |
447 |
} |
448 |
|
449 |
return bAceptar;
|
450 |
} |
451 |
|
452 |
private javax.swing.JButton getBCancelar() {
|
453 |
if (bCancelar == null) { |
454 |
bCancelar = new javax.swing.JButton();
|
455 |
bCancelar.setText(Messages.getText("Cancelar"));
|
456 |
bCancelar.addActionListener((java.awt.event.ActionEvent e) -> { |
457 |
if (createdView != null) { |
458 |
deleteView(); |
459 |
} |
460 |
ApplicationLocator.getManager().getUIManager().closeWindow( |
461 |
FFrameViewDialog.this |
462 |
); |
463 |
notifyDialogClosed(); |
464 |
}); |
465 |
} |
466 |
|
467 |
return bCancelar;
|
468 |
} |
469 |
|
470 |
private javax.swing.JLabel getLCalidad() {
|
471 |
if (lCalidad == null) { |
472 |
lCalidad = new javax.swing.JLabel();
|
473 |
lCalidad.setText(Messages.getText("calidad"));
|
474 |
} |
475 |
|
476 |
return lCalidad;
|
477 |
} |
478 |
|
479 |
private javax.swing.JComboBox getCbCalidad() {
|
480 |
if (cbCalidad == null) { |
481 |
// String[] s={"Presentaci?n","Borrador"};
|
482 |
cbCalidad = new javax.swing.JComboBox();
|
483 |
cbCalidad.addItem(Messages.getText("presentacion"));
|
484 |
cbCalidad.addItem(Messages.getText("borrador"));
|
485 |
cbCalidad.setSelectedIndex(fframeview.getQuality()); |
486 |
} |
487 |
|
488 |
return cbCalidad;
|
489 |
} |
490 |
|
491 |
@Override
|
492 |
public WindowInfo getWindowInfo() {
|
493 |
if (windowInfo == null) { |
494 |
windowInfo = new WindowInfo(WindowInfo.RESIZABLE);
|
495 |
windowInfo.setHeight(620);
|
496 |
windowInfo.setWidth(600);
|
497 |
windowInfo.setTitle(Messages.getText("propiedades_marco_vista"));
|
498 |
} |
499 |
return windowInfo;
|
500 |
} |
501 |
|
502 |
@Override
|
503 |
public boolean getIsAcepted() { |
504 |
return isAcepted;
|
505 |
} |
506 |
|
507 |
private JPRotation getPRotation() {
|
508 |
if (rotation == null) { |
509 |
rotation = new JPRotation();
|
510 |
rotation.setRotation(fframeview.getRotation()); |
511 |
} |
512 |
return rotation;
|
513 |
} |
514 |
|
515 |
@Override
|
516 |
public IFFrame getFFrame() {
|
517 |
return newFFrameView;
|
518 |
} |
519 |
|
520 |
private JButton getBGrid() { |
521 |
if (bGrid == null) { |
522 |
bGrid = new JButton(); |
523 |
bGrid.setText(Messages.getText("configurar"));
|
524 |
bGrid.addActionListener((java.awt.event.ActionEvent e) -> { |
525 |
if (fframeGrid == null) { |
526 |
fframeGrid = (FFrameGrid) layoutManager.createFrame( |
527 |
FFrameGrid.PERSISTENCE_DEFINITION_NAME |
528 |
); |
529 |
} |
530 |
|
531 |
FFrameGridDialog fframeGridDialog = (FFrameGridDialog) layoutManager |
532 |
.createFFrameDialog(fframeGrid, layoutPanel); |
533 |
|
534 |
if (fframeGridDialog != null) { |
535 |
fframeGridDialog.setMapContext(getSelectedView().getMapContext()); |
536 |
fframeGridDialog.setFrameRotation(getPRotation().getRotation()); |
537 |
ApplicationLocator.getManager().getUIManager().addWindow(fframeGridDialog); |
538 |
} |
539 |
fframeGrid = (FFrameGrid) fframeGridDialog.getFFrame(); |
540 |
}); |
541 |
} |
542 |
return bGrid;
|
543 |
} |
544 |
|
545 |
private JCheckBox getChbShowGrid() { |
546 |
if (chbShowGrid == null) { |
547 |
chbShowGrid = new JCheckBox(); |
548 |
chbShowGrid.setSelected(fframeview.isShowGrid()); |
549 |
chbShowGrid.setText(Messages.getText("Show_grid"));
|
550 |
chbShowGrid.addActionListener((ActionEvent e) -> {
|
551 |
if (e.getSource() instanceof JCheckBox) { |
552 |
JCheckBox cb = (JCheckBox) e.getSource(); |
553 |
if (cb.isSelected()) {
|
554 |
if (fframeGrid == null) { |
555 |
// ensure we have a non-null grid if the checkbox is selected
|
556 |
FFrameGrid fframeGrid1 = (FFrameGrid) layoutManager.createFrame( |
557 |
FFrameGrid.PERSISTENCE_DEFINITION_NAME |
558 |
); |
559 |
} |
560 |
} |
561 |
} |
562 |
}); |
563 |
} |
564 |
return chbShowGrid;
|
565 |
} |
566 |
|
567 |
private GridBagLayoutPanel getPnlSyncGroup() {
|
568 |
if (pnlSyncGroup == null) { |
569 |
pnlSyncGroup = new GridBagLayoutPanel();
|
570 |
pnlSyncGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText("Synchronization_of_the_view_and_the_frame_view"))); |
571 |
} |
572 |
return pnlSyncGroup;
|
573 |
} |
574 |
|
575 |
private GridBagLayoutPanel getPnlScaleTypeGroup() {
|
576 |
if (pnlScaleTypeGroup == null) { |
577 |
pnlScaleTypeGroup = new GridBagLayoutPanel();
|
578 |
pnlScaleTypeGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText("Fixed_scale_and_extent"))); |
579 |
} |
580 |
return pnlScaleTypeGroup;
|
581 |
} |
582 |
|
583 |
private ButtonGroup getGrpScaleType() { |
584 |
if (grpScaleType == null) { |
585 |
grpScaleType = new ButtonGroup(); |
586 |
} |
587 |
return grpScaleType;
|
588 |
} |
589 |
|
590 |
private JRadioButton getBtnNormalScale() { |
591 |
if (btnNormalScale == null) { |
592 |
btnNormalScale = new JRadioButton(Messages.getText("Non_fixed")); |
593 |
btnNormalScale.addActionListener((ActionEvent e) -> {
|
594 |
FFrameViewDialog.this.setScaleType(SCALE_TYPE.NORMAL); |
595 |
FFrameViewDialog.this.enableChbSyncExtent(); |
596 |
}); |
597 |
} |
598 |
return btnNormalScale;
|
599 |
} |
600 |
|
601 |
private JRadioButton getBtnFixedScale() { |
602 |
if (btnFixedScale == null) { |
603 |
btnFixedScale = new JRadioButton(Messages.getText("Fixed_scale")); |
604 |
btnFixedScale.addActionListener((ActionEvent e) -> {
|
605 |
FFrameViewDialog.this.setScaleType(SCALE_TYPE.FIXED_SCALE); |
606 |
FFrameViewDialog.this.disableChbSyncExtent(); |
607 |
}); |
608 |
} |
609 |
return btnFixedScale;
|
610 |
} |
611 |
|
612 |
private JPanel getPnlScale() { |
613 |
if (pnlScale == null) { |
614 |
pnlScale = new JPanel(new GridBagLayout()); |
615 |
GridBagConstraints c = new GridBagConstraints(); |
616 |
c.insets = new Insets(0, 0, 0, 0); |
617 |
c.gridx = 0;
|
618 |
pnlScale.add(getBtnFixedScale()); |
619 |
c.anchor = GridBagConstraints.LINE_START;
|
620 |
c.gridx = 1;
|
621 |
c.insets = new Insets(0, 25, 0, 5); |
622 |
c.anchor = GridBagConstraints.LINE_END;
|
623 |
pnlScale.add(getLblScale(), c); |
624 |
c.gridx = 2;
|
625 |
c.insets = new Insets(0, 5, 0, 5); |
626 |
c.anchor = GridBagConstraints.LINE_START;
|
627 |
pnlScale.add(getFldScale(), c); |
628 |
} |
629 |
return pnlScale;
|
630 |
} |
631 |
|
632 |
private JTextField getFldScale() { |
633 |
if (fldScale == null) { |
634 |
fldScale = new JTextField(8); |
635 |
if (fframeview != null |
636 |
&& fframeview.getMapContext() != null
|
637 |
&& fframeview.getMapContext().getViewPort().getEnvelope() != null) {
|
638 |
fldScale.setText(Long.toString(fframeview.getMapContext().getScaleView()));
|
639 |
} |
640 |
} |
641 |
return fldScale;
|
642 |
} |
643 |
|
644 |
private JLabel getLblScale() { |
645 |
return new JLabel(Messages.getText("1__")); |
646 |
} |
647 |
|
648 |
private JRadioButton getBtnFixedExtent() { |
649 |
if (btnFixedExtent == null) { |
650 |
btnFixedExtent = new JRadioButton(Messages.getText("Fixed_extent")); |
651 |
btnFixedExtent.addActionListener((ActionEvent e) -> {
|
652 |
FFrameViewDialog.this.setScaleType(SCALE_TYPE.FIXED_EXTENT); |
653 |
FFrameViewDialog.this.disableChbSyncExtent(); |
654 |
}); |
655 |
} |
656 |
return btnFixedExtent;
|
657 |
} |
658 |
|
659 |
private EnvelopePanel getPnlExtent() {
|
660 |
if (pnlExtent == null) { |
661 |
pnlExtent = new EnvelopePanel();
|
662 |
if (fframeview != null |
663 |
&& fframeview.getMapContext() != null
|
664 |
&& fframeview.getMapContext().getViewPort().getEnvelope() != null) {
|
665 |
pnlExtent.setEnvelope(fframeview.getMapContext().getViewPort().getEnvelope()); |
666 |
} |
667 |
} |
668 |
return pnlExtent;
|
669 |
} |
670 |
|
671 |
@Override
|
672 |
public Object getWindowProfile() { |
673 |
return WindowInfo.DIALOG_PROFILE;
|
674 |
} |
675 |
|
676 |
@Override
|
677 |
public Object getWindowModel() { |
678 |
return fframeview;
|
679 |
} |
680 |
|
681 |
protected void setScaleType(SCALE_TYPE type) { |
682 |
if (null == type) { |
683 |
return;
|
684 |
} |
685 |
switch (type) {
|
686 |
case NORMAL:
|
687 |
getFldScale().setEditable(false);
|
688 |
getFldScale().setEnabled(false);
|
689 |
getPnlExtent().setEditable(false);
|
690 |
getPnlExtent().setEnabled(false);
|
691 |
break;
|
692 |
case FIXED_SCALE:
|
693 |
getFldScale().setEditable(true);
|
694 |
getFldScale().setEnabled(true);
|
695 |
getPnlExtent().setEditable(false);
|
696 |
getPnlExtent().setEnabled(false);
|
697 |
break;
|
698 |
case FIXED_EXTENT:
|
699 |
getFldScale().setEditable(false);
|
700 |
getFldScale().setEnabled(false);
|
701 |
getPnlExtent().setEditable(true);
|
702 |
getPnlExtent().setEnabled(true);
|
703 |
break;
|
704 |
default:
|
705 |
break;
|
706 |
} |
707 |
|
708 |
} |
709 |
|
710 |
protected SCALE_TYPE getSelectedScaleType() {
|
711 |
if (getBtnFixedScale().isSelected()) {
|
712 |
return SCALE_TYPE.FIXED_SCALE;
|
713 |
} else if (getBtnFixedExtent().isSelected()) { |
714 |
return SCALE_TYPE.FIXED_EXTENT;
|
715 |
} |
716 |
return SCALE_TYPE.NORMAL;
|
717 |
} |
718 |
|
719 |
} |