RSS

(root)/freeplane/freeplane_program/release_branches/1_0_x : 888 : freeplane/src/org/freeplane/features/common/addins/mapstyle/MapStyle.java

« back to all changes in this revision

Viewing changes to freeplane/src/org/freeplane/features/common/addins/mapstyle/MapStyle.java

dpolivaev at sourceforge
2009-11-15 10:06:02
Revision ID: dpolivaev@users.sourceforge.net-20091115100602-wxmefhl9h5gkvh0q
save zoom and layout type in the map file

Show diffs side-by-side

added added

removed removed

52
52
 
53
53
        @Override
54
54
        protected IExtension createExtension(final NodeModel node, final XMLElement element) {
 
55
                final MapStyleModel model = new MapStyleModel();
 
56
 
55
57
                final String colorString = element.getAttribute("background", null);
56
58
                final Color bgColor;
57
59
                if (colorString != null) {
60
62
                else {
61
63
                        bgColor = null;
62
64
                }
63
 
                final MapStyleModel model = new MapStyleModel();
64
65
                model.setBackgroundColor(bgColor);
 
66
                final String zoomString = element.getAttribute("zoom", null);
 
67
                if (zoomString != null) {
 
68
                        final float zoom = Float.valueOf(zoomString);
 
69
                        model.setZoom(zoom);
 
70
                }
 
71
                
 
72
                final String layoutString =  element.getAttribute("layout", null);
 
73
                try{
 
74
                        if (layoutString != null) {
 
75
                                final MapViewLayout layout = MapViewLayout.valueOf(layoutString);
 
76
                                model.setMapViewLayout(layout);
 
77
                        }
 
78
                }
 
79
                catch (Exception e){
 
80
                }
65
81
                return model;
66
82
        }
67
83
 
96
112
        @Override
97
113
        protected void saveExtension(final IExtension extension, final XMLElement element) {
98
114
                super.saveExtension(extension, element);
99
 
                final Color backgroundColor = ((MapStyleModel) extension).getBackgroundColor();
 
115
                MapStyleModel mapStyleModel = (MapStyleModel) extension;
 
116
                final Color backgroundColor = mapStyleModel.getBackgroundColor();
100
117
                if (backgroundColor != null) {
101
118
                        element.setAttribute("background", ColorUtils.colorToString(backgroundColor));
102
119
                }
 
120
                float zoom = mapStyleModel.getZoom();
 
121
                if(zoom != 1f){
 
122
                        element.setAttribute("zoom", Float.toString(zoom));
 
123
                }
 
124
                MapViewLayout layout = mapStyleModel.getMapViewLayout();
 
125
                if(! layout.equals(MapViewLayout.MAP)){
 
126
                        element.setAttribute("layout", layout.toString());
 
127
                }
103
128
        }
104
129
 
 
130
        public void setZoom(MapModel map, final float zoom ) {
 
131
                final MapStyleModel mapStyleModel = MapStyleModel.getExtension(map); 
 
132
                if(zoom == mapStyleModel.getZoom()){
 
133
                        return;
 
134
                }
 
135
                mapStyleModel.setZoom(zoom);
 
136
                getModeController().getMapController().setSaved(map, false);
 
137
        }
 
138
        
 
139
        public void setMapViewLayout(MapModel map, final MapViewLayout layout ) {
 
140
                final MapStyleModel mapStyleModel = MapStyleModel.getExtension(map); 
 
141
                if(layout.equals(mapStyleModel.getMapViewLayout())){
 
142
                        return;
 
143
                }
 
144
                mapStyleModel.setMapViewLayout(layout);
 
145
                getModeController().getMapController().setSaved(map, false);
 
146
        }
 
147
        
105
148
        public void setBackgroundColor(final MapStyleModel model, final Color actionColor) {
106
149
                final Color oldColor = model.getBackgroundColor();
107
150
                if (actionColor == oldColor || actionColor != null && actionColor.equals(oldColor)) {

Loggerhead 1.17 is a web-based interface for Bazaar branches