Changeset 720


Ignore:
Timestamp:
01/20/14 11:06:05 (10 years ago)
Author:
davidb
Message:

Introduction of anchorLeft and anchorTop to compliment existing anchorRight and anchorBottom

Location:
trunk/src/org/expeditee
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r707 r720  
    195195                        _Attrib.put("BorderColor",          Item.class.getMethod("getBorderColor"),
    196196                                                            Item.class.getMethod("setBorderColor", pColor));
     197                        _Attrib.put("AnchorLeft",           Item.class.getMethod("getAnchorLeft"),
     198                                                            Item.class.getMethod("setAnchorLeft", pFloatO));
    197199                        _Attrib.put("AnchorRight",          Item.class.getMethod("getAnchorRight"),
    198200                                                            Item.class.getMethod("setAnchorRight", pFloatO));
     201                        _Attrib.put("AnchorTop",            Item.class.getMethod("getAnchorTop"),
     202                                                            Item.class.getMethod("setAnchorTop", pFloatO));
    199203                        _Attrib.put("AnchorBottom",         Item.class.getMethod("getAnchorBottom"),
    200204                                                            Item.class.getMethod("setAnchorBottom", pFloatO));
     
    288292                        _Attrib.alias("s",                  "size");
    289293                        _Attrib.alias("l",                  "link");
     294                        _Attrib.alias("at",                 "anchortop");
    290295                        _Attrib.alias("ab",                 "anchorbottom");
     296                        _Attrib.alias("al",                 "anchorleft");
    291297                        _Attrib.alias("ar",                 "anchorright");
    292298                        _Attrib.alias("t",                  "thickness");
  • trunk/src/org/expeditee/gui/Frame.java

    r717 r720  
    805805                boolean bReparse = false;
    806806                for (Item i : getItems()) {
     807                        Float anchorLeft   = i.getAnchorLeft();
     808                        Float anchorRight  = i.getAnchorRight();
     809                        Float anchorTop    = i.getAnchorTop();
    807810                        Float anchorBottom = i.getAnchorBottom();
    808                         Float anchorRight = i.getAnchorRight();
     811       
     812                       
     813                        if (anchorLeft != null) {
     814                                i.setAnchorLeft(anchorLeft);
     815                                if (i.hasVector()) {
     816                                        bReparse = true;
     817                                }
     818                        }
     819                       
    809820                        if (anchorRight != null) {
    810821                                i.setAnchorRight(anchorRight);
     
    813824                                }
    814825                        }
     826                       
     827                        if (anchorTop != null) {
     828                                i.setAnchorTop(anchorTop);
     829                                if (i.hasVector()) {
     830                                        bReparse = true;
     831                                }
     832                        }
     833                       
    815834                        if (anchorBottom != null) {
    816835                                i.setAnchorBottom(anchorBottom);
  • trunk/src/org/expeditee/io/DefaultFrameReader.java

    r676 r720  
    7777                        _ItemTags.put('K', Item.class.getMethod("setBorderColor",
    7878                                        pColor));
     79
     80                        _ItemTags.put('R', Item.class.getMethod("setAnchorLeft", pFloatO));
    7981                        _ItemTags.put('H', Item.class.getMethod("setAnchorRight", pFloatO));
     82                        _ItemTags.put('N', Item.class.getMethod("setAnchorTop", pFloatO));
    8083                        _ItemTags.put('I', Item.class.getMethod("setAnchorBottom", pFloatO));
     84
    8185                        _ItemTags.put('P', Item.class.getMethod("setPosition", pPoint));
    8286                        _ItemTags.put('F', Item.class.getMethod("setLink", pString));
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r707 r720  
    7171                        _ItemTags.put("G", Item.class.getMethod("getBackgroundColor", param));
    7272                        _ItemTags.put("K", Item.class.getMethod("getBorderColor", param));
     73
     74                        _ItemTags.put("R", Item.class.getMethod("getAnchorLeft", param));
    7375                        _ItemTags.put("H", Item.class.getMethod("getAnchorRight", param));
     76                        _ItemTags.put("N", Item.class.getMethod("getAnchorTop", param));
    7477                        _ItemTags.put("I", Item.class.getMethod("getAnchorBottom", param));
     78
    7579                        _ItemTags.put("P", Item.class.getMethod("getPosition", param));
    7680                        _ItemTags.put("T", Text.class.getMethod("getText", param));
  • trunk/src/org/expeditee/items/Dot.java

    r427 r720  
    6161
    6262        @Override
     63        public void setAnchorTop(Float anchor) {
     64                if (!isLineEnd()) {
     65                        super.setAnchorTop(anchor);
     66                        return;
     67                }
     68                invalidateFill();
     69                invalidateCommonTrait(ItemAppearence.PreMoved);
     70                int oldY = getY();
     71                if (anchor != null) {
     72                        float deltaY = anchor - oldY;
     73                        anchorConnected(AnchorEdgeType.Top, deltaY);
     74                }
     75                this._anchorTop = anchor;
     76                this._anchorBottom = null;
     77                invalidateCommonTrait(ItemAppearence.PostMoved);
     78                invalidateFill();
     79        }
     80
     81        @Override
    6382        public void setAnchorBottom(Float anchor) {
    6483                if (!isLineEnd()) {
     
    7291                        float deltaY = FrameGraphics.getMaxFrameSize().height - anchor
    7392                                        - getBoundsHeight() - oldY;
    74                         anchorConnected(null, deltaY);
     93                        anchorConnected(AnchorEdgeType.Bottom, deltaY);
    7594                }
    7695                this._anchorBottom = anchor;
     96                this._anchorTop = null;
     97                invalidateCommonTrait(ItemAppearence.PostMoved);
     98                invalidateFill();
     99        }
     100
     101
     102        @Override
     103        public void setAnchorLeft(Float anchor) {
     104                if (!isLineEnd()) {
     105                        super.setAnchorLeft(anchor);
     106                        return;
     107                }
     108                invalidateFill();
     109                invalidateCommonTrait(ItemAppearence.PreMoved);
     110                int oldX = getX();
     111                if (anchor != null) {
     112                        float deltaX = anchor - oldX;
     113
     114                        anchorConnected(AnchorEdgeType.Left, deltaX);
     115                }
     116                this._anchorLeft = anchor;
     117                this._anchorRight = null;
     118               
    77119                invalidateCommonTrait(ItemAppearence.PostMoved);
    78120                invalidateFill();
     
    92134                                        - getBoundsWidth() - oldX;
    93135
    94                         anchorConnected(deltaX, null);
     136                        anchorConnected(AnchorEdgeType.Right, deltaX);
    95137                }
    96138                this._anchorRight = anchor;
     139                this._anchorLeft = null;
    97140                invalidateCommonTrait(ItemAppearence.PostMoved);
    98141                invalidateFill();
  • trunk/src/org/expeditee/items/Item.java

    r711 r720  
    164164        private static Item _tooltipOwner = null;
    165165
     166        public enum AnchorEdgeType {
     167                None, Left, Right, Top, Bottom
     168        }
     169
    166170        public static void DuplicateItem(Item source, Item dest) {
    167171                dest.setX(source.getX());
     
    212216                 * the user uses backspace to delete a text line end
    213217                 */
     218                // dest._anchorLeft = source._anchorLeft;
     219                // dest._anchorRight = source._anchorRight;
     220                // dest._anchorTop = source._anchorTop;
    214221                // dest._anchorBottom = source._anchorBottom;
    215                 // dest._anchorRight = source._anchorRight;
    216222                dest.setFormula(source.getFormula());
    217223                dest._overlay = source._overlay;
     
    276282        }
    277283
     284        protected Float _anchorLeft = null;
    278285        protected Float _anchorRight = null;
    279286
     287        protected Float _anchorTop = null;
    280288        protected Float _anchorBottom = null;
    281289
     
    285293
    286294        protected float _x;
    287 
    288295        protected float _y;
    289296
     
    28242831        }
    28252832
     2833        public void setAnchorLeft(Float anchor) {
     2834                this._anchorLeft = anchor;
     2835                this._anchorRight = null;
     2836                if (anchor != null) {
     2837                    setX(anchor);
     2838                }
     2839        }
     2840
    28262841        public void setAnchorRight(Float anchor) {
    28272842                this._anchorRight = anchor;
     2843                this._anchorLeft = null;
    28282844                if (anchor != null)
    28292845                        setX(FrameGraphics.getMaxFrameSize().width - anchor
     
    28312847        }
    28322848
     2849        public void setAnchorTop(Float anchor) {
     2850                this._anchorTop = anchor;
     2851                this._anchorBottom = null;
     2852                if (anchor != null)
     2853                        setY(anchor);
     2854        }
     2855
     2856
     2857        public void setAnchorBottom(Float anchor) {
     2858                this._anchorBottom = anchor;
     2859                this._anchorTop = null;
     2860                if (anchor != null)
     2861                        setY(FrameGraphics.getMaxFrameSize().height - anchor);
     2862        }
     2863
     2864
     2865        public Float getAnchorLeft() {
     2866                return _anchorLeft;
     2867        }
     2868
    28332869        public Float getAnchorRight() {
    28342870                return _anchorRight;
    28352871        }
    28362872
    2837         public void setAnchorBottom(Float anchor) {
    2838                 this._anchorBottom = anchor;
    2839                 if (anchor != null)
    2840                         setY(FrameGraphics.getMaxFrameSize().height - anchor);
     2873        public Float getAnchorTop() {
     2874                return _anchorTop;
    28412875        }
    28422876
     
    28982932        }
    28992933
    2900         protected void anchorConnected(Float deltaX, Float deltaY) {
     2934        protected void anchorConnectedRefactored(AnchorEdgeType anchorEdgeType, Float delta) {
    29012935                // Check for a more efficient way to do this!!
    29022936                // Invalidate all the items
     
    29072941                for (Item i : this.getAllConnected()) {
    29082942                        if (i.isLineEnd()) {
    2909                                 if (deltaX != null) {
    2910                                         i.setAnchorRight(null);
    2911                                         i.setXY(i.getX() + deltaX, i.getY());
    2912                                 }
    2913                                 if (deltaY != null) {
    2914                                         i.setAnchorBottom(null);
    2915                                         i.setXY(i.getX(), i.getY() + deltaY);
     2943                                if (delta != null) {
     2944                                        if ((anchorEdgeType == AnchorEdgeType.Left) || (anchorEdgeType == AnchorEdgeType.Right)) {
     2945                                                // 'delta' encodes a horizontal (x) move
     2946                                                if (anchorEdgeType == AnchorEdgeType.Left) {
     2947                                                        i.setAnchorLeft(null);
     2948                                                }
     2949                                                else {
     2950                                                        // must be Right
     2951                                                        i.setAnchorRight(null);
     2952                                                }
     2953                                               
     2954                                                i.setXY(i.getX() + delta, i.getY());
     2955                                        }
     2956                                        if ((anchorEdgeType == AnchorEdgeType.Top) || (anchorEdgeType == AnchorEdgeType.Bottom)) {
     2957                                                // 'delta; encodes a vertical (y) move
     2958                                                if (anchorEdgeType == AnchorEdgeType.Top) {
     2959                                                        i.setAnchorTop(null);
     2960                                                }
     2961                                                else {
     2962                                                        // must be Bottom
     2963                                                        i.setAnchorBottom(null);
     2964                                                }
     2965                                                i.setXY(i.getX(), i.getY() + delta);
     2966                                        }
     2967                                       
    29162968                                }
    29172969                        }
     
    29242976        }
    29252977
     2978       
     2979        protected void anchorConnected(AnchorEdgeType anchorEdgeType, Float delta) {
     2980                // Check for a more efficient way to do this!!
     2981                // Invalidate all the items
     2982                for (Item i : this.getAllConnected()) {
     2983                        i.invalidateAll();
     2984                }
     2985               
     2986                // Move the items
     2987                for (Item i : this.getAllConnected()) {
     2988                        if (i.isLineEnd()) {
     2989                                if (delta != null) {
     2990                                        if ((anchorEdgeType == AnchorEdgeType.Left) || (anchorEdgeType == AnchorEdgeType.Right)) {
     2991                                                // 'delta' encodes a horizontal (x) move
     2992                                                if (anchorEdgeType == AnchorEdgeType.Left) {
     2993                                                        // Processing a Left anchor
     2994                                                        // => Anything connected that is *not* anchored to the right should be moved by 'delta'
     2995                                                        if (i.getAnchorRight()==null) {
     2996                                                                i.setXY(i.getX() + delta, i.getY());
     2997                                                        }
     2998                                                }
     2999                                                else {
     3000                                                        // Processing a Right anchor
     3001                                                        // => Anything connected that is *not* anchored to the left should be moved by 'delta'
     3002                                                        if (i.getAnchorLeft()==null) {
     3003                                                                i.setXY(i.getX() + delta, i.getY());
     3004                                                        }
     3005                                                }
     3006
     3007                                        }
     3008                                        if ((anchorEdgeType == AnchorEdgeType.Top) || (anchorEdgeType == AnchorEdgeType.Bottom)) {
     3009                                                // 'delta; encodes a vertical (y) move
     3010                                                if (anchorEdgeType == AnchorEdgeType.Top) {
     3011                                                        // Processing a Top anchor
     3012                                                        // => Anything connected that is *not* anchored to the bottom should be moved by 'delta'
     3013                                                        if (i.getAnchorBottom()==null) {
     3014                                                                i.setXY(i.getX(), i.getY() + delta);
     3015                                                        }
     3016                                                }
     3017                                                else {
     3018                                                        // Processing a Bottom anchor
     3019                                                        // => Anything connected that is *not* anchored to the top should be moved by 'delta'
     3020                                                        if (i.getAnchorTop()==null) {
     3021                                                        // must be Bottom
     3022                                                        i.setAnchorBottom(null);
     3023                                                        }
     3024                                                }
     3025                                        }               
     3026                                }
     3027                        }
     3028                }
     3029               
     3030                // Invalidate them again!!
     3031                for (Item i : this.getAllConnected()) {
     3032                        i.updatePolygon();
     3033                        i.invalidateAll();
     3034                }
     3035        }
    29263036        /**
    29273037         * Sets the item to pickup when the user attempts to pick this item up.
  • trunk/src/org/expeditee/items/Text.java

    r669 r720  
    23972397
    23982398        @Override
     2399        public void setAnchorLeft(Float anchor) {
     2400                if (!isLineEnd()) {
     2401                        super.setAnchorLeft(anchor);
     2402                        // Subtract off the link width
     2403                        if (anchor != null) {
     2404                                setX(anchor + getLeftMargin());
     2405                        }
     2406                        return;
     2407                }
     2408                invalidateFill();
     2409                invalidateCommonTrait(ItemAppearence.PreMoved);
     2410                int oldX = getX();
     2411                if (anchor != null) {
     2412                        float deltaX = anchor + getLeftMargin() - oldX;
     2413                        anchorConnected(AnchorEdgeType.Left, deltaX);
     2414                }
     2415                this._anchorLeft = anchor;
     2416                this._anchorRight = null;
     2417                invalidateCommonTrait(ItemAppearence.PostMoved);
     2418                invalidateFill();
     2419        }
     2420
     2421        @Override
    23992422        public void setAnchorRight(Float anchor) {
    24002423                if (!isLineEnd()) {
     
    24132436                        float deltaX = FrameGraphics.getMaxFrameSize().width - anchor
    24142437                                        - getBoundsWidth() + getLeftMargin() - oldX;
    2415                         anchorConnected(deltaX, null);
     2438                        anchorConnected(AnchorEdgeType.Right, deltaX);
    24162439                }
    24172440                this._anchorRight = anchor;
     2441                this._anchorLeft = null;
     2442                invalidateCommonTrait(ItemAppearence.PostMoved);
     2443                invalidateFill();
     2444        }
     2445
     2446
     2447
     2448        @Override
     2449        public void setAnchorTop(Float anchor) {
     2450                if (!isLineEnd()) {
     2451                        super.setAnchorTop(anchor);
     2452                        if (anchor != null) {
     2453                                setY(anchor + getBoundsHeight());
     2454                        }
     2455                        return;
     2456                }
     2457                invalidateFill();
     2458                invalidateCommonTrait(ItemAppearence.PreMoved);
     2459                int oldY = getY();
     2460                if (anchor != null) {
     2461                        float deltaY = anchor - oldY;
     2462                        anchorConnected(AnchorEdgeType.Top, deltaY);
     2463                }
     2464                this._anchorTop = anchor;
     2465                this._anchorBottom = null;
    24182466                invalidateCommonTrait(ItemAppearence.PostMoved);
    24192467                invalidateFill();
     
    24302478                int oldY = getY();
    24312479                if (anchor != null) {
     2480
    24322481                        float deltaY = FrameGraphics.getMaxFrameSize().height - anchor
    24332482                                        - oldY;
    2434                         anchorConnected(null, deltaY);
     2483                        anchorConnected(AnchorEdgeType.Bottom, deltaY);
    24352484                }
    24362485                this._anchorBottom = anchor;
     2486                this._anchorTop = null;
    24372487                invalidateCommonTrait(ItemAppearence.PostMoved);
    24382488                invalidateFill();
  • trunk/src/org/expeditee/items/XRayable.java

    r707 r720  
    135135       
    136136        @Override
     137        public Float getAnchorLeft() {
     138                return _source.getAnchorLeft();
     139        }
     140       
     141        @Override
     142        public Float getAnchorRight() {
     143                return _source.getAnchorRight();
     144        }
     145
     146        @Override
     147        public Float getAnchorTop() {
     148                return _source.getAnchorTop();
     149        }
     150
     151        @Override
    137152        public Float getAnchorBottom() {
    138153                return _source.getAnchorBottom();
    139154        }
    140155       
    141         @Override
    142         public Float getAnchorRight() {
    143                 return _source.getAnchorRight();
    144         }
    145156       
    146157        @Override
     
    235246       
    236247        @Override
     248        public void setAnchorTop(Float anchor) {
     249                _source.setAnchorTop(anchor);
     250                if (anchor != null)
     251                        _source.setY(anchor + getHeight());
     252        }
     253
     254        @Override
    237255        public void setAnchorBottom(Float anchor) {
    238256                _source.setAnchorBottom(anchor);
     
    240258                        _source.setY(FrameGraphics.getMaxFrameSize().height - getHeight() - anchor);
    241259        }
    242        
     260
     261       
     262        @Override
     263        public void setAnchorLeft(Float anchor) {
     264                _source.setAnchorLeft(anchor);
     265        }
     266
    243267        @Override
    244268        public void setAnchorRight(Float anchor) {
  • trunk/src/org/expeditee/items/widgets/InteractiveWidget.java

    r626 r720  
    17051705        }
    17061706
     1707        public void setAnchorTop(Float anchor) {
     1708                setPosition(getX(),Math.round(anchor));
     1709                getSource().setAnchorTop(anchor);
     1710        }
     1711
    17071712        public void setAnchorBottom(Float anchor) {
    17081713                setPosition(getX(),
    1709                                 Math.round(FrameGraphics.getMaxFrameSize().height - anchor - getHeight()));
     1714                            Math.round(FrameGraphics.getMaxFrameSize().height - anchor - getHeight()));
    17101715                getSource().setAnchorBottom(anchor);
    17111716        }
    17121717
     1718        public void setAnchorLeft(Float anchor) {
     1719                setPosition(Math.round(anchor),
     1720                            getY());
     1721                getSource().setAnchorLeft(anchor);
     1722        }
     1723
    17131724        public void setAnchorRight(Float anchor) {
    1714                 setPosition(
    1715                                 Math.round(FrameGraphics.getMaxFrameSize().width - anchor - getWidth()),
    1716                                 getY());
     1725                setPosition(Math.round(FrameGraphics.getMaxFrameSize().width - anchor - getWidth()),
     1726                            getY());
    17171727                getSource().setAnchorRight(anchor);
    17181728        }
  • trunk/src/org/expeditee/items/widgets/WidgetCorner.java

    r474 r720  
    150150
    151151        @Override
     152        public void setAnchorTop(Float anchor) {
     153                _widgetSource.setAnchorTop(anchor);
     154        }
     155
     156        @Override
    152157        public void setAnchorBottom(Float anchor) {
    153158                _widgetSource.setAnchorBottom(anchor);
     
    155160
    156161        @Override
     162        public void setAnchorLeft(Float anchor) {
     163                _widgetSource.setAnchorLeft(anchor);
     164        }
     165
     166        @Override
    157167        public void setAnchorRight(Float anchor) {
    158168                _widgetSource.setAnchorRight(anchor);
     
    160170
    161171        @Override
     172        public Float getAnchorTop() {
     173                return _widgetSource.getSource().getAnchorTop();
     174        }
     175
     176        @Override
    162177        public Float getAnchorBottom() {
    163178                return _widgetSource.getSource().getAnchorBottom();
     179        }
     180
     181        @Override
     182        public Float getAnchorLeft() {
     183                return _widgetSource.getSource().getAnchorLeft();
    164184        }
    165185
  • trunk/src/org/expeditee/items/widgets/WidgetEdge.java

    r474 r720  
    103103       
    104104        @Override
     105        public void setAnchorTop(Float anchor) {
     106                _widgetSource.setAnchorTop(anchor);
     107        }
     108
     109        @Override
    105110        public void setAnchorBottom(Float anchor) {
    106111                _widgetSource.setAnchorBottom(anchor);
     
    108113
    109114        @Override
     115        public void setAnchorLeft(Float anchor) {
     116                _widgetSource.setAnchorLeft(anchor);
     117        }
     118
     119        @Override
    110120        public void setAnchorRight(Float anchor) {
    111121                _widgetSource.setAnchorRight(anchor);
     
    113123       
    114124        @Override
     125        public Float getAnchorTop() {
     126                return _widgetSource.getSource().getAnchorTop();
     127        }
     128
     129        @Override
    115130        public Float getAnchorBottom() {
    116131                return _widgetSource.getSource().getAnchorBottom();
    117132        }
    118133       
     134        @Override
     135        public Float getAnchorLeft() {
     136                return _widgetSource.getSource().getAnchorLeft();
     137        }
     138
    119139        @Override
    120140        public Float getAnchorRight() {
Note: See TracChangeset for help on using the changeset viewer.