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