import jalview.schemes.UserColourScheme;
import jalview.structure.StructureImportSettings;
import jalview.urls.IdOrgSettings;
+import jalview.util.ChannelProperties;
import jalview.util.ColorUtils;
import jalview.util.MessageManager;
import jalview.util.Platform;
// lcastor.addAppender(ap);
// jalview.bin.Cache.log.addAppender(ap);
// Tell the user that debug is enabled
- jalview.bin.Cache.log.debug("Jalview Debugging Output Follows.");
+ jalview.bin.Cache.log.debug(ChannelProperties.getProperty("app_name")
+ + " Debugging Output Follows.");
} catch (Exception ex)
{
System.err.println("Problems initializing the log4j system\n");
new BuildDetails(codeVersion, null, codeInstallation);
if (printVersion && reportVersion)
{
- System.out.println(
- "Jalview Version: " + codeVersion + codeInstallation);
+ System.out.println(ChannelProperties.getProperty("app_name")
+ + " Version: " + codeVersion + codeInstallation);
}
}
lvclient.addAppender(log.getAppender("JalviewLogger"));
// Tell the user that debug is enabled
- lvclient.debug("Jalview Vamsas Client Debugging Output Follows.");
+ lvclient.debug(ChannelProperties.getProperty("app_name")
+ + " Vamsas Client Debugging Output Follows.");
}
} catch (Exception e)
{
lgclient.addAppender(log.getAppender("JalviewLogger"));
// Tell the user that debug is enabled
- lgclient.debug("Jalview Groovy Client Debugging Output Follows.");
+ lgclient.debug(ChannelProperties.getProperty("app_name")
+ + " Groovy Client Debugging Output Follows.");
}
} catch (Error e)
{
.getConstructor(new Class[]
{ String.class, String.class, String.class })
.newInstance(new Object[]
- { "Jalview Desktop",
+ { ChannelProperties.getProperty("app_name") + " Desktop",
(vrs = jalview.bin.Cache.getProperty("VERSION") + "_"
+ jalview.bin.Cache.getDefault("BUILD_DATE",
"unknown")),
public static String getVersionDetailsForConsole()
{
StringBuilder sb = new StringBuilder();
- sb.append("Jalview Version: ");
+ sb.append(ChannelProperties.getProperty("app_name"))
+ .append(" Version: ");
sb.append(jalview.bin.Cache.getDefault("VERSION", "TEST"));
sb.append("\n");
- sb.append("Jalview Installation: ");
+ sb.append(ChannelProperties.getProperty("app_name"))
+ .append(" Installation: ");
sb.append(jalview.bin.Cache.getDefault("INSTALLATION", "unknown"));
sb.append("\n");
sb.append("Build Date: ");
import org.apache.log4j.SimpleLayout;
import jalview.bin.Cache;
+import jalview.util.ChannelProperties;
import jalview.util.MessageManager;
/**
textAppender = new Thread(this);
textAppender.setDaemon(true);
textAppender.start();
+
+ // set icons
+ frame.setIconImages(ChannelProperties.getIconList());
}
private void setChosenLogLevelCombo()
Rectangle bounds = desktop.getLastKnownDimensions("JAVA_CONSOLE_");
if (bounds == null)
{
- frame = initFrame("Jalview Java Console", desktop.getWidth() / 2,
- desktop.getHeight() / 4, desktop.getX(), desktop.getY());
+ frame = initFrame(
+ ChannelProperties.getProperty("app_name") + " Java Console",
+ desktop.getWidth() / 2, desktop.getHeight() / 4,
+ desktop.getX(), desktop.getY());
}
else
{
- frame = initFrame("Jalview Java Console", bounds.width, bounds.height,
- bounds.x, bounds.y);
+ frame = initFrame(
+ ChannelProperties.getProperty("app_name") + " Java Console",
+ bounds.width, bounds.height, bounds.x, bounds.y);
}
frame.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
// desktop.add(frame);
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
private static final String CHANNEL_PROPERTIES_FILENAME = "/channel_properties";
- private Properties channelProps = new Properties();
+ private static final Properties channelProps;
private static final Properties defaultProps;
- private Map<String, Image> imageMap = new HashMap<String, Image>();
+ private static Map<String, Image> imageMap = new HashMap<String, Image>();
- private static ChannelProperties instance;
-
- private boolean initDone = false;
+ private static final ArrayList<Image> iconList;
static
{
defaultProps.put("uod_banner", "/default_images/UoD_banner.png");
defaultProps.put("default_appbase",
"https://www.jalview.org/getdown/release/1.8");
- }
- private boolean init()
- {
- if (initDone)
- {
- return initDone;
- }
// load channel_properties
- URL channelPropsURL = getClass()
+ Properties tryChannelProps = new Properties();
+ URL channelPropsURL = ChannelProperties.class
.getResource(CHANNEL_PROPERTIES_FILENAME);
if (channelPropsURL == null)
{
- // fallback
+ // complete failure of channel_properties, set all properties to defaults
System.err.println("Failed to find '" + CHANNEL_PROPERTIES_FILENAME
- + "' filem using defaults");
- channelProps = defaultProps;
- return false;
+ + "' file, using defaults");
+ tryChannelProps = defaultProps;
}
else
{
try
{
InputStream channelPropsIS = channelPropsURL.openStream();
- channelProps.load(channelPropsIS);
+ tryChannelProps.load(channelPropsIS);
channelPropsIS.close();
} catch (IOException e)
{
Cache.log.warn(e.getMessage());
- return false;
+ // return false;
}
}
- initDone = true;
- return initDone;
- }
-
- private ChannelProperties()
- {
- init();
- }
-
- public static ChannelProperties getChannelProperties()
- {
- if (instance == null)
+ channelProps = tryChannelProps;
+
+ /*
+ * The following slight palava for caching an icon list is so that all sizes of icons
+ * are the same. i.e. if there are /any/ channel_properties icons to use, then _only_
+ * use those channel_properties icons, don't mix in class default icons for missing
+ * sizes. If there are _no_ (usable) channel icons then we can use the class default icons.
+ */
+ iconList = new ArrayList<Image>();
+ List<String> sizes = Arrays.asList("16", "32", "48", "64", "128", "256",
+ "512");
+ for (String size : sizes)
{
- instance = new ChannelProperties();
+ Image logo = null;
+ // not using defaults or class props first time through
+ logo = ChannelProperties.getImage("logo." + size, null, false);
+ if (logo != null)
+ {
+ iconList.add(logo);
+ }
+ }
+ // now add the class defaults if there were no channel icons defined
+ if (iconList.size() == 0)
+ {
+ for (String size : sizes)
+ {
+ Image logo = null;
+ String path = defaultProps.getProperty("logo." + size);
+ URL imageURL = ChannelProperties.class.getResource(path);
+ logo = new ImageIcon(imageURL).getImage();
+ if (logo != null)
+ {
+ iconList.add(logo);
+ }
+ }
}
- return instance;
}
private static Properties channelProps()
{
- return getChannelProperties().channelProps;
+ return channelProps;
}
private static Map<String, Image> imageMap()
{
- return getChannelProperties().imageMap;
+ return imageMap;
}
/*
return getProperty(key, defaultVal, false);
}
+ /*
+ * internal method. note that setting useClassDefaultProps=true will ignore the provided defaultVal
+ */
private static String getProperty(String key, String defaultVal,
boolean useClassDefaultProps)
{
return null;
}
+ /*
+ * getImage(key) returns the channel defined image for property key. If that is null (e.g. due to
+ * no defined channel image or the image file being corrupt/unusable/missing) it uses the image
+ * defined in defaultChannelProps
+ */
public static Image getImage(String key)
{
+ return getImage(key, null, true);
+ }
+
+ /*
+ * getImage(key, defaultImg) will get image associated with value from channel_properties for key.
+ * If no property or associated image for key is found (or is usable), it will return defaultImg
+ * and NOT fall back to the class defaultProps.
+ */
+ public static Image getImage(String key, Image defaultImg)
+ {
+ return getImage(key, defaultImg, false);
+ }
+
+ /*
+ * internal method. note that setting useClassDefaultImage=true will ignore the provided defaultImg
+ */
+ private static Image getImage(String key, Image defaultImg,
+ boolean useClassDefaultImage)
+ {
Image img = null;
if (imageMap().containsKey(key))
{
// Catch a previously untried or failed load
if (img == null)
{
- String path = getProperty(key);
- if (path == null)
+ String path = getProperty(key, null, useClassDefaultImage);
+ if (path == null) // no channel property or class default property (if
+ // requested)
{
- return null;
+ return useClassDefaultImage ? null : defaultImg;
}
- URL imageURL = getChannelProperties().getClass().getResource(path);
+
+ URL imageURL = ChannelProperties.class.getResource(path);
img = new ImageIcon(imageURL).getImage();
if (img == null)
{
System.err.println(
"Failed to load channel image " + key + "=" + path);
+ if (!useClassDefaultImage)
+ {
+ return defaultImg;
+ }
}
else
{
}
return img;
}
+
+ /*
+ * Get a List of Icon images of different sizes.
+ */
+ public static ArrayList<Image> getIconList()
+ {
+ return iconList;
+ }
}
\ No newline at end of file