Changeset 1514
- Timestamp:
- 03/04/20 11:00:23 (4 years ago)
- Location:
- trunk/src/org/expeditee/items
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Dot.java
r1415 r1514 102 102 invalidateFill(); 103 103 } 104 105 @Override 106 public void setAnchorCenterX(Integer anchor) { 107 if (!isLineEnd()) { 108 super.setAnchorCenterX(anchor); 109 return; 110 } 111 112 invalidateFill(); 113 invalidateCommonTrait(ItemAppearence.PreMoved); 114 115 this._anchoring.setCenterXAnchor(anchor); 116 117 int oldX = getX(); 118 if (anchor != null) { 119 int centreX = DisplayController.getFramePaintArea().getCentreX(); 120 int alignedToLeft = centreX + anchor; 121 int alignedToCenter = alignedToLeft - (getBoundsWidth() / 2); 122 float deltaX = alignedToCenter - oldX; 123 anchorConnected(AnchorEdgeType.CenterX, deltaX); 124 } 125 126 invalidateCommonTrait(ItemAppearence.PostMoved); 127 invalidateFill(); 128 } 104 129 105 130 @Override … … 142 167 } 143 168 169 invalidateCommonTrait(ItemAppearence.PostMoved); 170 invalidateFill(); 171 } 172 173 @Override 174 public void setAnchorCenterY(Integer anchor) { 175 if (!isLineEnd()) { 176 super.setAnchorCenterY(anchor); 177 return; 178 } 179 invalidateFill(); 180 invalidateCommonTrait(ItemAppearence.PreMoved); 181 182 this._anchoring.setCenterYAnchor(anchor); 183 184 int oldY = getY(); 185 if (anchor != null) { 186 int alignedToTop = DisplayController.getFramePaintArea().getCentreY() + anchor; 187 float alignedToCenter = alignedToTop - (getBoundsHeight() / 2); 188 float deltaY = alignedToCenter - oldY; 189 anchorConnected(AnchorEdgeType.CenterY, deltaY); 190 } 191 144 192 invalidateCommonTrait(ItemAppearence.PostMoved); 145 193 invalidateFill(); -
trunk/src/org/expeditee/items/Item.java
r1513 r1514 98 98 /** Which edge of the window things are anchored to. */ 99 99 public enum AnchorEdgeType { 100 None, Left, Right, Top, Bottom100 None, Left, CenterY, Right, Top, CenterX, Bottom 101 101 } 102 102 … … 3925 3925 if (i.isLineEnd()) { 3926 3926 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()); 3935 3933 } 3936 else {3937 // Processing a Right anchor3938 // => 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()); 3942 3940 } 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 3944 3974 } 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 // } 3964 4012 } 3965 4013 } -
trunk/src/org/expeditee/items/Text.java
r1513 r1514 2907 2907 } 2908 2908 } 2909 2910 @Override 2911 public void setAnchorCenterX(Integer anchor) { 2912 if (!isLineEnd()) { 2913 super.setAnchorCenterX(anchor); 2914 // Subtract off the link width 2915 if (anchor != null) { 2916 int alignedToLeft = DisplayController.getFramePaintArea().getCentreX() + anchor; 2917 int alignedToCenter = alignedToLeft - (getBoundsWidth() / 2); 2918 setX(alignedToCenter); 2919 } 2920 return; 2921 } 2922 invalidateFill(); 2923 invalidateCommonTrait(ItemAppearence.PostMoved); 2924 2925 this._anchoring.setCenterXAnchor(anchor); 2926 2927 int oldX = getX(); 2928 if (anchor != null) { 2929 float deltaX = DisplayController.getFramePaintArea().getCentreX() - anchor - getBoundsWidth() + getLeftMargin() - oldX; 2930 anchorConnected(AnchorEdgeType.CenterY, deltaX); 2931 } 2932 2933 invalidateCommonTrait(ItemAppearence.PostMoved); 2934 invalidateFill(); 2935 2936 if (isSurrogate()) { 2937 surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_CENTERX_STR, false); 2938 Item primary = getPrimary(); 2939 if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_CENTERX_STR)) { 2940 EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave); 2941 primary.primaryPropertyEncryption.put(DefaultFrameWriter.ANCHOR_CENTERX_STR, inheritanceCheckOnSave); 2942 } 2943 } 2944 } 2909 2945 2910 2946 @Override … … 2983 3019 primary.primaryPropertyEncryption.put(DefaultFrameWriter.ANCHOR_TOP_STR, inheritanceCheckOnSave); 2984 3020 } 3021 } 3022 } 3023 3024 @Override 3025 public void setAnchorCenterY(Integer anchor) { 3026 if (!isLineEnd()) { 3027 super.setAnchorCenterY(anchor); 3028 if (anchor != null) { 3029 List<TextLayout> textLayouts = getTextLayouts(); 3030 if (!textLayouts.isEmpty()) { 3031 int middle = textLayouts.size() / 2; 3032 float heightFromTopOfTextItem = 0; 3033 for (int i = 0; i <= middle; i++) { 3034 TextLayout tl = textLayouts.get(i); 3035 float ascent = tl.getAscent(); 3036 float descent = tl.getDescent(); 3037 heightFromTopOfTextItem += (ascent + descent); 3038 } 3039 heightFromTopOfTextItem -= textLayouts.get(middle).getDescent(); 3040 float anchorCalc = anchor + this.getBoundsHeight() - heightFromTopOfTextItem; 3041 setY((DisplayController.getFramePaintAreaHeight() / 2) - anchorCalc); 3042 } else if (this.getFont() != null) { 3043 // p could be any character 3044 TextLayout fakeLayout = TextLayout.getManager().layoutStringSimple("p", this.getFont()); 3045 float ascent = fakeLayout.getAscent(); 3046 float descent = fakeLayout.getDescent(); 3047 float middle = descent - ascent; 3048 float anchorCalc = anchor + this.getBoundsHeight() - middle; 3049 setY((DisplayController.getFramePaintAreaHeight() / 2) - anchorCalc); 3050 } 3051 } 3052 return; 2985 3053 } 2986 3054 }
Note:
See TracChangeset
for help on using the changeset viewer.