e1b1f0af7cc4ea0c9cc53aad16d74906b4a15b71
[scilab.git] / scilab / modules / graphic_objects / src / java / org / scilab / modules / graphic_objects / xmlloader / GOBuilder.java
1 package org.scilab.modules.graphic_objects.xmlloader;
2
3 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_BORDER_OPT_PADDING__;
4 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_DOCKABLE__;
5 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_GRID__;
6 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_GRID_OPT_PADDING__;
7 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_INFOBAR_VISIBLE__;
8 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LAYOUT__;
9 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LINE_THICKNESS__;
10 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MARGINS__;
11 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_MENUBAR_VISIBLE__;
12 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_NAME__;
13 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POSITION__;
14 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_RESIZE__;
15 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_SIZE__;
16 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_STYLE__;
17 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TAG__;
18 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TITLE__;
19 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TOOLBAR_VISIBLE__;
20 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TYPE__;
21 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BACKGROUNDCOLOR__;
22 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_BORDER_POSITION__;
23 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_CHECKBOX__;
24 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ENABLE__;
25 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTANGLE__;
26 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTNAME__;
27 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTSIZE__;
28 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTWEIGHT__;
29 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_COLOR__;
30 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__;
31 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__;
32 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_IN_BORDER__;
33 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_JUSTIFICATION__;
34 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_OUT_BORDER__;
35 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_POSITION__;
36 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_ROUNDED__;
37 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_SHADOW_IN__;
38 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_SHADOW_OUT__;
39 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_STYLE__;
40 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_TITLE__;
41 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER__;
42 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_SCROLLABLE__;
43 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME__;
44 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_ANCHOR__;
45 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_FILL__;
46 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_GRID__;
47 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_PADDING__;
48 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_GRIDBAG_WEIGHT__;
49 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_HORIZONTALALIGNMENT__;
50 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_ICON__;
51 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_MAX__;
52 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_PUSHBUTTON__;
53 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_SCROLLABLE__;
54 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_STRING__;
55 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TAB__;
56 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_TEXT__;
57 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_VISIBLE__;
58
59 import java.awt.Color;
60 import java.io.File;
61 import java.lang.reflect.Field;
62 import java.util.Map;
63
64 import org.scilab.modules.graphic_objects.builder.Builder;
65 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
66 import org.scilab.modules.graphic_objects.graphicObject.GraphicObject;
67 import org.scilab.modules.graphic_objects.uicontrol.Uicontrol;
68 import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder;
69 import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorder.BorderType;
70 import org.scilab.modules.graphic_objects.uicontrol.frame.border.FrameBorderType;
71 import org.scilab.modules.graphic_objects.utils.LayoutType;
72 import org.xml.sax.Attributes;
73
74 public class GOBuilder {
75     public static Integer figureBuilder(GraphicController controller, Attributes attributes) {
76         Integer fig = Builder.createFigure(false, 0, 0, false, false);
77         //Integer fig = Builder.createNewFigureWithAxes();
78         String item = null;
79
80         // hide toolbar
81         controller.setProperty(fig, __GO_TOOLBAR_VISIBLE__, false);
82
83         // hide menubar
84         controller.setProperty(fig, __GO_MENUBAR_VISIBLE__, false);
85
86         // hide infobar
87         controller.setProperty(fig, __GO_INFOBAR_VISIBLE__, false);
88
89         // remove docking bar
90         controller.setProperty(fig, __GO_DOCKABLE__, false);
91
92         // id
93         XmlTools.setPropAsString(fig, __GO_TAG__, attributes.getValue("id"));
94
95         // position
96         Integer[] position = (Integer[]) controller.getProperty(fig, __GO_POSITION__);
97
98         // posX
99         item = attributes.getValue("posX");
100         if (item != null) {
101             position[0] = Integer.parseInt(item);
102         }
103
104         // posY
105         item = attributes.getValue("posY");
106         if (item != null) {
107             position[1] = Integer.parseInt(item);
108         }
109
110         // set position
111         controller.setProperty(fig, __GO_POSITION__, position);
112
113         Integer[] size = (Integer[]) controller.getProperty(fig, __GO_SIZE__);
114         // width
115         item = attributes.getValue("width");
116         if (item != null) {
117             size[0] = Integer.parseInt(item);
118         }
119
120         // height
121         item = attributes.getValue("height");
122         if (item != null) {
123             size[1] = Integer.parseInt(item);
124         }
125
126         // set size
127         controller.setProperty(fig, __GO_SIZE__, size);
128
129         // title
130         XmlTools.setPropAsString(fig, __GO_NAME__, attributes.getValue("title"));
131
132         // icon
133         // XmlTools.setPropAsString(fig, __GO_ICON__,
134         // attributes.getValue("icon"));
135
136         // resizable
137         XmlTools.setPropAsBoolean(fig, __GO_RESIZE__, attributes.getValue("resizable"));
138
139         // layout and layout_options
140         item = attributes.getValue("layout");
141         if (item == null) {
142             item = "name:border"; //default layout is border
143         }
144
145         setLayoutProperty(controller, fig, item);
146
147
148         //icon
149         item = attributes.getValue("icon");
150         if (item != null) {
151             controller.setProperty(fig, __GO_UI_ICON__, item);
152         }
153
154         // visible
155         XmlTools.setPropAsBoolean(fig, __GO_VISIBLE__, attributes.getValue("visible"));
156
157         return fig;
158     }
159
160     public static Integer uicontrolBuilder(GraphicController controller, int type, Attributes attributes, int parent) {
161         if (type == __GO_UI_FRAME__) {
162             String item = attributes.getValue("scrollable");
163             if (item != null && item.equals("true")) {
164                 type = __GO_UI_FRAME_SCROLLABLE__;
165             }
166         }
167
168         Integer uic = controller.askObject(GraphicObject.getTypeFromName(type));
169         return uicontrolUpdater(controller, uic, attributes, parent);
170     }
171
172     public static Integer uicontrolUpdater(GraphicController controller, int uic, Attributes attributes, int parent) {
173         return uicontrolUpdater(controller, uic, attributes, parent, null);
174     }
175
176     public static Integer uicontrolUpdater(GraphicController controller, int uic, Attributes attributes, int parent, Map<String, String> fromModel) {
177         String item = null;
178
179         try {
180             Map<String, String> map = null;
181             // Common attributes
182
183             // id
184             XmlTools.setPropAsString(uic, __GO_TAG__, attributes.getValue("id"));
185
186             // layout and layout_options
187             item = attributes.getValue("layout");
188             if (item == null) {
189                 if (fromModel != null) {
190                     item = fromModel.get("layout");
191                 }
192             }
193
194             if (item == null) {
195                 item = "name:none";
196             }
197             setLayoutProperty(controller, uic, item);
198
199             //visible
200             item = attributes.getValue("visible");
201             if (item == null || item.equals("true") || item.equals("on")) {
202                 controller.setProperty(uic, __GO_VISIBLE__, true);
203             } else {
204                 controller.setProperty(uic, __GO_VISIBLE__, false);
205             }
206
207             //enable
208             item = attributes.getValue("enable");
209             if (item == null || item.equals("true") || item.equals("on")) {
210                 controller.setProperty(uic, __GO_UI_ENABLE__, true);
211             } else {
212                 controller.setProperty(uic, __GO_UI_ENABLE__, false);
213             }
214
215             //backgroundcolor
216             item = attributes.getValue("background");
217             if (item != null) {
218
219                 controller.setProperty(uic, __GO_UI_BACKGROUNDCOLOR__, getColor(item));
220             }
221
222             // constraints
223
224             // get parent layout
225             LayoutType layout = LayoutType.NONE;
226             if (parent != 0) {
227                 layout = LayoutType.intToEnum((Integer) controller.getProperty(parent, __GO_LAYOUT__));
228             }
229
230             if (layout != LayoutType.NONE) {
231                 item = attributes.getValue("constraint");
232                 if (item == null && fromModel != null) {
233                     // use value from model if property is not in "declaration"
234                     item = XmlTools.getFromMap(fromModel, "constraint");
235                 }
236
237                 if (item != null) {
238                     map = CSSParser.parseLine(item);
239                 }
240
241                 switch (layout) {
242                     case BORDER: {
243                         item = XmlTools.getFromMap(map, "position", "center");
244                         controller.setProperty(uic, __GO_UI_BORDER_POSITION__, Uicontrol.BorderLayoutType.stringToEnum(item).ordinal());
245                         break;
246                     }
247                     case GRIDBAG: {
248                         Integer[] grid = new Integer[] { 0, 0, 0, 0 };
249                         grid[0] = Integer.parseInt(XmlTools.getFromMap(map, "gridx", "0"));
250                         grid[1] = Integer.parseInt(XmlTools.getFromMap(map, "gridy", "0"));
251                         grid[2] = Integer.parseInt(XmlTools.getFromMap(map, "gridwidth", "1"));
252                         grid[3] = Integer.parseInt(XmlTools.getFromMap(map, "gridheight", "1"));
253
254                         Double[] weight = new Double[] { 0.0, 0.0 };
255                         weight[0] = Double.parseDouble(XmlTools.getFromMap(map, "weightx", "1.0"));
256                         weight[1] = Double.parseDouble(XmlTools.getFromMap(map, "weighty", "1.0"));
257
258                         Integer fill = Uicontrol.FillType.stringToEnum(XmlTools.getFromMap(map, "fill", "none")).ordinal();
259                         Integer anchor = Uicontrol.AnchorType.stringToEnum(XmlTools.getFromMap(map, "anchor", "center")).ordinal();
260
261                         Integer[] padding = new Integer[] { 0, 0 };
262                         padding[0] = Integer.parseInt(XmlTools.getFromMap(map, "ipadx", "0"));
263                         padding[1] = Integer.parseInt(XmlTools.getFromMap(map, "ipady", "0"));
264
265                         controller.setProperty(uic, __GO_UI_GRIDBAG_GRID__, grid);
266                         controller.setProperty(uic, __GO_UI_GRIDBAG_WEIGHT__, weight);
267                         controller.setProperty(uic, __GO_UI_GRIDBAG_FILL__, fill);
268                         controller.setProperty(uic, __GO_UI_GRIDBAG_ANCHOR__, anchor);
269                         controller.setProperty(uic, __GO_UI_GRIDBAG_PADDING__, padding);
270                         break;
271                     }
272                     default:
273                         break;
274                 }
275
276                 // insets -> marging
277                 String insets = XmlTools.getFromMap(map, "insets", "0,0,0,0");
278                 Double[] margins = new Double[] { 0.0, 0.0, 0.0, 0.0 };
279                 String[] insert = insets.split(",");
280                 for (int i = 0; i < insert.length && i < 4; i++) {
281                     margins[i] = Double.parseDouble(insert[i]);
282                 }
283
284                 controller.setProperty(uic, __GO_MARGINS__, margins);
285             }
286
287             // specific attributes
288             Integer type = (Integer) controller.getProperty(uic, __GO_STYLE__);
289             switch (type) {
290                 case __GO_UI_FRAME__: {
291                     // border
292                     item = attributes.getValue("border");
293                     if (item == null && fromModel != null) {
294                         // use value from model if property is not in
295                         // "declaration"
296                         item = XmlTools.getFromMap(fromModel, "border");
297                     }
298
299                     if (item != null) {
300                         map = CSSParser.parseLine(item);
301                     }
302
303                     FrameBorderType borderType = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "name", "none"));
304                     Integer border = createBorder(controller, uic, borderType, map);
305                     controller.setProperty(uic, __GO_UI_FRAME_BORDER__, border);
306
307                     String[] text = new String[1];
308                     text[0] = attributes.getValue("tab-title");
309                     if (text[0] != null) {
310                         controller.setProperty(uic, __GO_UI_STRING__, text);
311                     }
312
313                     item = attributes.getValue("scrollable");
314                     if (item == null || item.equals("false")) {
315                         controller.setProperty(uic, __GO_UI_SCROLLABLE__, false);
316                     } else {
317                         controller.setProperty(uic, __GO_UI_SCROLLABLE__, true);
318                     }
319
320                     break;
321                 }
322
323                 case __GO_UI_TAB__: {
324                     item = attributes.getValue("ui-style");
325                     if (item != null) {
326                         map = CSSParser.parseLine(item);
327                         item = XmlTools.getFromMap(map, "bold", "false");
328                         if (item.equals("true")) {
329                             controller.setProperty(uic, __GO_UI_FONTWEIGHT__, "bold");
330                         }
331
332                         item = XmlTools.getFromMap(map, "italic", "false");
333                         if (item.equals("true")) {
334                             controller.setProperty(uic, __GO_UI_FONTANGLE__, "italic");
335                         }
336                     }
337                     break;
338                 }
339                 case __GO_UI_CHECKBOX__: {
340                     controller.setProperty(uic, __GO_UI_HORIZONTALALIGNMENT__, "left");
341
342                     String[] text = new String[1];
343                     text[0] = attributes.getValue("text");
344                     if (text[0] != null) {
345                         controller.setProperty(uic, __GO_UI_STRING__, text);
346                     }
347                     break;
348                 }
349                 case __GO_UI_PUSHBUTTON__: {
350
351                     //string
352                     String[] text = new String[1];
353                     text[0] = attributes.getValue("text");
354                     if (text[0] != null) {
355                         controller.setProperty(uic, __GO_UI_STRING__, text);
356                     }
357
358
359                     //icon
360                     item = attributes.getValue("icon");
361                     if (item != null) {
362                         controller.setProperty(uic, __GO_UI_ICON__, item);
363                     }
364
365                     break;
366                 }
367                 case __GO_UI_TEXT__:
368                     controller.setProperty(uic, __GO_UI_HORIZONTALALIGNMENT__, "left");
369                     String[] text = new String[1];
370                     text[0] = attributes.getValue("text");
371                     if (text[0] != null) {
372                         controller.setProperty(uic, __GO_UI_STRING__, text);
373                     }
374
375                     String columns = attributes.getValue("columns");
376                     if (columns != null) {
377                         controller.setProperty(uic, __GO_UI_MAX__, Double.parseDouble(columns));
378                     }
379
380                     //icon
381                     item = attributes.getValue("icon");
382                     if (item != null) {
383                         controller.setProperty(uic, __GO_UI_ICON__, item);
384                     }
385                     break;
386             }
387
388         } catch (CSSParserException e) {
389             e.printStackTrace();
390         }
391
392         return uic;
393     }
394
395     private static void setLayoutProperty(GraphicController controller, Integer uid, String item) {
396         try {
397             Map<String, String> map = null;
398             map = CSSParser.parseLine(item);
399             item = map.get("name");
400             LayoutType layout = LayoutType.stringToEnum(item);
401             controller.setProperty(uid, __GO_LAYOUT__, layout.ordinal());
402
403             // layout_options
404             switch (layout) {
405                 case BORDER: {
406                     Integer[] pad = new Integer[] { 0, 0 };
407                     pad[0] = Integer.parseInt(XmlTools.getFromMap(map, "hgap", "0"));
408                     pad[1] = Integer.parseInt(XmlTools.getFromMap(map, "vgap", "0"));
409
410                     controller.setProperty(uid, __GO_BORDER_OPT_PADDING__, pad);
411                     break;
412                 }
413                 case GRID: {
414                     Integer[] grid = new Integer[] { 0, 0 };
415                     grid[0] = Integer.parseInt(XmlTools.getFromMap(map, "rows", "0"));
416                     grid[1] = Integer.parseInt(XmlTools.getFromMap(map, "cols", "0"));
417
418                     Integer[] pad = new Integer[] { 0, 0 };
419                     pad[0] = Integer.parseInt(XmlTools.getFromMap(map, "hgap", "0"));
420                     pad[1] = Integer.parseInt(XmlTools.getFromMap(map, "vgap", "0"));
421
422                     controller.setProperty(uid, __GO_GRID_OPT_GRID__, grid);
423                     controller.setProperty(uid, __GO_GRID_OPT_PADDING__, pad);
424                     break;
425                 }
426                 default:
427                 case GRIDBAG:
428                 case NONE:
429                     // nothing to do
430                     break;
431             }
432         } catch (CSSParserException e) {
433             e.printStackTrace();
434         }
435
436     }
437
438     private static Integer createBorder(GraphicController controller, Integer uic, FrameBorderType borderType, Map<String, String> map) {
439         Integer border = controller.askObject(GraphicObject.getTypeFromName(__GO_UI_FRAME_BORDER__));
440         controller.setProperty(border, __GO_UI_FRAME_BORDER_STYLE__, borderType.ordinal());
441
442         switch (borderType) {
443             case SOFTBEVEL:
444             case BEVEL: {
445                 BorderType etching = BorderType.stringToEnum(XmlTools.getFromMap(map, "type", "none"));
446                 String color = XmlTools.getFromMap(map, "color", "black");
447
448                 controller.setProperty(border, __GO_TYPE__, etching.ordinal());
449                 controller.setProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, color);
450                 controller.setProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, color);
451                 controller.setProperty(border, __GO_UI_FRAME_BORDER_SHADOW_OUT__, color);
452                 controller.setProperty(border, __GO_UI_FRAME_BORDER_SHADOW_IN__, color);
453                 break;
454             }
455             case COMPOUND: {
456                 FrameBorderType borderOut = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "border-out", "none"));
457                 FrameBorderType borderIn = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "border-in", "none"));
458
459                 Integer out = createBorder(controller, border, borderOut, map);
460                 Integer in = createBorder(controller, border, borderIn, map);
461
462                 controller.setProperty(border, __GO_UI_FRAME_BORDER_OUT_BORDER__, out);
463                 controller.setProperty(border, __GO_UI_FRAME_BORDER_IN_BORDER__, in);
464
465                 break;
466             }
467             case EMPTY: {
468                 Double[] position = new Double[4];
469                 position[0] = Double.parseDouble(XmlTools.getFromMap(map, "top", "0"));
470                 position[1] = Double.parseDouble(XmlTools.getFromMap(map, "left", "0"));
471                 position[2] = Double.parseDouble(XmlTools.getFromMap(map, "right", "0"));
472                 position[3] = Double.parseDouble(XmlTools.getFromMap(map, "bottom", "0"));
473
474                 controller.setProperty(border, __GO_POSITION__, position);
475                 break;
476             }
477             case ETCHED: {
478                 BorderType etching = BorderType.stringToEnum(XmlTools.getFromMap(map, "type", "none"));
479                 String color = XmlTools.getFromMap(map, "color", "black");
480
481                 controller.setProperty(border, __GO_TYPE__, etching.ordinal());
482                 controller.setProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__, color);
483                 controller.setProperty(border, __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__, color);
484                 break;
485             }
486             case LINE: {
487                 String color = XmlTools.getFromMap(map, "color", "black");
488                 Integer thickness = Integer.parseInt(XmlTools.getFromMap(map, "thickness", "1"));
489                 Boolean rounded = Boolean.parseBoolean(XmlTools.getFromMap(map, "rounded", "false"));
490
491                 controller.setProperty(border, __GO_UI_FRAME_BORDER_COLOR__, color);
492                 controller.setProperty(border, __GO_LINE_THICKNESS__, thickness);
493                 controller.setProperty(border, __GO_UI_FRAME_BORDER_ROUNDED__, rounded);
494                 break;
495             }
496             case MATTE: {
497                 Double[] position = new Double[4];
498                 position[0] = Double.parseDouble(XmlTools.getFromMap(map, "top", "0"));
499                 position[1] = Double.parseDouble(XmlTools.getFromMap(map, "left", "0"));
500                 position[2] = Double.parseDouble(XmlTools.getFromMap(map, "right", "0"));
501                 position[3] = Double.parseDouble(XmlTools.getFromMap(map, "bottom", "0"));
502                 String color = XmlTools.getFromMap(map, "color", "black");
503
504                 controller.setProperty(border, __GO_POSITION__, position);
505                 controller.setProperty(border, __GO_UI_FRAME_BORDER_COLOR__, color);
506                 break;
507             }
508             case TITLED: {
509
510                 FrameBorderType borderOut = FrameBorderType.stringToEnum(XmlTools.getFromMap(map, "border", "none"));
511                 Integer out = createBorder(controller, border, borderOut, map);
512                 String title = XmlTools.getFromMap(map, "title", "");
513                 FrameBorder.JustificationType justify = FrameBorder.JustificationType.stringToEnum(XmlTools.getFromMap(map, "justify", "leading"));
514                 String fontName = XmlTools.getFromMap(map, "font-name", "");
515                 String fontAngle = XmlTools.getFromMap(map, "italic", "false") == "false" ? "normal" : "italic";
516                 Integer fontSize = Integer.parseInt(XmlTools.getFromMap(map, "font-size", "0"));
517                 String fontWeight = XmlTools.getFromMap(map, "bold", "false") == "false" ? "normal" : "bold";
518
519                 FrameBorder.TitlePositionType position = FrameBorder.TitlePositionType.stringToEnum(XmlTools.getFromMap(map, "position", "leading"));
520
521                 String color = XmlTools.getFromMap(map, "color", "black");
522
523                 controller.setProperty(border, __GO_UI_FRAME_BORDER_OUT_BORDER__, out);
524
525                 controller.setProperty(border, __GO_UI_FRAME_BORDER_TITLE__, out);
526                 controller.setProperty(border, __GO_TITLE__, title);
527                 controller.setProperty(border, __GO_UI_FRAME_BORDER_JUSTIFICATION__, justify.ordinal());
528                 controller.setProperty(border, __GO_UI_FONTNAME__, fontName);
529                 controller.setProperty(border, __GO_UI_FONTANGLE__, fontAngle);
530                 controller.setProperty(border, __GO_UI_FONTSIZE__, fontSize);
531                 controller.setProperty(border, __GO_UI_FONTWEIGHT__, fontWeight);
532                 controller.setProperty(border, __GO_UI_FRAME_BORDER_POSITION__, position.ordinal());
533                 controller.setProperty(border, __GO_UI_FRAME_BORDER_COLOR__, color);
534
535                 break;
536             }
537             case NONE:
538             default:
539                 break;
540         }
541
542         return border;
543     }
544
545     private static Double[] getColor(String str) {
546         try {
547             Field field = Class.forName("java.awt.Color").getField(str);
548             Color color = (Color) field.get(null);
549             return new Double[] {(double) color.getRed() / 255, (double) color.getGreen() / 255, (double) color.getBlue() / 255};
550         } catch (Exception e) {
551             return new Double[] {(double) Color.black.getRed() / 255, (double) Color.black.getGreen() / 255, (double) Color.black.getBlue() / 255};
552         }
553     }
554 }