mirror of https://github.com/sipwise/jitsi.git
parent
3711e42871
commit
1dc984862a
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Bare Bones Browser Launch //
|
||||
// Version 1.5 //
|
||||
// December 10, 2005 //
|
||||
// Supports: Mac OS X, GNU/Linux, Unix, Windows XP //
|
||||
// Example Usage: //
|
||||
// String url = "http://www.centerkey.com/"; //
|
||||
// BareBonesBrowserLaunch.openURL(url); //
|
||||
// Public Domain Software -- Free to Use as You Like //
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class BrowserLauncher {
|
||||
|
||||
private static final String errMsg = "Error attempting to launch web browser";
|
||||
|
||||
public static void openURL(String url) {
|
||||
String osName = System.getProperty("os.name");
|
||||
try {
|
||||
if (osName.startsWith("Mac OS")) {
|
||||
Class fileMgr = Class.forName("com.apple.eio.FileManager");
|
||||
Method openURL = fileMgr.getDeclaredMethod("openURL",
|
||||
new Class[] {String.class});
|
||||
openURL.invoke(null, new Object[] {url});
|
||||
}
|
||||
else if (osName.startsWith("Windows"))
|
||||
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
|
||||
else { //assume Unix or Linux
|
||||
String[] browsers = {
|
||||
"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
|
||||
String browser = null;
|
||||
for (int count = 0; count < browsers.length && browser == null; count++)
|
||||
if (Runtime.getRuntime().exec(
|
||||
new String[] {"which", browsers[count]}).waitFor() == 0)
|
||||
browser = browsers[count];
|
||||
if (browser == null)
|
||||
throw new Exception("Could not find web browser");
|
||||
else
|
||||
Runtime.getRuntime().exec(new String[] {browser, url});
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,483 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.java.sip.communicator.util.Logger;
|
||||
|
||||
public class ImageLoader {
|
||||
|
||||
private static Logger log = Logger.getLogger(ImageLoader.class);
|
||||
|
||||
public static final ImageID EMPTY_16x16_ICON
|
||||
= new ImageID("EMPTY_16x16_ICON");
|
||||
|
||||
public static final ImageID QUICK_MENU_ADD_ICON
|
||||
= new ImageID("QUICK_MENU_ADD_ICON");
|
||||
|
||||
public static final ImageID QUICK_MENU_CONFIGURE_ICON
|
||||
= new ImageID("QUICK_MENU_CONFIGURE_ICON");
|
||||
|
||||
public static final ImageID QUICK_MENU_SEARCH_ICON
|
||||
= new ImageID("QUICK_MENU_SEARCH_ICON");
|
||||
|
||||
public static final ImageID QUICK_MENU_INFO_ICON
|
||||
= new ImageID("QUICK_MENU_INFO_ICON");
|
||||
|
||||
public static final ImageID QUICK_MENU_BUTTON_BG
|
||||
= new ImageID("QUICK_MENU_BUTTON_BG");
|
||||
|
||||
public static final ImageID QUICK_MENU_BUTTON_ROLLOVER_BG
|
||||
= new ImageID("QUICK_MENU_BUTTON_ROLLOVER_BG");
|
||||
|
||||
public static final ImageID CALL_BUTTON_BG
|
||||
= new ImageID("CALL_BUTTON_BG");
|
||||
|
||||
public static final ImageID HANGUP_BUTTON_BG
|
||||
= new ImageID("HANGUP_BUTTON_BG");
|
||||
|
||||
public static final ImageID CALL_ROLLOVER_BUTTON_BG
|
||||
= new ImageID("CALL_ROLLOVER_BUTTON_BG");
|
||||
|
||||
public static final ImageID CALL_PRESSED_BUTTON_BG
|
||||
= new ImageID("CALL_PRESSED_BUTTON_BG");
|
||||
|
||||
public static final ImageID HANGUP_ROLLOVER_BUTTON_BG
|
||||
= new ImageID("HANGUP_ROLLOVER_BUTTON_BG");
|
||||
|
||||
public static final ImageID HANGUP_PRESSED_BUTTON_BG
|
||||
= new ImageID("HANGUP_PRESSED_BUTTON_BG");
|
||||
|
||||
public static final ImageID STATUS_SELECTOR_BOX
|
||||
= new ImageID("STATUS_SELECTOR_BOX");
|
||||
|
||||
public static final ImageID BUTTON_BG = new ImageID("BUTTON_BG");
|
||||
|
||||
public static final ImageID BUTTON_ROLLOVER_BG
|
||||
= new ImageID("BUTTON_ROLLOVER_BG");
|
||||
|
||||
public static final ImageID ONE_DIAL_BUTTON
|
||||
= new ImageID("ONE_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID TWO_DIAL_BUTTON
|
||||
= new ImageID("TWO_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID THREE_DIAL_BUTTON
|
||||
= new ImageID("THREE_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID FOUR_DIAL_BUTTON
|
||||
= new ImageID("FOUR_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID FIVE_DIAL_BUTTON
|
||||
= new ImageID("FIVE_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID SIX_DIAL_BUTTON
|
||||
= new ImageID("SIX_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID SEVEN_DIAL_BUTTON
|
||||
= new ImageID("SEVEN_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID EIGHT_DIAL_BUTTON
|
||||
= new ImageID("EIGHT_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID NINE_DIAL_BUTTON
|
||||
= new ImageID("NINE_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID STAR_DIAL_BUTTON
|
||||
= new ImageID("STAR_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID ZERO_DIAL_BUTTON
|
||||
= new ImageID("ZERO_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID DIEZ_DIAL_BUTTON
|
||||
= new ImageID("DIEZ_DIAL_BUTTON");
|
||||
|
||||
public static final ImageID DEFAULT_USER_PHOTO
|
||||
= new ImageID("DEFAULT_USER_PHOTO");
|
||||
|
||||
public static final ImageID DEFAULT_CHAT_USER_PHOTO
|
||||
= new ImageID("DEFAULT_CHAT_USER_PHOTO");
|
||||
|
||||
public static final ImageID CALL_PANEL_MINIMIZE_BUTTON
|
||||
= new ImageID("CALL_PANEL_MINIMIZE_BUTTON");
|
||||
|
||||
public static final ImageID CALL_PANEL_RESTORE_BUTTON
|
||||
= new ImageID("CALL_PANEL_RESTORE_BUTTON");
|
||||
|
||||
public static final ImageID CALL_PANEL_MINIMIZE_ROLLOVER_BUTTON
|
||||
= new ImageID("CALL_PANEL_MINIMIZE_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID CALL_PANEL_RESTORE_ROLLOVER_BUTTON
|
||||
= new ImageID("CALL_PANEL_RESTORE_ROLLOVER_BUTTON");
|
||||
|
||||
|
||||
public static final ImageID ADD_TO_CHAT_BUTTON
|
||||
= new ImageID("ADD_TO_CHAT_BUTTON");
|
||||
|
||||
public static final ImageID ADD_TO_CHAT_ROLLOVER_BUTTON
|
||||
= new ImageID("ADD_TO_CHAT_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID ADD_TO_CHAT_ICON
|
||||
= new ImageID("ADD_TO_CHAT_ICON");
|
||||
|
||||
public static final ImageID TOOLBAR_DIVIDER
|
||||
= new ImageID("TOOLBAR_DIVIDER");
|
||||
|
||||
public static final ImageID RIGHT_ARROW_ICON
|
||||
= new ImageID("RIGHT_ARROW_ICON");
|
||||
|
||||
public static final ImageID RIGHT_ARROW_ROLLOVER_ICON
|
||||
= new ImageID("RIGHT_ARROW_ROLLOVER_ICON");
|
||||
|
||||
public static final ImageID BOTTOM_ARROW_ICON
|
||||
= new ImageID("BOTTOM_ARROW_ICON");
|
||||
|
||||
public static final ImageID BOTTOM_ARROW_ROLLOVER_ICON
|
||||
= new ImageID("BOTTOM_ARROW_ROLLOVER_ICON");
|
||||
|
||||
/////////////////////// Edit Text Toolbar icons //////////////////////////
|
||||
|
||||
public static final ImageID ALIGN_LEFT_BUTTON
|
||||
= new ImageID("ALIGN_LEFT_BUTTON");
|
||||
|
||||
public static final ImageID ALIGN_RIGHT_BUTTON
|
||||
= new ImageID("ALIGN_RIGHT_BUTTON");
|
||||
|
||||
public static final ImageID ALIGN_CENTER_BUTTON
|
||||
= new ImageID("ALIGN_RIGHT_BUTTON");
|
||||
|
||||
public static final ImageID ALIGN_LEFT_ROLLOVER_BUTTON
|
||||
= new ImageID("ALIGN_LEFT_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID ALIGN_RIGHT_ROLLOVER_BUTTON
|
||||
= new ImageID("ALIGN_RIGHT_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID ALIGN_CENTER_ROLLOVER_BUTTON
|
||||
= new ImageID("ALIGN_CENTER_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID TEXT_BOLD_BUTTON
|
||||
= new ImageID("TEXT_BOLD_BUTTON");
|
||||
|
||||
public static final ImageID TEXT_ITALIC_BUTTON
|
||||
= new ImageID("TEXT_ITALIC_BUTTON");
|
||||
|
||||
public static final ImageID TEXT_UNDERLINED_BUTTON
|
||||
= new ImageID("TEXT_ITALIC_BUTTON");
|
||||
|
||||
public static final ImageID TEXT_BOLD_ROLLOVER_BUTTON
|
||||
= new ImageID("TEXT_BOLD_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID TEXT_ITALIC_ROLLOVER_BUTTON
|
||||
= new ImageID("TEXT_ITALIC_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID TEXT_UNDERLINED_ROLLOVER_BUTTON
|
||||
= new ImageID("TEXT_UNDERLINED_ROLLOVER_BUTTON");
|
||||
|
||||
// ///////////////////////// Main Toolbar icons ////////////////////////////
|
||||
|
||||
public static final ImageID MSG_TOOLBAR_BUTTON_BG
|
||||
= new ImageID("MSG_TOOLBAR_BUTTON_BG");
|
||||
|
||||
public static final ImageID MSG_TOOLBAR_ROLLOVER_BUTTON_BG
|
||||
= new ImageID("MSG_TOOLBAR_ROLLOVER_BUTTON_BG");
|
||||
|
||||
public static final ImageID COPY_ICON = new ImageID("COPY_ICON");
|
||||
|
||||
public static final ImageID CUT_ICON = new ImageID("CUT_ICON");
|
||||
|
||||
public static final ImageID PASTE_ICON = new ImageID("PASTE_ICON");
|
||||
|
||||
public static final ImageID SMILIES_ICON
|
||||
= new ImageID("SMILIES_ICON");
|
||||
|
||||
public static final ImageID SAVE_ICON = new ImageID("SAVE_ICON");
|
||||
|
||||
public static final ImageID PRINT_ICON = new ImageID("PRINT_ICON");
|
||||
|
||||
public static final ImageID CLOSE_ICON = new ImageID("CLOSE_ICON");
|
||||
|
||||
public static final ImageID QUIT_ICON = new ImageID("QUIT_ICON");
|
||||
|
||||
public static final ImageID PREVIOUS_ICON
|
||||
= new ImageID("PREVIOUS_ICON");
|
||||
|
||||
public static final ImageID NEXT_ICON = new ImageID("NEXT_ICON");
|
||||
|
||||
public static final ImageID HISTORY_ICON
|
||||
= new ImageID("HISTORY_ICON");
|
||||
|
||||
public static final ImageID SEND_FILE_ICON
|
||||
= new ImageID("SEND_FILE_ICON");
|
||||
|
||||
|
||||
public static final ImageID FONT_ICON = new ImageID("FONT_ICON");
|
||||
|
||||
// ///////////////////// Chat contact icons ////////////////////////////////
|
||||
|
||||
public static final ImageID CHAT_CONTACT_INFO_BUTTON
|
||||
= new ImageID("CHAT_CONTACT_INFO_BUTTON");
|
||||
|
||||
public static final ImageID CHAT_CONTACT_INFO_ROLLOVER_BUTTON
|
||||
= new ImageID("CHAT_CONTACT_INFO_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID CHAT_CONTACT_CALL_BUTTON
|
||||
= new ImageID("CHAT_CONTACT_CALL_BUTTON");
|
||||
|
||||
public static final ImageID CHAT_CONTACT_CALL_ROLLOVER_BUTTON
|
||||
= new ImageID("CHAT_CONTACT_CALL_ROLLOVER_BUTTON");
|
||||
|
||||
public static final ImageID CHAT_CONTACT_SEND_FILE_BUTTON
|
||||
= new ImageID("CHAT_CONTACT_SEND_FILE_BUTTON");
|
||||
|
||||
public static final ImageID CHAT_SEND_FILE_ROLLOVER_BUTTON
|
||||
= new ImageID("CHAT_SEND_FILE_ROLLOVER_BUTTON");
|
||||
|
||||
// ///////////////////// Optionpane icons /////////////////////////////
|
||||
|
||||
public static final ImageID WARNING_ICON
|
||||
= new ImageID("WARNING_ICON");
|
||||
|
||||
// //////////////////// RightButton menu icons ////////////////////////
|
||||
|
||||
public static final ImageID SEND_MESSAGE_16x16_ICON
|
||||
= new ImageID("SEND_MESSAGE_16x16_ICON");
|
||||
|
||||
public static final ImageID DELETE_16x16_ICON
|
||||
= new ImageID("DELETE_16x16_ICON");
|
||||
|
||||
public static final ImageID HISTORY_16x16_ICON
|
||||
= new ImageID("HISTORY_16x16_ICON");
|
||||
|
||||
public static final ImageID SEND_FILE_16x16_ICON
|
||||
= new ImageID("SEND_FILE_16x16_ICON");
|
||||
|
||||
public static final ImageID GROUPS_16x16_ICON
|
||||
= new ImageID("GROUPS_16x16_ICON");
|
||||
|
||||
public static final ImageID INFO_16x16_ICON
|
||||
= new ImageID("INFO_16x16_ICON");
|
||||
|
||||
public static final ImageID ADD_CONTACT_16x16_ICON
|
||||
= new ImageID("ADD_CONTACT_16x16_ICON");
|
||||
|
||||
public static final ImageID RENAME_16x16_ICON
|
||||
= new ImageID("RENAME_16x16_ICON");
|
||||
|
||||
public static final ImageID MORE_INFO_ICON
|
||||
= new ImageID("MORE_INFO_ICON");
|
||||
|
||||
public static final ImageID TOOLBAR_DRAG_ICON
|
||||
= new ImageID("TOOLBAR_DRAG_ICON");
|
||||
|
||||
/*
|
||||
* =========================================================================
|
||||
* --------------------- PROTOCOLS STATUS ICONS ---------------------------
|
||||
* ========================================================================
|
||||
*/
|
||||
|
||||
public static final ImageID ICQ_LOGO = new ImageID("ICQ_LOGO");
|
||||
|
||||
public static final ImageID ICQ_FF_CHAT_ICON
|
||||
= new ImageID("ICQ_FF_CHAT_ICON");
|
||||
|
||||
public static final ImageID ICQ_AWAY_ICON
|
||||
= new ImageID("ICQ_AWAY_ICON");
|
||||
|
||||
public static final ImageID ICQ_NA_ICON = new ImageID("ICQ_NA_ICON");
|
||||
|
||||
public static final ImageID ICQ_DND_ICON
|
||||
= new ImageID("ICQ_DND_ICON");
|
||||
|
||||
public static final ImageID ICQ_OCCUPIED_ICON
|
||||
= new ImageID("ICQ_OCCUPIED_ICON");
|
||||
|
||||
public static final ImageID ICQ_OFFLINE_ICON
|
||||
= new ImageID("ICQ_OFFLINE_ICON");
|
||||
|
||||
public static final ImageID ICQ_INVISIBLE_ICON
|
||||
= new ImageID("ICQ_INVISIBLE_ICON");
|
||||
|
||||
public static final ImageID MSN_LOGO = new ImageID("MSN_LOGO");
|
||||
|
||||
|
||||
public static final ImageID AIM_LOGO = new ImageID("AIM_LOGO");
|
||||
|
||||
public static final ImageID YAHOO_LOGO = new ImageID("YAHOO_LOGO");
|
||||
|
||||
public static final ImageID JABBER_LOGO = new ImageID("JABBER_LOGO");
|
||||
|
||||
public static final ImageID SKYPE_LOGO = new ImageID("SKYPE_LOGO");
|
||||
|
||||
public static final ImageID SIP_LOGO = new ImageID("SIP_LOGO");
|
||||
|
||||
|
||||
public static final ImageID SIP_ONLINE_ICON
|
||||
= new ImageID("SIP_ONLINE_ICON");
|
||||
|
||||
public static final ImageID SIP_OFFLINE_ICON
|
||||
= new ImageID("SIP_OFFLINE_ICON");
|
||||
|
||||
public static final ImageID SIP_INVISIBLE_ICON
|
||||
= new ImageID("SIP_INVISIBLE_ICON");
|
||||
|
||||
public static final ImageID SIP_AWAY_ICON
|
||||
= new ImageID("SIP_AWAY_ICON");
|
||||
|
||||
public static final ImageID SIP_NA_ICON = new ImageID("SIP_NA_ICON");
|
||||
|
||||
public static final ImageID SIP_DND_ICON
|
||||
= new ImageID("SIP_DND_ICON");
|
||||
|
||||
public static final ImageID SIP_OCCUPIED_ICON
|
||||
= new ImageID("SIP_OCCUPIED_ICON");
|
||||
|
||||
public static final ImageID SIP_CHAT_ICON
|
||||
= new ImageID("SIP_CHAT_ICON");
|
||||
|
||||
/*
|
||||
* ========================================================================
|
||||
* ------------------------ USERS ICONS ---------------------------------
|
||||
* ========================================================================
|
||||
*/
|
||||
|
||||
public static final ImageID USER_ONLINE_ICON
|
||||
= new ImageID("USER_ONLINE_ICON");
|
||||
|
||||
/*
|
||||
* ========================================================================
|
||||
* ---------------------------- SMILIES ---------------------------------
|
||||
* ========================================================================
|
||||
*/
|
||||
|
||||
public static final ImageID SMILY1 = new ImageID("SMILY1");
|
||||
|
||||
public static final ImageID SMILY2 = new ImageID("SMILY2");
|
||||
|
||||
public static final ImageID SMILY3 = new ImageID("SMILY3");
|
||||
|
||||
public static final ImageID SMILY4 = new ImageID("SMILY4");
|
||||
|
||||
public static final ImageID SMILY5 = new ImageID("SMILY5");
|
||||
|
||||
public static final ImageID SMILY6 = new ImageID("SMILY6");
|
||||
|
||||
public static final ImageID SMILY7 = new ImageID("SMILY7");
|
||||
|
||||
public static final ImageID SMILY8 = new ImageID("SMILY8");
|
||||
|
||||
public static final ImageID SMILY9 = new ImageID("SMILY9");
|
||||
|
||||
public static final ImageID SMILY10 = new ImageID("SMILY10");
|
||||
|
||||
public static final ImageID SMILY11 = new ImageID("SMILY11");
|
||||
|
||||
public static final ImageID SMILY12 = new ImageID("SMILY12");
|
||||
|
||||
/**
|
||||
* Load default smilies pack
|
||||
*
|
||||
* @return the ArrayList of all smilies.
|
||||
*
|
||||
*/
|
||||
public static ArrayList getDefaultSmiliesPack() {
|
||||
|
||||
ArrayList defaultPackList = new ArrayList();
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY1.getId(),
|
||||
new String[] { "$-)", "$)" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY2.getId(),
|
||||
new String[] { "8-)", "8)" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY3.getId(),
|
||||
new String[] { ":-*", ":*" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY4.getId(),
|
||||
new String[] { ":-0", ":0" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY5.getId(),
|
||||
new String[] { ":-((", ":((" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY6.getId(),
|
||||
new String[] { ":-~", ":~" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY7.getId(),
|
||||
new String[] { ":-|", ":|" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY8.getId(),
|
||||
new String[] { ":-P", ":P", ":-p", ":p" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY9.getId(),
|
||||
new String[] { ":-))", ":))" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY10.getId(),
|
||||
new String[] { ":-(", ":(" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY11.getId(),
|
||||
new String[] { ":-)", ":)" }));
|
||||
|
||||
defaultPackList.add(new Smily(ImageLoader.SMILY12.getId(),
|
||||
new String[] { ";-)", ";)" }));
|
||||
|
||||
return defaultPackList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an image from a given image identifier.
|
||||
*/
|
||||
|
||||
public static Image getImage(ImageID imageID) {
|
||||
|
||||
String path = Images.getString(imageID.getId());
|
||||
|
||||
Image image = null;
|
||||
|
||||
try {
|
||||
log.logEntry();
|
||||
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Loading image : " + path + "...");
|
||||
}
|
||||
|
||||
image = ImageIO.read(ImageLoader.class.getResource(path));
|
||||
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Loading image : " + path + "... [ DONE ]");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to load image:" + path, e);
|
||||
} finally {
|
||||
log.logExit();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the Image Identifier.
|
||||
*/
|
||||
public static class ImageID {
|
||||
|
||||
private String id;
|
||||
|
||||
private ImageID(String id){
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class Images {
|
||||
|
||||
private static final String BUNDLE_NAME = "net.java.sip.communicator.impl.gui.main.utils.images";
|
||||
|
||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
|
||||
.getBundle(BUNDLE_NAME);
|
||||
|
||||
private Images() {
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
|
||||
try {
|
||||
return RESOURCE_BUNDLE.getString(key);
|
||||
|
||||
} catch (MissingResourceException e) {
|
||||
|
||||
return '!' + key + '!';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import javax.swing.text.Element;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.View;
|
||||
import javax.swing.text.ViewFactory;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
|
||||
public class MyHTMLEditorKit extends HTMLEditorKit {
|
||||
|
||||
public ViewFactory getViewFactory() {
|
||||
return new HTMLFactoryX();
|
||||
}
|
||||
|
||||
public static class HTMLFactoryX extends HTMLFactory
|
||||
implements ViewFactory {
|
||||
|
||||
public View create(Element elem) {
|
||||
|
||||
Object o =
|
||||
elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
|
||||
|
||||
if (o instanceof HTML.Tag) {
|
||||
|
||||
HTML.Tag kind = (HTML.Tag) o;
|
||||
|
||||
if (kind == HTML.Tag.IMG)
|
||||
return new MyImageView(elem);
|
||||
}
|
||||
|
||||
return super.create( elem );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,763 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Dictionary;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.text.AbstractDocument;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.Element;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import javax.swing.text.Position;
|
||||
import javax.swing.text.StyledDocument;
|
||||
import javax.swing.text.View;
|
||||
import javax.swing.text.ViewFactory;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
|
||||
public class MyImageView extends View implements ImageObserver {
|
||||
|
||||
// --- Attribute Values ------------------------------------------
|
||||
|
||||
public static final String
|
||||
TOP = "top",
|
||||
TEXTTOP = "texttop",
|
||||
MIDDLE = "middle",
|
||||
ABSMIDDLE = "absmiddle",
|
||||
CENTER = "center",
|
||||
BOTTOM = "bottom";
|
||||
|
||||
|
||||
// --- Construction ----------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new view that represents an IMG element.
|
||||
*
|
||||
* @param elem the element to create a view for
|
||||
*/
|
||||
public MyImageView(Element elem) {
|
||||
|
||||
super(elem);
|
||||
|
||||
initialize(elem);
|
||||
|
||||
StyleSheet sheet = getStyleSheet();
|
||||
|
||||
attr = sheet.getViewAttributes(this);
|
||||
}
|
||||
|
||||
|
||||
private void initialize( Element elem ) {
|
||||
|
||||
synchronized(this) {
|
||||
loading = true;
|
||||
fWidth = fHeight = 0;
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
boolean customWidth = false;
|
||||
boolean customHeight = false;
|
||||
|
||||
try {
|
||||
fElement = elem;
|
||||
|
||||
// Request image from document's cache:
|
||||
AttributeSet attr = elem.getAttributes();
|
||||
|
||||
if (isURL()) {
|
||||
|
||||
URL src = getSourceURL();
|
||||
|
||||
if( src != null ) {
|
||||
|
||||
Dictionary cache = (Dictionary) getDocument().getProperty(IMAGE_CACHE_PROPERTY);
|
||||
|
||||
if( cache != null )
|
||||
fImage = (Image) cache.get(src);
|
||||
else
|
||||
fImage = Toolkit.getDefaultToolkit().getImage(src);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
/******** Code to load from relative path *************/
|
||||
String src =
|
||||
(String) fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
|
||||
|
||||
//fImage = Toolkit.getDefaultToolkit().createImage(src);
|
||||
try {
|
||||
fImage = ImageIO.read(Constants.class.getResource(src));
|
||||
|
||||
try { waitForImage(); }
|
||||
catch (InterruptedException e) { fImage = null; }
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
}
|
||||
|
||||
// Get height/width from params or image or defaults:
|
||||
height = getIntAttr(HTML.Attribute.HEIGHT,-1);
|
||||
|
||||
customHeight = (height>0);
|
||||
|
||||
if( !customHeight && fImage != null )
|
||||
height = fImage.getHeight(this);
|
||||
|
||||
if( height <= 0 )
|
||||
height = DEFAULT_HEIGHT;
|
||||
|
||||
width = getIntAttr(HTML.Attribute.WIDTH,-1);
|
||||
|
||||
customWidth = (width>0);
|
||||
|
||||
if( !customWidth && fImage != null )
|
||||
width = fImage.getWidth(this);
|
||||
|
||||
if( width <= 0 )
|
||||
width = DEFAULT_WIDTH;
|
||||
|
||||
// Make sure the image starts loading:
|
||||
if( fImage != null )
|
||||
if( customWidth && customHeight )
|
||||
Toolkit.getDefaultToolkit().prepareImage(fImage,height,
|
||||
width,this);
|
||||
else
|
||||
Toolkit.getDefaultToolkit().prepareImage(fImage,-1,-1,
|
||||
this);
|
||||
|
||||
/********************************************************
|
||||
// Rob took this out. Changed scope of src.
|
||||
if( DEBUG ) {
|
||||
if( fImage != null )
|
||||
System.out.println("ImageInfo: new on "+src+
|
||||
" ("+fWidth+"x"+fHeight+")");
|
||||
else
|
||||
System.out.println("ImageInfo: couldn't get image at "+
|
||||
src);
|
||||
if(isLink())
|
||||
System.out.println(" It's a link! Border = "+
|
||||
getBorder());
|
||||
//((AbstractDocument.AbstractElement)elem).dump(System.out,4);
|
||||
}
|
||||
********************************************************/
|
||||
} finally {
|
||||
|
||||
synchronized(this) {
|
||||
loading = false;
|
||||
|
||||
if (customWidth || fWidth == 0) {
|
||||
fWidth = width;
|
||||
}
|
||||
if (customHeight || fHeight == 0) {
|
||||
fHeight = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Determines if path is in the form of a URL */
|
||||
private boolean isURL() {
|
||||
|
||||
String src =
|
||||
(String) fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
|
||||
|
||||
return src.toLowerCase().startsWith("file") ||
|
||||
src.toLowerCase().startsWith("http");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Added this guy to make sure an image is loaded - ie no broken
|
||||
images. So far its used only for images loaded off the disk (non-URL).
|
||||
It seems to work marvelously. By the way, it does the same thing as
|
||||
MediaTracker, but you dont need to know the component its being
|
||||
rendered on. Rob */
|
||||
private void waitForImage() throws InterruptedException {
|
||||
|
||||
int w = fImage.getWidth(this);
|
||||
int h = fImage.getHeight(this);
|
||||
|
||||
while (true) {
|
||||
int flags = Toolkit.getDefaultToolkit().checkImage(fImage, w, h, this);
|
||||
|
||||
if ( ((flags & ERROR) != 0) || ((flags & ABORT) != 0 ) )
|
||||
throw new InterruptedException();
|
||||
|
||||
else if ((flags & (ALLBITS | FRAMEBITS)) != 0)
|
||||
return;
|
||||
|
||||
Thread.sleep(10);
|
||||
//System.out.println("rise and shine...");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches the attributes to use when rendering. This is
|
||||
* implemented to multiplex the attributes specified in the
|
||||
* model with a StyleSheet.
|
||||
*/
|
||||
public AttributeSet getAttributes() {
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
/** Is this image within a link? */
|
||||
boolean isLink( ) {
|
||||
//! It would be nice to cache this but in an editor it can change
|
||||
// See if I have an HREF attribute courtesy of the enclosing A tag:
|
||||
|
||||
AttributeSet anchorAttr = (AttributeSet)
|
||||
|
||||
fElement.getAttributes().getAttribute(HTML.Tag.A);
|
||||
|
||||
if (anchorAttr != null) {
|
||||
return anchorAttr.isDefined(HTML.Attribute.HREF);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns the size of the border to use. */
|
||||
int getBorder( ) {
|
||||
return getIntAttr(HTML.Attribute.BORDER, isLink() ?DEFAULT_BORDER :0);
|
||||
}
|
||||
|
||||
/** Returns the amount of extra space to add along an axis. */
|
||||
int getSpace( int axis ) {
|
||||
return getIntAttr( axis==X_AXIS ?HTML.Attribute.HSPACE :HTML.Attribute.VSPACE,
|
||||
0 );
|
||||
}
|
||||
|
||||
/** Returns the border's color, or null if this is not a link. */
|
||||
Color getBorderColor( ) {
|
||||
StyledDocument doc = (StyledDocument) getDocument();
|
||||
return doc.getForeground(getAttributes());
|
||||
}
|
||||
|
||||
/** Returns the image's vertical alignment. */
|
||||
float getVerticalAlignment( ) {
|
||||
String align = (String) fElement.getAttributes().getAttribute(HTML.Attribute.ALIGN);
|
||||
if( align != null ) {
|
||||
align = align.toLowerCase();
|
||||
if( align.equals(TOP) || align.equals(TEXTTOP) )
|
||||
return 0.0f;
|
||||
else if( align.equals(this.CENTER) || align.equals(MIDDLE)
|
||||
|| align.equals(ABSMIDDLE) )
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
return 1.0f; // default alignment is bottom
|
||||
}
|
||||
|
||||
boolean hasPixels( ImageObserver obs ) {
|
||||
|
||||
return fImage != null && fImage.getHeight(obs)>0
|
||||
&& fImage.getWidth(obs)>0;
|
||||
}
|
||||
|
||||
|
||||
/** Return a URL for the image source,
|
||||
or null if it could not be determined. */
|
||||
private URL getSourceURL( ) {
|
||||
|
||||
String src = (String) fElement.getAttributes().getAttribute(HTML.Attribute.SRC);
|
||||
if( src==null ) return null;
|
||||
|
||||
URL reference = ((HTMLDocument)getDocument()).getBase();
|
||||
try {
|
||||
URL u = new URL(reference,src);
|
||||
return u;
|
||||
} catch (MalformedURLException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Look up an integer-valued attribute. <b>Not</b> recursive. */
|
||||
private int getIntAttr(HTML.Attribute name, int deflt ) {
|
||||
AttributeSet attr = fElement.getAttributes();
|
||||
if( attr.isDefined(name) ) { // does not check parents!
|
||||
int i;
|
||||
String val = (String) attr.getAttribute(name);
|
||||
if( val == null )
|
||||
i = deflt;
|
||||
else
|
||||
try{
|
||||
i = Math.max(0, Integer.parseInt(val));
|
||||
}catch( NumberFormatException x ) {
|
||||
i = deflt;
|
||||
}
|
||||
return i;
|
||||
} else
|
||||
return deflt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Establishes the parent view for this view.
|
||||
* Seize this moment to cache the AWT Container I'm in.
|
||||
*/
|
||||
public void setParent(View parent) {
|
||||
super.setParent(parent);
|
||||
fContainer = parent!=null ?getContainer() :null;
|
||||
if( parent==null && fComponent!=null ) {
|
||||
fComponent.getParent().remove(fComponent);
|
||||
fComponent = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** My attributes may have changed. */
|
||||
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
|
||||
if(DEBUG) System.out.println("ImageView: changedUpdate begin...");
|
||||
super.changedUpdate(e,a,f);
|
||||
float align = getVerticalAlignment();
|
||||
|
||||
int height = fHeight;
|
||||
int width = fWidth;
|
||||
|
||||
initialize(getElement());
|
||||
|
||||
boolean hChanged = fHeight!=height;
|
||||
boolean wChanged = fWidth!=width;
|
||||
if( hChanged || wChanged || getVerticalAlignment()!=align ) {
|
||||
if(DEBUG) System.out.println("ImageView: calling preferenceChanged");
|
||||
getParent().preferenceChanged(this,hChanged,wChanged);
|
||||
}
|
||||
if(DEBUG) System.out.println("ImageView: changedUpdate end; valign="+getVerticalAlignment());
|
||||
}
|
||||
|
||||
|
||||
// --- Painting --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Paints the image.
|
||||
*
|
||||
* @param g the rendering surface to use
|
||||
* @param a the allocated region to render into
|
||||
* @see View#paint
|
||||
*/
|
||||
public void paint(Graphics g, Shape a) {
|
||||
Color oldColor = g.getColor();
|
||||
fBounds = a.getBounds();
|
||||
int border = getBorder();
|
||||
int x = fBounds.x + border + getSpace(X_AXIS);
|
||||
int y = fBounds.y + border + getSpace(Y_AXIS);
|
||||
int width = fWidth;
|
||||
int height = fHeight;
|
||||
int sel = getSelectionState();
|
||||
|
||||
// Make sure my Component is in the right place:
|
||||
/*
|
||||
if( fComponent == null ) {
|
||||
fComponent = new Component() { };
|
||||
fComponent.addMouseListener(this);
|
||||
fComponent.addMouseMotionListener(this);
|
||||
fComponent.setCursor(Cursor.getDefaultCursor()); // use arrow cursor
|
||||
fContainer.add(fComponent);
|
||||
}
|
||||
fComponent.setBounds(x,y,width,height);
|
||||
*/
|
||||
// If no pixels yet, draw gray outline and icon:
|
||||
if( ! hasPixels(this) ) {
|
||||
g.setColor(Color.lightGray);
|
||||
g.drawRect(x,y,width-1,height-1);
|
||||
g.setColor(oldColor);
|
||||
loadIcons();
|
||||
Icon icon = fImage==null ?sMissingImageIcon :sPendingImageIcon;
|
||||
if( icon != null )
|
||||
icon.paintIcon(getContainer(), g, x, y);
|
||||
}
|
||||
|
||||
// Draw image:
|
||||
if( fImage != null ) {
|
||||
g.drawImage(fImage,x, y,width,height,this);
|
||||
// Use the following instead of g.drawImage when
|
||||
// BufferedImageGraphics2D.setXORMode is fixed (4158822).
|
||||
|
||||
// Use Xor mode when selected/highlighted.
|
||||
//! Could darken image instead, but it would be more expensive.
|
||||
/*
|
||||
if( sel > 0 )
|
||||
g.setXORMode(Color.white);
|
||||
g.drawImage(fImage,x, y,
|
||||
width,height,this);
|
||||
if( sel > 0 )
|
||||
g.setPaintMode();
|
||||
*/
|
||||
}
|
||||
|
||||
// If selected exactly, we need a black border & grow-box:
|
||||
Color bc = getBorderColor();
|
||||
if( sel == 2 ) {
|
||||
// Make sure there's room for a border:
|
||||
int delta = 2-border;
|
||||
if( delta > 0 ) {
|
||||
x += delta;
|
||||
y += delta;
|
||||
width -= delta<<1;
|
||||
height -= delta<<1;
|
||||
border = 2;
|
||||
}
|
||||
bc = null;
|
||||
g.setColor(Color.black);
|
||||
// Draw grow box:
|
||||
g.fillRect(x+width-5,y+height-5,5,5);
|
||||
}
|
||||
|
||||
// Draw border:
|
||||
if( border > 0 ) {
|
||||
if( bc != null ) g.setColor(bc);
|
||||
// Draw a thick rectangle:
|
||||
for( int i=1; i<=border; i++ )
|
||||
g.drawRect(x-i, y-i, width-1+i+i, height-1+i+i);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
/** Request that this view be repainted.
|
||||
Assumes the view is still at its last-drawn location. */
|
||||
protected void repaint( long delay ) {
|
||||
if( fContainer != null && fBounds!=null ) {
|
||||
fContainer.repaint(delay,
|
||||
fBounds.x,fBounds.y,fBounds.width,fBounds.height);
|
||||
}
|
||||
}
|
||||
|
||||
/** Determines whether the image is selected, and if it's the only thing selected.
|
||||
@return 0 if not selected, 1 if selected, 2 if exclusively selected.
|
||||
"Exclusive" selection is only returned when editable. */
|
||||
protected int getSelectionState( ) {
|
||||
int p0 = fElement.getStartOffset();
|
||||
int p1 = fElement.getEndOffset();
|
||||
if (fContainer instanceof JTextComponent) {
|
||||
JTextComponent textComp = (JTextComponent)fContainer;
|
||||
int start = textComp.getSelectionStart();
|
||||
int end = textComp.getSelectionEnd();
|
||||
if( start<=p0 && end>=p1 ) {
|
||||
if( start==p0 && end==p1 && isEditable() )
|
||||
return 2;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected boolean isEditable( ) {
|
||||
return fContainer instanceof JEditorPane
|
||||
&& ((JEditorPane)fContainer).isEditable();
|
||||
}
|
||||
|
||||
/** Returns the text editor's highlight color. */
|
||||
protected Color getHighlightColor( ) {
|
||||
JTextComponent textComp = (JTextComponent)fContainer;
|
||||
return textComp.getSelectionColor();
|
||||
}
|
||||
|
||||
// --- Progressive display ---------------------------------------------
|
||||
|
||||
// This can come on any thread. If we are in the process of reloading
|
||||
// the image and determining our state (loading == true) we don't fire
|
||||
// preference changed, or repaint, we just reset the fWidth/fHeight as
|
||||
// necessary and return. This is ok as we know when loading finishes
|
||||
// it will pick up the new height/width, if necessary.
|
||||
public boolean imageUpdate( Image img, int flags, int x, int y,
|
||||
int width, int height ) {
|
||||
if( fImage==null || fImage != img )
|
||||
return false;
|
||||
|
||||
// Bail out if there was an error:
|
||||
if( (flags & (ABORT|ERROR)) != 0 ) {
|
||||
fImage = null;
|
||||
repaint(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resize image if necessary:
|
||||
short changed = 0;
|
||||
if( (flags & ImageObserver.HEIGHT) != 0 )
|
||||
if( ! getElement().getAttributes().isDefined(HTML.Attribute.HEIGHT) ) {
|
||||
changed |= 1;
|
||||
}
|
||||
if( (flags & ImageObserver.WIDTH) != 0 )
|
||||
if( ! getElement().getAttributes().isDefined(HTML.Attribute.WIDTH) ) {
|
||||
changed |= 2;
|
||||
}
|
||||
synchronized(this) {
|
||||
if ((changed & 1) == 1) {
|
||||
fWidth = width;
|
||||
}
|
||||
if ((changed & 2) == 2) {
|
||||
fHeight = height;
|
||||
}
|
||||
if (loading) {
|
||||
// No need to resize or repaint, still in the process of
|
||||
// loading.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if( changed != 0 ) {
|
||||
// May need to resize myself, asynchronously:
|
||||
if( DEBUG ) System.out.println("ImageView: resized to "+fWidth+"x"+fHeight);
|
||||
|
||||
Document doc = getDocument();
|
||||
try {
|
||||
if (doc instanceof AbstractDocument) {
|
||||
((AbstractDocument)doc).readLock();
|
||||
}
|
||||
preferenceChanged(this,true,true);
|
||||
} finally {
|
||||
if (doc instanceof AbstractDocument) {
|
||||
((AbstractDocument)doc).readUnlock();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Repaint when done or when new pixels arrive:
|
||||
if( (flags & (FRAMEBITS|ALLBITS)) != 0 )
|
||||
repaint(0);
|
||||
else if( (flags & SOMEBITS) != 0 )
|
||||
if( sIsInc )
|
||||
repaint(sIncRate);
|
||||
|
||||
return ((flags & ALLBITS) == 0);
|
||||
}
|
||||
/*
|
||||
/**
|
||||
* Static properties for incremental drawing.
|
||||
* Swiped from Component.java
|
||||
* @see #imageUpdate
|
||||
*/
|
||||
private static boolean sIsInc = true;
|
||||
private static int sIncRate = 100;
|
||||
|
||||
// --- Layout ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines the preferred span for this view along an
|
||||
* axis.
|
||||
*
|
||||
* @param axis may be either X_AXIS or Y_AXIS
|
||||
* @returns the span the view would like to be rendered into.
|
||||
* Typically the view is told to render into the span
|
||||
* that is returned, although there is no guarantee.
|
||||
* The parent may choose to resize or break the view.
|
||||
*/
|
||||
public float getPreferredSpan(int axis) {
|
||||
//if(DEBUG)System.out.println("ImageView: getPreferredSpan");
|
||||
int extra = 2*(getBorder()+getSpace(axis));
|
||||
switch (axis) {
|
||||
case View.X_AXIS:
|
||||
return fWidth+extra;
|
||||
case View.Y_AXIS:
|
||||
return fHeight+extra;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid axis: " + axis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the desired alignment for this view along an
|
||||
* axis. This is implemented to give the alignment to the
|
||||
* bottom of the icon along the y axis, and the default
|
||||
* along the x axis.
|
||||
*
|
||||
* @param axis may be either X_AXIS or Y_AXIS
|
||||
* @returns the desired alignment. This should be a value
|
||||
* between 0.0 and 1.0 where 0 indicates alignment at the
|
||||
* origin and 1.0 indicates alignment to the full span
|
||||
* away from the origin. An alignment of 0.5 would be the
|
||||
* center of the view.
|
||||
*/
|
||||
public float getAlignment(int axis) {
|
||||
switch (axis) {
|
||||
case View.Y_AXIS:
|
||||
return getVerticalAlignment();
|
||||
default:
|
||||
return super.getAlignment(axis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a mapping from the document model coordinate space
|
||||
* to the coordinate space of the view mapped to it.
|
||||
*
|
||||
* @param pos the position to convert
|
||||
* @param a the allocated region to render into
|
||||
* @return the bounding box of the given position
|
||||
* @exception BadLocationException if the given position does not represent a
|
||||
* valid location in the associated document
|
||||
* @see View#modelToView
|
||||
*/
|
||||
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException {
|
||||
int p0 = getStartOffset();
|
||||
int p1 = getEndOffset();
|
||||
if ((pos >= p0) && (pos <= p1)) {
|
||||
Rectangle r = a.getBounds();
|
||||
if (pos == p1) {
|
||||
r.x += r.width;
|
||||
}
|
||||
r.width = 0;
|
||||
return r;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a mapping from the view coordinate space to the logical
|
||||
* coordinate space of the model.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param a the allocated region to render into
|
||||
* @return the location within the model that best represents the
|
||||
* given point of view
|
||||
* @see View#viewToModel
|
||||
*/
|
||||
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias) {
|
||||
Rectangle alloc = (Rectangle) a;
|
||||
if (x < alloc.x + alloc.width) {
|
||||
bias[0] = Position.Bias.Forward;
|
||||
return getStartOffset();
|
||||
}
|
||||
bias[0] = Position.Bias.Backward;
|
||||
return getEndOffset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the view. (Ignored.)
|
||||
*
|
||||
* @param width the width
|
||||
* @param height the height
|
||||
*/
|
||||
public void setSize(float width, float height) {
|
||||
// Ignore this -- image size is determined by the tag attrs and
|
||||
// the image itself, not the surrounding layout!
|
||||
}
|
||||
|
||||
|
||||
// --- Static icon accessors -------------------------------------------
|
||||
|
||||
private Icon makeIcon(final String gifFile) throws IOException {
|
||||
/* Copy resource into a byte array. This is
|
||||
* necessary because several browsers consider
|
||||
* Class.getResource a security risk because it
|
||||
* can be used to load additional classes.
|
||||
* Class.getResourceAsStream just returns raw
|
||||
* bytes, which we can convert to an image.
|
||||
*/
|
||||
InputStream resource = MyImageView.class.getResourceAsStream(gifFile);
|
||||
|
||||
if (resource == null) {
|
||||
System.err.println(MyImageView.class.getName() + "/" +
|
||||
gifFile + " not found.");
|
||||
return null;
|
||||
}
|
||||
BufferedInputStream in =
|
||||
new BufferedInputStream(resource);
|
||||
ByteArrayOutputStream out =
|
||||
new ByteArrayOutputStream(1024);
|
||||
byte[] buffer = new byte[1024];
|
||||
int n;
|
||||
while ((n = in.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
in.close();
|
||||
out.flush();
|
||||
|
||||
buffer = out.toByteArray();
|
||||
if (buffer.length == 0) {
|
||||
System.err.println("warning: " + gifFile +
|
||||
" is zero-length");
|
||||
return null;
|
||||
}
|
||||
return new ImageIcon(buffer);
|
||||
}
|
||||
|
||||
private void loadIcons( ) {
|
||||
try{
|
||||
if( sPendingImageIcon == null )
|
||||
sPendingImageIcon = makeIcon(PENDING_IMAGE_SRC);
|
||||
if( sMissingImageIcon == null )
|
||||
sMissingImageIcon = makeIcon(MISSING_IMAGE_SRC);
|
||||
}catch( Exception x ) {
|
||||
System.err.println("ImageView: Couldn't load image icons");
|
||||
}
|
||||
}
|
||||
|
||||
protected StyleSheet getStyleSheet() {
|
||||
HTMLDocument doc = (HTMLDocument) getDocument();
|
||||
return doc.getStyleSheet();
|
||||
}
|
||||
|
||||
// --- member variables ------------------------------------------------
|
||||
|
||||
private AttributeSet attr;
|
||||
private Element fElement;
|
||||
private Image fImage;
|
||||
private int fHeight,fWidth;
|
||||
private Container fContainer;
|
||||
private Rectangle fBounds;
|
||||
private Component fComponent;
|
||||
private Point fGrowBase; // base of drag while growing image
|
||||
private boolean fGrowProportionally; // should grow be proportional?
|
||||
/** Set to true, while the receiver is locked, to indicate the reciever
|
||||
* is loading the image. This is used in imageUpdate. */
|
||||
private boolean loading;
|
||||
|
||||
// --- constants and static stuff --------------------------------
|
||||
|
||||
private static Icon sPendingImageIcon,
|
||||
sMissingImageIcon;
|
||||
private static final String
|
||||
PENDING_IMAGE_SRC = "icons/image-delayed.gif", // both stolen from HotJava
|
||||
MISSING_IMAGE_SRC = "icons/image-failed.gif";
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
//$ move this someplace public
|
||||
static final String IMAGE_CACHE_PROPERTY = "imageCache";
|
||||
|
||||
// Height/width to use before we know the real size:
|
||||
private static final int
|
||||
DEFAULT_WIDTH = 32,
|
||||
DEFAULT_HEIGHT= 32,
|
||||
// Default value of BORDER param: //? possibly move into stylesheet?
|
||||
DEFAULT_BORDER= 2;
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class SelectorBoxItem {
|
||||
|
||||
private String text;
|
||||
private Image icon;
|
||||
|
||||
public SelectorBoxItem (String text, Image icon){
|
||||
this.text = text;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public Image getIcon () {
|
||||
return icon;
|
||||
}
|
||||
public void setIcon (Image icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
public String getText () {
|
||||
return text;
|
||||
}
|
||||
public void setText (String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.main.utils.ImageLoader.ImageID;
|
||||
|
||||
public class Smily {
|
||||
|
||||
private ImageID imageID;
|
||||
|
||||
private String[] smilyStrings;
|
||||
|
||||
public Smily(String imagePath, String[] smilyStrings){
|
||||
|
||||
this.setImageID(imageID);
|
||||
|
||||
this.setSmilyStrings(smilyStrings);
|
||||
}
|
||||
|
||||
public ImageID getImageID() {
|
||||
|
||||
return imageID;
|
||||
}
|
||||
|
||||
public void setImageID(ImageID imageID) {
|
||||
|
||||
this.imageID = imageID;
|
||||
}
|
||||
|
||||
public String[] getSmilyStrings() {
|
||||
|
||||
return smilyStrings;
|
||||
}
|
||||
|
||||
public void setSmilyStrings(String[] smilyStrings) {
|
||||
|
||||
this.smilyStrings = smilyStrings;
|
||||
}
|
||||
|
||||
public String getDefaultString(){
|
||||
|
||||
return this.smilyStrings[0];
|
||||
}
|
||||
|
||||
public String getImagePath(){
|
||||
|
||||
return Images.getString(this.imageID.getId());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
|
||||
package net.java.sip.communicator.impl.gui.main.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
|
||||
public static String replaceSpecialRegExpChars(String text){
|
||||
|
||||
return text.replaceAll("([.()^&$*|])", "\\\\$1");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
EMPTY_16x16_ICON=../../resources/common/emptyIcon16x16.png
|
||||
QUICK_MENU_ADD_ICON=../../resources/buttons/addContactIcon.png
|
||||
QUICK_MENU_CONFIGURE_ICON=../../resources/buttons/configureIcon.png
|
||||
QUICK_MENU_SEARCH_ICON=../../resources/buttons/searchIcon.png
|
||||
QUICK_MENU_INFO_ICON=../../resources/buttons/infoIcon.png
|
||||
QUICK_MENU_BUTTON_BG=../../resources/buttons/quickMenuButtonBg.png
|
||||
QUICK_MENU_BUTTON_ROLLOVER_BG=../../resources/buttons/quickMenuButtonRolloverBg.png
|
||||
CALL_BUTTON_BG=../../resources/buttons/callButton.png
|
||||
HANGUP_BUTTON_BG=../../resources/buttons/hangupButton.png
|
||||
CALL_ROLLOVER_BUTTON_BG=../../resources/buttons/callButtonRollover.png
|
||||
CALL_PRESSED_BUTTON_BG=../../resources/buttons/callButtonPressed.png
|
||||
HANGUP_ROLLOVER_BUTTON_BG=../../resources/buttons/hangupButtonRollover.png
|
||||
HANGUP_PRESSED_BUTTON_BG=../../resources/buttons/hangupButtonPressed.png
|
||||
STATUS_SELECTOR_BOX=../../resources/buttons/combobox.png
|
||||
BUTTON_BG=../../resources/buttons/dialButtonBg.png
|
||||
BUTTON_ROLLOVER_BG=../../resources/buttons/dialButtonRolloverBg.png
|
||||
ONE_DIAL_BUTTON=../../resources/buttons/one.png
|
||||
TWO_DIAL_BUTTON=../../resources/buttons/two.png
|
||||
THREE_DIAL_BUTTON=../../resources/buttons/three.png
|
||||
FOUR_DIAL_BUTTON=../../resources/buttons/four.png
|
||||
FIVE_DIAL_BUTTON=../../resources/buttons/five.png
|
||||
SIX_DIAL_BUTTON=../../resources/buttons/six.png
|
||||
SEVEN_DIAL_BUTTON=../../resources/buttons/seven.png
|
||||
EIGHT_DIAL_BUTTON=../../resources/buttons/eight.png
|
||||
NINE_DIAL_BUTTON=../../resources/buttons/nine.png
|
||||
STAR_DIAL_BUTTON=../../resources/buttons/star.png
|
||||
ZERO_DIAL_BUTTON=../../resources/buttons/zero.png
|
||||
DIEZ_DIAL_BUTTON=../../resources/buttons/diez.png
|
||||
DEFAULT_USER_PHOTO=../../resources/common/personPhoto.png
|
||||
DEFAULT_CHAT_USER_PHOTO=../../resources/common/personPhotoChat.png
|
||||
CALL_PANEL_MINIMIZE_BUTTON=../../resources/buttons/callPanelMinimizeButton.png
|
||||
CALL_PANEL_RESTORE_BUTTON=../../resources/buttons/callPanelRestoreButton.png
|
||||
CALL_PANEL_MINIMIZE_ROLLOVER_BUTTON=../../resources/buttons/callPanelMinimizeButtonRollover.png
|
||||
CALL_PANEL_RESTORE_ROLLOVER_BUTTON=../../resources/buttons/callPanelRestoreButtonRollover.png
|
||||
ADD_TO_CHAT_BUTTON=../../resources/buttons/addToChat.png
|
||||
ADD_TO_CHAT_ROLLOVER_BUTTON=../../resources/buttons/addToChatRollover.png
|
||||
ADD_TO_CHAT_ICON=../../resources/buttons/addToChatIcon.png
|
||||
TOOLBAR_DIVIDER=../../resources/buttons/toolbarDivider.png
|
||||
RIGHT_ARROW_ICON=../../resources/common/rightArrow.png
|
||||
RIGHT_ARROW_ROLLOVER_ICON=../../resources/common/rightArrowRollover.png
|
||||
BOTTOM_ARROW_ICON=../../resources/common/bottomArrow.png
|
||||
BOTTOM_ARROW_ROLLOVER_ICON=../../resources/common/bottomArrowRollover.png
|
||||
ALIGN_LEFT_BUTTON=../../resources/buttons/alignLeft.png
|
||||
ALIGN_RIGHT_BUTTON=../../resources/buttons/alignRight.png
|
||||
ALIGN_CENTER_BUTTON=../../resources/buttons/alignCenter.png
|
||||
ALIGN_LEFT_ROLLOVER_BUTTON=../../resources/buttons/alignLeftRollover.png
|
||||
ALIGN_RIGHT_ROLLOVER_BUTTON=../../resources/buttons/alignRightRollover.png
|
||||
ALIGN_CENTER_ROLLOVER_BUTTON=../../resources/buttons/alignCenterRollover.png
|
||||
TEXT_BOLD_BUTTON=../../resources/buttons/textBold.png
|
||||
TEXT_ITALIC_BUTTON=../../resources/buttons/textItalic.png
|
||||
TEXT_UNDERLINED_BUTTON=../../resources/buttons/textUnderlined.png
|
||||
TEXT_BOLD_ROLLOVER_BUTTON=../../resources/buttons/textBoldRollover.png
|
||||
TEXT_ITALIC_ROLLOVER_BUTTON=../../resources/buttons/textItalicRollover.png
|
||||
TEXT_UNDERLINED_ROLLOVER_BUTTON=../../resources/buttons/textUnderlinedRollover.png
|
||||
|
||||
MSG_TOOLBAR_BUTTON_BG=../../resources/buttons/msgToolbarBg.png
|
||||
MSG_TOOLBAR_ROLLOVER_BUTTON_BG=../../resources/buttons/msgToolBarRolloverBg.png
|
||||
COPY_ICON=../../resources/buttons/copy.png
|
||||
CUT_ICON=../../resources/buttons/cut.png
|
||||
PASTE_ICON=../../resources/buttons/paste.png
|
||||
SMILIES_ICON=../../resources/buttons/smily.png
|
||||
SAVE_ICON=../../resources/buttons/save.png
|
||||
PRINT_ICON=../../resources/buttons/print.png
|
||||
CLOSE_ICON=../../resources/buttons/close.png
|
||||
QUIT_ICON=../../resources/buttons/quit.png
|
||||
PREVIOUS_ICON=../../resources/buttons/previous.png
|
||||
NEXT_ICON=../../resources/buttons/next.png
|
||||
HISTORY_ICON=../../resources/buttons/history.png
|
||||
SEND_FILE_ICON=../../resources/buttons/sendFile.png
|
||||
FONT_ICON=../../resources/buttons/fontIcon.png
|
||||
|
||||
CHAT_CONTACT_INFO_BUTTON=../../resources/buttons/chatInfoButton.png
|
||||
CHAT_CONTACT_INFO_ROLLOVER_BUTTON=../../resources/buttons/chatInfoButtonRollover.png
|
||||
CHAT_CONTACT_CALL_BUTTON=../../resources/buttons/chatCallButton.png
|
||||
CHAT_CONTACT_CALL_ROLLOVER_BUTTON=../../resources/buttons/chatCallButtonRollover.png
|
||||
CHAT_CONTACT_SEND_FILE_BUTTON=../../resources/buttons/chatSendFile.png
|
||||
CHAT_SEND_FILE_ROLLOVER_BUTTON=../../resources/buttons/chatSendFileRollover.png
|
||||
|
||||
WARNING_ICON=../../resources/common/warning.png
|
||||
|
||||
SEND_MESSAGE_16x16_ICON=../../resources/common/sendMessage16x16.png
|
||||
DELETE_16x16_ICON=../../resources/common/delete16x16.png
|
||||
HISTORY_16x16_ICON=../../resources/common/history16x16.png
|
||||
SEND_FILE_16x16_ICON=../../resources/common/sendFile16x16.png
|
||||
GROUPS_16x16_ICON=../../resources/common/groups16x16.png
|
||||
INFO_16x16_ICON=../../resources/common/userInfo16x16.png
|
||||
ADD_CONTACT_16x16_ICON=../../resources/common/addContact16x16.png
|
||||
RENAME_16x16_ICON=../../resources/common/rename16x16.png
|
||||
MORE_INFO_ICON=../../resources/common/moreInfo.png
|
||||
TOOLBAR_DRAG_ICON=../../resources/common/toolbarDragIcon.png
|
||||
|
||||
ICQ_LOGO=../../resources/protocols/icq/Icq16.png
|
||||
ICQ_FF_CHAT_ICON=../../resources/protocols/icq/cr16-action-icq_ffc.png
|
||||
ICQ_AWAY_ICON=../../resources/protocols/icq/cr16-action-icq_away.png
|
||||
ICQ_NA_ICON=../../resources/protocols/icq/cr16-action-icq_na.png
|
||||
ICQ_DND_ICON=../../resources/protocols/icq/cr16-action-icq_dnd.png
|
||||
ICQ_OCCUPIED_ICON=../../resources/protocols/icq/cr16-action-icq_occupied.png
|
||||
ICQ_OFFLINE_ICON=../../resources/protocols/icq/cr16-action-icq_offline.png
|
||||
ICQ_INVISIBLE_ICON=../../resources/protocols/icq/cr16-action-icq_invisible.png
|
||||
MSN_LOGO=../../resources/protocols/msn/Msn16.png
|
||||
AIM_LOGO=../../resources/protocols/aim/Aim16.png
|
||||
YAHOO_LOGO=../../resources/protocols/yahoo/Yahoo16.png
|
||||
JABBER_LOGO=../../resources/protocols/jabber/Jabber16.png
|
||||
SKYPE_LOGO=../../resources/protocols/skype/Skype16.png
|
||||
SIP_LOGO=../../resources/protocols/sip/sc_logo16x16.png
|
||||
SIP_ONLINE_ICON=../../resources/protocols/sip/onlineStatus.png
|
||||
SIP_OFFLINE_ICON=../../resources/protocols/sip/offlineStatus.png
|
||||
SIP_INVISIBLE_ICON=../../resources/protocols/sip/invisibleStatus.png
|
||||
SIP_AWAY_ICON=../../resources/protocols/sip/awayStatus.png
|
||||
SIP_NA_ICON=../../resources/protocols/sip/naStatus.png
|
||||
SIP_DND_ICON=../../resources/protocols/sip/dndStatus.png
|
||||
SIP_OCCUPIED_ICON=../../resources/protocols/sip/occupiedStatus.png
|
||||
SIP_CHAT_ICON=../../resources/protocols/sip/chatStatus.png
|
||||
USER_ONLINE_ICON=../../resources/protocols/sip/sc_user_online.png
|
||||
SMILY1=../../resources/common/smilies/default/smily1.gif
|
||||
SMILY2=../../resources/common/smilies/default/smily2.gif
|
||||
SMILY3=../../resources/common/smilies/default/smily3.gif
|
||||
SMILY4=../../resources/common/smilies/default/smily4.gif
|
||||
SMILY5=../../resources/common/smilies/default/smily5.gif
|
||||
SMILY6=../../resources/common/smilies/default/smily6.gif
|
||||
SMILY7=../../resources/common/smilies/default/smily7.gif
|
||||
SMILY8=../../resources/common/smilies/default/smily8.gif
|
||||
SMILY9=../../resources/common/smilies/default/smily9.gif
|
||||
SMILY10=../../resources/common/smilies/default/smily10.gif
|
||||
SMILY11=../../resources/common/smilies/default/smily11.gif
|
||||
SMILY12=../../resources/common/smilies/default/smily12.gif
|
||||
|
||||
|
||||
Loading…
Reference in new issue