帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

package com.fr.base.i18n;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.util.Locale;
/**
* 根据国际化获取组件方向
*
* @author obo
* @since 11.0
* Created on 2024/07/17
*/
public class BidiUtils {
//private static final Locale ar = new Locale("ar", "SA");
private static final Locale ar = Locale.CHINA;
private BidiUtils() {
}
public static ComponentOrientation getOrientationByLocale() {
return ComponentOrientation.getOrientation(ar);
}
public static <T extends Component> T applyOrientationByLocale(T component) {
component.applyComponentOrientation(ComponentOrientation.getOrientation(ar));
return component;
}
public static <T extends Component> T setOrientationByLocale(T component) {
component.setComponentOrientation(ComponentOrientation.getOrientation(ar));
return component;
}
public static void applyOrientationByLocale(Component... components) {
for (Component component : components) {
component.applyComponentOrientation(ComponentOrientation.getOrientation(ar));
}
}
public static boolean rtl() {
return ComponentOrientation.getOrientation(ar) == ComponentOrientation.RIGHT_TO_LEFT;
}
public static String reverseConcatenateStrings(String... strs) {
StringBuilder result = new StringBuilder();
if (rtl()) {
for (int i = strs.length - 1; i >= 0; i--) {
result.append(strs[i]);
}
} else {
for (int i = 0; i <= strs.length - 1; i++) {
result.append(strs[i]);
}
}
return result.toString();
}
}