uk.ac.kcl.cch.jb.pliny.imageRes
Class ImageResPlugin

java.lang.Object
  extended byorg.eclipse.core.runtime.Plugin
      extended byorg.eclipse.ui.plugin.AbstractUIPlugin
          extended byuk.ac.kcl.cch.jb.pliny.imageRes.ImageResPlugin
All Implemented Interfaces:
org.osgi.framework.BundleActivator

public class ImageResPlugin
extends org.eclipse.ui.plugin.AbstractUIPlugin

The main plugin class for Pliny's Image Editor to be used in the desktop. The plugin as a whole is a classic Eclipse plugin, and contains many basic Pliny elements including most of the model and UI code.

This plugin class itself, as well as supporting the usual base Eclipse functionality provides several Pliny-specific functions:

Author:
John Bradley

Field Summary
static String EDITOR_ID
           
static String PLUGIN_ID
           
 
Fields inherited from class org.eclipse.core.runtime.Plugin
PLUGIN_PREFERENCE_SCOPE, PREFERENCES_DEFAULT_OVERRIDE_BASE_NAME, PREFERENCES_DEFAULT_OVERRIDE_FILE_NAME
 
Constructor Summary
ImageResPlugin()
          The constructor.
 
Method Summary
 boolean cacheImage(URL url, int imageNo)
          fetches the image pointed to by the given URL and stores it in the image cache, with the given cache ID.
 org.eclipse.jface.resource.ImageDescriptor createThumbnail(org.eclipse.swt.graphics.ImageData data, String fname)
          creates a thumbnail size (120 pixels wide) version of the given imageData.
 File getCacheFile(URL url, int imageNo, String ext)
           
static ImageResPlugin getDefault()
          Returns the shared instance.
 org.eclipse.jface.resource.ImageDescriptor getFromImageCache(URL url, int imageNo, String ext)
          The main mechanism to use to fetch an image from the image Cache.
 File getImageCachePath()
          returns the full path to the directory where images are to be cached.
static org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(String path)
          Returns an image descriptor for the image file at the given plug-in relative path.
static ObjectType getImageObjectType()
          returns the ObjectType for image resources that the editor in this plugin can handle.
 String getLastExtension()
           
 String getStateLocationUrl(String objectName)
           
 org.eclipse.jface.resource.ImageDescriptor getThumbnailFromImageCache(URL url, int imageNo, String givenExt)
          fetches a thumbnail version of the image from the Image cache.
 void start(org.osgi.framework.BundleContext context)
          This method is called upon plug-in activation
 void stop(org.osgi.framework.BundleContext context)
          This method is called when the plug-in is stopped
 
Methods inherited from class org.eclipse.ui.plugin.AbstractUIPlugin
createImageRegistry, getDialogSettings, getImageRegistry, getPreferenceStore, getWorkbench, imageDescriptorFromPlugin, initializeDefaultPluginPreferences, initializeDefaultPreferences, initializeImageRegistry, loadDialogSettings, loadPreferenceStore, refreshPluginActions, saveDialogSettings, savePreferenceStore, shutdown, startup
 
Methods inherited from class org.eclipse.core.runtime.Plugin
find, find, getBundle, getDescriptor, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EDITOR_ID

public static String EDITOR_ID

PLUGIN_ID

public static String PLUGIN_ID
Constructor Detail

ImageResPlugin

public ImageResPlugin()
The constructor.

Method Detail

start

public void start(org.osgi.framework.BundleContext context)
           throws Exception
This method is called upon plug-in activation

Throws:
Exception

stop

public void stop(org.osgi.framework.BundleContext context)
          throws Exception
This method is called when the plug-in is stopped

Throws:
Exception

getDefault

public static ImageResPlugin getDefault()
Returns the shared instance.


getImageDescriptor

public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(String path)
Returns an image descriptor for the image file at the given plug-in relative path.

Parameters:
path - the path
Returns:
the image descriptor

getStateLocationUrl

public String getStateLocationUrl(String objectName)

getImageCachePath

public File getImageCachePath()
returns the full path to the directory where images are to be cached.

Returns:
File containing the Cache path

getLastExtension

public String getLastExtension()

getCacheFile

public File getCacheFile(URL url,
                         int imageNo,
                         String ext)

cacheImage

public boolean cacheImage(URL url,
                          int imageNo)
fetches the image pointed to by the given URL and stores it in the image cache, with the given cache ID.

Parameters:
url - a URL that points to the image to be cached
imageNo - a number that will act as an ID for this image in the cache in the future.

getFromImageCache

public org.eclipse.jface.resource.ImageDescriptor getFromImageCache(URL url,
                                                                    int imageNo,
                                                                    String ext)
The main mechanism to use to fetch an image from the image Cache. If the image is not in the cache, this code will fetch it, and store it there for future reference.

Parameters:
url - the URL that points to the image
imageNo - the Cache ID number
ext - the image extension (e.g. 'jpg' or 'png', etc.)
Returns:
an ImageDescriptor for the image.

createThumbnail

public org.eclipse.jface.resource.ImageDescriptor createThumbnail(org.eclipse.swt.graphics.ImageData data,
                                                                  String fname)
creates a thumbnail size (120 pixels wide) version of the given imageData.

Parameters:
data - ImageData of the image the thumbnail is to be created for.
fname - full file name to assign to the thumbnail image file.

getThumbnailFromImageCache

public org.eclipse.jface.resource.ImageDescriptor getThumbnailFromImageCache(URL url,
                                                                             int imageNo,
                                                                             String givenExt)
fetches a thumbnail version of the image from the Image cache. The thumbnail image is stored in the cache as well, and is created here if it has not been requested before.

Parameters:
url -
imageNo -
givenExt -

getImageObjectType

public static ObjectType getImageObjectType()
returns the ObjectType for image resources that the editor in this plugin can handle.

Returns:
the ObjectType for image resources.