save/load axes tag 48/13948/3
Antoine ELIAS [Fri, 7 Mar 2014 09:45:03 +0000 (10:45 +0100)]
Change-Id: I435969cc608ca7c87cf869b0b251ca2b4cd99df4

scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/GOBuilder.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlLoader.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/xmlloader/XmlSaver.java

index 6b75f65..b5a40ed 100644 (file)
@@ -1,5 +1,7 @@
 package org.scilab.modules.graphic_objects.xmlloader;
 
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FOREGROUNDCOLOR__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACKTYPE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FOREGROUNDCOLOR__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
@@ -82,6 +84,7 @@ import java.util.Map;
 import org.scilab.modules.graphic_objects.builder.Builder;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
 import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
+import org.scilab.modules.graphic_objects.graphicObject.GraphicObject.Type;
 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
 import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder;
 import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder.BorderType;
@@ -181,6 +184,15 @@ public class GOBuilder {
         return fig;
     }
 
+    public static Integer axesBuilder(GraphicController controller, Attributes attributes) {
+        Integer axes = GraphicController.getController().askObject(Type.AXES);
+        String id = attributes.getValue("id");
+        if(id != null) {
+            controller.setProperty(axes, __GO_TAG__, id);
+        }
+        return axes;
+    }
+
     public static Integer uicontrolBuilder(GraphicController controller, int type, Attributes attributes, int parent) {
         if (type == __GO_UI_FRAME__) {
             String item = attributes.getValue("scrollable");
@@ -517,13 +529,10 @@ public class GOBuilder {
                     //color
                     item = xmlAttributes.get("color");
                     if (item != null) {
-                        System.out.println("Color : " + item);
                         Color color = Color.decode(item);
                         Double[] val = new Double[] {(double) color.getRed() / 255, (double) color.getGreen() / 255, (double) color.getBlue() / 255};
-                        System.out.println("color : [" + val[0] + "," + val[1] + "," + val[2] + "]");
                         controller.setProperty(uic, __GO_UI_FOREGROUNDCOLOR__, val);
                     }
-
                     break;
                 }
                 case __GO_UI_EDIT__ : {
index 6041a8b..3c77fa2 100644 (file)
@@ -18,6 +18,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_FIGURE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TYPE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UIMENU__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_EDIT__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER__;
@@ -270,7 +271,7 @@ public class XmlLoader extends DefaultHandler {
                     // never create a new figure, clone figure model !
                     go = GOBuilder.figureBuilder(controller, attributes);
                 } else if (uitype == __GO_AXES__) {
-                    go = GraphicController.getController().askObject(Type.AXES);
+                    go = GOBuilder.axesBuilder(controller, attributes);
                 } else if (uitype == __GO_UIMENU__) {
                     Integer parent = 0;
                     if (stackGO.isEmpty() == false) {
@@ -300,7 +301,6 @@ public class XmlLoader extends DefaultHandler {
                         Integer newgo = cloneObject(go);
                         GOBuilder.uicontrolUpdater(controller, newgo, attributes, stackGO.peek(), entry.getValue());
                         go = newgo;
-
                     }
                 }
             }
@@ -348,7 +348,7 @@ public class XmlLoader extends DefaultHandler {
 
                 controller.setGraphicObjectRelationship(newGo, go);
                 controller.setProperty(newGo, GraphicObjectProperties.__GO_SELECTED_CHILD__, go);
-
+                controller.setProperty(go, GraphicObjectProperties.__GO_TAG__, controller.getProperty(children[i], __GO_TAG__));
                 ScilabNativeView.ScilabNativeView__setCurrentSubWin(go);
                 ScilabNativeView.ScilabNativeView__setCurrentObject(go);
             } else if (childType == __GO_UI_FRAME_BORDER__) {
index b6ef830..4329a52 100644 (file)
@@ -24,6 +24,7 @@ import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
 import org.scilab.modules.commons.CommonFileUtils;
+import org.scilab.modules.graphic_objects.axes.Axes;
 import org.scilab.modules.graphic_objects.console.Console;
 import org.scilab.modules.graphic_objects.figure.Figure;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
@@ -202,13 +203,23 @@ public class XmlSaver {
             }
             case __GO_AXES__ : {
                 //Axes axes = (Axes)controller.getObjectFromId(id);
-                return doc.createElement("axes");
+                return createAxes(doc, id, reverseChildren);
             }
         }
 
         return doc.createElement("fake");
     }
 
+    private static Element createAxes(Document doc, Integer id, boolean reverseChildren) {
+        GraphicController controller = GraphicController.getController();
+        Axes axes = (Axes)controller.getObjectFromId(id);
+
+        Element elemAxes = doc.createElement("axes");
+        setAttribute(elemAxes, "tag", createAttribute(axes.getTag()), createAttribute(""));
+
+        return elemAxes;
+    }
+
     private static Element createBorders(Document doc, Integer id) {
         return createBorders(doc, id, "borders");
     }