diff options
author | Yana Stamcheva <yana@jitsi.org> | 2009-10-30 11:37:19 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2009-10-30 11:37:19 +0000 |
commit | cf8a7b04a68737b626c5bd86818a45d2ae0ae30a (patch) | |
tree | 36a3a6e3c36d4c9acefdd91905554b806eb3a42c /src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java | |
parent | 86901fcffa1438058738f4ba14d56b217d7eb0c1 (diff) | |
download | jitsi-cf8a7b04a68737b626c5bd86818a45d2ae0ae30a.zip jitsi-cf8a7b04a68737b626c5bd86818a45d2ae0ae30a.tar.gz jitsi-cf8a7b04a68737b626c5bd86818a45d2ae0ae30a.tar.bz2 |
Drag'n'Drop related implementations including:
- dropping MetaContact-s or simple String addresses in the Call dialog would initiate an invite and hence the creation of a conference call or if such already exist just the adding of the new callee to the conference.
- added the possibility to drag the number entered in the call field on the bottom of the contact list.
- replaced previous implementation of Drag'n'Drop in the contact list with the default drag'n'drop mechanism used in java, thus allowing the dropping of contacts outside the contact list (like in an existing call, chat or simply as a string in any other desktop application)
- extended and override the default TransferHandler to provide visual representation of the dragged object (special handling of MetaContacts is provided in the ContactListCellRenderer) and add support of MetaContact flavor.
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java index a1a868c..5ac0693 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListCellRenderer.java @@ -27,7 +27,8 @@ import net.java.sip.communicator.util.swing.*; */ public class ContactListCellRenderer extends JPanel - implements ListCellRenderer + implements ListCellRenderer, + Icon { private static final int AVATAR_HEIGHT = 30; @@ -116,8 +117,10 @@ public class ContactListCellRenderer this.nameLabel.setPreferredSize(new Dimension(10, 17)); + this.rightLabel.setPreferredSize( + new Dimension(AVATAR_WIDTH, AVATAR_HEIGHT)); this.rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); - this.rightLabel.setHorizontalAlignment(JLabel.RIGHT); + this.rightLabel.setHorizontalAlignment(JLabel.CENTER); this.add(nameLabel, BorderLayout.CENTER); this.add(rightLabel, BorderLayout.EAST); @@ -331,4 +334,63 @@ public class ContactListCellRenderer 10, 10); } } + + /** + * Returns the height of this icon. + * @return the height of this icon + */ + public int getIconHeight() + { + return this.getHeight() + 10; + } + + /** + * Returns the width of this icon. + * @return the widht of this icon + */ + public int getIconWidth() + { + return this.getWidth() + 10; + } + + /** + * Draw the icon at the specified location. Paints this component as an + * icon. + * @param c the component which can be used as observer + * @param g the <tt>Graphics</tt> object used for painting + * @param x the position on the X coordinate + * @param y the position on the Y coordinate + */ + public void paintIcon(Component c, Graphics g, int x, int y) + { + Graphics2D g2 = (Graphics2D) g.create(); + try + { + AntialiasingManager.activateAntialiasing(g2); + + g2.setColor(Color.WHITE); + g2.setComposite(AlphaComposite. + getInstance(AlphaComposite.SRC_OVER, 0.8f)); + g2.fillRoundRect(x, y, + getIconWidth() - 1, getIconHeight() - 1, + 10, 10); + g2.setColor(Color.DARK_GRAY); + g2.drawRoundRect(x, y, + getIconWidth() - 1, getIconHeight() - 1, + 10, 10); + + // Indent component content from the border. + g2.translate(x + 5, y + 5); + + // Paint component. + super.paint(g2); + + // + g2.translate(x, y); + } + finally + { + g.dispose(); + } + } } |