Revision 250

View differences:

trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutGraphicControls.java
23 23

  
24 24
import org.slf4j.Logger;
25 25
import org.slf4j.LoggerFactory;
26

  
27 26
import org.gvsig.andami.IconThemeHelper;
28 27
import org.gvsig.andami.PluginServices;
29 28
import org.gvsig.andami.plugins.Extension;
30 29
import org.gvsig.andami.ui.mdiManager.IWindow;
31 30
import org.gvsig.app.project.documents.layout.FLayoutGraphics;
31
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification;
32 32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
33
import org.gvsig.tools.observer.Observable;
34
import org.gvsig.tools.observer.Observer;
33 35

  
34 36
/**
35 37
 * Extensi?n que actua sobre el Layout para controlas las diferentes
......
63 65
                layout.getDocument().setModified(true);
64 66
            } else
65 67
                if (s.compareTo("layout-graphic-properties") == 0) {
66
                    if (lg.openFFrameDialog()) {
67
                        layout.getDocument().setModified(true);
68
                    }
68
                	lg.openFrameDialog(new Observer() {
69
						public void update(Observable observable,
70
								Object notification) {
71
							if (notification instanceof FFrameDialogNotification &&
72
									((FFrameDialogNotification)notification).getType()==FFrameDialogNotification.FRAME_CREATED) {
73
								getLayout().getDocument().setModified(true);
74
							}
75
						}
76
                	});
69 77
                } else
70 78
                    if (s.compareTo("layout-graphic-align") == 0) {
71 79
                        lg.aligning();
......
132 140
            return false;
133 141
        return true;
134 142
    }
143
    
144
	protected LayoutPanel getLayout() {
145
		return layout;
146
	}
135 147
}
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/listener/LayoutAddRectangleWithDialogListener.java
27 27
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
28 28
import org.gvsig.app.project.documents.layout.LayoutDocument;
29 29
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
30
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameDialogNotification;
30 31
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
31 32
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32 33
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
33 34
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
35
import org.gvsig.tools.observer.Observable;
36
import org.gvsig.tools.observer.Observer;
34 37

  
35 38
/**
36 39
 * @author gvSIG Team
......
56 59
        r = getRectangle(TOLERANCE);
57 60
        fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layoutPanel
58 61
            .getLayoutControl().getAT()));
59
        IFFrameDialog fframedialog =
62
        final IFFrameDialog fframedialog =
60 63
            layoutManager.createFFrameDialog(fframe, layoutPanel);
61 64
        if (fframedialog != null) {
65
        	fframedialog.addObserver(new Observer() {
66
				public void update(Observable observable, Object notification) {
67
					if (notification instanceof FFrameDialogNotification &&
68
							((FFrameDialogNotification) notification).getType()==FFrameDialogNotification.DIALOG_CLOSED) {
69
				        IFFrame newFrame = fframedialog.getFFrame();
70
				        if (newFrame != null) {
71
				            layoutPanel.getLayoutContext().addFFrame(newFrame, true, true);
72
				        }
73
				        PluginServices.getMainFrame().enableControls();
74
				        layoutPanel.getLayoutControl().refresh();
75
					}
76
				}
77
			});
62 78
            PluginServices.getMDIManager().addWindow(fframedialog);
63 79
        }
64

  
65
        IFFrame newFrame = fframedialog.getFFrame();
66
        if (newFrame != null) {
67
            layoutPanel.getLayoutContext().addFFrame(newFrame, true, true);
68
        }
69
        PluginServices.getMainFrame().enableControls();
70
        layoutPanel.getLayoutControl().refresh();
71 80
    }
72 81

  
73 82
    public abstract String getFFrameName();
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/LayoutSelectListenerImpl.java
186 186

  
187 187
                if (event.getEvent().getClickCount() > 1) {
188 188
                    FLayoutGraphics flg = new FLayoutGraphics(layoutPanel);
189
                    flg.openFFrameDialog();
189
                    flg.openFrameDialog();
190 190
                    layoutPanel.getLayoutContext().updateFFrames();
191 191
                    layoutPanel.getLayoutContext().notifAllObservers();
192 192
                }
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/AbstractFFrameDialog.java
25 25

  
26 26
import org.slf4j.Logger;
27 27
import org.slf4j.LoggerFactory;
28

  
29 28
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
30 29
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
30
import org.gvsig.tools.observer.ObservableHelper;
31
import org.gvsig.tools.observer.Observer;
31 32

  
32 33
/**
33 34
 * @author gvSIG Team
......
44 45

  
45 46
    protected LayoutPanel layoutPanel = null;
46 47
    protected IFFrame frame = null;
48
    private ObservableHelper observableHelper = new ObservableHelper();
47 49

  
48 50
    public AbstractFFrameDialog(LayoutPanel layoutPanel, IFFrame frame) {
49 51
        super();
50 52
        this.layoutPanel = layoutPanel;
51 53
        this.frame = frame;
52 54
    }
55

  
56
	public void addObserver(Observer observer) {
57
		observableHelper.addObserver(observer);
58
	}
59

  
60
	public void deleteObserver(Observer observer) {
61
		observableHelper.deleteObserver(observer);
62
	}
63

  
64
	public void deleteObservers() {
65
		observableHelper.deleteObservers();
66
	}
67

  
68
	protected void notifyDialogClosed() {
69
		observableHelper.notifyObservers(this, new FFrameDialogNotification(FFrameDialogNotification.DIALOG_CLOSED));
70
	}
53 71
}
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/FFrameTextDialog.java
433 433
                    } catch (CloneNotSupportedException e1) {
434 434
                        LOG.error("It is not possible clonate the object", e);
435 435
                    }
436
                    isAcepted = true;
436 437
                    PluginServices.getMDIManager().closeWindow(
437 438
                        FFrameTextDialog.this);
439
                    notifyDialogClosed();
438 440
                    layoutPanel.getLayoutControl().setDefaultTool();
439
                    isAcepted = true;
440 441
                }
441 442
            };
442 443
            cancelAction = new java.awt.event.ActionListener() {
......
445 446
                    newFFrameText = null;
446 447
                    PluginServices.getMDIManager().closeWindow(
447 448
                        FFrameTextDialog.this);
449
                    notifyDialogClosed();
448 450
                }
449 451
            };
450 452
            accept = new AcceptCancelPanel(okAction, cancelAction);
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/FFrameGridDialog.java
461 461
                    }
462 462
                    PluginServices.getMDIManager().closeWindow(
463 463
                        FFrameGridDialog.this);
464
                    notifyDialogClosed();
464 465
                }
465 466
            };
466 467
            cancelAction = new java.awt.event.ActionListener() {
......
469 470
                    newFFrameGrid = null;
470 471
                    PluginServices.getMDIManager().closeWindow(
471 472
                        FFrameGridDialog.this);
473
                    notifyDialogClosed();
472 474
                }
473 475
            };
474 476
            accept = new AcceptCancelPanel(okAction, cancelAction);
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/FFrameDialogNotification.java
1
package org.gvsig.app.project.documents.layout.fframes.gui.dialogs;
2

  
3
import org.gvsig.tools.observer.BaseNotification;
4

  
5
public class FFrameDialogNotification extends BaseNotification {
6
    
7
	public FFrameDialogNotification(String type) {
8
    	super(type, new Object[0]);
9
    }
10
	public static final String DIALOG_CLOSED = "DialogClosed";
11
	public static final String FRAME_CREATED = "FrameCreated";
12
}
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/FFrameOverViewDialog.java
276 276
                    isAcepted = true;
277 277
                    PluginServices.getMDIManager().closeWindow(
278 278
                        FFrameOverViewDialog.this);
279
                    notifyDialogClosed();
279 280
                    layoutPanel.getLayoutControl().setDefaultTool();
280 281
                    fframeoverview.refresh();
281 282
                }
......
302 303
                    newFFrameView = null;
303 304
                    PluginServices.getMDIManager().closeWindow(
304 305
                        FFrameOverViewDialog.this);
306
                    notifyDialogClosed();
305 307
                }
306 308
            });
307 309
        }
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/FFrameBoxDialog.java
43 43
    private static final long serialVersionUID = 8263909754475456840L;
44 44

  
45 45
    /*
46
     * This class is a workarround to eliminate the dedepndency with
46
     * This class is a workaround to eliminate the dependency with
47 47
     * the package de.ios.framework.
48 48
     */
49 49
    private class NumberField extends JTextField {
......
133 133
                        PluginServices.getMDIManager().closeWindow(
134 134
                            FFrameBoxDialog.this);
135 135
                        isAcepted = true;
136
                        notifyDialogClosed();
136 137
                        layoutPanel.getLayoutControl().setDefaultTool();
137 138
                    }
138 139
                },
......
143 144
                        newFFrameBox = null;
144 145
                        PluginServices.getMDIManager().closeWindow(
145 146
                            FFrameBoxDialog.this);
147
                        notifyDialogClosed();
146 148
                    }
147 149
                });
148 150
            this.acceptCancel.setBounds(5, 150, this.getWidth() - 10, 30);
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/IFFrameDialog.java
26 26
import org.gvsig.andami.ui.mdiManager.IWindow;
27 27
import org.gvsig.andami.ui.mdiManager.WindowInfo;
28 28
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
29
import org.gvsig.tools.observer.Observable;
29 30

  
30 31
/**
31 32
 * Interface para la creaci?n de los di?logos que a?aden elementos al Layout.
32 33
 * 
33 34
 * @author Vicente Caballero Navarro
34 35
 */
35
public interface IFFrameDialog extends IWindow {
36
public interface IFFrameDialog extends IWindow, Observable {
36 37

  
37 38
    /**
38 39
     * Sets the bounding box of the fframe being created, in screen
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/FFrameNorthDialog.java
154 154

  
155 155
                            PluginServices.getMDIManager().closeWindow(
156 156
                                FFrameNorthDialog.this);
157
                            isAcepted = true;
158
                            notifyDialogClosed();
157 159
                            layoutPanel.getLayoutControl().setDefaultTool();
158
                            isAcepted = true;
159 160
                        }
160 161
                    }, new java.awt.event.ActionListener() { // Cancel
161 162

  
162 163
                        public void actionPerformed(java.awt.event.ActionEvent e) {
163 164
                            PluginServices.getMDIManager().closeWindow(
164 165
                                FFrameNorthDialog.this);
166
                            notifyDialogClosed();
165 167
                        }
166 168
                    }
167 169

  
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
29 29
import java.awt.event.ActionListener;
30 30
import java.awt.geom.Rectangle2D;
31 31

  
32
import javax.swing.BorderFactory;
33
import javax.swing.ButtonGroup;
32 34
import javax.swing.JButton;
33 35
import javax.swing.JCheckBox;
36
import javax.swing.JLabel;
34 37
import javax.swing.JList;
35 38
import javax.swing.JOptionPane;
36 39
import javax.swing.JPanel;
40
import javax.swing.JRadioButton;
41
import javax.swing.JTextField;
37 42

  
38 43
import org.gvsig.andami.messages.NotificationManager;
44
import org.gvsig.andami.ui.mdiManager.IWindow;
45
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
39 46
import org.gvsig.andami.ui.mdiManager.WindowInfo;
40 47
import org.gvsig.app.ApplicationLocator;
48
import org.gvsig.app.ApplicationManager;
41 49
import org.gvsig.app.project.ProjectManager;
42 50
import org.gvsig.app.project.documents.layout.FLayoutUtilities;
43 51
import org.gvsig.app.project.documents.layout.LayoutManager;
44 52
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid;
45 53
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
46 54
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
55
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap.SCALE_TYPE;
47 56
import org.gvsig.app.project.documents.layout.fframes.ListViewModel;
57
import org.gvsig.app.project.documents.layout.fframes.gui.EnvelopePanel;
48 58
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation;
49 59
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
50 60
import org.gvsig.app.project.documents.view.DefaultViewDocument;
61
import org.gvsig.app.project.documents.view.ViewDocument;
62
import org.gvsig.fmap.geom.primitive.Envelope;
51 63
import org.gvsig.fmap.mapcontext.ViewPort;
64
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
52 65
import org.gvsig.i18n.Messages;
66
import org.gvsig.tools.observer.Observer;
67
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
53 68

  
54 69
/**
55 70
 * Dialog to add a view to the Layout document, by means of a FFrameView
......
58 73
 * @author Cesar Martinez Izquierdo
59 74
 */
60 75
public class FFrameViewDialog extends AbstractFFrameDialog implements
61
    IFFrameDialog {
76
    IFFrameDialog, SingletonWindow {
62 77

  
63 78
    private static final long serialVersionUID = -7223804566537544559L;
64 79
    
......
74 89
    private javax.swing.JComboBox cbCalidad = null;
75 90
    private DefaultViewDocument m_projectView = null;
76 91
    private Rectangle2D rect = new Rectangle2D.Double();
77
    private FFrameView fframeview = null; // new FFrameView();
92
    private FFrameView fframeview = null;
78 93
    private boolean isAcepted = false;
79 94
    private JPRotation rotation = null;
80 95
    private FFrameView newFFrameView = null;
......
85 100
	
86 101
	private WindowInfo windowInfo = null;
87 102

  
103
	private GridBagLayoutPanel pnlSyncGroup = null;
104
	private GridBagLayoutPanel pnlScaleTypeGroup = null;
105
	private ButtonGroup grpScaleType = null;
106
	private JRadioButton btnNormalScale = null;
107
	private JRadioButton btnFixedScale = null;
108
	private JRadioButton btnFixedExtent = null;
109
	private JTextField fldScale = null;
110
	private EnvelopePanel pnlExtent = null;
111
	private JButton btConfigView = null;
112
	private JPanel pnlScale = null;
88 113

  
114

  
89 115
    /**
90 116
     * This is the default constructor
91 117
     * 
......
120 146
        c.gridx = 0;
121 147
        c.gridy = row++;
122 148
        c.gridwidth = GridBagConstraints.REMAINDER;
123
        add(getChbSyncLayers(), c);
124
        c.insets = insets;
125
        c.gridx = 0;
149
        c.fill = GridBagConstraints.HORIZONTAL;
150
        
151
        GridBagLayoutPanel pnl = getPnlSyncGroup();
152
        pnl.addComponent(getChbSyncLayers(), insets);
153
        pnl.addComponent(getChbSyncExtent(), insets);
154
        add(pnl, c);
155
        
156
        getGrpScaleType().add(getBtnNormalScale());
157
        getGrpScaleType().add(getBtnFixedScale());
158
        getGrpScaleType().add(getBtnFixedExtent());
159
        
160
        pnl = getPnlScaleTypeGroup();
161
        pnl.addComponent(getBtnNormalScale(), insets);
162
        pnl.addComponent(getPnlScale(), insets); // pnlScale() contains btnFixedScale
163
        pnl.addComponent(getBtnFixedExtent(), new Insets(5, 5, 0, 5));
164
        pnl.addComponent(getPnlExtent(), GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5));
165
        if (fframeview.getScaleType()==SCALE_TYPE.FIXED_SCALE) {
166
        	getBtnFixedScale().setSelected(true);
167
        	scaleTypeSet(SCALE_TYPE.FIXED_SCALE);
168
        }
169
        else if (fframeview.getScaleType()==SCALE_TYPE.FIXED_EXTENT) {
170
        	getBtnFixedExtent().setSelected(true);
171
        	scaleTypeSet(SCALE_TYPE.FIXED_EXTENT);
172
        }
173
        else {
174
        	getBtnNormalScale().setSelected(true);
175
        	scaleTypeSet(SCALE_TYPE.NORMAL);
176
        }
177
        
126 178
        c.gridy = row++;
127
        c.gridwidth = GridBagConstraints.REMAINDER;
128
        add(getChbSyncExtent(), c);
179
        add(pnl, c);
180
        
181
        c.fill = GridBagConstraints.NONE;
129 182
        c.gridx = 0;
130 183
        c.gridy = row++;
131 184
        c.gridwidth = 1;
......
164 217
    		pnlFirstRow  = new JPanel(new GridBagLayout());
165 218
    		GridBagConstraints c = new GridBagConstraints();
166 219
            Insets insets = new Insets(5, 5, 5, 5);
220
            Insets insetsTop = new Insets(12, 5, 5, 5);
167 221
            c.gridx = 0;
168
            c.gridy = 1;
169
            c.insets = insets;
222
            c.gridy = 0;
223
            c.insets = insetsTop;
170 224
            c.anchor = GridBagConstraints.PAGE_START;
171 225
            pnlFirstRow.add(getLViews(), c);
172 226
            c.gridx = 1;
173 227
            pnlFirstRow.add(getScrolledViewList(), c);
228
            c.insets = insets;
174 229
            c.gridx = 2;
230
            c.gridheight = 2;
175 231
            pnlFirstRow.add(getPRotation(), c);
232
            c.anchor = GridBagConstraints.LINE_END;
233
            c.gridy = 1;
234
            c.gridx = 1;
235
            c.gridheight = 1;
236
            pnlFirstRow.add(getBtnConfigView(), c);
176 237
    	}
177 238
    	return pnlFirstRow; 
178 239
    }
240
    
241
    protected ViewDocument getSelectedView() {
242
    	Object selected = getViewList().getSelectedValue();
243
    	if (selected instanceof ViewDocument) {
244
    		return (ViewDocument) selected;
245
    	}
246
    	return null;
247
    }
248
    
249
    private JButton getBtnConfigView() {
250
		UsabilitySwingManager manager = org.gvsig.tools.swing.api.ToolsSwingLocator.getUsabilitySwingManager();
251
		btConfigView = manager.createJButton(Messages.getText("Configure_view"));
252
		btConfigView.addActionListener(new ActionListener() {
253
			public void actionPerformed(ActionEvent e) {
254
				ViewDocument view = getSelectedView();
255
				if (view!=null) {
256
					IWindow propWin = view.getPropertiesWindow();
257
					ApplicationManager manager = ApplicationLocator.getManager();
258
					manager.getUIManager().addWindow(propWin);
259
				}
260
			}
261
		});
262
    	return btConfigView;
263
    }
179 264

  
180 265
    /**
181 266
     * This method initializes lVistas
......
310 395
    	}
311 396
    	return chbSyncExtent;
312 397
    }
398
    
399
    protected void disableChbSyncExtent() {
400
    	getChbSyncExtent().setEnabled(false);
401
    	getChbSyncExtent().setToolTipText(Messages.getText("Extent_cant_be_synchronized_when_using_fixed_scale_or_fixed_extent"));
402
    }
403
    
404
    protected void enableChbSyncExtent() {
405
    	getChbSyncExtent().setEnabled(true);
406
    	getChbSyncExtent().setToolTipText(null);
407
    }
313 408

  
314 409
    /**
315 410
     * This method initializes jButton
......
332 427
                        newFFrameView.setLayerSynced(getChbSyncLayers()
333 428
                                .isSelected());
334 429
                        newFFrameView.setExtentSynced(getChbSyncExtent().isSelected());
335

  
430
                        try {
431
                        	if (getBtnFixedScale().isSelected()) {
432
                        		Double d = Double.parseDouble(getFldScale().getText());
433
                        		newFFrameView.setScaleType(SCALE_TYPE.FIXED_SCALE, d);
434
                        	}
435
                        	else if (getBtnFixedExtent().isSelected()) {
436
                        		Envelope envelope = getPnlExtent().getEnvelope();
437
                        		if (envelope!=null) {
438
                        			newFFrameView.setScaleType(SCALE_TYPE.FIXED_EXTENT, envelope);
439
                        		}
440
                        		else {
441
                        			newFFrameView.setScaleType(SCALE_TYPE.NORMAL);
442
                        		}
443
                        	}
444
                        	else {
445
                        		newFFrameView.setScaleType(SCALE_TYPE.NORMAL);
446
                        	}
447
                        }
448
                        catch (Exception ex) {
449
                        	newFFrameView.setScaleType(SCALE_TYPE.NORMAL);
450
                        }
336 451
                        if (m_projectView != null) {
337 452
                            newFFrameView.setView(m_projectView);
338 453
                            newFFrameView.setQuality(getCbCalidad()
......
354 469
                    isAcepted = true;
355 470
                    ApplicationLocator.getManager().getUIManager().closeWindow(
356 471
                        FFrameViewDialog.this);
472
                    notifyDialogClosed();
357 473
                    layoutPanel.getLayoutControl().setDefaultTool();
358 474
                }
359 475
            });
......
377 493
                    newFFrameView = null;
378 494
                    ApplicationLocator.getManager().getUIManager().closeWindow(
379 495
                        FFrameViewDialog.this);
496
                    notifyDialogClosed();
380 497
                }
381 498
            });
382 499
        }
......
422 539
     */
423 540
    public WindowInfo getWindowInfo() {
424 541
    	if (windowInfo==null) {
425
    		windowInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
426
    		windowInfo.setHeight(300);
542
    		windowInfo = new WindowInfo(WindowInfo.RESIZABLE);
543
    		windowInfo.setHeight(600);
427 544
    		windowInfo.setWidth(550);
428 545
    		windowInfo.setTitle(Messages.getText(
429 546
    				"propiedades_marco_vista"));
......
507 624
        }
508 625
        return chbShowGrid;
509 626
    }
627
    
628
    private GridBagLayoutPanel getPnlSyncGroup() {
629
    	if (pnlSyncGroup ==null) {
630
    		pnlSyncGroup = new GridBagLayoutPanel();
631
    		pnlSyncGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText("Synchronization_of_the_view_and_the_frame_view")));
632
    	}
633
    	return pnlSyncGroup;
634
    }
635
    
636
    private GridBagLayoutPanel getPnlScaleTypeGroup() {
637
    	if (pnlScaleTypeGroup ==null) {
638
    		pnlScaleTypeGroup  = new GridBagLayoutPanel();
639
    		pnlScaleTypeGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText("Fixed_scale_and_extent")));
640
    	}
641
    	return pnlScaleTypeGroup;
642
    }
643
    
644
    private ButtonGroup getGrpScaleType() {
645
    	if (grpScaleType==null) {
646
    		grpScaleType  = new ButtonGroup();
647
    	}
648
    	return grpScaleType;
649
    }
650
    
651
    private JRadioButton getBtnNormalScale() {
652
    	if (btnNormalScale==null) {
653
    		btnNormalScale  = new JRadioButton(Messages.getText("Non_fixed"));
654
    		btnNormalScale.addActionListener(new ActionListener() {
655
				public void actionPerformed(ActionEvent e) {
656
					FFrameViewDialog.this.scaleTypeSet(SCALE_TYPE.NORMAL);
657
					FFrameViewDialog.this.enableChbSyncExtent();
658
				}
659
			});
660
    	}
661
    	return btnNormalScale;
662
    }
663
    
664
    private JRadioButton getBtnFixedScale() {
665
    	if (btnFixedScale==null) {
666
    		btnFixedScale  = new JRadioButton(Messages.getText("Fixed_scale"));
667
    		btnFixedScale.addActionListener(new ActionListener() {
668
				public void actionPerformed(ActionEvent e) {
669
					FFrameViewDialog.this.scaleTypeSet(SCALE_TYPE.FIXED_SCALE);
670
					FFrameViewDialog.this.disableChbSyncExtent();
671
				}
672
			});
673
    	}
674
    	return btnFixedScale;
675
    }
676
    
677
    private JPanel getPnlScale() {
678
    	if (pnlScale==null) {
679
    		pnlScale  = new JPanel(new GridBagLayout());
680
    		GridBagConstraints c = new GridBagConstraints();
681
    		c.insets = new Insets(0, 0, 0, 0);
682
    		c.gridx = 0;
683
    		pnlScale.add(getBtnFixedScale());
684
    		c.anchor = GridBagConstraints.LINE_START;
685
    		c.gridx = 1;
686
    		c.insets = new Insets(0, 25, 0, 5);
687
    		c.anchor = GridBagConstraints.LINE_END;
688
    		pnlScale.add(getLblScale(), c);
689
    		c.gridx = 2;
690
    		c.insets = new Insets(0, 5, 0, 5);;
691
    		c.anchor = GridBagConstraints.LINE_START;
692
    		pnlScale.add(getFldScale(), c);
693
    	}
694
    	return pnlScale;
695
    }
696
    
697
    private JTextField getFldScale() {
698
		if (fldScale==null) {
699
    		fldScale  = new JTextField(8);
700
    		if (fframeview!=null &&
701
    				fframeview.getMapContext()!=null &&
702
    				fframeview.getMapContext().getViewPort().getEnvelope()!=null) {
703
    			fldScale.setText(Long.toString(fframeview.getMapContext().getScaleView()));
704
    		}
705
    	}
706
    	return fldScale;
707
    }
708
    
709
    private JLabel getLblScale() {
710
    	return new JLabel(Messages.getText("1__"));
711
    }
712
    
713
    private JRadioButton getBtnFixedExtent() {
714
    	if (btnFixedExtent==null) {
715
    		btnFixedExtent   = new JRadioButton(Messages.getText("Fixed_extent"));
716
    		btnFixedExtent.addActionListener(new ActionListener() {
717
				public void actionPerformed(ActionEvent e) {
718
					FFrameViewDialog.this.scaleTypeSet(SCALE_TYPE.FIXED_EXTENT);
719
					FFrameViewDialog.this.disableChbSyncExtent();
720
				}
721
			});
722
    	}
723
    	return btnFixedExtent;
724
    }
725
    
726
    private EnvelopePanel getPnlExtent() {
727
    	if (pnlExtent==null) {
728
    		pnlExtent  = new EnvelopePanel();
729
    		if (fframeview!=null &&
730
    				fframeview.getMapContext()!=null &&
731
    				fframeview.getMapContext().getViewPort().getEnvelope()!=null) {
732
    			pnlExtent.setEnvelope(fframeview.getMapContext().getViewPort().getEnvelope());
733
    		}
734
    	}
735
    	return pnlExtent;
736
    }
510 737

  
511 738
    public Object getWindowProfile() {
512 739
        return WindowInfo.DIALOG_PROFILE;
513 740
    }
514 741

  
742
	public Object getWindowModel() {
743
		return fframeview;
744
	}
745
	
746
	protected void scaleTypeSet(SCALE_TYPE type) {
747
		if (type==SCALE_TYPE.NORMAL) {
748
			getFldScale().setEditable(false);
749
			getFldScale().setEnabled(false);
750
			getPnlExtent().setEditable(false);
751
			getPnlExtent().setEnabled(false);
752
		}
753
		else if (type==SCALE_TYPE.FIXED_SCALE) {
754
			getFldScale().setEditable(true);
755
			getFldScale().setEnabled(true);
756
			getPnlExtent().setEditable(false);
757
			getPnlExtent().setEnabled(false);
758
		}
759
		else if (type==SCALE_TYPE.FIXED_EXTENT) {
760
			getFldScale().setEditable(false);
761
			getFldScale().setEnabled(false);
762
			getPnlExtent().setEditable(true);
763
			getPnlExtent().setEnabled(true);
764
		}
765
		
766
	}
767
	
768
	protected SCALE_TYPE getSelectedScaleType() {
769
		if (getBtnFixedScale().isSelected()) {
770
			return SCALE_TYPE.FIXED_SCALE;
771
		}
772
		else if (getBtnFixedExtent().isSelected()) {
773
			return SCALE_TYPE.FIXED_EXTENT;
774
		}
775
		return SCALE_TYPE.NORMAL;		
776
	}
777

  
515 778
} // @jve:decl-index=0:visual-constraint="10,10"
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/FFramePictureDialog.java
340 340
                    } catch (CloneNotSupportedException e1) {
341 341
                        LOG.error("It is not possible clonate the object", e);
342 342
                    }
343

  
343
                    isAcepted = true;
344 344
                    PluginServices.getMDIManager().closeWindow(
345 345
                        FFramePictureDialog.this);
346
                    notifyDialogClosed();
346 347
                    layoutPanel.getLayoutControl().setDefaultTool();
347
                    isAcepted = true;
348 348
                }
349 349
            });
350 350
        }
......
369 369
                    newFFramePicture = null;
370 370
                    PluginServices.getMDIManager().closeWindow(
371 371
                        FFramePictureDialog.this);
372
                    notifyDialogClosed();
372 373
                }
373 374
            });
374 375
        }
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/FFrameGroupDialog.java
128 128
                    }
129 129
                    PluginServices.getMDIManager().closeWindow(
130 130
                        FFrameGroupDialog.this);
131
                    // m_layout.refresh();
132 131
                    isAcepted = true;
132
                    notifyDialogClosed();
133 133
                }
134 134
            });
135 135
        }
......
153 153
                public void actionPerformed(java.awt.event.ActionEvent e) {
154 154
                    PluginServices.getMDIManager().closeWindow(
155 155
                        FFrameGroupDialog.this);
156
                    notifyDialogClosed();
156 157
                }
157 158
            });
158 159
        }
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/FFrameScaleBarDialog.java
605 605
                        .getText()));
606 606
                    fframescalebar.setNumLeft(Integer
607 607
                        .parseInt(getTDivIzquierda().getText()));
608
                    isAcepted = true;
608 609
                    PluginServices.getMDIManager().closeWindow(
609 610
                        FFrameScaleBarDialog.this);
611
                    notifyDialogClosed();
610 612
                    layoutPanel.getLayoutControl().setDefaultTool();
611
                    isAcepted = true;
612 613
                }
613 614
            });
614 615
        }
......
634 635
                    fframescalebar = null;
635 636
                    PluginServices.getMDIManager().closeWindow(
636 637
                        FFrameScaleBarDialog.this);
638
                    notifyDialogClosed();
637 639
                }
638 640
            });
639 641
        }
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/FFrameLegendDialog.java
290 290

  
291 291
                    PluginServices.getMDIManager().closeWindow(
292 292
                        FFrameLegendDialog.this);
293
                    notifyDialogClosed();
293 294
                    layoutPanel.getLayoutControl().setDefaultTool();
294 295
                    isAcepted = true;
295 296
                }
......
300 301
                    newFFrameLegend = null;
301 302
                    PluginServices.getMDIManager().closeWindow(
302 303
                        FFrameLegendDialog.this);
304
                    notifyDialogClosed();
303 305
                }
304 306
            };
305 307
            accept = new AcceptCancelPanel(okAction, cancelAction);
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
28 28

  
29 29
import org.slf4j.Logger;
30 30
import org.slf4j.LoggerFactory;
31

  
32 31
import org.gvsig.andami.PluginServices;
33 32
import org.gvsig.andami.ui.mdiManager.WindowInfo;
34 33
import org.gvsig.app.gui.styling.SymbolSelector;
......
38 37
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
39 38
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
40 39
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
40
import org.gvsig.tools.observer.ObservableHelper;
41
import org.gvsig.tools.observer.Observer;
41 42

  
42 43
/**
43 44
 * Di?logo de las propiedades de los gr?ficos.
......
59 60
    private FFrameGraphics fframegraphics = null;
60 61
    private JPRotation pRotation = null;
61 62
    private FFrameGraphics newFFrameGraphics;
63
    private ObservableHelper observableHelper = new ObservableHelper();
62 64

  
65

  
63 66
    public FFrameGraphicsDialog(LayoutPanel layout, FFrameGraphics fframe) {
64 67
        super(fframe.getFSymbol(), fframe.getType(), null, true);
65 68
        m_layout = layout;
......
86 89
                    m_layout.getLayoutContext().updateFFrames();
87 90
                    m_layout.getLayoutControl().refresh();
88 91
                    isAcepted = true;
92
                    FFrameGraphicsDialog.this.notifyDialogClosed();
89 93
                } catch (CloneNotSupportedException e1) {
90 94
                    LOG.error("It is not possible clonate the object", e);
91 95
                }
92 96
            }
93 97
        };
98
        
99
        ActionListener cancelAction = new ActionListener() {
100
			public void actionPerformed(ActionEvent e) {
101
				isAcepted = false;
102
				FFrameGraphicsDialog.this.notifyDialogClosed();
103
			}
104
        };
105
        
94 106
        okCancelPanel.addOkButtonActionListener(okAction);
107
        okCancelPanel.addCancelButtonActionListener(cancelAction);
95 108
    }
96 109

  
97 110
    /**
......
153 166
    public IFFrame getFFrame() {
154 167
        return newFFrameGraphics;
155 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
	}
156 186
} 
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/EnvelopePanel.java
1
package org.gvsig.app.project.documents.layout.fframes.gui;
2

  
3
import java.awt.GridBagConstraints;
4
import java.awt.GridBagLayout;
5
import java.awt.Insets;
6
import java.text.DecimalFormat;
7
import java.text.NumberFormat;
8
import java.text.ParseException;
9

  
10
import javax.swing.JLabel;
11
import javax.swing.JPanel;
12
import javax.swing.JTextField;
13
import javax.swing.text.NumberFormatter;
14

  
15
import org.gvsig.fmap.geom.Geometry;
16
import org.gvsig.fmap.geom.GeometryLocator;
17
import org.gvsig.fmap.geom.GeometryManager;
18
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
19
import org.gvsig.fmap.geom.primitive.Envelope;
20
import org.gvsig.i18n.Messages;
21
import org.slf4j.LoggerFactory;
22

  
23

  
24
public class EnvelopePanel extends JPanel {
25
	private static final long serialVersionUID = -1828624765045725544L;
26
	private JTextField fldTop = null;
27
	private JTextField fldLeft = null;
28
	private JTextField fldRight = null;
29
	private JTextField fldBottom = null;
30
	private static final GeometryManager geoMgr = GeometryLocator.getGeometryManager();
31
	private int fieldWidth;
32
	private DecimalFormat formatLatLon = new DecimalFormat("0.######");
33
	private DecimalFormat formatMetres = new DecimalFormat("0.##");
34
	
35
	public EnvelopePanel() {
36
		this(8);
37
	}
38
	
39
	public EnvelopePanel(int fieldWidth) {
40
		super(new GridBagLayout());
41
		this.fieldWidth = fieldWidth;
42
		initComponents();
43
	}
44
	
45
	protected void initComponents() {
46
		int row = 0;
47
		GridBagConstraints c = new GridBagConstraints();
48
		c.gridy = row++;
49
		c.gridx = 1;
50
		c.anchor = GridBagConstraints.LINE_END;
51
		c.insets = new Insets(0, 5, 5, 5);
52
		JLabel label = new JLabel(Messages.getText("Top_extent_lbl"));
53
		add(label, c);
54
		c.gridx = 2;
55
		c.anchor = GridBagConstraints.LINE_START;
56
		add(getFldTop(), c);
57
		
58
		c.gridy = row++;
59
		c.gridx = 0;
60
		c.insets = new Insets(5, 0, 5, 5);
61
		c.anchor = GridBagConstraints.LINE_END;
62
		label = new JLabel(Messages.getText("Left_extent_lbl"));
63
		add(label, c);
64
		c.gridx = 1;
65
		c.insets = new Insets(5, 5, 5, 5);
66
		c.anchor = GridBagConstraints.LINE_START;
67
		add(getFldLeft(), c);		
68

  
69
		c.gridx = 3;
70
		c.anchor = GridBagConstraints.LINE_END;
71
		label = new JLabel(Messages.getText("Right_extent_lbl"));
72
		add(label, c);
73
		c.gridx = 4;
74
		c.anchor = GridBagConstraints.LINE_START;
75
		c.insets = new Insets(5, 5, 5, 0);
76
		add(getFldRight(), c);
77
		
78
		c.gridy = row++;
79
		c.gridx = 1;
80
		c.anchor = GridBagConstraints.LINE_END;
81
		label = new JLabel(Messages.getText("Bottom_extent_lbl"));
82
		c.insets = new Insets(5, 5, 0, 5);
83
		add(label, c);
84
		c.gridx = 2;
85
		c.anchor = GridBagConstraints.LINE_START;
86
		add(getFldBottom(), c);
87
	}
88
	
89
	private JTextField getFldTop() {
90
		if (fldTop==null) {
91
			fldTop  = new JTextField(fieldWidth);
92
		}
93
		return fldTop;
94
	}
95
	
96
	private JTextField getFldLeft() {
97
		if (fldLeft==null) {
98
			fldLeft = new JTextField(fieldWidth);
99
		}
100
		return fldLeft;
101
	}
102
	
103
	private JTextField getFldRight() {
104
		if (fldRight==null) {
105
			fldRight  = new JTextField(fieldWidth);
106
		}
107
		return fldRight;
108
	}
109
	
110
	private JTextField getFldBottom() {
111
		if (fldBottom==null) {
112
			fldBottom  = new JTextField(fieldWidth);
113
		}
114
		return fldBottom;
115
	}
116
	
117
	public Envelope getEnvelope() {
118
		double minX = 0.0, minY=0.0, maxX=0.0, maxY=0.0;
119
		try {
120
			maxY = formatMetres.parse(getFldTop().getText()).doubleValue();
121
			maxX = formatMetres.parse(getFldRight().getText()).doubleValue();
122
			minY = formatMetres.parse(getFldBottom().getText()).doubleValue();
123
			minX = formatMetres.parse(getFldLeft().getText()).doubleValue();
124
		} catch (ParseException e1) {
125
			try {
126
				maxY = Double.parseDouble(getFldTop().getText().replaceAll(",", "."));
127
				maxX = Double.parseDouble(getFldRight().getText().replaceAll(",", "."));
128
				minY = Double.parseDouble(getFldBottom().getText().replaceAll(",", "."));
129
				minX = Double.parseDouble(getFldLeft().getText().replaceAll(",", "."));
130
			} catch (NumberFormatException e2) {
131
				LoggerFactory.getLogger(EnvelopePanel.class).error("Error parsing envelope", e1);
132
				return null;
133
			}
134
		}
135
		try {
136
			return geoMgr.createEnvelope(minX, minY, maxX, maxY, Geometry.SUBTYPES.GEOM2D);
137
		} catch (CreateEnvelopeException e) {
138
			LoggerFactory.getLogger(EnvelopePanel.class).error("Error creating envelope", e);
139
			return null;
140
		}
141
	}
142
	
143
	public void setEnvelope(Envelope envelope) {
144
		double top = envelope.getMaximum(1);
145
		double left = envelope.getMinimum(0);
146
		double right = envelope.getMaximum(0);
147
		double bottom = envelope.getMinimum(1);
148
		DecimalFormat format;
149
		if (top>Math.abs(90.0d) || left>Math.abs(180.0d) ||
150
				right>Math.abs(180.0d) || bottom>Math.abs(90.0d)) {
151
			format = formatMetres;
152
		}
153
		else {
154
			format = formatLatLon;
155
		}
156
		String topStr = format.format(top);
157
		getFldTop().setText(topStr);
158
		String leftStr = format.format(left);
159
		getFldLeft().setText(leftStr);
160
		String rightStr = format.format(right);
161
		getFldRight().setText(rightStr);
162
		String bottomStr = format.format(bottom);
163
		getFldBottom().setText(bottomStr);
164
	}
165
	
166
	public void setEditable(boolean editable) {
167
		getFldTop().setEditable(editable);
168
		getFldLeft().setEditable(editable);
169
		getFldRight().setEditable(editable);
170
		getFldBottom().setEditable(editable);
171
	}
172
}
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/IFFrameUseFMap.java
48 48
     */
49 49
    public MapContext getMapContext();
50 50

  
51
    /**
52
     * Invalidates the FFrameView cache, which will cause the
53
     * FFrame to be repainted on the next drawing cycle.
54
     */
51 55
    public void refresh();
52 56

  
53 57
    /**
54
     * Sets a new Envelope on the MapContext contained in
55
     * this FFrameView
58
     * Sets the extent of the MapContext contained in this FFrameView. It will
59
     * be ignored if {@link #getScaleType()} equals to
60
     * {@link SCALE_TYPE#FIXED_SCALE} or {@link SCALE_TYPE#FIXED_EXTENT}
56 61
     * 
57 62
     * @param r Envelope to be set
58 63
     */
......
128 133
    public void setExtentSynced(boolean synced);
129 134
    
130 135
    /**
131
     * Sets the scale of the MapContext contained in this FFrameView
136
     * Sets the scale of the MapContext contained in this FFrameView. It will
137
     * be ignored if {@link #getScaleType()} equals to
138
     * {@link SCALE_TYPE#FIXED_SCALE} or {@link SCALE_TYPE#FIXED_EXTENT} 
132 139
     * 
133 140
     * @param d Scale to be set
134 141
     */
135 142
    public void setScale(double d);
143
    
144
    public static enum SCALE_TYPE {
145
    	/**
146
    	 * The scale and extent can be changed without restrictions 
147
    	 */
148
    	NORMAL,
149
    	/**
150
    	 * The scale has been fixed, so pans are enabled but the scale
151
    	 * can't be changed and the zoom in/out tools also behave as
152
    	 * pans. 
153
    	 */
154
    	FIXED_SCALE,
155
    	/**
156
    	 * The extent has been fixed, so the scale can't be changed and
157
    	 * the pan and zoom tools will not produce any change 
158
    	 */
159
    	FIXED_EXTENT
160
    };
161
    
162
    /**
163
     * Gets the scale and extent types. It can be one of the following:
164
     * {@link SCALE_TYPE#NORMAL}, {@link SCALE_TYPE#FIXED_SCALE}
165
     * or {@link SCALE_TYPE#FIXED_EXTENT}
166
     * 
167
     * @return The scale type
168
     */
169
    public SCALE_TYPE getScaleType();
170
    
171

  
172
    /**
173
     * Sets the scale and extent types. It can be one of the following:
174
     * {@link SCALE_TYPE#NORMAL}, {@link SCALE_TYPE#FIXED_SCALE}
175
     * or {@link SCALE_TYPE#FIXED_EXTENT}
176
     * 
177
     * @return The scale type
178
     */
179
    public void setScaleType(SCALE_TYPE scaleType);
180
    
181
    /*    
182
    DEPRECATED METHODS AND CONSTANTS, KEPT FOR THE MOMENT FOR
183
    BACKWARD-COMPATIBILITY. THEY SHOULD BE REMOVED ON FUTURE RELEASES
184
     */
185
    /**
186
     * Kept for the moment for backward-compatibility, it will be
187
     * removed on the future.
188
     * 
189
     * @Deprecated Replaced by {@link #getExtentSynced()},
190
     * {@link #setExtentSynced(boolean)}, {@link #getLayerSynced()},
191
     * {@link #setLayerSynced(boolean)}, {@link #getScaleType()}
192
     * and {@link #setScaleType(SCALE_TYPE)}.
193
     */
194
    @Deprecated
195
    public static final int AUTOMATICO = 0;
196
    /**
197
     * Kept for the moment for backward-compatibility, it will be
198
     * removed on the future.
199
     * 
200
     * @Deprecated Replaced by {@link #getExtentSynced()},
201
     * {@link #setExtentSynced(boolean)}, {@link #getLayerSynced()},
202
     * {@link #setLayerSynced(boolean)}, {@link #getScaleType()}
203
     * and {@link #setScaleType(SCALE_TYPE)}.
204
     */
205
    @Deprecated
206
    public static final int CONSTANTE = 1;
207
    /**
208
     * @Deprecated Replaced by {@link #getExtentSynced()},
209
     * {@link #setExtentSynced(boolean)}, {@link #getLayerSynced()},
210
     * {@link #setLayerSynced(boolean)}, {@link #getScaleType()}
211
     * and {@link #setScaleType(SCALE_TYPE)}.
212
     */
213
    @Deprecated
214
    public static final int MANUAL = 2;
215

  
216
    /**
217
     * Kept for the moment for backward-compatibility, it will be
218
     * removed on the future.
219
     * @Deprecated Replaced by {@link #getExtentSynced()},
220
     * {@link #setExtentSynced(boolean)}, {@link #getLayerSynced()},
221
     * {@link #setLayerSynced(boolean)}, {@link #getScaleType()}
222
     * and {@link #setScaleType(SCALE_TYPE)}.
223
     */
224
    @Deprecated
225
    public int getTypeScale();
226

  
227
    
228
    /**
229
     * Kept for the moment for backward-compatibility, it will be
230
     * removed on the future.
231
     * 
232
     * @Deprecated Replaced by {@link #getExtentSynced()},
233
     * {@link #setExtentSynced(boolean)}, {@link #getLayerSynced()},
234
     * {@link #setLayerSynced(boolean)}, {@link #getScaleType()}
235
     * and {@link #setScaleType(SCALE_TYPE)}.
236
     */
237
    @Deprecated
238
    public void setLinked(boolean b);
239

  
240
    /**
241
     * Kept for the moment for backward-compatibility, it will be
242
     * removed on the future.
243
     * 
244
     * @Deprecated Replaced by {@link #getExtentSynced()},
245
     * {@link #setExtentSynced(boolean)}, {@link #getLayerSynced()},
246
     * {@link #setLayerSynced(boolean)}, {@link #getScaleType()}
247
     * and {@link #setScaleType(SCALE_TYPE)}.
248
     */
249
    @Deprecated
250
    public boolean getLinked();
136 251
}
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameView.java
119 119
    private static final String HAS_TOC_FIELD = "hasToc";
120 120
    private static final String LAYER_SYNC_FIELD = "layerSync";
121 121
    private static final String EXTENT_SYNC_FIELD = "extentSync";
122
    private static final String SCALE_TYPE_FIELD = "scaleType";
122 123
    // following fields are unused - they are kept for backward-compatibility 
123 124
    private static final String EXTENSION_FIELD = "extension";
124 125
    private static final String BLINKED_FIELD = "bLinked";
......
131 132
        .getLogger(FFrameView.class);
132 133
    public static final int PRESENTATION = 0;
133 134
    public static final int DRAFT = 1;
135

  
134 136
    protected boolean syncLayers = true;
135 137
    protected boolean syncExtents = true;
136 138
    protected int quality = PRESENTATION;
......
167 169
	protected AffineTransform originalGraphicsAT = null;
168 170
	protected Rectangle originalClip = null;
169 171

  
172
	private SCALE_TYPE scaleType = SCALE_TYPE.NORMAL;
173
	private Double fixedScale = null;
174
	private Envelope fixedExtent = null;
170 175

  
176

  
171 177
    /**
172 178
     * Creates a new FFrameView object.
173 179
     */
......
294 300
    					.getViewPort().clone());
295 301
    		}
296 302
    		ViewPort newViewPort = getMapContext().getViewPort();
303
    		if (!syncExtents && oldViewEnvelope!=null) {
304
    			// if extent is not synced with the view, restore the previous
305
    			// envelope if existing
306
    			newViewPort.setEnvelope(oldViewEnvelope);
307
    		}
297 308
    		AffineTransform at;
298 309
    		if (getLayoutContext()!=null) {
299 310
    			at = getLayoutContext().getAT();
......
323 334
     */
324 335
    public void setView(ViewDocument dvd) {
325 336
    	ViewDocument oldDoc = viewDocument;
326
    	if (oldDoc!=null && oldDoc.getMapContext()!=null) {
327
    		clearViewListeners(oldDoc.getMapContext());
337
    	if (oldDoc!=null) {
338
    		if (oldDoc!=dvd) {
339
    			// Remove the oldEnvelope if the view has changed
340
    			oldViewEnvelope = null;
341
    		}
342
    		else {
343
    			if (getMapContext()!=null && getMapContext().getViewPort()!=null) {
344
    				oldViewEnvelope = getMapContext().getViewPort().getAdjustedEnvelope();
345
    			}
346
    		}
347
    		if (oldDoc.getMapContext()!=null) {
348
    			clearViewListeners(oldDoc.getMapContext());
349
    		}
328 350
    	}
329 351
        viewDocument = dvd;
330 352
        if (dvd!=null) {
......
840 862
            DynStruct definition =
841 863
                manager.addDefinition(FFrameView.class,
842 864
                    PERSISTENCE_DEFINITION_NAME,
843
                    "FFrameView persistence definition", null, null); 
865
                    "FFrameView persistence definition", null, null);
844 866
            definition.extend(manager
845 867
                .getDefinition(FFrame.PERSISTENCE_DEFINITION_NAME));
846 868
            definition.addDynFieldInt(QUALITY_FIELD).setMandatory(true);
......
856 878
            definition.addDynFieldBoolean(HAS_TOC_FIELD).setMandatory(false);
857 879
            definition.addDynFieldBoolean(EXTENT_SYNC_FIELD).setMandatory(false);
858 880
            definition.addDynFieldBoolean(LAYER_SYNC_FIELD).setMandatory(false);
881
            definition.addDynFieldInt(SCALE_TYPE_FIELD).setMandatory(false);
859 882
            // unused fields, kept for backward compatibility
860 883
            definition.addDynFieldInt(MODE_FIELD).setMandatory(false);
861 884
            definition.addDynFieldInt(TYPESCALE_FIELD).setMandatory(false);
......
884 907
        else {
885 908
        	syncLayers = true;
886 909
        }
910
        if (state.hasValue(SCALE_TYPE_FIELD)) {
911
        	int value = state.getInt(SCALE_TYPE_FIELD);
912
        	if (value==SCALE_TYPE.FIXED_EXTENT.ordinal()) {
913
        		scaleType = SCALE_TYPE.FIXED_EXTENT;
914
        	}
915
        	else if (value==SCALE_TYPE.FIXED_SCALE.ordinal()) {
916
        		scaleType = SCALE_TYPE.FIXED_SCALE;
917
        	}
918
        	// else use the default value
919
        }
887 920
        quality = state.getInt(QUALITY_FIELD);
888 921
        mapUnits = state.getInt(MAPUNITS_FIELD);;
889 922
        viewDocument = (ViewDocument) state.get(VIEW_FIELD);
......
900 933
        if (getMapContext()!=null) {
901 934
        	double mapScale = state.getDouble(SCALE_FIELD);
902 935
        	getMapContext().setScaleView((long)mapScale);
903
        	getMapContext().getViewPort().setEnvelope(
904
                (Envelope) state.get(ENVELOPE_FIELD));
936
        	Envelope envelope = (Envelope) state.get(ENVELOPE_FIELD); 
937
        	getMapContext().getViewPort().setEnvelope(envelope);
938
        	if (scaleType == SCALE_TYPE.FIXED_SCALE) {
939
        		fixedScale = new Double(mapScale);
940
        	}
941
        	else if (scaleType == SCALE_TYPE.FIXED_EXTENT) {
942
        		fixedExtent = envelope;
943
        	}
905 944
        	if (this.getLayoutContext()!=null) {
906 945
        		this.getLayoutContext().setTocModel(getMapContext());
907 946
        	}
......
920 959
        state.set(MAPUNITS_FIELD, mapUnits);
921 960
        state.set(VIEW_FIELD, viewDocument);
922 961
        state.set(HAS_TOC_FIELD, b_hasToc);
962
        state.set(SCALE_TYPE_FIELD, scaleType.ordinal());
923 963

  
924 964
        if (getMapContext() != null
925 965
            && getMapContext().getViewPort().getEnvelope() != null) {
926
            state.set(ENVELOPE_FIELD, getMapContext().getViewPort()
927
                .getEnvelope());
928
            state.set(SCALE_FIELD, (double)getMapContext().getScaleView());
966
        	if (scaleType==SCALE_TYPE.FIXED_SCALE && fixedScale!=null) {
967
        		state.set(SCALE_FIELD, (double)fixedScale);
968
        	}
969
        	else {
970
        		state.set(SCALE_FIELD, (double)getMapContext().getScaleView());	
971
        	}
972
        	if (scaleType == SCALE_TYPE.FIXED_EXTENT && fixedExtent!=null) {
973
        		state.set(ENVELOPE_FIELD, fixedExtent);
974
        	}
975
        	else {
976
        		state.set(ENVELOPE_FIELD, getMapContext().getViewPort()
977
                        .getEnvelope());	
978
        	}
929 979
        }
930 980

  
931 981
        state.set(SHOWGRID_FIELD, showGrid);
......
937 987
    	super.setBoundBox(r);
938 988
    	if (getMapContext()!=null) {
939 989
    		AffineTransform at = this.getLayoutContext().getAT();
990
    		long scale = getMapContext().getScaleView();
940 991
    		getMapContext().getViewPort().setImageSize(
941 992
    				new Dimension((int)getBoundingBox(at).getWidth(), (int)getBoundingBox(at).getHeight()));
942 993
    		getMapContext().getViewPort().setDPI(getDrawPaperDPI());
994
    		if (getScaleType()==SCALE_TYPE.FIXED_SCALE) {
995
    			getMapContext().setScaleView((long) scale);
996
    		}
943 997
    		updateScaleCtrl();
944 998
    		// FIXME: what should we do here? should we invalidate the cache?
945 999
    		// should we also trigger a Layout redraw?
......
973 1027

  
974 1028
	public void refresh() {
975 1029
        // FIXME: what should we do here? do we really need to invalidate cache??
976
    	b_validCache = false;		
1030
    	b_validCache = false;
977 1031
	}
978 1032
    
979 1033
    protected void resetListeners() {
......
1153 1207
					b_frameInitialized = true;
1154 1208
					return;
1155 1209
				}
1210
				b_updating = true;
1156 1211
				if (getMapContext()!=null) {
1157
					b_updating = true;
1158
					getMapContext().getViewPort().setEnvelope(calculateNewExtent(e.getNewExtent()));						
1159
					oldViewEnvelope = getView().getMapContext().getViewPort().getAdjustedEnvelope();
1160
					updateScaleCtrl();
1161
					invalidateLayout();
1162
					b_updating = false;
1212
					if (scaleType==SCALE_TYPE.FIXED_EXTENT) {
1213
						getView().getMapContext().getViewPort().setEnvelope(fixedExtent);
1214
					}
1215
					else {
1216
						getMapContext().getViewPort().setEnvelope(calculateNewExtent(e.getNewExtent()));
1217
						if (scaleType==SCALE_TYPE.FIXED_SCALE) {
1218
							getMapContext().setScaleView(Math.round(fixedScale));  
1219
							getView().getMapContext().getViewPort().setEnvelope(getMapContext().getViewPort().getAdjustedEnvelope());
1220
						}
1221
						oldViewEnvelope = getView().getMapContext().getViewPort().getAdjustedEnvelope();
1222
						updateScaleCtrl();
1223
						invalidateLayout();
1224
					}
1163 1225
				}
1226
				b_updating = false;
1164 1227
			}			
1165 1228
		}
1166 1229

  
......
1264 1327

  
1265 1328
		public void extentChanged(ExtentEvent e) {
1266 1329
			if (!b_drawing && !b_updating) {
1267
				if (getView()!=null) {
1268
					b_updating = true;
1269
					if (getExtentSynced()){
1270
						getView().getMapContext().getViewPort().setEnvelope(e.getNewExtent());
1271
						oldViewEnvelope = getView().getMapContext().getViewPort().getAdjustedEnvelope();
1330
				b_updating = true;
1331
				if (scaleType==SCALE_TYPE.FIXED_EXTENT) {
1332
					getMapContext().getViewPort().setEnvelope(fixedExtent);
1333
				}
1334
				else {
1335
					Envelope newEnvelope;
1336
					if (scaleType==SCALE_TYPE.FIXED_SCALE) {
1337
						getMapContext().setScaleView(Math.round(fixedScale));
1338
						newEnvelope = getMapContext().getViewPort().getAdjustedEnvelope();
1272 1339
					}
1273
					updateScaleCtrl();
1274
					invalidateLayout();
1275
					b_updating = false;
1340
					else {
1341
						newEnvelope = e.getNewExtent();
1342
					}
1343
					if (getView()!=null) {
1344
						if (getExtentSynced()){
1345
							getView().getMapContext().getViewPort().setEnvelope(newEnvelope);
1346
							oldViewEnvelope = getView().getMapContext().getViewPort().getAdjustedEnvelope();
1347
						}
1348
					}
1276 1349
				}
1350
				updateScaleCtrl();
1351
				invalidateLayout();
1352
				b_updating = false;
1277 1353
			}			
1278 1354
		}
1279 1355

  
......
1367 1443
			conditionalRedraw();
1368 1444
		}
1369 1445
	}
1446

  
1447
	public void setExtent(Envelope extent) {
1448
		if (getScaleType()==SCALE_TYPE.NORMAL) {
1449
			getMapContext().getViewPort().setEnvelope(extent);
1450
		}
1451
	}
1452

  
1453
	public SCALE_TYPE getScaleType() {
1454
		return scaleType ;
1455
	}
1456

  
1457
	public void setScaleType(SCALE_TYPE scaleType) {
1458
		this.scaleType = scaleType;
1459
	}
1460
	
1461
	public void setScaleType(SCALE_TYPE scaleType, double fixedScale) {
1462
		if (scaleType == SCALE_TYPE.FIXED_SCALE) {
1463
			this.scaleType = scaleType;
1464
			this.fixedScale = new Double(fixedScale);
1465
			setScale(fixedScale);
1466
		}
1467
	}
1468
	
1469
	public void setScaleType(SCALE_TYPE scaleType, Envelope fixedExtent) {
1470
		if (scaleType == SCALE_TYPE.FIXED_EXTENT) {
1471
			this.scaleType = scaleType;
1472
			this.fixedExtent  = fixedExtent;
1473
			setNewEnvelope(fixedExtent);
1474
		}
1475
	}
1476

  
1477
	@Deprecated
1478
	public int getTypeScale() {
1479
		return AUTOMATICO;
1480
	}
1481

  
1482
	@Deprecated
1483
	public void setLinked(boolean b) {}
1484

  
1485
	@Deprecated
1486
	public boolean getLinked() {
1487
		return false;
1488
	}
1370 1489
}
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutGraphics.java
26 26

  
27 27
import org.slf4j.Logger;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff