Ignore:
Timestamp:
03/04/20 11:00:23 (4 years ago)
Author:
bnemhaus
Message:

Anchoring with AnchorCenterX and AnchorCenterY now work correctly with connected shapes.

File:
1 edited

Legend:

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

    r1513 r1514  
    9898        /** Which edge of the window things are anchored to. */
    9999        public enum AnchorEdgeType {
    100                 None, Left, Right, Top, Bottom
     100                None, Left, CenterY, Right, Top, CenterX, Bottom
    101101        }
    102102       
     
    39253925                        if (i.isLineEnd()) {
    39263926                                if (delta != null) {
    3927                                         if ((anchorEdgeType == AnchorEdgeType.Left) || (anchorEdgeType == AnchorEdgeType.Right)) {
    3928                                                 // 'delta' encodes a horizontal (x) move
    3929                                                 if (anchorEdgeType == AnchorEdgeType.Left) {
    3930                                                         // Processing a Left anchor
    3931                                                         // => Anything connected that is *not* anchored to the right should be moved by 'delta'
    3932                                                         if (i.getAnchorRight()==null) {
    3933                                                                 i.setXY(i.getX() + delta, i.getY());
    3934                                                         }
     3927                                        switch (anchorEdgeType) {
     3928                                        case Left:
     3929                                                // Processing a Left anchor
     3930                                                // => Anything connected that is *not* anchored to the right or center should be moved by 'delta'
     3931                                                if (i.getAnchorRight() == null && i.getAnchorCenterX() == null) {
     3932                                                        i.setXY(i.getX() + delta, i.getY());
    39353933                                                }
    3936                                                 else {
    3937                                                         // Processing a Right anchor
    3938                                                         // => Anything connected that is *not* anchored to the left should be moved by 'delta'
    3939                                                         if (i.getAnchorLeft()==null) {
    3940                                                                 i.setXY(i.getX() + delta, i.getY());
    3941                                                         }
     3934                                                break;
     3935                                        case CenterX:
     3936                                                // Processing a CenterY anchor
     3937                                                // => Anything connected that is *not* anchored to the top or bottom should be moved by 'delta'
     3938                                                if (i.getAnchorTop()==null && i.getAnchorBottom()==null) {
     3939                                                        i.setXY(i.getX() + delta, i.getY());
    39423940                                                }
    3943 
     3941                                                break;
     3942                                        case Right:
     3943                                                // Processing a Right anchor
     3944                                                // => Anything connected that is *not* anchored to the left or center should be moved by 'delta'
     3945                                                if (i.getAnchorLeft()==null && i.getAnchorCenterX() == null) {
     3946                                                        i.setXY(i.getX() + delta, i.getY());
     3947                                                }
     3948                                                break;
     3949                                        case Top:
     3950                                                // Processing a Top anchor
     3951                                                // => Anything connected that is *not* anchored to the bottom or center should be moved by 'delta'
     3952                                                if (i.getAnchorBottom()==null && i.getAnchorCenterY() == null) {
     3953                                                        i.setXY(i.getX(), i.getY() + delta);
     3954                                                }
     3955                                                break;
     3956                                        case CenterY:
     3957                                                // Processing a CenterX anchor
     3958                                                // => Anything connected that is *not* anchored to the left or right should be moved by 'delta'
     3959                                                if (i.getAnchorLeft() == null && i.getAnchorRight() == null) {
     3960                                                        i.setXY(i.getX(), i.getY() + delta);
     3961                                                }
     3962                                                break;
     3963                                        case Bottom:
     3964                                                // Processing a Bottom anchor
     3965                                                // => Anything connected that is *not* anchored to the top or center should be moved by 'delta'
     3966                                                if (i.getAnchorTop()==null && i.getAnchorCenterY() == null) {
     3967                                                        i.setXY(i.getX(), i.getY() + delta);
     3968                                                }
     3969                                                break;
     3970                                        case None:
     3971                                        default:
     3972                                                break;
     3973                                       
    39443974                                        }
    3945                                         if ((anchorEdgeType == AnchorEdgeType.Top) || (anchorEdgeType == AnchorEdgeType.Bottom)) {
    3946                                                 // 'delta; encodes a vertical (y) move
    3947                                                 if (anchorEdgeType == AnchorEdgeType.Top) {
    3948                                                         // Processing a Top anchor
    3949                                                         // => Anything connected that is *not* anchored to the bottom should be moved by 'delta'
    3950                                                         if (i.getAnchorBottom()==null) {
    3951                                                                 i.setXY(i.getX(), i.getY() + delta);
    3952                                                         }
    3953                                                 }
    3954                                                 else {
    3955                                                         // Processing a Bottom anchor
    3956                                                         // => Anything connected that is *not* anchored to the top should be moved by 'delta'
    3957                                                         if (i.getAnchorTop()==null) {
    3958                                                                 // must be Bottom
    3959                                                                 //i.setAnchorBottom(null);
    3960                                                                 i.setXY(i.getX(), i.getY() + delta);
    3961                                                         }
    3962                                                 }
    3963                                         }               
     3975//                                      if ((anchorEdgeType == AnchorEdgeType.Left) || (anchorEdgeType == AnchorEdgeType.Right)) {
     3976//                                              // 'delta' encodes a horizontal (x) move
     3977//                                              if (anchorEdgeType == AnchorEdgeType.Left) {
     3978//                                                      // Processing a Left anchor
     3979//                                                      // => Anything connected that is *not* anchored to the right should be moved by 'delta'
     3980//                                                      if (i.getAnchorRight()==null) {
     3981//                                                              i.setXY(i.getX() + delta, i.getY());
     3982//                                                      }
     3983//                                              }
     3984//                                              else {
     3985//                                                      // Processing a Right anchor
     3986//                                                      // => Anything connected that is *not* anchored to the left should be moved by 'delta'
     3987//                                                      if (i.getAnchorLeft()==null) {
     3988//                                                              i.setXY(i.getX() + delta, i.getY());
     3989//                                                      }
     3990//                                              }
     3991//
     3992//                                      }
     3993//                                      if ((anchorEdgeType == AnchorEdgeType.Top) || (anchorEdgeType == AnchorEdgeType.Bottom)) {
     3994//                                              // 'delta; encodes a vertical (y) move
     3995//                                              if (anchorEdgeType == AnchorEdgeType.Top) {
     3996//                                                      // Processing a Top anchor
     3997//                                                      // => Anything connected that is *not* anchored to the bottom should be moved by 'delta'
     3998//                                                      if (i.getAnchorBottom()==null) {
     3999//                                                              i.setXY(i.getX(), i.getY() + delta);
     4000//                                                      }
     4001//                                              }
     4002//                                              else {
     4003//                                                      // Processing a Bottom anchor
     4004//                                                      // => Anything connected that is *not* anchored to the top should be moved by 'delta'
     4005//                                                      if (i.getAnchorTop()==null) {
     4006//                                                              // must be Bottom
     4007//                                                              //i.setAnchorBottom(null);
     4008//                                                              i.setXY(i.getX(), i.getY() + delta);
     4009//                                                      }
     4010//                                              }
     4011//                                      }               
    39644012                                }
    39654013                        }
Note: See TracChangeset for help on using the changeset viewer.