Coverity fixes: #1351092 #1360853 #1350979
[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
27     private static boolean visible = true;
28     private static boolean autoresize = true;
29     private static Integer pixelDrawingMode = 3;
30     private static Integer antialiasing = 0;
31     private static Integer rotationType = 0;
32     private static Integer clipState = 1;
33     private static boolean lineMode = true;
34     private static Integer lineStyle = 0;
35     private static boolean markMode = false;
36     private static Integer markSizeUnit = 1;
37     private static Integer dataMapping = 0;
38     private static boolean closed = false;
39     private static boolean surfaceMode = true;
40     private static boolean colored = true;
41     private static Integer datatipOrientation = 0;
42     private static String datatipDisplayComponents = "";
43     private static boolean datatipAutoOrientation = true;
44     private static boolean datatipBoxMode = true;
45     private static boolean datatipLabelMode = true;
46     private static Integer fontStyle = 0;
47     private static boolean fontFractional = false;
48     private static Integer legendLocation = 0;
49     private static boolean autoPosition = true;
50     private static boolean autoRotation = true;
51
52     public GEDView() {
53         GraphicController.getController().register(this);
54     }
55
56     @Override
57     public void updateObject(Integer id, int property) {
58         if (SwapObject.getLastType() == (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_TYPE__)) {
59             boolean isValid = false;
60             switch (property) {
61                 case GraphicObjectProperties.__GO_VISIBLE__:
62                     boolean c_visible = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_VISIBLE__);
63                     if (visible != c_visible) {
64                         isValid = true;
65                         visible = c_visible;
66                     }
67                     break;
68                 case GraphicObjectProperties.__GO_AUTORESIZE__:
69                     boolean c_autoresize = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_AUTORESIZE__);
70                     if (autoresize != c_autoresize) {
71                         isValid = true;
72                         autoresize = c_autoresize;
73                     }
74                     break;
75                 case GraphicObjectProperties.__GO_PIXEL_DRAWING_MODE__:
76                     Integer c_pixelDrawingMode = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_PIXEL_DRAWING_MODE__);
77                     if (!(pixelDrawingMode.equals(c_pixelDrawingMode))) {
78                         isValid = true;
79                         pixelDrawingMode = c_pixelDrawingMode;
80                     }
81                     break;
82                 case GraphicObjectProperties.__GO_ANTIALIASING__:
83                     Integer c_antialiasing = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_ANTIALIASING__);
84                     if (!(antialiasing.equals(c_antialiasing))) {
85                         isValid = true;
86                         antialiasing = c_antialiasing;
87                     }
88                     break;
89                 case GraphicObjectProperties.__GO_ROTATION_TYPE__:
90                     Integer c_rotationType = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_ROTATION_TYPE__);
91                     if (!(rotationType.equals(c_rotationType))) {
92                         isValid = true;
93                         rotationType = c_rotationType;
94                     }
95                     break;
96                 case GraphicObjectProperties.__GO_CLIP_STATE__:
97                     Integer c_clipState = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_CLIP_STATE__);
98                     if (!(clipState.equals(c_clipState))) {
99                         isValid = true;
100                         clipState = c_clipState;
101                     }
102                     break;
103                 case GraphicObjectProperties.__GO_LINE_MODE__:
104                     boolean c_lineMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_LINE_MODE__);
105                     if (lineMode != c_lineMode) {
106                         isValid = true;
107                         lineMode = c_lineMode;
108                     }
109                     break;
110                 case GraphicObjectProperties.__GO_LINE_STYLE__:
111                     Integer c_lineStyle = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_LINE_STYLE__);
112                     if (!(lineStyle.equals(c_lineStyle))) {
113                         isValid = true;
114                         lineStyle = c_lineStyle;
115                     }
116                     break;
117                 case GraphicObjectProperties.__GO_MARK_MODE__:
118                     boolean c_markMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_MARK_MODE__);
119                     if (markMode != c_markMode) {
120                         isValid = true;
121                         markMode = c_markMode;
122                     }
123                     break;
124                 case GraphicObjectProperties.__GO_MARK_SIZE_UNIT__:
125                     Integer c_markSizeUnit = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_MARK_SIZE_UNIT__);
126                     if (!(markSizeUnit.equals(c_markSizeUnit))) {
127                         isValid = true;
128                         markSizeUnit = c_markSizeUnit;
129                     }
130                     break;
131                 case GraphicObjectProperties.__GO_DATA_MAPPING__:
132                     Integer c_dataMapping = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATA_MAPPING__);
133                     if (!(dataMapping.equals(c_dataMapping))) {
134                         isValid = true;
135                         dataMapping = c_dataMapping;
136                     }
137                     break;
138                 case GraphicObjectProperties.__GO_CLOSED__:
139                     boolean c_closed = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_CLOSED__);
140                     if (closed != c_closed) {
141                         isValid = true;
142                         closed = c_closed;
143                     }
144                     break;
145                 case GraphicObjectProperties.__GO_SURFACE_MODE__:
146                     boolean c_surfaceMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_SURFACE_MODE__);
147                     if (surfaceMode != c_surfaceMode) {
148                         isValid = true;
149                         surfaceMode = c_surfaceMode;
150                     }
151                     break;
152                 case GraphicObjectProperties.__GO_COLORED__:
153                     boolean c_colored = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_COLORED__);
154                     if (colored != c_colored) {
155                         isValid = true;
156                         colored = c_colored;
157                     }
158                     break;
159                 case GraphicObjectProperties.__GO_DATATIP_ORIENTATION__:
160                     Integer c_datatipOrientation = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_ORIENTATION__);
161                     if (!(datatipOrientation.equals(c_datatipOrientation))) {
162                         isValid = true;
163                         datatipOrientation = c_datatipOrientation;
164                     }
165                     break;
166                 case GraphicObjectProperties.__GO_DATATIP_DISPLAY_COMPONENTS__:
167                     String c_datatipDisplayComponents = (String) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_DISPLAY_COMPONENTS__);
168                     if (!(datatipDisplayComponents.equals(c_datatipDisplayComponents))) {
169                         isValid = true;
170                         datatipDisplayComponents = c_datatipDisplayComponents;
171                     }
172                     break;
173                 case GraphicObjectProperties.__GO_DATATIP_AUTOORIENTATION__:
174                     boolean c_datatipAutoOrientation = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_AUTOORIENTATION__);
175                     if (datatipAutoOrientation != c_datatipAutoOrientation) {
176                         isValid = true;
177                         datatipAutoOrientation = c_datatipAutoOrientation;
178                     }
179                     break;
180                 case GraphicObjectProperties.__GO_DATATIP_BOX_MODE__:
181                     boolean c_datatipBoxMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_BOX_MODE__);
182                     if (datatipBoxMode != c_datatipBoxMode) {
183                         isValid = true;
184                         datatipBoxMode = c_datatipBoxMode;
185                     }
186                     break;
187                 case GraphicObjectProperties.__GO_DATATIP_LABEL_MODE__:
188                     boolean c_datatipLabelMode = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_DATATIP_LABEL_MODE__);
189                     if (datatipLabelMode != c_datatipLabelMode) {
190                         isValid = true;
191                         datatipLabelMode = c_datatipLabelMode;
192                     }
193                     break;
194                 case GraphicObjectProperties.__GO_FONT_STYLE__:
195                     Integer c_fontStyle = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_FONT_STYLE__);
196                     if (!(fontStyle.equals(c_fontStyle))) {
197                         isValid = true;
198                         fontStyle = c_fontStyle;
199                     }
200                     break;
201                 case GraphicObjectProperties.__GO_FONT_FRACTIONAL__:
202                     boolean c_fontFractional = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_FONT_FRACTIONAL__);
203                     if (fontFractional != c_fontFractional) {
204                         isValid = true;
205                         fontFractional = c_fontFractional;
206                     }
207                     break;
208                 case GraphicObjectProperties.__GO_LEGEND_LOCATION__:
209                     Integer c_legendLocation = (Integer) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_LEGEND_LOCATION__);
210                     if (!(legendLocation.equals(c_legendLocation))) {
211                         isValid = true;
212                         legendLocation = c_legendLocation;
213                     }
214                     break;
215                 case GraphicObjectProperties.__GO_AUTO_POSITION__:
216                     boolean c_autoPosition = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_AUTO_POSITION__);
217                     if (autoPosition != c_autoPosition) {
218                         isValid = true;
219                         autoPosition = c_autoPosition;
220                     }
221                     break;
222                 case GraphicObjectProperties.__GO_AUTO_ROTATION__:
223                     boolean c_autoRotation = (Boolean) GraphicController.getController().getProperty(id, GraphicObjectProperties.__GO_AUTO_ROTATION__);
224                     if (autoRotation != c_autoRotation) {
225                         isValid = true;
226                         autoRotation = c_autoRotation;
227                     }
228                     break;
229                 default:
230                     isValid = true;
231             }
232             if (isValid) {
233                 Inspector.getInspector(id);
234             }
235         }
236     }
237
238     @Override
239     public void createObject(Integer id) {
240     }
241
242     @Override
243     public void deleteObject(Integer id) {
244     }
245
246     public void close() {
247         GraphicController.getController().unregister(this);
248     }
249 }