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. 119
      designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetThemeECReportPreviewPane.java
  3. 75
      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);
} }
/** /**

119
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,6 +89,33 @@ 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 = createPreviewCellHeader(c);
headerCellList.add(headerCell);
eastSouthPane.add(headerCell);
}
centerPane.add(eastSouthPane, BorderLayout.CENTER);
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")); PreviewCell headerCell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header"));
int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (c > 0) { if (c > 0) {
@ -102,11 +125,7 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
} }
headerCell.setBorderSourceFlag(flag); headerCell.setBorderSourceFlag(flag);
headerCellList.add(headerCell); return headerCell;
eastSouthPane.add(headerCell);
}
centerPane.add(eastSouthPane, BorderLayout.CENTER);
return northPane;
} }
private JPanel createCenterPane() { private JPanel createCenterPane() {
@ -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,7 +146,26 @@ 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);
highLightCellList.add(cell);
} else {
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; int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r != 0) { if (r != 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER; flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
@ -149,9 +174,18 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
} }
cell.setBorderSourceFlag(flag); cell.setBorderSourceFlag(flag);
highLightCellList.add(cell); return cell;
} else { }
cell = new PreviewCell(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text"));
/**
* 创建正文预览单元格
*
* @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; int flag = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER;
if (r > 0) { if (r > 0) {
flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER; flag |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER;
@ -162,19 +196,32 @@ public class WidgetThemeECReportPreviewPane extends UINoOpaquePanel implements T
if (c > 0) { if (c > 0) {
flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; flag |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER;
} }
if (c < CONTENT_ROW_COUNT - 2) { if (c < 1) {
flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; flag |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER;
} }
cell.setBorderSourceFlag(flag); cell.setBorderSourceFlag(flag);
return cell;
}
contentCellList.add(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;
} }
cell.setPreferredSize(new Dimension(123, 31)); if (r < COL_COUNT - 1) {
innerCenterPane.add(cell); flag |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER;
} }
cell.setBorderSourceFlag(flag);
cell.setPreferredSize(new Dimension(113, 31));
return centerPane; headerCellList.add(cell);
gridPane.add(cell);
}
return gridPane;
} }
private JPanel createSouthPane(){ private JPanel createSouthPane(){

75
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 -> {
switch (it) {
case STYLE_TYPE:
initStyle(); initStyle();
break;
case THEME_COLOR:
colorSelectBox = new NewColorSelectBox(160, true); colorSelectBox = new NewColorSelectBox(160, true);
break;
case LINE_TYPE:
lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY); lineComboBox = new LineComboBox(WidgetThemeDisplayConstants.BORDER_LINE_STYLE_ARRAY);
break;
case FONT_SIZE:
fontSizePane = new FontSizeComboPane(); fontSizePane = new FontSizeComboPane();
break;
case BORDER_RADIUS:
borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1);
break;
case FONT:
frFontPane = new FRFontPane(); frFontPane = new FRFontPane();
break;
case BTN_BACKGROUND:
buttonStyleDefinedPane = new ButtonStyleDefinedPane(); buttonStyleDefinedPane = new ButtonStyleDefinedPane();
break; paneMap.put(StyleSetting.STYLE_TYPE, createStyleTypePane());
default: paneMap.put(StyleSetting.THEME_COLOR, colorSelectBox);
break; 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 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