From 611a5358905e21841f2e52ce7ddcdcbfe16c4cdb Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 29 Jun 2022 14:25:08 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-11406=20=20FRM=E5=92=8CFVS=E7=9A=84?= =?UTF-8?q?=E6=96=B0=E8=A1=A8=E6=A0=BC=E6=94=AF=E6=8C=81=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=A1=8C=E9=AB=98=E5=88=97=E5=AE=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/DesignerUIModeConfig.java | 23 +++++++ .../fit/common/NewUIModeAutoChangeLine.java | 20 ------ .../fit/common/NewUIModeRotationDraw.java | 69 ------------------- .../fit/NewUIModeCellElementPainter.java | 2 +- .../src/main/java/com/fr/grid/GridUtils.java | 3 +- 5 files changed, 26 insertions(+), 91 deletions(-) delete mode 100644 designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java delete mode 100644 designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java index 1e072d956a..400f698185 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java @@ -1,8 +1,11 @@ package com.fr.design.mainframe; +import com.fr.base.AutoChangeLineProvider; +import com.fr.base.DefaultAutoChangeLine; import com.fr.base.ScreenResolution; import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.unit.UnitConvertUtil; +import com.fr.form.fit.NewUIModeAutoChangeLine; import com.fr.general.ComparatorUtils; import com.fr.stable.Constants; @@ -58,6 +61,14 @@ public class DesignerUIModeConfig { return mode.parseLengthUNIT(unitType); } + /** + * 获取不同模式下的换行逻辑 + * @return AutoChangeLineProvider + */ + public AutoChangeLineProvider getAutoChangeLineStrategy() { + return mode.getAutoChangeLineStrategy(); + } + /** * 获取不同模式下的屏幕分辨率 * @@ -75,6 +86,11 @@ public class DesignerUIModeConfig { return UnitConvertUtil.parseLengthUNIT(unitType); } + @Override + public AutoChangeLineProvider getAutoChangeLineStrategy() { + return new DefaultAutoChangeLine(); + } + @Override protected int getScreenResolution() { return ScreenResolution.getScreenResolution(); @@ -87,6 +103,11 @@ public class DesignerUIModeConfig { return new PXReportLengthUNIT(); } + @Override + public AutoChangeLineProvider getAutoChangeLineStrategy() { + return new NewUIModeAutoChangeLine(); + } + @Override protected int getScreenResolution() { return Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION; @@ -96,6 +117,8 @@ public class DesignerUIModeConfig { protected abstract ReportLengthUNITProvider parseLengthUNIT(int unitType); + public abstract AutoChangeLineProvider getAutoChangeLineStrategy(); + protected abstract int getScreenResolution(); diff --git a/designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java b/designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java deleted file mode 100644 index 0037c738d8..0000000000 --- a/designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java +++ /dev/null @@ -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 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(); - } - -} diff --git a/designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java b/designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java deleted file mode 100644 index 3e0b06721e..0000000000 --- a/designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java +++ /dev/null @@ -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; - } - -} diff --git a/designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java b/designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java index 4f1e883674..c0b1ca65e6 100644 --- a/designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java +++ b/designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java @@ -1,6 +1,6 @@ package com.fr.design.fit; -import com.fr.design.fit.common.NewUIModeRotationDraw; +import com.fr.form.fit.NewUIModeRotationDraw; import com.fr.grid.CellElementPainter; import com.fr.report.cell.TemplateCellElement; import com.fr.report.core.PaintUtils; diff --git a/designer-realize/src/main/java/com/fr/grid/GridUtils.java b/designer-realize/src/main/java/com/fr/grid/GridUtils.java index 21b032265f..03d125075c 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUtils.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUtils.java @@ -448,7 +448,8 @@ public class GridUtils { int editElementcolumn = editCellElement.getColumn(); UNIT preferredHeight = PaintUtils.analyzeCellElementPreferredHeight( editCellElement, - columnWidthList.getRangeValue(editElementcolumn, editElementcolumn + editCellElement.getColumnSpan())); + columnWidthList.getRangeValue(editElementcolumn, editElementcolumn + editCellElement.getColumnSpan()), + DesignerUIModeConfig.getInstance().getAutoChangeLineStrategy()); if (editCellElement.getRowSpan() == 1) { rowHeightList.set(editCellElement.getRow(), UNIT.max(preferredHeight, rowHeightList.get(editCellElement.getRow())));