Changeset 1410
- Timestamp:
- 06/21/19 15:16:05 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/encryption/io/EncryptedExpWriter.java
r1409 r1410 11 11 import java.util.LinkedHashMap; 12 12 import java.util.List; 13 import java.util.Set; 13 14 import java.util.function.Consumer; 14 15 … … 135 136 LinkedHashMap<Character,Method> itemTags = new LinkedHashMap<Character, Method>(getItemTags()); 136 137 LinkedHashMap<String,Method> itemTagsExt = new LinkedHashMap<String, Method>(getItemTagsExt()); 138 139 // Perform final update on surrogates to ensure inheritance works. 140 Set<Surrogate> surrogates = toWrite.getSurrogates(); 141 for (Surrogate s: surrogates) { 142 s.toString(); 143 } 137 144 138 145 writeTag(toWrite, new Object[] {}, itemTags, 'S'); -
trunk/src/org/expeditee/encryption/items/surrogates/Surrogate.java
r1408 r1410 8 8 import java.util.List; 9 9 import java.util.Map; 10 import java.util.Optional; 10 11 import java.util.Set; 11 12 … … 17 18 18 19 public class Surrogate { 20 21 private static List<Surrogate> surrogateCache = new ArrayList<Surrogate>(); 19 22 20 23 private static Map<String, Boolean> propertyInheritanceDefault = new HashMap<String, Boolean>(); … … 40 43 this.surrogateItem = surrogateItem; 41 44 this.propertyInheritance = new HashMap<String, Boolean>(propertyInheritanceDefault); 45 surrogateCache.add(this); 42 46 } 43 47 … … 69 73 boolean propertyIsInherited = isPropertyIsInherited(itemTag + ""); 70 74 if (propertyIsInherited) { 75 surrogateItem.getClassic().setEncryptionDetailForTag(itemTag + "", EncryptionDetail.UnencryptedOnSave); 71 76 continue; 72 77 } … … 120 125 } 121 126 122 public static Surrogate forItem(Item item) { 127 public static Surrogate of(Item surrogate) { 128 Optional<Surrogate> s = surrogateCache.stream().filter(si -> si.getSurrogateItem() == surrogate).findAny(); 129 if (s.isPresent()) { 130 return s.get(); 131 } else { 132 return null; 133 } 134 } 135 136 public static Surrogate forItem(Item item) { 123 137 Item surrogateItem = item.copy(); 124 138 surrogateItem.setID(item.getParent().getNextItemID()); -
trunk/src/org/expeditee/gui/FrameGraphics.java
r1218 r1410 32 32 import org.expeditee.core.Image; 33 33 import org.expeditee.core.bounds.PolygonBounds; 34 import org.expeditee.encryption.items.surrogates.Label.LabelResult; 35 import org.expeditee.encryption.items.surrogates.Label; 36 import org.expeditee.encryption.items.surrogates.Surrogate; 34 37 import org.expeditee.gio.EcosystemManager; 35 38 import org.expeditee.gio.input.KBMInputEvent.Key; … … 454 457 if (i == null) { 455 458 return; 459 } 460 461 String encryptionLabel = i.getEncryptionLabel(); 462 if (encryptionLabel != null && encryptionLabel.length() > 0 && !i.isSurrogate()) { 463 LabelResult result = Label.resolveKey(encryptionLabel); 464 if (result != LabelResult.SuccessResolveLabelToKey) { 465 for(Surrogate s: i.getSurrogates()) { 466 PaintItem(s.getSurrogateItem()); 467 } 468 return; 469 } 456 470 } 457 471 -
trunk/src/org/expeditee/io/DefaultFrameWriter.java
r1408 r1410 42 42 FrameWriter { 43 43 44 public static final String TAB_INDEX = "_ti"; 45 public static final String SINGLE_LINE_ONLY = "_sl"; 46 public static final String PLACEHOLDER = "_ph"; 47 public static final String ENCRYPTION_LABEL = "_el"; 48 public static final char MAGNETIZED_ITEM_BOTTOM = '/'; 49 public static final char MAGNETIZED_ITEM_TOP = '^'; 50 public static final char MAGNETIZED_ITEM_RIGHT = ']'; 51 public static final char MAGNETIZED_ITEM_LEFT = '['; 52 public static final char PERMISSION = 'p'; 53 public static final char LINK_HISTORY = 'B'; 54 public static final char TOOLTIP = 'A'; 55 public static final char CONSTRAINT_IDS = 'c'; 56 public static final char LINE_IDS = 'l'; 57 public static final char THICKNESS = 'h'; 58 public static final char AUTO_WRAP_TO_SAVE = 'r'; 59 public static final char JUSTIFICATION = 'k'; 60 public static final char MIN_WIDTH_TO_SAVE = 'M'; 61 public static final char WIDTH_TO_SAVE = 'w'; 62 public static final char INITIAL_SPACING = 'm'; 63 public static final char LETTER_SPACING = 'b'; 64 public static final char WORD_SPACING = 'a'; 65 public static final char FORMULA = 'J'; 66 public static final char MASK = 'O'; 67 public static final char SPACING = 't'; 68 public static final char FONT = 'f'; 69 public static final char FILLED = 'z'; 70 public static final char DOT_TYPE = 'v'; 71 public static final char ARROW = 'j'; 72 public static final char LINE_PATTERN = 'g'; 73 public static final char LINK_TEMPLATE = 'y'; 74 public static final char LINK_FRAMESET = 'q'; 75 public static final char LINK_MARK = 'n'; 76 public static final char OWNER = 'o'; 77 public static final char FILL_PATTERN = 'i'; 78 public static final char ANCHOR_BOTTOM = 'I'; 79 public static final char ANCHOR_TOP = 'N'; 80 public static final char ANCHOR_RIGHT = 'H'; 81 public static final char ANCHOR_LEFT = 'R'; 82 public static final char GRADIENT_ANGLE = 'Q'; 83 public static final char GRADIENT_COLOR = 'E'; 84 public static final char FILL_COLOR = 'e'; 85 public static final char HIGHLIGHT = 'u'; 86 public static final char DATA = 'D'; 87 public static final char ACTION_LEAVE_FRAME = 'Y'; 88 public static final char ACTION_ENTER_FRAME = 'W'; 89 public static final char ACTION_CURSOR_LEAVE = 'V'; 90 public static final char ACTION_CURSOR_ENTER = 'U'; 91 public static final char ACTION_MARK = 'x'; 92 public static final char ACTION = 'X'; 93 public static final char LINK = 'F'; 94 public static final char TEXT = 'T'; 95 public static final char POSITION = 'P'; 96 public static final char BORDER_COLOR = 'K'; 97 public static final char BACKGROUND_COLOR = 'G'; 98 public static final char COLOR = 'd'; 99 public static final char DATE_CREATED = 's'; 100 public static final char TYPE_AND_ID = 'S'; 101 44 102 protected String _filename = null; 45 103 … … 86 144 87 145 // Note: As of 26/11/18 there are no unused letter item tags. Use other characters. 88 _ItemTags.put( 'S', Item.class.getMethod("getTypeAndID"));89 _ItemTags.put( 's', Item.class.getMethod("getDateCreated"));90 _ItemTags.put( 'd', Item.class.getMethod("getColor"));91 _ItemTags.put( 'G', Item.class.getMethod("getBackgroundColor"));92 _ItemTags.put( 'K', Item.class.getMethod("getBorderColor"));93 94 _ItemTags.put( 'P', Item.class.getMethod("getPosition"));95 _ItemTags.put( 'T', Text.class.getMethod("getText"));96 _ItemTags.put( 'F', Item.class.getMethod("getLink"));97 _ItemTags.put( 'X', Item.class.getMethod("getAction"));98 _ItemTags.put( 'x', Item.class.getMethod("getActionMark"));99 _ItemTags.put( 'U', Item.class.getMethod("getActionCursorEnter"));100 _ItemTags.put( 'V', Item.class.getMethod("getActionCursorLeave"));101 _ItemTags.put( 'W', Item.class.getMethod("getActionEnterFrame"));102 _ItemTags.put( 'Y', Item.class.getMethod("getActionLeaveFrame"));103 _ItemTags.put( 'D', Item.class.getMethod("getData"));104 _ItemTags.put( 'u', Item.class.getMethod("getHighlight"));105 _ItemTags.put( 'e', Item.class.getMethod("getFillColor"));106 _ItemTags.put( 'E', Item.class.getMethod("getGradientColor"));107 _ItemTags.put( 'Q', Item.class.getMethod("getGradientAngle"));108 109 _ItemTags.put( 'R', Item.class.getMethod("getAnchorLeft"));110 _ItemTags.put( 'H', Item.class.getMethod("getAnchorRight"));111 _ItemTags.put( 'N', Item.class.getMethod("getAnchorTop"));112 _ItemTags.put( 'I', Item.class.getMethod("getAnchorBottom"));113 114 _ItemTags.put( 'i', Item.class.getMethod("getFillPattern"));115 _ItemTags.put( 'o', Item.class.getMethod("getOwner"));116 _ItemTags.put( 'n', Item.class.getMethod("getLinkMark"));117 _ItemTags.put( 'q', Item.class.getMethod("getLinkFrameset"));118 _ItemTags.put( 'y', Item.class.getMethod("getLinkTemplate"));119 _ItemTags.put( 'g', Item.class.getMethod("getLinePattern"));120 121 _ItemTags.put( 'j', Item.class.getMethod("getArrow"));122 123 _ItemTags.put( 'v', Item.class.getMethod("getDotType"));124 _ItemTags.put( 'z', Item.class.getMethod("getFilled"));125 126 _ItemTags.put( 'f', Text.class.getMethod("getFont"));127 _ItemTags.put( 't', Text.class.getMethod("getSpacing"));128 129 _ItemTags.put( 'O', Text.class.getMethod("getMask"));146 _ItemTags.put(DefaultFrameWriter.TYPE_AND_ID, Item.class.getMethod("getTypeAndID")); 147 _ItemTags.put(DefaultFrameWriter.DATE_CREATED, Item.class.getMethod("getDateCreated")); 148 _ItemTags.put(DefaultFrameWriter.COLOR, Item.class.getMethod("getColor")); 149 _ItemTags.put(DefaultFrameWriter.BACKGROUND_COLOR, Item.class.getMethod("getBackgroundColor")); 150 _ItemTags.put(DefaultFrameWriter.BORDER_COLOR, Item.class.getMethod("getBorderColor")); 151 152 _ItemTags.put(DefaultFrameWriter.POSITION, Item.class.getMethod("getPosition")); 153 _ItemTags.put(DefaultFrameWriter.TEXT, Text.class.getMethod("getText")); 154 _ItemTags.put(DefaultFrameWriter.LINK, Item.class.getMethod("getLink")); 155 _ItemTags.put(DefaultFrameWriter.ACTION, Item.class.getMethod("getAction")); 156 _ItemTags.put(DefaultFrameWriter.ACTION_MARK, Item.class.getMethod("getActionMark")); 157 _ItemTags.put(DefaultFrameWriter.ACTION_CURSOR_ENTER, Item.class.getMethod("getActionCursorEnter")); 158 _ItemTags.put(DefaultFrameWriter.ACTION_CURSOR_LEAVE, Item.class.getMethod("getActionCursorLeave")); 159 _ItemTags.put(DefaultFrameWriter.ACTION_ENTER_FRAME, Item.class.getMethod("getActionEnterFrame")); 160 _ItemTags.put(DefaultFrameWriter.ACTION_LEAVE_FRAME, Item.class.getMethod("getActionLeaveFrame")); 161 _ItemTags.put(DefaultFrameWriter.DATA, Item.class.getMethod("getData")); 162 _ItemTags.put(DefaultFrameWriter.HIGHLIGHT, Item.class.getMethod("getHighlight")); 163 _ItemTags.put(DefaultFrameWriter.FILL_COLOR, Item.class.getMethod("getFillColor")); 164 _ItemTags.put(DefaultFrameWriter.GRADIENT_COLOR, Item.class.getMethod("getGradientColor")); 165 _ItemTags.put(DefaultFrameWriter.GRADIENT_ANGLE, Item.class.getMethod("getGradientAngle")); 166 167 _ItemTags.put(DefaultFrameWriter.ANCHOR_LEFT, Item.class.getMethod("getAnchorLeft")); 168 _ItemTags.put(DefaultFrameWriter.ANCHOR_RIGHT, Item.class.getMethod("getAnchorRight")); 169 _ItemTags.put(DefaultFrameWriter.ANCHOR_TOP, Item.class.getMethod("getAnchorTop")); 170 _ItemTags.put(DefaultFrameWriter.ANCHOR_BOTTOM, Item.class.getMethod("getAnchorBottom")); 171 172 _ItemTags.put(DefaultFrameWriter.FILL_PATTERN, Item.class.getMethod("getFillPattern")); 173 _ItemTags.put(DefaultFrameWriter.OWNER, Item.class.getMethod("getOwner")); 174 _ItemTags.put(DefaultFrameWriter.LINK_MARK, Item.class.getMethod("getLinkMark")); 175 _ItemTags.put(DefaultFrameWriter.LINK_FRAMESET, Item.class.getMethod("getLinkFrameset")); 176 _ItemTags.put(DefaultFrameWriter.LINK_TEMPLATE, Item.class.getMethod("getLinkTemplate")); 177 _ItemTags.put(DefaultFrameWriter.LINE_PATTERN, Item.class.getMethod("getLinePattern")); 178 179 _ItemTags.put(DefaultFrameWriter.ARROW, Item.class.getMethod("getArrow")); 180 181 _ItemTags.put(DefaultFrameWriter.DOT_TYPE, Item.class.getMethod("getDotType")); 182 _ItemTags.put(DefaultFrameWriter.FILLED, Item.class.getMethod("getFilled")); 183 184 _ItemTags.put(DefaultFrameWriter.FONT, Text.class.getMethod("getFont")); 185 _ItemTags.put(DefaultFrameWriter.SPACING, Text.class.getMethod("getSpacing")); 186 187 _ItemTags.put(DefaultFrameWriter.MASK, Text.class.getMethod("getMask")); 130 188 131 189 // TODO set a boolean flag to indicate that the text is a formula 132 190 // Store the formula in the text property NOT the answer 133 _ItemTags.put( 'J', Item.class.getMethod("getFormula"));134 135 _ItemTags.put( 'a', Text.class.getMethod("getWordSpacing"));136 _ItemTags.put( 'b', Text.class.getMethod("getLetterSpacing"));137 _ItemTags.put( 'm', Text.class.getMethod("getInitialSpacing"));138 _ItemTags.put( 'w', Text.class.getMethod("getWidthToSave"));139 _ItemTags.put( 'M', Text.class.getMethod("getMinWidthToSave"));140 _ItemTags.put( 'k', Text.class.getMethod("getJustification"));141 _ItemTags.put( 'r', Text.class.getMethod("getAutoWrapToSave"));142 143 _ItemTags.put( 'h', Item.class.getMethod("getThickness"));144 _ItemTags.put( 'l', Item.class.getMethod("getLineIDs"));145 _ItemTags.put( 'c', Item.class.getMethod("getConstraintIDs"));146 147 _ItemTags.put( 'A', Item.class.getMethod("getTooltip"));148 _ItemTags.put( 'B', Item.class.getMethod("getLinkHistory"));149 150 _ItemTags.put( 'p', Item.class.getMethod("getPermission"));151 152 _ItemTags.put( '[', Item.class.getMethod("getMagnetizedItemLeft"));153 _ItemTags.put( ']', Item.class.getMethod("getMagnetizedItemRight"));154 _ItemTags.put( '^', Item.class.getMethod("getMagnetizedItemTop"));155 _ItemTags.put( '/', Item.class.getMethod("getMagnetizedItemBottom"));156 157 _ItemTagsExt.put( "_el", Item.class.getMethod("getEncryptionLabel"));158 159 _ItemTagsExt.put( "_ph", Text.class.getMethod("getPlaceholder"));160 _ItemTagsExt.put( "_sl", Text.class.getMethod("isSingleLineOnly"));161 _ItemTagsExt.put( "_ti", Text.class.getMethod("getTabIndex"));191 _ItemTags.put(DefaultFrameWriter.FORMULA, Item.class.getMethod("getFormula")); 192 193 _ItemTags.put(DefaultFrameWriter.WORD_SPACING, Text.class.getMethod("getWordSpacing")); 194 _ItemTags.put(DefaultFrameWriter.LETTER_SPACING, Text.class.getMethod("getLetterSpacing")); 195 _ItemTags.put(DefaultFrameWriter.INITIAL_SPACING, Text.class.getMethod("getInitialSpacing")); 196 _ItemTags.put(DefaultFrameWriter.WIDTH_TO_SAVE, Text.class.getMethod("getWidthToSave")); 197 _ItemTags.put(DefaultFrameWriter.MIN_WIDTH_TO_SAVE, Text.class.getMethod("getMinWidthToSave")); 198 _ItemTags.put(DefaultFrameWriter.JUSTIFICATION, Text.class.getMethod("getJustification")); 199 _ItemTags.put(DefaultFrameWriter.AUTO_WRAP_TO_SAVE, Text.class.getMethod("getAutoWrapToSave")); 200 201 _ItemTags.put(DefaultFrameWriter.THICKNESS, Item.class.getMethod("getThickness")); 202 _ItemTags.put(DefaultFrameWriter.LINE_IDS, Item.class.getMethod("getLineIDs")); 203 _ItemTags.put(DefaultFrameWriter.CONSTRAINT_IDS, Item.class.getMethod("getConstraintIDs")); 204 205 _ItemTags.put(DefaultFrameWriter.TOOLTIP, Item.class.getMethod("getTooltip")); 206 _ItemTags.put(DefaultFrameWriter.LINK_HISTORY, Item.class.getMethod("getLinkHistory")); 207 208 _ItemTags.put(DefaultFrameWriter.PERMISSION, Item.class.getMethod("getPermission")); 209 210 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT, Item.class.getMethod("getMagnetizedItemLeft")); 211 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT, Item.class.getMethod("getMagnetizedItemRight")); 212 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_TOP, Item.class.getMethod("getMagnetizedItemTop")); 213 _ItemTags.put(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM, Item.class.getMethod("getMagnetizedItemBottom")); 214 215 _ItemTagsExt.put(DefaultFrameWriter.ENCRYPTION_LABEL, Item.class.getMethod("getEncryptionLabel")); 216 217 _ItemTagsExt.put(DefaultFrameWriter.PLACEHOLDER, Text.class.getMethod("getPlaceholder")); 218 _ItemTagsExt.put(DefaultFrameWriter.SINGLE_LINE_ONLY, Text.class.getMethod("isSingleLineOnly")); 219 _ItemTagsExt.put(DefaultFrameWriter.TAB_INDEX, Text.class.getMethod("getTabIndex")); 162 220 } catch (Exception e) { 163 221 e.printStackTrace(); -
trunk/src/org/expeditee/items/Item.java
r1408 r1410 418 418 419 419 public DotType getDotType() { 420 return _type; 420 Surrogate surrogate = Surrogate.of(this); 421 if (surrogate != null && 422 surrogate.isPropertyIsInherited(DefaultFrameWriter.DOT_TYPE + "")) { 423 return this.getClassic().getDotType(); 424 } else { 425 return _type; 426 } 421 427 } 422 428 … … 430 436 431 437 public boolean getFilled() { 432 return _filled; 438 Surrogate surrogate = Surrogate.of(this); 439 if (surrogate != null && 440 surrogate.isPropertyIsInherited(DefaultFrameWriter.FILLED + "")) { 441 return this.getClassic().getFilled(); 442 } else { 443 return _filled; 444 } 433 445 } 434 446 … … 457 469 */ 458 470 public double getGradientAngle() { 459 return _gradientAngle; 471 Surrogate surrogate = Surrogate.of(this); 472 if (surrogate != null && 473 surrogate.isPropertyIsInherited(DefaultFrameWriter.GRADIENT_ANGLE + "")) { 474 return this.getClassic().getGradientAngle(); 475 } else { 476 return _gradientAngle; 477 } 460 478 } 461 479 … … 513 531 514 532 public PermissionTriple getPermission() { 515 return _permissionTriple; 533 Surrogate surrogate = Surrogate.of(this); 534 if (surrogate != null && 535 surrogate.isPropertyIsInherited(DefaultFrameWriter.PERMISSION + "")) { 536 return this.getClassic().getPermission(); 537 } else { 538 return _permissionTriple; 539 } 516 540 } 517 541 … … 659 683 */ 660 684 public List<String> getAction() { 661 return _actions; 685 Surrogate surrogate = Surrogate.of(this); 686 if (surrogate != null && 687 surrogate.isPropertyIsInherited(DefaultFrameWriter.ACTION + "")) { 688 return this.getClassic().getAction(); 689 } else { 690 return _actions; 691 } 662 692 } 663 693 664 694 public List<String> getData() { 665 return _data.getData(); 695 Surrogate surrogate = Surrogate.of(this); 696 if (surrogate != null && 697 surrogate.isPropertyIsInherited(DefaultFrameWriter.DATA + "")) { 698 return this.getClassic().getData(); 699 } else { 700 return _data.getData(); 701 } 666 702 } 667 703 668 704 public List<String> getActionCursorEnter() { 669 return _actionCursorEnter; 705 Surrogate surrogate = Surrogate.of(this); 706 if (surrogate != null && 707 surrogate.isPropertyIsInherited(DefaultFrameWriter.ACTION_CURSOR_ENTER + "")) { 708 return this.getClassic().getActionCursorEnter(); 709 } else { 710 return _actionCursorEnter; 711 } 670 712 } 671 713 672 714 public List<String> getActionCursorLeave() { 673 return _actionCursorLeave; 715 Surrogate surrogate = Surrogate.of(this); 716 if (surrogate != null && 717 surrogate.isPropertyIsInherited(DefaultFrameWriter.ACTION_CURSOR_LEAVE + "")) { 718 return this.getClassic().getActionCursorLeave(); 719 } else { 720 return _actionCursorLeave; 721 } 674 722 } 675 723 676 724 public List<String> getActionEnterFrame() { 677 return _actionEnterFrame; 725 Surrogate surrogate = Surrogate.of(this); 726 if (surrogate != null && 727 surrogate.isPropertyIsInherited(DefaultFrameWriter.ACTION_ENTER_FRAME + "")) { 728 return this.getClassic().getActionEnterFrame(); 729 } else { 730 return _actionEnterFrame; 731 } 678 732 } 679 733 680 734 public List<String> getActionLeaveFrame() { 681 return _actionLeaveFrame; 735 Surrogate surrogate = Surrogate.of(this); 736 if (surrogate != null && 737 surrogate.isPropertyIsInherited(DefaultFrameWriter.ACTION_LEAVE_FRAME + "")) { 738 return this.getClassic().getActionLeaveFrame(); 739 } else { 740 return _actionLeaveFrame; 741 } 682 742 } 683 743 684 744 public boolean getActionMark() { 685 return _actionMark; 745 Surrogate surrogate = Surrogate.of(this); 746 if (surrogate != null && 747 surrogate.isPropertyIsInherited(DefaultFrameWriter.ACTION_MARK + "")) { 748 return this.getClassic().getActionMark(); 749 } else { 750 return _actionMark; 751 } 686 752 } 687 753 … … 703 769 }*/ 704 770 705 public String getArrow() 706 { 707 if (!hasVisibleArrow()) 708 return null; 709 710 String ratio = "" + getArrowheadRatio(); 711 if (ratio.length() - ratio.indexOf(".") > 2) 712 ratio = ratio.substring(0, ratio.indexOf(".") + 3); 713 714 return getArrowheadLength() + " " + ratio + " " + getArrowheadNibPerc(); 771 public String getArrow() { 772 Surrogate surrogate = Surrogate.of(this); 773 if (surrogate != null && 774 surrogate.isPropertyIsInherited(DefaultFrameWriter.ARROW + "")) { 775 return this.getClassic().getArrow(); 776 } else { 777 if (!hasVisibleArrow()) 778 return null; 779 780 String ratio = "" + getArrowheadRatio(); 781 if (ratio.length() - ratio.indexOf(".") > 2) 782 ratio = ratio.substring(0, ratio.indexOf(".") + 3); 783 784 return getArrowheadLength() + " " + ratio + " " + getArrowheadNibPerc(); 785 } 715 786 } 716 787 … … 735 806 } 736 807 737 public Colour getBackgroundColor() 738 { 739 return _backgroundColour; 740 } 741 742 public Colour getBorderColor() 743 { 744 return _colorBorder; 808 public Colour getBackgroundColor() { 809 Surrogate surrogate = Surrogate.of(this); 810 if (surrogate != null && 811 surrogate.isPropertyIsInherited(DefaultFrameWriter.BACKGROUND_COLOR + "")) { 812 return this.getClassic().getBackgroundColor(); 813 } else { 814 return _backgroundColour; 815 } 816 } 817 818 public Colour getBorderColor() { 819 Surrogate surrogate = Surrogate.of(this); 820 if (surrogate != null && 821 surrogate.isPropertyIsInherited(DefaultFrameWriter.TYPE_AND_ID + "")) { 822 return this.getClassic().getBorderColor(); 823 } else { 824 return _colorBorder; 825 } 745 826 } 746 827 … … 814 895 } 815 896 816 public Colour getColor() 817 { 818 return _foregroundColour; 897 public Colour getColor() { 898 Surrogate surrogate = Surrogate.of(this); 899 if (surrogate != null && 900 surrogate.isPropertyIsInherited(DefaultFrameWriter.COLOR + "")) { 901 return this.getClassic().getColor(); 902 } else { 903 return _foregroundColour; 904 } 819 905 } 820 906 … … 828 914 } 829 915 830 public String getConstraintIDs() 831 { 832 if (_constraints == null || _constraints.size() == 0) 833 return null; 834 835 String cons = ""; 836 837 for (Constraint c : _constraints) 838 cons += c.getID() + " "; 839 840 return cons.trim(); 916 public String getConstraintIDs() { 917 Surrogate surrogate = Surrogate.of(this); 918 if (surrogate != null && 919 surrogate.isPropertyIsInherited(DefaultFrameWriter.CONSTRAINT_IDS + "")) { 920 return this.getClassic().getConstraintIDs(); 921 } else { 922 if (_constraints == null || _constraints.size() == 0) 923 return null; 924 925 String cons = ""; 926 927 for (Constraint c : _constraints) 928 cons += c.getID() + " "; 929 930 return cons.trim(); 931 } 841 932 } 842 933 … … 862 953 } 863 954 864 public String getDateCreated() 865 { 866 return _creationDate; 867 } 868 869 public Colour getFillColor() 870 { 871 return _fillColour; 872 } 873 874 public String getFillPattern() 875 { 876 return _fillPattern; 955 public String getDateCreated() { 956 Surrogate surrogate = Surrogate.of(this); 957 if (surrogate != null && 958 surrogate.isPropertyIsInherited(DefaultFrameWriter.DATE_CREATED + "")) { 959 return this.getClassic().getDateCreated(); 960 } else { 961 return _creationDate; 962 } 963 } 964 965 public Colour getFillColor() { 966 Surrogate surrogate = Surrogate.of(this); 967 if (surrogate != null && 968 surrogate.isPropertyIsInherited(DefaultFrameWriter.FILL_COLOR + "")) { 969 return this.getClassic().getFillColor(); 970 } else { 971 return _fillColour; 972 } 973 } 974 975 public String getFillPattern() { 976 Surrogate surrogate = Surrogate.of(this); 977 if (surrogate != null && 978 surrogate.isPropertyIsInherited(DefaultFrameWriter.FILL_PATTERN + "")) { 979 return this.getClassic().getFillPattern(); 980 } else { 981 return _fillPattern; 982 } 877 983 } 878 984 … … 890 996 * @return The value of <code>_highlight</code>. 891 997 */ 892 public boolean getHighlight() 893 { 894 return _highlight; 998 public boolean getHighlight() { 999 Surrogate surrogate = Surrogate.of(this); 1000 if (surrogate != null && 1001 surrogate.isPropertyIsInherited(DefaultFrameWriter.HIGHLIGHT + "")) { 1002 return this.getClassic().getHighlight(); 1003 } else { 1004 return _highlight; 1005 } 895 1006 } 896 1007 … … 919 1030 * @return The list of Line IDs that this point is part of. 920 1031 */ 921 public String getLineIDs() 922 { 923 String lineID = null; 924 925 if (_lines.size() > 0) { 926 lineID = "" + _lines.get(0).getID(); 927 928 for (int i = 1; i < _lines.size(); i++) 929 lineID += " " + _lines.get(i).getID(); 930 } 931 932 return lineID; 933 } 934 935 public int[] getLinePattern() 936 { 937 return _linePattern; 1032 public String getLineIDs() { 1033 Surrogate surrogate = Surrogate.of(this); 1034 if (surrogate != null && 1035 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINE_IDS + "")) { 1036 return this.getClassic().getLineIDs(); 1037 } else { 1038 String lineID = null; 1039 1040 if (_lines.size() > 0) { 1041 lineID = "" + _lines.get(0).getID(); 1042 1043 for (int i = 1; i < _lines.size(); i++) 1044 lineID += " " + _lines.get(i).getID(); 1045 } 1046 1047 return lineID; 1048 } 1049 } 1050 1051 public int[] getLinePattern() { 1052 Surrogate surrogate = Surrogate.of(this); 1053 if (surrogate != null && 1054 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINE_PATTERN + "")) { 1055 return this.getClassic().getLinePattern(); 1056 } else { 1057 return _linePattern; 1058 } 938 1059 } 939 1060 … … 956 1077 * this Item does not link to anything. 957 1078 */ 958 public String getLink() 959 { 960 return _link; 961 } 962 963 public String getFormula() 964 { 965 return _formula; 1079 public String getLink() { 1080 Surrogate surrogate = Surrogate.of(this); 1081 if (surrogate != null && 1082 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINK + "")) { 1083 return this.getClassic().getLink(); 1084 } else { 1085 return _link; 1086 } 1087 } 1088 1089 public String getFormula() { 1090 Surrogate surrogate = Surrogate.of(this); 1091 if (surrogate != null && 1092 surrogate.isPropertyIsInherited(DefaultFrameWriter.FORMULA + "")) { 1093 return this.getClassic().getFormula(); 1094 } else { 1095 return _formula; 1096 } 966 1097 } 967 1098 … … 987 1118 } 988 1119 989 public String getLinkFrameset() 990 { 991 return _link_frameset; 992 } 993 994 public boolean getLinkMark() 995 { 996 return _linkMark; 997 } 998 999 public String getLinkTemplate() 1000 { 1001 return _link_template; 1120 public String getLinkFrameset() { 1121 Surrogate surrogate = Surrogate.of(this); 1122 if (surrogate != null && 1123 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINK_FRAMESET + "")) { 1124 return this.getClassic().getLinkFrameset(); 1125 } else { 1126 return _link_frameset; 1127 } 1128 } 1129 1130 public boolean getLinkMark() { 1131 Surrogate surrogate = Surrogate.of(this); 1132 if (surrogate != null && 1133 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINK_MARK + "")) { 1134 return this.getClassic().getLinkMark(); 1135 } else { 1136 return _linkMark; 1137 } 1138 } 1139 1140 public String getLinkTemplate() { 1141 Surrogate surrogate = Surrogate.of(this); 1142 if (surrogate != null && 1143 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINK_TEMPLATE + "")) { 1144 return this.getClassic().getLinkTemplate(); 1145 } else { 1146 return _link_template; 1147 } 1002 1148 } 1003 1149 … … 1012 1158 } 1013 1159 1014 public String getOwner() 1015 { 1016 return _owner; 1160 public String getOwner() { 1161 Surrogate surrogate = Surrogate.of(this); 1162 if (surrogate != null && 1163 surrogate.isPropertyIsInherited(DefaultFrameWriter.OWNER + "")) { 1164 return this.getClassic().getOwner(); 1165 } else { 1166 return _owner; 1167 } 1017 1168 } 1018 1169 … … 1129 1280 1130 1281 /** Gets the position of this item. */ 1131 public final Point getPosition() 1132 { 1133 return new Point(getX(), getY()); 1282 public final Point getPosition() { 1283 Surrogate surrogate = Surrogate.of(this); 1284 if (surrogate != null && 1285 surrogate.isPropertyIsInherited(DefaultFrameWriter.POSITION + "")) { 1286 return this.getClassic().getPosition(); 1287 } else { 1288 return new Point(getX(), getY()); 1289 } 1134 1290 } 1135 1291 … … 1156 1312 } 1157 1313 1158 public String getTypeAndID() 1159 { 1160 return "T " + getID(); 1161 } 1162 1163 public Integer getWidthToSave() 1164 { 1165 return getWidth(); 1314 public String getTypeAndID() { 1315 Surrogate surrogate = Surrogate.of(this); 1316 if (surrogate != null && 1317 surrogate.isPropertyIsInherited(DefaultFrameWriter.TYPE_AND_ID + "")) { 1318 return this.getClassic().getTypeAndID(); 1319 } else { 1320 return "T " + getID(); 1321 } 1322 } 1323 1324 public Integer getWidthToSave() { 1325 Surrogate surrogate = Surrogate.of(this); 1326 if (surrogate != null && 1327 surrogate.isPropertyIsInherited(DefaultFrameWriter.WIDTH_TO_SAVE + "")) { 1328 return this.getClassic().getWidthToSave(); 1329 } else { 1330 return getWidth(); 1331 } 1166 1332 } 1167 1333 1168 1334 public Integer getMinWidthToSave() { 1169 return getMinWidth(); 1335 Surrogate surrogate = Surrogate.of(this); 1336 if (surrogate != null && 1337 surrogate.isPropertyIsInherited(DefaultFrameWriter.MIN_WIDTH_TO_SAVE + "")) { 1338 return this.getClassic().getMinWidthToSave(); 1339 } else { 1340 return getMinWidth(); 1341 } 1170 1342 } 1171 1343 … … 1189 1361 * @return The X coordinate of this Item on the screen 1190 1362 */ 1191 public int getX() 1192 { 1193 return Math.round(_x); 1363 public int getX() { 1364 Surrogate surrogate = Surrogate.of(this); 1365 if (surrogate != null && 1366 surrogate.isPropertyIsInherited(DefaultFrameWriter.POSITION + "")) { 1367 return this.getClassic().getX(); 1368 } else { 1369 return Math.round(_x); 1370 } 1194 1371 } 1195 1372 … … 1199 1376 * @return The Y coordinate of this Item on the screen 1200 1377 */ 1201 public int getY() 1202 { 1203 return Math.round(_y); 1378 public int getY() { 1379 Surrogate surrogate = Surrogate.of(this); 1380 if (surrogate != null && 1381 surrogate.isPropertyIsInherited(DefaultFrameWriter.POSITION + "")) { 1382 return this.getClassic().getY(); 1383 } else { 1384 return Math.round(_y); 1385 } 1204 1386 } 1205 1387 … … 1357 1539 } 1358 1540 1359 public List<String> getTooltip() 1360 { 1361 return _tooltip.asStringList(); 1541 public List<String> getTooltip() { 1542 Surrogate surrogate = Surrogate.of(this); 1543 if (surrogate != null && 1544 surrogate.isPropertyIsInherited(DefaultFrameWriter.TOOLTIP + "")) { 1545 return this.getClassic().getTooltip(); 1546 } else { 1547 return _tooltip.asStringList(); 1548 } 1362 1549 } 1363 1550 … … 1836 2023 1837 2024 public Colour getGradientColor() { 1838 return _gradientColour; 2025 Surrogate surrogate = Surrogate.of(this); 2026 if (surrogate != null && 2027 surrogate.isPropertyIsInherited(DefaultFrameWriter.GRADIENT_COLOR + "")) { 2028 return this.getClassic().getGradientColor(); 2029 } else { 2030 return _gradientColour; 2031 } 1839 2032 } 1840 2033 … … 1924 2117 1925 2118 public boolean getLinkHistory() { 1926 return _linkHistory; 2119 Surrogate surrogate = Surrogate.of(this); 2120 if (surrogate != null && 2121 surrogate.isPropertyIsInherited(DefaultFrameWriter.LINK_HISTORY + "")) { 2122 return this.getClassic().getLinkHistory(); 2123 } else { 2124 return _linkHistory; 2125 } 1927 2126 } 1928 2127 … … 2251 2450 * set). 2252 2451 */ 2253 public float getThickness() 2254 { 2255 return _thickness; 2452 public float getThickness() { 2453 Surrogate surrogate = Surrogate.of(this); 2454 if (surrogate != null && 2455 surrogate.isPropertyIsInherited(DefaultFrameWriter.THICKNESS + "")) { 2456 return this.getClassic().getThickness(); 2457 } else { 2458 return _thickness; 2459 } 2256 2460 } 2257 2461 … … 3160 3364 3161 3365 public Integer getAnchorLeft() { 3162 return _anchoring.getLeftAnchor(); 3366 Surrogate surrogate = Surrogate.of(this); 3367 if (surrogate != null && 3368 surrogate.isPropertyIsInherited(DefaultFrameWriter.ANCHOR_LEFT + "")) { 3369 return this.getClassic().getAnchorLeft(); 3370 } else { 3371 return _anchoring.getLeftAnchor(); 3372 } 3163 3373 } 3164 3374 3165 3375 public Integer getAnchorRight() { 3166 return _anchoring.getRightAnchor(); 3376 Surrogate surrogate = Surrogate.of(this); 3377 if (surrogate != null && 3378 surrogate.isPropertyIsInherited(DefaultFrameWriter.ANCHOR_RIGHT + "")) { 3379 return this.getClassic().getAnchorRight(); 3380 } else { 3381 return _anchoring.getRightAnchor(); 3382 } 3167 3383 } 3168 3384 3169 3385 public Integer getAnchorTop() { 3170 return _anchoring.getTopAnchor(); 3386 Surrogate surrogate = Surrogate.of(this); 3387 if (surrogate != null && 3388 surrogate.isPropertyIsInherited(DefaultFrameWriter.ANCHOR_TOP + "")) { 3389 return this.getClassic().getAnchorTop(); 3390 } else { 3391 return _anchoring.getTopAnchor(); 3392 } 3171 3393 } 3172 3394 3173 3395 public Integer getAnchorBottom() { 3174 return _anchoring.getBottomAnchor(); 3396 Surrogate surrogate = Surrogate.of(this); 3397 if (surrogate != null && 3398 surrogate.isPropertyIsInherited(DefaultFrameWriter.ANCHOR_BOTTOM + "")) { 3399 return this.getClassic().getAnchorBottom(); 3400 } else { 3401 return _anchoring.getBottomAnchor(); 3402 } 3175 3403 } 3176 3404 3177 3405 public String getText() { 3178 return "@" + getClass().getSimpleName() + ":" + getID(); 3406 Surrogate surrogate = Surrogate.of(this); 3407 if (surrogate != null && 3408 surrogate.isPropertyIsInherited(DefaultFrameWriter.TEXT + "")) { 3409 return this.getClassic().getText(); 3410 } else { 3411 return "@" + getClass().getSimpleName() + ":" + getID(); 3412 } 3179 3413 } 3180 3414 … … 3412 3646 3413 3647 public int getMagnetizedItemLeft() { 3414 if(_magnetizedItemLeft != null) return _magnetizedItemLeft.getID(); 3415 else return -1; 3648 Surrogate surrogate = Surrogate.of(this); 3649 if (surrogate != null && 3650 surrogate.isPropertyIsInherited(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT + "")) { 3651 return this.getClassic().getMagnetizedItemLeft(); 3652 } else { 3653 if(_magnetizedItemLeft != null) return _magnetizedItemLeft.getID(); 3654 else return -1; 3655 } 3416 3656 } 3417 3657 … … 3425 3665 3426 3666 public int getMagnetizedItemRight() { 3427 if(_magnetizedItemRight != null) return _magnetizedItemRight.getID(); 3428 else return -1; 3667 Surrogate surrogate = Surrogate.of(this); 3668 if (surrogate != null && 3669 surrogate.isPropertyIsInherited(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT + "")) { 3670 return this.getClassic().getMagnetizedItemRight(); 3671 } else { 3672 if(_magnetizedItemRight != null) return _magnetizedItemRight.getID(); 3673 else return -1; 3674 } 3429 3675 } 3430 3676 … … 3438 3684 3439 3685 public int getMagnetizedItemTop() { 3440 if(_magnetizedItemTop != null) return _magnetizedItemTop.getID(); 3441 else return -1; 3686 Surrogate surrogate = Surrogate.of(this); 3687 if (surrogate != null && 3688 surrogate.isPropertyIsInherited(DefaultFrameWriter.MAGNETIZED_ITEM_TOP + "")) { 3689 return this.getClassic().getMagnetizedItemTop(); 3690 } else { 3691 if(_magnetizedItemTop != null) return _magnetizedItemTop.getID(); 3692 else return -1; 3693 } 3442 3694 } 3443 3695 … … 3451 3703 3452 3704 public int getMagnetizedItemBottom() { 3453 if(_magnetizedItemBottom != null) return _magnetizedItemBottom.getID(); 3454 else return -1; 3705 Surrogate surrogate = Surrogate.of(this); 3706 if (surrogate != null && 3707 surrogate.isPropertyIsInherited(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM + "")) { 3708 return this.getClassic().getMagnetizedItemBottom(); 3709 } else { 3710 if(_magnetizedItemBottom != null) return _magnetizedItemBottom.getID(); 3711 else return -1; 3712 } 3455 3713 } 3456 3714 … … 3464 3722 3465 3723 public String getEncryptionLabel() { 3466 return _encryptionLabel; 3724 Surrogate surrogate = Surrogate.of(this); 3725 if (surrogate != null && 3726 surrogate.isPropertyIsInherited(DefaultFrameWriter.ENCRYPTION_LABEL + "")) { 3727 return this.getClassic().getEncryptionLabel(); 3728 } else { 3729 return _encryptionLabel; 3730 } 3467 3731 } 3468 3732 -
trunk/src/org/expeditee/items/Text.java
r1392 r1410 41 41 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 42 42 import org.expeditee.core.bounds.PolygonBounds; 43 import org.expeditee.encryption.items.surrogates.Surrogate; 43 44 import org.expeditee.gio.EcosystemManager; 44 45 import org.expeditee.gio.GraphicsManager; … … 51 52 import org.expeditee.gui.FreeItems; 52 53 import org.expeditee.gui.MessageBay; 54 import org.expeditee.io.DefaultFrameWriter; 53 55 import org.expeditee.items.MagneticConstraint.MagneticConstraints; 54 56 import org.expeditee.math.ExpediteeJEP; … … 499 501 */ 500 502 public Justification getJustification() { 501 if (_justification == null || _justification.equals(Justification.left)) { 502 return null; 503 } 504 505 return _justification; 503 Surrogate surrogate = Surrogate.of(this); 504 if (surrogate != null && 505 surrogate.isPropertyIsInherited(DefaultFrameWriter.JUSTIFICATION + "")) { 506 return ((Text) this.getClassic()).getJustification(); 507 } else { 508 if (_justification == null || _justification.equals(Justification.left)) { 509 return null; 510 } 511 512 return _justification; 513 } 506 514 } 507 515 … … 1295 1303 */ 1296 1304 public Font getFont() { 1297 return _font; 1305 Surrogate surrogate = Surrogate.of(this); 1306 if (surrogate != null && 1307 surrogate.isPropertyIsInherited(DefaultFrameWriter.FONT + "")) { 1308 return ((Text) this.getClassic()).getFont(); 1309 } else { 1310 return _font; 1311 } 1298 1312 } 1299 1313 … … 1501 1515 */ 1502 1516 public float getSpacing() { 1503 return _spacing; 1517 Surrogate surrogate = Surrogate.of(this); 1518 if (surrogate != null && 1519 surrogate.isPropertyIsInherited(DefaultFrameWriter.SPACING + "")) { 1520 return ((Text) this.getClassic()).getSpacing(); 1521 } else { 1522 return _spacing; 1523 } 1504 1524 } 1505 1525 … … 1525 1545 1526 1546 public int getWordSpacing() { 1527 return _word_spacing; 1547 Surrogate surrogate = Surrogate.of(this); 1548 if (surrogate != null && 1549 surrogate.isPropertyIsInherited(DefaultFrameWriter.WORD_SPACING + "")) { 1550 return ((Text) this.getClassic()).getWordSpacing(); 1551 } else { 1552 return _word_spacing; 1553 } 1528 1554 } 1529 1555 … … 1548 1574 */ 1549 1575 public float getLetterSpacing() { 1550 return _letter_spacing; 1576 Surrogate surrogate = Surrogate.of(this); 1577 if (surrogate != null && 1578 surrogate.isPropertyIsInherited(DefaultFrameWriter.LETTER_SPACING + "")) { 1579 return ((Text) this.getClassic()).getLetterSpacing(); 1580 } else { 1581 return _letter_spacing; 1582 } 1551 1583 } 1552 1584 … … 1556 1588 1557 1589 public float getInitialSpacing() { 1558 return _initial_spacing; 1590 Surrogate surrogate = Surrogate.of(this); 1591 if (surrogate != null && 1592 surrogate.isPropertyIsInherited(DefaultFrameWriter.INITIAL_SPACING + "")) { 1593 return ((Text) this.getClassic()).getInitialSpacing(); 1594 } else { 1595 return _initial_spacing; 1596 } 1559 1597 } 1560 1598 … … 3009 3047 3010 3048 public boolean getAutoWrap() { 3011 return _autoWrap; 3049 Surrogate surrogate = Surrogate.of(this); 3050 if (surrogate != null && 3051 surrogate.isPropertyIsInherited(DefaultFrameWriter.AUTO_WRAP_TO_SAVE + "")) { 3052 return ((Text) this.getClassic()).getAutoWrap(); 3053 } else { 3054 return _autoWrap; 3055 } 3012 3056 } 3013 3057 … … 3145 3189 3146 3190 public Integer getMask() { 3147 if (_mask == null) { 3148 return null; 3191 Surrogate surrogate = Surrogate.of(this); 3192 if (surrogate != null && 3193 surrogate.isPropertyIsInherited(DefaultFrameWriter.MASK + "")) { 3194 return ((Text) this.getClassic()).getMask(); 3149 3195 } else { 3150 return _mask; 3151 } 3196 if (_mask == null) { 3197 return null; 3198 } else { 3199 return _mask; 3200 } 3201 } 3202 3152 3203 } 3153 3204 … … 3157 3208 3158 3209 public String getPlaceholder() { 3159 if (_placeholder == null || _placeholder.length() == 0) { 3160 return null; 3161 } 3162 return _placeholder.toString(); 3210 Surrogate surrogate = Surrogate.of(this); 3211 if (surrogate != null && 3212 surrogate.isPropertyIsInherited(DefaultFrameWriter.PLACEHOLDER + "")) { 3213 return ((Text) this.getClassic()).getPlaceholder(); 3214 } else { 3215 if (_placeholder == null || _placeholder.length() == 0) { 3216 return null; 3217 } 3218 return _placeholder.toString(); 3219 } 3163 3220 } 3164 3221 … … 3178 3235 3179 3236 public boolean isSingleLineOnly() { 3180 return _singleLine; 3237 Surrogate surrogate = Surrogate.of(this); 3238 if (surrogate != null && 3239 surrogate.isPropertyIsInherited(DefaultFrameWriter.SINGLE_LINE_ONLY + "")) { 3240 return ((Text) this.getClassic()).isSingleLineOnly(); 3241 } else { 3242 return _singleLine; 3243 } 3181 3244 } 3182 3245 … … 3186 3249 3187 3250 public int getTabIndex() { 3188 return this._tabIndex; 3251 Surrogate surrogate = Surrogate.of(this); 3252 if (surrogate != null && 3253 surrogate.isPropertyIsInherited(DefaultFrameWriter.TAB_INDEX + "")) { 3254 return ((Text) this.getClassic()).getTabIndex(); 3255 } else { 3256 return this._tabIndex; 3257 } 3189 3258 } 3190 3259
Note:
See TracChangeset
for help on using the changeset viewer.