pl.edu.agh.cast.resource
Class VisualResource

java.lang.Object
  extended by pl.edu.agh.cast.resource.VisualResource
All Implemented Interfaces:
IVisualResource

public class VisualResource
extends Object
implements IVisualResource

Default implementation of IVisualResource.

Author:
AGH CAST Team

Field Summary
 
Fields inherited from interface pl.edu.agh.cast.resource.IVisualResource
NAME_SEPARATOR
 
Constructor Summary
VisualResource(String id, String label, String description)
          Constructor with all required parameters.
VisualResource(String id, String label, String description, List<String> tags, String groupId, Type type)
          Constructor.
 
Method Summary
 void dispose()
          Disposes the resource.
 String getDescription()
          Gets localized resource description.
 String getGroupId()
          Returns group id.
 String getId()
          Gets resource id.
 org.eclipse.swt.graphics.Image getImage()
          Gets default image associated with the resource.
 org.eclipse.swt.graphics.Image getImage(ImageSize size)
          Gets default image associated with this resource with specified size.
 org.eclipse.swt.graphics.Image getImage(String variant)
          Gets a given variant of image in default size (see IVisualResource.getImage() method java doc for more details about how default size is chosen).
 org.eclipse.swt.graphics.Image getImage(String variant, ImageSize size)
          Gets a given variant of image in specified size.
 String getLabel()
          Gets localized resource label.
 List<String> getTags()
          Returns tags associated with the resource.
 Type getType()
          Returns type of element represented by the resource.
 org.eclipse.jface.resource.ImageDescriptor registerDefaultImageDesriptor(ImageSize size, org.eclipse.jface.resource.ImageDescriptor descriptor)
          Registers image descriptor for default image with specified size.
 org.eclipse.jface.resource.ImageDescriptor registerVariantImageDescriptor(String variant, ImageSize size, org.eclipse.jface.resource.ImageDescriptor descriptor)
          Registers image descriptor for variant with specified size.
protected  void setDescription(String description)
           
protected  void setGroupId(String groupId)
           
protected  void setId(String id)
           
protected  void setLabel(String label)
           
protected  void setTags(List<String> tags)
           
protected  void setType(Type type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VisualResource

public VisualResource(String id,
                      String label,
                      String description)
Constructor with all required parameters.

Parameters:
id - resource id
label - resource label
description - resource description

VisualResource

public VisualResource(String id,
                      String label,
                      String description,
                      List<String> tags,
                      String groupId,
                      Type type)
Constructor.

Parameters:
id - resource id
label - resource label
description - resource description
tags - resource tags
groupId - resource group id
type - type of described element or data set
Method Detail

registerDefaultImageDesriptor

public org.eclipse.jface.resource.ImageDescriptor registerDefaultImageDesriptor(ImageSize size,
                                                                                org.eclipse.jface.resource.ImageDescriptor descriptor)
                                                                         throws ResourceException
Registers image descriptor for default image with specified size. Descriptor and size cannot be equal to null. If an image descriptor has been already registered, it is overridden with a new one.

Parameters:
size - image size
descriptor - image descriptor
Returns:
image descriptor which was registered with the same size before (overridden one), null if there was no such image
Throws:
ResourceException - when image cannot be created
IllegalArgumentException - when at least one of the given arguments is null

registerVariantImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor registerVariantImageDescriptor(String variant,
                                                                                 ImageSize size,
                                                                                 org.eclipse.jface.resource.ImageDescriptor descriptor)
                                                                          throws ResourceException
Registers image descriptor for variant with specified size. All arguments cannot be null. If an image descriptor has been already registered, it is overridden with a new one.

Parameters:
variant - id of image variant
size - image size
descriptor - image descriptor
Returns:
image descriptor for specified variant which was registered with the same size before (overridden one), null if there was no such image
Throws:
ResourceException - when image cannot be created
IllegalArgumentException - when at least one of the given arguments is null

getDescription

public String getDescription()
Gets localized resource description.

Specified by:
getDescription in interface IVisualResource
Returns:
resource description
See Also:
IVisualResource.getDescription()

getGroupId

public String getGroupId()
Returns group id.

Specified by:
getGroupId in interface IVisualResource
Returns:
group id or null if the resource has no group.
See Also:
IVisualResource.getGroupId()

getId

public String getId()
Gets resource id. For resources representing type such as phone number, entity, etc the id should be equal to Type.toString(). In other cases the id should be unique string in Java package style.

Specified by:
getId in interface IVisualResource
Returns:
resource id
See Also:
IVisualResource.getId()

getImage

public org.eclipse.swt.graphics.Image getImage()
Gets default image associated with the resource. If the default image has only one size registered this version is returned, otherwise the default size (according to ImageSize.getDefaultSize() is searched and returned, if not found null is returned

Specified by:
getImage in interface IVisualResource
Returns:
default image, null if image not exists
See Also:
IVisualResource.getImage()

getImage

public org.eclipse.swt.graphics.Image getImage(ImageSize size)
Gets default image associated with this resource with specified size.

Specified by:
getImage in interface IVisualResource
Parameters:
size - image size
Returns:
image with specified size, null if image not exists
See Also:
IVisualResource.getImage(pl.edu.agh.cast.resource.ImageSize)

getImage

public org.eclipse.swt.graphics.Image getImage(String variant)
Gets a given variant of image in default size (see IVisualResource.getImage() method java doc for more details about how default size is chosen).

Specified by:
getImage in interface IVisualResource
Parameters:
variant - image variant
Returns:
a specified variant of the resource image, null if variant of image not exists
See Also:
IVisualResource.getImage(java.lang.String)

getImage

public org.eclipse.swt.graphics.Image getImage(String variant,
                                               ImageSize size)
Gets a given variant of image in specified size.

Specified by:
getImage in interface IVisualResource
Parameters:
variant - image variant
size - image size
Returns:
a specified variant of the resource image, null if image not exists
See Also:
IVisualResource.getImage(java.lang.String, pl.edu.agh.cast.resource.ImageSize)

getLabel

public String getLabel()
Gets localized resource label.

Specified by:
getLabel in interface IVisualResource
Returns:
resource label
See Also:
IVisualResource.getLabel()

getTags

public List<String> getTags()
Returns tags associated with the resource.

Specified by:
getTags in interface IVisualResource
Returns:
list of tags
See Also:
IVisualResource.getTags()

getType

public Type getType()
Returns type of element represented by the resource.

Specified by:
getType in interface IVisualResource
Returns:
element or data set type or null if the resource is not associated with any element
See Also:
IVisualResource.getType()

dispose

public void dispose()
Disposes the resource. It disposes all hold images.

Specified by:
dispose in interface IVisualResource
See Also:
IVisualResource.dispose()

setId

protected void setId(String id)
Parameters:
id - the id to set

setLabel

protected void setLabel(String label)
Parameters:
label - the label to set

setDescription

protected void setDescription(String description)
Parameters:
description - the description to set

setTags

protected void setTags(List<String> tags)
Parameters:
tags - the tags to set

setGroupId

protected void setGroupId(String groupId)
Parameters:
groupId - the groupId to set

setType

protected void setType(Type type)
Parameters:
type - the type to set


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.