Browse Source

KERNEL-11406 FRM和FVS的新表格支持后台调整行高列宽

feature/x
kerry 2 years ago
parent
commit
611a535890
  1. 23
      designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java
  2. 20
      designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java
  3. 69
      designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java
  4. 2
      designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java
  5. 3
      designer-realize/src/main/java/com/fr/grid/GridUtils.java

23
designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java

@ -1,8 +1,11 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.AutoChangeLineProvider;
import com.fr.base.DefaultAutoChangeLine;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.fun.ReportLengthUNITProvider;
import com.fr.design.unit.UnitConvertUtil; import com.fr.design.unit.UnitConvertUtil;
import com.fr.form.fit.NewUIModeAutoChangeLine;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
@ -58,6 +61,14 @@ public class DesignerUIModeConfig {
return mode.parseLengthUNIT(unitType); return mode.parseLengthUNIT(unitType);
} }
/**
* 获取不同模式下的换行逻辑
* @return AutoChangeLineProvider
*/
public AutoChangeLineProvider getAutoChangeLineStrategy() {
return mode.getAutoChangeLineStrategy();
}
/** /**
* 获取不同模式下的屏幕分辨率 * 获取不同模式下的屏幕分辨率
* *
@ -75,6 +86,11 @@ public class DesignerUIModeConfig {
return UnitConvertUtil.parseLengthUNIT(unitType); return UnitConvertUtil.parseLengthUNIT(unitType);
} }
@Override
public AutoChangeLineProvider getAutoChangeLineStrategy() {
return new DefaultAutoChangeLine();
}
@Override @Override
protected int getScreenResolution() { protected int getScreenResolution() {
return ScreenResolution.getScreenResolution(); return ScreenResolution.getScreenResolution();
@ -87,6 +103,11 @@ public class DesignerUIModeConfig {
return new PXReportLengthUNIT(); return new PXReportLengthUNIT();
} }
@Override
public AutoChangeLineProvider getAutoChangeLineStrategy() {
return new NewUIModeAutoChangeLine();
}
@Override @Override
protected int getScreenResolution() { protected int getScreenResolution() {
return Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION; return Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION;
@ -96,6 +117,8 @@ public class DesignerUIModeConfig {
protected abstract ReportLengthUNITProvider parseLengthUNIT(int unitType); protected abstract ReportLengthUNITProvider parseLengthUNIT(int unitType);
public abstract AutoChangeLineProvider getAutoChangeLineStrategy();
protected abstract int getScreenResolution(); protected abstract int getScreenResolution();

20
designer-form/src/main/java/com/fr/design/fit/common/NewUIModeAutoChangeLine.java

@ -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();
}
}

69
designer-form/src/main/java/com/fr/design/fit/common/NewUIModeRotationDraw.java

@ -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;
}
}

2
designer-realize/src/main/java/com/fr/design/fit/NewUIModeCellElementPainter.java

@ -1,6 +1,6 @@
package com.fr.design.fit; 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.grid.CellElementPainter;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.core.PaintUtils; import com.fr.report.core.PaintUtils;

3
designer-realize/src/main/java/com/fr/grid/GridUtils.java

@ -448,7 +448,8 @@ public class GridUtils {
int editElementcolumn = editCellElement.getColumn(); int editElementcolumn = editCellElement.getColumn();
UNIT preferredHeight = PaintUtils.analyzeCellElementPreferredHeight( UNIT preferredHeight = PaintUtils.analyzeCellElementPreferredHeight(
editCellElement, editCellElement,
columnWidthList.getRangeValue(editElementcolumn, editElementcolumn + editCellElement.getColumnSpan())); columnWidthList.getRangeValue(editElementcolumn, editElementcolumn + editCellElement.getColumnSpan()),
DesignerUIModeConfig.getInstance().getAutoChangeLineStrategy());
if (editCellElement.getRowSpan() == 1) { if (editCellElement.getRowSpan() == 1) {
rowHeightList.set(editCellElement.getRow(), rowHeightList.set(editCellElement.getRow(),
UNIT.max(preferredHeight, rowHeightList.get(editCellElement.getRow()))); UNIT.max(preferredHeight, rowHeightList.get(editCellElement.getRow())));

Loading…
Cancel
Save