|
|
|
@ -32,6 +32,7 @@ import java.awt.event.MouseEvent;
|
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.function.Supplier; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -151,18 +152,31 @@ public class NotificationDialog extends JDialog {
|
|
|
|
|
} |
|
|
|
|
return new UILabel(LinkStrUtils.generateHtmlTag(messageModel.format())); |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
Function<Double, Integer> calStandardWidth = e -> e > 4 ? 280 : 300; |
|
|
|
|
|
|
|
|
|
int widthUnit = messageComponents.stream() |
|
|
|
|
.map((component) -> { |
|
|
|
|
Dimension preferredSize = component.getPreferredSize(); |
|
|
|
|
return preferredSize.getHeight(); |
|
|
|
|
}) |
|
|
|
|
.reduce(Double::sum) |
|
|
|
|
.map(calStandardWidth) |
|
|
|
|
.orElse(300); |
|
|
|
|
|
|
|
|
|
messageComponents = messageComponents.stream() |
|
|
|
|
.peek((component) -> { |
|
|
|
|
Dimension preferredSize = component.getPreferredSize(); |
|
|
|
|
double componentWidth = preferredSize.getWidth(); |
|
|
|
|
double componentHeight = preferredSize.getHeight(); |
|
|
|
|
double widthFactor = Math.ceil(componentWidth / 300); |
|
|
|
|
double heightFactor = Math.ceil(componentHeight / 15); |
|
|
|
|
double widthFactor = Math.ceil(componentWidth / widthUnit); |
|
|
|
|
int realHeight = (int) (heightFactor + widthFactor - 1) * 15; |
|
|
|
|
component.setPreferredSize(new Dimension(300, realHeight)); |
|
|
|
|
|
|
|
|
|
component.setPreferredSize(new Dimension(widthUnit, realHeight)); |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 竖向排列
|
|
|
|
|
JPanel messageSummaryPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 0); |
|
|
|
|
messageComponents.forEach(messageSummaryPanel::add); |
|
|
|
|