Ignore:
Timestamp:
06/25/19 13:57:37 (5 years ago)
Author:
bln4
Message:

Changed surrogates to work the way discussed with David. EncryptedExpReader/Writer updated to work with this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Text.java

    r1410 r1413  
    4141import org.expeditee.core.bounds.AxisAlignedBoxBounds;
    4242import org.expeditee.core.bounds.PolygonBounds;
    43 import org.expeditee.encryption.items.surrogates.Surrogate;
     43import org.expeditee.encryption.items.surrogates.EncryptionDetail;
    4444import org.expeditee.gio.EcosystemManager;
    4545import org.expeditee.gio.GraphicsManager;
     
    404404                rebuild(true);
    405405                invalidateAll();
     406               
     407                if (isSurrogate()) {
     408                        surrogatePropertyInheritance.put(DefaultFrameWriter.WIDTH_TO_SAVE_STR, false);
     409                        Item classic = getClassic();
     410                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.WIDTH_TO_SAVE_STR)) {
     411                                classic.classicPropertyEncryption.put(DefaultFrameWriter.WIDTH_TO_SAVE_STR, EncryptionDetail.InheritanceCheckOnSave);
     412                        }
     413                }
    406414        }
    407415
     
    419427                rebuild(true);
    420428                invalidateAll();
     429               
     430                if (isSurrogate()) {
     431                        surrogatePropertyInheritance.put(DefaultFrameWriter.MIN_WIDTH_TO_SAVE_STR, false);
     432                        Item classic = getClassic();
     433                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.MIN_WIDTH_TO_SAVE_STR)) {
     434                                classic.classicPropertyEncryption.put(DefaultFrameWriter.MIN_WIDTH_TO_SAVE_STR, EncryptionDetail.InheritanceCheckOnSave);
     435                        }
     436                }
    421437        }
    422438
     
    434450        @Override
    435451        public Integer getWidth() {
    436                 if (_width == null || _width <= 0) {
    437                         return null;
    438                 }
    439 
    440                 return _width;
     452                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.WIDTH_TO_SAVE_STR)) {
     453                        return this.getClassic().getWidth();
     454                } else {
     455                        return _width;
     456                }
    441457        }
    442458
     
    450466
    451467        public Integer getMinWidth() {
    452                 if (_minWidth == null || _minWidth <= 0) {
    453                         return null;
    454                 }
    455                 return _minWidth;
     468                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MIN_WIDTH_TO_SAVE_STR)) {
     469                        return this.getClassic().getMinWidth();
     470                } else {
     471                        return _minWidth;
     472                }
    456473        }
    457474
     
    465482        @Override
    466483        public Colour getHighlightColor() {
    467                 if (_highlightColour.equals(getPaintBackgroundColor())) {
    468                         return ALTERNATE_HIGHLIGHT;
    469                 }
    470                 return _highlightColour;
     484                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.HIGHLIGHT_STR)) {
     485                        return this.getClassic().getHighlightColor();
     486                } else {
     487                        return _highlightColour;
     488                }
    471489        }
    472490
     
    490508                rebuild(true);
    491509                invalidateAll();
     510               
     511                if (isSurrogate()) {
     512                        surrogatePropertyInheritance.put(DefaultFrameWriter.JUSTIFICATION_STR, false);
     513                        Item classic = getClassic();
     514                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.JUSTIFICATION_STR)) {
     515                                classic.classicPropertyEncryption.put(DefaultFrameWriter.JUSTIFICATION_STR, EncryptionDetail.InheritanceCheckOnSave);
     516                        }
     517                }
    492518        }
    493519
     
    501527         */
    502528        public Justification getJustification() {
    503                 Surrogate surrogate = Surrogate.of(this);
    504                 if (surrogate != null &&
    505                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.JUSTIFICATION + "")) {
     529                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.JUSTIFICATION_STR)) {
    506530                        return ((Text) this.getClassic()).getJustification();
    507531                } else {
     
    665689
    666690                rebuild(true);
     691               
     692                if (isSurrogate()) {
     693                        surrogatePropertyInheritance.put(DefaultFrameWriter.TEXT_STR, false);
     694                        Item classic = getClassic();
     695                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.TEXT_STR)) {
     696                                classic.classicPropertyEncryption.put(DefaultFrameWriter.TEXT_STR, EncryptionDetail.InheritanceCheckOnSave);
     697                        }
     698                }
    667699        }
    668700
     
    12951327
    12961328                invalidateAll();
     1329               
     1330                if (isSurrogate()) {
     1331                        surrogatePropertyInheritance.put(DefaultFrameWriter.FONT_STR, false);
     1332                        Item classic = getClassic();
     1333                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.FONT_STR)) {
     1334                                classic.classicPropertyEncryption.put(DefaultFrameWriter.FONT_STR, EncryptionDetail.InheritanceCheckOnSave);
     1335                        }
     1336                }
    12971337        }
    12981338
     
    13031343         */
    13041344        public Font getFont() {
    1305                 Surrogate surrogate = Surrogate.of(this);
    1306                 if (surrogate != null &&
    1307                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.FONT + "")) {
     1345                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.FONT_STR)) {
    13081346                        return ((Text) this.getClassic()).getFont();
    13091347                } else {
     
    14691507        @Override
    14701508        public String getText() {
    1471                 return _text.toString();
     1509                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.TEXT_STR)) {
     1510                        return this.getClassic().getText();
     1511                } else {
     1512                        return _text.toString();
     1513                }
    14721514        }
    14731515
     
    15071549                _spacing = spacing;
    15081550                invalidateBounds();
     1551               
     1552                if (isSurrogate()) {
     1553                        surrogatePropertyInheritance.put(DefaultFrameWriter.SPACING_STR, false);
     1554                        Item classic = getClassic();
     1555                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.SPACING_STR)) {
     1556                                classic.classicPropertyEncryption.put(DefaultFrameWriter.SPACING_STR, EncryptionDetail.InheritanceCheckOnSave);
     1557                        }
     1558                }
    15091559        }
    15101560
     
    15151565         */
    15161566        public float getSpacing() {
    1517                 Surrogate surrogate = Surrogate.of(this);
    1518                 if (surrogate != null &&
    1519                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.SPACING + "")) {
     1567                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.SPACING_STR)) {
    15201568                        return ((Text) this.getClassic()).getSpacing();
    15211569                } else {
     
    15421590        public void setWordSpacing(int spacing) {
    15431591                _word_spacing = spacing;
     1592               
     1593                if (isSurrogate()) {
     1594                        surrogatePropertyInheritance.put(DefaultFrameWriter.WORD_SPACING_STR, false);
     1595                        Item classic = getClassic();
     1596                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.WORD_SPACING_STR)) {
     1597                                classic.classicPropertyEncryption.put(DefaultFrameWriter.WORD_SPACING_STR, EncryptionDetail.InheritanceCheckOnSave);
     1598                        }
     1599                }
    15441600        }
    15451601
    15461602        public int getWordSpacing() {
    1547                 Surrogate surrogate = Surrogate.of(this);
    1548                 if (surrogate != null &&
    1549                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.WORD_SPACING + "")) {
     1603                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.WORD_SPACING_STR)) {
    15501604                        return ((Text) this.getClassic()).getWordSpacing();
    15511605                } else {
     
    15671621                currentFont.setSpacing(spacing);
    15681622                // setFont(currentFont);
     1623               
     1624                if (isSurrogate()) {
     1625                        surrogatePropertyInheritance.put(DefaultFrameWriter.LETTER_SPACING_STR, false);
     1626                        Item classic = getClassic();
     1627                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LETTER_SPACING_STR)) {
     1628                                classic.classicPropertyEncryption.put(DefaultFrameWriter.LETTER_SPACING_STR, EncryptionDetail.InheritanceCheckOnSave);
     1629                        }
     1630                }
    15691631        }
    15701632
     
    15741636         */
    15751637        public float getLetterSpacing() {
    1576                 Surrogate surrogate = Surrogate.of(this);
    1577                 if (surrogate != null &&
    1578                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.LETTER_SPACING + "")) {
     1638                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LETTER_SPACING_STR)) {
    15791639                        return ((Text) this.getClassic()).getLetterSpacing();
    15801640                } else {
     
    15851645        public void setInitialSpacing(float spacing) {
    15861646                _initial_spacing = spacing;
     1647               
     1648                if (isSurrogate()) {
     1649                        surrogatePropertyInheritance.put(DefaultFrameWriter.INITIAL_SPACING_STR, false);
     1650                        Item classic = getClassic();
     1651                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.INITIAL_SPACING_STR)) {
     1652                                classic.classicPropertyEncryption.put(DefaultFrameWriter.INITIAL_SPACING_STR, EncryptionDetail.InheritanceCheckOnSave);
     1653                        }
     1654                }
    15871655        }
    15881656
    15891657        public float getInitialSpacing() {
    1590                 Surrogate surrogate = Surrogate.of(this);
    1591                 if (surrogate != null &&
    1592                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.INITIAL_SPACING + "")) {
     1658                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.INITIAL_SPACING_STR)) {
    15931659                        return ((Text) this.getClassic()).getInitialSpacing();
    15941660                } else {
     
    27952861                invalidateCommonTrait(ItemAppearence.PostMoved);
    27962862                invalidateFill();
     2863               
     2864                if (isSurrogate()) {
     2865                        surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_LEFT_STR, false);
     2866                        Item classic = getClassic();
     2867                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_LEFT_STR)) {
     2868                                classic.classicPropertyEncryption.put(DefaultFrameWriter.ANCHOR_LEFT_STR, EncryptionDetail.InheritanceCheckOnSave);
     2869                        }
     2870                }
    27972871        }
    27982872
     
    28212895                invalidateCommonTrait(ItemAppearence.PostMoved);
    28222896                invalidateFill();
     2897               
     2898                if (isSurrogate()) {
     2899                        surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_RIGHT_STR, false);
     2900                        Item classic = getClassic();
     2901                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_RIGHT_STR)) {
     2902                                classic.classicPropertyEncryption.put(DefaultFrameWriter.ANCHOR_RIGHT_STR, EncryptionDetail.InheritanceCheckOnSave);
     2903                        }
     2904                }
    28232905        }
    28242906
     
    28542936                invalidateCommonTrait(ItemAppearence.PostMoved);
    28552937                invalidateFill();
     2938               
     2939                if (isSurrogate()) {
     2940                        surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_TOP_STR, false);
     2941                        Item classic = getClassic();
     2942                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_TOP_STR)) {
     2943                                classic.classicPropertyEncryption.put(DefaultFrameWriter.ANCHOR_TOP_STR, EncryptionDetail.InheritanceCheckOnSave);
     2944                        }
     2945                }
    28562946        }
    28572947
     
    28922982                invalidateCommonTrait(ItemAppearence.PostMoved);
    28932983                invalidateFill();
     2984               
     2985                if (isSurrogate()) {
     2986                        surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_BOTTOM_STR, false);
     2987                        Item classic = getClassic();
     2988                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_BOTTOM_STR)) {
     2989                                classic.classicPropertyEncryption.put(DefaultFrameWriter.ANCHOR_BOTTOM_STR, EncryptionDetail.InheritanceCheckOnSave);
     2990                        }
     2991                }
    28942992        }
    28952993
     
    30473145
    30483146        public boolean getAutoWrap() {
    3049                 Surrogate surrogate = Surrogate.of(this);
    3050                 if (surrogate != null &&
    3051                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.AUTO_WRAP_TO_SAVE + "")) {
     3147                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.AUTO_WRAP_TO_SAVE_STR)) {
    30523148                        return ((Text) this.getClassic()).getAutoWrap();
    30533149                } else {
     
    30593155        // normally
    30603156        public String getAutoWrapToSave() {
    3061                 if (!_autoWrap) {
     3157                if (!getAutoWrap()) {
    30623158                        return null;
    30633159                }
     
    30673163        public void setAutoWrap(boolean autoWrap) {
    30683164                _autoWrap = autoWrap;
     3165               
     3166                if (isSurrogate()) {
     3167                        surrogatePropertyInheritance.put(DefaultFrameWriter.AUTO_WRAP_TO_SAVE_STR, false);
     3168                        Item classic = getClassic();
     3169                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.AUTO_WRAP_TO_SAVE_STR)) {
     3170                                classic.classicPropertyEncryption.put(DefaultFrameWriter.AUTO_WRAP_TO_SAVE_STR, EncryptionDetail.InheritanceCheckOnSave);
     3171                        }
     3172                }
    30693173        }
    30703174
     
    31893293
    31903294        public Integer getMask() {
    3191                 Surrogate surrogate = Surrogate.of(this);
    3192                 if (surrogate != null &&
    3193                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.MASK + "")) {
     3295                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MASK_STR)) {
    31943296                        return ((Text) this.getClassic()).getMask();
    31953297                } else {
    3196                         if (_mask == null) {
    3197                                 return null;
    3198                         } else {
    3199                                 return _mask;
    3200                         }
    3201                 }
    3202 
     3298                        return _mask;
     3299                }
    32033300        }
    32043301
    32053302        public void setMask(final Integer c) {
    32063303                _mask = c;
     3304               
     3305                if (isSurrogate()) {
     3306                        surrogatePropertyInheritance.put(DefaultFrameWriter.MASK_STR, false);
     3307                        Item classic = getClassic();
     3308                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.MASK_STR)) {
     3309                                classic.classicPropertyEncryption.put(DefaultFrameWriter.MASK_STR, EncryptionDetail.InheritanceCheckOnSave);
     3310                        }
     3311                }
    32073312        }
    32083313       
    32093314        public String getPlaceholder() {
    3210                 Surrogate surrogate = Surrogate.of(this);
    3211                 if (surrogate != null &&
    3212                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.PLACEHOLDER + "")) {
     3315                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.PLACEHOLDER_STR)) {
    32133316                        return ((Text) this.getClassic()).getPlaceholder();
    32143317                } else {
     
    32223325        public void setPlaceholder(String _placeholder) {
    32233326                this._placeholder = new StringBuffer(_placeholder);
     3327               
     3328                if (isSurrogate()) {
     3329                        surrogatePropertyInheritance.put(DefaultFrameWriter.PLACEHOLDER_STR, false);
     3330                        Item classic = getClassic();
     3331                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.PLACEHOLDER_STR)) {
     3332                                classic.classicPropertyEncryption.put(DefaultFrameWriter.PLACEHOLDER_STR, EncryptionDetail.InheritanceCheckOnSave);
     3333                        }
     3334                }
    32243335        }
    32253336
     
    32353346
    32363347        public boolean isSingleLineOnly() {
    3237                 Surrogate surrogate = Surrogate.of(this);
    3238                 if (surrogate != null &&
    3239                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.SINGLE_LINE_ONLY + "")) {
     3348                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.SINGLE_LINE_ONLY_STR)) {
    32403349                        return ((Text) this.getClassic()).isSingleLineOnly();
    32413350                } else {
     
    32463355        public void setSingleLineOnly(boolean _singleLine) {
    32473356                this._singleLine = _singleLine;
     3357               
     3358                if (isSurrogate()) {
     3359                        surrogatePropertyInheritance.put(DefaultFrameWriter.SINGLE_LINE_ONLY_STR, false);
     3360                        Item classic = getClassic();
     3361                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.SINGLE_LINE_ONLY_STR)) {
     3362                                classic.classicPropertyEncryption.put(DefaultFrameWriter.SINGLE_LINE_ONLY_STR, EncryptionDetail.InheritanceCheckOnSave);
     3363                        }
     3364                }
    32483365        }
    32493366       
    32503367        public int getTabIndex() {
    3251                 Surrogate surrogate = Surrogate.of(this);
    3252                 if (surrogate != null &&
    3253                                 surrogate.isPropertyIsInherited(DefaultFrameWriter.TAB_INDEX + "")) {
     3368                if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.TAB_INDEX_STR)) {
    32543369                        return ((Text) this.getClassic()).getTabIndex();
    32553370                } else {
     
    32603375        public void setTabIndex(int index) {
    32613376                this._tabIndex = index;
     3377               
     3378                if (isSurrogate()) {
     3379                        surrogatePropertyInheritance.put(DefaultFrameWriter.TAB_INDEX_STR, false);
     3380                        Item classic = getClassic();
     3381                        if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.TAB_INDEX_STR)) {
     3382                                classic.classicPropertyEncryption.put(DefaultFrameWriter.TAB_INDEX_STR, EncryptionDetail.InheritanceCheckOnSave);
     3383                        }
     3384                }
    32623385        }
    32633386       
Note: See TracChangeset for help on using the changeset viewer.