Changeset 1188 for trunk/src/org/expeditee/gui/AttributeUtils.java
- Timestamp:
- 10/31/18 10:22:24 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/AttributeUtils.java
r1102 r1188 392 392 Attribute a = attribSet.get(prop); 393 393 // Make sure the classes of the methods match the item 394 if (a != null && a.getter != null && a.getter.getDeclaringClass().isAssignableFrom(toExtract.getClass())) { 395 394 if (a != null && a.getter != null && a.getter.getDeclaringClass().isAssignableFrom(toExtract.getClass())) { 396 395 try { 397 396 String s = getValue(prop, a, toExtract, true); 398 if (s == null) 397 if (s == null) { 399 398 continue; 399 } 400 400 // Append the attributes 401 401 attributes.append(a.displayName) … … 410 410 411 411 // if no attributes were extracted 412 if (attributes.length() <= 0) 412 if (attributes.length() <= 0) { 413 413 return null; 414 415 while (attributes.charAt(attributes.length() - 1) == '\n') 414 } 415 416 while (attributes.charAt(attributes.length() - 1) == '\n') { 416 417 attributes.delete(attributes.length() - 1, attributes.length()); 418 } 417 419 418 420 // create the text Item … … 450 452 // are in the AllowNull list 451 453 if (_AllowNull.contains(a.getter)) { 452 if (name.equals("color")) 454 if (name.equals("color")) { 453 455 o = "default"; 454 else if (name.equals("backgroundcolor"))456 } else if (name.equals("backgroundcolor")) { 455 457 o = "transparent"; 456 else if (name.equals("foregroundcolor"))458 } else if (name.equals("foregroundcolor")) { 457 459 o = "auto"; 458 else460 } else { 459 461 o = ""; 462 } 460 463 } else { 461 464 return null; … … 469 472 if (o instanceof Integer) { 470 473 Integer i = (Integer) o; 471 if (i == Item.DEFAULT_INTEGER) 474 if (i == Item.DEFAULT_INTEGER) { 472 475 return null; 476 } 473 477 if (a.getter.getName().endsWith("Justification") 474 && ((Justification) o).toString() != null) 478 && ((Justification) o).toString() != null) { 475 479 o = ((Justification) o).toString(); 476 480 // -1 indicates default value 477 else481 } else { 478 482 o = i; 483 } 479 484 } else if (o instanceof Float) { 480 485 if (((Float) o) < -0.0001) 486 { 481 487 return null; 482 488 // Null indicates default 483 489 // o = Math.round((Float) o); 490 } 484 491 } else if (o instanceof Double) { 485 492 // -1 indicates default value 486 if (((Double) o) < 0.0001) 493 if (((Double) o) < 0.0001) { 487 494 return null; 495 } 488 496 } else if (o instanceof Colour) { 489 497 // converts the color to the Expeditee code 490 498 o = Conversion.getExpediteeColorCode((Colour) o); 491 if (o == null) 499 if (o == null) { 492 500 return null; 501 } 493 502 } else if (o instanceof Point) { 494 503 Point p = (Point) o; … … 498 507 499 508 String s = f.getFamilyName() + "-"; 500 if (f.isPlain()) 509 if (f.isPlain()) { 501 510 s += "Plain"; 502 503 if (f.isBold()) 511 } 512 513 if (f.isBold()) { 504 514 s += "Bold"; 505 506 if (f.isItalic()) 515 } 516 517 if (f.isItalic()) { 507 518 s += "Italic"; 519 } 508 520 509 521 s += "-" + f.getSize(); … … 514 526 List list = (List) o; 515 527 StringBuffer sb = new StringBuffer(); 516 for (Object ob : list) 528 for (Object ob : list) { 517 529 // TODO check that this works ok 518 530 if (sb.length() == 0) { … … 521 533 sb.append('\n').append(a.displayName).append(AttributeValuePair.SEPARATOR_STRING).append(ob); 522 534 } 535 } 523 536 return sb.toString(); 524 537 } else if (o instanceof int[]) { … … 532 545 } else if (o instanceof Boolean) { 533 546 // true is the default for boolean values 534 if (((Boolean) o).booleanValue()) 547 if (((Boolean) o).booleanValue()) { 535 548 return null; 549 } 536 550 } 537 551 return o.toString(); … … 557 571 int minAttributeLength) { 558 572 // error checking 559 if (toSet == null || attribs == null) 573 if (toSet == null || attribs == null) { 560 574 return false; 575 } 561 576 562 577 ensureReady(); … … 589 604 // attribute merging 590 605 if (!avp.hasAttribute() 591 || avp.getAttribute().length() < minAttributeLength) 606 || avp.getAttribute().length() < minAttributeLength) { 592 607 return false; 608 } 593 609 594 610 // check if the next string is another attribute to merge or a … … 699 715 // if there are duplicate methods with the same name 700 716 List<Method> possibles = new LinkedList<Method>(); 701 if (a.setter.getDeclaringClass().isInstance(toSet)) 717 if (a.setter.getDeclaringClass().isInstance(toSet)) { 702 718 possibles.add(a.setter); 719 } 703 720 int i = 0; 704 721 while (attribSet.containsKey(attribute + i)) { … … 741 758 742 759 if(possibles.size() == 0){ 743 if(invokeAttributeGetMethod(avp.getAttribute(), toSet) == null) 760 if(invokeAttributeGetMethod(avp.getAttribute(), toSet) == null) { 744 761 throw new NoSuchAttributeException(avp.getAttribute(), toSet.getClass().getSimpleName()); 762 } 745 763 throw new ReadOnlyAttributeException(avp.getAttribute(), toSet.getClass().getSimpleName()); 746 764 }
Note:
See TracChangeset
for help on using the changeset viewer.