use backgroundcolor [-2 -2 -2] for transparence
[scilab.git] / scilab / modules / graphic_objects / src / java / org / scilab / modules / graphic_objects / xmlloader / GOBuilder.java
index 30d6593..6f30e44 100644 (file)
@@ -1,11 +1,10 @@
 package org.scilab.modules.graphic_objects.xmlloader;
 
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES_SIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_IMAGE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_AXES_SIZE__;
 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__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CALLBACK__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_CLOSEREQUESTFCN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DOCKABLE__;
@@ -39,6 +38,7 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTNAME__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTSIZE__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTWEIGHT__;
+import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FOREGROUNDCOLOR__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_COLOR__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__;
 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__;
@@ -188,7 +188,7 @@ public class GOBuilder {
     public static Integer axesBuilder(GraphicController controller, Attributes attributes) {
         Integer axes = GraphicController.getController().askObject(Type.AXES);
         String id = attributes.getValue("id");
-        if(id != null) {
+        if (id != null) {
             controller.setProperty(axes, __GO_TAG__, id);
         }
         return axes;
@@ -291,6 +291,8 @@ public class GOBuilder {
 
 
             //font properties
+
+            //fontname
             item = xmlAttributes.get("font-name");
             if (item != null) {
                 controller.setProperty(uic, __GO_UI_FONTNAME__, item);
@@ -301,6 +303,7 @@ public class GOBuilder {
                 controller.setProperty(uic, __GO_UI_FONTNAME__, item);
             }
 
+            //fontsize
             item = xmlAttributes.get("font-size");
             if (item != null) {
                 controller.setProperty(uic, __GO_UI_FONTSIZE__, Double.parseDouble(item));
@@ -311,6 +314,34 @@ public class GOBuilder {
                 controller.setProperty(uic, __GO_UI_FONTSIZE__, Double.parseDouble(item));
             }
 
+            //units and position
+            String[] units = null;
+            item = xmlAttributes.get("units");
+            if (item != null) {
+                units = item.split("[,;]");
+            }
+
+            //position, take care of units values
+            item = xmlAttributes.get("position");
+            if (item != null) {
+                Double[] pos = new Double[4];
+                Double[] parentSize = new Double[] {934.0, 511.0};
+                String[] strPos = item.split("[,;]");
+                for (int i = 0 ; i < strPos.length ; i++) {
+                    pos[i] = Double.parseDouble(strPos[i]);
+                    if (units != null && units[i].equals("n")) {
+                        //convert %age to pixel
+                        pos[i] = parentSize[i % 2] * pos[i];
+                    }
+                }
+
+                controller.setProperty(uic,  __GO_POSITION__, pos);
+            }
+
+            item = xmlAttributes.get("opaque");
+            if (item != null && (item.equals("false") || item.equals("off"))) {
+                controller.setProperty(uic, __GO_UI_BACKGROUNDCOLOR__, new Double[] { -2.0, -2.0, -2.0});
+            }
 
             if (layout != LayoutType.NONE) {
                 item = xmlAttributes.get("constraint");
@@ -325,7 +356,7 @@ public class GOBuilder {
                         Integer[] preferredsize = new Integer[] { -1, -1};
                         item = xmlAttributes.get("preferred-size");
                         if (item != null) {
-                            String[] pref = item.split(",");
+                            String[] pref = item.split("[,;]");
                             for (int i = 0; i < pref.length && i < 4; i++) {
                                 preferredsize[i] = Integer.parseInt(pref[i]);
                             }
@@ -355,7 +386,7 @@ public class GOBuilder {
                         Integer[] preferredsize = new Integer[] { -1, -1};
                         item = xmlAttributes.get("preferred-size");
                         if (item != null) {
-                            String[] pref = item.split(",");
+                            String[] pref = item.split("[,;]");
                             for (int i = 0; i < pref.length && i < 4; i++) {
                                 preferredsize[i] = Integer.parseInt(pref[i]);
                             }
@@ -375,7 +406,7 @@ public class GOBuilder {
                 // insets -> marging
                 String insets = XmlTools.getFromMap(map, "insets", "0,0,0,0");
                 Double[] margins = new Double[] { 0.0, 0.0, 0.0, 0.0 };
-                String[] inset = insets.split(",");
+                String[] inset = insets.split("[,;]");
                 for (int i = 0; i < inset.length && i < 4; i++) {
                     margins[i] = Double.parseDouble(inset[i]);
                 }