Browse Source
Merge in DESIGN/design from ~TOMMY/design:final/11.0 to final/11.0 * commit '5f66ff0fec214c6773c5b5c17c6511630669c5d1': REPORT-60896 代码还原 无JIRA任务 引导任务的组件替换下 REPORT-60896 引导蒙层有残留阴影 REPORT-61207 引导相关字体显示不对且被截断 REPORT-61213 mac全屏下部分高亮元素位置有偏差new-design
Tommy
3 years ago
8 changed files with 58 additions and 46 deletions
@ -0,0 +1,28 @@
|
||||
package com.fr.design.mainframe.guide.utils; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JTextPane; |
||||
import javax.swing.text.MutableAttributeSet; |
||||
import javax.swing.text.SimpleAttributeSet; |
||||
import javax.swing.text.StyleConstants; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Insets; |
||||
|
||||
public class GuideUIUtils { |
||||
public static void setTextPaneLineHeight(JTextPane pane, int lineHeight) { |
||||
pane.selectAll(); |
||||
pane.setMargin(new Insets(0,0,0,0)); |
||||
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes()); |
||||
FontMetrics fontMetrics = GraphHelper.getFontMetrics(pane.getFont()); |
||||
int delta = (lineHeight - fontMetrics.getHeight()) / 2 * 2 ; |
||||
if (delta > 0) { |
||||
StyleConstants.setLineSpacing(set, delta/ 2.0f / fontMetrics.getHeight()); |
||||
pane.setParagraphAttributes(set, false); |
||||
int dis = fontMetrics.getDescent() - fontMetrics.getLeading(); |
||||
int marginTop = dis > 0 ? ((delta - dis) / 2 + dis) : ((delta - dis) / 2); |
||||
pane.setBorder(BorderFactory.createEmptyBorder(marginTop, 0,0,0)); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue