kerry
2 years ago
5 changed files with 26 additions and 91 deletions
@ -1,20 +0,0 @@
|
||||
package com.fr.design.fit.common; |
||||
|
||||
import com.fr.base.DefaultAutoChangeLine; |
||||
import com.fr.base.Style; |
||||
import com.fr.stable.unit.UNIT; |
||||
|
||||
import java.awt.Font; |
||||
import java.util.List; |
||||
|
||||
public class NewUIModeAutoChangeLine extends DefaultAutoChangeLine { |
||||
@Override |
||||
public List<String> textAutoChangeLine(String text, Font font, Style style, UNIT unitWidth, int resolution) { |
||||
return autoChangeLine(text, font, style, unitWidth, resolution); |
||||
} |
||||
|
||||
protected double calculateShowWidth(double paintWidth, Style style, int resolution) { |
||||
return paintWidth - style.getPaddingLeft() - style.getPaddingRight() - style.getBorderLeftWidth(); |
||||
} |
||||
|
||||
} |
@ -1,69 +0,0 @@
|
||||
package com.fr.design.fit.common; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.DefaultRotationTextDrawProvider; |
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.base.Style; |
||||
import com.fr.design.mainframe.PX; |
||||
import com.fr.stable.Constants; |
||||
|
||||
import java.awt.Font; |
||||
import java.awt.FontMetrics; |
||||
import java.awt.Graphics2D; |
||||
import java.util.List; |
||||
|
||||
public class NewUIModeRotationDraw extends DefaultRotationTextDrawProvider { |
||||
@Override |
||||
public void drawRotationText(Graphics2D g2d, String text, Style style, Font rfont, int width, int height, int horizontalAlignment, int resolution) { |
||||
FontMetrics cellFM = GraphHelper.getFontMetrics(rfont); |
||||
List lineTextList = BaseUtils.getLineTextList(text, style, rfont, height, width, resolution, new NewUIModeAutoChangeLine()); |
||||
drawRotationText(g2d, lineTextList, style, cellFM, width, height, horizontalAlignment, resolution); |
||||
} |
||||
|
||||
|
||||
protected int calculateTextWidth(int width, Style style) { |
||||
return width - style.getPaddingRight(); |
||||
} |
||||
|
||||
protected double calculateTextX(Style style, int width, int textWidth, int horizontalAlignment, int resolution) { |
||||
double textX = padding2PixExcludeRight(style.getPaddingLeft(), resolution); |
||||
if (horizontalAlignment == Constants.CENTER) { |
||||
textX += (width - textWidth - textX) / 2f; |
||||
} else if (horizontalAlignment == Constants.RIGHT) { |
||||
textX = width - style.getPaddingRight() - textWidth; |
||||
} |
||||
return textX; |
||||
} |
||||
|
||||
protected int toPXWithResolution(double pt, int resolution) { |
||||
return (int) PX.toPixWithResolution(pt, resolution); |
||||
} |
||||
|
||||
protected double padding2PixExcludeRight(int padding, int resolution) { |
||||
return PX.toPixWithResolution(padding, resolution); |
||||
} |
||||
|
||||
protected int calculateTextY(Style style, int height, int textHeight, int textAscent, List lineTextList, int resolution) { |
||||
// 计算Y的高度.
|
||||
int textY = 0; |
||||
int textAllHeight = textHeight * lineTextList.size(); |
||||
double spacingBefore = toPXWithResolution(style.getSpacingBefore(), resolution); |
||||
double spacingAfter = toPXWithResolution(style.getSpacingAfter(), resolution); |
||||
double lineSpacing = toPXWithResolution(style.getLineSpacing(), resolution); |
||||
textAllHeight += spacingBefore + spacingAfter + lineSpacing * lineTextList.size(); |
||||
if (style.getVerticalAlignment() == Constants.TOP) { |
||||
} else if (style.getVerticalAlignment() == Constants.CENTER) { |
||||
if (height > textAllHeight) {// 如果所有文本的高度小于当前可以绘区域的高度,就从0开始画字符.
|
||||
textY = (height - textAllHeight) / 2; |
||||
} |
||||
} else if (style.getVerticalAlignment() == Constants.BOTTOM) { |
||||
if (height > textAllHeight) { |
||||
textY = height - textAllHeight; |
||||
} |
||||
} |
||||
textY += textAscent;// 在绘画的时候,必须添加Ascent的高度.
|
||||
textY += spacingBefore + lineSpacing;//james:加上"段前间距"+“行间距”
|
||||
return textY; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue