Changeset 812


Ignore:
Timestamp:
02/03/14 13:46:41 (10 years ago)
Author:
davidb
Message:

When setting an anchor left/rightr/top/bottom on a Dot, it now looks for connected items that are constrained to the the same x (vertical) or y (horizontal) value, and sets the anchor status of that item to be the same.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Misc.java

    r805 r812  
    12271227                        }
    12281228                        else {
    1229                             int new_x = i.getX();
    1230                             int new_y = i.getY();
    1231 
    1232                             if (!i.isAnchoredX()) {
    1233                                 new_x += x;
    1234                             }
    1235 
    1236                             if (!i.isAnchoredY()) {
    1237                                 new_y += y;
    1238                             }
    1239 
    1240 
    1241 
    1242                             if ((new_x != x) || (new_y != y)) {
     1229                                int new_x = i.getX();
     1230                                int new_y = i.getY();
     1231
     1232                                if (!i.isAnchoredX()) {
     1233                                        new_x += x;
     1234                                }
     1235
     1236                                if (!i.isAnchoredY()) {
     1237                                        new_y += y;
     1238                                }
    12431239
    12441240                                if(i instanceof XRayable) {
    1245 
    1246                                     i.setPosition(new_x,new_y);
     1241                                        i.setPosition(new_x,new_y);
    12471242                                }
    1248 
    12491243                                else {
    1250                                     i.setXY(new_x,new_y);
     1244                                        i.setXY(new_x,new_y);
    12511245                                }
    1252                             }
    12531246                        }
    12541247                        // update the polygon, otherwise stuff moves but leaves it's outline behind
     
    12581251                for (InteractiveWidget iw : frame.getInteractiveWidgets()) {
    12591252
    1260                     int new_x = iw.getX();
    1261                     int new_y = iw.getY();
    1262                    
    1263                     if (!iw.isAnchoredX()) {
    1264                         new_x += x;
    1265                     }
    1266                    
    1267                     if (!iw.isAnchoredY()) {
    1268                         new_y += y;
    1269                     }
    1270                    
    1271                    
    1272                     if ((new_x != x) || (new_y != y)) {
    1273                        
     1253                        int new_x = iw.getX();
     1254                        int new_y = iw.getY();
     1255
     1256                        if (!iw.isAnchoredX()) {
     1257                                new_x += x;
     1258                        }
     1259
     1260                        if (!iw.isAnchoredY()) {
     1261                                new_y += y;
     1262                        }
     1263
    12741264                        iw.setPosition(new_x,new_y);
    1275                     }
     1265       
    12761266                }
    12771267
  • trunk/src/org/expeditee/items/Dot.java

    r720 r812  
    6161
    6262        @Override
     63        public void setAnchorLeft(Float anchor) {
     64                if (!isLineEnd()) {
     65                        super.setAnchorLeft(anchor);
     66                        return;
     67                }
     68               
     69                invalidateFill();
     70                invalidateCommonTrait(ItemAppearence.PreMoved);
     71               
     72                this._anchorLeft = anchor;
     73                this._anchorRight = null;
     74               
     75                int oldX = getX();
     76                if (anchor != null) {
     77                        float deltaX = anchor - oldX;
     78                        anchorConnected(AnchorEdgeType.Left, deltaX);
     79                }
     80               
     81                invalidateCommonTrait(ItemAppearence.PostMoved);
     82                invalidateFill();
     83        }
     84
     85        @Override
     86        public void setAnchorRight(Float anchor) {
     87                if (!isLineEnd()) {
     88                        super.setAnchorRight(anchor);
     89                        return;
     90                }
     91                invalidateFill();
     92                invalidateCommonTrait(ItemAppearence.PreMoved);
     93               
     94                this._anchorRight = anchor;
     95                this._anchorLeft = null;
     96               
     97                int oldX = getX();
     98                if (anchor != null) {
     99                        float deltaX = FrameGraphics.getMaxFrameSize().width - anchor
     100                                        - getBoundsWidth() - oldX;
     101
     102                        anchorConnected(AnchorEdgeType.Right, deltaX);
     103                }
     104       
     105                invalidateCommonTrait(ItemAppearence.PostMoved);
     106                invalidateFill();
     107        }
     108
     109        @Override
    63110        public void setAnchorTop(Float anchor) {
    64111                if (!isLineEnd()) {
     
    68115                invalidateFill();
    69116                invalidateCommonTrait(ItemAppearence.PreMoved);
     117               
     118                this._anchorTop = anchor;
     119                this._anchorBottom = null;
     120               
    70121                int oldY = getY();
    71122                if (anchor != null) {
     
    73124                        anchorConnected(AnchorEdgeType.Top, deltaY);
    74125                }
    75                 this._anchorTop = anchor;
    76                 this._anchorBottom = null;
     126
    77127                invalidateCommonTrait(ItemAppearence.PostMoved);
    78128                invalidateFill();
     
    87137                invalidateFill();
    88138                invalidateCommonTrait(ItemAppearence.PreMoved);
     139               
     140                this._anchorBottom = anchor;
     141                this._anchorTop = null;
     142               
    89143                int oldY = getY();
    90144                if (anchor != null) {
     
    93147                        anchorConnected(AnchorEdgeType.Bottom, deltaY);
    94148                }
    95                 this._anchorBottom = anchor;
    96                 this._anchorTop = null;
     149
    97150                invalidateCommonTrait(ItemAppearence.PostMoved);
    98151                invalidateFill();
     
    100153
    101154
    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                
    119                 invalidateCommonTrait(ItemAppearence.PostMoved);
    120                 invalidateFill();
    121         }
    122 
    123         @Override
    124         public void setAnchorRight(Float anchor) {
    125                 if (!isLineEnd()) {
    126                         super.setAnchorRight(anchor);
    127                         return;
    128                 }
    129                 invalidateFill();
    130                 invalidateCommonTrait(ItemAppearence.PreMoved);
    131                 int oldX = getX();
    132                 if (anchor != null) {
    133                         float deltaX = FrameGraphics.getMaxFrameSize().width - anchor
    134                                         - getBoundsWidth() - oldX;
    135 
    136                         anchorConnected(AnchorEdgeType.Right, deltaX);
    137                 }
    138                 this._anchorRight = anchor;
    139                 this._anchorLeft = null;
    140                 invalidateCommonTrait(ItemAppearence.PostMoved);
    141                 invalidateFill();
    142         }
    143155
    144156        @Override
  • trunk/src/org/expeditee/items/Item.java

    r805 r812  
    1616import java.awt.geom.Rectangle2D;
    1717import java.util.ArrayList;
    18 import java.util.Arrays;
    1918import java.util.Collection;
    2019import java.util.ConcurrentModificationException;
     
    13261325
    13271326        /**
    1328          * Removes the given Constraint from the list of constraintss that this Dot
     1327         * Removes the given Constraint from the list of constraints that this Dot
    13291328         * is a part of.
    13301329         *
     
    18241823        }
    18251824
     1825       
     1826       
     1827       
     1828       
     1829        protected void anchorConstraints()
     1830        {
     1831                // update the position of any dots that are constrained by this one
     1832                for (Constraint c : _constraints) {
     1833                        Item other = c.getOppositeEnd(this);
     1834
     1835                        // only set position if the other dot is still fixed to the
     1836                        // frame
     1837                        if (/* this.isFloating() && */!other.isFloating()) {
     1838                                if (c.getType() == Constraint.HORIZONTAL) {
     1839                                        if (isAnchoredY()) {
     1840                                                // Make the 'other' item have the same anchor top/bottom values as this
     1841                                                other._anchorTop    = _anchorTop;
     1842                                                other._anchorBottom = _anchorBottom;
     1843                                        }
     1844                                } else if (c.getType() == Constraint.VERTICAL) {
     1845                                        if (isAnchoredX()) {
     1846                                                // Make the 'other' item have the same anchor left/right values as this
     1847                                                other._anchorLeft  = _anchorLeft;
     1848                                                other._anchorRight = _anchorRight;
     1849                                        }
     1850                                } else if (c.isDiagonal()) {
     1851
     1852                                        System.err.println("Warning: anchorConstraints() not implement for Diagonal setting");
     1853                                }
     1854                        }
     1855                }
     1856        }
     1857       
    18261858        /**
    18271859         * Sets the position of this item on the screen
     
    22932325        public boolean isLineEnd() {
    22942326                // TODO this will need to be redone when enclosure class is added...
    2295                 // At the moment enclosures are only circles...we dont want circle
    2296                 // centers to be lineEnds
     2327                // At the moment enclosures are only circles...we don't want circle
     2328                // centres to be lineEnds
    22972329                return _lines.size() > 0;
    22982330        }
     
    26992731         *
    27002732         * @return the collection of items that are linked to this item as source.
    2701          *         Guarenteed not to be null.
     2733         *         Guaranteed not to be null.
    27022734         */
    27032735        public Collection<? extends XRayable> getEnclosures() {
     
    28452877                this._anchorRight = null;
    28462878                if (anchor != null) {
     2879                        anchorConstraints();
    28472880                    setX(anchor);
    28482881                }
     
    28522885                this._anchorRight = anchor;
    28532886                this._anchorLeft = null;
    2854                 if (anchor != null)
     2887                if (anchor != null) {
     2888                        anchorConstraints();
    28552889                        setX(FrameGraphics.getMaxFrameSize().width - anchor
    28562890                                        - getBoundsWidth());
     2891                }
    28572892        }
    28582893
     
    28602895                this._anchorTop = anchor;
    28612896                this._anchorBottom = null;
    2862                 if (anchor != null)
     2897                if (anchor != null) {
     2898                        anchorConstraints();
    28632899                        setY(anchor);
     2900                }
    28642901        }
    28652902
     
    28682905                this._anchorBottom = anchor;
    28692906                this._anchorTop = null;
    2870                 if (anchor != null)
     2907                if (anchor != null) {
     2908                        anchorConstraints();
    28712909                        setY(FrameGraphics.getMaxFrameSize().height - anchor);
     2910                }
    28722911        }
    28732912
     
    29552994        }
    29562995
    2957         protected void anchorConnectedRefactored(AnchorEdgeType anchorEdgeType, Float delta) {
     2996        protected void anchorConnectedOLD(AnchorEdgeType anchorEdgeType, Float delta) {
    29582997                // Check for a more efficient way to do this!!
    29592998                // Invalidate all the items
     
    30013040       
    30023041        protected void anchorConnected(AnchorEdgeType anchorEdgeType, Float delta) {
     3042               
    30033043                // Check for a more efficient way to do this!!
    30043044                // Invalidate all the items
     
    30523092                }
    30533093               
     3094                anchorConstraints();
     3095               
    30543096                // Invalidate them again!!
    30553097                for (Item i : this.getAllConnected()) {
  • trunk/src/org/expeditee/items/Text.java

    r777 r812  
    24662466                invalidateFill();
    24672467                invalidateCommonTrait(ItemAppearence.PreMoved);
     2468               
     2469                this._anchorLeft = anchor;
     2470                this._anchorRight = null;
     2471               
    24682472                int oldX = getX();
    24692473                if (anchor != null) {
     
    24712475                        anchorConnected(AnchorEdgeType.Left, deltaX);
    24722476                }
    2473                 this._anchorLeft = anchor;
    2474                 this._anchorRight = null;
     2477
    24752478                invalidateCommonTrait(ItemAppearence.PostMoved);
    24762479                invalidateFill();
     
    24902493                invalidateFill();
    24912494                invalidateCommonTrait(ItemAppearence.PreMoved);
     2495               
     2496                this._anchorRight = anchor;
     2497                this._anchorLeft = null;
     2498               
    24922499                int oldX = getX();
    24932500                if (anchor != null) {
     
    24962503                        anchorConnected(AnchorEdgeType.Right, deltaX);
    24972504                }
    2498                 this._anchorRight = anchor;
    2499                 this._anchorLeft = null;
     2505
    25002506                invalidateCommonTrait(ItemAppearence.PostMoved);
    25012507                invalidateFill();
     
    25152521                invalidateFill();
    25162522                invalidateCommonTrait(ItemAppearence.PreMoved);
     2523               
     2524                this._anchorTop = anchor;
     2525                this._anchorBottom = null;
     2526               
    25172527                int oldY = getY();
    25182528                if (anchor != null) {
     
    25202530                        anchorConnected(AnchorEdgeType.Top, deltaY);
    25212531                }
    2522                 this._anchorTop = anchor;
    2523                 this._anchorBottom = null;
     2532
    25242533                invalidateCommonTrait(ItemAppearence.PostMoved);
    25252534                invalidateFill();
     
    25342543                invalidateFill();
    25352544                invalidateCommonTrait(ItemAppearence.PreMoved);
     2545               
     2546                this._anchorBottom = anchor;
     2547                this._anchorTop = null;
     2548               
    25362549                int oldY = getY();
    25372550                if (anchor != null) {
     
    25412554                        anchorConnected(AnchorEdgeType.Bottom, deltaY);
    25422555                }
    2543                 this._anchorBottom = anchor;
    2544                 this._anchorTop = null;
     2556
    25452557                invalidateCommonTrait(ItemAppearence.PostMoved);
    25462558                invalidateFill();
Note: See TracChangeset for help on using the changeset viewer.