diff options
author | Vincent Lucas <chenzo@jitsi.org> | 2008-07-15 17:21:13 +0000 |
---|---|---|
committer | Vincent Lucas <chenzo@jitsi.org> | 2008-07-15 17:21:13 +0000 |
commit | bcc63e7a1ef85b012a6a27df2b73694d45f44170 (patch) | |
tree | c2623eecf56d99c4022af7d5ee1a14fd8068f26c /src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java | |
parent | 4d6ef5c1a88e76ded58f53e35ac67a0e948e1a76 (diff) | |
download | jitsi-bcc63e7a1ef85b012a6a27df2b73694d45f44170.zip jitsi-bcc63e7a1ef85b012a6a27df2b73694d45f44170.tar.gz jitsi-bcc63e7a1ef85b012a6a27df2b73694d45f44170.tar.bz2 |
Resolving issue #428: Aspect ratio is not respected when rescaling contact image (patch from Sébastien Mazy).
Diffstat (limited to 'src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java')
-rw-r--r-- | src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java index 2b7252e..41b28f8 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java @@ -15,6 +15,7 @@ import java.text.DateFormat; import javax.swing.*;
import javax.swing.event.*;
+import net.java.sip.communicator.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.*;
@@ -45,6 +46,16 @@ public class ContactInfoDetailsPanel private Contact contact;
/**
+ * The default width of hte avater area.
+ */
+ private final int AVATAR_AREA_WIDTH = 105;
+
+ /**
+ * The default height of hte avater area.
+ */
+ private final int AVATAR_AREA_HEIGHT = 130;
+
+ /**
* Construct a tabbed pane that will have one tab with a summary of info for
* the selected subcontact and one tab for all of the extended details.
*/
@@ -171,11 +182,19 @@ public class ContactInfoDetailsPanel else
avatarImage = Resources.getImage("contactInfoDefaultPersonIcon");
- ImageIcon scaledImage =
- new ImageIcon(avatarImage.getImage().getScaledInstance(105, 130,
- Image.SCALE_SMOOTH));
+ ImageIcon scaledImage = ImageUtils.scaleIconWithinBounds(
+ avatarImage,
+ AVATAR_AREA_WIDTH,
+ AVATAR_AREA_HEIGHT
+ );
JLabel label = new JLabel(scaledImage);
+ label.setVerticalAlignment(JLabel.CENTER);
+ label.setHorizontalAlignment(JLabel.CENTER);
+ label.setPreferredSize(new Dimension(
+ AVATAR_AREA_WIDTH,
+ AVATAR_AREA_HEIGHT)
+ );
avatarPanel.add(label);
summaryPanel.add(avatarPanel, BorderLayout.WEST);
@@ -487,4 +506,4 @@ public class ContactInfoDetailsPanel return mainExtendedPanel;
}
-}
\ No newline at end of file +}
|