Browse Source

消除严重警告

persist/11.0-arabic
obo 4 months ago
parent
commit
f0be7e2883
  1. 43
      designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java
  2. 6
      designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java
  3. 24
      designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java
  4. 9
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  5. 66
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  6. 1
      designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java

43
designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java

@ -17,44 +17,73 @@ import java.util.Locale;
*/
public class BidiUtils {
/**
* 设计器国际化
*/
private static final Locale LOCALE = DesignerEnvManager.getEnvManager().getLanguage();
private BidiUtils() {
}
/**
* 获取当前设计器语言的组件方向值
*/
public static ComponentOrientation getOrientationByLocale() {
return ComponentOrientation.getOrientation(LOCALE);
}
/**
* 把当前设计器国际化的组件方向应用到组件影响子组件
*
* @param component 组件
* @return 组件对象
* @param <T> Component子类
*/
public static <T extends Component> T applyOrientationByLocale(T component) {
component.applyComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
return component;
}
/**
* 把当前设计器国际化的组件方向设置到组件不影响子组件
*
* @param component 组件
* @return 组件对象
* @param <T> Component子类
*/
public static <T extends Component> T setOrientationByLocale(T component) {
component.setComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
return component;
}
/**
* 设置设计器国际化组件方向到多个组件不影响子组件
*
* @param components 组件数组
*/
public static void setOrientationByLocale(Component... components) {
for (Component component : components) {
component.setComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
}
}
/**
* 应用设计器国际化组件方向到多个组件影响子组件
*
* @param components 组件数组
*/
public static void applyOrientationByLocale(Component... components) {
for (Component component : components) {
component.applyComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
}
}
/**
* 判断当前设计器组件方向是否为rtl
*/
public static boolean rtl() {
return ComponentOrientation.getOrientation(LOCALE) == ComponentOrientation.RIGHT_TO_LEFT;
}
/**
* 拼接字符数组有的组件名是多段字符串拼接起来的如果是rtl的话需要反向拼接
*/
public static String concatenateStrings(String... strs) {
StringBuilder result = new StringBuilder();
@ -70,6 +99,12 @@ public class BidiUtils {
return result.toString();
}
/**
* 根据组件方向调整titleBorder的标题位置
* @param titledBorder
* @return
* @param <T>
*/
public static <T extends TitledBorder> T applyTitledBorderJustification(T titledBorder) {
titledBorder.setTitleJustification(BidiUtils.rtl() ? TitledBorder.RIGHT : TitledBorder.LEFT);
return titledBorder;

6
designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java

@ -22,7 +22,7 @@ import java.awt.Dimension;
*/
public class UILabel extends JLabel implements UITextComponent {
private static final int HTML_SHIFT_HEIGHT = 3;
private static final String COLON = ":";
public UILabel(String text, Icon image, int horizontalAlignment) {
super(text, image, horizontalAlignment);
if (image != null && text != null) {
@ -84,8 +84,8 @@ public class UILabel extends JLabel implements UITextComponent {
return;
}
String text = this.getText();
if (StringUtils.isNotEmpty(text) && text.length() > 1 && text.charAt(text.length() - 1) == ':') {
text = ":" + text.substring(0, text.length() - 1);
if (StringUtils.isNotEmpty(text) && text.length() > 1 && StringUtils.equals(String.valueOf(text.charAt(text.length() - 1)), COLON)) {
text = COLON + text.substring(0, text.length() - 1);
this.setText(text);
}
}

24
designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java

@ -22,6 +22,10 @@ import java.awt.Rectangle;
**/
public class UIMenuItemUI extends BasicMenuItemUI {
private static final int RTL_X = 5;
private static final int ICON_WIDTH = 30;
private static final int ARC = 7;
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
if (menuItem.getIcon() == null) {
@ -35,20 +39,28 @@ public class UIMenuItemUI extends BasicMenuItemUI {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRect(0, 0, menuWidth, menuHeight);
int bidiX = BidiUtils.rtl() ? 5 : 30;
int bidiX = BidiUtils.rtl() ? RTL_X : ICON_WIDTH;
if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
if (itemArmedOrSelected(model, menuItem)) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - ICON_WIDTH, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, ARC);
} else {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7);
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - ICON_WIDTH, menuHeight, true, Constants.NULL, menuItem.getBackground(), ARC);
}
g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7);
} else if (itemArmedOrSelected(model, menuItem)) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - ICON_WIDTH, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, ARC);
g.setColor(oldColor);
}
}
/**
* 按钮被触发或菜单项被选中
* 抽个方法
*/
private boolean itemArmedOrSelected(ButtonModel model, JMenuItem menuItem) {
return model.isArmed() || (menuItem instanceof JMenu && model.isSelected());
}
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
ButtonModel model = menuItem.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);

9
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -83,6 +83,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
private static final int CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH;
private static final int POPUP_TOOLPANE_HEIGHT = 27;
private static final int ARROW_RANGE_START = CONTENT_WIDTH - 30;
private static final int ARROW_WIDTH = 30;
// 弹出对话框高度
private static final int POPUP_MIN_HEIGHT = 145;
private static final int POPUP_DEFAULT_HEIGHT = 356;
@ -1190,7 +1191,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
@Override
public void mouseClicked(MouseEvent e) {
if ((BidiUtils.rtl() && e.getX() <= 30) || (!BidiUtils.rtl() && e.getX() >= ARROW_RANGE_START)) {
if (BidiUtils.rtl() && e.getX() <= ARROW_WIDTH) {
onPop();
} else if (e.getX() >= ARROW_RANGE_START) {
onPop();
}
}
@ -1205,7 +1208,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
@Override
public void mousePressed(MouseEvent e) {
if ((BidiUtils.rtl() && e.getX() > 30) || (!BidiUtils.rtl() && e.getX() < ARROW_RANGE_START)) {
if (BidiUtils.rtl() && e.getX() <= ARROW_WIDTH) {
mouseDownCompCoords = e.getPoint();
} else if (e.getX() >= ARROW_RANGE_START) {
mouseDownCompCoords = e.getPoint();
}
}

66
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -155,7 +155,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
JPanel themeColorPane = new JPanel(new BorderLayout(0, 5));
themeColorPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
themeColorPane.add(createColorSelectPaneLabel(Toolkit.i18nText("Fine-Design_Basic_Theme_Color")), BorderLayout.CENTER);
themeColorPane.add(menuColorPane, BorderLayout.SOUTH);
menuColorPane.setLayout(new BorderLayout(0, 10));
@ -164,22 +163,26 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
menuColorPane.add(northPane, BorderLayout.NORTH);
menuColorPane.add(centerPane, BorderLayout.CENTER);
Color[] colorArray = new Color[]{
// 8列主题色
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
// 2列灰度色
Color.decode("#000000"),
Color.decode("#FFFFFF"),
};
Color[] colorArray = createColorArray();
initThemeColorCellGrid(colorArray);
for (int i = 0; i < colorArray.length; i++) {
northPane.add(themeColorCellGrid[i][0]);
}
for (int i = 0; i < colorArray.length; i++) {
JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 0));
for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) {
columnPane.add(themeColorCellGrid[i][j]);
}
centerPane.add(columnPane);
}
refreshThemeMenuColorPane();
return themeColorPane;
}
/**
* 初始化themeColorCellGrid
*/
private void initThemeColorCellGrid(Color[] colorArray) {
if (themeColorCellGrid == null) {
themeColorCellGrid = new ColorCell[colorArray.length][DEFAULT_DERIVE_COUNT];
for (int i = 0; i < colorArray.length; i++) {
@ -193,20 +196,27 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
themeColorCellGrid[i] = colorCellColumn;
}
}
for (int i = 0; i < colorArray.length; i++) {
northPane.add(themeColorCellGrid[i][0]);
}
for (int i = 0; i < colorArray.length; i++) {
JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 0));
for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) {
columnPane.add(themeColorCellGrid[i][j]);
}
centerPane.add(columnPane);
}
refreshThemeMenuColorPane();
return themeColorPane;
/**
* 创建color数组对象抽方法降复杂度
*/
private Color[] createColorArray() {
return new Color[]{
// 8列主题色
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
// 2列灰度色
Color.decode("#000000"),
Color.decode("#FFFFFF"),
};
}
private void refreshThemeMenuColorPane() {

1
designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java

@ -53,7 +53,6 @@ public class LinkStrUtils {
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
//style.append("margin-bottom:").append("5px").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");
style.append("color:rgb(").append(fontColor.getRed()).append(",").append(fontColor.getGreen()).append(",").append(fontColor.getBlue()).append(");");
style.append("background-color: rgb(").append(backgroundColor.getRed()).append(",").append(backgroundColor.getGreen()).append(",").append(backgroundColor.getBlue()).append(");");

Loading…
Cancel
Save