Browse Source

Pull request #4: 消除严重警告

Merge in ~OBO/design from arabic to persist/11.0-arabic

* commit 'f0be7e2883a6133b0256faa4149295d533ce33c0':
  消除严重警告
persist/11.0-arabic
Obo-王学仁 7 months ago
parent
commit
199f38fa48
  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. 26
      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 { public class BidiUtils {
/**
* 设计器国际化
*/
private static final Locale LOCALE = DesignerEnvManager.getEnvManager().getLanguage(); private static final Locale LOCALE = DesignerEnvManager.getEnvManager().getLanguage();
private BidiUtils() { private BidiUtils() {
} }
/**
* 获取当前设计器语言的组件方向值
*/
public static ComponentOrientation getOrientationByLocale() { public static ComponentOrientation getOrientationByLocale() {
return ComponentOrientation.getOrientation(LOCALE); return ComponentOrientation.getOrientation(LOCALE);
} }
/**
* 把当前设计器国际化的组件方向应用到组件影响子组件
*
* @param component 组件
* @return 组件对象
* @param <T> Component子类
*/
public static <T extends Component> T applyOrientationByLocale(T component) { public static <T extends Component> T applyOrientationByLocale(T component) {
component.applyComponentOrientation(ComponentOrientation.getOrientation(LOCALE)); component.applyComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
return component; return component;
} }
/**
* 把当前设计器国际化的组件方向设置到组件不影响子组件
*
* @param component 组件
* @return 组件对象
* @param <T> Component子类
*/
public static <T extends Component> T setOrientationByLocale(T component) { public static <T extends Component> T setOrientationByLocale(T component) {
component.setComponentOrientation(ComponentOrientation.getOrientation(LOCALE)); component.setComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
return component; return component;
} }
/**
* 设置设计器国际化组件方向到多个组件不影响子组件
*
* @param components 组件数组
*/
public static void setOrientationByLocale(Component... components) { public static void setOrientationByLocale(Component... components) {
for (Component component : components) { for (Component component : components) {
component.setComponentOrientation(ComponentOrientation.getOrientation(LOCALE)); component.setComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
} }
} }
/**
* 应用设计器国际化组件方向到多个组件影响子组件
*
* @param components 组件数组
*/
public static void applyOrientationByLocale(Component... components) { public static void applyOrientationByLocale(Component... components) {
for (Component component : components) { for (Component component : components) {
component.applyComponentOrientation(ComponentOrientation.getOrientation(LOCALE)); component.applyComponentOrientation(ComponentOrientation.getOrientation(LOCALE));
} }
} }
/**
* 判断当前设计器组件方向是否为rtl
*/
public static boolean rtl() { public static boolean rtl() {
return ComponentOrientation.getOrientation(LOCALE) == ComponentOrientation.RIGHT_TO_LEFT; return ComponentOrientation.getOrientation(LOCALE) == ComponentOrientation.RIGHT_TO_LEFT;
} }
/**
* 拼接字符数组有的组件名是多段字符串拼接起来的如果是rtl的话需要反向拼接
*/
public static String concatenateStrings(String... strs) { public static String concatenateStrings(String... strs) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
@ -70,6 +99,12 @@ public class BidiUtils {
return result.toString(); return result.toString();
} }
/**
* 根据组件方向调整titleBorder的标题位置
* @param titledBorder
* @return
* @param <T>
*/
public static <T extends TitledBorder> T applyTitledBorderJustification(T titledBorder) { public static <T extends TitledBorder> T applyTitledBorderJustification(T titledBorder) {
titledBorder.setTitleJustification(BidiUtils.rtl() ? TitledBorder.RIGHT : TitledBorder.LEFT); titledBorder.setTitleJustification(BidiUtils.rtl() ? TitledBorder.RIGHT : TitledBorder.LEFT);
return titledBorder; 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 { public class UILabel extends JLabel implements UITextComponent {
private static final int HTML_SHIFT_HEIGHT = 3; private static final int HTML_SHIFT_HEIGHT = 3;
private static final String COLON = ":";
public UILabel(String text, Icon image, int horizontalAlignment) { public UILabel(String text, Icon image, int horizontalAlignment) {
super(text, image, horizontalAlignment); super(text, image, horizontalAlignment);
if (image != null && text != null) { if (image != null && text != null) {
@ -84,8 +84,8 @@ public class UILabel extends JLabel implements UITextComponent {
return; return;
} }
String text = this.getText(); String text = this.getText();
if (StringUtils.isNotEmpty(text) && text.length() > 1 && text.charAt(text.length() - 1) == ':') { if (StringUtils.isNotEmpty(text) && text.length() > 1 && StringUtils.equals(String.valueOf(text.charAt(text.length() - 1)), COLON)) {
text = ":" + text.substring(0, text.length() - 1); text = COLON + text.substring(0, text.length() - 1);
this.setText(text); this.setText(text);
} }
} }

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

@ -21,7 +21,11 @@ import java.awt.Rectangle;
* created by Harrison on 2020/03/22 * created by Harrison on 2020/03/22
**/ **/
public class UIMenuItemUI extends BasicMenuItemUI { 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 @Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
if (menuItem.getIcon() == null) { if (menuItem.getIcon() == null) {
@ -35,20 +39,28 @@ public class UIMenuItemUI extends BasicMenuItemUI {
g.setColor(UIConstants.NORMAL_BACKGROUND); g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRect(0, 0, menuWidth, menuHeight); g.fillRect(0, 0, menuWidth, menuHeight);
int bidiX = BidiUtils.rtl() ? 5 : 30; int bidiX = BidiUtils.rtl() ? RTL_X : ICON_WIDTH;
if (menuItem.isOpaque()) { if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { if (itemArmedOrSelected(model, menuItem)) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - ICON_WIDTH, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, ARC);
} else { } 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); g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { } else if (itemArmedOrSelected(model, menuItem)) {
GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, menuWidth - ICON_WIDTH, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, ARC);
g.setColor(oldColor); 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) { protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
ButtonModel model = menuItem.getModel(); ButtonModel model = menuItem.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); 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 CONTENT_WIDTH = CONTAINER_WIDTH - TAB_WIDTH;
private static final int POPUP_TOOLPANE_HEIGHT = 27; private static final int POPUP_TOOLPANE_HEIGHT = 27;
private static final int ARROW_RANGE_START = CONTENT_WIDTH - 30; 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_MIN_HEIGHT = 145;
private static final int POPUP_DEFAULT_HEIGHT = 356; private static final int POPUP_DEFAULT_HEIGHT = 356;
@ -1190,7 +1191,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
@Override @Override
public void mouseClicked(MouseEvent e) { 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(); onPop();
} }
} }
@ -1205,7 +1208,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
@Override @Override
public void mousePressed(MouseEvent e) { 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(); 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)); JPanel themeColorPane = new JPanel(new BorderLayout(0, 5));
themeColorPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); themeColorPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
themeColorPane.add(createColorSelectPaneLabel(Toolkit.i18nText("Fine-Design_Basic_Theme_Color")), BorderLayout.CENTER); themeColorPane.add(createColorSelectPaneLabel(Toolkit.i18nText("Fine-Design_Basic_Theme_Color")), BorderLayout.CENTER);
themeColorPane.add(menuColorPane, BorderLayout.SOUTH); themeColorPane.add(menuColorPane, BorderLayout.SOUTH);
menuColorPane.setLayout(new BorderLayout(0, 10)); menuColorPane.setLayout(new BorderLayout(0, 10));
@ -164,22 +163,26 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
menuColorPane.add(northPane, BorderLayout.NORTH); menuColorPane.add(northPane, BorderLayout.NORTH);
menuColorPane.add(centerPane, BorderLayout.CENTER); menuColorPane.add(centerPane, BorderLayout.CENTER);
Color[] colorArray = new Color[]{ Color[] colorArray = createColorArray();
// 8列主题色 initThemeColorCellGrid(colorArray);
Color.decode("#FFFFFF"), for (int i = 0; i < colorArray.length; i++) {
Color.decode("#CCCCCC"), northPane.add(themeColorCellGrid[i][0]);
Color.decode("#FFFFFF"), }
Color.decode("#CCCCCC"), for (int i = 0; i < colorArray.length; i++) {
Color.decode("#FFFFFF"), JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 0));
Color.decode("#CCCCCC"), for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) {
Color.decode("#FFFFFF"), columnPane.add(themeColorCellGrid[i][j]);
Color.decode("#CCCCCC"), }
centerPane.add(columnPane);
// 2列灰度色 }
Color.decode("#000000"), refreshThemeMenuColorPane();
Color.decode("#FFFFFF"), return themeColorPane;
}; }
/**
* 初始化themeColorCellGrid
*/
private void initThemeColorCellGrid(Color[] colorArray) {
if (themeColorCellGrid == null) { if (themeColorCellGrid == null) {
themeColorCellGrid = new ColorCell[colorArray.length][DEFAULT_DERIVE_COUNT]; themeColorCellGrid = new ColorCell[colorArray.length][DEFAULT_DERIVE_COUNT];
for (int i = 0; i < colorArray.length; i++) { for (int i = 0; i < colorArray.length; i++) {
@ -193,20 +196,27 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
themeColorCellGrid[i] = colorCellColumn; themeColorCellGrid[i] = colorCellColumn;
} }
} }
}
for (int i = 0; i < colorArray.length; i++) { /**
northPane.add(themeColorCellGrid[i][0]); * 创建color数组对象抽方法降复杂度
} */
for (int i = 0; i < colorArray.length; i++) { private Color[] createColorArray() {
JPanel columnPane = new JPanel(new GridLayout(DEFAULT_DERIVE_COUNT - 1, 1, 0, 0)); return new Color[]{
for (int j = 1; j < DEFAULT_DERIVE_COUNT; j++) { // 8列主题色
columnPane.add(themeColorCellGrid[i][j]); Color.decode("#FFFFFF"),
} Color.decode("#CCCCCC"),
centerPane.add(columnPane); Color.decode("#FFFFFF"),
} Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
Color.decode("#FFFFFF"),
Color.decode("#CCCCCC"),
refreshThemeMenuColorPane(); // 2列灰度色
return themeColorPane; Color.decode("#000000"),
Color.decode("#FFFFFF"),
};
} }
private void refreshThemeMenuColorPane() { 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() + ";"); StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";"); 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("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("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(");"); style.append("background-color: rgb(").append(backgroundColor.getRed()).append(",").append(backgroundColor.getGreen()).append(",").append(backgroundColor.getBlue()).append(");");

Loading…
Cancel
Save