Revision 326

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/gui/DefaultLayoutPanel.java
581 581
    public void loadFromState(PersistentState state)
582 582
        throws PersistenceException {
583 583
        this.layoutContext = (LayoutContext) state.get(LAYOUTCONTEXT_OBJECT);
584
        this.layoutDocument = (LayoutDocument) state.get(LAYOUTDOCUMENT_OBJECT);
585
        this.layoutControl.setLayoutContext(layoutContext);
584
        this.setDocument((LayoutDocument) state.get(LAYOUTDOCUMENT_OBJECT));
586 585
    }
587 586

  
588 587
    public static void registerPersistent() {
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
936 936
        else {
937 937
        	syncLayers = true;
938 938
        }
939
        double layoutScale = state.getDouble(SCALE_FIELD);
939
        Double layoutScale = null;
940
        if (state.hasValue(SCALE_FIELD)) { 
941
        	layoutScale = state.getDouble(SCALE_FIELD);
942
        }
940 943
    	Envelope envelope = (Envelope) state.get(ENVELOPE_FIELD); 
941 944

  
942 945
        if (state.hasValue(SCALE_TYPE_FIELD)) {
......
947 950
        	}
948 951
        	else if (value==SCALE_TYPE.FIXED_SCALE.ordinal()) {
949 952
        		scaleType = SCALE_TYPE.FIXED_SCALE;
950
        		fixedScale = new Double(layoutScale);
953
        		fixedScale = layoutScale;
951 954
        	}
952 955
        	// else use the default value
953 956
        }
......
965 968
        	// create 2 separate EventBuffers, which will then have a very stange behaviour
966 969
        }
967 970
        if (getMapContext()!=null) {
968
        	getMapContext().setScaleView((long)layoutScale);
971
        	if (layoutScale!=null) {
972
        		getMapContext().setScaleView(layoutScale.longValue());
973
        	}
969 974
        	getMapContext().getViewPort().setEnvelope(envelope);
970 975
        	if (this.getLayoutContext()!=null) {
971 976
        		this.getLayoutContext().setTocModel(getMapContext());
......
989 994

  
990 995
        if (getMapContext() != null
991 996
            && getMapContext().getViewPort().getEnvelope() != null) {
992
        	if (scaleType==SCALE_TYPE.FIXED_SCALE && fixedScale!=null) {
997
        	if (scaleType==SCALE_TYPE.FIXED_SCALE) {
998
        		if (fixedScale==null) {
999
        			fixedScale = new Double(getMapContext().getScaleView());
1000
        		}
993 1001
        		state.set(SCALE_FIELD, (double)fixedScale);
994 1002
        	}
995 1003
        	else {
996 1004
        		state.set(SCALE_FIELD, (double)getMapContext().getScaleView());	
997 1005
        	}
998
        	if (scaleType == SCALE_TYPE.FIXED_EXTENT && fixedExtent!=null) {
1006
        	if (scaleType == SCALE_TYPE.FIXED_EXTENT) {
1007
        		if (fixedExtent==null) {
1008
        			fixedExtent = getMapContext().getViewPort().getAdjustedEnvelope();
1009
        		}
999 1010
        		state.set(ENVELOPE_FIELD, fixedExtent);
1000 1011
        	}
1001 1012
        	else {
......
1368 1379
				}
1369 1380
				else {
1370 1381
					Envelope newEnvelope;
1371
					if (scaleType==SCALE_TYPE.FIXED_SCALE) {
1382
					if (scaleType==SCALE_TYPE.FIXED_SCALE && fixedScale!=null) {
1372 1383
						getMapContext().setScaleView(Math.round(fixedScale));
1373 1384
						newEnvelope = getMapContext().getViewPort().getAdjustedEnvelope();
1374 1385
					}
trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/extension/LayoutMainExtension.java
99 99
import org.gvsig.tools.persistence.PersistentState;
100 100
import org.gvsig.tools.persistence.exception.PersistenceException;
101 101
import org.gvsig.utils.GenericFileFilter;
102
import org.slf4j.Logger;
103
import org.slf4j.LoggerFactory;
102 104

  
103 105
/**
104 106
 * Extension que proporciona controles para crear proyectos nuevos, abrirlos y
......
108 110
 * @author Fernando Gonz?lez Cort?s
109 111
 */
110 112
public class LayoutMainExtension extends Extension {
111

  
113
    private static final Logger logger = LoggerFactory
114
            .getLogger(FFrameView.class);
112 115
    private String templatesPath;
113 116
    public static final String LAYOUT_TEMPLATE_FILECHOOSER_ID =
114 117
        "LAYOUT_TEMPLATE_FILECHOOSER_ID";
......
186 189
                    (LayoutPanel) persistenceManager.create(persistentState);
187 190

  
188 191
            } catch (Exception e) {
189
                
190 192
                String tit = Messages.getText("_Layout_template");
191 193
                String msg = null;
192 194
                
......
198 200
                
199 201
                msg = msg + ": " + file.getPath();
200 202
                msg = msg + "\n" + e.getMessage();
203
                logger.warn(msg, e);
201 204
                JOptionPane.showMessageDialog(
202 205
                    ApplicationLocator.getManager().getRootComponent(),
203 206
                    msg, tit, JOptionPane.ERROR_MESSAGE);
......
215 218
                
216 219
            Project p = ApplicationLocator.getManager().getProjectManager()
217 220
                    .getCurrentProject();
218
            p.add(layoutDocument);
221
            p.addDocument(layoutDocument);
219 222
            
220 223
            layout.getLayoutControl().setTool("layoutselect");
221 224
            

Also available in: Unified diff