|
|
|
@ -31,6 +31,8 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
private static final String ASC_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/asc.svg"; |
|
|
|
|
private static final String DES_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/des.svg"; |
|
|
|
|
private static final String NOSORT_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/nosort.svg"; |
|
|
|
|
private static final double ICON_SCALE = SVGIcon.SYSTEM_SCALE * 1.25; |
|
|
|
|
private static final int ICON_LENGTH = (int) Math.ceil(16 * ICON_SCALE); |
|
|
|
|
IconButton ascIconButton; |
|
|
|
|
IconButton desIconButton; |
|
|
|
|
IconButton nosortIconButton; |
|
|
|
@ -63,8 +65,8 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
new Component[]{desUICheckBox = new UICheckBox(SortRule.DES.getDescription()), desIconButton = new IconButton(DES_ICON_TEMPLATE_PATH)}, |
|
|
|
|
new Component[]{nosortUICheckBox = new UICheckBox(SortRule.NO_SORT.getDescription()), nosortIconButton = new IconButton(NOSORT_ICON_TEMPLATE_PATH)}, |
|
|
|
|
}; |
|
|
|
|
double[] rowSize = {24, 24, 24}; |
|
|
|
|
double[] columnSize = {80, 30}; |
|
|
|
|
double[] rowSize = {ICON_LENGTH + 10, ICON_LENGTH + 10, ICON_LENGTH + 10}; |
|
|
|
|
double[] columnSize = {80, ICON_LENGTH + 10}; |
|
|
|
|
JPanel sortRuleItem = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 0); |
|
|
|
|
this.add(sortRuleItem, BorderLayout.CENTER); |
|
|
|
|
initUICheckBoxChange(ascUICheckBox, ascIconButton); |
|
|
|
@ -125,12 +127,12 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
jLayeredPane = new JLayeredPane(); |
|
|
|
|
iconLabel = getIconLabel(iconTemplatePath); |
|
|
|
|
borderUiLabel = new UILabel(); |
|
|
|
|
borderUiLabel.setSize(16, 16); |
|
|
|
|
borderUiLabel.setSize(ICON_LENGTH, ICON_LENGTH); |
|
|
|
|
borderUiLabel.setOpaque(true); |
|
|
|
|
borderUiLabel.setBackground(Color.WHITE); |
|
|
|
|
iconLabel.setSize(16, 16); |
|
|
|
|
iconLabel.setSize(ICON_LENGTH, ICON_LENGTH); |
|
|
|
|
colorButton = new ColorListPane.ColorButton(Color.CYAN); |
|
|
|
|
colorButton.setSize(16, 16); |
|
|
|
|
colorButton.setSize(ICON_LENGTH, ICON_LENGTH); |
|
|
|
|
colorButton.addChangeListener(new ChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void stateChanged(ChangeEvent e) { |
|
|
|
@ -139,7 +141,7 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
uiObserverListener.doChange(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
jLayeredPane.setPreferredSize(new Dimension(16, 16)); |
|
|
|
|
jLayeredPane.setPreferredSize(new Dimension(ICON_LENGTH, ICON_LENGTH)); |
|
|
|
|
|
|
|
|
|
jLayeredPane.add(iconLabel, JLayeredPane.POPUP_LAYER); |
|
|
|
|
jLayeredPane.add(borderUiLabel, JLayeredPane.MODAL_LAYER); |
|
|
|
@ -152,6 +154,14 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
refreshIconLabel(icon); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void refreshIconLabel(BufferedImage bufferedImage) { |
|
|
|
|
if (bufferedImage != null) { |
|
|
|
|
this.bufferedImage = bufferedImage; |
|
|
|
|
Icon icon = new SVGIcon(bufferedImage); |
|
|
|
|
refreshIconLabel(icon); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void refreshIconLabel(Icon icon) { |
|
|
|
|
if (icon != null) { |
|
|
|
|
iconLabel.removeAll(); |
|
|
|
@ -175,7 +185,7 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
String svgText = originalSvgText.replaceAll("\\{fillColor\\}", shiftColor(color)); |
|
|
|
|
InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
TranscoderInput input = new TranscoderInput(svgInputStream); |
|
|
|
|
bufferedImage = SVGTranscoder.createImage(SVGIcon.SYSTEM_SCALE, input).getImage(); |
|
|
|
|
bufferedImage = SVGTranscoder.createImage(ICON_SCALE, input).getImage(); |
|
|
|
|
SVGIcon svgIcon = new SVGIcon(bufferedImage); |
|
|
|
|
return svgIcon; |
|
|
|
|
} catch (Exception e) { |
|
|
|
@ -203,12 +213,11 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String shiftValue(int value) { |
|
|
|
|
int resultValue = (int) ((((float) value) / 255) * 99); |
|
|
|
|
if (resultValue < 10) { |
|
|
|
|
return "0" + resultValue; |
|
|
|
|
} else { |
|
|
|
|
return "" + resultValue; |
|
|
|
|
String resultValue = Integer.toHexString(value); |
|
|
|
|
if (resultValue.length() == 1) { |
|
|
|
|
resultValue = "0" + resultValue; |
|
|
|
|
} |
|
|
|
|
return resultValue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getSvgText(InputStream inputStream) throws Exception { |
|
|
|
@ -237,18 +246,14 @@ public class HeaderSortRulePane extends JPanel {
|
|
|
|
|
for (SortHeader.SortItem sortItem : sortItems) { |
|
|
|
|
SortRule sortRule = sortItem.getSortRule(); |
|
|
|
|
BufferedImage bufferedImage = sortItem.getBufferedImage(); |
|
|
|
|
Icon icon = null; |
|
|
|
|
if (bufferedImage != null) { |
|
|
|
|
icon = new SVGIcon(bufferedImage); |
|
|
|
|
} |
|
|
|
|
if (sortRule == SortRule.ASC) { |
|
|
|
|
ascIconButton.refreshIconLabel(icon); |
|
|
|
|
ascIconButton.refreshIconLabel(bufferedImage); |
|
|
|
|
ascUICheckBox.setSelected(true); |
|
|
|
|
} else if (sortRule == SortRule.DES) { |
|
|
|
|
desIconButton.refreshIconLabel(icon); |
|
|
|
|
desIconButton.refreshIconLabel(bufferedImage); |
|
|
|
|
desUICheckBox.setSelected(true); |
|
|
|
|
} else if (sortRule == SortRule.NO_SORT) { |
|
|
|
|
nosortIconButton.refreshIconLabel(icon); |
|
|
|
|
nosortIconButton.refreshIconLabel(bufferedImage); |
|
|
|
|
nosortUICheckBox.setSelected(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|