Browse Source

消除一波插件警告

feature/x
obo 1 year ago
parent
commit
e9582c6962
  1. 34
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/ImageUtils.java
  2. 157
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetThemeECReportPreviewPane.java
  3. 89
      designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java

34
designer-base/src/main/java/com/fr/widgettheme/theme/panel/ImageUtils.java

@ -29,18 +29,44 @@ public class ImageUtils {
for (int xx = 0; xx < width; xx++) {
for (int yy = 0; yy < height; yy++) {
dealRasterPixels(raster, xx, yy, color);
int[] pixels = raster.getPixel(xx, yy, (int[]) null);
setRedPixels(pixels, color);
setGreenPixels(pixels, color);
setBluePixels(pixels, color);
raster.setPixel(xx, yy, pixels);
}
}
return image;
}
private static void dealRasterPixels(WritableRaster raster, int x, int y, Color color) {
int[] pixels = raster.getPixel(x, y, (int[]) null);
/**
* 处理红像素
*
* @param pixels 像素数组
* @param color 颜色
*/
private static void setRedPixels(int[] pixels, Color color) {
pixels[0] = pixels[0] > 0 && pixels[0] < 255 ? color.getRed() : 255;
}
/**
* 处理绿像素
*
* @param pixels 像素数组
* @param color 颜色
*/
private static void setGreenPixels(int[] pixels, Color color) {
pixels[1] = pixels[1] > 0 && pixels[1] < 255 ? color.getGreen() : 255;
}
/**
* 处理蓝像素
*
* @param pixels 像素数组
* @param color 颜色
*/
private static void setBluePixels(int[] pixels, Color color) {
pixels[2] = pixels[2] > 0 && pixels[2] < 255 ? color.getBlue() : 255;
raster.setPixel(x, y, pixels);
}
/**

157
designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetThemeECReportPreviewPane.java

@ -77,11 +77,7 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
bigTitleCell.setPreferredSize(new Dimension(615, 46));
headerTitleCellList.add(bigTitleCell);
northPane.add(bigTitleCell, BorderLayout.NORTH);
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Column_Name"),
Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Data"), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Row_Name")},
new Point2D[]{new Point(159, 71), new Point(225, 49)});
cornerCell.setBorderSourceFlag(CellBorderSourceFlag.INVALID_BORDER_SOURCE);
cornerCell.setPreferredSize(new Dimension(225, 71));
CornerPreviewCell cornerCell = createCornerPreviewCell();
titleCellList.add(cornerCell);
northPane.add(cornerCell, BorderLayout.WEST);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
@ -93,15 +89,7 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
centerPane.add(cell, BorderLayout.NORTH);
JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout());
for (int c = 0; c < CONTENT_ROW_COUNT; c++) {
PreviewCell headerCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < CONTENT_ROW_COUNT - 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
headerCell.setBorderSourceFlag(flag);
PreviewCell headerCell = createPreviewCellHeader(c);
headerCellList.add(headerCell);
eastSouthPane.add(headerCell);
}
@ -109,6 +97,37 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
return northPane;
}
/**
* 创建CornerPreviewCell
*/
private CornerPreviewCell createCornerPreviewCell() {
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Column_Name"),
Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_EC_Data"), Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Row_Name")},
new Point2D[]{new Point(159, 71), new Point(225, 49)});
cornerCell.setBorderSourceFlag(CellBorderSourceFlag.INVALID_BORDER_SOURCE);
cornerCell.setPreferredSize(new Dimension(225, 71));
return cornerCell;
}
/**
* 创建预览单元格标题
*
* @param c 文本行数
* @return PreviewCell
*/
private PreviewCell createPreviewCellHeader(int c) {
PreviewCell headerCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < CONTENT_ROW_COUNT - 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
headerCell.setBorderSourceFlag(flag);
return headerCell;
}
private JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
JPanel westPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
@ -117,21 +136,8 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
titleCellList.add(cell1);
cell1.setPreferredSize(new Dimension(112, 93));
westPane.add(cell1, BorderLayout.WEST);
JPanel gridPane = new UINoOpaquePanel(new GridLayout(3, 1));
for (int r = 0; r < 3; r++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(113, 31));
headerCellList.add(cell);
gridPane.add(cell);
}
JPanel gridPane = createGridPane();
westPane.add(gridPane, BorderLayout.CENTER);
JPanel innerCenterPane = new UINoOpaquePanel(new GridLayout(3, 3));
centerPane.add(innerCenterPane, BorderLayout.CENTER);
@ -140,41 +146,82 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
int r = i / CONTENT_ROW_COUNT;
int c = i % CONTENT_ROW_COUNT;
if (c == CONTENT_ROW_COUNT - 1) {
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r != COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell = createPreviewCellHighlight(r);
highLightCellList.add(cell);
} else {
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < CONTENT_ROW_COUNT - 2) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell = createPreviewCellMain(r, c);
contentCellList.add(cell);
}
cell.setPreferredSize(new Dimension(123, 31));
innerCenterPane.add(cell);
}
return centerPane;
}
/**
* 创建高亮预览单元格
*
* @param r 计算标志位
* @return 单元格
*/
private PreviewCell createPreviewCellHighlight(int r) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r != COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
return cell;
}
return centerPane;
/**
* 创建正文预览单元格
*
* @param r 计算标志位
* @param c 计算标志位
* @return 单元格
*/
private PreviewCell createPreviewCellMain(int r, int c) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
}
if (c < 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
return cell;
}
private JPanel createGridPane() {
int rowCount = 3;
int columnCount = 1;
JPanel gridPane = new UINoOpaquePanel(new GridLayout(rowCount, columnCount));
for (int r = 0; r < rowCount; r++) {
PreviewCell cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
}
if (r < COL_COUNT - 1) {
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
}
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(113, 31));
headerCellList.add(cell);
gridPane.add(cell);
}
return gridPane;
}
private JPanel createSouthPane(){

89
designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java

@ -31,7 +31,9 @@ import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 样式设置pane抽象类
@ -64,14 +66,15 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
// 按钮背景设置
protected ButtonStyleDefinedPane buttonStyleDefinedPane;
private Map<StyleSetting, UILabel> labelMap;
private Map<StyleSetting, Component> paneMap;
public BaseStyleSettingPane(List<StyleSetting> styleSettingList) {
this.styleSettingList = styleSettingList;
initStyleEditor();
initPane();
initDefaultValue();
initLabelMap();
}
protected void initPane() {
@ -82,33 +85,20 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
protected void initStyleEditor() {
styleSettingList.forEach(it -> {
switch (it) {
case STYLE_TYPE:
initStyle();
break;
case THEME_COLOR:
colorSelectBox = new NewColorSelectBox(160, true);
break;
case LINE_TYPE:
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY);
break;
case FONT_SIZE:
fontSizePane = new FontSizeComboPane();
break;
case BORDER_RADIUS:
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1);
break;
case FONT:
frFontPane = new FRFontPane();
break;
case BTN_BACKGROUND:
buttonStyleDefinedPane = new ButtonStyleDefinedPane();
break;
default:
break;
}
});
initStyle();
colorSelectBox = new NewColorSelectBox(160, true);
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY);
fontSizePane = new FontSizeComboPane();
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1);
frFontPane = new FRFontPane();
buttonStyleDefinedPane = new ButtonStyleDefinedPane();
paneMap.put(StyleSetting.STYLE_TYPE, createStyleTypePane());
paneMap.put(StyleSetting.THEME_COLOR, colorSelectBox);
paneMap.put(StyleSetting.LINE_TYPE, lineComboBox);
paneMap.put(StyleSetting.FONT_SIZE, fontSizePane);
paneMap.put(StyleSetting.BORDER_RADIUS, borderRadiusSpinner);
paneMap.put(StyleSetting.FONT, frFontPane);
paneMap.put(StyleSetting.BTN_BACKGROUND, buttonStyleDefinedPane);
}
/**
@ -151,7 +141,7 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
int columnCount = 2;
double[] rowSize = new double[size];
for (int i = 0; i < size; i++) {
rowSize[i] = p;
@ -159,9 +149,9 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
double[] columnSize = {p, f};
int[][] rowCount = new int[size][2];
int[][] rowCount = new int[size][columnCount];
for (int i = 0; i < size; i++) {
for (int j = 0; j < 2; j++) {
for (int j = 0; j < columnCount; j++) {
rowCount[i][j] = 1;
}
}
@ -180,24 +170,10 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
}
protected Component[] createComponentByStyleSetting(StyleSetting styleSetting) {
switch (styleSetting) {
case THEME_COLOR:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color")), colorSelectBox};
case FONT_SIZE:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font_Size")), fontSizePane};
case FONT:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font")), frFontPane};
case STYLE_TYPE:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style")), createStyleTypePane()};
case LINE_TYPE:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line")), lineComboBox};
case BORDER_RADIUS:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius")), borderRadiusSpinner};
case BTN_BACKGROUND:
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Theme_Widget_Background")), buttonStyleDefinedPane};
default:
return null;
}
Component[] components = new Component[2];
components[0] = labelMap.get(styleSetting);
components[1] = paneMap.get(styleSetting);
return components;
}
protected void switchCard() {
@ -297,5 +273,16 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
}
}
/**
* 初始化枚举和UILabel对应的map
*/
private void initLabelMap() {
labelMap.put(StyleSetting.THEME_COLOR, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color")));
labelMap.put(StyleSetting.FONT_SIZE, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font_Size")));
labelMap.put(StyleSetting.FONT, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Font")));
labelMap.put(StyleSetting.STYLE_TYPE, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style")));
labelMap.put(StyleSetting.LINE_TYPE, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line")));
labelMap.put(StyleSetting.BORDER_RADIUS, new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius")));
labelMap.put(StyleSetting.BTN_BACKGROUND, new UILabel(Toolkit.i18nText("Fine-Design_Theme_Widget_Background")));
}
}

Loading…
Cancel
Save