f6991bcf1a03dc796da3e88f0a5a5826d17b90f8
[scilab.git] / scilab / modules / gui / src / java / org / scilab / modules / gui / ged / SwapObject.java
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2012 2013 - Marcos CARDINOT
4  *
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12 package org.scilab.modules.gui.ged;
13
14 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
15 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
16 import org.scilab.modules.gui.ged.graphic_objects.axes.Axes;
17 import org.scilab.modules.gui.ged.graphic_objects.champ.Champ;
18 import org.scilab.modules.gui.ged.graphic_objects.datatip.Datatip;
19 import org.scilab.modules.gui.ged.graphic_objects.fec.Fec;
20 import org.scilab.modules.gui.ged.graphic_objects.figure.Figure;
21 import org.scilab.modules.gui.ged.graphic_objects.imageplot.Imageplot;
22 import org.scilab.modules.gui.ged.graphic_objects.label.Label;
23 import org.scilab.modules.gui.ged.graphic_objects.legend.Legend;
24 import org.scilab.modules.gui.ged.graphic_objects.polyline.Polyline;
25 import org.scilab.modules.gui.ged.graphic_objects.rectangle.Rectangle;
26 import org.scilab.modules.gui.ged.graphic_objects.segs.Segs;
27 import org.scilab.modules.gui.ged.graphic_objects.surface.Surface;
28
29 /**
30 * Manager object exchange.
31 *
32 * @author Marcos CARDINOT <mcardinot@gmail.com>
33 */
34 public class SwapObject {
35     private static int lastType;
36
37     /**
38     * Manager which property window will open.
39     * @param objectID Enters the identification of object.
40     */
41     public SwapObject(String objectID) {
42         Integer type = (Integer) GraphicController.getController().getProperty(objectID, GraphicObjectProperties.__GO_TYPE__);
43         lastType = type;
44         switch (type) {
45             case GraphicObjectProperties.__GO_POLYLINE__:
46                 Polyline polyline = new Polyline(objectID);
47                 SwingInspector.setPanel(polyline, MessagesGED.polyline);
48                 break;
49             case GraphicObjectProperties.__GO_PLOT3D__:
50                 Surface plot3d = new Surface(objectID);
51                 SwingInspector.setPanel(plot3d, MessagesGED.plot3d);
52                 break;
53             case GraphicObjectProperties.__GO_GRAYPLOT__:
54                 Imageplot grayplot = new Imageplot(objectID);
55                 SwingInspector.setPanel(grayplot, MessagesGED.grayplot);
56                 break;
57             case GraphicObjectProperties.__GO_FAC3D__:
58                 Surface fac3d = new Surface(objectID);
59                 SwingInspector.setPanel(fac3d, MessagesGED.fac3d);
60                 break;
61             case GraphicObjectProperties.__GO_MATPLOT__:
62                 Imageplot matplot = new Imageplot(objectID);
63                 SwingInspector.setPanel(matplot, MessagesGED.matplot);
64                 break;
65             case GraphicObjectProperties.__GO_LEGEND__:
66                 Legend legend = new Legend(objectID);
67                 SwingInspector.setPanel(legend, MessagesGED.legend);
68                 break;
69             case GraphicObjectProperties.__GO_LABEL__:
70                 Label label = new Label(objectID);
71                 SwingInspector.setPanel(label, MessagesGED.label);
72                 break;
73             case GraphicObjectProperties.__GO_ARC__:
74                 break;
75             case GraphicObjectProperties.__GO_CHAMP__:
76                 Champ champ = new Champ(objectID);
77                 SwingInspector.setPanel(champ, MessagesGED.champ);
78                 break;
79             case GraphicObjectProperties.__GO_FEC__:
80                 Fec fec = new Fec(objectID);
81                 SwingInspector.setPanel(fec, MessagesGED.fec);
82                 break;
83             case GraphicObjectProperties.__GO_RECTANGLE__:
84                 Rectangle rectangle = new Rectangle(objectID);
85                 SwingInspector.setPanel(rectangle, MessagesGED.rectangle);
86                 break;
87             case GraphicObjectProperties.__GO_SEGS__:
88                 Segs segs = new Segs(objectID);
89                 SwingInspector.setPanel(segs, MessagesGED.segs);
90                 break;
91             case GraphicObjectProperties.__GO_DATATIP__:
92                 Datatip datatip = new Datatip(objectID);
93                 SwingInspector.setPanel(datatip, MessagesGED.datatip);
94                 break;
95             case GraphicObjectProperties.__GO_AXES__:
96                 Axes axes = new Axes(objectID);
97                 SwingInspector.setPanel(axes, MessagesGED.axes);
98                 break;
99             default:
100                 try {
101                     Figure figure = new Figure(objectID);
102                     SwingInspector.setPanel(figure, MessagesGED.figure);
103                 } catch (NullPointerException e) { }
104                 break;
105         }
106     }
107
108     /**
109     * Get the last type of object.
110     * @return type
111     */
112     public static int getLastType() {
113         return lastType;
114     }
115 }