a1b8686f0eb804b688ae1cffd840ab3e5aa48c03
[scilab.git] / scilab / modules / gui / src / java / org / scilab / modules / gui / ged / GEDView.java
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2013 - Marcos CARDINOT
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15 package org.scilab.modules.gui.ged;
16
17 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
18 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
19 import org.scilab.modules.graphic_objects.graphicView.GraphicView;
20
21 /**
22  *
23  * @author Marcos CARDINOT <mcardinot@gmail.com>
24  */
25 public class GEDView implements GraphicView {
26     private String lastID = null;
27
28     private static boolean visible = true;
29     private static boolean autoresize = true;
30     private static Integer pixelDrawingMode = 3;
31     private static Integer antialiasing = 0;
32     private static Integer rotationType = 0;
33     private static Integer clipState = 1;
34     private static boolean lineMode = true;
35     private static Integer lineStyle = 0;
36     private static boolean markMode = false;
37     private static Integer markSizeUnit = 1;
38     private static Integer dataMapping = 0;
39     private static boolean closed = false;
40     private static boolean surfaceMode = true;
41     private static boolean colored = true;
42     private static Integer datatipOrientation = 0;
43     private static String datatipDisplayComponents = "";
44     private static boolean datatipAutoOrientation = true;
45     private static boolean datatipBoxMode = true;
46     private static boolean datatipLabelMode = true;
47     private static Integer fontStyle = 0;
48     private static boolean fontFractional = false;
49     private static Integer legendLocation = 0;
50     private static boolean autoPosition = true;
51     private static boolean autoRotation = true;
52
53     public GEDView() {
54         GraphicController.getController().register(this);
55     }
56
57     @Override
58     public void updateObject(Integer id, int property) {
59         if (SwapObject.getLastType() == (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__)) {
60             boolean isValid = false;
61             switch (property) {
62                 case GraphicObjectProperties.__GO_VISIBLE__:
63                     boolean c_visible = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_VISIBLE__);
64                     if (visible != c_visible) {
65                         isValid = true;
66                         visible = c_visible;
67                     }
68                     break;
69                 case GraphicObjectProperties.__GO_AUTORESIZE__:
70                     boolean c_autoresize = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_AUTORESIZE__);
71                     if (autoresize != c_autoresize) {
72                         isValid = true;
73                         autoresize = c_autoresize;
74                     }
75                     break;
76                 case GraphicObjectProperties.__GO_PIXEL_DRAWING_MODE__:
77                     Integer c_pixelDrawingMode = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_PIXEL_DRAWING_MODE__);
78                     if (pixelDrawingMode != c_pixelDrawingMode) {
79                         isValid = true;
80                         pixelDrawingMode = c_pixelDrawingMode;
81                     }
82                     break;
83                 case GraphicObjectProperties.__GO_ANTIALIASING__:
84                     Integer c_antialiasing = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_ANTIALIASING__);
85                     if (antialiasing != c_antialiasing) {
86                         isValid = true;
87                         antialiasing = c_antialiasing;
88                     }
89                     break;
90                 case GraphicObjectProperties.__GO_ROTATION_TYPE__:
91                     Integer c_rotationType = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_ROTATION_TYPE__);
92                     if (rotationType != c_rotationType) {
93                         isValid = true;
94                         rotationType = c_rotationType;
95                     }
96                     break;
97                 case GraphicObjectProperties.__GO_CLIP_STATE__:
98                     Integer c_clipState = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_CLIP_STATE__);
99                     if (clipState != c_clipState) {
100                         isValid = true;
101                         clipState = c_clipState;
102                     }
103                     break;
104                 case GraphicObjectProperties.__GO_LINE_MODE__:
105                     boolean c_lineMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_LINE_MODE__);
106                     if (lineMode != c_lineMode) {
107                         isValid = true;
108                         lineMode = c_lineMode;
109                     }
110                     break;
111                 case GraphicObjectProperties.__GO_LINE_STYLE__:
112                     Integer c_lineStyle = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_LINE_STYLE__);
113                     if (lineStyle != c_lineStyle) {
114                         isValid = true;
115                         lineStyle = c_lineStyle;
116                     }
117                     break;
118                 case GraphicObjectProperties.__GO_MARK_MODE__:
119                     boolean c_markMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_MARK_MODE__);
120                     if (markMode != c_markMode) {
121                         isValid = true;
122                         markMode = c_markMode;
123                     }
124                     break;
125                 case GraphicObjectProperties.__GO_MARK_SIZE_UNIT__:
126                     Integer c_markSizeUnit = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_MARK_SIZE_UNIT__);
127                     if (markSizeUnit != c_markSizeUnit) {
128                         isValid = true;
129                         markSizeUnit = c_markSizeUnit;
130                     }
131                     break;
132                 case GraphicObjectProperties.__GO_DATA_MAPPING__:
133                     Integer c_dataMapping = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATA_MAPPING__);
134                     if (dataMapping != c_dataMapping) {
135                         isValid = true;
136                         dataMapping = c_dataMapping;
137                     }
138                     break;
139                 case GraphicObjectProperties.__GO_CLOSED__:
140                     boolean c_closed = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_CLOSED__);
141                     if (closed != c_closed) {
142                         isValid = true;
143                         closed = c_closed;
144                     }
145                     break;
146                 case GraphicObjectProperties.__GO_SURFACE_MODE__:
147                     boolean c_surfaceMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_SURFACE_MODE__);
148                     if (surfaceMode != c_surfaceMode) {
149                         isValid = true;
150                         surfaceMode = c_surfaceMode;
151                     }
152                     break;
153                 case GraphicObjectProperties.__GO_COLORED__:
154                     boolean c_colored = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_COLORED__);
155                     if (colored != c_colored) {
156                         isValid = true;
157                         colored = c_colored;
158                     }
159                     break;
160                 case GraphicObjectProperties.__GO_DATATIP_ORIENTATION__:
161                     Integer c_datatipOrientation = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_ORIENTATION__);
162                     if (datatipOrientation != c_datatipOrientation) {
163                         isValid = true;
164                         datatipOrientation = c_datatipOrientation;
165                     }
166                     break;
167                 case GraphicObjectProperties.__GO_DATATIP_DISPLAY_COMPONENTS__:
168                     String c_datatipDisplayComponents = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_DISPLAY_COMPONENTS__);
169                     if (datatipDisplayComponents != c_datatipDisplayComponents) {
170                         isValid = true;
171                         datatipDisplayComponents = c_datatipDisplayComponents;
172                     }
173                     break;
174                 case GraphicObjectProperties.__GO_DATATIP_AUTOORIENTATION__:
175                     boolean c_datatipAutoOrientation = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_AUTOORIENTATION__);
176                     if (datatipAutoOrientation != c_datatipAutoOrientation) {
177                         isValid = true;
178                         datatipAutoOrientation = c_datatipAutoOrientation;
179                     }
180                     break;
181                 case GraphicObjectProperties.__GO_DATATIP_BOX_MODE__:
182                     boolean c_datatipBoxMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_BOX_MODE__);
183                     if (datatipBoxMode != c_datatipBoxMode) {
184                         isValid = true;
185                         datatipBoxMode = c_datatipBoxMode;
186                     }
187                     break;
188                 case GraphicObjectProperties.__GO_DATATIP_LABEL_MODE__:
189                     boolean c_datatipLabelMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_LABEL_MODE__);
190                     if (datatipLabelMode != c_datatipLabelMode) {
191                         isValid = true;
192                         datatipLabelMode = c_datatipLabelMode;
193                     }
194                     break;
195                 case GraphicObjectProperties.__GO_FONT_STYLE__:
196                     Integer c_fontStyle = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_FONT_STYLE__);
197                     if (fontStyle != c_fontStyle) {
198                         isValid = true;
199                         fontStyle = c_fontStyle;
200                     }
201                     break;
202                 case GraphicObjectProperties.__GO_FONT_FRACTIONAL__:
203                     boolean c_fontFractional = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_FONT_FRACTIONAL__);
204                     if (fontFractional != c_fontFractional) {
205                         isValid = true;
206                         fontFractional = c_fontFractional;
207                     }
208                     break;
209                 case GraphicObjectProperties.__GO_LEGEND_LOCATION__:
210                     Integer c_legendLocation = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_LEGEND_LOCATION__);
211                     if (legendLocation != c_legendLocation) {
212                         isValid = true;
213                         legendLocation = c_legendLocation;
214                     }
215                     break;
216                 case GraphicObjectProperties.__GO_AUTO_POSITION__:
217                     boolean c_autoPosition = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_AUTO_POSITION__);
218                     if (autoPosition != c_autoPosition) {
219                         isValid = true;
220                         autoPosition = c_autoPosition;
221                     }
222                     break;
223                 case GraphicObjectProperties.__GO_AUTO_ROTATION__:
224                     boolean c_autoRotation = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_AUTO_ROTATION__);
225                     if (autoRotation != c_autoRotation) {
226                         isValid = true;
227                         autoRotation = c_autoRotation;
228                     }
229                     break;
230                 default:
231                     isValid = true;
232             }
233             if (isValid) {
234                 Inspector.getInspector(id);
235             }
236         }
237     }
238
239     @Override
240     public void createObject(Integer id) {
241     }
242
243     @Override
244     public void deleteObject(Integer id) {
245     }
246
247     public void close() {
248         GraphicController.getController().unregister(this);
249     }
250 }