Changeset 1514 for trunk/src/org/expeditee/items/Text.java
- Timestamp:
- 03/04/20 11:00:23 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.