Display thumbnail if one is available on creation

dbus-notify
Zlatin Balevsky 2022-06-04 07:23:56 +01:00
parent b22dbcf4d0
commit e374833681
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 18 additions and 12 deletions

View File

@ -60,12 +60,7 @@ class ViewProfileView {
borderLayout()
panel(border: titledBorder(title : trans("PROFILE_VIEWER_HEADER"), border: etchedBorder(),
titlePosition: TitledBorder.TOP), constraints: BorderLayout.NORTH) {
if (model.profileHeader == null)
thumbnailPanel = panel(preferredSize: [ProfileConstants.MAX_THUMBNAIL_SIZE, ProfileConstants.MAX_THUMBNAIL_SIZE])
else {
Icon thumbNail = new ThumbnailIcon(model.profileHeader.getThumbNail())
thumbnailPanel = panel(icon: thumbNail.image)
}
thumbnailPanel = panel(preferredSize: [ProfileConstants.MAX_THUMBNAIL_SIZE, ProfileConstants.MAX_THUMBNAIL_SIZE])
if (model.profileTitle == null)
titleLabel = label(text: trans("PROFILE_VIEWER_HEADER_MISSING"))
else
@ -113,12 +108,19 @@ class ViewProfileView {
}
}
window.setPreferredSize([dimX, dimY] as Dimension)
}
void mvcGroupInit(Map<String, String> params) {
window.addWindowListener(new WindowAdapter() {
@Override
void windowOpened(WindowEvent e) {
if (model.profileHeader != null) {
Icon thumbNail = new ThumbnailIcon(model.profileHeader.getThumbNail())
drawThumbnail(thumbNail)
}
}
@Override
void windowClosed(WindowEvent e) {
mvcGroup.destroy()
@ -141,11 +143,7 @@ class ViewProfileView {
SwingUtilities.invokeLater {
Icon thumbNail = new ThumbnailIcon(profile.getHeader().getThumbNail())
def thumbDim = thumbnailPanel.getSize()
thumbnailPanel.getGraphics().drawImage(thumbNail.image,
(int)(thumbDim.getWidth() / 2) - (int)(thumbNail.getIconHeight() / 2),
(int)(thumbDim.getHeight() / 2) - (int)(thumbNail.getIconHeight() / 2),
null)
drawThumbnail(thumbNail)
def imgDim = imagePanel.getSize()
imagePanel.getGraphics().drawImage(mainImage,
@ -154,4 +152,12 @@ class ViewProfileView {
null)
} as Runnable
}
private void drawThumbnail(ThumbnailIcon thumbNail) {
def thumbDim = thumbnailPanel.getSize()
thumbnailPanel.getGraphics().drawImage(thumbNail.image,
(int)(thumbDim.getWidth() / 2) - (int)(thumbNail.getIconHeight() / 2),
(int)(thumbDim.getHeight() / 2) - (int)(thumbNail.getIconHeight() / 2),
null)
}
}