1 package org.scilab.modules.graphic_objects.uicontrol.frame.border; 2 3 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_LINE_THICKNESS__; 4 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_POSITION__; 5 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_TITLE__; 6 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTANGLE__; 7 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTNAME__; 8 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTSIZE__; 9 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FONTWEIGHT__; 10 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_COLOR__; 11 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_IN__; 12 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__; 13 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_IN_BORDER__; 14 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_JUSTIFICATION__; 15 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_OUT_BORDER__; 16 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_POSITION__; 17 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_ROUNDED__; 18 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_SHADOW_IN__; 19 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_SHADOW_OUT__; 20 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_STYLE__; 21 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_TITLE__; 22 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER_TYPE__; 23 import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties.__GO_UI_FRAME_BORDER__; 24 25 import java.util.Arrays; 26 27 import org.scilab.modules.graphic_objects.ObjectRemovedException; 28 import org.scilab.modules.graphic_objects.graphicObject.GraphicObject; 29 import org.scilab.modules.graphic_objects.graphicObject.Visitor; 30 31 public class FrameBorder extends GraphicObject { 32 enum FrameBorderProperty { 33 TYPE, //RAISED or LOWERED 34 COLOR, //string 35 THICKNESS, //int 36 ROUNDED, //boolean 37 STYLE, //FrameBorderType 38 HIGHLIGHT_OUT, //string 39 HIGHLIGHT_IN, //string 40 SHADOW_OUT, //string 41 SHADOW_IN, //string 42 TITLE_BORDER, 43 TITLE, //string 44 JUSTIFICATION, //JustificationType 45 FONTNAME, //string 46 FONTANGLE, // string 47 FONT_SIZE, //int 48 FONT_WEIGHT, //string 49 TITLE_POSITION, // TitlePostionType 50 POSITION, //tlbr 51 IN_BORDER, 52 OUT_BORDER, 53 }; 54 55 public enum BorderType { 56 RAISED, LOWERED; intToEnum(Integer value)57 public static BorderType intToEnum(Integer value) { 58 switch (value) { 59 default: 60 case 0: 61 return RAISED; 62 case 1: 63 return LOWERED; 64 } 65 } 66 stringToEnum(String value)67 public static BorderType stringToEnum(String value) { 68 if (value == null || value.equals("")) { 69 return null; 70 } 71 72 char[] chars = value.toCharArray(); 73 if (chars[0] == 'l' || chars[0] == 'L') { 74 return LOWERED; 75 } 76 77 return RAISED; 78 } 79 } 80 81 public enum JustificationType { 82 LEADING, LEFT, CENTER, RIGHT, TRAILING; 83 intToEnum(Integer val)84 public static JustificationType intToEnum(Integer val) { 85 switch (val) { 86 default : 87 case 0: 88 return LEADING; 89 case 1: 90 return LEFT; 91 case 2: 92 return CENTER; 93 case 3: 94 return RIGHT; 95 case 4: 96 return TRAILING; 97 } 98 } 99 stringToEnum(String value)100 public static JustificationType stringToEnum(String value) { 101 if (value == null || value.equals("")) { 102 return null; 103 } 104 105 char[] chars = value.toCharArray(); 106 if (chars[0] == 'l' || chars[0] == 'L') { 107 if (chars[3] == 'f' || chars[3] == 'F') { 108 return LEFT; 109 } 110 return LEADING; 111 } 112 113 if (chars[0] == 'c' || chars[0] == 'C') { 114 return CENTER; 115 } 116 117 if (chars[0] == 'r' || chars[0] == 'R') { 118 return RIGHT; 119 } 120 121 if (chars[0] == 't' || chars[0] == 'T') { 122 return TRAILING; 123 } 124 125 126 return LEADING; 127 } 128 129 }; 130 131 public enum TitlePositionType { 132 TOP, ABOVE_TOP, BELOW_TOP, BOTTOM, ABOVE_BOTTOM, BELOW_BOTTOM; 133 intToEnum(Integer val)134 public static TitlePositionType intToEnum(Integer val) { 135 switch (val) { 136 default : 137 case 0: 138 return TOP; 139 case 1: 140 return ABOVE_TOP; 141 case 2: 142 return BELOW_TOP; 143 case 3: 144 return BOTTOM; 145 case 4: 146 return ABOVE_BOTTOM; 147 case 5: 148 return BELOW_BOTTOM; 149 } 150 } 151 stringToEnum(String value)152 public static TitlePositionType stringToEnum(String value) { 153 if (value == null || value.equals("")) { 154 return null; 155 } 156 157 if (value.equalsIgnoreCase("above_top")) { 158 return ABOVE_TOP; 159 } 160 161 if (value.equalsIgnoreCase("below_top")) { 162 return BELOW_TOP; 163 } 164 165 if (value.equalsIgnoreCase("bottom")) { 166 return BOTTOM; 167 } 168 169 if (value.equalsIgnoreCase("above_bottom")) { 170 return ABOVE_BOTTOM; 171 } 172 173 if (value.equalsIgnoreCase("below_bottom")) { 174 return BELOW_BOTTOM; 175 } 176 177 return TOP; 178 } 179 }; 180 181 private BorderType type = null;//BorderType.NONE; 182 private String color = null; 183 private String hlOutColor = null; 184 private String hlInColor = null; 185 private String shadowOutColor = null; 186 private String shadowInColor = null; 187 private Integer thickness = null; 188 private Boolean rounded = null; 189 private FrameBorderType style = null;//FrameBorderType.ETCHED; 190 private String title = null; 191 private JustificationType justification = null;//JustificationType.LEADING; 192 private String fontAngle = null; 193 private String fontName = null; 194 private Integer fontSize = null; 195 private String fontWeight = null; 196 private TitlePositionType titlePosition = TitlePositionType.TOP; 197 private Double[] position = null;//new Double[] {0.0, 0.0, 0.0, 0.0};//TLBR 198 199 private Integer titleBorder = null; 200 private Integer inBorder = null; 201 private Integer outBorder = null; 202 FrameBorder()203 public FrameBorder() { 204 205 } 206 207 /** 208 * Get style as a string 209 * @param style the uicontrol style 210 * @return the uicontrol style as a string 211 */ getPropertyFromName(int propertyName)212 public Object getPropertyFromName(int propertyName) { 213 switch (propertyName) { 214 case __GO_UI_FRAME_BORDER_COLOR__: 215 return FrameBorderProperty.COLOR; 216 case __GO_UI_FONTANGLE__: 217 return FrameBorderProperty.FONTANGLE; 218 case __GO_UI_FONTNAME__: 219 return FrameBorderProperty.FONTNAME; 220 case __GO_UI_FONTSIZE__: 221 return FrameBorderProperty.FONT_SIZE; 222 case __GO_UI_FONTWEIGHT__: 223 return FrameBorderProperty.FONT_WEIGHT; 224 case __GO_UI_FRAME_BORDER_HIGHLIGHT_IN__: 225 return FrameBorderProperty.HIGHLIGHT_IN; 226 case __GO_UI_FRAME_BORDER_HIGHLIGHT_OUT__: 227 return FrameBorderProperty.HIGHLIGHT_OUT; 228 case __GO_UI_FRAME_BORDER_IN_BORDER__: 229 return FrameBorderProperty.IN_BORDER; 230 case __GO_UI_FRAME_BORDER_JUSTIFICATION__: 231 return FrameBorderProperty.JUSTIFICATION; 232 case __GO_UI_FRAME_BORDER_OUT_BORDER__: 233 return FrameBorderProperty.OUT_BORDER; 234 case __GO_POSITION__: 235 return FrameBorderProperty.POSITION; 236 case __GO_UI_FRAME_BORDER_ROUNDED__: 237 return FrameBorderProperty.ROUNDED; 238 case __GO_UI_FRAME_BORDER_SHADOW_IN__: 239 return FrameBorderProperty.SHADOW_IN; 240 case __GO_UI_FRAME_BORDER_SHADOW_OUT__: 241 return FrameBorderProperty.SHADOW_OUT; 242 case __GO_UI_FRAME_BORDER_STYLE__: 243 return FrameBorderProperty.STYLE; 244 case __GO_LINE_THICKNESS__: 245 return FrameBorderProperty.THICKNESS; 246 case __GO_TITLE__: 247 return FrameBorderProperty.TITLE; 248 case __GO_UI_FRAME_BORDER_TITLE__: 249 return FrameBorderProperty.TITLE_BORDER; 250 case __GO_UI_FRAME_BORDER_POSITION__: 251 return FrameBorderProperty.TITLE_POSITION; 252 case __GO_UI_FRAME_BORDER_TYPE__: 253 return FrameBorderProperty.TYPE; 254 default: 255 return super.getPropertyFromName(propertyName); 256 } 257 } 258 getProperty(Object property)259 public Object getProperty(Object property) { 260 if (property instanceof FrameBorderProperty) { 261 switch ((FrameBorderProperty)property) { 262 case COLOR: 263 return getColor(); 264 case FONTANGLE: 265 return getFontAngle(); 266 case FONTNAME: 267 return getFontName(); 268 case FONT_SIZE: 269 return getFontSize(); 270 case FONT_WEIGHT: 271 return getFontWeight(); 272 case HIGHLIGHT_IN: 273 return getHlIn(); 274 case HIGHLIGHT_OUT: 275 return getHlOut(); 276 case IN_BORDER: 277 return getInBorder(); 278 case JUSTIFICATION: 279 return getJustification(); 280 case OUT_BORDER: 281 return getOutBorder(); 282 case POSITION: 283 return getPosition(); 284 case ROUNDED: 285 return getRounded(); 286 case SHADOW_IN: 287 return getShadowIn(); 288 case SHADOW_OUT: 289 return getShadowOut(); 290 case STYLE: 291 return getStyle(); 292 case THICKNESS: 293 return getThickness(); 294 case TITLE: 295 return getTitle(); 296 case TITLE_BORDER: 297 return getTitleBorder(); 298 case TITLE_POSITION: 299 return getTitlePosition(); 300 case TYPE: 301 return getBorderType(); 302 } 303 } 304 305 return super.getProperty(property); 306 } 307 setProperty(Object property, Object value)308 public UpdateStatus setProperty(Object property, Object value) { 309 if (property instanceof FrameBorderProperty) { 310 switch ((FrameBorderProperty) property) { 311 case COLOR: 312 return setColor((String)value); 313 case FONTANGLE: 314 return setFontAngle((String)value); 315 case FONTNAME: 316 return setFontName((String)value); 317 case FONT_SIZE: 318 return setFontSize((Integer)value); 319 case FONT_WEIGHT: 320 return setFontWeight((String)value); 321 case HIGHLIGHT_IN: 322 return setHlIn((String)value); 323 case HIGHLIGHT_OUT: 324 return setHlOut((String)value); 325 case IN_BORDER: 326 return setInBorder((Integer)value); 327 case JUSTIFICATION: 328 return setJustification((Integer)value); 329 case OUT_BORDER: 330 return setOutBorder((Integer)value); 331 case POSITION: 332 return setPosition((Double[])value); 333 case ROUNDED: 334 return setRounded((Boolean)value); 335 case SHADOW_IN: 336 return setShadowIn((String)value); 337 case SHADOW_OUT: 338 return setShadowOut((String)value); 339 case STYLE: 340 return setStyle((Integer)value); 341 case THICKNESS: 342 return setThickness((Integer)value); 343 case TITLE: 344 return setTitle((String)value); 345 case TITLE_BORDER: 346 return setTitleBorder((Integer)value); 347 case TITLE_POSITION: 348 return setTitlePosition((Integer)value); 349 case TYPE: 350 return setBorderType((Integer)value); 351 } 352 } 353 return super.setProperty(property, value); 354 } 355 356 /** type */ getBorderType()357 public Integer getBorderType() { 358 return type == null ? null : type.ordinal(); 359 } 360 getBorderTypeAsEnum()361 public BorderType getBorderTypeAsEnum() { 362 return type; 363 } 364 setBorderType(BorderType value)365 public UpdateStatus setBorderType(BorderType value) { 366 if (value == type) { 367 return UpdateStatus.NoChange; 368 } 369 370 type = value; 371 return UpdateStatus.Success; 372 } 373 setBorderType(Integer value)374 public UpdateStatus setBorderType(Integer value) { 375 return setBorderType(BorderType.intToEnum(value)); 376 } 377 378 /** titleposition */ getTitlePosition()379 public Integer getTitlePosition() { 380 return titlePosition == null ? null : titlePosition.ordinal(); 381 } 382 getTitlePositionAsEnum()383 public TitlePositionType getTitlePositionAsEnum() { 384 return titlePosition; 385 } 386 setTitlePosition(Integer value)387 public UpdateStatus setTitlePosition(Integer value) { 388 return setTitlePosition(TitlePositionType.intToEnum(value)); 389 } 390 setTitlePosition(TitlePositionType value)391 public UpdateStatus setTitlePosition(TitlePositionType value) { 392 if (titlePosition == value) { 393 return UpdateStatus.NoChange; 394 } 395 396 titlePosition = value; 397 return UpdateStatus.Success; 398 } 399 400 /** titleborder */ getTitleBorder()401 public Integer getTitleBorder() { 402 return titleBorder; 403 } 404 setTitleBorder(Integer value)405 public UpdateStatus setTitleBorder(Integer value) { 406 if (titleBorder != null && titleBorder.equals(value)) { 407 return UpdateStatus.NoChange; 408 } 409 410 titleBorder = value; 411 return UpdateStatus.Success; 412 } 413 414 /** title */ getTitle()415 public String getTitle() { 416 return title; 417 } 418 setTitle(String value)419 public UpdateStatus setTitle(String value) { 420 if (title != null && title.equals(value)) { 421 return UpdateStatus.NoChange; 422 } 423 424 title = value; 425 return UpdateStatus.Success; 426 } 427 428 /** thickness */ getThickness()429 public Integer getThickness() { 430 return thickness; 431 } 432 setThickness(Integer value)433 public UpdateStatus setThickness(Integer value) { 434 if (thickness != null && thickness.equals(value)) { 435 return UpdateStatus.NoChange; 436 } 437 438 thickness = value; 439 return UpdateStatus.Success; 440 } 441 442 /** style */ getStyle()443 public Integer getStyle() { 444 return style == null ? null : style.ordinal(); 445 } 446 getStyleAsEnum()447 public FrameBorderType getStyleAsEnum() { 448 return style; 449 } 450 setStyle(Integer value)451 public UpdateStatus setStyle(Integer value) { 452 return setStyle(FrameBorderType.intToEnum(value)); 453 } 454 setStyle(FrameBorderType value)455 public UpdateStatus setStyle(FrameBorderType value) { 456 if (style != null && style.equals(value)) { 457 return UpdateStatus.NoChange; 458 } 459 460 style = value; 461 return UpdateStatus.Success; 462 } 463 464 /** shadowOut */ getShadowOut()465 public String getShadowOut() { 466 return shadowOutColor; 467 } 468 setShadowOut(String value)469 public UpdateStatus setShadowOut(String value) { 470 if (shadowOutColor != null && shadowOutColor.equals(value)) { 471 return UpdateStatus.NoChange; 472 } 473 474 shadowOutColor = value; 475 return UpdateStatus.Success; 476 } 477 478 /** shadowIn */ getShadowIn()479 public String getShadowIn() { 480 return shadowInColor; 481 } 482 setShadowIn(String value)483 public UpdateStatus setShadowIn(String value) { 484 if (shadowInColor != null && shadowInColor.equals(value)) { 485 return UpdateStatus.NoChange; 486 } 487 488 shadowInColor = value; 489 return UpdateStatus.Success; 490 } 491 492 /** rounded */ getRounded()493 public Boolean getRounded() { 494 return rounded; 495 } 496 setRounded(Boolean value)497 public UpdateStatus setRounded(Boolean value) { 498 if (rounded != null && rounded.equals(value)) { 499 return UpdateStatus.NoChange; 500 } 501 502 rounded = value; 503 return UpdateStatus.Success; 504 } 505 506 /** position */ getPosition()507 public Double[] getPosition() { 508 return position; 509 } 510 setPosition(Double[] value)511 public UpdateStatus setPosition(Double[] value) { 512 if (position != null && Arrays.equals(position, value)) { 513 return UpdateStatus.NoChange; 514 } 515 516 position = value; 517 return UpdateStatus.Success; 518 } 519 520 /** outBorder */ getOutBorder()521 public Integer getOutBorder() { 522 return outBorder; 523 } 524 setOutBorder(Integer value)525 public UpdateStatus setOutBorder(Integer value) { 526 if (outBorder != null && outBorder.equals(value)) { 527 return UpdateStatus.NoChange; 528 } 529 530 outBorder = value; 531 return UpdateStatus.Success; 532 } 533 534 /** justification */ getJustification()535 public Integer getJustification() { 536 return justification == null ? null : justification.ordinal(); 537 } 538 getJustificationAsEnum()539 public JustificationType getJustificationAsEnum() { 540 return justification; 541 } 542 setJustification(Integer value)543 public UpdateStatus setJustification(Integer value) { 544 return setJustification(JustificationType.intToEnum(value)); 545 } 546 setJustification(JustificationType value)547 public UpdateStatus setJustification(JustificationType value) { 548 if (justification == value) { 549 return UpdateStatus.NoChange; 550 } 551 552 justification = value; 553 return UpdateStatus.Success; 554 } 555 556 /** inBorder */ getInBorder()557 public Integer getInBorder() { 558 return inBorder; 559 } 560 setInBorder(Integer value)561 public UpdateStatus setInBorder(Integer value) { 562 if (inBorder != null && inBorder.equals(value)) { 563 return UpdateStatus.NoChange; 564 } 565 566 inBorder = value; 567 return UpdateStatus.Success; 568 } 569 570 /** hlOutColor */ getHlOut()571 public String getHlOut() { 572 return hlOutColor; 573 } 574 setHlOut(String value)575 public UpdateStatus setHlOut(String value) { 576 if (hlOutColor != null && hlOutColor.equals(value)) { 577 return UpdateStatus.NoChange; 578 } 579 580 hlOutColor = value; 581 return UpdateStatus.Success; 582 } 583 584 /** hlInColor */ getHlIn()585 public String getHlIn() { 586 return hlInColor; 587 } 588 setHlIn(String value)589 public UpdateStatus setHlIn(String value) { 590 if (hlInColor != null && hlInColor.equals(value)) { 591 return UpdateStatus.NoChange; 592 } 593 594 hlInColor = value; 595 return UpdateStatus.Success; 596 } 597 598 /** fontWeight */ getFontWeight()599 public String getFontWeight() { 600 return fontWeight; 601 } 602 setFontWeight(String value)603 public UpdateStatus setFontWeight(String value) { 604 if (fontWeight != null && fontWeight.equals(value)) { 605 return UpdateStatus.NoChange; 606 } 607 608 fontWeight = value; 609 return UpdateStatus.Success; 610 } 611 612 /** fontSize */ getFontSize()613 public Integer getFontSize() { 614 return fontSize; 615 } 616 setFontSize(Integer value)617 public UpdateStatus setFontSize(Integer value) { 618 if (fontSize != null && fontSize.equals(value)) { 619 return UpdateStatus.NoChange; 620 } 621 622 fontSize = value; 623 return UpdateStatus.Success; 624 } 625 626 /** fontName */ getFontName()627 public String getFontName() { 628 return fontName; 629 } 630 setFontName(String value)631 public UpdateStatus setFontName(String value) { 632 if (fontName != null && fontName.equals(value)) { 633 return UpdateStatus.NoChange; 634 } 635 636 fontName = value; 637 return UpdateStatus.Success; 638 } 639 640 /** fontAngle */ getFontAngle()641 public String getFontAngle() { 642 return fontAngle; 643 } 644 setFontAngle(String value)645 public UpdateStatus setFontAngle(String value) { 646 if (fontAngle != null && fontAngle.equals(value)) { 647 return UpdateStatus.NoChange; 648 } 649 650 fontAngle = value; 651 return UpdateStatus.Success; 652 } 653 654 /** color */ getColor()655 public String getColor() { 656 return color; 657 } 658 setColor(String value)659 public UpdateStatus setColor(String value) { 660 if (color != null && color.equals(value)) { 661 return UpdateStatus.NoChange; 662 } 663 664 color = value; 665 return UpdateStatus.Success; 666 } 667 accept(Visitor visitor)668 public void accept(Visitor visitor) throws ObjectRemovedException { 669 } 670 getType()671 public Integer getType() { 672 return __GO_UI_FRAME_BORDER__; 673 } 674 675 } 676