|
|
|
@ -10,6 +10,7 @@ import com.fr.design.i18n.Toolkit;
|
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.design.mainframe.theme.edit.ui.ColorListPane; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.report.core.sort.header.SortHeader; |
|
|
|
|
import com.fr.report.core.sort.common.SortRule; |
|
|
|
|
import org.apache.batik.transcoder.TranscoderInput; |
|
|
|
@ -21,7 +22,10 @@ import java.awt.*;
|
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
public class HeaderSortRulePane extends JPanel { |
|
|
|
|
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 desUICheckBox; |
|
|
|
|
UICheckBox nosortUICheckBox; |
|
|
|
|
static Map<String, String> originalSvgTextMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
HeaderSortRulePane() { |
|
|
|
|
initComponents(); |
|
|
|
@ -166,19 +171,27 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
|
|
|
|
|
Icon getIcon(String iconPath, Color color) { |
|
|
|
|
try { |
|
|
|
|
InputStream inputStream = IOUtils.getResourceAsStream(iconPath, HeaderSortRulePane.class); |
|
|
|
|
String svgText = getSvgText(inputStream); |
|
|
|
|
svgText = svgText.replaceAll("\\{fillColor\\}", shiftColor(color)); |
|
|
|
|
InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes()); |
|
|
|
|
String originalSvgText = getOriginalSvgText(iconPath); |
|
|
|
|
String svgText = originalSvgText.replaceAll("\\{fillColor\\}", shiftColor(color)); |
|
|
|
|
InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
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); |
|
|
|
|
return svgIcon; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e, e.getMessage()); |
|
|
|
|
} |
|
|
|
|
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) { |
|
|
|
|