Browse Source

Pull request #7206: REPORT-62440 表头排序内置

Merge in DESIGN/design from ~HENRY.WANG/design:feature/x to feature/x

* commit '3f09f2e7183a325c5bc04da766ebd912d4c8ece5':
  REPORT-62440 表头排序内置
feature/x
Henry.Wang 3 years ago
parent
commit
eb2f77d365
  1. 25
      designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java

25
designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java

@ -10,6 +10,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.theme.edit.ui.ColorListPane; import com.fr.design.mainframe.theme.edit.ui.ColorListPane;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.core.sort.header.SortHeader; import com.fr.report.core.sort.header.SortHeader;
import com.fr.report.core.sort.common.SortRule; import com.fr.report.core.sort.common.SortRule;
import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderInput;
@ -21,7 +22,10 @@ import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class HeaderSortRulePane extends JPanel { public class HeaderSortRulePane extends JPanel {
private static final String ASC_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/asc.svg"; private static final String ASC_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/asc.svg";
@ -33,6 +37,7 @@ public class HeaderSortRulePane extends JPanel {
UICheckBox ascUICheckBox; UICheckBox ascUICheckBox;
UICheckBox desUICheckBox; UICheckBox desUICheckBox;
UICheckBox nosortUICheckBox; UICheckBox nosortUICheckBox;
static Map<String, String> originalSvgTextMap = new HashMap<>();
HeaderSortRulePane() { HeaderSortRulePane() {
initComponents(); initComponents();
@ -166,19 +171,27 @@ public class HeaderSortRulePane extends JPanel {
Icon getIcon(String iconPath, Color color) { Icon getIcon(String iconPath, Color color) {
try { try {
InputStream inputStream = IOUtils.getResourceAsStream(iconPath, HeaderSortRulePane.class); String originalSvgText = getOriginalSvgText(iconPath);
String svgText = getSvgText(inputStream); String svgText = originalSvgText.replaceAll("\\{fillColor\\}", shiftColor(color));
svgText = svgText.replaceAll("\\{fillColor\\}", shiftColor(color)); InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes(StandardCharsets.UTF_8));
InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes());
TranscoderInput input = new TranscoderInput(svgInputStream); TranscoderInput input = new TranscoderInput(svgInputStream);
bufferedImage = SVGTranscoder.createImage(1.0, input).getImage(); bufferedImage = SVGTranscoder.createImage(SVGIcon.SYSTEM_SCALE, input).getImage();
SVGIcon svgIcon = new SVGIcon(bufferedImage); SVGIcon svgIcon = new SVGIcon(bufferedImage);
return svgIcon; return svgIcon;
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
} }
return null; return null;
}
String getOriginalSvgText(String iconPath) throws Exception {
String originalSvgText = originalSvgTextMap.get(iconPath);
if (originalSvgText == null) {
InputStream inputStream = IOUtils.getResourceAsStream(iconPath, HeaderSortRulePane.class);
originalSvgText = getSvgText(inputStream);
originalSvgTextMap.put(iconPath, originalSvgText);
}
return originalSvgText;
} }
String shiftColor(Color color) { String shiftColor(Color color) {

Loading…
Cancel
Save