Revision 219

View differences:

trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutFunctions.java
201 201
                                logger.error("Error creating the envelope", e);
202 202
                            }
203 203
                            fframe.refresh();
204
                            if (fframe.getLinked()) {
204
                            if (fframe.getExtentSynced()) {
205 205
                                fframe.refreshOriginalExtent();
206 206
                            }
207 207
                        }
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameOverView.java
240 240
        assoc_map = fframeViewDependence.getMapContext();
241 241
        setViewMapContext(v.getMapOverViewContext());
242 242
    }
243
    
244
    public boolean getLinked() {
245
    	if (fframeViewDependence!=null) {
246
    		return fframeViewDependence.getLinked();
247
    	}
248
    	return false;
249
    } 
250 243

  
251 244
    /**
252
     * Inserta el ProjectView de donde obtener las propiedades de la vista a
253
     * mostrar.
254
     * 
255
     * @param v
256
     *            Modelo de la vista.
257
     */
258
    /*
259
    public void setViewOld(ViewDocument v) {
260
        viewDocument = v;
261

  
262
        ViewPort vp = null;
263

  
264
        if (getMapContext() != null) {
265
            vp = getMapContext().getViewPort();
266
        } else {
267
            try {
268
                vp = (ViewPort) v.getMapContext().getViewPort().clone();
269
            } catch (CloneNotSupportedException e) {
270
                NotificationManager.addError("Excepci?n :", e);
271
            }
272
        }
273

  
274
        vp.setImageSize(new Dimension((int) getBoundingBox(null).width,
275
            (int) getBoundingBox(null).height));
276
        if (fframeViewDependence == null)
277
            return;
278
        assoc_map = fframeViewDependence.getMapContext();
279

  
280
        if (fframeViewDependence.getLinked()) {
281
            try {
282
                mapContext =
283
                    fframeViewDependence
284
                        .getView()
285
                        .getMapOverViewContext()
286
                        .createNewFMap(
287
                            (ViewPort) fframeViewDependence.getView()
288
                                .getMapOverViewContext().getViewPort().clone());
289
            } catch (CloneNotSupportedException e) {
290
                NotificationManager.addError("Excepci?n :", e);
291
            }
292
            mapContext.getViewPort().setImageSize(
293
                new Dimension((int) getBoundingBox(null).width,
294
                    (int) getBoundingBox(null).height));
295
            fframeViewDependence.getMapContext().getViewPort()
296
                .addViewPortListener(this);
297
            v.getMapContext().getViewPort().addViewPortListener(this);
298
            fframeViewDependence.getView().getMapOverViewContext()
299
                .addLayerListener(this);
300
        } else
301
            if (!fframeViewDependence.getLinked()) {
302
                mapContext =
303
                    fframeViewDependence.getView().getMapOverViewContext()
304
                        .cloneFMap();
305
                try {
306
                    mapContext.setViewPort((ViewPort) fframeViewDependence
307
                        .getView().getMapOverViewContext().getViewPort()
308
                        .clone());
309
                } catch (CloneNotSupportedException e) {
310
                    NotificationManager.addError("Excepci?n :", e);
311
                }
312
                mapContext.getViewPort().setImageSize(
313
                    new Dimension((int) getBoundingBox(null).width,
314
                        (int) getBoundingBox(null).height));
315
                fframeViewDependence.getMapContext().getViewPort()
316
                    .addViewPortListener(this);
317
                v.getMapContext().getViewPort().addViewPortListener(this);
318
                fframeViewDependence.getView().getMapOverViewContext()
319
                    .addLayerListener(this);
320
            }
321
    }
322
*/
323
    /**
324 245
     * @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getNameFFrame()
325 246
     */
326 247
    public String getNameFFrame() {
......
353 274
        	setView(newFFView.getView());
354 275
        }
355 276
    }
356
    
357
    /*
358
    public void refreshDependenceOld(IFFrame fant, IFFrame fnew) {
359
        if ((fframeViewDependence != null) && fframeViewDependence.equals(fant)) {
360
            fframeViewDependence = (FFrameView) fnew;
361
            assoc_map = fframeViewDependence.getMapContext();
362

  
363
            if (fframeViewDependence.getLinked()) {
364
                try {
365
                    mapContext =
366
                        fframeViewDependence
367
                            .getView()
368
                            .getMapOverViewContext()
369
                            .createNewFMap(
370
                                (ViewPort) fframeViewDependence.getView()
371
                                    .getMapOverViewContext().getViewPort()
372
                                    .clone());
373
                } catch (CloneNotSupportedException e) {
374
                    NotificationManager.addError("Excepci?n :", e);
375
                }
376
                mapContext.getViewPort().setImageSize(
377
                    new Dimension((int) getBoundingBox(null).width,
378
                        (int) getBoundingBox(null).height));
379
                fframeViewDependence.getMapContext().getViewPort()
380
                    .addViewPortListener(this);
381
                getView().getMapContext().getViewPort()
382
                    .addViewPortListener(this);
383
                fframeViewDependence.getView().getMapOverViewContext()
384
                    .addLayerListener(this);
385
            } else
386
                if (!fframeViewDependence.getLinked()) {
387
                    mapContext =
388
                        fframeViewDependence.getView().getMapOverViewContext()
389
                            .cloneFMap(); // (v.getMapContext().getViewPort().cloneViewPort());
390
                    try {
391
                        mapContext.setViewPort((ViewPort) fframeViewDependence
392
                            .getView().getMapOverViewContext().getViewPort()
393
                            .clone());
394
                    } catch (CloneNotSupportedException e) {
395
                        NotificationManager.addError("Excepci?n :", e);
396
                    }
397
                    mapContext.getViewPort().setImageSize(
398
                        new Dimension((int) getBoundingBox(null).width,
399
                            (int) getBoundingBox(null).height));
400
                    fframeViewDependence.getMapContext().getViewPort()
401
                        .addViewPortListener(this);
402
                    getView().getMapContext().getViewPort()
403
                        .addViewPortListener(this);
404
                    fframeViewDependence.getView().getMapOverViewContext()
405
                        .addLayerListener(this);
406
                }
407
        }
408

  
409
    }
410
    */
411

  
277
 
412 278
    public static void registerPersistent() {
413 279
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
414 280
        if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) {
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
34 34
 * dependent on the MapContext properties
35 35
 */
36 36
public interface IFFrameUseFMap extends IFFrame {
37

  
38
    public static final int AUTOMATICO = 0;
39
    /**
40
    * @Deprecated {@value #CONSTANTE} is considered now
41
    * equivalent to {@link #MANUAL}
42
    */
43
    public static final int CONSTANTE = 1;
44
    public static final int MANUAL = 2;
45

  
46 37
    public AffineTransform getATMap();
47 38

  
48 39
    public void setATMap(AffineTransform at);
......
77 68
     */
78 69
    public BufferedImage getBufferedImage();
79 70

  
71
    /**
72
     * Zooms to the extent containing all the layers loaded in the map. 
73
     * 
74
     * @throws ReadException
75
     */
80 76
    public void fullExtent() throws ReadException;
81 77

  
82 78
    public void setPointsToZoom(Point2D px1, Point2D px2);
83 79

  
84 80
    public void movePoints(Point2D px1, Point2D px2);
85 81

  
82
    public void refreshOriginalExtent();    
83
    
86 84
    /**
87
     * See {@link #AUTOMATICA}, {@link #MANUAL}
88
     * @return
85
     * Gets the synchronization mode for layers. If <code>true</code>, layers
86
     * will be synchronized between the FFrameView and the associated View, so
87
     * any change in the FFrameView (layer added or removed, visibility changed,
88
     * symbology change, etc) will be propagated to the associated View, and
89
     * vice versa.
90
     * 
91
     * @return <code>true</code> if the layers are synchronized between the 
92
     * FFrameView and the View, <code>false</code> otherwise.
89 93
     */
90
    public int getTypeScale();
94
    public boolean getLayerSynced();
91 95

  
92
    public void refreshOriginalExtent();
93
    
94 96
    /**
95
     * Seleccionar si la vista esta relacionada o no con la original.
97
     * Sets the synchronization mode for map layers. If <code>true</code>,
98
     * layers will be synchronized between the FFrameView and the associated
99
     * View, so any change in the FFrameView (layer added or removed,
100
     * visibility changed, symbology change, etc) will be propagated to the
101
     * associated View, and vice versa.
96 102
     * 
97
     * @param b
98
     *            true si est? ligada y false si no lo est?.
103
     * @param synced <code>true</code> to enable layers synchronization
104
     * between the FFrameView and the View, <code>false</code> otherwise.
99 105
     */
100
    public void setLinked(boolean b);
106
    public void setLayerSynced(boolean synced);
101 107

  
102 108
    /**
103
     * Devuelve si est? ligada o no el FFrameView con la vista.
109
     * Gets the synchronization mode for the map extent. If <code>true</code>,
110
     * the map extent will be synchronized between the FFrameView and the
111
     * associated View, so any change in the FFrameView (pan, zoom in, zoom
112
     * out...) will be propagated to the associated View, and vice versa.
104 113
     * 
105
     * @return True si la vista est? ligada.
114
     * @return <code>true</code> if the map extent is synchronized between the 
115
     * FFrameView and the View, <code>false</code> otherwise.
106 116
     */
107
    public boolean getLinked();
117
    public boolean getExtentSynced();
108 118
    
109 119
    /**
120
     * Sets the synchronization mode for the map extent. If <code>true</code>,
121
     * the map extent will be synchronized between the FFrameView and the
122
     * associated View, so any change in the FFrameView (pan, zoom in, zoom
123
     * out...) will be propagated to the associated View, and vice versa.
124
     * 
125
     * @param synced <code>true</code> to enable extent synchronization
126
     * between the FFrameView and the View, <code>false</code> otherwise.
127
     */
128
    public void setExtentSynced(boolean synced);
129
    
130
    /**
110 131
     * Sets the scale of the MapContext contained in this FFrameView
111 132
     * 
112 133
     * @param d Scale to be set
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
106 106

  
107 107
    public static final String PERSISTENCE_DEFINITION_NAME = "FFrameView";
108 108

  
109
    private static final String MODE_FIELD = "mode";
110
    private static final String TYPESCALE_FIELD = "typeScale";
111 109
    private static final String QUALITY_FIELD = "quality";
112
    private static final String BLINKED_FIELD = "bLinked";
113 110
    private static final String MAPUNITS_FIELD = "mapUnits";
114 111
    private static final String SCALE_FIELD = "scale";
115 112
    private static final String VIEW_FIELD = "view";
......
117 114
    private static final String SHOWGRID_FIELD = "showGrid";
118 115
    private static final String GRID_FIELD = "gridview";
119 116
    private static final String HAS_TOC = "hasToc";
120
    // following fields are unused - should be deleted? 
117
    private static final String LAYER_SYNC_FIELD = "layerSync";
118
    private static final String EXTENT_SYNC_FIELD = "extentSync";
119
    // following fields are unused - they are kept for backward-compatibility 
121 120
    private static final String EXTENSION_FIELD = "extension";
121
    private static final String BLINKED_FIELD = "bLinked";
122
    private static final String MODE_FIELD = "mode";
123
    private static final String TYPESCALE_FIELD = "typeScale";
124
    private static final String MAPCONTEXT_FIELD = "mapContext";
125
    private static final String VIEWING_FIELD = "viewing";
122 126

  
123 127
    private static final Logger logger = LoggerFactory
124 128
        .getLogger(FFrameView.class);
125 129
    public static final int PRESENTATION = 0;
126 130
    public static final int DRAFT = 1;
127
    protected int mode;
128
    protected int typeScale = AUTOMATICO;
131
    protected boolean syncLayers = true;
132
    protected boolean syncExtents = true;
129 133
    protected int quality = PRESENTATION;
130
    protected boolean linked = true;
131 134
    protected ViewDocument viewDocument = null;
132 135
    protected MapContext mapContext = null;
133 136
    protected int mapUnits = 1; // Meters.
......
270 273
    		clearOwnListeners(mapContext);
271 274
    	}
272 275
    	try {
273
    		if (linked){
276
    		if (syncLayers){
274 277
    			mapContext =
275 278
    					viewMapContext.createNewFMap(
276 279
    							(ViewPort) viewMapContext.getViewPort().clone());
......
622 625
    }
623 626

  
624 627
    /**
625
     * Seleccionar si la vista esta relacionada o no con la original.
626
     * 
627
     * @param b
628
     *            true si est? ligada y false si no lo est?.
629
     */
630
    public void setLinked(boolean b) {
631
        linked = b;
632
        resetListeners();
633
    }
634

  
635
    /**
636
     * Devuelve si est? ligada o no el FFrameView con la vista.
637
     * 
638
     * @return True si la vista est? ligada.
639
     */
640
    public boolean getLinked() {
641
        return linked;
642
    }
643

  
644
    /**
645
     * Devuelve el tipo de escala que est? seleccionada AUTOMATICO o
646
     * MANUAL.
647
     * 
648
     * @return entero que representa el tipo seleccionado.
649
     */
650
    public int getTypeScale() {
651
        return typeScale;
652
    }
653

  
654
    /**
655
     * Rellenar el tipo de escala que se desea.
656
     * 
657
     * @param i
658
     *            entero que representa el tipo de escala.
659
     */
660
    public void setTypeScale(int i) {
661
        typeScale = i;
662
        resetListeners();
663
    }
664

  
665
    /**
666 628
     * Inserta la imagen para repintar el FFrameView.
667 629
     * 
668 630
     * @param bi
......
812 774
    	Document d = ProjectManager.getInstance().getCurrentProject().getDocuments().get(0);
813 775
        FFrameView frame = (FFrameView) super.clone();
814 776
        frame.createListeners(); // necessary to create the listeners within the right scope
815
        frame.setView(this.getView());        
777
        frame.setView(this.getView());
778
        frame.getMapContext().getViewPort().setEnvelope(getMapContext().getViewPort().getEnvelope());
816 779

  
817 780
        if (grid != null) {
818 781
            FFrameGrid newGrid = (FFrameGrid) this.grid.clone();
......
860 823
            definition.extend(manager
861 824
                .getDefinition(FFrame.PERSISTENCE_DEFINITION_NAME));
862 825

  
863
            definition.addDynFieldInt(MODE_FIELD).setMandatory(true);
864
            definition.addDynFieldInt(TYPESCALE_FIELD).setMandatory(true);
865 826
            definition.addDynFieldInt(EXTENSION_FIELD).setMandatory(false);
866 827
            definition.addDynFieldInt(QUALITY_FIELD).setMandatory(true);
867
            definition.addDynFieldBoolean(BLINKED_FIELD).setMandatory(true);
868 828
            definition.addDynFieldInt(MAPUNITS_FIELD).setMandatory(true);
869 829
            definition.addDynFieldDouble(SCALE_FIELD).setMandatory(false);
870 830
            definition.addDynFieldObject(VIEW_FIELD)
......
875 835
            definition.addDynFieldObject(GRID_FIELD)
876 836
                .setClassOfValue(IFFrame.class).setMandatory(false);
877 837
            definition.addDynFieldBoolean(HAS_TOC).setMandatory(false);
838
            // unused fields, kept for backward compatibility
839
            definition.addDynFieldInt(MODE_FIELD).setMandatory(false);
840
            definition.addDynFieldInt(TYPESCALE_FIELD).setMandatory(false);
841
            definition.addDynFieldBoolean(BLINKED_FIELD).setMandatory(false);
842
            definition.addDynFieldObject(MAPCONTEXT_FIELD)
843
            .setClassOfValue(MapContext.class).setMandatory(false);
844
            definition.addDynFieldInt(VIEWING_FIELD).setMandatory(false);
878 845
        }
879 846
    }
880 847

  
......
883 850
        throws PersistenceException {
884 851
        super.loadFromState(state);
885 852
        b_frameInitialized = false;
886
        mode = state.getInt(MODE_FIELD);
887
        typeScale = state.getInt(TYPESCALE_FIELD);
853
        if (state.hasValue(EXTENT_SYNC_FIELD)) {
854
        	syncExtents = state.getBoolean(EXTENT_SYNC_FIELD);
855
        }
856
        else {
857
        	syncExtents = true;
858
        }
859
        if (state.hasValue(LAYER_SYNC_FIELD)) {
860
        	syncLayers = state.getBoolean(LAYER_SYNC_FIELD);
861
        }
862
        else {
863
        	syncLayers = true;
864
        }
888 865
        quality = state.getInt(QUALITY_FIELD);
889
        linked = state.getBoolean(BLINKED_FIELD);
866
        syncLayers = state.getBoolean(BLINKED_FIELD);
890 867
        mapUnits = state.getInt(MAPUNITS_FIELD);;
891 868
        viewDocument = (ViewDocument) state.get(VIEW_FIELD);
892 869
        if (state.hasValue(HAS_TOC)) {
......
916 893
    @Override
917 894
    public void saveToState(PersistentState state) throws PersistenceException {
918 895
        super.saveToState(state);
919
        state.set(MODE_FIELD, mode);
920
        state.set(TYPESCALE_FIELD, typeScale);
896
        state.set(EXTENT_SYNC_FIELD, syncExtents);
897
        state.set(LAYER_SYNC_FIELD, syncLayers);
921 898
        state.set(QUALITY_FIELD, quality);
922
        state.set(BLINKED_FIELD, linked);
923 899
        state.set(MAPUNITS_FIELD, mapUnits);
924 900
        state.set(VIEW_FIELD, viewDocument);
925 901
        state.set(HAS_TOC, b_hasToc);
......
991 967
    
992 968
    protected void setListeners() {
993 969
    	if (getView()!=null) {
994
    		if (linked) {
970
    		if (syncLayers) {
995 971
    			getView().getMapContext().addLayerListener(viewDocListener);
996 972
    			getView().getMapContext().getLayers().addLayerCollectionListener(viewDocListener);
997 973
    			getView().getMapContext().addAtomicEventListener(viewDocListener);
998 974
    		}
999
    		if (getTypeScale()==IFFrameUseFMap.AUTOMATICO) {
975
    		if (getExtentSynced()) {
1000 976
    			getView().getMapContext().getViewPort().addViewPortListener(viewDocListener);
1001 977
    		}
1002 978
    	}
......
1080 1056
			updateScaleCtrl();
1081 1057
		}
1082 1058
	}
1059
	
1060
	public boolean getLayerSynced() {
1061
		return syncLayers;
1062
	}
1083 1063

  
1064
	public void setLayerSynced(boolean synced) {
1065
        syncLayers = synced;
1066
        resetListeners();
1067
	}
1068

  
1069
	public boolean getExtentSynced() {
1070
		return syncExtents;
1071
	}
1072

  
1073
	public void setExtentSynced(boolean synced) {
1074
		syncExtents = synced;
1075
        resetListeners();
1076
	}
1077

  
1084 1078
	private class ViewDocListener
1085 1079
	implements ViewPortListener, LegendListener, LayerCollectionListener, AtomicEventListener {
1086 1080

  
1087 1081
		public void extentChanged(ExtentEvent e) {
1088
			if (!b_updating && getTypeScale()==AUTOMATICO) {
1082
			if (!b_updating && getExtentSynced()) {
1089 1083
				if (!b_frameInitialized) {
1090 1084
					b_frameInitialized = true;
1091 1085
					return;
......
1101 1095
		}
1102 1096

  
1103 1097
		public void backColorChanged(ColorEvent e) {
1104
			if (!b_updating && linked) {
1098
			if (!b_updating && syncLayers) {
1105 1099
				if (getMapContext()!=null) {
1106 1100
					b_updating = true;
1107 1101
					mapContext.getViewPort().setBackColor(e.getNewColor());
......
1112 1106
		}
1113 1107

  
1114 1108
		public void projectionChanged(ProjectionEvent e) {
1115
			if (!b_updating && getTypeScale()==AUTOMATICO) {
1109
			if (!b_updating && getExtentSynced()) {
1116 1110
				if (getMapContext()!=null) {
1117 1111
					b_updating = true;
1118 1112
					getMapContext().getViewPort().setProjection(e.getNewProjection());
......
1124 1118
		}
1125 1119

  
1126 1120
		public void conditionalRedraw() {
1127
			if (!b_updating && linked) {
1121
			if (!b_updating && syncLayers) {
1128 1122
				b_updating = true;
1129 1123
				invalidateLayout();
1130 1124
				// the view should also receive the event and update automatically
......
1199 1193
		implements ViewPortListener, LegendListener, LayerCollectionListener {
1200 1194

  
1201 1195
		public void extentChanged(ExtentEvent e) {
1202
			if (!b_drawing && !b_updating && (getTypeScale() == AUTOMATICO)) {
1196
			if (!b_drawing && !b_updating) {
1203 1197
				if (getView()!=null) {
1204 1198
					b_updating = true;
1205
					getView().getMapContext().getViewPort().setEnvelope(e.getNewExtent());
1199
					if (getExtentSynced()){
1200
						getView().getMapContext().getViewPort().setEnvelope(e.getNewExtent());
1201
					}
1206 1202
					updateScaleCtrl();
1207 1203
					invalidateLayout();
1208 1204
					b_updating = false;
......
1214 1210
			if (!b_updating) {
1215 1211
				if (getView()!=null) {
1216 1212
					b_updating = true;
1217
					getView().getMapContext().getViewPort().setBackColor(e.getNewColor());
1213
					if (getLayerSynced()) {
1214
						getView().getMapContext().getViewPort().setBackColor(e.getNewColor());
1215
					}
1218 1216
					invalidateLayout();
1219 1217
					b_updating = false;
1220 1218
				}
......
1222 1220
		}
1223 1221

  
1224 1222
		public void projectionChanged(ProjectionEvent e) {
1225
			if (!b_updating && (getTypeScale() == AUTOMATICO)) {
1223
			if (!b_updating && getExtentSynced()) {
1226 1224
				if (getView()!=null) {
1227 1225
					b_updating = true;
1228
					getView().getMapContext().getViewPort().setProjection(e.getNewProjection());
1226
					if (getLayerSynced()) {
1227
						getView().getMapContext().getViewPort().setProjection(e.getNewProjection());
1228
					}
1229 1229
					invalidateLayout();
1230 1230
					// FIXME: force also a view redraw someway??
1231 1231
					b_updating = false;
......
1295 1295
				throws CancelationException {
1296 1296
			conditionalRedraw();
1297 1297
		}
1298

  
1299 1298
	}
1300 1299
}
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
21 21
 */
22 22
package org.gvsig.app.project.documents.layout.fframes.gui.dialogs;
23 23

  
24
import java.awt.Color;
25 24
import java.awt.Dimension;
26 25
import java.awt.GridBagConstraints;
27 26
import java.awt.GridBagLayout;
28 27
import java.awt.Insets;
28
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionListener;
29 30
import java.awt.geom.Rectangle2D;
30 31

  
31
import javax.swing.BorderFactory;
32 32
import javax.swing.JButton;
33 33
import javax.swing.JCheckBox;
34 34
import javax.swing.JList;
35 35
import javax.swing.JOptionPane;
36 36
import javax.swing.JPanel;
37 37

  
38
import org.bouncycastle.mail.smime.examples.ReadEncryptedMail;
39
import org.gvsig.andami.PluginServices;
40 38
import org.gvsig.andami.messages.NotificationManager;
41 39
import org.gvsig.andami.ui.mdiManager.WindowInfo;
42 40
import org.gvsig.app.ApplicationLocator;
......
46 44
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid;
47 45
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
48 46
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
49
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
50 47
import org.gvsig.app.project.documents.layout.fframes.ListViewModel;
51 48
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation;
52 49
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
......
55 52
import org.gvsig.i18n.Messages;
56 53

  
57 54
/**
58
 * Di?logo para a?adir una vista al Layout.
55
 * Dialog to add a view to the Layout document, by means of a FFrameView
59 56
 * 
60 57
 * @author Vicente Caballero Navarro
58
 * @author Cesar Martinez Izquierdo
61 59
 */
62 60
public class FFrameViewDialog extends AbstractFFrameDialog implements
63 61
    IFFrameDialog {
......
65 63
    private static final long serialVersionUID = -7223804566537544559L;
66 64
    
67 65
    private final LayoutManager layoutManager;
68
    
69
    private javax.swing.JPanel jContentPane = null;
70
    private javax.swing.JLabel lVistas = null;
66
    private javax.swing.JLabel lViews = null;
71 67
    private javax.swing.JScrollPane jScrollPane = null;
72
    private javax.swing.JList liVistas = null; // @jve:visual-info decl-index=0
68
    private javax.swing.JList liViews = null; // @jve:visual-info decl-index=0
73 69
                                               // visual-constraint="98,-3"
74
    private javax.swing.JCheckBox chbEnlaceVivo = null;
75
    private javax.swing.JLabel lEscala = null;
76
    private javax.swing.JComboBox cbEscala = null;
77
    private javax.swing.JLabel lEscalaNumerica = null;
78
    private javax.swing.JTextField tEscalaNumerica = null;
79
    private javax.swing.JLabel lExtension = null;
80
    private javax.swing.JComboBox cbExtension = null;
70
    private javax.swing.JCheckBox chbSyncLayers = null;
81 71
    private javax.swing.JButton bAceptar = null;
82 72
    private javax.swing.JButton bCancelar = null;
83 73
    private javax.swing.JLabel lCalidad = null;
......
108 98
        super(layoutPanel, frame);
109 99
        fframeview = (FFrameView) frame;
110 100
        initComponents();
111
        initValues();
112 101
        layoutManager = (LayoutManager) ProjectManager.getInstance()
113 102
            .getDocumentManager("project.document.layout");
114 103
    }
......
131 120
        c.gridx = 0;
132 121
        c.gridy = row++;
133 122
        c.gridwidth = GridBagConstraints.REMAINDER;
134
        add(getChbEnlaceVivo(), c);
123
        add(getChbSyncLayers(), c);
135 124
        c.insets = insets;
136 125
        c.gridx = 0;
137 126
        c.gridy = row++;
......
140 129
        c.gridx = 0;
141 130
        c.gridy = row++;
142 131
        c.gridwidth = 1;
143
        add(getLExtension(), c);
144
        c.gridx = 1;
145
        c.gridwidth = GridBagConstraints.REMAINDER;
146
        add(getCbExtension(), c);
147
        c.gridx = 0;
148
        c.gridy = row++;
149
        c.gridwidth = 1;
150 132
        add(getLCalidad(), c);
151 133
        c.gridx = 1;
152 134
        c.gridwidth = GridBagConstraints.REMAINDER;
......
172 154
        c.gridwidth = GridBagConstraints.REMAINDER;
173 155
        add(acceptCancelPnl, c);
174 156
    }
175
    
176
    private void initValues() {
177
    	getPRotation().setRotation(fframeview.getRotation());
178
    }
179 157

  
180 158
    /**
181 159
     * Inserta el rect?ngulo que ocupar? el fframe vista.
......
196 174
            c.gridy = 1;
197 175
            c.insets = insets;
198 176
            c.anchor = GridBagConstraints.PAGE_START;
199
            pnlFirstRow.add(getLVistas(), c);
177
            pnlFirstRow.add(getLViews(), c);
200 178
            c.gridx = 1;
201 179
            pnlFirstRow.add(getScrolledViewList(), c);
202 180
            c.gridx = 2;
......
210 188
     * 
211 189
     * @return javax.swing.JLabel
212 190
     */
213
    private javax.swing.JLabel getLVistas() {
214
        if (lVistas == null) {
215
            lVistas = new javax.swing.JLabel();
216
            lVistas.setText(Messages.getText("Vista"));
191
    private javax.swing.JLabel getLViews() {
192
        if (lViews == null) {
193
            lViews = new javax.swing.JLabel();
194
            lViews.setText(Messages.getText("Vista"));
217 195
        }
218 196

  
219
        return lVistas;
197
        return lViews;
220 198
    }
221 199

  
222 200
    /**
......
239 217
     * @return javax.swing.JList
240 218
     */
241 219
    private javax.swing.JList getViewList() {
242
        if (liVistas == null) {
220
        if (liViews == null) {
243 221
            ListViewModel listmodel = new ListViewModel();
244 222
            
245 223
            if (listmodel.addViews()) {
......
250 228
                   JOptionPane.WARNING_MESSAGE); 
251 229
            }
252 230
            
253
            liVistas = new javax.swing.JList();
254
            liVistas.setModel(listmodel);
255
            for (int i = 0; i < liVistas.getModel().getSize(); i++) {
231
            liViews = new javax.swing.JList();
232
            liViews.setModel(listmodel);
233
            for (int i = 0; i < liViews.getModel().getSize(); i++) {
256 234
                if (fframeview.getMapContext() != null) {
257 235

  
258 236
                    DefaultViewDocument pvaux =
259
                        (DefaultViewDocument) liVistas.getModel().getElementAt(
237
                        (DefaultViewDocument) liViews.getModel().getElementAt(
260 238
                            i);
261 239

  
262 240
                    if (pvaux.getMapContext()
263 241
                        .equals(fframeview.getMapContext())) {
264
                        liVistas.setSelectedIndex(i);
242
                        liViews.setSelectedIndex(i);
265 243
                        m_projectView =
266
                            (DefaultViewDocument) liVistas.getModel()
244
                            (DefaultViewDocument) liViews.getModel()
267 245
                                .getElementAt(i);
268 246
                    }
269 247
                }
270 248
            }
271 249

  
272
            liVistas
250
            liViews
273 251
                .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
274 252

  
275 253
                    private int selectIndex = -1;
276
                    private Rectangle2D boundBox;
277

  
278 254
                    public void valueChanged(
279 255
                        javax.swing.event.ListSelectionEvent e) {
280 256
                        int selectInt =
......
285 261
                                return;
286 262
                            }
287 263
                            m_projectView =
288
                                (DefaultViewDocument) liVistas.getModel()
264
                                (DefaultViewDocument) liViews.getModel()
289 265
                                    .getElementAt(selectInt);
290

  
291
                            getCbEscala().setSelectedItem(
292
                                Messages.getText("automatico"));
293
                            boundBox =
294
                                FLayoutUtilities.toSheetRect(rect, layoutPanel
295
                                    .getLayoutControl().getAT());
296 266
                            ViewPort vp;
297 267
                            try {
298 268
                                vp =
......
300 270
                                        .getViewPort().clone();
301 271
                                vp.setImageSize(new Dimension((int) rect
302 272
                                    .getWidth(), (int) rect.getHeight()));
303
                                getTEscalaNumerica().setText(
304
                                    String.valueOf(FLayoutUtilities
305
                                        .getScaleView(vp, boundBox.getWidth(),
306
                                            FLayoutUtilities.fromSheetDistance(
307
                                                boundBox.getWidth(),
308
                                                layoutPanel.getLayoutControl()
309
                                                    .getAT()))));
310 273
                            } catch (CloneNotSupportedException e1) {
311 274
                                NotificationManager.addError("Excepci?n :", e1);
312 275
                            }
......
315 278
                });
316 279
        }
317 280

  
318
        return liVistas;
281
        return liViews;
319 282
    }
320 283

  
321 284
    /**
......
323 286
     * 
324 287
     * @return javax.swing.JCheckBox
325 288
     */
326
    private javax.swing.JCheckBox getChbEnlaceVivo() {
327
        if (chbEnlaceVivo == null) {
328
            chbEnlaceVivo = new javax.swing.JCheckBox();
329
            chbEnlaceVivo.setText(Messages.getText("enlace_vivo"));
330
            chbEnlaceVivo.setSelected(fframeview.getLinked()); // FIXME: use more focused methods
331
            chbEnlaceVivo.setEnabled(true);
289
    private javax.swing.JCheckBox getChbSyncLayers() {
290
        if (chbSyncLayers == null) {
291
            chbSyncLayers = new javax.swing.JCheckBox();
292
            chbSyncLayers.setText(Messages.getText("Synchronize_layers"));
293
            chbSyncLayers.setSelected(fframeview.getLayerSynced());
294
            chbSyncLayers.addActionListener(new ActionListener() {
295

  
296
				public void actionPerformed(ActionEvent e) {
297
					if (chbSyncLayers.isSelected()) {
298
						JOptionPane.showMessageDialog(FFrameViewDialog.this,
299
						Messages.getText("Warning_Enabling_layer_synchronization_will_discard_any_change_not_present_in_associated_view"),
300
						Messages.getText("Warning_Layer_sync"),
301
					    JOptionPane.WARNING_MESSAGE);
302
					}
303
				}
304
            	
305
            });
332 306
        }
333 307

  
334
        return chbEnlaceVivo;
308
        return chbSyncLayers;
335 309
    }
336 310
    
337 311
    private javax.swing.JCheckBox getChbSyncExtent() {
338 312
    	if (chbSyncExtent==null) {
339 313
    		chbSyncExtent  = new  javax.swing.JCheckBox();
340 314
    		chbSyncExtent.setText(Messages.getText("Synchronize_extents"));
341
    		chbSyncExtent.setSelected(fframeview.getLinked()); // FIXME: use more focused methods
342
    		chbSyncExtent.setEnabled(true);
315
    		chbSyncExtent.setSelected(fframeview.getExtentSynced());
343 316
    	}
344 317
    	return chbSyncExtent;
345 318
    }
346 319

  
347 320
    /**
348
     * This method initializes cbEscala
349
     * 
350
     * @return javax.swing.JComboBox
351
     */
352
    private javax.swing.JComboBox getCbEscala() {
353
        if (cbEscala == null) {
354
            // String[]
355
            // s={"Autom?tico","Conservar escala de visualizaci?n","Escala especificada por el usuario"};
356
            cbEscala = new javax.swing.JComboBox();
357
            cbEscala.addItem(Messages.getText("automatico"));
358
            cbEscala.addItem(Messages.getText(
359
                "conservar_escala_visualizacion"));
360
            cbEscala.addItem(Messages.getText("escala_usuario"));
361
            cbEscala.setSelectedIndex(fframeview.getTypeScale());
362

  
363
            if (fframeview.getTypeScale() == 0
364
                || fframeview.getTypeScale() == 1) {
365
                getTEscalaNumerica().setEnabled(false);
366
            } else {
367
                getTEscalaNumerica().setEnabled(true);
368
            }
369
            cbEscala.addActionListener(new java.awt.event.ActionListener() {
370

  
371
                public void actionPerformed(java.awt.event.ActionEvent e) {
372
                    if (cbEscala.getSelectedIndex() == 2) {
373
                        getTEscalaNumerica().setEnabled(true);
374
                    } else {
375
                        getTEscalaNumerica().setEnabled(false);
376
                    }
377
                }
378
            });
379
        }
380

  
381
        return cbEscala;
382
    }
383

  
384
    /**
385
     * This method initializes tEscalaNumerica
386
     * 
387
     * @return javax.swing.JTextField
388
     */
389
    private javax.swing.JTextField getTEscalaNumerica() {
390
        if (tEscalaNumerica == null) {
391
            tEscalaNumerica = new javax.swing.JTextField();
392

  
393
            if (m_projectView != null) {
394
                tEscalaNumerica.setText(String.valueOf(fframeview.getScale()));
395
            }
396
            tEscalaNumerica.setEnabled(false);
397
        }
398

  
399
        return tEscalaNumerica;
400
    }
401

  
402
    /**
403
     * This method initializes lExtension
404
     * 
405
     * @return javax.swing.JLabel
406
     */
407
    private javax.swing.JLabel getLExtension() {
408
        if (lExtension == null) {
409
            lExtension = new javax.swing.JLabel();
410
            lExtension.setText(Messages.getText("extension"));
411
            lExtension.setVisible(false);
412
        }
413

  
414
        return lExtension;
415
    }
416

  
417
    /**
418
     * This method initializes cbExtension
419
     * 
420
     * @return javax.swing.JComboBox
421
     */
422
    private javax.swing.JComboBox getCbExtension() {
423
        if (cbExtension == null) {
424
            // String[] s={"Rellenar marco de la vista","Recorte a vista"};
425
            cbExtension = new javax.swing.JComboBox();
426
            cbExtension.addItem(Messages.getText(
427
                "rellenar_marco_vista"));
428
            cbExtension.addItem(Messages.getText("recorte_vista"));
429

  
430
            cbExtension.setEnabled(false);
431
            cbExtension.setVisible(false);
432
        }
433

  
434
        return cbExtension;
435
    }
436

  
437
    /**
438 321
     * This method initializes jButton
439 322
     * 
440 323
     * @return javax.swing.JButton
......
452 335
                            rect, layoutPanel.getLayoutControl().getAT()));
453 336
                        newFFrameView.setRotation(getPRotation().getRotation());
454 337
                        newFFrameView.setHasToc(true);
338
                        newFFrameView.setLayerSynced(getChbSyncLayers()
339
                                .isSelected());
340
                        newFFrameView.setExtentSynced(getChbSyncExtent().isSelected());
455 341

  
456 342
                        if (m_projectView != null) {
457
                            newFFrameView.setLinked(getChbEnlaceVivo()
458
                                .isSelected());
459
                            newFFrameView.setTypeScale(getCbEscala()
460
                                .getSelectedIndex());
461
                            if (newFFrameView.getTypeScale()!=IFFrameUseFMap.AUTOMATICO){
462
                            	newFFrameView.setScale(Double
463
                            			.parseDouble(getTEscalaNumerica().getText()));
464
                            }
465 343
                            newFFrameView.setView(m_projectView);
344
                            newFFrameView.getMapContext().getViewPort().setEnvelope(fframeview.getMapContext().getViewPort().getEnvelope());
466 345
                            newFFrameView.setQuality(getCbCalidad()
467 346
                                .getSelectedIndex());
468 347
                            if (fframeview.getGrid() != null) {                             
......
480 359
                        LOG.error("It is not possible to clone the object", e);
481 360
                    }
482 361
                    isAcepted = true;
483
                    PluginServices.getMDIManager().closeWindow(
362
                    ApplicationLocator.getManager().getUIManager().closeWindow(
484 363
                        FFrameViewDialog.this);
485 364
                    layoutPanel.getLayoutControl().setDefaultTool();
486 365
                }
......
503 382

  
504 383
                public void actionPerformed(java.awt.event.ActionEvent e) {
505 384
                    newFFrameView = null;
506
                    PluginServices.getMDIManager().closeWindow(
385
                    ApplicationLocator.getManager().getUIManager().closeWindow(
507 386
                        FFrameViewDialog.this);
508 387
                }
509 388
            });
......
574 453
    private JPRotation getPRotation() {
575 454
        if (rotation == null) {
576 455
            rotation = new JPRotation();
456
            rotation.setRotation(fframeview.getRotation());
577 457
        }
578 458
        return rotation;
579 459
    }
......
609 489
                        
610 490
   
611 491
                    if (fframeGridDialog != null) {
612
                        PluginServices.getMDIManager().addWindow(fframeGridDialog);
492
                        ApplicationLocator.getManager().getUIManager().addWindow(fframeGridDialog);
613 493
                    }
614 494
                    IFFrame newFrame = fframeGridDialog.getFFrame();
615 495
                    if (newFrame != null) {
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/dialogs/FConfigLayoutDialog.java
59 59
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager;
60 60

  
61 61
/**
62
 * Clase para configurar el Layout.
62
 * Dialog which can be used to configure the Layout page settings
63 63
 * 
64 64
 * @author Vicente Caballero Navarro
65
 * @author Cesar Martinez Izquierdo
65 66
 */
66 67
public class FConfigLayoutDialog extends JPanel implements SingletonWindow {
67 68

  
......
723 724
                    	ffv.setBoundBox(new Rectangle2D.Double(izq, sup, attributes.getPaperSize().getAncho()-(izq+der), attributes.getPaperSize().getAlto()-(sup+inf)));
724 725
                    	ffv.setView(vd);
725 726
                    	lctxt.addFFrame(ffv, true, true);
727
                    	m_layout.getLayoutControl().setDefaultTool();
726 728
                    }
727 729
                    if (createdView!=null && createdView!=getSelectedView()) { // a view was created but later de-selected
728 730
                    	deleteView();
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/resources-plugin/i18n/text.properties
24 24
Grid_and_ruler=Malla y regla
25 25
Show_page_config_dialog_when_layout_document_is_created=Mostrar el di?logo de configuraci?n de p?gina cuando se crea un documento Mapa
26 26
User_interface=Interfaz de usuario
27
Show_table_of_contents_TOC_for_Layout_views=Mostrar tabla de contenidos (TOC) para las vistas del Layout
27
Show_table_of_contents_TOC_for_Layout_views=Mostrar tabla de contenidos (TOC) para las vistas del Layout
28
Synchronize_layers=Sincronizar capas
29
Synchronize_extents=Sincronizar extensi?n del mapa
30
Warning_Enabling_layer_synchronization_will_discard_any_change_not_present_in_associated_view=??Cuidado!! Al activar la sincronizaci?n de capas se perder? cualquier cambio que no est? presente en la vista asociada
31
Warning_Layer_sync=Aviso: sincronizaci?n de capas
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
24 24
Grid_and_ruler=Grid and ruler
25 25
Show_page_config_dialog_when_layout_document_is_created=Show the page config dialog when layout document is created
26 26
User_interface=User interface
27
Show_table_of_contents_TOC_for_Layout_views=Show table of contents (TOC) for Layout views
27
Show_table_of_contents_TOC_for_Layout_views=Show table of contents (TOC) for Layout views
28
Synchronize_layers=Synchronize layers
29
Synchronize_extents=Synchronize map extent
30
Warning_Enabling_layer_synchronization_will_discard_any_change_not_present_in_associated_view=Warning!! Enabling layer synchronization will discard any change not present in the associated view
31
Warning_Layer_sync=Warning: Layer synchronization

Also available in: Unified diff