This commit is contained in:
Kai S. K. Engelbart 2020-03-17 11:08:58 +01:00
parent ba222deec9
commit 5f2b05dcce

View File

@ -35,7 +35,7 @@ public class MessageListRenderer implements ComponentListCellRenderer<Message> {
static { static {
try { try {
statusIcons = IconUtil.loadByEnum(MessageStatus.class, 16); statusIcons = IconUtil.loadByEnum(MessageStatus.class, 16);
// forwardIcon = IconUtil.load("icons/forward.png", 16); forwardIcon = IconUtil.load("icons/forward.png", 16);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -43,6 +43,14 @@ public class MessageListRenderer implements ComponentListCellRenderer<Message> {
private final long senderId; private final long senderId;
/**
* Initializes a message list renderer. Messages with the given sender ID will
* be aligned on the right side, while all other messages will be aligned on
* the left side
*
* @param senderId the sender ID of the messages to align on the right side
* @since Envoy v0.1-beta
*/
public MessageListRenderer(long senderId) { this.senderId = senderId; } public MessageListRenderer(long senderId) { this.senderId = senderId; }
// TODO: Handle message attachments // TODO: Handle message attachments
@ -87,9 +95,6 @@ public class MessageListRenderer implements ComponentListCellRenderer<Message> {
messageTextArea.setEditable(false); messageTextArea.setEditable(false);
var font = new Font("Arial", Font.PLAIN, 14); var font = new Font("Arial", Font.PLAIN, 14);
messageTextArea.setFont(font); messageTextArea.setFont(font);
// var frc = new FontRenderContext(new AffineTransform(), true, true);
// messageTextArea.setSize(Math.min(list.getWidth() - padding, (int)
// font.getStringBounds(message.getText(), frc).getWidth()), 10);
messageTextArea.setSize(list.getWidth() - padding - 16, 10); messageTextArea.setSize(list.getWidth() - padding - 16, 10);
var gbc_messageTextArea = new GridBagConstraints(); var gbc_messageTextArea = new GridBagConstraints();
@ -102,15 +107,13 @@ public class MessageListRenderer implements ComponentListCellRenderer<Message> {
var statusLabel = new JLabel(statusIcons.get(message.getStatus())); var statusLabel = new JLabel(statusIcons.get(message.getStatus()));
var gbc_statusLabel = new GridBagConstraints(); var gbc_statusLabel = new GridBagConstraints();
// gbc_statusLabel.fill = GridBagConstraints.BOTH;
gbc_statusLabel.gridx = 1; gbc_statusLabel.gridx = 1;
gbc_statusLabel.gridy = 1; gbc_statusLabel.gridy = 1;
panel.add(statusLabel, gbc_statusLabel); panel.add(statusLabel, gbc_statusLabel);
// Forwarding // Forwarding
if (message.isForwarded()) { if (message.isForwarded()) {
// TODO: icon var forwardLabel = new JLabel("Forwarded", forwardIcon, SwingConstants.CENTER);
var forwardLabel = new JLabel("Forwarded", null, SwingConstants.CENTER);
forwardLabel.setBackground(panel.getBackground()); forwardLabel.setBackground(panel.getBackground());
forwardLabel.setForeground(Color.lightGray); forwardLabel.setForeground(Color.lightGray);