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 xx = 0; xx < width; xx++) {
for (int yy = 0; yy < height; yy++) { 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; 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; 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; 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; 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)); bigTitleCell.setPreferredSize(new Dimension(615, 46));
headerTitleCellList.add(bigTitleCell); headerTitleCellList.add(bigTitleCell);
northPane.add(bigTitleCell, BorderLayout.NORTH); northPane.add(bigTitleCell, BorderLayout.NORTH);
CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{Toolkit.i18nText("Fine-Design_Basic_Column_Name"), CornerPreviewCell cornerCell = createCornerPreviewCell();
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));
titleCellList.add(cornerCell); titleCellList.add(cornerCell);
northPane.add(cornerCell, BorderLayout.WEST); northPane.add(cornerCell, BorderLayout.WEST);
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
@ -93,15 +89,7 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
centerPane.add(cell, BorderLayout.NORTH); centerPane.add(cell, BorderLayout.NORTH);
JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout()); JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout());
for (int c = 0; c < CONTENT_ROW_COUNT; c++) { for (int c = 0; c < CONTENT_ROW_COUNT; c++) {
PreviewCell headerCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); PreviewCell headerCell = createPreviewCellHeader(c);
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);
headerCellList.add(headerCell); headerCellList.add(headerCell);
eastSouthPane.add(headerCell); eastSouthPane.add(headerCell);
} }
@ -109,6 +97,37 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
return northPane; 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() { private JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane();
JPanel westPane = 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); titleCellList.add(cell1);
cell1.setPreferredSize(new Dimension(112, 93)); cell1.setPreferredSize(new Dimension(112, 93));
westPane.add(cell1, BorderLayout.WEST); westPane.add(cell1, BorderLayout.WEST);
JPanel gridPane = new UINoOpaquePanel(new GridLayout(3, 1)); JPanel gridPane = createGridPane();
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);
}
westPane.add(gridPane, BorderLayout.CENTER); westPane.add(gridPane, BorderLayout.CENTER);
JPanel innerCenterPane = new UINoOpaquePanel(new GridLayout(3, 3)); JPanel innerCenterPane = new UINoOpaquePanel(new GridLayout(3, 3));
centerPane.add(innerCenterPane, BorderLayout.CENTER); centerPane.add(innerCenterPane, BorderLayout.CENTER);
@ -140,41 +146,82 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
int r = i / CONTENT_ROW_COUNT; int r = i / CONTENT_ROW_COUNT;
int c = i % CONTENT_ROW_COUNT; int c = i % CONTENT_ROW_COUNT;
if (c == CONTENT_ROW_COUNT - 1) { if (c == CONTENT_ROW_COUNT - 1) {
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); cell = createPreviewCellHighlight(r);
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);
highLightCellList.add(cell); highLightCellList.add(cell);
} else { } else {
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); cell = createPreviewCellMain(r, c);
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);
contentCellList.add(cell); contentCellList.add(cell);
} }
cell.setPreferredSize(new Dimension(123, 31)); cell.setPreferredSize(new Dimension(123, 31));
innerCenterPane.add(cell); 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(){ 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 javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 样式设置pane抽象类 * 样式设置pane抽象类
@ -64,14 +66,15 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
// 按钮背景设置 // 按钮背景设置
protected ButtonStyleDefinedPane buttonStyleDefinedPane; protected ButtonStyleDefinedPane buttonStyleDefinedPane;
private Map<StyleSetting, UILabel> labelMap;
private Map<StyleSetting, Component> paneMap;
public BaseStyleSettingPane(List<StyleSetting> styleSettingList) { public BaseStyleSettingPane(List<StyleSetting> styleSettingList) {
this.styleSettingList = styleSettingList; this.styleSettingList = styleSettingList;
initStyleEditor(); initStyleEditor();
initPane(); initPane();
initDefaultValue(); initDefaultValue();
initLabelMap();
} }
protected void initPane() { protected void initPane() {
@ -82,33 +85,20 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
protected void initStyleEditor() { protected void initStyleEditor() {
styleSettingList.forEach(it -> { initStyle();
switch (it) { colorSelectBox = new NewColorSelectBox(160, true);
case STYLE_TYPE: lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY);
initStyle(); fontSizePane = new FontSizeComboPane();
break; borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1);
case THEME_COLOR: frFontPane = new FRFontPane();
colorSelectBox = new NewColorSelectBox(160, true); buttonStyleDefinedPane = new ButtonStyleDefinedPane();
break; paneMap.put(StyleSetting.STYLE_TYPE, createStyleTypePane());
case LINE_TYPE: paneMap.put(StyleSetting.THEME_COLOR, colorSelectBox);
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY); paneMap.put(StyleSetting.LINE_TYPE, lineComboBox);
break; paneMap.put(StyleSetting.FONT_SIZE, fontSizePane);
case FONT_SIZE: paneMap.put(StyleSetting.BORDER_RADIUS, borderRadiusSpinner);
fontSizePane = new FontSizeComboPane(); paneMap.put(StyleSetting.FONT, frFontPane);
break; paneMap.put(StyleSetting.BTN_BACKGROUND, buttonStyleDefinedPane);
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;
}
});
} }
/** /**
@ -151,7 +141,7 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
int columnCount = 2;
double[] rowSize = new double[size]; double[] rowSize = new double[size];
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
rowSize[i] = p; rowSize[i] = p;
@ -159,9 +149,9 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
double[] columnSize = {p, f}; 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 i = 0; i < size; i++) {
for (int j = 0; j < 2; j++) { for (int j = 0; j < columnCount; j++) {
rowCount[i][j] = 1; rowCount[i][j] = 1;
} }
} }
@ -180,24 +170,10 @@ public abstract class BaseStyleSettingPane<T extends Widget> extends BasicBeanPa
} }
protected Component[] createComponentByStyleSetting(StyleSetting styleSetting) { protected Component[] createComponentByStyleSetting(StyleSetting styleSetting) {
switch (styleSetting) { Component[] components = new Component[2];
case THEME_COLOR: components[0] = labelMap.get(styleSetting);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Color")), colorSelectBox}; components[1] = paneMap.get(styleSetting);
case FONT_SIZE: return components;
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;
}
} }
protected void switchCard() { 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