aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2009-05-12 15:31:17 +0000
committerYana Stamcheva <yana@jitsi.org>2009-05-12 15:31:17 +0000
commit5e8f7072ef7bbf110f47afa281068f86e8dee9b3 (patch)
tree966d1c9ed90a6fa8c99932c005cf7a0fc4d51568
parentcaa08d9d2e4aff50924420ea4a06a1b46028c255 (diff)
downloadjitsi-5e8f7072ef7bbf110f47afa281068f86e8dee9b3.zip
jitsi-5e8f7072ef7bbf110f47afa281068f86e8dee9b3.tar.gz
jitsi-5e8f7072ef7bbf110f47afa281068f86e8dee9b3.tar.bz2
Fixing issue #669 (Broken smiles preivew on linux and windows).
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java3
-rwxr-xr-xsrc/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java5
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java9
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java3
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java9
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java3
-rw-r--r--src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java268
-rw-r--r--src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java18
8 files changed, 116 insertions, 202 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java b/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java
index bb43799..146100a 100644
--- a/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java
@@ -245,8 +245,7 @@ public class NewAccountDialog
if( icon != null && icon.length > 0)
{
- this.setIcon(new ImageIcon(
- ImageLoader.getBytesInImage(icon)));
+ this.setIcon(new ImageIcon(icon));
}
else
{
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
index 768e95a..beea01f 100755
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
@@ -10,6 +10,7 @@ import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import java.io.*;
+import java.net.*;
import java.util.*;
import java.util.regex.*;
@@ -319,8 +320,8 @@ public class ChatConversationPanel
endHeaderTag = "</h6>";
String errorIcon = "<IMG SRC='"
- + ImageLoader.getImagePath(ImageLoader
- .getImage(ImageLoader.EXCLAMATION_MARK)) + "' </IMG>";
+ + ImageLoader.getImageUri(ImageLoader.EXCLAMATION_MARK)
+ + "' </IMG>";
chatString += errorIcon
+ GuiActivator.getResources()
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java
index e7fd912..a626be4 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/SmileysSelectorBox.java
@@ -227,11 +227,9 @@ public class SmileysSelectorBox
Smiley smiley = smileysList.get(smileyItem);
- String smileyIconHtml = "<HTML><IMG SRC=\""
- + ImageLoader.getSmiley(smiley.getDefaultString()).getImagePath()
- + "\"></IMG></HTML>";
- smileyItem.setIcon(null);
- smileyItem.setText(smileyIconHtml);
+ ImageIcon imageIcon
+ = GuiActivator.getResources().getImage(smiley.getImageID().getId());
+ smileyItem.setIcon(imageIcon);
smileyDescriptionLabel.setText(smiley.getDescription());
smileyTextLabel.setText(smiley.getSmileyStrings()[0]);
@@ -270,7 +268,6 @@ public class SmileysSelectorBox
new ImageIcon(ImageLoader.getImage(smiley.getImageID()));
smileyItem.setIcon(imageIcon);
- smileyItem.setText(null);
smileyTextLabel.setText("");
smileyDescriptionLabel.setText("");
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java
index 88d7506..5351a6e 100644
--- a/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java
+++ b/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigFormDescriptor.java
@@ -57,8 +57,7 @@ public class ConfigFormDescriptor
}
if(icon != null)
- configFormIcon
- = new ImageIcon(ImageLoader.getBytesInImage(icon));
+ configFormIcon = new ImageIcon(icon);
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java
index b89e5ae..cb1c482 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/DefaultContactList.java
@@ -126,15 +126,14 @@ public class DefaultContactList
{
Contact protocolContact = i.next();
- Image protocolStatusIcon
- = ImageLoader.getBytesInImage(
- protocolContact.getPresenceStatus().getStatusIcon());
+ ImageIcon protocolStatusIcon
+ = new ImageIcon(
+ protocolContact.getPresenceStatus().getStatusIcon());
String contactAddress = protocolContact.getAddress();
//String statusMessage = protocolContact.getStatusMessage();
- tip.addLine(new ImageIcon(protocolStatusIcon),
- contactAddress);
+ tip.addLine(protocolStatusIcon, contactAddress);
}
}
else if (element instanceof MetaContactGroup)
diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
index f85fe53..b84f172 100644
--- a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
@@ -106,8 +106,7 @@ public class PresenceStatusMenu
}
this.addItem(status.getStatusName(),
- new ImageIcon(
- ImageLoader.getBytesInImage(status.getStatusIcon())),
+ new ImageIcon(status.getStatusIcon()),
new ItemActionListener());
}
diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
index 969b560..c41363a 100644
--- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
+++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
@@ -14,7 +14,6 @@ import java.util.*;
import java.util.List;
import javax.imageio.*;
-import javax.imageio.stream.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.service.protocol.*;
@@ -136,8 +135,11 @@ public class ImageLoader
public static final ImageID DELETE_TEXT_ROLLOVER_ICON
= new ImageID("service.gui.lookandfeel.DELETE_TEXT_ROLLOVER_ICON");
- /////////////////////// OptionPane icons /////////////////////////////
-
+ /*
+ * =======================================================================
+ * ------------------------ OPTION PANE ICONS ----------------------------
+ * =======================================================================
+ */
/**
* The icon used in the <tt>SIPCommLookAndFeel</tt> to paint the icon
* of an option pane warning message.
@@ -444,7 +446,8 @@ public class ImageLoader
new ImageID("service.gui.buttons.SECURE_VIDEO_OFF");
/**
- * The security button: encryted and SAS verified, encrypted only, security off.
+ * The security button: encrypted and SAS verified, encrypted only,
+ * security off.
*/
public static final ImageID ENCR_VERIFIED = new ImageID(
"service.gui.buttons.ENCR_VERIFIED");
@@ -726,16 +729,17 @@ public class ImageLoader
public static final ImageID HIDE_ACTIONS_ROLLOVER_BUTTON
= new ImageID("service.gui.buttons.HIDE_ACTIONS_ROLLOVER_BUTTON");
- // ///////////////////// Edit Text Toolbar icons //////////////////////////
-
+ /*
+ * =======================================================================
+ * ------------------------ EDIT TOOLBAR ICONS ---------------------------
+ * =======================================================================
+ */
/**
* Add not in contact list contact icon.
*/
public static final ImageID ADD_CONTACT_CHAT_ICON
= new ImageID("service.gui.icons.ADD_CONTACT_CHAT_ICON");
- /////////////////////// Edit Text Toolbar icons /////////////////////////
-
/**
* "Bold" button image in the <tt>EditTextToolBar</tt> in the
* <tt>ChatWindow</tt>.
@@ -775,8 +779,11 @@ public class ImageLoader
public static final ImageID INVITE_DIALOG_ICON
= new ImageID("service.gui.icons.INVITE_DIALOG_ICON");
- // ///////////////////////// Main Toolbar icons ////////////////////////////
-
+ /*
+ * =======================================================================
+ * ------------------------ MAIN TOOLBAR ICONS ---------------------------
+ * =======================================================================
+ */
/**
* The background image of a button in one of the <tt>ChatWindow</tt>
* toolbars.
@@ -863,8 +870,11 @@ public class ImageLoader
public static final ImageID FONT_ICON
= new ImageID("service.gui.icons.FONT_ICON");
- // ///////////////////// Chat contact icons ////////////////////////////////
-
+ /*
+ * =======================================================================
+ * ------------------------ CHAT CONTACT ICONS ---------------------------
+ * =======================================================================
+ */
/**
* A special "info" icon used in the <tt>ChatContactPanel</tt>.
*/
@@ -905,7 +915,11 @@ public class ImageLoader
public static final ImageID CHAT_CONFIGURE_ICON
= new ImageID("service.gui.icons.CHAT_CONFIGURE_ICON");
- ////////////////////////////// 16x16 icons ////////////////////////////////
+ /*
+ * =======================================================================
+ * ------------------------- 16x16 ICONS ---------------------------------
+ * =======================================================================
+ */
/**
* Send message 16x16 image.
*/
@@ -955,8 +969,6 @@ public class ImageLoader
public static final ImageID RENAME_16x16_ICON
= new ImageID("service.gui.icons.RENAME_16x16_ICON");
- ///////////////////////////////////////////////////////////////////////////
-
/**
* Toolbar drag area icon.
*/
@@ -1100,69 +1112,70 @@ public class ImageLoader
*
* @return the ArrayList of all smileys.
*/
- public static Collection<Smiley> getDefaultSmileysPack() {
+ public static Collection<Smiley> getDefaultSmileysPack()
+ {
List<Smiley> defaultPackList = new ArrayList<Smiley>();
- defaultPackList.add(new Smiley(ImageLoader.SMILEY1, new String[] {
- ":((", ":-((", ":((", ":(", ":-(", "(sad)"}, "Sad"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY1,
+ new String[] {":((", ":-((", ":((", ":(", ":-(", "(sad)"}, "Sad"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY2, new String[] {
- "(angel)" }, "Angel"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY2,
+ new String[] {"(angel)" }, "Angel"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY3, new String[] {
- ":-*", ":*", "(kiss)"}, "Kiss"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY3,
+ new String[] {":-*", ":*", "(kiss)"}, "Kiss"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY4, new String[] {
- ":-0", "(shocked)"}, "Shocked"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY4,
+ new String[] {":-0", "(shocked)"}, "Shocked"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY5, new String[] {
- ";-((", ";((", ";-(", ";(", ":'(", ":'-(",
- ":~-(", ":~(", "(upset)" }, "Upset"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY5,
+ new String[] { ";-((", ";((", ";-(", ";(", ":'(", ":'-(",
+ ":~-(", ":~(", "(upset)" }, "Upset"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY6, new String[] {
- "(L)" , "(l)", "(H)", "(h)"}, "In love"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY6,
+ new String[] {"(L)" , "(l)", "(H)", "(h)"}, "In love"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY7, new String[] {
- "(blush)"}, "Blushing"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY7,
+ new String[] {"(blush)"}, "Blushing"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY8, new String[] {
- ":-P", ":P", ":-p", ":p" }, "Tongue out"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY8,
+ new String[] {":-P", ":P", ":-p", ":p" }, "Tongue out"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY9, new String[] {
- ":-))", ":))", ";-))", ";))", "(lol)"}, "Laughing"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY9,
+ new String[] {":-))", ":))", ";-))", ";))", "(lol)"}, "Laughing"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY10, new String[] {
- "(y)", "(Y)", "(ok)"}, "Ok"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY10,
+ new String[] {"(y)", "(Y)", "(ok)"}, "Ok"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY11, new String[] {
- ";-)", ";)", ":-)", ":)"}, "Smile"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY11,
+ new String[] {";-)", ";)", ":-)", ":)"}, "Smile"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY12, new String[] {
- "(sick)"}, "Sick"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY12,
+ new String[] {"(sick)"}, "Sick"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY13, new String[] {
- "(n)", "(N)" }, "No"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY13,
+ new String[] {"(n)", "(N)" }, "No"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY14, new String[] {
- "(chuckle)" }, "Chuckle"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY14,
+ new String[] {"(chuckle)" }, "Chuckle"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY15, new String[] {
- "(wave)" }, "Waving"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY15,
+ new String[] {"(wave)" }, "Waving"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY16, new String[] {
- "(clap)"}, "Clapping"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY16,
+ new String[] {"(clap)"}, "Clapping"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY17, new String[] {
- "(angry)"}, "Angry"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY17,
+ new String[] {"(angry)"}, "Angry"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY18, new String[] {
- "(bomb)"}, "Explosing"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY18,
+ new String[] {"(bomb)"}, "Explosing"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY19, new String[] {
- "(search)"}, "Searching"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY19,
+ new String[] {"(search)"}, "Searching"));
- defaultPackList.add(new Smiley(ImageLoader.SMILEY20, new String[] {
- "(oops)"}, "Oops"));
+ defaultPackList.add(new Smiley(ImageLoader.SMILEY20,
+ new String[] {"(oops)"}, "Oops"));
return defaultPackList;
}
@@ -1172,13 +1185,16 @@ public class ImageLoader
* @param smileyString One of :-), ;-), etc.
* @return A Smiley object for a given smiley string.
*/
- public static Smiley getSmiley(String smileyString) {
+ public static Smiley getSmiley(String smileyString)
+ {
Collection<Smiley> smileys = getDefaultSmileysPack();
- for (Smiley smiley : smileys) {
+ for (Smiley smiley : smileys)
+ {
String[] smileyStrings = smiley.getSmileyStrings();
- for (int j = 0; j < smileyStrings.length; j++) {
+ for (int j = 0; j < smileyStrings.length; j++)
+ {
String srcString = smileyStrings[j];
if (srcString.equals(smileyString))
@@ -1227,56 +1243,6 @@ public class ImageLoader
}
/**
- * Loads an image from a given path.
- *
- * @param path The path url of the image.
- * @return The image for the given identifier.
- */
- public static BufferedImage getImageFromUrl(String path)
- {
- BufferedImage image = null;
-
- try
- {
- URL imgUrl = new URL(path);
-
- image = ImageIO.read(imgUrl.openStream());
- }
- catch (Exception exc)
- {
- log.error("Failed to load image:" + path, exc);
- }
-
- return image;
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImageInBytes(ImageID imageID)
- {
- InputStream in =
- GuiActivator.getResources().getImageInputStream(imageID.getId());
-
- if (in == null)
- return null;
- byte[] image = null;
- try
- {
- image = new byte[in.available()];
-
- in.read(image);
- } catch (IOException e)
- {
- log.error("Failed to load image:" + imageID.getId(), e);
- }
-
- return image;
- }
-
- /**
* Loads an image from a given bytes array.
* @param imageBytes The bytes array to load the image from.
* @return The image for the given bytes array.
@@ -1298,67 +1264,25 @@ public class ImageLoader
}
/**
- * Loads an animated gif image.
- * @param animatedImage the animated image buffer
- * @return a <tt>BufferedImage</tt> array containing the animated image.
+ * Returns the URI corresponding to the image with the given image
+ * identifier.
+ *
+ * @param imageID the identifier of the image
+ * @return the URI corresponding to the image with the given image
+ * identifier
*/
- public static BufferedImage[] getAnimatedImage(byte[] animatedImage)
+ public static String getImageUri(ImageID imageID)
{
- ImageReader reader = ImageIO.getImageReadersBySuffix("gif").next();
-
- ImageInputStream iis;
-
- BufferedImage[] images = null;
+ URL imageURL = GuiActivator.getResources().getImageURL(imageID.getId());
- try {
- iis = ImageIO.createImageInputStream(
- new ByteArrayInputStream(animatedImage));
-
- reader.setInput(iis);
-
- int numImages = reader.getNumImages(true);
-
- if(numImages == 0)
- return null;
-
- images = new BufferedImage[numImages];
-
- for (int i = 0; i < numImages; ++i) {
- images[i] = reader.read(i);
- }
-
- } catch (IOException e) {
- log.error("Failed to load image.", e);
- } finally {
- log.logExit();
+ try
+ {
+ if (imageURL != null)
+ return imageURL.toURI().toString();
}
- return images;
- }
-
- /**
- * Returns the path string of an already loaded image, otherwise null.
- *
- * @param image
- * The image wich path to return.
- * @return The path string of an already loaded image, otherwise null.
- */
- public static String getImagePath(Image image)
- {
- for (Map.Entry<ImageID, BufferedImage> entry : loadedImages.entrySet()) {
- if (entry.getValue().equals(image))
- {
- String imageID = entry.getKey().getId();
-
- try
- {
- return GuiActivator.getResources().getImageURL(imageID)
- .toURI().toString();
- }
- catch(URISyntaxException ex)
- {
- log.error("Failed to create path for image " + imageID);
- }
- }
+ catch (URISyntaxException e)
+ {
+ log.debug("Unable to parse image URL to URI.", e);
}
return null;
@@ -1400,6 +1324,16 @@ public class ImageLoader
return badgeImageWithProtocolIndex(statusImage, pps);
}
+ /**
+ * Badges the given protocol image with an index allowing to distinguish
+ * different accounts from the same protocol.
+ *
+ * @param image the initial image to badge with an index
+ * @param pps the protocol provider service corresponding to the account,
+ * containing the index.
+ * @return the given protocol image with an index allowing to distinguish
+ * different accounts from the same protocol.
+ */
public static Image badgeImageWithProtocolIndex(
Image image, ProtocolProviderService pps)
{
diff --git a/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java b/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java
index 16f0e4e..61b0f9d 100644
--- a/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java
@@ -669,22 +669,8 @@ public class ResourceManagementServiceImpl
*/
public ImageIcon getImage(String imageID)
{
- BufferedImage image = null;
+ URL imageURL = getImageURL(imageID);
- InputStream in = getImageInputStream(imageID);
-
- if(in == null)
- return null;
-
- try
- {
- image = ImageIO.read(in);
- }
- catch (IOException e)
- {
- logger.error("Failed to load image:" + imageID, e);
- }
-
- return new ImageIcon(image);
+ return new ImageIcon(imageURL);
}
}